From d8cc9415a40f479b666fc03e7b1f4601868e6dc8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:29:56 +0200 Subject: [PATCH 001/131] hwmon: constify pointers to hwmon_channel_info HWmon core receives an array of pointers to hwmon_channel_info and it does not modify it, thus it can be array of const pointers for safety. This allows drivers to make them also const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- Documentation/hwmon/hwmon-kernel-api.rst | 6 +++--- drivers/accel/habanalabs/common/hwmon.c | 2 +- drivers/hwmon/hwmon.c | 4 ++-- include/linux/hwmon.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/hwmon/hwmon-kernel-api.rst b/Documentation/hwmon/hwmon-kernel-api.rst index 5451a6d4c874be..f00e4a01c24042 100644 --- a/Documentation/hwmon/hwmon-kernel-api.rst +++ b/Documentation/hwmon/hwmon-kernel-api.rst @@ -133,7 +133,7 @@ The hwmon_chip_info structure looks as follows:: struct hwmon_chip_info { const struct hwmon_ops *ops; - const struct hwmon_channel_info **info; + const struct hwmon_channel_info * const *info; }; It contains the following fields: @@ -229,7 +229,7 @@ register (HWMON_T_MAX) as well as a maximum temperature hysteresis register .config = lm75_temp_config, }; - static const struct hwmon_channel_info *lm75_info[] = { + static const struct hwmon_channel_info * const lm75_info[] = { &lm75_chip, &lm75_temp, NULL @@ -238,7 +238,7 @@ register (HWMON_T_MAX) as well as a maximum temperature hysteresis register The HWMON_CHANNEL_INFO() macro can and should be used when possible. With this macro, the above example can be simplified to - static const struct hwmon_channel_info *lm75_info[] = { + static const struct hwmon_channel_info * const lm75_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, diff --git a/drivers/accel/habanalabs/common/hwmon.c b/drivers/accel/habanalabs/common/hwmon.c index 55eb0203817f17..8598056216e751 100644 --- a/drivers/accel/habanalabs/common/hwmon.c +++ b/drivers/accel/habanalabs/common/hwmon.c @@ -914,7 +914,7 @@ void hl_hwmon_fini(struct hl_device *hdev) void hl_hwmon_release_resources(struct hl_device *hdev) { - const struct hwmon_channel_info **channel_info_arr; + const struct hwmon_channel_info * const *channel_info_arr; int i = 0; if (!hdev->hl_chip_info->info) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index d193ed3cb35e5b..c7ebef1990c82e 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -174,7 +174,7 @@ static int hwmon_thermal_set_trips(struct thermal_zone_device *tz, int low, int struct hwmon_thermal_data *tdata = tz->devdata; struct hwmon_device *hwdev = to_hwmon_device(tdata->dev); const struct hwmon_chip_info *chip = hwdev->chip; - const struct hwmon_channel_info **info = chip->info; + const struct hwmon_channel_info * const *info = chip->info; unsigned int i; int err; @@ -253,7 +253,7 @@ static int hwmon_thermal_register_sensors(struct device *dev) { struct hwmon_device *hwdev = to_hwmon_device(dev); const struct hwmon_chip_info *chip = hwdev->chip; - const struct hwmon_channel_info **info = chip->info; + const struct hwmon_channel_info * const *info = chip->info; void *drvdata = dev_get_drvdata(dev); int i; diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h index c1b62384b6ee71..492dd27a5dd87f 100644 --- a/include/linux/hwmon.h +++ b/include/linux/hwmon.h @@ -430,7 +430,7 @@ struct hwmon_channel_info { */ struct hwmon_chip_info { const struct hwmon_ops *ops; - const struct hwmon_channel_info **info; + const struct hwmon_channel_info * const *info; }; /* hwmon_device_register() is deprecated */ From 0c072385348e3ac5229145644055d3e2afb5b3db Mon Sep 17 00:00:00 2001 From: Babu Moger Date: Thu, 13 Apr 2023 16:39:58 -0500 Subject: [PATCH 002/131] hwmon: (k10temp) Check range scale when CUR_TEMP register is read-write MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spec says, when CUR_TEMP_TJ_SEL == 3 and CUR_TEMP_RANGE_SEL == 0, it should use RangeUnadjusted is 0, which is (CurTmp*0.125 -49) C. The CUR_TEMP register is read-write when CUR_TEMP_TJ_SEL == 3 (bit 17-16). Add the check to detect it. Sensors command's output before the patch. $sensors k10temp-pci-00c3 Adapter: PCI adapter Tctl: +76.6°C <- Wrong value Tccd1: +26.5°C Tccd2: +27.5°C Tccd3: +27.2°C Tccd4: +27.5°C Tccd5: +26.0°C Tccd6: +26.2°C Tccd7: +25.0°C Tccd8: +26.5°C Sensors command's output after the patch. $sensors k10temp-pci-00c3 Adapter: PCI adapter Tctl: +28.8°C <- corrected value Tccd1: +27.5°C Tccd2: +28.5°C Tccd3: +28.5°C Tccd4: +28.5°C Tccd5: +27.0°C Tccd6: +27.5°C Tccd7: +27.0°C Tccd8: +27.5°C Signed-off-by: Babu Moger Fixes: 1b59788979ac ("hwmon: (k10temp) Add temperature offset for Ryzen 2700X") Link: https://lore.kernel.org/r/20230413213958.847634-1-babu.moger@amd.com Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 5a9d47a229e406..be8bbb1c3a02d9 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -75,6 +75,7 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); #define ZEN_CUR_TEMP_SHIFT 21 #define ZEN_CUR_TEMP_RANGE_SEL_MASK BIT(19) +#define ZEN_CUR_TEMP_TJ_SEL_MASK GENMASK(17, 16) struct k10temp_data { struct pci_dev *pdev; @@ -155,7 +156,8 @@ static long get_raw_temp(struct k10temp_data *data) data->read_tempreg(data->pdev, ®val); temp = (regval >> ZEN_CUR_TEMP_SHIFT) * 125; - if (regval & data->temp_adjust_mask) + if ((regval & data->temp_adjust_mask) || + (regval & ZEN_CUR_TEMP_TJ_SEL_MASK) == ZEN_CUR_TEMP_TJ_SEL_MASK) temp -= 49000; return temp; } From 8107fe93896dee8f159c8cb4ec8ec18656fbcd96 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sun, 12 Mar 2023 20:37:22 +0100 Subject: [PATCH 003/131] hwmon: (gpio-fan) drop of_match_ptr for ID table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The driver can match only via the DT table so the table should be always used and the of_match_ptr does not have any sense (this also allows ACPI matching via PRP0001, even though it might not be relevant here). This also fixes !CONFIG_OF error: drivers/hwmon/gpio-fan.c:484:34: error: ‘of_gpio_fan_match’ defined but not used [-Werror=unused-const-variable=] Note(groeck): The build error is only seen if Kconfig dependencies are messed up. The driver depends on OF_GPIO which should depend on OF. This was temporarily broken in linux-next, and it was possible to select CONFIG_OF=n and CONFIG_SENSORS_GPIO_FAN=y. Nevertheless, this is a sensible fix. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20230312193723.478032-1-krzysztof.kozlowski@linaro.org Signed-off-by: Guenter Roeck --- drivers/hwmon/gpio-fan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index e75db6f64e8cee..d92c536be9af78 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -586,7 +586,7 @@ static struct platform_driver gpio_fan_driver = { .driver = { .name = "gpio-fan", .pm = pm_sleep_ptr(&gpio_fan_pm), - .of_match_table = of_match_ptr(of_gpio_fan_match), + .of_match_table = of_gpio_fan_match, }, }; From 4a148e9b1ee04e608263fa9536a96214d5561220 Mon Sep 17 00:00:00 2001 From: Aleksandr Mezin Date: Sun, 19 Feb 2023 12:59:19 +0200 Subject: [PATCH 004/131] hwmon: (nzxt-smart2) add another USB ID This seems to be a new revision of the device. RGB controls have changed, but this driver doesn't touch them anyway. Fan speed control reported to be working with existing userspace (hidraw) software, so I assume it's compatible. Fan channel count is the same. Recently added (0x1e71, 0x2019) seems to be the same device. Discovered in liquidctl project: https://github.com/liquidctl/liquidctl/issues/541 Signed-off-by: Aleksandr Mezin Link: https://lore.kernel.org/r/20230219105924.333007-1-mezin.alexander@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nzxt-smart2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c index 2b93ba89610ae0..a8e72d8fd06050 100644 --- a/drivers/hwmon/nzxt-smart2.c +++ b/drivers/hwmon/nzxt-smart2.c @@ -791,7 +791,8 @@ static const struct hid_device_id nzxt_smart2_hid_id_table[] = { { HID_USB_DEVICE(0x1e71, 0x2009) }, /* NZXT RGB & Fan Controller */ { HID_USB_DEVICE(0x1e71, 0x200e) }, /* NZXT RGB & Fan Controller */ { HID_USB_DEVICE(0x1e71, 0x2010) }, /* NZXT RGB & Fan Controller */ - { HID_USB_DEVICE(0x1e71, 0x2019) }, /* NZXT RGB & Fan Controller */ + { HID_USB_DEVICE(0x1e71, 0x2011) }, /* NZXT RGB & Fan Controller (6 RGB) */ + { HID_USB_DEVICE(0x1e71, 0x2019) }, /* NZXT RGB & Fan Controller (6 RGB) */ {}, }; From 08d40c1d57b7127cfdebbc0648b57d54e38f2ba7 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 17 Feb 2023 21:16:00 +0200 Subject: [PATCH 005/131] hwmon: (nct6775) Drop unneeded casting and conjunction The 64-bit result will be cut to 32-bit automatically (by compiler) due to the type of the destination value. No need to have an explicit casting and especially additional conjunction which does the same. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20230217191600.24837-1-andriy.shevchenko@linux.intel.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index 76c6b564d7fc46..7576b8ffec676d 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -149,7 +149,7 @@ static int nct6775_asuswmi_evaluate_method(u32 method_id, u8 bank, u8 reg, u8 va return -EIO; if (retval) - *retval = (u32)result & 0xFFFFFFFF; + *retval = result; return 0; #else From 50c3480b6db859ce2c5f524eedb74973342455d0 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 10 Mar 2023 08:47:07 -0600 Subject: [PATCH 006/131] hwmon: (ltc4245) Use of_property_read_bool() for boolean properties It is preferred to use typed property access functions (i.e. of_property_read_ functions) rather than low-level of_get_property/of_find_property functions for reading properties. Convert reading boolean properties to of_property_read_bool(). Signed-off-by: Rob Herring Link: https://lore.kernel.org/r/20230310144707.1542525-1-robh@kernel.org Signed-off-by: Guenter Roeck --- drivers/hwmon/ltc4245.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ltc4245.c b/drivers/hwmon/ltc4245.c index 5088d28b3a7c30..57cbaf3b39faaf 100644 --- a/drivers/hwmon/ltc4245.c +++ b/drivers/hwmon/ltc4245.c @@ -434,7 +434,7 @@ static bool ltc4245_use_extra_gpios(struct i2c_client *client) return pdata->use_extra_gpios; /* fallback on OF */ - if (of_find_property(np, "ltc4245,use-extra-gpios", NULL)) + if (of_property_read_bool(np, "ltc4245,use-extra-gpios")) return true; return false; From 914b2fd2cd928f1eccd753e30707800b53acbeec Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 10 Mar 2023 08:47:06 -0600 Subject: [PATCH 007/131] hwmon: (ibmpowernv, pwm-fan) Use of_property_present() for testing DT property presence It is preferred to use typed property access functions (i.e. of_property_read_ functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more. Signed-off-by: Rob Herring Link: https://lore.kernel.org/r/20230310144706.1542434-1-robh@kernel.org Signed-off-by: Guenter Roeck --- drivers/hwmon/ibmpowernv.c | 4 ++-- drivers/hwmon/pwm-fan.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c index 8e3724728cce08..594254d6a72dde 100644 --- a/drivers/hwmon/ibmpowernv.c +++ b/drivers/hwmon/ibmpowernv.c @@ -456,9 +456,9 @@ static int populate_attr_groups(struct platform_device *pdev) */ if (!of_property_read_string(np, "label", &label)) sensor_groups[type].attr_count++; - if (of_find_property(np, "sensor-data-min", NULL)) + if (of_property_present(np, "sensor-data-min")) sensor_groups[type].attr_count++; - if (of_find_property(np, "sensor-data-max", NULL)) + if (of_property_present(np, "sensor-data-max")) sensor_groups[type].attr_count++; } diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 83a347ca35da5c..57928d27001562 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -427,7 +427,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev, struct device_node *np = dev->of_node; int num, i, ret; - if (!of_find_property(np, "cooling-levels", NULL)) + if (!of_property_present(np, "cooling-levels")) return 0; ret = of_property_count_u32_elems(np, "cooling-levels"); From 37ef30fbf2894e1acd5aa7cc1dccfc54039cecd5 Mon Sep 17 00:00:00 2001 From: Armin Wolf Date: Sun, 26 Feb 2023 02:48:30 +0100 Subject: [PATCH 008/131] hwmon: (ftsteutates) Update specifications website The Fujitsu OEM Mainboard business was acquired by Kontron, so the specifications of the Teutates chip was transferred to the new Kontron FTP server. Update the specifications website accordingly. The outdated sensors how-to was omitted. Signed-off-by: Armin Wolf Link: https://lore.kernel.org/r/20230226014830.10929-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck --- Documentation/hwmon/ftsteutates.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/hwmon/ftsteutates.rst b/Documentation/hwmon/ftsteutates.rst index b3bfec36661dc4..2abd16830c997f 100644 --- a/Documentation/hwmon/ftsteutates.rst +++ b/Documentation/hwmon/ftsteutates.rst @@ -36,7 +36,7 @@ correct path to the alarm file:: echo 0 >XXXX_alarm -Specification of the chip can be found here: +Specifications of the chip can be found at the `Kontron FTP Server `_ (username = "anonymous", no password required) +under the following path: -- ftp://ftp.ts.fujitsu.com/pub/Mainboard-OEM-Sales/Services/Software&Tools/Linux_SystemMonitoring&Watchdog&GPIO/BMC-Teutates_Specification_V1.21.pdf -- ftp://ftp.ts.fujitsu.com/pub/Mainboard-OEM-Sales/Services/Software&Tools/Linux_SystemMonitoring&Watchdog&GPIO/Fujitsu_mainboards-1-Sensors_HowTo-en-US.pdf + /Services/Software_Tools/Linux_SystemMonitoring_Watchdog_GPIO/BMC-Teutates_Specification_V1.21.pdf From dbfeafdad31c52da8965819a298ed3b0127025e7 Mon Sep 17 00:00:00 2001 From: Kang Chen Date: Mon, 27 Feb 2023 17:15:34 +0800 Subject: [PATCH 009/131] hwmon: (nzxt-smart2) handle failure of devm_add_action in nzxt_smart2_hid_probe 1. replace the devm_add_action with devm_add_action_or_reset to ensure the mutex lock can be destroyed when it fails. 2. use local wrapper function mutex_fini instead of mutex_destroy to avoid undefined behaviours. 3. add a check of devm_add_action_or_reset and return early when it fails. Link: https://lore.kernel.org/all/f5043281-9b3e-e454-16fe-ef4cde36dfdb@roeck-us.net Signed-off-by: Kang Chen Link: https://lore.kernel.org/r/20230227091534.907101-1-void0red@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nzxt-smart2.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c index a8e72d8fd06050..e5edf8071f398f 100644 --- a/drivers/hwmon/nzxt-smart2.c +++ b/drivers/hwmon/nzxt-smart2.c @@ -721,6 +721,11 @@ static int __maybe_unused nzxt_smart2_hid_reset_resume(struct hid_device *hdev) return init_device(drvdata, drvdata->update_interval); } +static void mutex_fini(void *lock) +{ + mutex_destroy(lock); +} + static int nzxt_smart2_hid_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -737,8 +742,9 @@ static int nzxt_smart2_hid_probe(struct hid_device *hdev, init_waitqueue_head(&drvdata->wq); mutex_init(&drvdata->mutex); - devm_add_action(&hdev->dev, (void (*)(void *))mutex_destroy, - &drvdata->mutex); + ret = devm_add_action_or_reset(&hdev->dev, mutex_fini, &drvdata->mutex); + if (ret) + return ret; ret = hid_parse(hdev); if (ret) From 92e58a87a26cd2fd7c12165e68d5bd53c8cfb122 Mon Sep 17 00:00:00 2001 From: Kang Chen Date: Mon, 27 Feb 2023 11:09:12 +0800 Subject: [PATCH 010/131] hwmon: (g762) add a check of devm_add_action in g762_of_clock_enable devm_add_action may fails, check it and do the cleanup. Signed-off-by: Kang Chen Link: https://lore.kernel.org/r/20230227030913.893004-1-void0red@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/g762.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/g762.c b/drivers/hwmon/g762.c index 64a0599b2da5c4..e2c3c34f06e808 100644 --- a/drivers/hwmon/g762.c +++ b/drivers/hwmon/g762.c @@ -620,7 +620,12 @@ static int g762_of_clock_enable(struct i2c_client *client) data = i2c_get_clientdata(client); data->clk = clk; - devm_add_action(&client->dev, g762_of_clock_disable, data); + ret = devm_add_action(&client->dev, g762_of_clock_disable, data); + if (ret) { + dev_err(&client->dev, "failed to add disable clock action\n"); + goto clk_unprep; + } + return 0; clk_unprep: From 90b86248d31eb3d56b243487c188d0f5a3d24fdb Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 27 Feb 2023 10:03:11 +0100 Subject: [PATCH 011/131] hwmon: (nct6775) ASUS PRIME Z590 boards support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tested on Z590M-PLUS. dmesg log: nct6775: Found NCT6798D or compatible chip at 0x2e:0x290 sensors output: nct6798-isa-0290 Adapter: ISA adapter in0: 672.00 mV (min = +0.00 V, max = +1.74 V) in1: 1000.00 mV (min = +0.00 V, max = +0.00 V) ALARM in2: 3.38 V (min = +0.00 V, max = +0.00 V) ALARM in3: 3.28 V (min = +0.00 V, max = +0.00 V) ALARM in4: 1.01 V (min = +0.00 V, max = +0.00 V) ALARM in5: 808.00 mV (min = +0.00 V, max = +0.00 V) ALARM in6: 1000.00 mV (min = +0.00 V, max = +0.00 V) ALARM in7: 3.38 V (min = +0.00 V, max = +0.00 V) ALARM in8: 3.20 V (min = +0.00 V, max = +0.00 V) ALARM in9: 528.00 mV (min = +0.00 V, max = +0.00 V) ALARM in10: 672.00 mV (min = +0.00 V, max = +0.00 V) ALARM in11: 528.00 mV (min = +0.00 V, max = +0.00 V) ALARM in12: 1.21 V (min = +0.00 V, max = +0.00 V) ALARM in13: 992.00 mV (min = +0.00 V, max = +0.00 V) ALARM in14: 1.02 V (min = +0.00 V, max = +0.00 V) ALARM fan1: 971 RPM (min = 0 RPM) fan2: 1525 RPM (min = 0 RPM) fan3: 0 RPM (min = 0 RPM) fan4: 1094 RPM (min = 0 RPM) fan5: 0 RPM (min = 0 RPM) fan6: 0 RPM (min = 0 RPM) fan7: 0 RPM (min = 0 RPM) SYSTIN: +36.0°C (high = +80.0°C, hyst = +75.0°C) sensor = thermistor CPUTIN: +40.0°C (high = +80.0°C, hyst = +75.0°C) sensor = thermistor AUXTIN0: +26.0°C sensor = thermistor AUXTIN1: +8.0°C sensor = thermistor AUXTIN2: +22.0°C sensor = thermistor AUXTIN3: +25.0°C sensor = thermistor PECI Agent 0 Calibration: +40.0°C PCH_CHIP_CPU_MAX_TEMP: +0.0°C PCH_CHIP_TEMP: +55.0°C PCH_CPU_TEMP: +0.0°C intrusion0: OK intrusion1: ALARM beep_enable: disabled Signed-off-by: Erik Ekman Link: https://lore.kernel.org/r/20230227090312.91091-1-erik@kryo.se Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index 7576b8ffec676d..24c67dbfa8ab2b 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -1122,6 +1122,9 @@ static const char * const asus_msi_boards[] = { "PRIME X670-P", "PRIME X670-P WIFI", "PRIME X670E-PRO WIFI", + "PRIME Z590-A", + "PRIME Z590-P", + "PRIME Z590M-PLUS", "Pro B660M-C-D4", "ProArt B660-CREATOR D4", "ProArt X670E-CREATOR WIFI", From d0450fc1e3960ef2cd9aeea1b525bb513ee387bb Mon Sep 17 00:00:00 2001 From: Leonard Anderweit Date: Tue, 14 Feb 2023 23:02:16 +0100 Subject: [PATCH 012/131] hwmon: (aquacomputer_d5next) Support one byte control values Add support for one byte control values. This extends aqc_set_ctrl_val() and aqc_get_ctrl_val() with a type. Currently supported types are AQC_8 (one byte) and AQC_BE16 (two bytes big endian). More types will be added in the future. Signed-off-by: Leonard Anderweit Link: https://lore.kernel.org/r/20230214220221.15003-2-leonard.anderweit@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/aquacomputer_d5next.c | 48 +++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 12682a610ce794..babfd998e70c99 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -70,6 +70,10 @@ static u8 secondary_ctrl_report[] = { /* Report IDs for legacy devices */ #define POWERADJUST3_STATUS_REPORT_ID 0x03 +/* Data types for reading and writing control reports */ +#define AQC_8 0 +#define AQC_BE16 1 + /* Info, sensor sizes and offsets for most Aquacomputer devices */ #define AQC_SERIAL_START 0x3 #define AQC_FIRMWARE_VERSION 0xD @@ -544,7 +548,7 @@ static int aqc_send_ctrl_data(struct aqc_data *priv) } /* Refreshes the control buffer and stores value at offset in val */ -static int aqc_get_ctrl_val(struct aqc_data *priv, int offset, long *val) +static int aqc_get_ctrl_val(struct aqc_data *priv, int offset, long *val, int type) { int ret; @@ -554,14 +558,23 @@ static int aqc_get_ctrl_val(struct aqc_data *priv, int offset, long *val) if (ret < 0) goto unlock_and_return; - *val = (s16)get_unaligned_be16(priv->buffer + offset); + switch (type) { + case AQC_BE16: + *val = (s16)get_unaligned_be16(priv->buffer + offset); + break; + case AQC_8: + *val = priv->buffer[offset]; + break; + default: + ret = -EINVAL; + } unlock_and_return: mutex_unlock(&priv->mutex); return ret; } -static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val) +static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type) { int ret; @@ -571,7 +584,19 @@ static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val) if (ret < 0) goto unlock_and_return; - put_unaligned_be16((s16)val, priv->buffer + offset); + switch (type) { + case AQC_BE16: + put_unaligned_be16((s16)val, priv->buffer + offset); + break; + case AQC_8: + priv->buffer[offset] = (u8)val; + break; + default: + ret = -EINVAL; + } + + if (ret < 0) + goto unlock_and_return; ret = aqc_send_ctrl_data(priv); @@ -775,7 +800,7 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, case hwmon_temp_offset: ret = aqc_get_ctrl_val(priv, priv->temp_ctrl_offset + - channel * AQC_SENSOR_SIZE, val); + channel * AQC_SENSOR_SIZE, val, AQC_BE16); if (ret < 0) return ret; @@ -791,7 +816,8 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, *val = priv->speed_input[channel]; break; case hwmon_fan_pulses: - ret = aqc_get_ctrl_val(priv, priv->flow_pulses_ctrl_offset, val); + ret = aqc_get_ctrl_val(priv, priv->flow_pulses_ctrl_offset, + val, AQC_BE16); if (ret < 0) return ret; break; @@ -804,7 +830,8 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, break; case hwmon_pwm: if (priv->fan_ctrl_offsets) { - ret = aqc_get_ctrl_val(priv, priv->fan_ctrl_offsets[channel], val); + ret = aqc_get_ctrl_val(priv, priv->fan_ctrl_offsets[channel], + val, AQC_BE16); if (ret < 0) return ret; @@ -877,7 +904,7 @@ static int aqc_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, val = clamp_val(val, -15000, 15000) / 10; ret = aqc_set_ctrl_val(priv, priv->temp_ctrl_offset + - channel * AQC_SENSOR_SIZE, val); + channel * AQC_SENSOR_SIZE, val, AQC_BE16); if (ret < 0) return ret; break; @@ -889,7 +916,8 @@ static int aqc_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, switch (attr) { case hwmon_fan_pulses: val = clamp_val(val, 10, 1000); - ret = aqc_set_ctrl_val(priv, priv->flow_pulses_ctrl_offset, val); + ret = aqc_set_ctrl_val(priv, priv->flow_pulses_ctrl_offset, + val, AQC_BE16); if (ret < 0) return ret; break; @@ -906,7 +934,7 @@ static int aqc_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, return pwm_value; ret = aqc_set_ctrl_val(priv, priv->fan_ctrl_offsets[channel], - pwm_value); + pwm_value, AQC_BE16); if (ret < 0) return ret; } From 4d09d155a5d1aa984cba70e52609a3587149a911 Mon Sep 17 00:00:00 2001 From: Leonard Anderweit Date: Tue, 14 Feb 2023 23:02:17 +0100 Subject: [PATCH 013/131] hwmon: (aquacomputer_d5next) Support writing multiple control values at once Add new function aqc_set_ctrl_vals() to support changing multiple control values at once while sending only one control report. Signed-off-by: Leonard Anderweit Link: https://lore.kernel.org/r/20230214220221.15003-3-leonard.anderweit@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/aquacomputer_d5next.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index babfd998e70c99..f0c036d38e91ae 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -574,9 +574,9 @@ static int aqc_get_ctrl_val(struct aqc_data *priv, int offset, long *val, int ty return ret; } -static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type) +static int aqc_set_ctrl_vals(struct aqc_data *priv, int *offsets, long *vals, int *types, int len) { - int ret; + int ret, i; mutex_lock(&priv->mutex); @@ -584,15 +584,17 @@ static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int typ if (ret < 0) goto unlock_and_return; - switch (type) { - case AQC_BE16: - put_unaligned_be16((s16)val, priv->buffer + offset); - break; - case AQC_8: - priv->buffer[offset] = (u8)val; - break; - default: - ret = -EINVAL; + for (i = 0; i < len; i++) { + switch (types[i]) { + case AQC_BE16: + put_unaligned_be16((s16)vals[i], priv->buffer + offsets[i]); + break; + case AQC_8: + priv->buffer[offsets[i]] = (u8)vals[i]; + break; + default: + ret = -EINVAL; + } } if (ret < 0) @@ -605,6 +607,11 @@ static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int typ return ret; } +static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type) +{ + return aqc_set_ctrl_vals(priv, &offset, &val, &type, 1); +} + static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr, int channel) { const struct aqc_data *priv = data; From b29090bac9358344804b6d2007d9ec68d252cda4 Mon Sep 17 00:00:00 2001 From: Leonard Anderweit Date: Tue, 14 Feb 2023 23:02:18 +0100 Subject: [PATCH 014/131] hwmon: (aquacomputer_d5next) Device dependent control report settings Add device dependent control report id, secondary control report id, secondary control report size and secondary control report for devices which need different control report settings. All currently supported devices use the same values. Signed-off-by: Leonard Anderweit Link: https://lore.kernel.org/r/20230214220221.15003-4-leonard.anderweit@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/aquacomputer_d5next.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index f0c036d38e91ae..535d2fc0e55cf6 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -441,6 +441,10 @@ struct aqc_data { const char *name; int status_report_id; /* Used for legacy devices, report is stored in buffer */ + int ctrl_report_id; + int secondary_ctrl_report_id; + int secondary_ctrl_report_size; + u8 *secondary_ctrl_report; int buffer_size; u8 *buffer; @@ -513,7 +517,7 @@ static int aqc_get_ctrl_data(struct aqc_data *priv) int ret; memset(priv->buffer, 0x00, priv->buffer_size); - ret = hid_hw_raw_request(priv->hdev, CTRL_REPORT_ID, priv->buffer, priv->buffer_size, + ret = hid_hw_raw_request(priv->hdev, priv->ctrl_report_id, priv->buffer, priv->buffer_size, HID_FEATURE_REPORT, HID_REQ_GET_REPORT); if (ret < 0) ret = -ENODATA; @@ -535,15 +539,15 @@ static int aqc_send_ctrl_data(struct aqc_data *priv) put_unaligned_be16(checksum, priv->buffer + priv->checksum_offset); /* Send the patched up report back to the device */ - ret = hid_hw_raw_request(priv->hdev, CTRL_REPORT_ID, priv->buffer, priv->buffer_size, + ret = hid_hw_raw_request(priv->hdev, priv->ctrl_report_id, priv->buffer, priv->buffer_size, HID_FEATURE_REPORT, HID_REQ_SET_REPORT); if (ret < 0) return ret; /* The official software sends this report after every change, so do it here as well */ - ret = hid_hw_raw_request(priv->hdev, SECONDARY_CTRL_REPORT_ID, secondary_ctrl_report, - SECONDARY_CTRL_REPORT_SIZE, HID_FEATURE_REPORT, - HID_REQ_SET_REPORT); + ret = hid_hw_raw_request(priv->hdev, priv->secondary_ctrl_report_id, + priv->secondary_ctrl_report, priv->secondary_ctrl_report_size, + HID_FEATURE_REPORT, HID_REQ_SET_REPORT); return ret; } @@ -1447,6 +1451,11 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->serial_number_start_offset = AQC_SERIAL_START; priv->firmware_version_offset = AQC_FIRMWARE_VERSION; + priv->ctrl_report_id = CTRL_REPORT_ID; + priv->secondary_ctrl_report_id = SECONDARY_CTRL_REPORT_ID; + priv->secondary_ctrl_report_size = SECONDARY_CTRL_REPORT_SIZE; + priv->secondary_ctrl_report = secondary_ctrl_report; + if (priv->kind == aquastreamult) priv->fan_structure = &aqc_aquastreamult_fan_structure; else From 6c83ccb10c49e4867299a7ad34a0712c72d1f1a4 Mon Sep 17 00:00:00 2001 From: Leonard Anderweit Date: Tue, 14 Feb 2023 23:02:19 +0100 Subject: [PATCH 015/131] hwmon: (aquacomputer_d5next) Add infrastructure for Aquaero control reports Add information on the Aquacomputer Aquaero control report and disable the control report checksum for Aquaero. The Aquaero does not use the checksum so it must be disabled to avoid overwriting the last two bytes of the control report. Signed-off-by: Leonard Anderweit Link: https://lore.kernel.org/r/20230214220221.15003-5-leonard.anderweit@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/aquacomputer_d5next.c | 31 ++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 535d2fc0e55cf6..eb185318098a97 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -56,6 +56,7 @@ static const char *const aqc_device_names[] = { #define SERIAL_PART_OFFSET 2 #define CTRL_REPORT_ID 0x03 +#define AQUAERO_CTRL_REPORT_ID 0x0b /* The HID report that the official software always sends * after writing values, currently same for all devices @@ -67,6 +68,14 @@ static u8 secondary_ctrl_report[] = { 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x34, 0xC6 }; +/* Secondary HID report values for Aquaero */ +#define AQUAERO_SECONDARY_CTRL_REPORT_ID 0x06 +#define AQUAERO_SECONDARY_CTRL_REPORT_SIZE 0x07 + +static u8 aquaero_secondary_ctrl_report[] = { + 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 +}; + /* Report IDs for legacy devices */ #define POWERADJUST3_STATUS_REPORT_ID 0x03 @@ -94,6 +103,7 @@ static u8 secondary_ctrl_report[] = { #define AQUAERO_NUM_VIRTUAL_SENSORS 8 #define AQUAERO_NUM_CALC_VIRTUAL_SENSORS 4 #define AQUAERO_NUM_FLOW_SENSORS 2 +#define AQUAERO_CTRL_REPORT_SIZE 0xa93 /* Sensor report offsets for Aquaero fan controllers */ #define AQUAERO_SENSOR_START 0x65 @@ -531,12 +541,16 @@ static int aqc_send_ctrl_data(struct aqc_data *priv) int ret; u16 checksum; - /* Init and xorout value for CRC-16/USB is 0xffff */ - checksum = crc16(0xffff, priv->buffer + priv->checksum_start, priv->checksum_length); - checksum ^= 0xffff; + /* Checksum is not needed for Aquaero */ + if (priv->kind != aquaero) { + /* Init and xorout value for CRC-16/USB is 0xffff */ + checksum = crc16(0xffff, priv->buffer + priv->checksum_start, + priv->checksum_length); + checksum ^= 0xffff; - /* Place the new checksum at the end of the report */ - put_unaligned_be16(checksum, priv->buffer + priv->checksum_offset); + /* Place the new checksum at the end of the report */ + put_unaligned_be16(checksum, priv->buffer + priv->checksum_offset); + } /* Send the patched up report back to the device */ ret = hid_hw_raw_request(priv->hdev, priv->ctrl_report_id, priv->buffer, priv->buffer_size, @@ -1280,6 +1294,8 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->num_flow_sensors = AQUAERO_NUM_FLOW_SENSORS; priv->flow_sensors_start_offset = AQUAERO_FLOW_SENSORS_START; + priv->buffer_size = AQUAERO_CTRL_REPORT_SIZE; + priv->temp_label = label_temp_sensors; priv->virtual_temp_label = label_virtual_temp_sensors; priv->calc_virt_temp_label = label_aquaero_calc_temp_sensors; @@ -1443,6 +1459,11 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->firmware_version_offset = AQUAERO_FIRMWARE_VERSION; priv->fan_structure = &aqc_aquaero_fan_structure; + + priv->ctrl_report_id = AQUAERO_CTRL_REPORT_ID; + priv->secondary_ctrl_report_id = AQUAERO_SECONDARY_CTRL_REPORT_ID; + priv->secondary_ctrl_report_size = AQUAERO_SECONDARY_CTRL_REPORT_SIZE; + priv->secondary_ctrl_report = aquaero_secondary_ctrl_report; break; case poweradjust3: priv->status_report_id = POWERADJUST3_STATUS_REPORT_ID; From 866e630a3b8b48688f0656e3c31da436493e8a99 Mon Sep 17 00:00:00 2001 From: Leonard Anderweit Date: Tue, 14 Feb 2023 23:02:20 +0100 Subject: [PATCH 016/131] hwmon: (aquacomputer_d5next) Add temperature offset control for Aquaero Adds control over the Aquacomputer Aquaero temperature offset for all eight temperature sensors. Signed-off-by: Leonard Anderweit Link: https://lore.kernel.org/r/20230214220221.15003-6-leonard.anderweit@gmail.com Signed-off-by: Guenter Roeck --- Documentation/hwmon/aquacomputer_d5next.rst | 4 ++-- drivers/hwmon/aquacomputer_d5next.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Documentation/hwmon/aquacomputer_d5next.rst b/Documentation/hwmon/aquacomputer_d5next.rst index 7d0d015b1a5284..618c826093a232 100644 --- a/Documentation/hwmon/aquacomputer_d5next.rst +++ b/Documentation/hwmon/aquacomputer_d5next.rst @@ -25,7 +25,7 @@ communicate through proprietary USB HID protocols. The Aquaero devices expose eight physical, eight virtual and four calculated virtual temperature sensors, as well as two flow sensors. The fans expose their -speed (in RPM), power, voltage and current. +speed (in RPM), power, voltage and current. Temperature offsets can be controlled. For the D5 Next pump, available sensors are pump and fan speed, power, voltage and current, as well as coolant temperature and eight virtual temp sensors. Also @@ -75,7 +75,7 @@ Sysfs entries ================ ============================================================== temp[1-20]_input Physical/virtual temperature sensors (in millidegrees Celsius) -temp[1-4]_offset Temperature sensor correction offset (in millidegrees Celsius) +temp[1-8]_offset Temperature sensor correction offset (in millidegrees Celsius) fan[1-8]_input Pump/fan speed (in RPM) / Flow speed (in dL/h) fan5_pulses Quadro flow sensor pulses power[1-8]_input Pump/fan power (in micro Watts) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index eb185318098a97..61c1ffcd8f3ba4 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -116,6 +116,9 @@ static u8 aquaero_secondary_ctrl_report[] = { #define AQUAERO_FAN_SPEED_OFFSET 0x00 static u16 aquaero_sensor_fan_offsets[] = { 0x167, 0x173, 0x17f, 0x18B }; +/* Control report offsets for the Aquaero fan controllers */ +#define AQUAERO_TEMP_CTRL_OFFSET 0xdb + /* Specs of the D5 Next pump */ #define D5NEXT_NUM_FANS 2 #define D5NEXT_NUM_SENSORS 1 @@ -988,10 +991,10 @@ static const struct hwmon_channel_info *aqc_info[] = { HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, - HWMON_T_INPUT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, @@ -1295,6 +1298,7 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->flow_sensors_start_offset = AQUAERO_FLOW_SENSORS_START; priv->buffer_size = AQUAERO_CTRL_REPORT_SIZE; + priv->temp_ctrl_offset = AQUAERO_TEMP_CTRL_OFFSET; priv->temp_label = label_temp_sensors; priv->virtual_temp_label = label_virtual_temp_sensors; From bd1e92f9977c78a04e9fe401e359feb67aacb7f9 Mon Sep 17 00:00:00 2001 From: Leonard Anderweit Date: Tue, 14 Feb 2023 23:02:21 +0100 Subject: [PATCH 017/131] hwmon: (aquacomputer_d5next) Add fan PWM control for Aquaero Add the option to control fan PWM on Aquacomputer Aquaero. The Aquaero is the most complex Aquacomputer device, control is therefore more complicated then on already supported devices. Setting PWM requires multiple steps. First, an internal static PWM controller is set to the desired PWM value. Second, the fan is set to use that PWM controller. Last, the minimum and maximum accepted PWM values of the fan are set to allow all possible PWM values. Signed-off-by: Leonard Anderweit Link: https://lore.kernel.org/r/20230214220221.15003-7-leonard.anderweit@gmail.com Signed-off-by: Guenter Roeck --- Documentation/hwmon/aquacomputer_d5next.rst | 3 +- drivers/hwmon/aquacomputer_d5next.c | 64 +++++++++++++++++++-- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/Documentation/hwmon/aquacomputer_d5next.rst b/Documentation/hwmon/aquacomputer_d5next.rst index 618c826093a232..c604d4becb8d1a 100644 --- a/Documentation/hwmon/aquacomputer_d5next.rst +++ b/Documentation/hwmon/aquacomputer_d5next.rst @@ -25,7 +25,8 @@ communicate through proprietary USB HID protocols. The Aquaero devices expose eight physical, eight virtual and four calculated virtual temperature sensors, as well as two flow sensors. The fans expose their -speed (in RPM), power, voltage and current. Temperature offsets can be controlled. +speed (in RPM), power, voltage and current. Temperature offsets and fan speeds +can be controlled. For the D5 Next pump, available sensors are pump and fan speed, power, voltage and current, as well as coolant temperature and eight virtual temp sensors. Also diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 61c1ffcd8f3ba4..17fad3142118f7 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -104,6 +104,9 @@ static u8 aquaero_secondary_ctrl_report[] = { #define AQUAERO_NUM_CALC_VIRTUAL_SENSORS 4 #define AQUAERO_NUM_FLOW_SENSORS 2 #define AQUAERO_CTRL_REPORT_SIZE 0xa93 +#define AQUAERO_CTRL_PRESET_ID 0x5c +#define AQUAERO_CTRL_PRESET_SIZE 0x02 +#define AQUAERO_CTRL_PRESET_START 0x55c /* Sensor report offsets for Aquaero fan controllers */ #define AQUAERO_SENSOR_START 0x65 @@ -118,6 +121,10 @@ static u16 aquaero_sensor_fan_offsets[] = { 0x167, 0x173, 0x17f, 0x18B }; /* Control report offsets for the Aquaero fan controllers */ #define AQUAERO_TEMP_CTRL_OFFSET 0xdb +#define AQUAERO_FAN_CTRL_MIN_PWR_OFFSET 0x04 +#define AQUAERO_FAN_CTRL_MAX_PWR_OFFSET 0x06 +#define AQUAERO_FAN_CTRL_SRC_OFFSET 0x10 +static u16 aquaero_ctrl_fan_offsets[] = { 0x20c, 0x220, 0x234, 0x248 }; /* Specs of the D5 Next pump */ #define D5NEXT_NUM_FANS 2 @@ -857,13 +864,23 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, *val = priv->power_input[channel]; break; case hwmon_pwm: - if (priv->fan_ctrl_offsets) { + switch (priv->kind) { + case aquaero: + ret = aqc_get_ctrl_val(priv, + AQUAERO_CTRL_PRESET_START + channel * AQUAERO_CTRL_PRESET_SIZE, + val, AQC_BE16); + if (ret < 0) + return ret; + *val = aqc_percent_to_pwm(*val); + break; + default: ret = aqc_get_ctrl_val(priv, priv->fan_ctrl_offsets[channel], val, AQC_BE16); if (ret < 0) return ret; *val = aqc_percent_to_pwm(ret); + break; } break; case hwmon_in: @@ -922,6 +939,10 @@ static int aqc_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, long val) { int ret, pwm_value; + /* Arrays for setting multiple values at once in the control report */ + int ctrl_values_offsets[4]; + long ctrl_values[4]; + int ctrl_values_types[4]; struct aqc_data *priv = dev_get_drvdata(dev); switch (type) { @@ -956,15 +977,47 @@ static int aqc_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, case hwmon_pwm: switch (attr) { case hwmon_pwm_input: - if (priv->fan_ctrl_offsets) { - pwm_value = aqc_pwm_to_percent(val); - if (pwm_value < 0) - return pwm_value; + pwm_value = aqc_pwm_to_percent(val); + if (pwm_value < 0) + return pwm_value; + switch (priv->kind) { + case aquaero: + /* Write pwm value to preset corresponding to the channel */ + ctrl_values_offsets[0] = AQUAERO_CTRL_PRESET_START + + channel * AQUAERO_CTRL_PRESET_SIZE; + ctrl_values[0] = pwm_value; + ctrl_values_types[0] = AQC_BE16; + + /* Write preset number in fan control source */ + ctrl_values_offsets[1] = priv->fan_ctrl_offsets[channel] + + AQUAERO_FAN_CTRL_SRC_OFFSET; + ctrl_values[1] = AQUAERO_CTRL_PRESET_ID + channel; + ctrl_values_types[1] = AQC_BE16; + + /* Set minimum power to 0 to allow the fan to turn off */ + ctrl_values_offsets[2] = priv->fan_ctrl_offsets[channel] + + AQUAERO_FAN_CTRL_MIN_PWR_OFFSET; + ctrl_values[2] = 0; + ctrl_values_types[2] = AQC_BE16; + + /* Set maximum power to 255 to allow the fan to reach max speed */ + ctrl_values_offsets[3] = priv->fan_ctrl_offsets[channel] + + AQUAERO_FAN_CTRL_MAX_PWR_OFFSET; + ctrl_values[3] = aqc_pwm_to_percent(255); + ctrl_values_types[3] = AQC_BE16; + + ret = aqc_set_ctrl_vals(priv, ctrl_values_offsets, ctrl_values, + ctrl_values_types, 4); + if (ret < 0) + return ret; + break; + default: ret = aqc_set_ctrl_val(priv, priv->fan_ctrl_offsets[channel], pwm_value, AQC_BE16); if (ret < 0) return ret; + break; } break; default: @@ -1287,6 +1340,7 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->num_fans = AQUAERO_NUM_FANS; priv->fan_sensor_offsets = aquaero_sensor_fan_offsets; + priv->fan_ctrl_offsets = aquaero_ctrl_fan_offsets; priv->num_temp_sensors = AQUAERO_NUM_SENSORS; priv->temp_sensor_start_offset = AQUAERO_SENSOR_START; From 7ab0da3a77fe62670877b986028861dc098532ae Mon Sep 17 00:00:00 2001 From: Naresh Solanki Date: Wed, 1 Mar 2023 17:44:31 +0100 Subject: [PATCH 018/131] hwmon: (pmbus/core) Generalize pmbus status flag map The PMBus status flag map(pmbus_regulator_status_flag_map) is moved outside of the regulator #if block and the associated variable/struct name updated to reflect as generic PMBus status. This will make the PMBus status flag map more versatile and easier to incorporate into different contexts and functions. Signed-off-by: Naresh Solanki Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20230301164434.1928237-1-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus_core.c | 94 ++++++++++++++++---------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 95e95783972abb..1b70cf3be31326 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2692,6 +2692,49 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, return 0; } +/* A PMBus status flag and the corresponding REGULATOR_ERROR_* flag */ +struct pmbus_status_assoc { + int pflag, rflag; +}; + +/* PMBus->regulator bit mappings for a PMBus status register */ +struct pmbus_status_category { + int func; + int reg; + const struct pmbus_status_assoc *bits; /* zero-terminated */ +}; + +static const struct pmbus_status_category __maybe_unused pmbus_status_flag_map[] = { + { + .func = PMBUS_HAVE_STATUS_VOUT, + .reg = PMBUS_STATUS_VOUT, + .bits = (const struct pmbus_status_assoc[]) { + { PB_VOLTAGE_UV_WARNING, REGULATOR_ERROR_UNDER_VOLTAGE_WARN }, + { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE }, + { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN }, + { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_REGULATION_OUT }, + { }, + }, + }, { + .func = PMBUS_HAVE_STATUS_IOUT, + .reg = PMBUS_STATUS_IOUT, + .bits = (const struct pmbus_status_assoc[]) { + { PB_IOUT_OC_WARNING, REGULATOR_ERROR_OVER_CURRENT_WARN }, + { PB_IOUT_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT }, + { PB_IOUT_OC_LV_FAULT, REGULATOR_ERROR_OVER_CURRENT }, + { }, + }, + }, { + .func = PMBUS_HAVE_STATUS_TEMP, + .reg = PMBUS_STATUS_TEMPERATURE, + .bits = (const struct pmbus_status_assoc[]) { + { PB_TEMP_OT_WARNING, REGULATOR_ERROR_OVER_TEMP_WARN }, + { PB_TEMP_OT_FAULT, REGULATOR_ERROR_OVER_TEMP }, + { }, + }, + }, +}; + #if IS_ENABLED(CONFIG_REGULATOR) static int pmbus_regulator_is_enabled(struct regulator_dev *rdev) { @@ -2738,54 +2781,11 @@ static int pmbus_regulator_disable(struct regulator_dev *rdev) return _pmbus_regulator_on_off(rdev, 0); } -/* A PMBus status flag and the corresponding REGULATOR_ERROR_* flag */ -struct pmbus_regulator_status_assoc { - int pflag, rflag; -}; - -/* PMBus->regulator bit mappings for a PMBus status register */ -struct pmbus_regulator_status_category { - int func; - int reg; - const struct pmbus_regulator_status_assoc *bits; /* zero-terminated */ -}; - -static const struct pmbus_regulator_status_category pmbus_regulator_flag_map[] = { - { - .func = PMBUS_HAVE_STATUS_VOUT, - .reg = PMBUS_STATUS_VOUT, - .bits = (const struct pmbus_regulator_status_assoc[]) { - { PB_VOLTAGE_UV_WARNING, REGULATOR_ERROR_UNDER_VOLTAGE_WARN }, - { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE }, - { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_REGULATION_OUT }, - { }, - }, - }, { - .func = PMBUS_HAVE_STATUS_IOUT, - .reg = PMBUS_STATUS_IOUT, - .bits = (const struct pmbus_regulator_status_assoc[]) { - { PB_IOUT_OC_WARNING, REGULATOR_ERROR_OVER_CURRENT_WARN }, - { PB_IOUT_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT }, - { PB_IOUT_OC_LV_FAULT, REGULATOR_ERROR_OVER_CURRENT }, - { }, - }, - }, { - .func = PMBUS_HAVE_STATUS_TEMP, - .reg = PMBUS_STATUS_TEMPERATURE, - .bits = (const struct pmbus_regulator_status_assoc[]) { - { PB_TEMP_OT_WARNING, REGULATOR_ERROR_OVER_TEMP_WARN }, - { PB_TEMP_OT_FAULT, REGULATOR_ERROR_OVER_TEMP }, - { }, - }, - }, -}; - static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned int *flags) { int i, status; - const struct pmbus_regulator_status_category *cat; - const struct pmbus_regulator_status_assoc *bit; + const struct pmbus_status_category *cat; + const struct pmbus_status_assoc *bit; struct device *dev = rdev_get_dev(rdev); struct i2c_client *client = to_i2c_client(dev->parent); struct pmbus_data *data = i2c_get_clientdata(client); @@ -2796,8 +2796,8 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned mutex_lock(&data->update_lock); - for (i = 0; i < ARRAY_SIZE(pmbus_regulator_flag_map); i++) { - cat = &pmbus_regulator_flag_map[i]; + for (i = 0; i < ARRAY_SIZE(pmbus_status_flag_map); i++) { + cat = &pmbus_status_flag_map[i]; if (!(func & cat->func)) continue; From df5f6b6af01ca326dd4babb287c9580fed0ad3d6 Mon Sep 17 00:00:00 2001 From: Naresh Solanki Date: Wed, 1 Mar 2023 17:44:32 +0100 Subject: [PATCH 019/131] hwmon: (pmbus/core) Generalise pmbus get status Add function pmbus get status that can be used to get both pmbus specific status & regulator status Signed-off-by: Naresh Solanki Reviewed-by: Guenter Roeck ... Change in V4 - None Changes in V3: - Add pmbus_is_enabled function Changes in V2: - Add __maybe attribute for pmbus_get_status function - Remove unrelated changes Link: https://lore.kernel.org/r/20230301164434.1928237-2-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus_core.c | 98 ++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 36 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 1b70cf3be31326..f8ac9016ea0e01 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2735,18 +2735,12 @@ static const struct pmbus_status_category __maybe_unused pmbus_status_flag_map[] }, }; -#if IS_ENABLED(CONFIG_REGULATOR) -static int pmbus_regulator_is_enabled(struct regulator_dev *rdev) +static int _pmbus_is_enabled(struct device *dev, u8 page) { - struct device *dev = rdev_get_dev(rdev); struct i2c_client *client = to_i2c_client(dev->parent); - struct pmbus_data *data = i2c_get_clientdata(client); - u8 page = rdev_get_id(rdev); int ret; - mutex_lock(&data->update_lock); ret = _pmbus_read_byte_data(client, page, PMBUS_OPERATION); - mutex_unlock(&data->update_lock); if (ret < 0) return ret; @@ -2754,58 +2748,38 @@ static int pmbus_regulator_is_enabled(struct regulator_dev *rdev) return !!(ret & PB_OPERATION_CONTROL_ON); } -static int _pmbus_regulator_on_off(struct regulator_dev *rdev, bool enable) +static int __maybe_unused pmbus_is_enabled(struct device *dev, u8 page) { - struct device *dev = rdev_get_dev(rdev); struct i2c_client *client = to_i2c_client(dev->parent); struct pmbus_data *data = i2c_get_clientdata(client); - u8 page = rdev_get_id(rdev); int ret; mutex_lock(&data->update_lock); - ret = pmbus_update_byte_data(client, page, PMBUS_OPERATION, - PB_OPERATION_CONTROL_ON, - enable ? PB_OPERATION_CONTROL_ON : 0); + ret = _pmbus_is_enabled(dev, page); mutex_unlock(&data->update_lock); - return ret; -} - -static int pmbus_regulator_enable(struct regulator_dev *rdev) -{ - return _pmbus_regulator_on_off(rdev, 1); -} - -static int pmbus_regulator_disable(struct regulator_dev *rdev) -{ - return _pmbus_regulator_on_off(rdev, 0); + return !!(ret & PB_OPERATION_CONTROL_ON); } -static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned int *flags) +static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags) { int i, status; const struct pmbus_status_category *cat; const struct pmbus_status_assoc *bit; - struct device *dev = rdev_get_dev(rdev); - struct i2c_client *client = to_i2c_client(dev->parent); - struct pmbus_data *data = i2c_get_clientdata(client); - u8 page = rdev_get_id(rdev); + struct device *dev = data->dev; + struct i2c_client *client = to_i2c_client(dev); int func = data->info->func[page]; *flags = 0; - mutex_lock(&data->update_lock); - for (i = 0; i < ARRAY_SIZE(pmbus_status_flag_map); i++) { cat = &pmbus_status_flag_map[i]; if (!(func & cat->func)) continue; status = _pmbus_read_byte_data(client, page, cat->reg); - if (status < 0) { - mutex_unlock(&data->update_lock); + if (status < 0) return status; - } for (bit = cat->bits; bit->pflag; bit++) { if (status & bit->pflag) @@ -2823,11 +2797,10 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned * REGULATOR_ERROR__WARN. */ status = pmbus_get_status(client, page, PMBUS_STATUS_WORD); - mutex_unlock(&data->update_lock); if (status < 0) return status; - if (pmbus_regulator_is_enabled(rdev)) { + if (_pmbus_is_enabled(dev, page)) { if (status & PB_STATUS_OFF) *flags |= REGULATOR_ERROR_FAIL; @@ -2855,6 +2828,59 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned return 0; } +static int __maybe_unused pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags) +{ + int ret; + + mutex_lock(&data->update_lock); + ret = _pmbus_get_flags(data, page, flags); + mutex_unlock(&data->update_lock); + + return ret; +} + +#if IS_ENABLED(CONFIG_REGULATOR) +static int pmbus_regulator_is_enabled(struct regulator_dev *rdev) +{ + return pmbus_is_enabled(rdev_get_dev(rdev), rdev_get_id(rdev)); +} + +static int _pmbus_regulator_on_off(struct regulator_dev *rdev, bool enable) +{ + struct device *dev = rdev_get_dev(rdev); + struct i2c_client *client = to_i2c_client(dev->parent); + struct pmbus_data *data = i2c_get_clientdata(client); + u8 page = rdev_get_id(rdev); + int ret; + + mutex_lock(&data->update_lock); + ret = pmbus_update_byte_data(client, page, PMBUS_OPERATION, + PB_OPERATION_CONTROL_ON, + enable ? PB_OPERATION_CONTROL_ON : 0); + mutex_unlock(&data->update_lock); + + return ret; +} + +static int pmbus_regulator_enable(struct regulator_dev *rdev) +{ + return _pmbus_regulator_on_off(rdev, 1); +} + +static int pmbus_regulator_disable(struct regulator_dev *rdev) +{ + return _pmbus_regulator_on_off(rdev, 0); +} + +static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned int *flags) +{ + struct device *dev = rdev_get_dev(rdev); + struct i2c_client *client = to_i2c_client(dev->parent); + struct pmbus_data *data = i2c_get_clientdata(client); + + return pmbus_get_flags(data, rdev_get_id(rdev), flags); +} + static int pmbus_regulator_get_status(struct regulator_dev *rdev) { struct device *dev = rdev_get_dev(rdev); From 221819ca4c36e13a77475af56e8481dfb0a85646 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Wed, 1 Mar 2023 17:44:33 +0100 Subject: [PATCH 020/131] hwmon: (pmbus/core) Add interrupt support Implement PMBUS irq handler. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki Link: https://lore.kernel.org/r/20230301164434.1928237-3-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus.h | 2 +- drivers/hwmon/pmbus/pmbus_core.c | 70 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 713ea79154259b..11e84e1411266d 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -26,7 +26,7 @@ enum pmbus_regs { PMBUS_CAPABILITY = 0x19, PMBUS_QUERY = 0x1A, - + PMBUS_SMBALERT_MASK = 0x1B, PMBUS_VOUT_MODE = 0x20, PMBUS_VOUT_COMMAND = 0x21, PMBUS_VOUT_TRIM = 0x22, diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index f8ac9016ea0e01..dfd227459d8bbf 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3105,6 +3105,72 @@ static int pmbus_regulator_register(struct pmbus_data *data) } #endif +static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, u8 val) +{ + return pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); +} + +static irqreturn_t pmbus_fault_handler(int irq, void *pdata) +{ + struct pmbus_data *data = pdata; + struct i2c_client *client = to_i2c_client(data->dev); + + mutex_lock(&data->update_lock); + /* TODO: Check status flag & notify hwmon events */ + + pmbus_clear_faults(client); + mutex_unlock(&data->update_lock); + + return IRQ_HANDLED; +} + +static int pmbus_irq_setup(struct i2c_client *client, struct pmbus_data *data) +{ + struct device *dev = &client->dev; + const struct pmbus_status_category *cat; + const struct pmbus_status_assoc *bit; + int i, j, err, func; + u8 mask; + + static const u8 misc_status[] = {PMBUS_STATUS_CML, PMBUS_STATUS_OTHER, + PMBUS_STATUS_MFR_SPECIFIC, PMBUS_STATUS_FAN_12, + PMBUS_STATUS_FAN_34}; + + if (!client->irq) + return 0; + + for (i = 0; i < data->info->pages; i++) { + func = data->info->func[i]; + + for (j = 0; j < ARRAY_SIZE(pmbus_status_flag_map); j++) { + cat = &pmbus_status_flag_map[j]; + if (!(func & cat->func)) + continue; + mask = 0; + for (bit = cat->bits; bit->pflag; bit++) + mask |= bit->pflag; + + err = pmbus_write_smbalert_mask(client, i, cat->reg, ~mask); + if (err) + dev_dbg_once(dev, "Failed to set smbalert for reg 0x%02x\n", + cat->reg); + } + + for (j = 0; j < ARRAY_SIZE(misc_status); j++) + pmbus_write_smbalert_mask(client, i, misc_status[j], 0xff); + } + + /* Register notifiers */ + err = devm_request_threaded_irq(dev, client->irq, NULL, pmbus_fault_handler, 0, + "pmbus-irq", data); + if (err) { + dev_err(dev, "failed to request an irq %d\n", err); + return err; + } + + return 0; +} + static struct dentry *pmbus_debugfs_dir; /* pmbus debugfs directory */ #if IS_ENABLED(CONFIG_DEBUG_FS) @@ -3467,6 +3533,10 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info) if (ret) return ret; + ret = pmbus_irq_setup(client, data); + if (ret) + return ret; + ret = pmbus_init_debugfs(client, data); if (ret) dev_warn(dev, "Failed to register debugfs\n"); From f469bde9afd136598a0c4edc054296e6046f90ee Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Wed, 1 Mar 2023 17:44:34 +0100 Subject: [PATCH 021/131] hwmon: (pmbus/core) Notify hwmon events Notify hwmon events using the pmbus irq handler. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki Link: https://lore.kernel.org/r/20230301164434.1928237-4-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus_core.c | 46 +++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index dfd227459d8bbf..0ddef2c9ba9bf0 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2761,7 +2761,35 @@ static int __maybe_unused pmbus_is_enabled(struct device *dev, u8 page) return !!(ret & PB_OPERATION_CONTROL_ON); } -static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags) +#define to_dev_attr(_dev_attr) \ + container_of(_dev_attr, struct device_attribute, attr) + +static void pmbus_notify(struct pmbus_data *data, int page, int reg, int flags) +{ + int i; + + for (i = 0; i < data->num_attributes; i++) { + struct device_attribute *da = to_dev_attr(data->group.attrs[i]); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + int index = attr->index; + u16 smask = pb_index_to_mask(index); + u8 spage = pb_index_to_page(index); + u16 sreg = pb_index_to_reg(index); + + if (reg == sreg && page == spage && (smask & flags)) { + dev_dbg(data->dev, "sysfs notify: %s", da->attr.name); + sysfs_notify(&data->dev->kobj, NULL, da->attr.name); + kobject_uevent(&data->dev->kobj, KOBJ_CHANGE); + flags &= ~smask; + } + + if (!flags) + break; + } +} + +static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags, + bool notify) { int i, status; const struct pmbus_status_category *cat; @@ -2785,6 +2813,10 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag if (status & bit->pflag) *flags |= bit->rflag; } + + if (notify && status) + pmbus_notify(data, page, cat->reg, status); + } /* @@ -2828,12 +2860,13 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag return 0; } -static int __maybe_unused pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags) +static int __maybe_unused pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags, + bool notify) { int ret; mutex_lock(&data->update_lock); - ret = _pmbus_get_flags(data, page, flags); + ret = _pmbus_get_flags(data, page, flags, notify); mutex_unlock(&data->update_lock); return ret; @@ -2878,7 +2911,7 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned struct i2c_client *client = to_i2c_client(dev->parent); struct pmbus_data *data = i2c_get_clientdata(client); - return pmbus_get_flags(data, rdev_get_id(rdev), flags); + return pmbus_get_flags(data, rdev_get_id(rdev), flags, false); } static int pmbus_regulator_get_status(struct regulator_dev *rdev) @@ -3114,9 +3147,10 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) { struct pmbus_data *data = pdata; struct i2c_client *client = to_i2c_client(data->dev); - + int i, status; mutex_lock(&data->update_lock); - /* TODO: Check status flag & notify hwmon events */ + for (i = 0; i < data->info->pages; i++) + _pmbus_get_flags(data, i, &status, true); pmbus_clear_faults(client); mutex_unlock(&data->update_lock); From 9fadbda6d1e0c1022fc77fa14461d1f475b83510 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sun, 12 Mar 2023 16:57:14 +0100 Subject: [PATCH 022/131] docs: hwmon: sysfs-interface: Fix stray colon The commit 036d6a4e75c9 ("ABI: sysfs-class-hwmon: add ABI documentation for it") moved all ABI attributes to the usual ABI documentation. But this change left a stray colon for the fan speed control method. Fix this to avoid a confusion of readers. Fixes: 036d6a4e75c9 ("ABI: sysfs-class-hwmon: add ABI documentation for it") Signed-off-by: Stefan Wahren Link: https://lore.kernel.org/r/20230312155714.17290-1-stefan.wahren@i2se.com Signed-off-by: Guenter Roeck --- Documentation/hwmon/sysfs-interface.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/hwmon/sysfs-interface.rst b/Documentation/hwmon/sysfs-interface.rst index 209626fb24052c..f76e9f8cc1adae 100644 --- a/Documentation/hwmon/sysfs-interface.rst +++ b/Documentation/hwmon/sysfs-interface.rst @@ -201,7 +201,7 @@ PWM Pulse width modulation fan control. `pwm[1-*]_enable` - Fan speed control method: + Fan speed control method. `pwm[1-*]_mode` direct current or pulse-width modulation. From aededf875a233b2b890af0000aa1b8f17b5351a0 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 15 Mar 2023 14:41:30 -0700 Subject: [PATCH 023/131] Documentation/hwmon: Remove description of deprecated registration functions Remove description of deprecated registration functions from the hardware monitoring kernel API documentation to help ensure that no attempts are made to use them in new drivers. Signed-off-by: Guenter Roeck --- Documentation/hwmon/hwmon-kernel-api.rst | 60 +++++++----------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/Documentation/hwmon/hwmon-kernel-api.rst b/Documentation/hwmon/hwmon-kernel-api.rst index f00e4a01c24042..c2d1e0299d8d84 100644 --- a/Documentation/hwmon/hwmon-kernel-api.rst +++ b/Documentation/hwmon/hwmon-kernel-api.rst @@ -19,20 +19,10 @@ also read Documentation/hwmon/submitting-patches.rst. The API ------- -Each hardware monitoring driver must #include and, in most +Each hardware monitoring driver must #include and, in some cases, . linux/hwmon.h declares the following register/unregister functions:: - struct device * - hwmon_device_register_with_groups(struct device *dev, const char *name, - void *drvdata, - const struct attribute_group **groups); - - struct device * - devm_hwmon_device_register_with_groups(struct device *dev, - const char *name, void *drvdata, - const struct attribute_group **groups); - struct device * hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, @@ -54,46 +44,30 @@ register/unregister functions:: char *devm_hwmon_sanitize_name(struct device *dev, const char *name); -hwmon_device_register_with_groups registers a hardware monitoring device. -The first parameter of this function is a pointer to the parent device. -The name parameter is a pointer to the hwmon device name. The registration -function will create a name sysfs attribute pointing to this name. -The drvdata parameter is the pointer to the local driver data. -hwmon_device_register_with_groups will attach this pointer to the newly -allocated hwmon device. The pointer can be retrieved by the driver using -dev_get_drvdata() on the hwmon device pointer. The groups parameter is -a pointer to a list of sysfs attribute groups. The list must be NULL terminated. -hwmon_device_register_with_groups creates the hwmon device with name attribute -as well as all sysfs attributes attached to the hwmon device. -This function returns a pointer to the newly created hardware monitoring device -or PTR_ERR for failure. - -devm_hwmon_device_register_with_groups is similar to -hwmon_device_register_with_groups. However, it is device managed, meaning the -hwmon device does not have to be removed explicitly by the removal function. - -hwmon_device_register_with_info is the most comprehensive and preferred means -to register a hardware monitoring device. It creates the standard sysfs -attributes in the hardware monitoring core, letting the driver focus on reading -from and writing to the chip instead of having to bother with sysfs attributes. -The parent device parameter as well as the chip parameter must not be NULL. Its -parameters are described in more detail below. +hwmon_device_register_with_info registers a hardware monitoring device. +It creates the standard sysfs attributes in the hardware monitoring core, +letting the driver focus on reading from and writing to the chip instead +of having to bother with sysfs attributes. The parent device parameter +as well as the chip parameter must not be NULL. Its parameters are described +in more detail below. devm_hwmon_device_register_with_info is similar to hwmon_device_register_with_info. However, it is device managed, meaning the hwmon device does not have to be removed explicitly by the removal function. +All other hardware monitoring device registration functions are deprecated +and must not be used in new drivers. + hwmon_device_unregister deregisters a registered hardware monitoring device. The parameter of this function is the pointer to the registered hardware monitoring device structure. This function must be called from the driver remove function if the hardware monitoring device was registered with -hwmon_device_register_with_groups or hwmon_device_register_with_info. +hwmon_device_register_with_info. devm_hwmon_device_unregister does not normally have to be called. It is only needed for error handling, and only needed if the driver probe fails after -the call to devm_hwmon_device_register_with_groups or -hwmon_device_register_with_info and if the automatic (device managed) -removal would be too late. +the call to hwmon_device_register_with_info and if the automatic (device +managed) removal would be too late. All supported hwmon device registration functions only accept valid device names. Device names including invalid characters (whitespace, '*', or '-') @@ -351,11 +325,9 @@ Return value: Driver-provided sysfs attributes -------------------------------- -If the hardware monitoring device is registered with -hwmon_device_register_with_info or devm_hwmon_device_register_with_info, -it is most likely not necessary to provide sysfs attributes. Only additional -non-standard sysfs attributes need to be provided when one of those registration -functions is used. +In most situations it should not be necessary for a driver to provide sysfs +attributes since the hardware monitoring core creates those internally. +Only additional non-standard sysfs attributes need to be provided. The header file linux/hwmon-sysfs.h provides a number of useful macros to declare and use hardware monitoring sysfs attributes. From ea00552690bb408a8d1c361edf626d1bfe961f74 Mon Sep 17 00:00:00 2001 From: Holger Kiehl Date: Mon, 13 Mar 2023 13:10:31 +0000 Subject: [PATCH 024/131] hwmon: (nct6775) add Asus Pro A520M-C II/CSM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An NCT6798D chip is now detected: dmesg|grep nct6775 [ 23.765392] nct6775: Found NCT6798D or compatible chip at 0x2e:0x290 And sensors now shows: nct6798-isa-0290 Adapter: ISA adapter in0: 312.00 mV (min = +0.00 V, max = +1.74 V) in1: 1.02 V (min = +0.00 V, max = +0.00 V) ALARM in2: 3.42 V (min = +0.00 V, max = +0.00 V) ALARM in3: 3.38 V (min = +0.00 V, max = +0.00 V) ALARM in4: 1.03 V (min = +0.00 V, max = +0.00 V) ALARM in5: 1.02 V (min = +0.00 V, max = +0.00 V) ALARM in6: 200.00 mV (min = +0.00 V, max = +0.00 V) ALARM in7: 3.42 V (min = +0.00 V, max = +0.00 V) ALARM in8: 3.28 V (min = +0.00 V, max = +0.00 V) ALARM in9: 920.00 mV (min = +0.00 V, max = +0.00 V) ALARM in10: 512.00 mV (min = +0.00 V, max = +0.00 V) ALARM in11: 504.00 mV (min = +0.00 V, max = +0.00 V) ALARM in12: 1.03 V (min = +0.00 V, max = +0.00 V) ALARM in13: 256.00 mV (min = +0.00 V, max = +0.00 V) ALARM in14: 1.47 V (min = +0.00 V, max = +0.00 V) ALARM fan1: 0 RPM (min = 0 RPM) fan2: 0 RPM (min = 0 RPM) fan3: 355 RPM (min = 0 RPM) fan7: 0 RPM (min = 0 RPM) SYSTIN: +25.0°C (high = +80.0°C, hyst = +75.0°C) sensor = thermistor CPUTIN: +26.5°C (high = +80.0°C, hyst = +75.0°C) sensor = thermistor AUXTIN0: +97.0°C sensor = thermistor AUXTIN1: +25.0°C sensor = thermistor AUXTIN2: +25.0°C sensor = thermistor AUXTIN3: +1.0°C sensor = thermistor PECI Agent 0 Calibration: +26.0°C PCH_CHIP_CPU_MAX_TEMP: +0.0°C PCH_CHIP_TEMP: +0.0°C PCH_CPU_TEMP: +0.0°C TSI0_TEMP: +27.9°C intrusion0: ALARM intrusion1: OK beep_enable: disabled Signed-off-by: Holger Kiehl Tested-by: Holger Kiehl Link: https://lore.kernel.org/r/868bdc4f-9d45-475c-963e-f5232a8b95@praktifix.dwd.de Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index 24c67dbfa8ab2b..b19edee85575f6 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -1052,6 +1052,7 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) static struct platform_device *pdev[2]; static const char * const asus_wmi_boards[] = { + "Pro A520M-C II", "PRO H410T", "ProArt B550-CREATOR", "ProArt X570-CREATOR WIFI", From 23e8a379cf5c29a97c63016e1554de731b26a29b Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Wed, 15 Mar 2023 23:01:34 +0200 Subject: [PATCH 025/131] hwmon: (nct6775) Fix TUF GAMING B550M-E WIFI name TUF GAMING B550M-E WIFI motherboard is incorrectly named as TUF GAMING B550M-E (WI-FI). Validated by dmidecode output from https://github.com/linuxhw/DMI/ Link: https://bugzilla.kernel.org/show_bug.cgi?id=204807 Signed-off-by: Denis Pauk Link: https://lore.kernel.org/r/20230315210135.2155-1-pauk.denis@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index b19edee85575f6..02e9241a98bf03 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -1096,7 +1096,7 @@ static const char * const asus_wmi_boards[] = { "ROG STRIX Z490-H GAMING", "ROG STRIX Z490-I GAMING", "TUF GAMING B550M-E", - "TUF GAMING B550M-E (WI-FI)", + "TUF GAMING B550M-E WIFI", "TUF GAMING B550M-PLUS", "TUF GAMING B550M-PLUS (WI-FI)", "TUF GAMING B550M-PLUS WIFI II", From bcd2fbec8a2583f4180ffc8b453c24fad2068306 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Thu, 16 Mar 2023 00:51:28 +0200 Subject: [PATCH 026/131] hwmon: (nct6775) update ASUS WMI monitoring list A520/B360/B460/B550... Boards such as * EX-B660M-V5 D4, * PRIME A520M-A, * PRIME A520M-A II, * PRIME A520M-E, * PRIME A520M-K, * PRIME B360M-A, * PRIME B360M-C, * PRIME B460M-A R2.0, * PRIME B550M-A AC, * PRIME B550M-A WIFI II, * PRIME B550M-K, * PRIME B650M-A AX II, * PRIME Z590-P WIFI, * PRIME Z590-V, * Pro A520M-C, * ProArt B650-CREATOR, * ProArt Z790-CREATOR WIFI, * Pro B660M-C, * Pro WS W680-ACE, * Pro WS W680-ACE IPMI, * ROG MAXIMUS XIII APEX, * ROG MAXIMUS XIII EXTREME, * ROG MAXIMUS XIII HERO, * ROG MAXIMUS Z690 APEX, * ROG MAXIMUS Z790 EXTREME, * ROG STRIX B660-A GAMING WIFI, * ROG STRIX Z590-A GAMING WIFI, * ROG STRIX Z590-E GAMING WIFI, * ROG STRIX Z590-F GAMING WIFI, * ROG STRIX Z590-I GAMING WIFI, * TUF GAMING A520M-PLUS, * TUF GAMING A520M-PLUS II, * TUF GAMING A520M-PLUS WIFI, * TUF GAMING B660M-E D4, * TUF GAMING B660-PLUS WIFI D4, * TUF GAMING X570-PLUS_BR, * TUF GAMING Z590-PLUS, * Z490-GUNDAM (WI-FI), * Z590 WIFI GUNDAM EDITION have got a nct6775 chip, but by default there's no use of it because of resource conflict with WMI method. This commit adds such boards to the WMI monitoring list. Link: https://bugzilla.kernel.org/show_bug.cgi?id=204807 Signed-off-by: Denis Pauk Tested-by: Nick Owens Tested-by: A. M. Link: https://lore.kernel.org/r/20230315225128.1236-1-pauk.denis@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index 02e9241a98bf03..2db71b62e03d4d 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -1052,6 +1052,7 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) static struct platform_device *pdev[2]; static const char * const asus_wmi_boards[] = { + "Pro A520M-C", "Pro A520M-C II", "PRO H410T", "ProArt B550-CREATOR", @@ -1059,11 +1060,21 @@ static const char * const asus_wmi_boards[] = { "ProArt Z490-CREATOR 10G", "Pro B550M-C", "Pro WS X570-ACE", + "PRIME A520M-A", + "PRIME A520M-A II", + "PRIME A520M-E", + "PRIME A520M-K", "PRIME B360-PLUS", + "PRIME B360M-A", + "PRIME B360M-C", "PRIME B460-PLUS", + "PRIME B460M-A R2.0", "PRIME B550-PLUS", "PRIME B550M-A", "PRIME B550M-A (WI-FI)", + "PRIME B550M-A AC", + "PRIME B550M-A WIFI II", + "PRIME B550M-K", "PRIME H410M-R", "PRIME X570-P", "PRIME X570-PRO", @@ -1095,6 +1106,9 @@ static const char * const asus_wmi_boards[] = { "ROG STRIX Z490-G GAMING (WI-FI)", "ROG STRIX Z490-H GAMING", "ROG STRIX Z490-I GAMING", + "TUF GAMING A520M-PLUS", + "TUF GAMING A520M-PLUS II", + "TUF GAMING A520M-PLUS WIFI", "TUF GAMING B550M-E", "TUF GAMING B550M-E WIFI", "TUF GAMING B550M-PLUS", @@ -1105,16 +1119,20 @@ static const char * const asus_wmi_boards[] = { "TUF GAMING B550-PRO", "TUF GAMING X570-PLUS", "TUF GAMING X570-PLUS (WI-FI)", + "TUF GAMING X570-PLUS_BR", "TUF GAMING X570-PRO (WI-FI)", "TUF GAMING Z490-PLUS", "TUF GAMING Z490-PLUS (WI-FI)", + "Z490-GUNDAM (WI-FI)", }; static const char * const asus_msi_boards[] = { + "EX-B660M-V5 D4", "EX-B660M-V5 PRO D4", "PRIME B650-PLUS", "PRIME B650M-A", "PRIME B650M-A AX", + "PRIME B650M-A AX II", "PRIME B650M-A II", "PRIME B650M-A WIFI", "PRIME B650M-A WIFI II", @@ -1125,20 +1143,33 @@ static const char * const asus_msi_boards[] = { "PRIME X670E-PRO WIFI", "PRIME Z590-A", "PRIME Z590-P", + "PRIME Z590-P WIFI", + "PRIME Z590-V", "PRIME Z590M-PLUS", + "Pro B660M-C", "Pro B660M-C-D4", + "Pro WS W680-ACE", + "Pro WS W680-ACE IPMI", + "ProArt B650-CREATOR", "ProArt B660-CREATOR D4", "ProArt X670E-CREATOR WIFI", + "ProArt Z790-CREATOR WIFI", "ROG CROSSHAIR X670E EXTREME", "ROG CROSSHAIR X670E GENE", "ROG CROSSHAIR X670E HERO", + "ROG MAXIMUS XIII APEX", + "ROG MAXIMUS XIII EXTREME", "ROG MAXIMUS XIII EXTREME GLACIAL", + "ROG MAXIMUS XIII HERO", + "ROG MAXIMUS Z690 APEX", "ROG MAXIMUS Z690 EXTREME", "ROG MAXIMUS Z690 EXTREME GLACIAL", + "ROG MAXIMUS Z790 EXTREME", "ROG STRIX B650-A GAMING WIFI", "ROG STRIX B650E-E GAMING WIFI", "ROG STRIX B650E-F GAMING WIFI", "ROG STRIX B650E-I GAMING WIFI", + "ROG STRIX B660-A GAMING WIFI", "ROG STRIX B660-A GAMING WIFI D4", "ROG STRIX B660-F GAMING WIFI", "ROG STRIX B660-G GAMING WIFI", @@ -1147,16 +1178,24 @@ static const char * const asus_msi_boards[] = { "ROG STRIX X670E-E GAMING WIFI", "ROG STRIX X670E-F GAMING WIFI", "ROG STRIX X670E-I GAMING WIFI", + "ROG STRIX Z590-A GAMING WIFI", "ROG STRIX Z590-A GAMING WIFI II", + "ROG STRIX Z590-E GAMING WIFI", + "ROG STRIX Z590-F GAMING WIFI", + "ROG STRIX Z590-I GAMING WIFI", "ROG STRIX Z690-A GAMING WIFI D4", "TUF GAMING B650-PLUS", "TUF GAMING B650-PLUS WIFI", "TUF GAMING B650M-PLUS", "TUF GAMING B650M-PLUS WIFI", + "TUF GAMING B660-PLUS WIFI D4", + "TUF GAMING B660M-E D4", "TUF GAMING B660M-PLUS WIFI", "TUF GAMING X670E-PLUS", "TUF GAMING X670E-PLUS WIFI", + "TUF GAMING Z590-PLUS", "TUF GAMING Z590-PLUS WIFI", + "Z590 WIFI GUNDAM EDITION", }; #if IS_ENABLED(CONFIG_ACPI) From dedbe4c1499cf1b7b0357872cf858221f583bfc0 Mon Sep 17 00:00:00 2001 From: Frank Crawford Date: Sat, 18 Mar 2023 19:05:43 +1100 Subject: [PATCH 027/131] hwmon: (it87) Use voltage scaling macro where appropriate Apply scaling macro to match the labels for internal voltage sensors. Signed-off-by: Frank Crawford Link: https://lore.kernel.org/r/20230318080543.1226700-3-frank@crawford.emu.id.au Signed-off-by: Guenter Roeck --- drivers/hwmon/it87.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index e9614eb557d4eb..f774a0732a7c45 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -2004,7 +2004,7 @@ static ssize_t show_label(struct device *dev, struct device_attribute *attr, if (has_vin3_5v(data) && nr == 0) label = labels[0]; - else if (has_12mv_adc(data) || has_10_9mv_adc(data)) + else if (has_scaling(data)) label = labels_it8721[nr]; else label = labels[nr]; From a7da8a8bf19b758d6db50a1c09627b0422fe98db Mon Sep 17 00:00:00 2001 From: Lorenz Brun Date: Thu, 9 Mar 2023 02:10:08 +0100 Subject: [PATCH 028/131] hwmon: (pwm-fan) set usage_power on PWM state PWM fans are controlled solely by the duty cycle of the PWM signal, they do not care about the exact timing. Thus set usage_power to true to allow less flexible hardware to work as a PWM source for fan control. Signed-off-by: Lorenz Brun Link: https://lore.kernel.org/r/20230309011009.2109696-1-lorenz@brun.one Signed-off-by: Guenter Roeck --- drivers/hwmon/pwm-fan.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 57928d27001562..6e4516c2ab894f 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -507,6 +507,14 @@ static int pwm_fan_probe(struct platform_device *pdev) pwm_init_state(ctx->pwm, &ctx->pwm_state); + /* + * PWM fans are controlled solely by the duty cycle of the PWM signal, + * they do not care about the exact timing. Thus set usage_power to true + * to allow less flexible hardware to work as a PWM source for fan + * control. + */ + ctx->pwm_state.usage_power = true; + /* * set_pwm assumes that MAX_PWM * (period - 1) fits into an unsigned * long. Check this here to prevent the fan running at a too low From 8ea57c51e508d8c6ce1531b5336199ceeda39120 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Thu, 23 Mar 2023 17:15:35 -0400 Subject: [PATCH 029/131] hwmon: remove unused superio_outb function clang with W=1 reports drivers/hwmon/vt1211.c:198:20: error: unused function 'superio_outb' [-Werror,-Wunused-function] static inline void superio_outb(int sio_cip, int reg, int val) ^ This function is not used so remove it. Signed-off-by: Tom Rix Acked-by: Juerg Haefliger Link: https://lore.kernel.org/r/20230323211535.2637939-1-trix@redhat.com Signed-off-by: Guenter Roeck --- drivers/hwmon/vt1211.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c index 4a5e911d26ebf9..fcd4be7a5a8500 100644 --- a/drivers/hwmon/vt1211.c +++ b/drivers/hwmon/vt1211.c @@ -195,12 +195,6 @@ struct vt1211_data { /* VT1211 logical device numbers */ #define SIO_VT1211_LDN_HWMON 0x0b /* HW monitor */ -static inline void superio_outb(int sio_cip, int reg, int val) -{ - outb(reg, sio_cip); - outb(val, sio_cip + 1); -} - static inline int superio_inb(int sio_cip, int reg) { outb(reg, sio_cip); From 0282592678b1e397916db36052986380d5fe4ec6 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Thu, 23 Mar 2023 23:27:49 +0200 Subject: [PATCH 030/131] hwmon: (nct6775) Sort ASUS board list Rearrange board list in alphabetical order by: LC_ALL=C sort -u Link: https://bugzilla.kernel.org/show_bug.cgi?id=204807 Signed-off-by: Denis Pauk Link: https://lore.kernel.org/r/20230323212751.2474-1-pauk.denis@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index 2db71b62e03d4d..5ba888b7eb8c88 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -1052,14 +1052,6 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) static struct platform_device *pdev[2]; static const char * const asus_wmi_boards[] = { - "Pro A520M-C", - "Pro A520M-C II", - "PRO H410T", - "ProArt B550-CREATOR", - "ProArt X570-CREATOR WIFI", - "ProArt Z490-CREATOR 10G", - "Pro B550M-C", - "Pro WS X570-ACE", "PRIME A520M-A", "PRIME A520M-A II", "PRIME A520M-E", @@ -1078,6 +1070,14 @@ static const char * const asus_wmi_boards[] = { "PRIME H410M-R", "PRIME X570-P", "PRIME X570-PRO", + "PRO H410T", + "Pro A520M-C", + "Pro A520M-C II", + "Pro B550M-C", + "Pro WS X570-ACE", + "ProArt B550-CREATOR", + "ProArt X570-CREATOR WIFI", + "ProArt Z490-CREATOR 10G", "ROG CROSSHAIR VIII DARK HERO", "ROG CROSSHAIR VIII EXTREME", "ROG CROSSHAIR VIII FORMULA", @@ -1109,14 +1109,14 @@ static const char * const asus_wmi_boards[] = { "TUF GAMING A520M-PLUS", "TUF GAMING A520M-PLUS II", "TUF GAMING A520M-PLUS WIFI", + "TUF GAMING B550-PLUS", + "TUF GAMING B550-PLUS WIFI II", + "TUF GAMING B550-PRO", "TUF GAMING B550M-E", "TUF GAMING B550M-E WIFI", "TUF GAMING B550M-PLUS", "TUF GAMING B550M-PLUS (WI-FI)", "TUF GAMING B550M-PLUS WIFI II", - "TUF GAMING B550-PLUS", - "TUF GAMING B550-PLUS WIFI II", - "TUF GAMING B550-PRO", "TUF GAMING X570-PLUS", "TUF GAMING X570-PLUS (WI-FI)", "TUF GAMING X570-PLUS_BR", From c05403e64d7feb12ac31cf785a61b665970cc821 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Thu, 23 Mar 2023 23:27:50 +0200 Subject: [PATCH 031/131] hwmon: (nct6775) Fix ROG B550-XE WIFI and Pro B660M-C D4 names ROG STRIX B550-XE GAMING WIFI motherboard is incorrectly named as ROG STRIX B550-XE GAMING (WI-FI). Pro B660M-C D4 motherboard is incorrectly named as Pro B660M-C-D4. Validated by dmidecode output from https://github.com/linuxhw/DMI/ Link: https://bugzilla.kernel.org/show_bug.cgi?id=204807 Signed-off-by: Denis Pauk Link: https://lore.kernel.org/r/20230323212751.2474-2-pauk.denis@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index 5ba888b7eb8c88..9a7ad64c2cc3c1 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -1090,7 +1090,7 @@ static const char * const asus_wmi_boards[] = { "ROG STRIX B550-F GAMING (WI-FI)", "ROG STRIX B550-F GAMING WIFI II", "ROG STRIX B550-I GAMING", - "ROG STRIX B550-XE GAMING (WI-FI)", + "ROG STRIX B550-XE GAMING WIFI", "ROG STRIX X570-E GAMING", "ROG STRIX X570-E GAMING WIFI II", "ROG STRIX X570-F GAMING", @@ -1147,7 +1147,7 @@ static const char * const asus_msi_boards[] = { "PRIME Z590-V", "PRIME Z590M-PLUS", "Pro B660M-C", - "Pro B660M-C-D4", + "Pro B660M-C D4", "Pro WS W680-ACE", "Pro WS W680-ACE IPMI", "ProArt B650-CREATOR", From a4fffe48e4bab49b991490abd3e6d4bd98af2610 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Thu, 23 Mar 2023 23:27:51 +0200 Subject: [PATCH 032/131] hwmon: (nct6775) update ASUS WMI monitoring list B360/H410/H610/Z390... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Boards such as * EX-B460M-V5, * EX-H410M-V3, * PRIME B360M-D, * PRIME B360M-K, * PRIME H410M-A, * PRIME H410M-D, * PRIME H410M-E, * PRIME H410M-F, * PRIME H410M-K, * PRIME H410M-K R2.0, * PRIME H510M-K R2.0, * PRIME Z390-A, * PRIME Z390-A/H10, * PRIME Z390-P, * PRIME Z390M-PLUS, * PRIME Z490-A, * PRIME Z490-P, * PRIME Z490-V, * PRIME Z490M-PLUS, * PRO B460M-C, * PRO H410M-C, * ROG MAXIMUS XI APEX, * ROG MAXIMUS XI CODE, * ROG MAXIMUS XI EXTREME, * ROG MAXIMUS XI FORMULA, * ROG MAXIMUS XI GENE, * ROG MAXIMUS XI HERO, * ROG MAXIMUS XI HERO (WI-FI), * ROG MAXIMUS XII APEX, * ROG MAXIMUS XII EXTREME, * ROG MAXIMUS XII FORMULA, * ROG MAXIMUS XII HERO (WI-FI), * ROG STRIX B460-F GAMING, * ROG STRIX B460-G GAMING, * ROG STRIX B460-H GAMING, * ROG STRIX B460-I GAMING, * TUF GAMING B460-PLUS, * TUF GAMING B460-PRO (WI-FI), * TUF GAMING B460M-PLUS, * TUF GAMING B460M-PLUS (WI-FI), * TUF GAMING B460M-PRO, * TUF GAMING B550-PLUS (WI-FI), * TUF GAMING B550M ZAKU (WI-FI), * TUF Z390-PLUS GAMING, * TUF Z390-PLUS GAMING (WI-FI), * TUF Z390-PRO GAMING, * TUF Z390M-PRO GAMING, * TUF Z390M-PRO GAMING (WI-FI), * WS Z390 PRO, * B560M-P, * EX-B560M-V5, * EX-H510M-V3, * EX-H610M-V3 D4, * PRIME B560-PLUS, * PRIME B560-PLUS AC-HES, * PRIME B560M-A, * PRIME B560M-A AC, * PRIME B560M-K, * PRIME B660-PLUS D4, * PRIME H510M-A, * PRIME H510M-A WIFI, * PRIME H510M-D, * PRIME H510M-E, * PRIME H510M-F, * PRIME H510M-K, * PRIME H610I-PLUS D4, * PRIME H610M-A D4, * PRIME H610M-A WIFI D4, * PRIME H610M-D D4, * PRIME H610M-E D4, * PRIME H610M-F D4, * PRIME H610M-K D4, * PRIME Z690-A, * PRIME Z690-P, * PRIME Z690-P D4, * PRIME Z690-P WIFI, * PRIME Z690-P WIFI D4, * PRIME Z690M-PLUS D4, * PRIME Z790-A WIFI, * PRIME Z790-P, * PRIME Z790-P D4, * PRIME Z790-P WIFI, * PRIME Z790-P WIFI D4, * PRIME Z790M-PLUS, * PRIME Z790M-PLUS D4, * Pro B560M-C, * Pro B560M-CT, * Pro H510M-C, * Pro H510M-CT, * Pro H610M-C, * Pro H610M-C D4, * Pro H610M-CT D4, * Pro H610T D4, * ProArt Z690-CREATOR WIFI, * ROG MAXIMUS Z690 HERO EVA, * ROG MAXIMUS Z790 APEX, * ROG MAXIMUS Z790 HERO, * ROG STRIX B560-A GAMING WIFI, * ROG STRIX B560-E GAMING WIFI, * ROG STRIX B560-F GAMING WIFI, * ROG STRIX B560-G GAMING WIFI, * ROG STRIX B560-I GAMING WIFI, * ROG STRIX Z690-A GAMING WIFI, * ROG STRIX Z690-I GAMING WIFI, * ROG STRIX Z790-A GAMING WIFI, * ROG STRIX Z790-A GAMING WIFI D4, * ROG STRIX Z790-E GAMING WIFI, * ROG STRIX Z790-F GAMING WIFI, * ROG STRIX Z790-H GAMING WIFI, * ROG STRIX Z790-I GAMING WIFI, * TUF GAMING B560-PLUS WIFI, * TUF GAMING B560M-E, * TUF GAMING B560M-PLUS, * TUF GAMING B560M-PLUS WIFI, * TUF GAMING Z690-PLUS, * TUF GAMING Z690-PLUS D4, * TUF GAMING Z690-PLUS WIFI, * TUF GAMING Z690-PLUS WIFI D4, * TUF GAMING Z790-PLUS D4, * TUF GAMING Z790-PLUS WIFI, * TUF GAMING Z790-PLUS WIFI D4, have got a nct6775 chip, but by default there's no use of it because of resource conflict with WMI method. This commit adds such boards to the WMI monitoring list. Link: https://bugzilla.kernel.org/show_bug.cgi?id=204807 Signed-off-by: Denis Pauk Tested-by: Alejandro González Tested-by: bruno Tested-by: renedis Link: https://lore.kernel.org/r/20230323212751.2474-3-pauk.denis@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 121 +++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index 9a7ad64c2cc3c1..680fa0ecd6c317 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -1052,6 +1052,8 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) static struct platform_device *pdev[2]; static const char * const asus_wmi_boards[] = { + "EX-B460M-V5", + "EX-H410M-V3", "PRIME A520M-A", "PRIME A520M-A II", "PRIME A520M-E", @@ -1059,6 +1061,8 @@ static const char * const asus_wmi_boards[] = { "PRIME B360-PLUS", "PRIME B360M-A", "PRIME B360M-C", + "PRIME B360M-D", + "PRIME B360M-K", "PRIME B460-PLUS", "PRIME B460M-A R2.0", "PRIME B550-PLUS", @@ -1067,9 +1071,26 @@ static const char * const asus_wmi_boards[] = { "PRIME B550M-A AC", "PRIME B550M-A WIFI II", "PRIME B550M-K", + "PRIME H410M-A", + "PRIME H410M-D", + "PRIME H410M-E", + "PRIME H410M-F", + "PRIME H410M-K", + "PRIME H410M-K R2.0", "PRIME H410M-R", + "PRIME H510M-K R2.0", "PRIME X570-P", "PRIME X570-PRO", + "PRIME Z390-A", + "PRIME Z390-A/H10", + "PRIME Z390-P", + "PRIME Z390M-PLUS", + "PRIME Z490-A", + "PRIME Z490-P", + "PRIME Z490-V", + "PRIME Z490M-PLUS", + "PRO B460M-C", + "PRO H410M-C", "PRO H410T", "Pro A520M-C", "Pro A520M-C II", @@ -1084,6 +1105,21 @@ static const char * const asus_wmi_boards[] = { "ROG CROSSHAIR VIII HERO", "ROG CROSSHAIR VIII HERO (WI-FI)", "ROG CROSSHAIR VIII IMPACT", + "ROG MAXIMUS XI APEX", + "ROG MAXIMUS XI CODE", + "ROG MAXIMUS XI EXTREME", + "ROG MAXIMUS XI FORMULA", + "ROG MAXIMUS XI GENE", + "ROG MAXIMUS XI HERO", + "ROG MAXIMUS XI HERO (WI-FI)", + "ROG MAXIMUS XII APEX", + "ROG MAXIMUS XII EXTREME", + "ROG MAXIMUS XII FORMULA", + "ROG MAXIMUS XII HERO (WI-FI)", + "ROG STRIX B460-F GAMING", + "ROG STRIX B460-G GAMING", + "ROG STRIX B460-H GAMING", + "ROG STRIX B460-I GAMING", "ROG STRIX B550-A GAMING", "ROG STRIX B550-E GAMING", "ROG STRIX B550-F GAMING", @@ -1109,9 +1145,16 @@ static const char * const asus_wmi_boards[] = { "TUF GAMING A520M-PLUS", "TUF GAMING A520M-PLUS II", "TUF GAMING A520M-PLUS WIFI", + "TUF GAMING B460-PLUS", + "TUF GAMING B460-PRO (WI-FI)", + "TUF GAMING B460M-PLUS", + "TUF GAMING B460M-PLUS (WI-FI)", + "TUF GAMING B460M-PRO", "TUF GAMING B550-PLUS", + "TUF GAMING B550-PLUS (WI-FI)", "TUF GAMING B550-PLUS WIFI II", "TUF GAMING B550-PRO", + "TUF GAMING B550M ZAKU (WI-FI)", "TUF GAMING B550M-E", "TUF GAMING B550M-E WIFI", "TUF GAMING B550M-PLUS", @@ -1123,12 +1166,27 @@ static const char * const asus_wmi_boards[] = { "TUF GAMING X570-PRO (WI-FI)", "TUF GAMING Z490-PLUS", "TUF GAMING Z490-PLUS (WI-FI)", + "TUF Z390-PLUS GAMING", + "TUF Z390-PLUS GAMING (WI-FI)", + "TUF Z390-PRO GAMING", + "TUF Z390M-PRO GAMING", + "TUF Z390M-PRO GAMING (WI-FI)", + "WS Z390 PRO", "Z490-GUNDAM (WI-FI)", }; static const char * const asus_msi_boards[] = { + "B560M-P", + "EX-B560M-V5", "EX-B660M-V5 D4", "EX-B660M-V5 PRO D4", + "EX-H510M-V3", + "EX-H610M-V3 D4", + "PRIME B560-PLUS", + "PRIME B560-PLUS AC-HES", + "PRIME B560M-A", + "PRIME B560M-A AC", + "PRIME B560M-K", "PRIME B650-PLUS", "PRIME B650M-A", "PRIME B650M-A AX", @@ -1136,8 +1194,22 @@ static const char * const asus_msi_boards[] = { "PRIME B650M-A II", "PRIME B650M-A WIFI", "PRIME B650M-A WIFI II", + "PRIME B660-PLUS D4", "PRIME B660M-A D4", "PRIME B660M-A WIFI D4", + "PRIME H510M-A", + "PRIME H510M-A WIFI", + "PRIME H510M-D", + "PRIME H510M-E", + "PRIME H510M-F", + "PRIME H510M-K", + "PRIME H610I-PLUS D4", + "PRIME H610M-A D4", + "PRIME H610M-A WIFI D4", + "PRIME H610M-D D4", + "PRIME H610M-E D4", + "PRIME H610M-F D4", + "PRIME H610M-K D4", "PRIME X670-P", "PRIME X670-P WIFI", "PRIME X670E-PRO WIFI", @@ -1146,13 +1218,35 @@ static const char * const asus_msi_boards[] = { "PRIME Z590-P WIFI", "PRIME Z590-V", "PRIME Z590M-PLUS", + "PRIME Z690-A", + "PRIME Z690-P", + "PRIME Z690-P D4", + "PRIME Z690-P WIFI", + "PRIME Z690-P WIFI D4", + "PRIME Z690M-PLUS D4", + "PRIME Z790-A WIFI", + "PRIME Z790-P", + "PRIME Z790-P D4", + "PRIME Z790-P WIFI", + "PRIME Z790-P WIFI D4", + "PRIME Z790M-PLUS", + "PRIME Z790M-PLUS D4", + "Pro B560M-C", + "Pro B560M-CT", "Pro B660M-C", "Pro B660M-C D4", + "Pro H510M-C", + "Pro H510M-CT", + "Pro H610M-C", + "Pro H610M-C D4", + "Pro H610M-CT D4", + "Pro H610T D4", "Pro WS W680-ACE", "Pro WS W680-ACE IPMI", "ProArt B650-CREATOR", "ProArt B660-CREATOR D4", "ProArt X670E-CREATOR WIFI", + "ProArt Z690-CREATOR WIFI", "ProArt Z790-CREATOR WIFI", "ROG CROSSHAIR X670E EXTREME", "ROG CROSSHAIR X670E GENE", @@ -1164,7 +1258,15 @@ static const char * const asus_msi_boards[] = { "ROG MAXIMUS Z690 APEX", "ROG MAXIMUS Z690 EXTREME", "ROG MAXIMUS Z690 EXTREME GLACIAL", + "ROG MAXIMUS Z690 HERO EVA", + "ROG MAXIMUS Z790 APEX", "ROG MAXIMUS Z790 EXTREME", + "ROG MAXIMUS Z790 HERO", + "ROG STRIX B560-A GAMING WIFI", + "ROG STRIX B560-E GAMING WIFI", + "ROG STRIX B560-F GAMING WIFI", + "ROG STRIX B560-G GAMING WIFI", + "ROG STRIX B560-I GAMING WIFI", "ROG STRIX B650-A GAMING WIFI", "ROG STRIX B650E-E GAMING WIFI", "ROG STRIX B650E-F GAMING WIFI", @@ -1183,7 +1285,19 @@ static const char * const asus_msi_boards[] = { "ROG STRIX Z590-E GAMING WIFI", "ROG STRIX Z590-F GAMING WIFI", "ROG STRIX Z590-I GAMING WIFI", + "ROG STRIX Z690-A GAMING WIFI", "ROG STRIX Z690-A GAMING WIFI D4", + "ROG STRIX Z690-I GAMING WIFI", + "ROG STRIX Z790-A GAMING WIFI", + "ROG STRIX Z790-A GAMING WIFI D4", + "ROG STRIX Z790-E GAMING WIFI", + "ROG STRIX Z790-F GAMING WIFI", + "ROG STRIX Z790-H GAMING WIFI", + "ROG STRIX Z790-I GAMING WIFI", + "TUF GAMING B560-PLUS WIFI", + "TUF GAMING B560M-E", + "TUF GAMING B560M-PLUS", + "TUF GAMING B560M-PLUS WIFI", "TUF GAMING B650-PLUS", "TUF GAMING B650-PLUS WIFI", "TUF GAMING B650M-PLUS", @@ -1195,6 +1309,13 @@ static const char * const asus_msi_boards[] = { "TUF GAMING X670E-PLUS WIFI", "TUF GAMING Z590-PLUS", "TUF GAMING Z590-PLUS WIFI", + "TUF GAMING Z690-PLUS", + "TUF GAMING Z690-PLUS D4", + "TUF GAMING Z690-PLUS WIFI", + "TUF GAMING Z690-PLUS WIFI D4", + "TUF GAMING Z790-PLUS D4", + "TUF GAMING Z790-PLUS WIFI", + "TUF GAMING Z790-PLUS WIFI D4", "Z590 WIFI GUNDAM EDITION", }; From 7165bfc9b89e5c144d63391e2229a905c920f1db Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:47:50 +0200 Subject: [PATCH 033/131] MAINTAINERS: hwmon: drop Agathe Porte Mails to Agathe Porte bounce ("550 5.4.1 Recipient address rejected: Access denied. AS(201806281)"). Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20230406204750.3017850-1-krzysztof.kozlowski@linaro.org Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml | 2 +- MAINTAINERS | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml b/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml index e7493e25a7d2a2..f9c00cbb280682 100644 --- a/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml +++ b/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml @@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# title: TMP464 and TMP468 temperature sensors maintainers: - - Agathe Porte + - Guenter Roeck description: | ±0.0625°C Remote and Local temperature sensor diff --git a/MAINTAINERS b/MAINTAINERS index 90abe83c02f3bc..9e9381babb0671 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21068,7 +21068,6 @@ F: Documentation/hwmon/tmp401.rst F: drivers/hwmon/tmp401.c TMP464 HARDWARE MONITOR DRIVER -M: Agathe Porte M: Guenter Roeck L: linux-hwmon@vger.kernel.org S: Maintained From 63bde65918e60c679e58dcc382b19cf24cc3f07a Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:29:57 +0200 Subject: [PATCH 034/131] hwmon: adm1177: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/adm1177.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/adm1177.c b/drivers/hwmon/adm1177.c index be17a26a84f19a..bfe070a1b501c4 100644 --- a/drivers/hwmon/adm1177.c +++ b/drivers/hwmon/adm1177.c @@ -168,7 +168,7 @@ static umode_t adm1177_is_visible(const void *data, return 0; } -static const struct hwmon_channel_info *adm1177_info[] = { +static const struct hwmon_channel_info * const adm1177_info[] = { HWMON_CHANNEL_INFO(curr, HWMON_C_INPUT | HWMON_C_MAX_ALARM), HWMON_CHANNEL_INFO(in, From 013adc9852a1352007722c3e42986cb6e03a99be Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:29:58 +0200 Subject: [PATCH 035/131] hwmon: adm9240: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/adm9240.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 40e3558d37096f..9eb973a38e4b27 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -731,7 +731,7 @@ static const struct hwmon_ops adm9240_hwmon_ops = { .write = adm9240_write, }; -static const struct hwmon_channel_info *adm9240_info[] = { +static const struct hwmon_channel_info * const adm9240_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_ALARMS), HWMON_CHANNEL_INFO(intrusion, HWMON_INTRUSION_ALARM), HWMON_CHANNEL_INFO(temp, From 07aa164a503878a83a8e8319109f69ce863a10c3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:29:59 +0200 Subject: [PATCH 036/131] hwmon: adt7411: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/adt7411.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/adt7411.c b/drivers/hwmon/adt7411.c index bf5c5618f8d0d9..6ba84921614fa0 100644 --- a/drivers/hwmon/adt7411.c +++ b/drivers/hwmon/adt7411.c @@ -636,7 +636,7 @@ static int adt7411_init_device(struct adt7411_data *data) return i2c_smbus_write_byte_data(data->client, ADT7411_REG_CFG1, val); } -static const struct hwmon_channel_info *adt7411_info[] = { +static const struct hwmon_channel_info * const adt7411_info[] = { HWMON_CHANNEL_INFO(in, HWMON_I_INPUT | HWMON_I_MIN | HWMON_I_MAX | HWMON_I_ALARM, HWMON_I_INPUT | HWMON_I_MIN | HWMON_I_MAX | HWMON_I_ALARM, From ce94ff2ef9758797c4c1670fb90c3d5060024525 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:00 +0200 Subject: [PATCH 037/131] hwmon: adt7470: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/adt7470.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 927f8df05b7c93..64f801b859ff60 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c @@ -1187,7 +1187,7 @@ static const struct hwmon_ops adt7470_hwmon_ops = { .write = adt7470_write, }; -static const struct hwmon_channel_info *adt7470_info[] = { +static const struct hwmon_channel_info * const adt7470_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | HWMON_T_ALARM, HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | HWMON_T_ALARM, From d7bb04c3e226350d0f99aaf900ecb6f324173c14 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:01 +0200 Subject: [PATCH 038/131] hwmon: adt7x10: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/adt7x10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index da67734edafd75..6701920de17f44 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -309,7 +309,7 @@ static int adt7x10_write(struct device *dev, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *adt7x10_info[] = { +static const struct hwmon_channel_info * const adt7x10_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MIN | HWMON_T_CRIT | HWMON_T_MAX_HYST | HWMON_T_MIN_HYST | HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM | From b9ab28a7749895e9ef20c5a70642825479d4dc75 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:02 +0200 Subject: [PATCH 039/131] hwmon: aht10: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/aht10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c index 9babd69d54a35c..b8fe3f7248bafd 100644 --- a/drivers/hwmon/aht10.c +++ b/drivers/hwmon/aht10.c @@ -270,7 +270,7 @@ static int aht10_hwmon_write(struct device *dev, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *aht10_info[] = { +static const struct hwmon_channel_info * const aht10_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), HWMON_CHANNEL_INFO(humidity, HWMON_H_INPUT), From 832dc5106e813b4dc942bce27f89819f8d21fbd7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:03 +0200 Subject: [PATCH 040/131] hwmon: aquacomputer: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/aquacomputer_d5next.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 17fad3142118f7..3bd35d833e693c 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -1038,7 +1038,7 @@ static const struct hwmon_ops aqc_hwmon_ops = { .write = aqc_write }; -static const struct hwmon_channel_info *aqc_info[] = { +static const struct hwmon_channel_info * const aqc_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_OFFSET, From 69a1ffca989e0b43afda1b8c93a43433a1c9ec60 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:04 +0200 Subject: [PATCH 041/131] hwmon: as370: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/as370-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/as370-hwmon.c b/drivers/hwmon/as370-hwmon.c index 63b5b2d6e59307..fffbf385a57f0d 100644 --- a/drivers/hwmon/as370-hwmon.c +++ b/drivers/hwmon/as370-hwmon.c @@ -76,7 +76,7 @@ as370_hwmon_is_visible(const void *data, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *as370_hwmon_info[] = { +static const struct hwmon_channel_info * const as370_hwmon_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), NULL }; From a1e308bfae71d1f464edeb40141b23b1c1a86519 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:05 +0200 Subject: [PATCH 042/131] hwmon: axi-fan: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/axi-fan-control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/axi-fan-control.c b/drivers/hwmon/axi-fan-control.c index 6724e0dd308809..5fd136baf1cd31 100644 --- a/drivers/hwmon/axi-fan-control.c +++ b/drivers/hwmon/axi-fan-control.c @@ -394,7 +394,7 @@ static int axi_fan_control_init(struct axi_fan_control_data *ctl, return ret; } -static const struct hwmon_channel_info *axi_fan_control_info[] = { +static const struct hwmon_channel_info * const axi_fan_control_info[] = { HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT), HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_FAULT | HWMON_F_LABEL), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL), From edcde8cfefb9809fea5172fcc3f4993c01bed4f1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:06 +0200 Subject: [PATCH 043/131] hwmon: bt1-pvt: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/bt1-pvt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/bt1-pvt.c b/drivers/hwmon/bt1-pvt.c index 21ab172774ec58..8d402a62730687 100644 --- a/drivers/hwmon/bt1-pvt.c +++ b/drivers/hwmon/bt1-pvt.c @@ -379,7 +379,7 @@ static int pvt_read_alarm(struct pvt_hwmon *pvt, enum pvt_sensor_type type, return 0; } -static const struct hwmon_channel_info *pvt_channel_info[] = { +static const struct hwmon_channel_info * const pvt_channel_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, @@ -523,7 +523,7 @@ static int pvt_read_alarm(struct pvt_hwmon *pvt, enum pvt_sensor_type type, return -EOPNOTSUPP; } -static const struct hwmon_channel_info *pvt_channel_info[] = { +static const struct hwmon_channel_info * const pvt_channel_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, From 42bd7a59f3b54f8f7dcf802001a8ed8ebb6cabd6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:07 +0200 Subject: [PATCH 044/131] hwmon: corsair: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/corsair-cpro.c | 2 +- drivers/hwmon/corsair-psu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/corsair-cpro.c b/drivers/hwmon/corsair-cpro.c index fa6aa4fc8b5213..463ab4296ede5c 100644 --- a/drivers/hwmon/corsair-cpro.c +++ b/drivers/hwmon/corsair-cpro.c @@ -385,7 +385,7 @@ static const struct hwmon_ops ccp_hwmon_ops = { .write = ccp_write, }; -static const struct hwmon_channel_info *ccp_info[] = { +static const struct hwmon_channel_info * const ccp_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c index 2210aa62e3d06f..dc24c566d08b27 100644 --- a/drivers/hwmon/corsair-psu.c +++ b/drivers/hwmon/corsair-psu.c @@ -571,7 +571,7 @@ static const struct hwmon_ops corsairpsu_hwmon_ops = { .read_string = corsairpsu_hwmon_ops_read_string, }; -static const struct hwmon_channel_info *corsairpsu_info[] = { +static const struct hwmon_channel_info * const corsairpsu_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, From f4ddd8f2e12f75fcbf956fa6845a11dc0455c040 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:08 +0200 Subject: [PATCH 045/131] hwmon: dell-smm: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/dell-smm-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 7ac778aedc68d1..44aaf9b9191d41 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -920,7 +920,7 @@ static const struct hwmon_ops dell_smm_ops = { .write = dell_smm_write, }; -static const struct hwmon_channel_info *dell_smm_info[] = { +static const struct hwmon_channel_info * const dell_smm_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL, From b9adb6b6654486cebdf3b96bf2330d6958c9c326 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:09 +0200 Subject: [PATCH 046/131] hwmon: drivetemp: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/drivetemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c index 8e5759b4239020..e73b7bfc6af357 100644 --- a/drivers/hwmon/drivetemp.c +++ b/drivers/hwmon/drivetemp.c @@ -526,7 +526,7 @@ static umode_t drivetemp_is_visible(const void *data, return 0; } -static const struct hwmon_channel_info *drivetemp_info[] = { +static const struct hwmon_channel_info * const drivetemp_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | From c1686de1db3656b0fe91dce44c0dffe084d07853 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:10 +0200 Subject: [PATCH 047/131] hwmon: emc2305: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/emc2305.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c index f65467fbd86c55..723f57518c9a29 100644 --- a/drivers/hwmon/emc2305.c +++ b/drivers/hwmon/emc2305.c @@ -479,7 +479,7 @@ static const struct hwmon_ops emc2305_ops = { .write = emc2305_write, }; -static const struct hwmon_channel_info *emc2305_info[] = { +static const struct hwmon_channel_info * const emc2305_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_FAULT, HWMON_F_INPUT | HWMON_F_FAULT, From 06c3779625378bb1ceb27e83e0366a2bef6707a8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:11 +0200 Subject: [PATCH 048/131] hwmon: ftsteutates: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/ftsteutates.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c index 25afd9167a346d..f5a4d91a7e90b6 100644 --- a/drivers/hwmon/ftsteutates.c +++ b/drivers/hwmon/ftsteutates.c @@ -520,7 +520,7 @@ static const struct hwmon_ops fts_ops = { .write = fts_write, }; -static const struct hwmon_channel_info *fts_info[] = { +static const struct hwmon_channel_info * const fts_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, From d6171e4d3229fb671706edba14052897a353f262 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:12 +0200 Subject: [PATCH 049/131] hwmon: gxp-fan: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/gxp-fan-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/gxp-fan-ctrl.c b/drivers/hwmon/gxp-fan-ctrl.c index 0014b8b0fd41ac..2e05bc2f627a33 100644 --- a/drivers/hwmon/gxp-fan-ctrl.c +++ b/drivers/hwmon/gxp-fan-ctrl.c @@ -168,7 +168,7 @@ static const struct hwmon_ops gxp_fan_ctrl_ops = { .write = gxp_fan_ctrl_write, }; -static const struct hwmon_channel_info *gxp_fan_ctrl_info[] = { +static const struct hwmon_channel_info * const gxp_fan_ctrl_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_FAULT | HWMON_F_ENABLE, HWMON_F_FAULT | HWMON_F_ENABLE, From 92b978fe7616486d9cbefbf2d99267f4258b758e Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:13 +0200 Subject: [PATCH 050/131] hwmon: i5500_temp: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/i5500_temp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/i5500_temp.c b/drivers/hwmon/i5500_temp.c index 23b9f94fe0a9b6..7b00b38c7f7bf2 100644 --- a/drivers/hwmon/i5500_temp.c +++ b/drivers/hwmon/i5500_temp.c @@ -88,7 +88,7 @@ static const struct hwmon_ops i5500_ops = { .read = i5500_read, }; -static const struct hwmon_channel_info *i5500_info[] = { +static const struct hwmon_channel_info * const i5500_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST | HWMON_T_CRIT | From bf9b7f92df737654fc7f3fff3fab320e97ff33de Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:14 +0200 Subject: [PATCH 051/131] hwmon: ina238: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/ina238.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ina238.c b/drivers/hwmon/ina238.c index 50eb9c5e132ef5..8af07bc0c50e0c 100644 --- a/drivers/hwmon/ina238.c +++ b/drivers/hwmon/ina238.c @@ -501,7 +501,7 @@ static umode_t ina238_is_visible(const void *drvdata, HWMON_I_MAX | HWMON_I_MAX_ALARM | \ HWMON_I_MIN | HWMON_I_MIN_ALARM) -static const struct hwmon_channel_info *ina238_info[] = { +static const struct hwmon_channel_info * const ina238_info[] = { HWMON_CHANNEL_INFO(in, /* 0: shunt voltage */ INA238_HWMON_IN_CONFIG, From 324399753854b8aaa6a621902a33e77f4425e7cf Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:15 +0200 Subject: [PATCH 052/131] hwmon: ina3221: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/ina3221.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index f3a4c5633b1ea6..2735e3782ffb42 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -650,7 +650,7 @@ static umode_t ina3221_is_visible(const void *drvdata, HWMON_C_CRIT | HWMON_C_CRIT_ALARM | \ HWMON_C_MAX | HWMON_C_MAX_ALARM) -static const struct hwmon_channel_info *ina3221_info[] = { +static const struct hwmon_channel_info * const ina3221_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_SAMPLES, HWMON_C_UPDATE_INTERVAL), From e374c4100b6154f80aaf12af39c67a942b519a87 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:16 +0200 Subject: [PATCH 053/131] hwmon: intel-m10-bmc: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/intel-m10-bmc-hwmon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/intel-m10-bmc-hwmon.c b/drivers/hwmon/intel-m10-bmc-hwmon.c index 2f0323c14bab29..6512f4bec79aad 100644 --- a/drivers/hwmon/intel-m10-bmc-hwmon.c +++ b/drivers/hwmon/intel-m10-bmc-hwmon.c @@ -24,7 +24,7 @@ struct m10bmc_sdata { struct m10bmc_hwmon_board_data { const struct m10bmc_sdata *tables[hwmon_max]; - const struct hwmon_channel_info **hinfo; + const struct hwmon_channel_info * const *hinfo; }; struct m10bmc_hwmon { @@ -67,7 +67,7 @@ static const struct m10bmc_sdata n3000bmc_power_tbl[] = { { 0x160, 0x0, 0x0, 0x0, 0x0, 1000, "Board Power" }, }; -static const struct hwmon_channel_info *n3000bmc_hinfo[] = { +static const struct hwmon_channel_info * const n3000bmc_hinfo[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST | HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_LABEL, @@ -154,7 +154,7 @@ static const struct m10bmc_hwmon_board_data n3000bmc_hwmon_bdata = { .hinfo = n3000bmc_hinfo, }; -static const struct hwmon_channel_info *d5005bmc_hinfo[] = { +static const struct hwmon_channel_info * const d5005bmc_hinfo[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST | HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_LABEL, @@ -280,7 +280,7 @@ static const struct m10bmc_sdata n5010bmc_curr_tbl[] = { { 0x1a0, 0x0, 0x0, 0x0, 0x0, 1, "CVL2 0.8V Current" }, }; -static const struct hwmon_channel_info *n5010bmc_hinfo[] = { +static const struct hwmon_channel_info * const n5010bmc_hinfo[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_LABEL, @@ -432,7 +432,7 @@ static const struct m10bmc_sdata n6000bmc_power_tbl[] = { { 0x724, 0x0, 0x0, 0x0, 0x0, 1, "Board Power" }, }; -static const struct hwmon_channel_info *n6000bmc_hinfo[] = { +static const struct hwmon_channel_info * const n6000bmc_hinfo[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_LABEL, From b3dc5eee6b2dce921ccfd40dd209b26885a31093 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:17 +0200 Subject: [PATCH 054/131] hwmon: jc42: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/jc42.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c index 8523bf974310bf..4c60dc520b1218 100644 --- a/drivers/hwmon/jc42.c +++ b/drivers/hwmon/jc42.c @@ -450,7 +450,7 @@ static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info) return -ENODEV; } -static const struct hwmon_channel_info *jc42_info[] = { +static const struct hwmon_channel_info * const jc42_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, From 4dd50f3c1d6521d8f4a688bb00d0228fbe65b2b8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:18 +0200 Subject: [PATCH 055/131] hwmon: k10temp: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index be8bbb1c3a02d9..ba2f6a4f8c167f 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -334,7 +334,7 @@ static bool has_erratum_319(struct pci_dev *pdev) (boot_cpu_data.x86_model == 4 && boot_cpu_data.x86_stepping <= 2); } -static const struct hwmon_channel_info *k10temp_info[] = { +static const struct hwmon_channel_info * const k10temp_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_CRIT_HYST | From 55f4466382313d17fb0712e7733d75a91c380f04 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:19 +0200 Subject: [PATCH 056/131] hwmon: k8temp: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/k8temp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index f73bd4eceb28f0..2b80ac410cd1b9 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c @@ -118,7 +118,7 @@ static const struct hwmon_ops k8temp_ops = { .read = k8temp_read, }; -static const struct hwmon_channel_info *k8temp_info[] = { +static const struct hwmon_channel_info * const k8temp_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT, HWMON_T_INPUT, HWMON_T_INPUT, HWMON_T_INPUT), NULL From 2d9011813e5ff462fef0c93d6fcea5a152b702ba Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:20 +0200 Subject: [PATCH 057/131] hwmon: lan966x: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/lan966x-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lan966x-hwmon.c b/drivers/hwmon/lan966x-hwmon.c index f41df053ac319b..f8658359a09805 100644 --- a/drivers/hwmon/lan966x-hwmon.c +++ b/drivers/hwmon/lan966x-hwmon.c @@ -260,7 +260,7 @@ static umode_t lan966x_hwmon_is_visible(const void *data, return mode; } -static const struct hwmon_channel_info *lan966x_hwmon_info[] = { +static const struct hwmon_channel_info * const lan966x_hwmon_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT), From 3ee2ceca3f1d65503a9d599a67d92a52a4aea5dc Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:21 +0200 Subject: [PATCH 058/131] hwmon: lm75: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/lm75.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index bcc3adcb3af1a5..dbb99ea4a0eccf 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -512,7 +512,7 @@ static umode_t lm75_is_visible(const void *data, enum hwmon_sensor_types type, return 0; } -static const struct hwmon_channel_info *lm75_info[] = { +static const struct hwmon_channel_info * const lm75_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, From 3c370243cbfa2d194fe9caa36772bf9d8e83110d Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:22 +0200 Subject: [PATCH 059/131] hwmon: lm83: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/lm83.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 616449f2cc5043..bcaf31ec176e9c 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -337,7 +337,7 @@ static umode_t lm83_is_visible(const void *_data, enum hwmon_sensor_types type, return 0; } -static const struct hwmon_channel_info *lm83_info[] = { +static const struct hwmon_channel_info * const lm83_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_ALARMS), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT | From 1d0cfeb2ea93c6378d62cab88a512a570578c152 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:23 +0200 Subject: [PATCH 060/131] hwmon: lm95241: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/lm95241.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c index f1ed777a87353c..647a90570bc6df 100644 --- a/drivers/hwmon/lm95241.c +++ b/drivers/hwmon/lm95241.c @@ -409,7 +409,7 @@ static void lm95241_init_client(struct i2c_client *client, data->model); } -static const struct hwmon_channel_info *lm95241_info[] = { +static const struct hwmon_channel_info * const lm95241_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, From 043f90c8d103f05bdb63aa03afd4d84e1a77bf41 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:24 +0200 Subject: [PATCH 061/131] hwmon: lm95245: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/lm95245.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lm95245.c b/drivers/hwmon/lm95245.c index c433f0af2d3185..4236d1e0544d7f 100644 --- a/drivers/hwmon/lm95245.c +++ b/drivers/hwmon/lm95245.c @@ -523,7 +523,7 @@ static const struct regmap_config lm95245_regmap_config = { .use_single_write = true, }; -static const struct hwmon_channel_info *lm95245_info[] = { +static const struct hwmon_channel_info * const lm95245_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, From bf36b752ca464582a0ec67fedf647d841071320e Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:25 +0200 Subject: [PATCH 062/131] hwmon: lochnagar: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/lochnagar-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lochnagar-hwmon.c b/drivers/hwmon/lochnagar-hwmon.c index 8b19adf2eeb07e..9948e2f7208db2 100644 --- a/drivers/hwmon/lochnagar-hwmon.c +++ b/drivers/hwmon/lochnagar-hwmon.c @@ -321,7 +321,7 @@ static const struct hwmon_ops lochnagar_ops = { .write = lochnagar_write, }; -static const struct hwmon_channel_info *lochnagar_info[] = { +static const struct hwmon_channel_info * const lochnagar_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), HWMON_CHANNEL_INFO(in, HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, From 53dc67eb935c8a3e18a06d10847cd761bd715ac4 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:26 +0200 Subject: [PATCH 063/131] hwmon: ltc2947: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/ltc2947-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ltc2947-core.c b/drivers/hwmon/ltc2947-core.c index 2dbbbac9de093d..d2ff6e700770d2 100644 --- a/drivers/hwmon/ltc2947-core.c +++ b/drivers/hwmon/ltc2947-core.c @@ -901,7 +901,7 @@ static umode_t ltc2947_is_visible(const void *data, } } -static const struct hwmon_channel_info *ltc2947_info[] = { +static const struct hwmon_channel_info * const ltc2947_info[] = { HWMON_CHANNEL_INFO(in, HWMON_I_INPUT | HWMON_I_LOWEST | HWMON_I_HIGHEST | HWMON_I_MAX | HWMON_I_MIN | HWMON_I_RESET_HISTORY | From 8cbafa6efece730bfb6f11829ec64c80437fbc96 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:27 +0200 Subject: [PATCH 064/131] hwmon: ltc2992: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/ltc2992.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ltc2992.c b/drivers/hwmon/ltc2992.c index 69341de397cb93..429a7f5837f091 100644 --- a/drivers/hwmon/ltc2992.c +++ b/drivers/hwmon/ltc2992.c @@ -812,7 +812,7 @@ static const struct hwmon_ops ltc2992_hwmon_ops = { .write = ltc2992_write, }; -static const struct hwmon_channel_info *ltc2992_info[] = { +static const struct hwmon_channel_info * const ltc2992_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_IN_RESET_HISTORY), HWMON_CHANNEL_INFO(in, From 38ab6d602ea1c332f06f9b22bcee5ea69deab14c Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:28 +0200 Subject: [PATCH 065/131] hwmon: ltc4245: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/ltc4245.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ltc4245.c b/drivers/hwmon/ltc4245.c index 57cbaf3b39faaf..fb9bc8dbe99bc2 100644 --- a/drivers/hwmon/ltc4245.c +++ b/drivers/hwmon/ltc4245.c @@ -387,7 +387,7 @@ static umode_t ltc4245_is_visible(const void *_data, } } -static const struct hwmon_channel_info *ltc4245_info[] = { +static const struct hwmon_channel_info * const ltc4245_info[] = { HWMON_CHANNEL_INFO(in, HWMON_I_INPUT, HWMON_I_INPUT | HWMON_I_MIN_ALARM, From 894fce118b8dbf3c5b93cd3e0fab186bae35a48f Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:29 +0200 Subject: [PATCH 066/131] hwmon: ltq-cputemp: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/ltq-cputemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ltq-cputemp.c b/drivers/hwmon/ltq-cputemp.c index 019e770d4c0cf2..08e09a82acab10 100644 --- a/drivers/hwmon/ltq-cputemp.c +++ b/drivers/hwmon/ltq-cputemp.c @@ -65,7 +65,7 @@ static umode_t ltq_is_visible(const void *_data, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *ltq_info[] = { +static const struct hwmon_channel_info * const ltq_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, From 2b1aec842ee248b2320cdaeea23c9ce6d4c3ea58 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:30 +0200 Subject: [PATCH 067/131] hwmon: max127: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/max127.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/max127.c b/drivers/hwmon/max127.c index 0e21e7e6bbd2e5..49de1d2be2949c 100644 --- a/drivers/hwmon/max127.c +++ b/drivers/hwmon/max127.c @@ -285,7 +285,7 @@ static const struct hwmon_ops max127_hwmon_ops = { .write = max127_write, }; -static const struct hwmon_channel_info *max127_info[] = { +static const struct hwmon_channel_info * const max127_info[] = { HWMON_CHANNEL_INFO(in, HWMON_I_INPUT | HWMON_I_MIN | HWMON_I_MAX, HWMON_I_INPUT | HWMON_I_MIN | HWMON_I_MAX, From c70164adbbdd15bc793bd4eed776ec4752dced82 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:31 +0200 Subject: [PATCH 068/131] hwmon: max31730: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/max31730.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/max31730.c b/drivers/hwmon/max31730.c index 746a767c9fc663..924333d89ce4da 100644 --- a/drivers/hwmon/max31730.c +++ b/drivers/hwmon/max31730.c @@ -248,7 +248,7 @@ static umode_t max31730_is_visible(const void *data, return 0; } -static const struct hwmon_channel_info *max31730_info[] = { +static const struct hwmon_channel_info * const max31730_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, From 02681a9f33ab1e18e7838b69c637ca3ec80ddb36 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:32 +0200 Subject: [PATCH 069/131] hwmon: max31760: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/max31760.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/max31760.c b/drivers/hwmon/max31760.c index 06d5f39dc33d30..4489110f109c52 100644 --- a/drivers/hwmon/max31760.c +++ b/drivers/hwmon/max31760.c @@ -318,7 +318,7 @@ static int max31760_write(struct device *dev, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *max31760_info[] = { +static const struct hwmon_channel_info * const max31760_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(fan, From 822ce415baa4f46e0c8fe03944ccd1bcee199583 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:33 +0200 Subject: [PATCH 070/131] hwmon: max31790: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/max31790.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c index 20bf5ffadefead..6caba6e8ee8f33 100644 --- a/drivers/hwmon/max31790.c +++ b/drivers/hwmon/max31790.c @@ -445,7 +445,7 @@ static umode_t max31790_is_visible(const void *data, } } -static const struct hwmon_channel_info *max31790_info[] = { +static const struct hwmon_channel_info * const max31790_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_TARGET | HWMON_F_FAULT | HWMON_F_ENABLE, HWMON_F_INPUT | HWMON_F_TARGET | HWMON_F_FAULT | HWMON_F_ENABLE, From b3fcd02c608184e1ab42710d4bc58b4c15fbf873 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:34 +0200 Subject: [PATCH 071/131] hwmon: max6620: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/max6620.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/max6620.c b/drivers/hwmon/max6620.c index 202b6438179d1f..0f277d945ea20d 100644 --- a/drivers/hwmon/max6620.c +++ b/drivers/hwmon/max6620.c @@ -401,7 +401,7 @@ max6620_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, return ret; } -static const struct hwmon_channel_info *max6620_info[] = { +static const struct hwmon_channel_info * const max6620_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_DIV | HWMON_F_TARGET | HWMON_F_ALARM, HWMON_F_INPUT | HWMON_F_DIV | HWMON_F_TARGET | HWMON_F_ALARM, From a7bae59766835188917b3d1f186ecf02f5628cde Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:35 +0200 Subject: [PATCH 072/131] hwmon: max6621: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/max6621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/max6621.c b/drivers/hwmon/max6621.c index 7821132e17faa8..0656eb1e7959b5 100644 --- a/drivers/hwmon/max6621.c +++ b/drivers/hwmon/max6621.c @@ -449,7 +449,7 @@ static const struct regmap_config max6621_regmap_config = { .num_reg_defaults = ARRAY_SIZE(max6621_regmap_default), }; -static const struct hwmon_channel_info *max6621_info[] = { +static const struct hwmon_channel_info * const max6621_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, From 1c80f98754952749873d02bea5e67883733e7b42 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:30:36 +0200 Subject: [PATCH 073/131] hwmon: max6650: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/max6650.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index f8d4534ce172ef..19e2c762ed2d61 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c @@ -737,7 +737,7 @@ static umode_t max6650_is_visible(const void *_data, return 0; } -static const struct hwmon_channel_info *max6650_info[] = { +static const struct hwmon_channel_info * const max6650_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_TARGET | HWMON_F_DIV | HWMON_F_MIN_ALARM | HWMON_F_MAX_ALARM | HWMON_F_FAULT, From 11305fd37b428e9afddd4acdc104d87774162c09 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:35:23 +0200 Subject: [PATCH 074/131] hwmon: mc34vr500: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/mc34vr500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/mc34vr500.c b/drivers/hwmon/mc34vr500.c index 6268e973049c58..6a7a950a933290 100644 --- a/drivers/hwmon/mc34vr500.c +++ b/drivers/hwmon/mc34vr500.c @@ -138,7 +138,7 @@ static int mc34vr500_read(struct device *dev, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *mc34vr500_info[] = { +static const struct hwmon_channel_info * const mc34vr500_info[] = { HWMON_CHANNEL_INFO(in, HWMON_I_MIN_ALARM), HWMON_CHANNEL_INFO(temp, HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM | HWMON_T_EMERGENCY_ALARM), From d716e0cf674d016ddeaeb25bede1bcd15366bc7f Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:35:24 +0200 Subject: [PATCH 075/131] hwmon: mcp3021: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/mcp3021.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/mcp3021.c b/drivers/hwmon/mcp3021.c index e093b199829681..a5f7a294f33d09 100644 --- a/drivers/hwmon/mcp3021.c +++ b/drivers/hwmon/mcp3021.c @@ -102,7 +102,7 @@ static umode_t mcp3021_is_visible(const void *_data, return 0444; } -static const struct hwmon_channel_info *mcp3021_info[] = { +static const struct hwmon_channel_info * const mcp3021_info[] = { HWMON_CHANNEL_INFO(in, HWMON_I_INPUT), NULL }; From bb54a54b5c660053e96032209c5f75c72070b676 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:35:25 +0200 Subject: [PATCH 076/131] hwmon: mlxreg: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/mlxreg-fan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c index 96017cc8da7ecd..c2a96468c9b47e 100644 --- a/drivers/hwmon/mlxreg-fan.c +++ b/drivers/hwmon/mlxreg-fan.c @@ -285,7 +285,7 @@ static char *mlxreg_fan_name[] = { "mlxreg_fan3", }; -static const struct hwmon_channel_info *mlxreg_fan_hwmon_info[] = { +static const struct hwmon_channel_info * const mlxreg_fan_hwmon_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_FAULT, HWMON_F_INPUT | HWMON_F_FAULT, From 2a06edbe33b21a7c6851f5d4f81f73e1407af040 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:35:26 +0200 Subject: [PATCH 077/131] hwmon: nct7904: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/nct7904.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c index ecc5db0011a3e4..007bae4c7028f7 100644 --- a/drivers/hwmon/nct7904.c +++ b/drivers/hwmon/nct7904.c @@ -803,7 +803,7 @@ static int nct7904_detect(struct i2c_client *client, return 0; } -static const struct hwmon_channel_info *nct7904_info[] = { +static const struct hwmon_channel_info * const nct7904_info[] = { HWMON_CHANNEL_INFO(in, /* dummy, skipped in is_visible */ HWMON_I_INPUT | HWMON_I_MIN | HWMON_I_MAX | From ed30302c3bccc1be2c3b3205c37b3f3a0da55138 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:35:27 +0200 Subject: [PATCH 078/131] hwmon: npcm750-pwm: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/npcm750-pwm-fan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/npcm750-pwm-fan.c b/drivers/hwmon/npcm750-pwm-fan.c index 11a28609da3c76..10ed3f4335d472 100644 --- a/drivers/hwmon/npcm750-pwm-fan.c +++ b/drivers/hwmon/npcm750-pwm-fan.c @@ -629,7 +629,7 @@ static umode_t npcm7xx_is_visible(const void *data, } } -static const struct hwmon_channel_info *npcm7xx_info[] = { +static const struct hwmon_channel_info * const npcm7xx_info[] = { HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT, HWMON_PWM_INPUT, From 9add51f2bc65340e5a42efa8f7312fbd9d13ee61 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:35:28 +0200 Subject: [PATCH 079/131] hwmon: ntc_thermistor: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/ntc_thermistor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 9c9e9f4ccb9e93..ef75b63f5894e5 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -546,7 +546,7 @@ static umode_t ntc_is_visible(const void *data, enum hwmon_sensor_types type, return 0; } -static const struct hwmon_channel_info *ntc_info[] = { +static const struct hwmon_channel_info * const ntc_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_TYPE), NULL From 98ce1fc134ef4450c798a9e198261b6d0b9b7cb2 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:35:29 +0200 Subject: [PATCH 080/131] hwmon: nzxt: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/nzxt-kraken2.c | 2 +- drivers/hwmon/nzxt-smart2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/nzxt-kraken2.c b/drivers/hwmon/nzxt-kraken2.c index 89f7ea4f42d47c..428c77b5fce5a2 100644 --- a/drivers/hwmon/nzxt-kraken2.c +++ b/drivers/hwmon/nzxt-kraken2.c @@ -86,7 +86,7 @@ static const struct hwmon_ops kraken2_hwmon_ops = { .read_string = kraken2_read_string, }; -static const struct hwmon_channel_info *kraken2_info[] = { +static const struct hwmon_channel_info * const kraken2_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL), HWMON_CHANNEL_INFO(fan, diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c index e5edf8071f398f..7aa586eb74be15 100644 --- a/drivers/hwmon/nzxt-smart2.c +++ b/drivers/hwmon/nzxt-smart2.c @@ -663,7 +663,7 @@ static const struct hwmon_ops nzxt_smart2_hwmon_ops = { .write = nzxt_smart2_hwmon_write, }; -static const struct hwmon_channel_info *nzxt_smart2_channel_info[] = { +static const struct hwmon_channel_info * const nzxt_smart2_channel_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_LABEL, HWMON_F_INPUT | HWMON_F_LABEL, HWMON_F_INPUT | HWMON_F_LABEL), From 195030d34ee9a77e851b23b9d5f174860e21a982 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:35:30 +0200 Subject: [PATCH 081/131] hwmon: oxp-sensors: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/oxp-sensors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index 36872b57912afd..ae67207030e8a3 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -239,7 +239,7 @@ static int oxp_platform_write(struct device *dev, enum hwmon_sensor_types type, } /* Known sensors in the OXP EC controllers */ -static const struct hwmon_channel_info *oxp_platform_sensors[] = { +static const struct hwmon_channel_info * const oxp_platform_sensors[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT), HWMON_CHANNEL_INFO(pwm, From 0c15d66d071c3490a9a3004b5a4c6f7524041a99 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:12 +0200 Subject: [PATCH 082/131] hwmon: peci: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/peci/cputemp.c | 2 +- drivers/hwmon/peci/dimmtemp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c index 87d56f0fc888c2..e5b65a382772c5 100644 --- a/drivers/hwmon/peci/cputemp.c +++ b/drivers/hwmon/peci/cputemp.c @@ -447,7 +447,7 @@ static const struct hwmon_ops peci_cputemp_ops = { .read = cputemp_read, }; -static const struct hwmon_channel_info *peci_cputemp_info[] = { +static const struct hwmon_channel_info * const peci_cputemp_info[] = { HWMON_CHANNEL_INFO(temp, /* Die temperature */ HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX | diff --git a/drivers/hwmon/peci/dimmtemp.c b/drivers/hwmon/peci/dimmtemp.c index 0a633bda36689b..ed968401f93cdc 100644 --- a/drivers/hwmon/peci/dimmtemp.c +++ b/drivers/hwmon/peci/dimmtemp.c @@ -300,7 +300,7 @@ static int create_dimm_temp_label(struct peci_dimmtemp *priv, int chan) return 0; } -static const struct hwmon_channel_info *peci_dimmtemp_temp_info[] = { +static const struct hwmon_channel_info * const peci_dimmtemp_temp_info[] = { HWMON_CHANNEL_INFO(temp, [0 ... DIMM_NUMS_MAX - 1] = HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT), From 42d273bcf4f2e74aa5591fa6a497c9ee48fe523e Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:13 +0200 Subject: [PATCH 083/131] hwmon: powr1220: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/powr1220.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c index f77dc6db31ac52..9cb0c2de521931 100644 --- a/drivers/hwmon/powr1220.c +++ b/drivers/hwmon/powr1220.c @@ -248,7 +248,7 @@ powr1220_read(struct device *dev, enum hwmon_sensor_types type, u32 return 0; } -static const struct hwmon_channel_info *powr1220_info[] = { +static const struct hwmon_channel_info * const powr1220_info[] = { HWMON_CHANNEL_INFO(in, HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL, From 70df9a55434b2c05f70163524007f1b4382489a3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:14 +0200 Subject: [PATCH 084/131] hwmon: raspberrypi: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/raspberrypi-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/raspberrypi-hwmon.c b/drivers/hwmon/raspberrypi-hwmon.c index 1650d3b4c26e5a..65cc52e47db081 100644 --- a/drivers/hwmon/raspberrypi-hwmon.c +++ b/drivers/hwmon/raspberrypi-hwmon.c @@ -87,7 +87,7 @@ static umode_t rpi_is_visible(const void *_data, enum hwmon_sensor_types type, return 0444; } -static const struct hwmon_channel_info *rpi_info[] = { +static const struct hwmon_channel_info * const rpi_info[] = { HWMON_CHANNEL_INFO(in, HWMON_I_LCRIT_ALARM), NULL From 29423978b76912b43ebb9ac6433be0f9dd7bd8fa Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:15 +0200 Subject: [PATCH 085/131] hwmon: sbrmi: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/sbrmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sbrmi.c b/drivers/hwmon/sbrmi.c index 8ea5a4d3219fff..529f0e766319be 100644 --- a/drivers/hwmon/sbrmi.c +++ b/drivers/hwmon/sbrmi.c @@ -265,7 +265,7 @@ static umode_t sbrmi_is_visible(const void *data, return 0; } -static const struct hwmon_channel_info *sbrmi_info[] = { +static const struct hwmon_channel_info * const sbrmi_info[] = { HWMON_CHANNEL_INFO(power, HWMON_P_INPUT | HWMON_P_CAP | HWMON_P_CAP_MAX), NULL From eeda3a44532371bf72ef80d163326ca1c65a5bda Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:16 +0200 Subject: [PATCH 086/131] hwmon: sbtsi_temp: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/sbtsi_temp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sbtsi_temp.c b/drivers/hwmon/sbtsi_temp.c index 4c37de846f93be..7049d9464ac6d4 100644 --- a/drivers/hwmon/sbtsi_temp.c +++ b/drivers/hwmon/sbtsi_temp.c @@ -182,7 +182,7 @@ static umode_t sbtsi_is_visible(const void *data, return 0; } -static const struct hwmon_channel_info *sbtsi_info[] = { +static const struct hwmon_channel_info * const sbtsi_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX), NULL From 1ff3d23d00184dc350394e3ca53fdce87daa1bc1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:17 +0200 Subject: [PATCH 087/131] hwmon: sch5627: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/sch5627.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c index 25fbbd4c9a2b31..1bbda3b05532e5 100644 --- a/drivers/hwmon/sch5627.c +++ b/drivers/hwmon/sch5627.c @@ -379,7 +379,7 @@ static const struct hwmon_ops sch5627_ops = { .write = sch5627_write, }; -static const struct hwmon_channel_info *sch5627_info[] = { +static const struct hwmon_channel_info * const sch5627_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_FAULT, From 11c1dff58c65ee6a5cbfa19af049ee8af01a91c6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:18 +0200 Subject: [PATCH 088/131] hwmon: sht4x: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/sht4x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sht4x.c b/drivers/hwmon/sht4x.c index 13e042927bf89e..5bbe09135ab9d8 100644 --- a/drivers/hwmon/sht4x.c +++ b/drivers/hwmon/sht4x.c @@ -214,7 +214,7 @@ static int sht4x_hwmon_write(struct device *dev, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *sht4x_info[] = { +static const struct hwmon_channel_info * const sht4x_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), HWMON_CHANNEL_INFO(humidity, HWMON_H_INPUT), From 7f46e9883f530068473f2adae93d3cf4a2f8b92e Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:19 +0200 Subject: [PATCH 089/131] hwmon: sl28cpld: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/sl28cpld-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sl28cpld-hwmon.c b/drivers/hwmon/sl28cpld-hwmon.c index 9ce4899a81a55c..e020f25c930050 100644 --- a/drivers/hwmon/sl28cpld-hwmon.c +++ b/drivers/hwmon/sl28cpld-hwmon.c @@ -67,7 +67,7 @@ static int sl28cpld_hwmon_read(struct device *dev, return 0; } -static const struct hwmon_channel_info *sl28cpld_hwmon_info[] = { +static const struct hwmon_channel_info * const sl28cpld_hwmon_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT), NULL }; From d302988c9867bc0daf2bf4057588a59fb2e637f6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:20 +0200 Subject: [PATCH 090/131] hwmon: smpro: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/smpro-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c index a76c49dd8438dc..d320adbd47f439 100644 --- a/drivers/hwmon/smpro-hwmon.c +++ b/drivers/hwmon/smpro-hwmon.c @@ -385,7 +385,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, return 0444; } -static const struct hwmon_channel_info *smpro_info[] = { +static const struct hwmon_channel_info * const smpro_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, From dc8811447c6be6959b0f18b5a06fd9eafeba32c6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:38:21 +0200 Subject: [PATCH 091/131] hwmon: sparx5-temp: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/sparx5-temp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sparx5-temp.c b/drivers/hwmon/sparx5-temp.c index 04fd8505e5d6ca..d640904939cda2 100644 --- a/drivers/hwmon/sparx5-temp.c +++ b/drivers/hwmon/sparx5-temp.c @@ -86,7 +86,7 @@ static umode_t s5_is_visible(const void *_data, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *s5_info[] = { +static const struct hwmon_channel_info * const s5_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), NULL From 5b5d8ae01954350f47b9d601ebfc7f96563c3496 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:19 +0200 Subject: [PATCH 092/131] hwmon: sy7636a: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/sy7636a-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sy7636a-hwmon.c b/drivers/hwmon/sy7636a-hwmon.c index 6dd9c2a0f0e03c..ed110884786b48 100644 --- a/drivers/hwmon/sy7636a-hwmon.c +++ b/drivers/hwmon/sy7636a-hwmon.c @@ -52,7 +52,7 @@ static const struct hwmon_ops sy7636a_hwmon_ops = { .read = sy7636a_read, }; -static const struct hwmon_channel_info *sy7636a_info[] = { +static const struct hwmon_channel_info * const sy7636a_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), NULL From fc3ad66804807efa88a6e8c97869ada1b59a257d Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:20 +0200 Subject: [PATCH 093/131] hwmon: tmp102: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/tmp102.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c index 2bf496a62206ae..e271556efe0b86 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c @@ -141,7 +141,7 @@ static umode_t tmp102_is_visible(const void *data, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *tmp102_info[] = { +static const struct hwmon_channel_info * const tmp102_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, From a705bc468840a3392771477a28aaa394b493aecc Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:21 +0200 Subject: [PATCH 094/131] hwmon: tmp103: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/tmp103.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/tmp103.c b/drivers/hwmon/tmp103.c index 56d5cbf36a45b4..d257bb91fc6954 100644 --- a/drivers/hwmon/tmp103.c +++ b/drivers/hwmon/tmp103.c @@ -119,7 +119,7 @@ static umode_t tmp103_is_visible(const void *data, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *tmp103_info[] = { +static const struct hwmon_channel_info * const tmp103_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, From 1198c51f8fb312450c0cb01f989d2537d43dcd0b Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:22 +0200 Subject: [PATCH 095/131] hwmon: tmp108: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/tmp108.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/tmp108.c b/drivers/hwmon/tmp108.c index acb4ba750b09c7..43784c289a9e94 100644 --- a/drivers/hwmon/tmp108.c +++ b/drivers/hwmon/tmp108.c @@ -272,7 +272,7 @@ static umode_t tmp108_is_visible(const void *data, enum hwmon_sensor_types type, } } -static const struct hwmon_channel_info *tmp108_info[] = { +static const struct hwmon_channel_info * const tmp108_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, From 98bc085cae3e350fdf1e4b7f60c8fd80dc6b84cc Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:23 +0200 Subject: [PATCH 096/131] hwmon: tmp464: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/tmp464.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/tmp464.c b/drivers/hwmon/tmp464.c index 7814f39bd1a376..9213a493a590a5 100644 --- a/drivers/hwmon/tmp464.c +++ b/drivers/hwmon/tmp464.c @@ -589,7 +589,7 @@ static const struct hwmon_ops tmp464_ops = { .write = tmp464_write, }; -static const struct hwmon_channel_info *tmp464_info[] = { +static const struct hwmon_channel_info * const tmp464_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, From b39c94a1f6f0aa3c0438588340495d5c777e2f4f Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:24 +0200 Subject: [PATCH 097/131] hwmon: tmp513: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/tmp513.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/tmp513.c b/drivers/hwmon/tmp513.c index 7d5f7441aceb10..0693eaee054ffe 100644 --- a/drivers/hwmon/tmp513.c +++ b/drivers/hwmon/tmp513.c @@ -491,7 +491,7 @@ static umode_t tmp51x_is_visible(const void *_data, return 0; } -static const struct hwmon_channel_info *tmp51x_info[] = { +static const struct hwmon_channel_info * const tmp51x_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_CRIT_ALARM | HWMON_T_CRIT_HYST, From 7325fea5a5213d91805dc9dc448686b110df82ec Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:25 +0200 Subject: [PATCH 098/131] hwmon: tps23861: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/tps23861.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c index 68c77c49327002..85a75f55114893 100644 --- a/drivers/hwmon/tps23861.c +++ b/drivers/hwmon/tps23861.c @@ -341,7 +341,7 @@ static int tps23861_read_string(struct device *dev, return 0; } -static const struct hwmon_channel_info *tps23861_info[] = { +static const struct hwmon_channel_info * const tps23861_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), HWMON_CHANNEL_INFO(temp, From b418bd0a3119ae97cdfc9ab71193e494efc5add8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:26 +0200 Subject: [PATCH 099/131] hwmon: w83627ehf: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/w83627ehf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 939d4c35e713c1..fe960c0a624f77 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -1640,7 +1640,7 @@ static const struct hwmon_ops w83627ehf_ops = { .write = w83627ehf_write, }; -static const struct hwmon_channel_info *w83627ehf_info[] = { +static const struct hwmon_channel_info * const w83627ehf_info[] = { HWMON_CHANNEL_INFO(fan, HWMON_F_ALARM | HWMON_F_DIV | HWMON_F_INPUT | HWMON_F_MIN, HWMON_F_ALARM | HWMON_F_DIV | HWMON_F_INPUT | HWMON_F_MIN, From 3bf8437be3755084e77cea6b68aec71235301cbe Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 6 Apr 2023 22:40:27 +0200 Subject: [PATCH 100/131] hwmon: w83773g: constify pointers to hwmon_channel_info Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Guenter Roeck --- drivers/hwmon/w83773g.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/w83773g.c b/drivers/hwmon/w83773g.c index 88d11dc5feb98a..8dbcd05abd9ad2 100644 --- a/drivers/hwmon/w83773g.c +++ b/drivers/hwmon/w83773g.c @@ -233,7 +233,7 @@ static umode_t w83773_is_visible(const void *data, enum hwmon_sensor_types type, return 0; } -static const struct hwmon_channel_info *w83773_info[] = { +static const struct hwmon_channel_info * const w83773_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, From 38c92a3110106e1b75d6d3c237478a11fefb461f Mon Sep 17 00:00:00 2001 From: James Seo Date: Wed, 5 Apr 2023 07:31:05 +0000 Subject: [PATCH 101/131] hwmon: remove trailing whitespace in Kconfig Remove an unneeded trailing space. Signed-off-by: James Seo Link: https://lore.kernel.org/r/20230405073056.53466-2-james@equiv.tech Signed-off-by: Guenter Roeck --- drivers/hwmon/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 5b3b76477b0e3f..0d6b60b8d0d2da 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1976,7 +1976,7 @@ config SENSORS_ADS7871 config SENSORS_AMC6821 tristate "Texas Instruments AMC6821" - depends on I2C + depends on I2C help If you say yes here you get support for the Texas Instruments AMC6821 hardware monitoring chips. From b0eb085b4f960a2961e566b5608470e493b2003d Mon Sep 17 00:00:00 2001 From: James Seo Date: Wed, 5 Apr 2023 07:31:07 +0000 Subject: [PATCH 102/131] hwmon: fix typo in Makefile Fix the spelling of "ACPI" in Makefile. Signed-off-by: James Seo Link: https://lore.kernel.org/r/20230405073056.53466-3-james@equiv.tech Signed-off-by: Guenter Roeck --- drivers/hwmon/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 88712b5031c87c..e12c111a174ad3 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -6,7 +6,7 @@ obj-$(CONFIG_HWMON) += hwmon.o obj-$(CONFIG_HWMON_VID) += hwmon-vid.o -# APCI drivers +# ACPI drivers obj-$(CONFIG_SENSORS_ACPI_POWER) += acpi_power_meter.o obj-$(CONFIG_SENSORS_ATK0110) += asus_atk0110.o obj-$(CONFIG_SENSORS_ASUS_EC) += asus-ec-sensors.o From c7ba3e26fd988116c98e7c8b9c27262b78db594c Mon Sep 17 00:00:00 2001 From: fireflame90051 Date: Thu, 6 Apr 2023 00:43:38 +0200 Subject: [PATCH 103/131] hwmon: (asus-ec-sensors) add ProArt B550-Creator Add support for the ASUS ProArt B550-Creator board, was tested with the hardware [1]. [1] https://github.com/zeule/asus-ec-sensors/issues/35 Signed-off-by: Eugene Shalygin Signed-off-by: fireflame90051 Link: https://lore.kernel.org/r/20230405224339.358675-2-eugene.shalygin@gmail.com Signed-off-by: Guenter Roeck --- Documentation/hwmon/asus_ec_sensors.rst | 1 + drivers/hwmon/asus-ec-sensors.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/hwmon/asus_ec_sensors.rst b/Documentation/hwmon/asus_ec_sensors.rst index a4039f2f9ca4f4..f1c9b1e11268c7 100644 --- a/Documentation/hwmon/asus_ec_sensors.rst +++ b/Documentation/hwmon/asus_ec_sensors.rst @@ -8,6 +8,7 @@ Supported boards: * PRIME X570-PRO * Pro WS X570-ACE * ProArt X570-CREATOR WIFI + * ProArt B550-CREATOR * ROG CROSSHAIR VIII DARK HERO * ROG CROSSHAIR VIII HERO (WI-FI) * ROG CROSSHAIR VIII FORMULA diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c index 2768b7511684f8..594fe724111116 100644 --- a/drivers/hwmon/asus-ec-sensors.c +++ b/drivers/hwmon/asus-ec-sensors.c @@ -303,6 +303,14 @@ static const struct ec_board_info board_info_pro_art_x570_creator_wifi = { .family = family_amd_500_series, }; +static const struct ec_board_info board_info_pro_art_b550_creator = { + .sensors = SENSOR_SET_TEMP_CHIPSET_CPU_MB | + SENSOR_TEMP_T_SENSOR | + SENSOR_FAN_CPU_OPT, + .mutex_path = ASUS_HW_ACCESS_MUTEX_ASMX, + .family = family_amd_500_series, +}; + static const struct ec_board_info board_info_pro_ws_x570_ace = { .sensors = SENSOR_SET_TEMP_CHIPSET_CPU_MB | SENSOR_TEMP_VRM | SENSOR_TEMP_T_SENSOR | SENSOR_FAN_CHIPSET | @@ -435,6 +443,8 @@ static const struct dmi_system_id dmi_table[] = { &board_info_prime_x570_pro), DMI_EXACT_MATCH_ASUS_BOARD_NAME("ProArt X570-CREATOR WIFI", &board_info_pro_art_x570_creator_wifi), + DMI_EXACT_MATCH_ASUS_BOARD_NAME("ProArt B550-CREATOR", + &board_info_pro_art_b550_creator), DMI_EXACT_MATCH_ASUS_BOARD_NAME("Pro WS X570-ACE", &board_info_pro_ws_x570_ace), DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR VIII DARK HERO", From 3a31e0920308487331e53a53c4133ce1d8e12ad9 Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Thu, 6 Apr 2023 00:43:39 +0200 Subject: [PATCH 104/131] hwmon: (asus-ec-sensors) add ROG STRIX Z390-F GAMING The definition comes from a LHM PR [1], and the mutex path from the ACPI dump, kindly provided by the PR author [2] [1] https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/pull/1031 [2] https://github.com/zeule/asus-ec-sensors/issues/36 Signed-off-by: Eugene Shalygin Link: https://lore.kernel.org/r/20230405224339.358675-3-eugene.shalygin@gmail.com Signed-off-by: Guenter Roeck --- Documentation/hwmon/asus_ec_sensors.rst | 1 + drivers/hwmon/asus-ec-sensors.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/hwmon/asus_ec_sensors.rst b/Documentation/hwmon/asus_ec_sensors.rst index f1c9b1e11268c7..c92c1d3839e4e9 100644 --- a/Documentation/hwmon/asus_ec_sensors.rst +++ b/Documentation/hwmon/asus_ec_sensors.rst @@ -22,6 +22,7 @@ Supported boards: * ROG STRIX X570-E GAMING WIFI II * ROG STRIX X570-F GAMING * ROG STRIX X570-I GAMING + * ROG STRIX Z390-F GAMING * ROG STRIX Z690-A GAMING WIFI D4 * ROG ZENITH II EXTREME * ROG ZENITH II EXTREME ALPHA diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c index 594fe724111116..e5be0cf472fc93 100644 --- a/drivers/hwmon/asus-ec-sensors.c +++ b/drivers/hwmon/asus-ec-sensors.c @@ -408,6 +408,14 @@ static const struct ec_board_info board_info_strix_x570_i_gaming = { .family = family_amd_500_series, }; +static const struct ec_board_info board_info_strix_z390_f_gaming = { + .sensors = SENSOR_TEMP_CHIPSET | SENSOR_TEMP_VRM | + SENSOR_TEMP_T_SENSOR | + SENSOR_FAN_CPU_OPT, + .mutex_path = ASUS_HW_ACCESS_MUTEX_ASMX, + .family = family_intel_300_series, +}; + static const struct ec_board_info board_info_strix_z690_a_gaming_wifi_d4 = { .sensors = SENSOR_TEMP_T_SENSOR | SENSOR_TEMP_VRM, .mutex_path = ASUS_HW_ACCESS_MUTEX_RMTW_ASMX, @@ -473,6 +481,8 @@ static const struct dmi_system_id dmi_table[] = { &board_info_strix_x570_f_gaming), DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X570-I GAMING", &board_info_strix_x570_i_gaming), + DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX Z390-F GAMING", + &board_info_strix_z390_f_gaming), DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX Z690-A GAMING WIFI D4", &board_info_strix_z690_a_gaming_wifi_d4), DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG ZENITH II EXTREME", From 6c2b659913ad9c70c30050efc3e287fd0869012a Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 30 Mar 2023 18:33:45 +0800 Subject: [PATCH 105/131] hwmon: (coretemp) Delete tjmax debug message After commit c0c67f8761ce ("hwmon: (coretemp) Add support for dynamic tjmax"), tjmax value is retrieved from MSR every time the temperature is read. This means that, with debug message enabled, the tjmax debug message is printed out for every single temperature read for any CPU. This spams the syslog. Ideally, as tjmax is package scope unique, the debug message should show once when tjmax is changed for one package. But this requires inventing some new per-package data in the coretemp driver, and this is overkill. To keep the code simple, delete the tjmax debug message. Signed-off-by: Zhang Rui Link: https://lore.kernel.org/r/20230330103346.6044-1-rui.zhang@intel.com Signed-off-by: Guenter Roeck --- drivers/hwmon/coretemp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 30d77f451937a1..fe3d4d0dcbedff 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -286,10 +286,8 @@ static int get_tjmax(struct temp_data *tdata, struct device *dev) * If the TjMax is not plausible, an assumption * will be used */ - if (val) { - dev_dbg(dev, "TjMax is %d degrees C\n", val); + if (val) return val * 1000; - } } if (force_tjmax) { From a2930f6dc90f07b2d956cab5f98b594b16918132 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 30 Mar 2023 18:33:46 +0800 Subject: [PATCH 106/131] hwmon: (coretemp) Delete an obsolete comment The refinement of tjmax value retrieved from MSR_IA32_TEMPERATURE_TARGET has been changed for several times. Now, the raw value from MSR is used without refinement. Thus remove the obsolete comment. Signed-off-by: Zhang Rui Link: https://lore.kernel.org/r/20230330103346.6044-2-rui.zhang@intel.com Signed-off-by: Guenter Roeck --- drivers/hwmon/coretemp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index fe3d4d0dcbedff..eba94f68585a8f 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -282,10 +282,6 @@ static int get_tjmax(struct temp_data *tdata, struct device *dev) dev_warn(dev, "Unable to read TjMax from CPU %u\n", tdata->cpu); } else { val = (eax >> 16) & 0xff; - /* - * If the TjMax is not plausible, an assumption - * will be used - */ if (val) return val * 1000; } From d16718fcdde702c70fd07f8f3e1e0f67166389aa Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Tue, 21 Mar 2023 10:26:43 +0800 Subject: [PATCH 107/131] dt-bindings: hwmon: Add starfive,jh71x0-temp Add bindings for the temperature sensor on the StarFive JH7100 and JH7110 SoCs. Signed-off-by: Emil Renner Berthing Signed-off-by: Hal Feng Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20230321022644.107027-2-hal.feng@starfivetech.com Signed-off-by: Guenter Roeck --- .../bindings/hwmon/starfive,jh71x0-temp.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jh71x0-temp.yaml diff --git a/Documentation/devicetree/bindings/hwmon/starfive,jh71x0-temp.yaml b/Documentation/devicetree/bindings/hwmon/starfive,jh71x0-temp.yaml new file mode 100644 index 00000000000000..f5b34528928ddf --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/starfive,jh71x0-temp.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/starfive,jh71x0-temp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH71x0 Temperature Sensor + +maintainers: + - Emil Renner Berthing + +description: | + StarFive Technology Co. JH71x0 embedded temperature sensor + +properties: + compatible: + enum: + - starfive,jh7100-temp + - starfive,jh7110-temp + + reg: + maxItems: 1 + + clocks: + minItems: 2 + maxItems: 2 + + clock-names: + items: + - const: "sense" + - const: "bus" + + '#thermal-sensor-cells': + const: 0 + + resets: + minItems: 2 + maxItems: 2 + + reset-names: + items: + - const: "sense" + - const: "bus" + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + +additionalProperties: false + +examples: + - | + #include + #include + + temperature-sensor@124a0000 { + compatible = "starfive,jh7100-temp"; + reg = <0x124a0000 0x10000>; + clocks = <&clkgen JH7100_CLK_TEMP_SENSE>, + <&clkgen JH7100_CLK_TEMP_APB>; + clock-names = "sense", "bus"; + #thermal-sensor-cells = <0>; + resets = <&rstgen JH7100_RSTN_TEMP_SENSE>, + <&rstgen JH7100_RSTN_TEMP_APB>; + reset-names = "sense", "bus"; + }; From 7f2958e845d2c8bf1100dc088dbdc31af2a80fd0 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Tue, 21 Mar 2023 10:26:44 +0800 Subject: [PATCH 108/131] hwmon: (sfctemp) Add StarFive JH71x0 temperature sensor Add driver for the StarFive JH71x0 temperature sensor. You can enable/disable it and read temperature in milli Celcius through sysfs. Signed-off-by: Emil Renner Berthing Co-developed-by: Samin Guo Signed-off-by: Samin Guo Signed-off-by: Hal Feng Link: https://lore.kernel.org/r/20230321022644.107027-3-hal.feng@starfivetech.com Signed-off-by: Guenter Roeck --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/sfctemp.rst | 33 ++++ MAINTAINERS | 8 + drivers/hwmon/Kconfig | 10 + drivers/hwmon/Makefile | 1 + drivers/hwmon/sfctemp.c | 331 ++++++++++++++++++++++++++++++++ 6 files changed, 384 insertions(+) create mode 100644 Documentation/hwmon/sfctemp.rst create mode 100644 drivers/hwmon/sfctemp.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index f1fe75f596a59d..d72bb1df643193 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -184,6 +184,7 @@ Hardware Monitoring Kernel Drivers sch5627 sch5636 scpi-hwmon + sfctemp sht15 sht21 sht3x diff --git a/Documentation/hwmon/sfctemp.rst b/Documentation/hwmon/sfctemp.rst new file mode 100644 index 00000000000000..9fbd5bb1f356d4 --- /dev/null +++ b/Documentation/hwmon/sfctemp.rst @@ -0,0 +1,33 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver sfctemp +===================== + +Supported chips: + - StarFive JH7100 + - StarFive JH7110 + +Authors: + - Emil Renner Berthing + +Description +----------- + +This driver adds support for reading the built-in temperature sensor on the +JH7100 and JH7110 RISC-V SoCs by StarFive Technology Co. Ltd. + +``sysfs`` interface +------------------- + +The temperature sensor can be enabled, disabled and queried via the standard +hwmon interface in sysfs under ``/sys/class/hwmon/hwmonX`` for some value of +``X``: + +================ ==== ============================================= +Name Perm Description +================ ==== ============================================= +temp1_enable RW Enable or disable temperature sensor. + Automatically enabled by the driver, + but may be disabled to save power. +temp1_input RO Temperature reading in milli-degrees Celsius. +================ ==== ============================================= diff --git a/MAINTAINERS b/MAINTAINERS index 9e9381babb0671..3ddafe6be4bc31 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18908,6 +18908,14 @@ S: Supported F: Documentation/networking/devlink/sfc.rst F: drivers/net/ethernet/sfc/ +SFCTEMP HWMON DRIVER +M: Emil Renner Berthing +L: linux-hwmon@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/hwmon/starfive,jh71x0-temp.yaml +F: Documentation/hwmon/sfctemp.rst +F: drivers/hwmon/sfctemp.c + SFF/SFP/SFP+ MODULE SUPPORT M: Russell King L: netdev@vger.kernel.org diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 0d6b60b8d0d2da..fc640201a2dea3 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1929,6 +1929,16 @@ config SENSORS_STTS751 This driver can also be built as a module. If so, the module will be called stts751. +config SENSORS_SFCTEMP + tristate "Starfive JH71x0 temperature sensor" + depends on ARCH_STARFIVE || COMPILE_TEST + help + If you say yes here you get support for temperature sensor + on the Starfive JH71x0 SoCs. + + This driver can also be built as a module. If so, the module + will be called sfctemp. + config SENSORS_SMM665 tristate "Summit Microelectronics SMM665" depends on I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index e12c111a174ad3..cd8c568c80a9bc 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -181,6 +181,7 @@ obj-$(CONFIG_SENSORS_SBRMI) += sbrmi.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o obj-$(CONFIG_SENSORS_SCH5636) += sch5636.o +obj-$(CONFIG_SENSORS_SFCTEMP) += sfctemp.o obj-$(CONFIG_SENSORS_SL28CPLD) += sl28cpld-hwmon.o obj-$(CONFIG_SENSORS_SHT15) += sht15.o obj-$(CONFIG_SENSORS_SHT21) += sht21.o diff --git a/drivers/hwmon/sfctemp.c b/drivers/hwmon/sfctemp.c new file mode 100644 index 00000000000000..d7484e2b81005a --- /dev/null +++ b/drivers/hwmon/sfctemp.c @@ -0,0 +1,331 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Emil Renner Berthing + * Copyright (C) 2021 Samin Guo + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * TempSensor reset. The RSTN can be de-asserted once the analog core has + * powered up. Trst(min 100ns) + * 0:reset 1:de-assert + */ +#define SFCTEMP_RSTN BIT(0) + +/* + * TempSensor analog core power down. The analog core will be powered up + * Tpu(min 50us) after PD is de-asserted. RSTN should be held low until the + * analog core is powered up. + * 0:power up 1:power down + */ +#define SFCTEMP_PD BIT(1) + +/* + * TempSensor start conversion enable. + * 0:disable 1:enable + */ +#define SFCTEMP_RUN BIT(2) + +/* + * TempSensor conversion value output. + * Temp(C)=DOUT*Y/4094 - K + */ +#define SFCTEMP_DOUT_POS 16 +#define SFCTEMP_DOUT_MSK GENMASK(27, 16) + +/* DOUT to Celcius conversion constants */ +#define SFCTEMP_Y1000 237500L +#define SFCTEMP_Z 4094L +#define SFCTEMP_K1000 81100L + +struct sfctemp { + /* serialize access to hardware register and enabled below */ + struct mutex lock; + void __iomem *regs; + struct clk *clk_sense; + struct clk *clk_bus; + struct reset_control *rst_sense; + struct reset_control *rst_bus; + bool enabled; +}; + +static void sfctemp_power_up(struct sfctemp *sfctemp) +{ + /* make sure we're powered down first */ + writel(SFCTEMP_PD, sfctemp->regs); + udelay(1); + + writel(0, sfctemp->regs); + /* wait t_pu(50us) + t_rst(100ns) */ + usleep_range(60, 200); + + /* de-assert reset */ + writel(SFCTEMP_RSTN, sfctemp->regs); + udelay(1); /* wait t_su(500ps) */ +} + +static void sfctemp_power_down(struct sfctemp *sfctemp) +{ + writel(SFCTEMP_PD, sfctemp->regs); +} + +static void sfctemp_run(struct sfctemp *sfctemp) +{ + writel(SFCTEMP_RSTN | SFCTEMP_RUN, sfctemp->regs); + udelay(1); +} + +static void sfctemp_stop(struct sfctemp *sfctemp) +{ + writel(SFCTEMP_RSTN, sfctemp->regs); +} + +static int sfctemp_enable(struct sfctemp *sfctemp) +{ + int ret = 0; + + mutex_lock(&sfctemp->lock); + if (sfctemp->enabled) + goto done; + + ret = clk_prepare_enable(sfctemp->clk_bus); + if (ret) + goto err; + ret = reset_control_deassert(sfctemp->rst_bus); + if (ret) + goto err_disable_bus; + + ret = clk_prepare_enable(sfctemp->clk_sense); + if (ret) + goto err_assert_bus; + ret = reset_control_deassert(sfctemp->rst_sense); + if (ret) + goto err_disable_sense; + + sfctemp_power_up(sfctemp); + sfctemp_run(sfctemp); + sfctemp->enabled = true; +done: + mutex_unlock(&sfctemp->lock); + return ret; + +err_disable_sense: + clk_disable_unprepare(sfctemp->clk_sense); +err_assert_bus: + reset_control_assert(sfctemp->rst_bus); +err_disable_bus: + clk_disable_unprepare(sfctemp->clk_bus); +err: + mutex_unlock(&sfctemp->lock); + return ret; +} + +static int sfctemp_disable(struct sfctemp *sfctemp) +{ + mutex_lock(&sfctemp->lock); + if (!sfctemp->enabled) + goto done; + + sfctemp_stop(sfctemp); + sfctemp_power_down(sfctemp); + reset_control_assert(sfctemp->rst_sense); + clk_disable_unprepare(sfctemp->clk_sense); + reset_control_assert(sfctemp->rst_bus); + clk_disable_unprepare(sfctemp->clk_bus); + sfctemp->enabled = false; +done: + mutex_unlock(&sfctemp->lock); + return 0; +} + +static void sfctemp_disable_action(void *data) +{ + sfctemp_disable(data); +} + +static int sfctemp_convert(struct sfctemp *sfctemp, long *val) +{ + int ret; + + mutex_lock(&sfctemp->lock); + if (!sfctemp->enabled) { + ret = -ENODATA; + goto out; + } + + /* calculate temperature in milli Celcius */ + *val = (long)((readl(sfctemp->regs) & SFCTEMP_DOUT_MSK) >> SFCTEMP_DOUT_POS) + * SFCTEMP_Y1000 / SFCTEMP_Z - SFCTEMP_K1000; + + ret = 0; +out: + mutex_unlock(&sfctemp->lock); + return ret; +} + +static umode_t sfctemp_is_visible(const void *data, enum hwmon_sensor_types type, + u32 attr, int channel) +{ + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_enable: + return 0644; + case hwmon_temp_input: + return 0444; + default: + return 0; + } + default: + return 0; + } +} + +static int sfctemp_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + struct sfctemp *sfctemp = dev_get_drvdata(dev); + + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_enable: + *val = sfctemp->enabled; + return 0; + case hwmon_temp_input: + return sfctemp_convert(sfctemp, val); + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +static int sfctemp_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) +{ + struct sfctemp *sfctemp = dev_get_drvdata(dev); + + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_enable: + if (val == 0) + return sfctemp_disable(sfctemp); + if (val == 1) + return sfctemp_enable(sfctemp); + return -EINVAL; + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +static const struct hwmon_channel_info *sfctemp_info[] = { + HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), + HWMON_CHANNEL_INFO(temp, HWMON_T_ENABLE | HWMON_T_INPUT), + NULL +}; + +static const struct hwmon_ops sfctemp_hwmon_ops = { + .is_visible = sfctemp_is_visible, + .read = sfctemp_read, + .write = sfctemp_write, +}; + +static const struct hwmon_chip_info sfctemp_chip_info = { + .ops = &sfctemp_hwmon_ops, + .info = sfctemp_info, +}; + +static int sfctemp_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device *hwmon_dev; + struct sfctemp *sfctemp; + int ret; + + sfctemp = devm_kzalloc(dev, sizeof(*sfctemp), GFP_KERNEL); + if (!sfctemp) + return -ENOMEM; + + dev_set_drvdata(dev, sfctemp); + mutex_init(&sfctemp->lock); + + sfctemp->regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(sfctemp->regs)) + return PTR_ERR(sfctemp->regs); + + sfctemp->clk_sense = devm_clk_get(dev, "sense"); + if (IS_ERR(sfctemp->clk_sense)) + return dev_err_probe(dev, PTR_ERR(sfctemp->clk_sense), + "error getting sense clock\n"); + + sfctemp->clk_bus = devm_clk_get(dev, "bus"); + if (IS_ERR(sfctemp->clk_bus)) + return dev_err_probe(dev, PTR_ERR(sfctemp->clk_bus), + "error getting bus clock\n"); + + sfctemp->rst_sense = devm_reset_control_get_exclusive(dev, "sense"); + if (IS_ERR(sfctemp->rst_sense)) + return dev_err_probe(dev, PTR_ERR(sfctemp->rst_sense), + "error getting sense reset\n"); + + sfctemp->rst_bus = devm_reset_control_get_exclusive(dev, "bus"); + if (IS_ERR(sfctemp->rst_bus)) + return dev_err_probe(dev, PTR_ERR(sfctemp->rst_bus), + "error getting busreset\n"); + + ret = reset_control_assert(sfctemp->rst_sense); + if (ret) + return dev_err_probe(dev, ret, "error asserting sense reset\n"); + + ret = reset_control_assert(sfctemp->rst_bus); + if (ret) + return dev_err_probe(dev, ret, "error asserting bus reset\n"); + + ret = devm_add_action(dev, sfctemp_disable_action, sfctemp); + if (ret) + return ret; + + ret = sfctemp_enable(sfctemp); + if (ret) + return dev_err_probe(dev, ret, "error enabling temperature sensor: %d\n", ret); + + hwmon_dev = devm_hwmon_device_register_with_info(dev, "sfctemp", sfctemp, + &sfctemp_chip_info, NULL); + return PTR_ERR_OR_ZERO(hwmon_dev); +} + +static const struct of_device_id sfctemp_of_match[] = { + { .compatible = "starfive,jh7100-temp" }, + { .compatible = "starfive,jh7110-temp" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, sfctemp_of_match); + +static struct platform_driver sfctemp_driver = { + .probe = sfctemp_probe, + .driver = { + .name = "sfctemp", + .of_match_table = sfctemp_of_match, + }, +}; +module_platform_driver(sfctemp_driver); + +MODULE_AUTHOR("Emil Renner Berthing"); +MODULE_DESCRIPTION("StarFive JH71x0 temperature sensor driver"); +MODULE_LICENSE("GPL"); From ffe36eb557d375ff7667d249aecdf08ed5acf55d Mon Sep 17 00:00:00 2001 From: Naresh Solanki Date: Tue, 28 Mar 2023 17:03:33 +0200 Subject: [PATCH 109/131] hwmon: (pmbus/core) Add rdev in pmbus_data struct Add regulator device in pmbus_data & initialize the same during PMBus regulator register. Signed-off-by: Naresh Solanki Link: https://lore.kernel.org/r/20230328150335.90238-1-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus_core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 0ddef2c9ba9bf0..d93405f1a49524 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -81,6 +81,7 @@ struct pmbus_label { struct pmbus_data { struct device *dev; struct device *hwmon_dev; + struct regulator_dev **rdevs; u32 flags; /* from platform data */ @@ -3109,9 +3110,13 @@ static int pmbus_regulator_register(struct pmbus_data *data) struct device *dev = data->dev; const struct pmbus_driver_info *info = data->info; const struct pmbus_platform_data *pdata = dev_get_platdata(dev); - struct regulator_dev *rdev; int i; + data->rdevs = devm_kzalloc(dev, sizeof(struct regulator_dev *) * info->num_regulators, + GFP_KERNEL); + if (!data->rdevs) + return -ENOMEM; + for (i = 0; i < info->num_regulators; i++) { struct regulator_config config = { }; @@ -3121,10 +3126,10 @@ static int pmbus_regulator_register(struct pmbus_data *data) if (pdata && pdata->reg_init_data) config.init_data = &pdata->reg_init_data[i]; - rdev = devm_regulator_register(dev, &info->reg_desc[i], - &config); - if (IS_ERR(rdev)) - return dev_err_probe(dev, PTR_ERR(rdev), + data->rdevs[i] = devm_regulator_register(dev, &info->reg_desc[i], + &config); + if (IS_ERR(data->rdevs[i])) + return dev_err_probe(dev, PTR_ERR(data->rdevs[i]), "Failed to register %s regulator\n", info->reg_desc[i].name); } From f74f06f4069ec008cec62574a55415c4567f8acf Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Tue, 28 Mar 2023 17:03:34 +0200 Subject: [PATCH 110/131] hwmon: (pmbus/core) Add regulator event support Add regulator events corresponding to regulator error in regulator flag map. Also capture the same in pmbus_regulator_get_flags. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki Link: https://lore.kernel.org/r/20230328150335.90238-2-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus_core.c | 74 +++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index d93405f1a49524..509bc0ef1706c5 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2693,9 +2693,9 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, return 0; } -/* A PMBus status flag and the corresponding REGULATOR_ERROR_* flag */ +/* A PMBus status flag and the corresponding REGULATOR_ERROR_* and REGULATOR_EVENTS_* flag */ struct pmbus_status_assoc { - int pflag, rflag; + int pflag, rflag, eflag; }; /* PMBus->regulator bit mappings for a PMBus status register */ @@ -2710,27 +2710,36 @@ static const struct pmbus_status_category __maybe_unused pmbus_status_flag_map[] .func = PMBUS_HAVE_STATUS_VOUT, .reg = PMBUS_STATUS_VOUT, .bits = (const struct pmbus_status_assoc[]) { - { PB_VOLTAGE_UV_WARNING, REGULATOR_ERROR_UNDER_VOLTAGE_WARN }, - { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE }, - { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_REGULATION_OUT }, + { PB_VOLTAGE_UV_WARNING, REGULATOR_ERROR_UNDER_VOLTAGE_WARN, + REGULATOR_EVENT_UNDER_VOLTAGE_WARN }, + { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE, + REGULATOR_EVENT_UNDER_VOLTAGE }, + { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN, + REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_REGULATION_OUT, + REGULATOR_EVENT_OVER_VOLTAGE_WARN }, { }, }, }, { .func = PMBUS_HAVE_STATUS_IOUT, .reg = PMBUS_STATUS_IOUT, .bits = (const struct pmbus_status_assoc[]) { - { PB_IOUT_OC_WARNING, REGULATOR_ERROR_OVER_CURRENT_WARN }, - { PB_IOUT_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT }, - { PB_IOUT_OC_LV_FAULT, REGULATOR_ERROR_OVER_CURRENT }, + { PB_IOUT_OC_WARNING, REGULATOR_ERROR_OVER_CURRENT_WARN, + REGULATOR_EVENT_OVER_CURRENT_WARN }, + { PB_IOUT_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT, + REGULATOR_EVENT_OVER_CURRENT }, + { PB_IOUT_OC_LV_FAULT, REGULATOR_ERROR_OVER_CURRENT, + REGULATOR_EVENT_OVER_CURRENT }, { }, }, }, { .func = PMBUS_HAVE_STATUS_TEMP, .reg = PMBUS_STATUS_TEMPERATURE, .bits = (const struct pmbus_status_assoc[]) { - { PB_TEMP_OT_WARNING, REGULATOR_ERROR_OVER_TEMP_WARN }, - { PB_TEMP_OT_FAULT, REGULATOR_ERROR_OVER_TEMP }, + { PB_TEMP_OT_WARNING, REGULATOR_ERROR_OVER_TEMP_WARN, + REGULATOR_EVENT_OVER_TEMP_WARN }, + { PB_TEMP_OT_FAULT, REGULATOR_ERROR_OVER_TEMP, + REGULATOR_EVENT_OVER_TEMP }, { }, }, }, @@ -2790,7 +2799,7 @@ static void pmbus_notify(struct pmbus_data *data, int page, int reg, int flags) } static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags, - bool notify) + unsigned int *event, bool notify) { int i, status; const struct pmbus_status_category *cat; @@ -2800,6 +2809,7 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag int func = data->info->func[page]; *flags = 0; + *event = 0; for (i = 0; i < ARRAY_SIZE(pmbus_status_flag_map); i++) { cat = &pmbus_status_flag_map[i]; @@ -2810,10 +2820,11 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag if (status < 0) return status; - for (bit = cat->bits; bit->pflag; bit++) { - if (status & bit->pflag) + for (bit = cat->bits; bit->pflag; bit++) + if (status & bit->pflag) { *flags |= bit->rflag; - } + *event |= bit->eflag; + } if (notify && status) pmbus_notify(data, page, cat->reg, status); @@ -2834,20 +2845,28 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag return status; if (_pmbus_is_enabled(dev, page)) { - if (status & PB_STATUS_OFF) + if (status & PB_STATUS_OFF) { *flags |= REGULATOR_ERROR_FAIL; + *event |= REGULATOR_EVENT_FAIL; + } - if (status & PB_STATUS_POWER_GOOD_N) + if (status & PB_STATUS_POWER_GOOD_N) { *flags |= REGULATOR_ERROR_REGULATION_OUT; + *event |= REGULATOR_EVENT_REGULATION_OUT; + } } /* * Unlike most other status bits, PB_STATUS_{IOUT_OC,VOUT_OV} are * defined strictly as fault indicators (not warnings). */ - if (status & PB_STATUS_IOUT_OC) + if (status & PB_STATUS_IOUT_OC) { *flags |= REGULATOR_ERROR_OVER_CURRENT; - if (status & PB_STATUS_VOUT_OV) + *event |= REGULATOR_EVENT_OVER_CURRENT; + } + if (status & PB_STATUS_VOUT_OV) { *flags |= REGULATOR_ERROR_REGULATION_OUT; + *event |= REGULATOR_EVENT_FAIL; + } /* * If we haven't discovered any thermal faults or warnings via @@ -2855,19 +2874,22 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag * a (conservative) best-effort interpretation. */ if (!(*flags & (REGULATOR_ERROR_OVER_TEMP | REGULATOR_ERROR_OVER_TEMP_WARN)) && - (status & PB_STATUS_TEMPERATURE)) + (status & PB_STATUS_TEMPERATURE)) { *flags |= REGULATOR_ERROR_OVER_TEMP_WARN; + *event |= REGULATOR_EVENT_OVER_TEMP_WARN; + } + return 0; } static int __maybe_unused pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags, - bool notify) + unsigned int *event, bool notify) { int ret; mutex_lock(&data->update_lock); - ret = _pmbus_get_flags(data, page, flags, notify); + ret = _pmbus_get_flags(data, page, flags, event, notify); mutex_unlock(&data->update_lock); return ret; @@ -2911,8 +2933,9 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned struct device *dev = rdev_get_dev(rdev); struct i2c_client *client = to_i2c_client(dev->parent); struct pmbus_data *data = i2c_get_clientdata(client); + int event; - return pmbus_get_flags(data, rdev_get_id(rdev), flags, false); + return pmbus_get_flags(data, rdev_get_id(rdev), flags, &event, false); } static int pmbus_regulator_get_status(struct regulator_dev *rdev) @@ -3152,10 +3175,11 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) { struct pmbus_data *data = pdata; struct i2c_client *client = to_i2c_client(data->dev); - int i, status; + + int i, status, event; mutex_lock(&data->update_lock); for (i = 0; i < data->info->pages; i++) - _pmbus_get_flags(data, i, &status, true); + _pmbus_get_flags(data, i, &status, &event, true); pmbus_clear_faults(client); mutex_unlock(&data->update_lock); From 7a0c7b9ff21d35c398fe609b3e2c7c3eaf374d05 Mon Sep 17 00:00:00 2001 From: Naresh Solanki Date: Tue, 28 Mar 2023 17:03:35 +0200 Subject: [PATCH 111/131] hwmon: (pmbus/core) Notify regulator events Notify regulator events in PMBus irq handler. Signed-off-by: Naresh Solanki Link: https://lore.kernel.org/r/20230328150335.90238-3-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus_core.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 509bc0ef1706c5..86cc8001a7888b 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3159,11 +3159,29 @@ static int pmbus_regulator_register(struct pmbus_data *data) return 0; } + +static int pmbus_regulator_notify(struct pmbus_data *data, int page, int event) +{ + int j; + + for (j = 0; j < data->info->num_regulators; j++) { + if (page == rdev_get_id(data->rdevs[j])) { + regulator_notifier_call_chain(data->rdevs[j], event, NULL); + break; + } + } + return 0; +} #else static int pmbus_regulator_register(struct pmbus_data *data) { return 0; } + +static int pmbus_regulator_notify(struct pmbus_data *data, int page, int event) +{ + return 0; +} #endif static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, u8 val) @@ -3178,9 +3196,13 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) int i, status, event; mutex_lock(&data->update_lock); - for (i = 0; i < data->info->pages; i++) + for (i = 0; i < data->info->pages; i++) { _pmbus_get_flags(data, i, &status, &event, true); + if (event) + pmbus_regulator_notify(data, i, event); + } + pmbus_clear_faults(client); mutex_unlock(&data->update_lock); From 9e51acc4dbed91265c3a3e04e9ab6bd63bc9819b Mon Sep 17 00:00:00 2001 From: Cristian Ciocaltea Date: Thu, 6 Apr 2023 21:20:00 +0300 Subject: [PATCH 112/131] dt-bindings: hwmon: pwm-fan: Convert to DT schema Convert the PWM fan bindings to DT schema format. Signed-off-by: Cristian Ciocaltea Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20230406182000.956275-2-cristian.ciocaltea@collabora.com Signed-off-by: Guenter Roeck --- .../devicetree/bindings/hwmon/pwm-fan.txt | 68 +------------ .../devicetree/bindings/hwmon/pwm-fan.yaml | 97 +++++++++++++++++++ 2 files changed, 98 insertions(+), 67 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.yaml diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index 4509e688623abb..48886f0ce415f3 100644 --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -1,67 +1 @@ -Bindings for a fan connected to the PWM lines - -Required properties: -- compatible : "pwm-fan" -- pwms : the PWM that is used to control the PWM fan -- cooling-levels : PWM duty cycle values in a range from 0 to 255 - which correspond to thermal cooling states - -Optional properties: -- fan-supply : phandle to the regulator that provides power to the fan -- interrupts : This contains an interrupt specifier for each fan - tachometer output connected to an interrupt source. - The output signal must generate a defined number of - interrupts per fan revolution, which require that - it must be self resetting edge interrupts. See - interrupt-controller/interrupts.txt for the format. -- pulses-per-revolution : define the number of pulses per fan revolution for - each tachometer input as an integer (default is 2 - interrupts per revolution). The value must be - greater than zero. - -Example: - fan0: pwm-fan { - compatible = "pwm-fan"; - #cooling-cells = <2>; - pwms = <&pwm 0 10000 0>; - cooling-levels = <0 102 170 230>; - }; - - thermal-zones { - cpu_thermal: cpu-thermal { - thermal-sensors = <&tmu 0>; - polling-delay-passive = <0>; - polling-delay = <0>; - trips { - cpu_alert1: cpu-alert1 { - temperature = <100000>; /* millicelsius */ - hysteresis = <2000>; /* millicelsius */ - type = "passive"; - }; - }; - cooling-maps { - map0 { - trip = <&cpu_alert1>; - cooling-device = <&fan0 0 1>; - }; - }; - }; - -Example 2: - fan0: pwm-fan { - compatible = "pwm-fan"; - pwms = <&pwm 0 40000 0>; - fan-supply = <®_fan>; - interrupt-parent = <&gpio5>; - interrupts = <1 IRQ_TYPE_EDGE_FALLING>; - pulses-per-revolution = <2>; - }; - -Example 3: - fan0: pwm-fan { - compatible = "pwm-fan"; - pwms = <&pwm1 0 25000 0>; - interrupts-extended = <&gpio1 1 IRQ_TYPE_EDGE_FALLING>, - <&gpio2 5 IRQ_TYPE_EDGE_FALLING>; - pulses-per-revolution = <2>, <1>; - }; +This file has moved to pwm-fan.yaml. diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml b/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml new file mode 100644 index 00000000000000..4e5abf7580cc66 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml @@ -0,0 +1,97 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/pwm-fan.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Fan connected to PWM lines + +maintainers: + - Jean Delvare + - Guenter Roeck + +properties: + compatible: + const: pwm-fan + + cooling-levels: + description: PWM duty cycle values corresponding to thermal cooling states. + $ref: /schemas/types.yaml#/definitions/uint32-array + items: + maximum: 255 + + fan-supply: + description: Phandle to the regulator that provides power to the fan. + + interrupts: + description: + This contains an interrupt specifier for each fan tachometer output + connected to an interrupt source. The output signal must generate a + defined number of interrupts per fan revolution, which require that + it must be self resetting edge interrupts. + maxItems: 1 + + pulses-per-revolution: + description: + Define the number of pulses per fan revolution for each tachometer + input as an integer. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 1 + maximum: 4 + default: 2 + + pwms: + description: The PWM that is used to control the fan. + maxItems: 1 + + "#cooling-cells": true + +required: + - compatible + - pwms + +additionalProperties: false + +examples: + - | + pwm-fan { + compatible = "pwm-fan"; + cooling-levels = <0 102 170 230>; + pwms = <&pwm 0 10000 0>; + #cooling-cells = <2>; + }; + + thermal-zones { + cpu_thermal: cpu-thermal { + thermal-sensors = <&tmu 0>; + polling-delay-passive = <0>; + polling-delay = <0>; + + trips { + cpu_alert1: cpu-alert1 { + temperature = <100000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "passive"; + }; + }; + + cooling-maps { + map0 { + trip = <&cpu_alert1>; + cooling-device = <&fan0 0 1>; + }; + }; + }; + }; + + - | + #include + + pwm-fan { + compatible = "pwm-fan"; + pwms = <&pwm 0 40000 0>; + fan-supply = <®_fan>; + interrupt-parent = <&gpio5>; + interrupts = <1 IRQ_TYPE_EDGE_FALLING>; + pulses-per-revolution = <2>; + }; From 4173a5bb7f51e3726381af65c365c1aac7769b54 Mon Sep 17 00:00:00 2001 From: Svyatoslav Ryhel Date: Fri, 7 Apr 2023 19:05:07 +0300 Subject: [PATCH 113/131] dt-bindings: hwmon: ina2xx: add supply property Add vs-supply property. Signed-off-by: Svyatoslav Ryhel Acked-by: Rob Herring Link: https://lore.kernel.org/r/20230407160508.20479-2-clamor95@gmail.com Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml b/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml index 47af97bb4cedf9..8648877d2d01ef 100644 --- a/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml +++ b/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml @@ -57,6 +57,10 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 enum: [1, 2, 4, 8] + vs-supply: + description: phandle to the regulator that provides the VS supply typically + in range from 2.7 V to 5.5 V. + required: - compatible - reg @@ -73,5 +77,6 @@ examples: compatible = "ti,ina220"; reg = <0x44>; shunt-resistor = <1000>; + vs-supply = <&vdd_3v0>; }; }; From ad20248a2d644087fc149e6a8db150bde826c16f Mon Sep 17 00:00:00 2001 From: Svyatoslav Ryhel Date: Fri, 7 Apr 2023 19:05:08 +0300 Subject: [PATCH 114/131] hwmon: ina2xx: add optional regulator support TI ina2xx sensors according to datasheets have dedicated vs supplies. Add it for proper work. Signed-off-by: Svyatoslav Ryhel Link: https://lore.kernel.org/r/20230407160508.20479-3-clamor95@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/ina2xx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index 00fc70305a890d..fd50d9785ccbbe 100644 --- a/drivers/hwmon/ina2xx.c +++ b/drivers/hwmon/ina2xx.c @@ -656,6 +656,10 @@ static int ina2xx_probe(struct i2c_client *client) return PTR_ERR(data->regmap); } + ret = devm_regulator_get_enable(dev, "vs"); + if (ret) + return dev_err_probe(dev, ret, "failed to enable vs regulator\n"); + ret = ina2xx_init(data); if (ret < 0) { dev_err(dev, "error configuring the device: %d\n", ret); From 5dcd53e315b7cd3efb591227c281f979bebd2155 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sat, 8 Apr 2023 19:22:28 +0300 Subject: [PATCH 115/131] hwmon: (nct6775) update ASUS WMI monitoring list A620/B760/W790 Boards such as * B360M-BASALT, * B360M-D3H, * EX-B360M-V, * EX-B360M-V3, * EX-B360M-V5, * EX-B760M-V5 D4, * PRIME A620M-A, * PRIME B460I-PLUS, * PRIME B460M-A, * PRIME B460M-K, * PRIME B550-PLUS AC-HES, * PRIME B660M-A AC D4, * PRIME B760M-A, * PRIME B760M-A AX D4, * PRIME B760M-A D4, * PRIME B760M-AJ D4, * PRIME B760M-A WIFI, * PRIME B760M-A WIFI D4, * PRIME B760M-K D4, * PRIME B760-PLUS, * PRIME B760-PLUS D4, * PRIME H310I-PLUS, * PRIME H310M-A, * PRIME H310M-C, * PRIME H310M-D, * PRIME H310M-DASH, * PRIME H310M-E, * PRIME H310M-E/BR, * PRIME H310M-F, * PRIME H310M-K, * PRIME H310-PLUS, * PRIME H310T, * PRIME H370-A, * PRIME H370M-PLUS, * PRIME H370-PLUS, * PRIME H410I-PLUS, * PRIME H470M-PLUS, * PRIME H470-PLUS, * PRIME H510M-R, * PRIME H510T2/CSM, * PRIME H570M-PLUS, * PRIME H570-PLUS, * PRIME H610M-R D4, * PRIME H670-PLUS D4, * PRIME H770-PLUS D4, * PRIME Q370M-C, * ProArt B760-CREATOR D4, * Pro B760M-C, * Pro B760M-CT, * PRO Q470M-C, * Pro Q670M-C, * Pro WS W790-ACE, * Pro WS W790E-SAGE SE, * ROG MAXIMUS Z690 FORMULA, * ROG MAXIMUS Z690 HERO, * ROG STRIX B360-F GAMING, * ROG STRIX B360-G GAMING, * ROG STRIX B360-H GAMING, * ROG STRIX B360-H GAMING/OPTANE, * ROG STRIX B360-I GAMING, * ROG STRIX B760-A GAMING WIFI, * ROG STRIX B760-A GAMING WIFI D4, * ROG STRIX B760-F GAMING WIFI, * ROG STRIX B760-G GAMING WIFI, * ROG STRIX B760-G GAMING WIFI D4, * ROG STRIX B760-I GAMING WIFI, * ROG STRIX H370-F GAMING, * ROG STRIX H370-I GAMING, * ROG STRIX H470-I GAMING, * ROG STRIX Z690-E GAMING WIFI, * ROG STRIX Z690-F GAMING WIFI, * ROG STRIX Z690-G GAMING WIFI, * TUF B360M-E GAMING, * TUF B360M-PLUS GAMING, * TUF B360M-PLUS GAMING/BR, * TUF B360M-PLUS GAMING S, * TUF B360-PLUS GAMING, * TUF B360-PRO GAMING, * TUF B360-PRO GAMING (WI-FI), * TUF GAMING A620M-PLUS, * TUF GAMING A620M-PLUS WIFI, * TUF GAMING B660M-PLUS D4, * TUF GAMING B660M-PLUS WIFI D4, * TUF GAMING B760M-BTF WIFI D4, * TUF GAMING B760M-E D4, * TUF GAMING B760M-PLUS, * TUF GAMING B760M-PLUS D4, * TUF GAMING B760M-PLUS WIFI, * TUF GAMING B760M-PLUS WIFI D4, * TUF GAMING B760-PLUS WIFI, * TUF GAMING B760-PLUS WIFI D4, * TUF GAMING H470-PRO, * TUF GAMING H470-PRO (WI-FI), * TUF GAMING H570-PRO, * TUF GAMING H570-PRO WIFI, * TUF GAMING H670-PRO WIFI D4, * TUF GAMING H770-PRO WIFI, * TUF GAMING X570-PRO WIFI II, * TUF H310M-PLUS GAMING, * TUF H310M-PLUS GAMING/BR, * TUF H310-PLUS GAMING, * TUF H370-PRO GAMING, * TUF H370-PRO GAMING (WI-FI), have got a nct6775 chip, but by default there's no use of it because of resource conflict with WMI method. This commit adds such boards to the WMI monitoring list. Link: https://bugzilla.kernel.org/show_bug.cgi?id=204807 Signed-off-by: Denis Pauk Link: https://lore.kernel.org/r/20230408162228.4291-1-pauk.denis@gmail.com Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775-platform.c | 103 +++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c index 680fa0ecd6c317..5782acfb4ee1be 100644 --- a/drivers/hwmon/nct6775-platform.c +++ b/drivers/hwmon/nct6775-platform.c @@ -1052,6 +1052,11 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) static struct platform_device *pdev[2]; static const char * const asus_wmi_boards[] = { + "B360M-BASALT", + "B360M-D3H", + "EX-B360M-V", + "EX-B360M-V3", + "EX-B360M-V5", "EX-B460M-V5", "EX-H410M-V3", "PRIME A520M-A", @@ -1064,13 +1069,32 @@ static const char * const asus_wmi_boards[] = { "PRIME B360M-D", "PRIME B360M-K", "PRIME B460-PLUS", + "PRIME B460I-PLUS", + "PRIME B460M-A", "PRIME B460M-A R2.0", + "PRIME B460M-K", "PRIME B550-PLUS", + "PRIME B550-PLUS AC-HES", "PRIME B550M-A", "PRIME B550M-A (WI-FI)", "PRIME B550M-A AC", "PRIME B550M-A WIFI II", "PRIME B550M-K", + "PRIME H310-PLUS", + "PRIME H310I-PLUS", + "PRIME H310M-A", + "PRIME H310M-C", + "PRIME H310M-D", + "PRIME H310M-DASH", + "PRIME H310M-E", + "PRIME H310M-E/BR", + "PRIME H310M-F", + "PRIME H310M-K", + "PRIME H310T", + "PRIME H370-A", + "PRIME H370-PLUS", + "PRIME H370M-PLUS", + "PRIME H410I-PLUS", "PRIME H410M-A", "PRIME H410M-D", "PRIME H410M-E", @@ -1078,7 +1102,10 @@ static const char * const asus_wmi_boards[] = { "PRIME H410M-K", "PRIME H410M-K R2.0", "PRIME H410M-R", + "PRIME H470-PLUS", + "PRIME H470M-PLUS", "PRIME H510M-K R2.0", + "PRIME Q370M-C", "PRIME X570-P", "PRIME X570-PRO", "PRIME Z390-A", @@ -1092,6 +1119,7 @@ static const char * const asus_wmi_boards[] = { "PRO B460M-C", "PRO H410M-C", "PRO H410T", + "PRO Q470M-C", "Pro A520M-C", "Pro A520M-C II", "Pro B550M-C", @@ -1116,6 +1144,11 @@ static const char * const asus_wmi_boards[] = { "ROG MAXIMUS XII EXTREME", "ROG MAXIMUS XII FORMULA", "ROG MAXIMUS XII HERO (WI-FI)", + "ROG STRIX B360-F GAMING", + "ROG STRIX B360-G GAMING", + "ROG STRIX B360-H GAMING", + "ROG STRIX B360-H GAMING/OPTANE", + "ROG STRIX B360-I GAMING", "ROG STRIX B460-F GAMING", "ROG STRIX B460-G GAMING", "ROG STRIX B460-H GAMING", @@ -1127,6 +1160,9 @@ static const char * const asus_wmi_boards[] = { "ROG STRIX B550-F GAMING WIFI II", "ROG STRIX B550-I GAMING", "ROG STRIX B550-XE GAMING WIFI", + "ROG STRIX H370-F GAMING", + "ROG STRIX H370-I GAMING", + "ROG STRIX H470-I GAMING", "ROG STRIX X570-E GAMING", "ROG STRIX X570-E GAMING WIFI II", "ROG STRIX X570-F GAMING", @@ -1142,6 +1178,13 @@ static const char * const asus_wmi_boards[] = { "ROG STRIX Z490-G GAMING (WI-FI)", "ROG STRIX Z490-H GAMING", "ROG STRIX Z490-I GAMING", + "TUF B360-PLUS GAMING", + "TUF B360-PRO GAMING", + "TUF B360-PRO GAMING (WI-FI)", + "TUF B360M-E GAMING", + "TUF B360M-PLUS GAMING", + "TUF B360M-PLUS GAMING S", + "TUF B360M-PLUS GAMING/BR", "TUF GAMING A520M-PLUS", "TUF GAMING A520M-PLUS II", "TUF GAMING A520M-PLUS WIFI", @@ -1160,12 +1203,20 @@ static const char * const asus_wmi_boards[] = { "TUF GAMING B550M-PLUS", "TUF GAMING B550M-PLUS (WI-FI)", "TUF GAMING B550M-PLUS WIFI II", + "TUF GAMING H470-PRO", + "TUF GAMING H470-PRO (WI-FI)", "TUF GAMING X570-PLUS", "TUF GAMING X570-PLUS (WI-FI)", "TUF GAMING X570-PLUS_BR", "TUF GAMING X570-PRO (WI-FI)", + "TUF GAMING X570-PRO WIFI II", "TUF GAMING Z490-PLUS", "TUF GAMING Z490-PLUS (WI-FI)", + "TUF H310-PLUS GAMING", + "TUF H310M-PLUS GAMING", + "TUF H310M-PLUS GAMING/BR", + "TUF H370-PRO GAMING", + "TUF H370-PRO GAMING (WI-FI)", "TUF Z390-PLUS GAMING", "TUF Z390-PLUS GAMING (WI-FI)", "TUF Z390-PRO GAMING", @@ -1180,8 +1231,10 @@ static const char * const asus_msi_boards[] = { "EX-B560M-V5", "EX-B660M-V5 D4", "EX-B660M-V5 PRO D4", + "EX-B760M-V5 D4", "EX-H510M-V3", "EX-H610M-V3 D4", + "PRIME A620M-A", "PRIME B560-PLUS", "PRIME B560-PLUS AC-HES", "PRIME B560M-A", @@ -1195,14 +1248,28 @@ static const char * const asus_msi_boards[] = { "PRIME B650M-A WIFI", "PRIME B650M-A WIFI II", "PRIME B660-PLUS D4", + "PRIME B660M-A AC D4", "PRIME B660M-A D4", "PRIME B660M-A WIFI D4", + "PRIME B760-PLUS", + "PRIME B760-PLUS D4", + "PRIME B760M-A", + "PRIME B760M-A AX D4", + "PRIME B760M-A D4", + "PRIME B760M-A WIFI", + "PRIME B760M-A WIFI D4", + "PRIME B760M-AJ D4", + "PRIME B760M-K D4", "PRIME H510M-A", "PRIME H510M-A WIFI", "PRIME H510M-D", "PRIME H510M-E", "PRIME H510M-F", "PRIME H510M-K", + "PRIME H510M-R", + "PRIME H510T2/CSM", + "PRIME H570-PLUS", + "PRIME H570M-PLUS", "PRIME H610I-PLUS D4", "PRIME H610M-A D4", "PRIME H610M-A WIFI D4", @@ -1210,6 +1277,9 @@ static const char * const asus_msi_boards[] = { "PRIME H610M-E D4", "PRIME H610M-F D4", "PRIME H610M-K D4", + "PRIME H610M-R D4", + "PRIME H670-PLUS D4", + "PRIME H770-PLUS D4", "PRIME X670-P", "PRIME X670-P WIFI", "PRIME X670E-PRO WIFI", @@ -1235,16 +1305,22 @@ static const char * const asus_msi_boards[] = { "Pro B560M-CT", "Pro B660M-C", "Pro B660M-C D4", + "Pro B760M-C", + "Pro B760M-CT", "Pro H510M-C", "Pro H510M-CT", "Pro H610M-C", "Pro H610M-C D4", "Pro H610M-CT D4", "Pro H610T D4", + "Pro Q670M-C", "Pro WS W680-ACE", "Pro WS W680-ACE IPMI", + "Pro WS W790-ACE", + "Pro WS W790E-SAGE SE", "ProArt B650-CREATOR", "ProArt B660-CREATOR D4", + "ProArt B760-CREATOR D4", "ProArt X670E-CREATOR WIFI", "ProArt Z690-CREATOR WIFI", "ProArt Z790-CREATOR WIFI", @@ -1258,6 +1334,8 @@ static const char * const asus_msi_boards[] = { "ROG MAXIMUS Z690 APEX", "ROG MAXIMUS Z690 EXTREME", "ROG MAXIMUS Z690 EXTREME GLACIAL", + "ROG MAXIMUS Z690 FORMULA", + "ROG MAXIMUS Z690 HERO", "ROG MAXIMUS Z690 HERO EVA", "ROG MAXIMUS Z790 APEX", "ROG MAXIMUS Z790 EXTREME", @@ -1276,6 +1354,12 @@ static const char * const asus_msi_boards[] = { "ROG STRIX B660-F GAMING WIFI", "ROG STRIX B660-G GAMING WIFI", "ROG STRIX B660-I GAMING WIFI", + "ROG STRIX B760-A GAMING WIFI", + "ROG STRIX B760-A GAMING WIFI D4", + "ROG STRIX B760-F GAMING WIFI", + "ROG STRIX B760-G GAMING WIFI", + "ROG STRIX B760-G GAMING WIFI D4", + "ROG STRIX B760-I GAMING WIFI", "ROG STRIX X670E-A GAMING WIFI", "ROG STRIX X670E-E GAMING WIFI", "ROG STRIX X670E-F GAMING WIFI", @@ -1287,6 +1371,9 @@ static const char * const asus_msi_boards[] = { "ROG STRIX Z590-I GAMING WIFI", "ROG STRIX Z690-A GAMING WIFI", "ROG STRIX Z690-A GAMING WIFI D4", + "ROG STRIX Z690-E GAMING WIFI", + "ROG STRIX Z690-F GAMING WIFI", + "ROG STRIX Z690-G GAMING WIFI", "ROG STRIX Z690-I GAMING WIFI", "ROG STRIX Z790-A GAMING WIFI", "ROG STRIX Z790-A GAMING WIFI D4", @@ -1294,6 +1381,8 @@ static const char * const asus_msi_boards[] = { "ROG STRIX Z790-F GAMING WIFI", "ROG STRIX Z790-H GAMING WIFI", "ROG STRIX Z790-I GAMING WIFI", + "TUF GAMING A620M-PLUS", + "TUF GAMING A620M-PLUS WIFI", "TUF GAMING B560-PLUS WIFI", "TUF GAMING B560M-E", "TUF GAMING B560M-PLUS", @@ -1304,7 +1393,21 @@ static const char * const asus_msi_boards[] = { "TUF GAMING B650M-PLUS WIFI", "TUF GAMING B660-PLUS WIFI D4", "TUF GAMING B660M-E D4", + "TUF GAMING B660M-PLUS D4", "TUF GAMING B660M-PLUS WIFI", + "TUF GAMING B660M-PLUS WIFI D4", + "TUF GAMING B760-PLUS WIFI", + "TUF GAMING B760-PLUS WIFI D4", + "TUF GAMING B760M-BTF WIFI D4", + "TUF GAMING B760M-E D4", + "TUF GAMING B760M-PLUS", + "TUF GAMING B760M-PLUS D4", + "TUF GAMING B760M-PLUS WIFI", + "TUF GAMING B760M-PLUS WIFI D4", + "TUF GAMING H570-PRO", + "TUF GAMING H570-PRO WIFI", + "TUF GAMING H670-PRO WIFI D4", + "TUF GAMING H770-PRO WIFI", "TUF GAMING X670E-PLUS", "TUF GAMING X670E-PLUS WIFI", "TUF GAMING Z590-PLUS", From ab3e00416a0078be6d4126edc139536286d816e2 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 12 Apr 2023 11:11:17 -0700 Subject: [PATCH 116/131] hwmon: (pmbus/core) Request threaded interrupt with IRQF_ONESHOT 0-day rightfully complains: drivers/hwmon/pmbus/pmbus_core.c:3164:7-32: WARNING: Threaded IRQ with no primary handler requested without IRQF_ONESHOT (unless it is nested IRQ) Without IRQF_ONESHOT, the primary interrupt may end up in a loop, and the threaded interrupt handler may never execute. Request interrupt with IRQF_ONESHOT and assume that the interrupt will cleared and re-enabled by clearing the fault condition in the threaded interrupt handler. Reported-by: kernel test robot Link: https://lore.kernel.org/linux-hwmon/6436efbb.08+e+yEDqvRxvHDP%25lkp@intel.com/T/#u Cc: Patrick Rudolph Cc: Naresh Solanki Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 86cc8001a7888b..bf561277c43063 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3246,8 +3246,8 @@ static int pmbus_irq_setup(struct i2c_client *client, struct pmbus_data *data) } /* Register notifiers */ - err = devm_request_threaded_irq(dev, client->irq, NULL, pmbus_fault_handler, 0, - "pmbus-irq", data); + err = devm_request_threaded_irq(dev, client->irq, NULL, pmbus_fault_handler, + IRQF_ONESHOT, "pmbus-irq", data); if (err) { dev_err(dev, "failed to request an irq %d\n", err); return err; From a7ac37183ac2a0cc46d857997b2dd24997ca2754 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Wed, 12 Apr 2023 11:15:25 -0500 Subject: [PATCH 117/131] hwmon: (pmbus/core) Add lock and unlock functions Debugfs operations may set the page number, which must be done atomically with the subsequent i2c operation. Lock the update_lock in the debugfs functions and provide a function for pmbus drivers to lock and unlock the update_lock. Signed-off-by: Eddie James Link: https://lore.kernel.org/r/20230412161526.252294-2-eajames@linux.ibm.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/pmbus.h | 2 ++ drivers/hwmon/pmbus/pmbus_core.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 11e84e1411266d..b0832a4c690d7f 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -505,6 +505,8 @@ int pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id, enum pmbus_fan_mode mode); int pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id, enum pmbus_fan_mode mode); +int pmbus_lock_interruptible(struct i2c_client *client); +void pmbus_unlock(struct i2c_client *client); int pmbus_update_fan(struct i2c_client *client, int page, int id, u8 config, u8 mask, u16 command); struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client); diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index bf561277c43063..80ec4a5493b4bb 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3263,8 +3263,13 @@ static int pmbus_debugfs_get(void *data, u64 *val) { int rc; struct pmbus_debugfs_entry *entry = data; + struct pmbus_data *pdata = i2c_get_clientdata(entry->client); + rc = mutex_lock_interruptible(&pdata->update_lock); + if (rc) + return rc; rc = _pmbus_read_byte_data(entry->client, entry->page, entry->reg); + mutex_unlock(&pdata->update_lock); if (rc < 0) return rc; @@ -3281,7 +3286,11 @@ static int pmbus_debugfs_get_status(void *data, u64 *val) struct pmbus_debugfs_entry *entry = data; struct pmbus_data *pdata = i2c_get_clientdata(entry->client); + rc = mutex_lock_interruptible(&pdata->update_lock); + if (rc) + return rc; rc = pdata->read_status(entry->client, entry->page); + mutex_unlock(&pdata->update_lock); if (rc < 0) return rc; @@ -3297,10 +3306,15 @@ static ssize_t pmbus_debugfs_mfr_read(struct file *file, char __user *buf, { int rc; struct pmbus_debugfs_entry *entry = file->private_data; + struct pmbus_data *pdata = i2c_get_clientdata(entry->client); char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; + rc = mutex_lock_interruptible(&pdata->update_lock); + if (rc) + return rc; rc = pmbus_read_block_data(entry->client, entry->page, entry->reg, data); + mutex_unlock(&pdata->update_lock); if (rc < 0) return rc; @@ -3638,6 +3652,22 @@ struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client) } EXPORT_SYMBOL_NS_GPL(pmbus_get_debugfs_dir, PMBUS); +int pmbus_lock_interruptible(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + return mutex_lock_interruptible(&data->update_lock); +} +EXPORT_SYMBOL_NS_GPL(pmbus_lock_interruptible, PMBUS); + +void pmbus_unlock(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + mutex_unlock(&data->update_lock); +} +EXPORT_SYMBOL_NS_GPL(pmbus_unlock, PMBUS); + static int __init pmbus_core_init(void) { pmbus_debugfs_dir = debugfs_create_dir("pmbus", NULL); From 1680796b21c33cc13f413f8c39640b594092a3a4 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Wed, 12 Apr 2023 11:15:26 -0500 Subject: [PATCH 118/131] hwmon: (pmbus/ibm-cffps) Use default debugfs attributes and lock function Switch the driver to use the default debugfs attributes instead of ones that provide the same data under different names. Use the lock functions for the debugfs and led attributes, and simplify the input history operation by dropping the timer and lock. Signed-off-by: Eddie James Link: https://lore.kernel.org/r/20230412161526.252294-3-eajames@linux.ibm.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/ibm-cffps.c | 272 ++++++++++++++------------------ 1 file changed, 118 insertions(+), 154 deletions(-) diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c index e3294a1a54bb94..76e72e9acda781 100644 --- a/drivers/hwmon/pmbus/ibm-cffps.c +++ b/drivers/hwmon/pmbus/ibm-cffps.c @@ -18,12 +18,6 @@ #include "pmbus.h" -#define CFFPS_MFG_ID_CMD 0x99 -#define CFFPS_FRU_CMD 0x9A -#define CFFPS_PN_CMD 0x9B -#define CFFPS_HEADER_CMD 0x9C -#define CFFPS_SN_CMD 0x9E -#define CFFPS_MAX_POWER_OUT_CMD 0xA7 #define CFFPS_CCIN_CMD 0xBD #define CFFPS_FW_CMD 0xFA #define CFFPS1_FW_NUM_BYTES 4 @@ -32,7 +26,7 @@ #define CFFPS_12VCS_VOUT_CMD 0xDE #define CFFPS_INPUT_HISTORY_CMD 0xD6 -#define CFFPS_INPUT_HISTORY_SIZE 100 +#define CFFPS_INPUT_HISTORY_SIZE 101 #define CFFPS_CCIN_REVISION GENMASK(7, 0) #define CFFPS_CCIN_REVISION_LEGACY 0xde @@ -57,13 +51,7 @@ #define CFFPS_BLINK_RATE_MS 250 enum { - CFFPS_DEBUGFS_INPUT_HISTORY = 0, - CFFPS_DEBUGFS_MFG_ID, - CFFPS_DEBUGFS_FRU, - CFFPS_DEBUGFS_PN, - CFFPS_DEBUGFS_HEADER, - CFFPS_DEBUGFS_SN, - CFFPS_DEBUGFS_MAX_POWER_OUT, + CFFPS_DEBUGFS_MAX_POWER_OUT = 0, CFFPS_DEBUGFS_CCIN, CFFPS_DEBUGFS_FW, CFFPS_DEBUGFS_ON_OFF_CONFIG, @@ -72,19 +60,11 @@ enum { enum versions { cffps1, cffps2, cffps_unknown }; -struct ibm_cffps_input_history { - struct mutex update_lock; - unsigned long last_update; - - u8 byte_count; - u8 data[CFFPS_INPUT_HISTORY_SIZE]; -}; - struct ibm_cffps { enum versions version; struct i2c_client *client; - struct ibm_cffps_input_history input_history; + u8 input_history[CFFPS_INPUT_HISTORY_SIZE]; int debugfs_entries[CFFPS_DEBUGFS_NUM_ENTRIES]; @@ -93,118 +73,98 @@ struct ibm_cffps { struct led_classdev led; }; -static const struct i2c_device_id ibm_cffps_id[]; - #define to_psu(x, y) container_of((x), struct ibm_cffps, debugfs_entries[(y)]) -static ssize_t ibm_cffps_read_input_history(struct ibm_cffps *psu, - char __user *buf, size_t count, - loff_t *ppos) +static ssize_t ibm_cffps_debugfs_read_input_history(struct file *file, char __user *buf, + size_t count, loff_t *ppos) { int rc; - u8 msgbuf0[1] = { CFFPS_INPUT_HISTORY_CMD }; - u8 msgbuf1[CFFPS_INPUT_HISTORY_SIZE + 1] = { 0 }; + u8 cmd = CFFPS_INPUT_HISTORY_CMD; + struct ibm_cffps *psu = file->private_data; struct i2c_msg msg[2] = { { .addr = psu->client->addr, .flags = psu->client->flags, .len = 1, - .buf = msgbuf0, + .buf = &cmd, }, { .addr = psu->client->addr, .flags = psu->client->flags | I2C_M_RD, - .len = CFFPS_INPUT_HISTORY_SIZE + 1, - .buf = msgbuf1, + .len = CFFPS_INPUT_HISTORY_SIZE, + .buf = psu->input_history, }, }; if (!*ppos) { - mutex_lock(&psu->input_history.update_lock); - if (time_after(jiffies, psu->input_history.last_update + HZ)) { - /* - * Use a raw i2c transfer, since we need more bytes - * than Linux I2C supports through smbus xfr (only 32). - */ - rc = i2c_transfer(psu->client->adapter, msg, 2); - if (rc < 0) { - mutex_unlock(&psu->input_history.update_lock); - return rc; - } + rc = pmbus_lock_interruptible(psu->client); + if (rc) + return rc; - psu->input_history.byte_count = msgbuf1[0]; - memcpy(psu->input_history.data, &msgbuf1[1], - CFFPS_INPUT_HISTORY_SIZE); - psu->input_history.last_update = jiffies; + rc = pmbus_set_page(psu->client, 0, 0xff); + if (rc) { + pmbus_unlock(psu->client); + return rc; } - mutex_unlock(&psu->input_history.update_lock); + /* + * Use a raw i2c transfer, since we need more bytes + * than Linux I2C supports through smbus xfr (only 32). + */ + rc = i2c_transfer(psu->client->adapter, msg, 2); + pmbus_unlock(psu->client); + if (rc < 0) + return rc; } return simple_read_from_buffer(buf, count, ppos, - psu->input_history.data, - psu->input_history.byte_count); + psu->input_history + 1, + psu->input_history[0]); } +static const struct file_operations ibm_cffps_input_history_fops = { + .llseek = noop_llseek, + .read = ibm_cffps_debugfs_read_input_history, + .open = simple_open, +}; + static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - u8 cmd; int i, rc; int *idxp = file->private_data; int idx = *idxp; struct ibm_cffps *psu = to_psu(idxp, idx); char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; - pmbus_set_page(psu->client, 0, 0xff); + rc = pmbus_lock_interruptible(psu->client); + if (rc) + return rc; + + rc = pmbus_set_page(psu->client, 0, 0xff); + if (rc) + goto unlock; switch (idx) { - case CFFPS_DEBUGFS_INPUT_HISTORY: - return ibm_cffps_read_input_history(psu, buf, count, ppos); - case CFFPS_DEBUGFS_MFG_ID: - cmd = CFFPS_MFG_ID_CMD; - break; - case CFFPS_DEBUGFS_FRU: - cmd = CFFPS_FRU_CMD; - break; - case CFFPS_DEBUGFS_PN: - cmd = CFFPS_PN_CMD; - break; - case CFFPS_DEBUGFS_HEADER: - cmd = CFFPS_HEADER_CMD; - break; - case CFFPS_DEBUGFS_SN: - cmd = CFFPS_SN_CMD; - break; case CFFPS_DEBUGFS_MAX_POWER_OUT: - if (psu->version == cffps1) { - rc = i2c_smbus_read_word_swapped(psu->client, - CFFPS_MAX_POWER_OUT_CMD); - } else { - rc = i2c_smbus_read_word_data(psu->client, - CFFPS_MAX_POWER_OUT_CMD); - } - - if (rc < 0) - return rc; - - rc = snprintf(data, I2C_SMBUS_BLOCK_MAX, "%d", rc); - goto done; + if (psu->version == cffps1) + rc = i2c_smbus_read_word_swapped(psu->client, PMBUS_MFR_POUT_MAX); + else + rc = i2c_smbus_read_word_data(psu->client, PMBUS_MFR_POUT_MAX); + if (rc >= 0) + rc = snprintf(data, I2C_SMBUS_BLOCK_MAX, "%d", rc); + break; case CFFPS_DEBUGFS_CCIN: rc = i2c_smbus_read_word_swapped(psu->client, CFFPS_CCIN_CMD); - if (rc < 0) - return rc; - - rc = snprintf(data, 5, "%04X", rc); - goto done; + if (rc >= 0) + rc = snprintf(data, 5, "%04X", rc); + break; case CFFPS_DEBUGFS_FW: switch (psu->version) { case cffps1: for (i = 0; i < CFFPS1_FW_NUM_BYTES; ++i) { - rc = i2c_smbus_read_byte_data(psu->client, - CFFPS_FW_CMD + - i); + rc = i2c_smbus_read_byte_data(psu->client, CFFPS_FW_CMD + i); if (rc < 0) - return rc; + goto unlock; snprintf(&data[i * 2], 3, "%02X", rc); } @@ -213,11 +173,9 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf, break; case cffps2: for (i = 0; i < CFFPS2_FW_NUM_WORDS; ++i) { - rc = i2c_smbus_read_word_data(psu->client, - CFFPS_FW_CMD + - i); + rc = i2c_smbus_read_word_data(psu->client, CFFPS_FW_CMD + i); if (rc < 0) - return rc; + goto unlock; snprintf(&data[i * 4], 5, "%04X", rc); } @@ -225,26 +183,25 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf, rc = i * 4; break; default: - return -EOPNOTSUPP; + rc = -EOPNOTSUPP; + break; } - goto done; + break; case CFFPS_DEBUGFS_ON_OFF_CONFIG: - rc = i2c_smbus_read_byte_data(psu->client, - PMBUS_ON_OFF_CONFIG); - if (rc < 0) - return rc; - - rc = snprintf(data, 3, "%02x", rc); - goto done; + rc = i2c_smbus_read_byte_data(psu->client, PMBUS_ON_OFF_CONFIG); + if (rc >= 0) + rc = snprintf(data, 3, "%02x", rc); + break; default: - return -EINVAL; + rc = -EINVAL; + break; } - rc = i2c_smbus_read_block_data(psu->client, cmd, data); +unlock: + pmbus_unlock(psu->client); if (rc < 0) return rc; -done: data[rc] = '\n'; rc += 2; @@ -263,14 +220,22 @@ static ssize_t ibm_cffps_debugfs_write(struct file *file, switch (idx) { case CFFPS_DEBUGFS_ON_OFF_CONFIG: - pmbus_set_page(psu->client, 0, 0xff); - rc = simple_write_to_buffer(&data, 1, ppos, buf, count); if (rc <= 0) return rc; - rc = i2c_smbus_write_byte_data(psu->client, - PMBUS_ON_OFF_CONFIG, data); + rc = pmbus_lock_interruptible(psu->client); + if (rc) + return rc; + + rc = pmbus_set_page(psu->client, 0, 0xff); + if (rc) { + pmbus_unlock(psu->client); + return rc; + } + + rc = i2c_smbus_write_byte_data(psu->client, PMBUS_ON_OFF_CONFIG, data); + pmbus_unlock(psu->client); if (rc) return rc; @@ -396,10 +361,19 @@ static int ibm_cffps_led_brightness_set(struct led_classdev *led_cdev, dev_dbg(&psu->client->dev, "LED brightness set: %d. Command: %d.\n", brightness, next_led_state); - pmbus_set_page(psu->client, 0, 0xff); + rc = pmbus_lock_interruptible(psu->client); + if (rc) + return rc; + + rc = pmbus_set_page(psu->client, 0, 0xff); + if (rc) { + pmbus_unlock(psu->client); + return rc; + } rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD, next_led_state); + pmbus_unlock(psu->client); if (rc < 0) return rc; @@ -418,10 +392,19 @@ static int ibm_cffps_led_blink_set(struct led_classdev *led_cdev, dev_dbg(&psu->client->dev, "LED blink set.\n"); - pmbus_set_page(psu->client, 0, 0xff); + rc = pmbus_lock_interruptible(psu->client); + if (rc) + return rc; + + rc = pmbus_set_page(psu->client, 0, 0xff); + if (rc) { + pmbus_unlock(psu->client); + return rc; + } rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD, CFFPS_LED_BLINK); + pmbus_unlock(psu->client); if (rc < 0) return rc; @@ -474,9 +457,11 @@ static struct pmbus_driver_info ibm_cffps_info[] = { PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12 | PMBUS_HAVE_VMON, - .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | - PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | - PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT, + .func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | + PMBUS_HAVE_PIN | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | + PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT | + PMBUS_HAVE_STATUS_TEMP, .read_byte_data = ibm_cffps_read_byte_data, .read_word_data = ibm_cffps_read_word_data, }, @@ -486,12 +471,19 @@ static struct pmbus_platform_data ibm_cffps_pdata = { .flags = PMBUS_SKIP_STATUS_CHECK | PMBUS_NO_CAPABILITY, }; +static const struct i2c_device_id ibm_cffps_id[] = { + { "ibm_cffps1", cffps1 }, + { "ibm_cffps2", cffps2 }, + { "ibm_cffps", cffps_unknown }, + {} +}; +MODULE_DEVICE_TABLE(i2c, ibm_cffps_id); + static int ibm_cffps_probe(struct i2c_client *client) { int i, rc; enum versions vs = cffps_unknown; struct dentry *debugfs; - struct dentry *ibm_cffps_dir; struct ibm_cffps *psu; const void *md = of_device_get_match_data(&client->dev); const struct i2c_device_id *id; @@ -560,8 +552,6 @@ static int ibm_cffps_probe(struct i2c_client *client) psu->version = vs; psu->client = client; - mutex_init(&psu->input_history.update_lock); - psu->input_history.last_update = jiffies - HZ; ibm_cffps_create_led_class(psu); @@ -570,55 +560,29 @@ static int ibm_cffps_probe(struct i2c_client *client) if (!debugfs) return 0; - ibm_cffps_dir = debugfs_create_dir(client->name, debugfs); - if (!ibm_cffps_dir) - return 0; - for (i = 0; i < CFFPS_DEBUGFS_NUM_ENTRIES; ++i) psu->debugfs_entries[i] = i; - debugfs_create_file("input_history", 0444, ibm_cffps_dir, - &psu->debugfs_entries[CFFPS_DEBUGFS_INPUT_HISTORY], - &ibm_cffps_fops); - debugfs_create_file("mfg_id", 0444, ibm_cffps_dir, - &psu->debugfs_entries[CFFPS_DEBUGFS_MFG_ID], - &ibm_cffps_fops); - debugfs_create_file("fru", 0444, ibm_cffps_dir, - &psu->debugfs_entries[CFFPS_DEBUGFS_FRU], - &ibm_cffps_fops); - debugfs_create_file("part_number", 0444, ibm_cffps_dir, - &psu->debugfs_entries[CFFPS_DEBUGFS_PN], - &ibm_cffps_fops); - debugfs_create_file("header", 0444, ibm_cffps_dir, - &psu->debugfs_entries[CFFPS_DEBUGFS_HEADER], - &ibm_cffps_fops); - debugfs_create_file("serial_number", 0444, ibm_cffps_dir, - &psu->debugfs_entries[CFFPS_DEBUGFS_SN], - &ibm_cffps_fops); - debugfs_create_file("max_power_out", 0444, ibm_cffps_dir, + debugfs_create_file("input_history", 0444, debugfs, psu, &ibm_cffps_input_history_fops); + debugfs_create_file("max_power_out", 0444, debugfs, &psu->debugfs_entries[CFFPS_DEBUGFS_MAX_POWER_OUT], &ibm_cffps_fops); - debugfs_create_file("ccin", 0444, ibm_cffps_dir, + debugfs_create_file("ccin", 0444, debugfs, &psu->debugfs_entries[CFFPS_DEBUGFS_CCIN], &ibm_cffps_fops); - debugfs_create_file("fw_version", 0444, ibm_cffps_dir, + debugfs_create_file("fw_version", 0444, debugfs, &psu->debugfs_entries[CFFPS_DEBUGFS_FW], &ibm_cffps_fops); - debugfs_create_file("on_off_config", 0644, ibm_cffps_dir, + debugfs_create_file("on_off_config", 0644, debugfs, &psu->debugfs_entries[CFFPS_DEBUGFS_ON_OFF_CONFIG], &ibm_cffps_fops); + /* For compatibility with users of the old naming scheme. */ + debugfs_create_symlink(client->name, debugfs, "."); + return 0; } -static const struct i2c_device_id ibm_cffps_id[] = { - { "ibm_cffps1", cffps1 }, - { "ibm_cffps2", cffps2 }, - { "ibm_cffps", cffps_unknown }, - {} -}; -MODULE_DEVICE_TABLE(i2c, ibm_cffps_id); - static const struct of_device_id ibm_cffps_of_match[] = { { .compatible = "ibm,cffps1", From fb23f23096471f915bf9745fa297c366e03ee579 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sat, 15 Apr 2023 18:23:37 +0200 Subject: [PATCH 119/131] hwmon: (sfctemp) Simplify error message dev_err_probe() already display the error code. There is no need to duplicate it explicitly in the error message. Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/f32a6e877f399e11ca130476002f85c2b48ba7ec.1681575790.git.christophe.jaillet@wanadoo.fr Signed-off-by: Guenter Roeck --- drivers/hwmon/sfctemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sfctemp.c b/drivers/hwmon/sfctemp.c index d7484e2b81005a..fb1da93383d712 100644 --- a/drivers/hwmon/sfctemp.c +++ b/drivers/hwmon/sfctemp.c @@ -303,7 +303,7 @@ static int sfctemp_probe(struct platform_device *pdev) ret = sfctemp_enable(sfctemp); if (ret) - return dev_err_probe(dev, ret, "error enabling temperature sensor: %d\n", ret); + return dev_err_probe(dev, ret, "error enabling temperature sensor\n"); hwmon_dev = devm_hwmon_device_register_with_info(dev, "sfctemp", sfctemp, &sfctemp_chip_info, NULL); From 680921653cf39f086fe065234a2d9813b526bb6c Mon Sep 17 00:00:00 2001 From: Lakshmi Yadlapati Date: Thu, 13 Apr 2023 08:26:23 -0500 Subject: [PATCH 120/131] dt-bindings: vendor-prefixes: Add prefix for acbel Add a vendor prefix entry for acbel (https://www.acbel.com) Signed-off-by: Lakshmi Yadlapati Acked-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20230413132627.3444119-2-lakshmiy@us.ibm.com Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index ed64e06ecca49f..9dbb8f69be6532 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -37,6 +37,8 @@ patternProperties: description: Abracon Corporation "^abt,.*": description: ShenZhen Asia Better Technology Ltd. + "^acbel,.*": + description: Acbel Polytech Inc. "^acer,.*": description: Acer Inc. "^acme,.*": From b0cda2cc85686d5cd30a874f2caf9c6c34958cd1 Mon Sep 17 00:00:00 2001 From: Lakshmi Yadlapati Date: Thu, 13 Apr 2023 08:26:24 -0500 Subject: [PATCH 121/131] dt-bindings: trivial-devices: Add acbel,fsg032 Add new Acbel FSG032 power supply to trivial devices. Signed-off-by: Lakshmi Yadlapati Acked-by: Rob Herring Link: https://lore.kernel.org/r/20230413132627.3444119-3-lakshmiy@us.ibm.com Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 6f482a254a1dde..246863a9bc7e26 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -29,6 +29,8 @@ properties: compatible: items: - enum: + # Acbel fsg032 power supply + - acbel,fsg032 # SMBus/I2C Digital Temperature Sensor in 6-Pin SOT with SMBus Alert and Over Temperature Pin - ad,ad7414 # ADM9240: Complete System Hardware Monitor for uProcessor-Based Systems From d89d6c093acdf4545a89ded625686ee6e8db4634 Mon Sep 17 00:00:00 2001 From: Lakshmi Yadlapati Date: Thu, 13 Apr 2023 08:26:25 -0500 Subject: [PATCH 122/131] hwmon: (pmbus/acbel-fsg032) Add Acbel power supply Add the driver to support ACBEL FSG032 power supply. Signed-off-by: Lakshmi Yadlapati Link: https://lore.kernel.org/r/20230413132627.3444119-4-lakshmiy@us.ibm.com Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/Kconfig | 9 ++++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/acbel-fsg032.c | 85 ++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 drivers/hwmon/pmbus/acbel-fsg032.c diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 59d9a7430499f7..270b6336b76da3 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -27,6 +27,15 @@ config SENSORS_PMBUS This driver can also be built as a module. If so, the module will be called pmbus. +config SENSORS_ACBEL_FSG032 + tristate "ACBEL FSG032 Power Supply" + help + If you say yes here you get hardware monitoring support for the ACBEL + FSG032 Power Supply. + + This driver can also be built as a module. If so, the module will + be called acbel-fsg032. + config SENSORS_ADM1266 tristate "Analog Devices ADM1266 Sequencer" select CRC8 diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index 3ae01991626779..84ee960a6c2d90 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_PMBUS) += pmbus_core.o obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o +obj-$(CONFIG_SENSORS_ACBEL_FSG032) += acbel-fsg032.o obj-$(CONFIG_SENSORS_ADM1266) += adm1266.o obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o obj-$(CONFIG_SENSORS_BEL_PFE) += bel-pfe.o diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c b/drivers/hwmon/pmbus/acbel-fsg032.c new file mode 100644 index 00000000000000..28a25f30e2cfd5 --- /dev/null +++ b/drivers/hwmon/pmbus/acbel-fsg032.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2023 IBM Corp. + */ + +#include +#include +#include +#include +#include +#include +#include "pmbus.h" + +static const struct i2c_device_id acbel_fsg032_id[] = { + { "acbel_fsg032" }, + {} +}; + +static struct pmbus_driver_info acbel_fsg032_info = { + .pages = 1, + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN | + PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | + PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_FAN12, +}; + +static int acbel_fsg032_probe(struct i2c_client *client) +{ + u8 buf[I2C_SMBUS_BLOCK_MAX + 1]; + struct device *dev = &client->dev; + int rc; + + rc = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf); + if (rc < 0) { + dev_err(dev, "Failed to read PMBUS_MFR_ID\n"); + return rc; + } + if (strncmp(buf, "ACBEL", 5)) { + buf[rc] = '\0'; + dev_err(dev, "Manufacturer '%s' not supported\n", buf); + return -ENODEV; + } + + rc = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf); + if (rc < 0) { + dev_err(dev, "Failed to read PMBUS_MFR_MODEL\n"); + return rc; + } + + if (strncmp(buf, "FSG032", 6)) { + buf[rc] = '\0'; + dev_err(dev, "Model '%s' not supported\n", buf); + return -ENODEV; + } + + rc = pmbus_do_probe(client, &acbel_fsg032_info); + if (rc) + return rc; + + return 0; +} + +static const struct of_device_id acbel_fsg032_of_match[] = { + { .compatible = "acbel,fsg032" }, + {} +}; +MODULE_DEVICE_TABLE(of, acbel_fsg032_of_match); + +static struct i2c_driver acbel_fsg032_driver = { + .driver = { + .name = "acbel-fsg032", + .of_match_table = acbel_fsg032_of_match, + }, + .probe_new = acbel_fsg032_probe, + .id_table = acbel_fsg032_id, +}; + +module_i2c_driver(acbel_fsg032_driver); + +MODULE_AUTHOR("Lakshmi Yadlapati"); +MODULE_DESCRIPTION("PMBus driver for AcBel Power System power supplies"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(PMBUS); From 7a46c0cb473f05fe61edf26aa5509aa555dcd9be Mon Sep 17 00:00:00 2001 From: Lakshmi Yadlapati Date: Thu, 13 Apr 2023 08:26:26 -0500 Subject: [PATCH 123/131] docs: hwmon: Add documentaion for acbel-fsg032 PSU Add documentation changes for acbel-fsg032 psu Signed-off-by: Lakshmi Yadlapati Link: https://lore.kernel.org/r/20230413132627.3444119-5-lakshmiy@us.ibm.com [groeck: Fixed alphabetic order in index.rst] Signed-off-by: Guenter Roeck --- Documentation/hwmon/acbel-fsg032.rst | 80 ++++++++++++++++++++++++++++ Documentation/hwmon/index.rst | 1 + 2 files changed, 81 insertions(+) create mode 100644 Documentation/hwmon/acbel-fsg032.rst diff --git a/Documentation/hwmon/acbel-fsg032.rst b/Documentation/hwmon/acbel-fsg032.rst new file mode 100644 index 00000000000000..f1684b95e10375 --- /dev/null +++ b/Documentation/hwmon/acbel-fsg032.rst @@ -0,0 +1,80 @@ +Kernel driver acbel-fsg032 +========================== + +Supported chips: + + * ACBEL FSG032-00xG power supply. + +Author: Lakshmi Yadlapati + +Description +----------- + +This driver supports ACBEL FSG032-00xG Power Supply. This driver +is a client to the core PMBus driver. + +Usage Notes +----------- + +This driver does not auto-detect devices. You will have to instantiate the +devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for +details. + +Sysfs entries +------------- + +The following attributes are supported: + +======================= ====================================================== +curr1_crit Critical maximum current. +curr1_crit_alarm Input current critical alarm. +curr1_input Measured output current. +curr1_label "iin" +curr1_max Maximum input current. +curr1_max_alarm Maximum input current high alarm. +curr1_rated_max Maximum rated input current. +curr2_crit Critical maximum current. +curr2_crit_alarm Output current critical alarm. +curr2_input Measured output current. +curr2_label "iout1" +curr2_max Maximum output current. +curr2_max_alarm Output current high alarm. +curr2_rated_max Maximum rated output current. + + +fan1_alarm Fan 1 warning. +fan1_fault Fan 1 fault. +fan1_input Fan 1 speed in RPM. +fan1_target Set fan speed reference. + +in1_alarm Input voltage under-voltage alarm. +in1_input Measured input voltage. +in1_label "vin" +in1_rated_max Maximum rated input voltage. +in1_rated_min Minimum rated input voltage. +in2_crit Critical maximum output voltage. +in2_crit_alarm Output voltage critical high alarm. +in2_input Measured output voltage. +in2_label "vout1" +in2_lcrit Critical minimum output voltage. +in2_lcrit_alarm Output voltage critical low alarm. +in2_rated_max Maximum rated output voltage. +in2_rated_min Minimum rated output voltage. + +power1_alarm Input fault or alarm. +power1_input Measured input power. +power1_label "pin" +power1_max Input power limit. +power1_rated_max Maximum rated input power. +power2_crit Critical output power limit. +power2_crit_alarm Output power crit alarm limit exceeded. +power2_input Measured output power. +power2_label "pout" +power2_max Output power limit. +power2_max_alarm Output power high alarm. +power2_rated_max Maximum rated output power. + +temp[1-3]_input Measured temperature. +temp[1-2]_max Maximum temperature. +temp[1-3]_rated_max Temperature high alarm. +======================= ====================================================== diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index d72bb1df643193..fa1208c62855d5 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -22,6 +22,7 @@ Hardware Monitoring Kernel Drivers abituguru abituguru3 + acbel-fsg032 acpi_power_meter ad7314 adc128d818 From 9989b3c0ff9771760c103d46e6b5e8645fd3d836 Mon Sep 17 00:00:00 2001 From: Frank Crawford Date: Sun, 16 Apr 2023 14:25:07 +1000 Subject: [PATCH 124/131] hwmon: (it87) Disable SMBus access for environmental controller registers. Add functions to disable and re-enable access by the SMBus for specific chips. Signed-off-by: Frank Crawford Signed-off-by: Guenter Roeck --- drivers/hwmon/it87.c | 58 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index f774a0732a7c45..b74dd861f0fe69 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -162,8 +162,11 @@ static inline void superio_exit(int ioreg, bool noexit) #define IT8623E_DEVID 0x8623 #define IT8628E_DEVID 0x8628 #define IT87952E_DEVID 0x8695 -#define IT87_ACT_REG 0x30 -#define IT87_BASE_REG 0x60 + +/* Logical device 4 (Environmental Monitor) registers */ +#define IT87_ACT_REG 0x30 +#define IT87_BASE_REG 0x60 +#define IT87_SPECIAL_CFG_REG 0xf3 /* special configuration register */ /* Logical device 7 registers (IT8712F and later) */ #define IT87_SIO_GPIO1_REG 0x25 @@ -284,6 +287,8 @@ struct it87_devices { u32 features; u8 peci_mask; u8 old_peci_mask; + u8 smbus_bitmap; /* SMBus enable bits in extra config register */ + u8 ec_special_config; }; #define FEAT_12MV_ADC BIT(0) @@ -533,6 +538,8 @@ struct it87_sio_data { u8 skip_fan; u8 skip_pwm; u8 skip_temp; + u8 smbus_bitmap; + u8 ec_special_config; }; /* @@ -547,6 +554,9 @@ struct it87_data { u8 peci_mask; u8 old_peci_mask; + u8 smbus_bitmap; /* !=0 if SMBus needs to be disabled */ + u8 ec_special_config; /* EC special config register restore value */ + unsigned short addr; const char *name; struct mutex update_lock; @@ -701,6 +711,39 @@ static const unsigned int pwm_freq[8] = { 750000, }; +static int smbus_disable(struct it87_data *data) +{ + int err; + + if (data->smbus_bitmap) { + err = superio_enter(data->sioaddr); + if (err) + return err; + superio_select(data->sioaddr, PME); + superio_outb(data->sioaddr, IT87_SPECIAL_CFG_REG, + data->ec_special_config & ~data->smbus_bitmap); + superio_exit(data->sioaddr, has_conf_noexit(data)); + } + return 0; +} + +static int smbus_enable(struct it87_data *data) +{ + int err; + + if (data->smbus_bitmap) { + err = superio_enter(data->sioaddr); + if (err) + return err; + + superio_select(data->sioaddr, PME); + superio_outb(data->sioaddr, IT87_SPECIAL_CFG_REG, + data->ec_special_config); + superio_exit(data->sioaddr, has_conf_noexit(data)); + } + return 0; +} + /* * Must be called with data->update_lock held, except during initialization. * We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, @@ -2859,6 +2902,15 @@ static int __init it87_find(int sioaddr, unsigned short *address, if (dmi_data) sio_data->skip_pwm |= dmi_data->skip_pwm; + if (config->smbus_bitmap) { + u8 reg; + + superio_select(sioaddr, PME); + reg = superio_inb(sioaddr, IT87_SPECIAL_CFG_REG); + sio_data->ec_special_config = reg; + sio_data->smbus_bitmap = reg & config->smbus_bitmap; + } + exit: superio_exit(sioaddr, config ? has_conf_noexit(config) : false); return err; @@ -3094,6 +3146,8 @@ static int it87_probe(struct platform_device *pdev) data->addr = res->start; data->sioaddr = sio_data->sioaddr; data->type = sio_data->type; + data->smbus_bitmap = sio_data->smbus_bitmap; + data->ec_special_config = sio_data->ec_special_config; data->features = it87_devices[sio_data->type].features; data->peci_mask = it87_devices[sio_data->type].peci_mask; data->old_peci_mask = it87_devices[sio_data->type].old_peci_mask; From 0282ba4a4fe6c8e6c0ffecfcdf214fa7f6452dc4 Mon Sep 17 00:00:00 2001 From: Frank Crawford Date: Sun, 16 Apr 2023 14:25:08 +1000 Subject: [PATCH 125/131] hwmon: (it87) Test for error in it87_update_device Handle errors from it87_update_device(), which currently only occurs if SMBus access locking fails. Signed-off-by: Frank Crawford [groeck: Fixed handling in show_temp_type()] Signed-off-by: Guenter Roeck --- drivers/hwmon/it87.c | 54 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index b74dd861f0fe69..5083ec04a019f5 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -942,6 +942,9 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, int index = sattr->index; int nr = sattr->nr; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", in_from_reg(data, nr, data->in[nr][index])); } @@ -1030,6 +1033,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, int index = sattr->index; struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr][index])); } @@ -1104,8 +1110,13 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int nr = sensor_attr->index; struct it87_data *data = it87_update_device(dev); - u8 reg = data->sensor; /* In case value is updated while used */ - u8 extra = data->extra; + u8 reg, extra; + + if (IS_ERR(data)) + return PTR_ERR(data); + + reg = data->sensor; /* In case value is updated while used */ + extra = data->extra; if ((has_temp_peci(data, nr) && (reg >> 6 == nr + 1)) || (has_temp_old_peci(data, nr) && (extra & 0x80))) @@ -1197,6 +1208,9 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, int speed; struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + speed = has_16bit_fans(data) ? FAN16_FROM_REG(data->fan[nr][index]) : FAN_FROM_REG(data->fan[nr][index], @@ -1211,6 +1225,9 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%lu\n", DIV_FROM_REG(data->fan_div[nr])); } @@ -1221,6 +1238,9 @@ static ssize_t show_pwm_enable(struct device *dev, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_mode(data, nr)); } @@ -1231,6 +1251,9 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_from_reg(data, data->pwm_duty[nr])); } @@ -1244,6 +1267,9 @@ static ssize_t show_pwm_freq(struct device *dev, struct device_attribute *attr, unsigned int freq; int index; + if (IS_ERR(data)) + return PTR_ERR(data); + if (has_pwm_freq2(data) && nr == 1) index = (data->extra >> 4) & 0x07; else @@ -1531,6 +1557,9 @@ static ssize_t show_pwm_temp_map(struct device *dev, int nr = sensor_attr->index; int map; + if (IS_ERR(data)) + return PTR_ERR(data); + map = data->pwm_temp_map[nr]; if (map >= 3) map = 0; /* Should never happen */ @@ -1595,6 +1624,9 @@ static ssize_t show_auto_pwm(struct device *dev, struct device_attribute *attr, int nr = sensor_attr->nr; int point = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_from_reg(data, data->auto_pwm[nr][point])); } @@ -1631,6 +1663,9 @@ static ssize_t show_auto_pwm_slope(struct device *dev, struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", data->auto_pwm[nr][1] & 0x7f); } @@ -1664,6 +1699,9 @@ static ssize_t show_auto_temp(struct device *dev, struct device_attribute *attr, int point = sensor_attr->index; int reg; + if (IS_ERR(data)) + return PTR_ERR(data); + if (has_old_autopwm(data) || point) reg = data->auto_temp[nr][point]; else @@ -1884,6 +1922,9 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, { struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", data->alarms); } static DEVICE_ATTR_RO(alarms); @@ -1894,6 +1935,9 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int bitnr = to_sensor_dev_attr(attr)->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); } @@ -1949,6 +1993,9 @@ static ssize_t show_beep(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int bitnr = to_sensor_dev_attr(attr)->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", (data->beeps >> bitnr) & 1); } @@ -2022,6 +2069,9 @@ static ssize_t cpu0_vid_show(struct device *dev, { struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%ld\n", (long)vid_from_reg(data->vid, data->vrm)); } static DEVICE_ATTR_RO(cpu0_vid); From 376e1a937b3056802f3ad86811ec92ee3f49d560 Mon Sep 17 00:00:00 2001 From: Frank Crawford Date: Sun, 16 Apr 2023 14:25:09 +1000 Subject: [PATCH 126/131] hwmon: (it87) Add calls to smbus_enable/smbus_disable as required Disable/re-enable access through SMBus for chip registers when they are are being read or written. For simple cases this is done at the same time as when a mutex is set, however, within loops or during initialisation it is done separately. Signed-off-by: Frank Crawford [groeck: Fixed multi-line alignment] Signed-off-by: Guenter Roeck --- drivers/hwmon/it87.c | 181 ++++++++++++++++++++++++++++++++----------- 1 file changed, 135 insertions(+), 46 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 5083ec04a019f5..cb97b3f029bde1 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -746,6 +746,7 @@ static int smbus_enable(struct it87_data *data) /* * Must be called with data->update_lock held, except during initialization. + * Must be called with SMBus accesses disabled. * We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, * would slow down the IT87 access and should not be necessary. */ @@ -757,6 +758,7 @@ static int it87_read_value(struct it87_data *data, u8 reg) /* * Must be called with data->update_lock held, except during initialization. + * Must be called with SMBus accesses disabled. * We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, * would slow down the IT87 access and should not be necessary. */ @@ -816,15 +818,39 @@ static void it87_update_pwm_ctrl(struct it87_data *data, int nr) } } +static int it87_lock(struct it87_data *data) +{ + int err; + + mutex_lock(&data->update_lock); + err = smbus_disable(data); + if (err) + mutex_unlock(&data->update_lock); + return err; +} + +static void it87_unlock(struct it87_data *data) +{ + smbus_enable(data); + mutex_unlock(&data->update_lock); +} + static struct it87_data *it87_update_device(struct device *dev) { struct it87_data *data = dev_get_drvdata(dev); + struct it87_data *ret = data; + int err; int i; mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || - !data->valid) { + !data->valid) { + err = smbus_disable(data); + if (err) { + ret = ERR_PTR(err); + goto unlock; + } if (update_vbat) { /* * Cleared after each update, so reenable. Value @@ -927,11 +953,11 @@ static struct it87_data *it87_update_device(struct device *dev) } data->last_updated = jiffies; data->valid = true; + smbus_enable(data); } - +unlock: mutex_unlock(&data->update_lock); - - return data; + return ret; } static ssize_t show_in(struct device *dev, struct device_attribute *attr, @@ -956,17 +982,21 @@ static ssize_t set_in(struct device *dev, struct device_attribute *attr, int index = sattr->index; int nr = sattr->nr; unsigned long val; + int err; if (kstrtoul(buf, 10, &val) < 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + data->in[nr][index] = in_to_reg(data, nr, val); it87_write_value(data, index == 1 ? IT87_REG_VIN_MIN(nr) : IT87_REG_VIN_MAX(nr), data->in[nr][index]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1048,11 +1078,14 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); long val; u8 reg, regval; + int err; if (kstrtol(buf, 10, &val) < 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; switch (index) { default: @@ -1075,7 +1108,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr, data->temp[nr][index] = TEMP_TO_REG(val); it87_write_value(data, reg, data->temp[nr][index]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1137,10 +1170,15 @@ static ssize_t set_temp_type(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); long val; u8 reg, extra; + int err; if (kstrtol(buf, 10, &val) < 0) return -EINVAL; + err = it87_lock(data); + if (err) + return err; + reg = it87_read_value(data, IT87_REG_TEMP_ENABLE); reg &= ~(1 << nr); reg &= ~(8 << nr); @@ -1163,17 +1201,19 @@ static ssize_t set_temp_type(struct device *dev, struct device_attribute *attr, reg |= (nr + 1) << 6; else if (has_temp_old_peci(data, nr) && val == 6) extra |= 0x80; - else if (val != 0) - return -EINVAL; + else if (val != 0) { + count = -EINVAL; + goto unlock; + } - mutex_lock(&data->update_lock); data->sensor = reg; data->extra = extra; it87_write_value(data, IT87_REG_TEMP_ENABLE, data->sensor); if (has_temp_old_peci(data, nr)) it87_write_value(data, IT87_REG_TEMP_EXTRA, data->extra); data->valid = false; /* Force cache refresh */ - mutex_unlock(&data->update_lock); +unlock: + it87_unlock(data); return count; } @@ -1289,12 +1329,15 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); long val; + int err; u8 reg; if (kstrtol(buf, 10, &val) < 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; if (has_16bit_fans(data)) { data->fan[nr][index] = FAN16_TO_REG(val); @@ -1321,7 +1364,7 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *attr, data->fan[nr][index]); } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1332,13 +1375,16 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; unsigned long val; - int min; + int min, err; u8 old; if (kstrtoul(buf, 10, &val) < 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + old = it87_read_value(data, IT87_REG_FAN_DIV); /* Save fan min limit */ @@ -1366,7 +1412,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, data->fan[nr][1] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); it87_write_value(data, IT87_REG_FAN_MIN[nr], data->fan[nr][1]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1407,6 +1453,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; long val; + int err; if (kstrtol(buf, 10, &val) < 0 || val < 0 || val > 2) return -EINVAL; @@ -1417,7 +1464,9 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, return -EINVAL; } - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; if (val == 0) { if (nr < 3 && data->type != it8603) { @@ -1468,7 +1517,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, } } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1479,11 +1528,15 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; long val; + int err; if (kstrtol(buf, 10, &val) < 0 || val < 0 || val > 255) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + it87_update_pwm_ctrl(data, nr); if (has_newer_autopwm(data)) { /* @@ -1491,8 +1544,8 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, * is read-only so we can't write the value. */ if (data->pwm_ctrl[nr] & 0x80) { - mutex_unlock(&data->update_lock); - return -EBUSY; + count = -EBUSY; + goto unlock; } data->pwm_duty[nr] = pwm_to_reg(data, val); it87_write_value(data, IT87_REG_PWM_DUTY[nr], @@ -1509,7 +1562,8 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, data->pwm_ctrl[nr]); } } - mutex_unlock(&data->update_lock); +unlock: + it87_unlock(data); return count; } @@ -1520,6 +1574,7 @@ static ssize_t set_pwm_freq(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; unsigned long val; + int err; int i; if (kstrtoul(buf, 10, &val) < 0) @@ -1534,7 +1589,10 @@ static ssize_t set_pwm_freq(struct device *dev, struct device_attribute *attr, break; } - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + if (nr == 0) { data->fan_ctl = it87_read_value(data, IT87_REG_FAN_CTL) & 0x8f; data->fan_ctl |= i << 4; @@ -1544,7 +1602,7 @@ static ssize_t set_pwm_freq(struct device *dev, struct device_attribute *attr, data->extra |= i << 4; it87_write_value(data, IT87_REG_TEMP_EXTRA, data->extra); } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1577,6 +1635,7 @@ static ssize_t set_pwm_temp_map(struct device *dev, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; long val; + int err; u8 reg; if (kstrtol(buf, 10, &val) < 0) @@ -1599,7 +1658,10 @@ static ssize_t set_pwm_temp_map(struct device *dev, return -EINVAL; } - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + it87_update_pwm_ctrl(data, nr); data->pwm_temp_map[nr] = reg; /* @@ -1611,7 +1673,7 @@ static ssize_t set_pwm_temp_map(struct device *dev, data->pwm_temp_map[nr]; it87_write_value(data, IT87_REG_PWM[nr], data->pwm_ctrl[nr]); } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1641,18 +1703,22 @@ static ssize_t set_auto_pwm(struct device *dev, struct device_attribute *attr, int point = sensor_attr->index; int regaddr; long val; + int err; if (kstrtol(buf, 10, &val) < 0 || val < 0 || val > 255) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + data->auto_pwm[nr][point] = pwm_to_reg(data, val); if (has_newer_autopwm(data)) regaddr = IT87_REG_AUTO_TEMP(nr, 3); else regaddr = IT87_REG_AUTO_PWM(nr, point); it87_write_value(data, regaddr, data->auto_pwm[nr][point]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1677,15 +1743,19 @@ static ssize_t set_auto_pwm_slope(struct device *dev, struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int nr = sensor_attr->index; unsigned long val; + int err; if (kstrtoul(buf, 10, &val) < 0 || val > 127) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + data->auto_pwm[nr][1] = (data->auto_pwm[nr][1] & 0x80) | val; it87_write_value(data, IT87_REG_AUTO_TEMP(nr, 4), data->auto_pwm[nr][1]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1720,11 +1790,15 @@ static ssize_t set_auto_temp(struct device *dev, struct device_attribute *attr, int point = sensor_attr->index; long val; int reg; + int err; if (kstrtol(buf, 10, &val) < 0 || val < -128000 || val > 127000) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + if (has_newer_autopwm(data) && !point) { reg = data->auto_temp[nr][1] - TEMP_TO_REG(val); reg = clamp_val(reg, 0, 0x1f) | (data->auto_temp[nr][0] & 0xe0); @@ -1737,7 +1811,7 @@ static ssize_t set_auto_temp(struct device *dev, struct device_attribute *attr, point--; it87_write_value(data, IT87_REG_AUTO_TEMP(nr, point), reg); } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1946,13 +2020,16 @@ static ssize_t clear_intrusion(struct device *dev, size_t count) { struct it87_data *data = dev_get_drvdata(dev); - int config; + int err, config; long val; if (kstrtol(buf, 10, &val) < 0 || val != 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + config = it87_read_value(data, IT87_REG_CONFIG); if (config < 0) { count = config; @@ -1962,8 +2039,7 @@ static ssize_t clear_intrusion(struct device *dev, /* Invalidate cache to force re-read */ data->valid = false; } - mutex_unlock(&data->update_lock); - + it87_unlock(data); return count; } @@ -2005,18 +2081,22 @@ static ssize_t set_beep(struct device *dev, struct device_attribute *attr, int bitnr = to_sensor_dev_attr(attr)->index; struct it87_data *data = dev_get_drvdata(dev); long val; + int err; if (kstrtol(buf, 10, &val) < 0 || (val != 0 && val != 1)) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + data->beeps = it87_read_value(data, IT87_REG_BEEP_ENABLE); if (val) data->beeps |= BIT(bitnr); else data->beeps &= ~BIT(bitnr); it87_write_value(data, IT87_REG_BEEP_ENABLE, data->beeps); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -3179,6 +3259,7 @@ static int it87_probe(struct platform_device *pdev) struct it87_sio_data *sio_data = dev_get_platdata(dev); int enable_pwm_interface; struct device *hwmon_dev; + int err; res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!devm_request_region(&pdev->dev, res->start, IT87_EC_EXTENT, @@ -3224,15 +3305,21 @@ static int it87_probe(struct platform_device *pdev) break; } - /* Now, we do the remaining detection. */ - if ((it87_read_value(data, IT87_REG_CONFIG) & 0x80) || - it87_read_value(data, IT87_REG_CHIPID) != 0x90) - return -ENODEV; - platform_set_drvdata(pdev, data); mutex_init(&data->update_lock); + err = smbus_disable(data); + if (err) + return err; + + /* Now, we do the remaining detection. */ + if ((it87_read_value(data, IT87_REG_CONFIG) & 0x80) || + it87_read_value(data, IT87_REG_CHIPID) != 0x90) { + smbus_enable(data); + return -ENODEV; + } + /* Check PWM configuration */ enable_pwm_interface = it87_check_pwm(dev); if (!enable_pwm_interface) @@ -3293,6 +3380,8 @@ static int it87_probe(struct platform_device *pdev) /* Initialize the IT87 chip */ it87_init_device(pdev); + smbus_enable(data); + if (!sio_data->skip_vid) { data->has_vid = true; data->vrm = vid_which_vrm(); @@ -3360,7 +3449,7 @@ static int it87_resume(struct device *dev) it87_resume_sio(pdev); - mutex_lock(&data->update_lock); + it87_lock(data); it87_check_pwm(dev); it87_check_limit_regs(data); @@ -3373,7 +3462,7 @@ static int it87_resume(struct device *dev) /* force update */ data->valid = false; - mutex_unlock(&data->update_lock); + it87_unlock(data); it87_update_device(dev); From 0be100771711b99ab561ee3121657329a11e173a Mon Sep 17 00:00:00 2001 From: Frank Crawford Date: Sun, 16 Apr 2023 14:25:10 +1000 Subject: [PATCH 127/131] hwmon: (it87) Disable/enable SMBus access for IT8622E chipset Configure the IT8622E chip to disable/re-enable access via an SMBus when reading or writing the chip's registers. Signed-off-by: Frank Crawford Signed-off-by: Guenter Roeck --- drivers/hwmon/it87.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index cb97b3f029bde1..eb38f54ebeb616 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -474,6 +474,7 @@ static const struct it87_devices it87_devices[] = { | FEAT_FIVE_PWM | FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2 | FEAT_AVCC3 | FEAT_VIN3_5V, .peci_mask = 0x07, + .smbus_bitmap = BIT(1) | BIT(2), }, [it8628] = { .name = "it8628", From 19692f17cd133ba2305e1f5c6484e623ec1ac7d0 Mon Sep 17 00:00:00 2001 From: Aleksa Savic Date: Sun, 16 Apr 2023 20:17:01 +0200 Subject: [PATCH 128/131] hwmon: (aquacomputer_d5next) Add support for Aquacomputer Aquastream XT Extend aquacomputer_d5next driver to expose various hardware sensors of the Aquacomputer Aquastream XT watercooling pump, which communicates through a proprietary USB HID protocol. Implemented by Leonard Anderweit [1] [2]. Coolant temp, fan IC and external temp sensor readings are available, along with speed and voltage of both the pump and optionally connected fan. It also exposes pump current. Additionally, serial number and firmware version are exposed through debugfs. [1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/46 [2] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/49 Originally-from: Leonard Anderweit Signed-off-by: Aleksa Savic Link: https://lore.kernel.org/r/20230416181702.9892-1-savicaleksa83@gmail.com Signed-off-by: Guenter Roeck --- Documentation/hwmon/aquacomputer_d5next.rst | 5 + drivers/hwmon/aquacomputer_d5next.c | 114 +++++++++++++++++++- 2 files changed, 118 insertions(+), 1 deletion(-) diff --git a/Documentation/hwmon/aquacomputer_d5next.rst b/Documentation/hwmon/aquacomputer_d5next.rst index c604d4becb8d1a..14b37851af0ca7 100644 --- a/Documentation/hwmon/aquacomputer_d5next.rst +++ b/Documentation/hwmon/aquacomputer_d5next.rst @@ -12,6 +12,7 @@ Supported devices: * Aquacomputer Octo fan controller * Aquacomputer Quadro fan controller * Aquacomputer High Flow Next sensor +* Aquacomputer Aquastream XT watercooling pump * Aquacomputer Aquastream Ultimate watercooling pump * Aquacomputer Poweradjust 3 fan controller @@ -56,6 +57,10 @@ The High Flow Next exposes +5V voltages, water quality, conductivity and flow re A temperature sensor can be connected to it, in which case it provides its reading and an estimation of the dissipated/absorbed power in the liquid cooling loop. +The Aquastream XT pump exposes temperature readings for the coolant, external sensor +and fan IC. It also exposes pump and fan speeds (in RPM), voltages, as well as pump +current. + The Aquastream Ultimate pump exposes coolant temp and an external temp sensor, along with speed, power, voltage and current of both the pump and optionally connected fan. It also exposes pressure and flow speed readings. diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 3bd35d833e693c..a4fcd4ebf76c2b 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -29,12 +29,14 @@ #define USB_PRODUCT_ID_FARBWERK360 0xf010 #define USB_PRODUCT_ID_OCTO 0xf011 #define USB_PRODUCT_ID_HIGHFLOWNEXT 0xf012 +#define USB_PRODUCT_ID_AQUASTREAMXT 0xf0b6 #define USB_PRODUCT_ID_AQUASTREAMULT 0xf00b #define USB_PRODUCT_ID_POWERADJUST3 0xf0bd enum kinds { d5next, farbwerk, farbwerk360, octo, quadro, - highflownext, aquaero, poweradjust3, aquastreamult + highflownext, aquaero, poweradjust3, aquastreamult, + aquastreamxt }; static const char *const aqc_device_names[] = { @@ -44,6 +46,7 @@ static const char *const aqc_device_names[] = { [octo] = "octo", [quadro] = "quadro", [highflownext] = "highflownext", + [aquastreamxt] = "aquastreamxt", [aquaero] = "aquaero", [aquastreamult] = "aquastreamultimate", [poweradjust3] = "poweradjust3" @@ -77,6 +80,8 @@ static u8 aquaero_secondary_ctrl_report[] = { }; /* Report IDs for legacy devices */ +#define AQUASTREAMXT_STATUS_REPORT_ID 0x04 + #define POWERADJUST3_STATUS_REPORT_ID 0x03 /* Data types for reading and writing control reports */ @@ -231,6 +236,24 @@ static u16 quadro_ctrl_fan_offsets[] = { 0x37, 0x8c, 0xe1, 0x136 }; /* Fan speed #define HIGHFLOWNEXT_5V_VOLTAGE 97 #define HIGHFLOWNEXT_5V_VOLTAGE_USB 99 +/* Specs of the Aquastream XT pump */ +#define AQUASTREAMXT_SERIAL_START 0x3a +#define AQUASTREAMXT_FIRMWARE_VERSION 0x32 +#define AQUASTREAMXT_NUM_FANS 2 +#define AQUASTREAMXT_NUM_SENSORS 3 +#define AQUASTREAMXT_FAN_STOPPED 0x4 +#define AQUASTREAMXT_PUMP_CONVERSION_CONST 45000000 +#define AQUASTREAMXT_FAN_CONVERSION_CONST 5646000 +#define AQUASTREAMXT_SENSOR_REPORT_SIZE 0x42 + +/* Sensor report offsets and info for Aquastream XT */ +#define AQUASTREAMXT_SENSOR_START 0xd +#define AQUASTREAMXT_FAN_VOLTAGE_OFFSET 0x7 +#define AQUASTREAMXT_FAN_STATUS_OFFSET 0x1d +#define AQUASTREAMXT_PUMP_VOLTAGE_OFFSET 0x9 +#define AQUASTREAMXT_PUMP_CURR_OFFSET 0xb +static u16 aquastreamxt_sensor_fan_offsets[] = { 0x13, 0x1b }; + /* Specs of the Poweradjust 3 */ #define POWERADJUST3_NUM_SENSORS 1 #define POWERADJUST3_SENSOR_REPORT_SIZE 0x32 @@ -388,6 +411,13 @@ static const char *const label_highflownext_voltage[] = { "+5V USB voltage" }; +/* Labels for Aquastream XT */ +static const char *const label_aquastreamxt_temp_sensors[] = { + "Fan IC temp", + "External sensor", + "Coolant temp" +}; + /* Labels for Aquastream Ultimate */ static const char *const label_aquastreamult_temp[] = { "Coolant temp", @@ -531,6 +561,22 @@ static int aqc_pwm_to_percent(long val) return DIV_ROUND_CLOSEST(val * 100 * 100, 255); } +/* Converts raw value for Aquastream XT pump speed to RPM */ +static int aqc_aquastreamxt_convert_pump_rpm(u16 val) +{ + if (val > 0) + return DIV_ROUND_CLOSEST(AQUASTREAMXT_PUMP_CONVERSION_CONST, val); + return 0; +} + +/* Converts raw value for Aquastream XT fan speed to RPM */ +static int aqc_aquastreamxt_convert_fan_rpm(u16 val) +{ + if (val > 0) + return DIV_ROUND_CLOSEST(AQUASTREAMXT_FAN_CONVERSION_CONST, val); + return 0; +} + /* Expects the mutex to be locked */ static int aqc_get_ctrl_data(struct aqc_data *priv) { @@ -734,6 +780,8 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3 if (channel == 0) return 0444; break; + case aquastreamxt: + break; default: if (channel < priv->num_fans) return 0444; @@ -747,6 +795,11 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3 if (channel < 2) return 0444; break; + case aquastreamxt: + /* Special case to support pump current */ + if (channel == 0) + return 0444; + break; default: if (channel < priv->num_fans) return 0444; @@ -799,6 +852,43 @@ static int aqc_legacy_read(struct aqc_data *priv) priv->temp_input[i] = sensor_value * 10; } + /* Special-case sensor readings */ + switch (priv->kind) { + case aquastreamxt: + /* Info provided with every report */ + priv->serial_number[0] = get_unaligned_le16(priv->buffer + + priv->serial_number_start_offset); + priv->firmware_version = + get_unaligned_le16(priv->buffer + priv->firmware_version_offset); + + /* Read pump speed in RPM */ + sensor_value = get_unaligned_le16(priv->buffer + priv->fan_sensor_offsets[0]); + priv->speed_input[0] = aqc_aquastreamxt_convert_pump_rpm(sensor_value); + + /* Read fan speed in RPM, if available */ + sensor_value = get_unaligned_le16(priv->buffer + AQUASTREAMXT_FAN_STATUS_OFFSET); + if (sensor_value == AQUASTREAMXT_FAN_STOPPED) { + priv->speed_input[1] = 0; + } else { + sensor_value = + get_unaligned_le16(priv->buffer + priv->fan_sensor_offsets[1]); + priv->speed_input[1] = aqc_aquastreamxt_convert_fan_rpm(sensor_value); + } + + /* Calculation derived from linear regression */ + sensor_value = get_unaligned_le16(priv->buffer + AQUASTREAMXT_PUMP_CURR_OFFSET); + priv->current_input[0] = DIV_ROUND_CLOSEST(sensor_value * 176, 100) - 52; + + sensor_value = get_unaligned_le16(priv->buffer + AQUASTREAMXT_PUMP_VOLTAGE_OFFSET); + priv->voltage_input[0] = DIV_ROUND_CLOSEST(sensor_value * 1000, 61); + + sensor_value = get_unaligned_le16(priv->buffer + AQUASTREAMXT_FAN_VOLTAGE_OFFSET); + priv->voltage_input[1] = DIV_ROUND_CLOSEST(sensor_value * 1000, 63); + break; + default: + break; + } + priv->updated = jiffies; unlock_and_return: @@ -1481,6 +1571,21 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->power_label = label_highflownext_power; priv->voltage_label = label_highflownext_voltage; break; + case USB_PRODUCT_ID_AQUASTREAMXT: + priv->kind = aquastreamxt; + + priv->num_fans = AQUASTREAMXT_NUM_FANS; + priv->fan_sensor_offsets = aquastreamxt_sensor_fan_offsets; + + priv->num_temp_sensors = AQUASTREAMXT_NUM_SENSORS; + priv->temp_sensor_start_offset = AQUASTREAMXT_SENSOR_START; + priv->buffer_size = AQUASTREAMXT_SENSOR_REPORT_SIZE; + + priv->temp_label = label_aquastreamxt_temp_sensors; + priv->speed_label = label_d5next_speeds; + priv->voltage_label = label_d5next_voltages; + priv->current_label = label_d5next_current; + break; case USB_PRODUCT_ID_AQUASTREAMULT: priv->kind = aquastreamult; @@ -1526,6 +1631,12 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) case poweradjust3: priv->status_report_id = POWERADJUST3_STATUS_REPORT_ID; break; + case aquastreamxt: + priv->serial_number_start_offset = AQUASTREAMXT_SERIAL_START; + priv->firmware_version_offset = AQUASTREAMXT_FIRMWARE_VERSION; + + priv->status_report_id = AQUASTREAMXT_STATUS_REPORT_ID; + break; default: priv->serial_number_start_offset = AQC_SERIAL_START; priv->firmware_version_offset = AQC_FIRMWARE_VERSION; @@ -1596,6 +1707,7 @@ static const struct hid_device_id aqc_table[] = { { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_OCTO) }, { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_QUADRO) }, { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_HIGHFLOWNEXT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_AQUASTREAMXT) }, { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_AQUASTREAMULT) }, { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_POWERADJUST3) }, { } From 2a8e41ad337508fc5d598c0f9288890214f8e318 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Wed, 19 Apr 2023 11:36:55 +1200 Subject: [PATCH 129/131] hwmon: (adt7475) Use device_property APIs when configuring polarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On DT unaware platforms of_property_read_u32_array() returns -ENOSYS which wasn't handled by the code treating adi,pwm-active-state as optional. Update the code to use device_property_read_u32_array() which deals gracefully with DT unaware platforms. Fixes: 86da28eed4fb ("hwmon: (adt7475) Add support for inverting pwm output") Reported-by: Mariusz Białończyk Link: https://lore.kernel.org/linux-hwmon/52e26a67-9131-2dc0-40cb-db5c07370027@alliedtelesis.co.nz/T/#mdd0505801e0a4e72340de009a47c0fca4f771ed3 Signed-off-by: Chris Packham Link: https://lore.kernel.org/r/20230418233656.869055-2-chris.packham@alliedtelesis.co.nz Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck --- drivers/hwmon/adt7475.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 6e4c92b500b8e3..6a6ebcc896b1d1 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -1604,9 +1604,9 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client) int ret, i; u8 val; - ret = of_property_read_u32_array(client->dev.of_node, - "adi,pwm-active-state", states, - ARRAY_SIZE(states)); + ret = device_property_read_u32_array(&client->dev, + "adi,pwm-active-state", states, + ARRAY_SIZE(states)); if (ret) return ret; From 93822f5161a2dc57a60b95b35b3cb8589f53413e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Thu, 20 Apr 2023 19:19:39 +0200 Subject: [PATCH 130/131] hwmon: (pmbus/fsp-3y) Fix functionality bitmask in FSP-3Y YM-2151E MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bit flags in pmbus_driver_info functionality for YM-2151E chip were joined with a comma operator instead of a bitwise OR. This means that the last constant PMBUS_HAVE_IIN was not OR-ed with the other PM_BUS_HAVE_* constants for this page but it initialized the next element of the func array (which was not accessed from anywhere because of the number of pages). However, there is no need for setting PMBUS_HAVE_IIN in the 5Vsb page because this command does not seem to be paged. Obviously, the device only has one IIN sensor, so it doesn't make sense to query it again from the second page. Fixes: 1734b4135a62 ("hwmon: Add driver for fsp-3y PSUs and PDUs") Signed-off-by: Jan Kundrát Signed-off-by: Tomáš Pecka Link: https://lore.kernel.org/r/20230420171939.212040-1-tomas.pecka@cesnet.cz Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/fsp-3y.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hwmon/pmbus/fsp-3y.c b/drivers/hwmon/pmbus/fsp-3y.c index aec294cc72d1f2..c7469d2cdedcf7 100644 --- a/drivers/hwmon/pmbus/fsp-3y.c +++ b/drivers/hwmon/pmbus/fsp-3y.c @@ -180,7 +180,6 @@ static struct pmbus_driver_info fsp3y_info[] = { PMBUS_HAVE_FAN12, .func[YM2151_PAGE_5VSB_LOG] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT, - PMBUS_HAVE_IIN, .read_word_data = fsp3y_read_word_data, .read_byte_data = fsp3y_read_byte_data, }, From 1c19ac768b8eeb0304c4ed7db66c2bb89c6ad226 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 23 Apr 2023 10:10:07 +0200 Subject: [PATCH 131/131] hwmon: lochnagar: Remove the unneeded include This driver does not use i2c, so there is no point in including Remove it. Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/df555e724d1b52bd9958c0bd729a774dfe0cf150.1682237387.git.christophe.jaillet@wanadoo.fr Signed-off-by: Guenter Roeck --- drivers/hwmon/lochnagar-hwmon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hwmon/lochnagar-hwmon.c b/drivers/hwmon/lochnagar-hwmon.c index 9948e2f7208db2..6350904a8a8b46 100644 --- a/drivers/hwmon/lochnagar-hwmon.c +++ b/drivers/hwmon/lochnagar-hwmon.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include