summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-11-14 10:57:26 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-11-14 10:57:26 -0800
commit54975c6523dc77862c25deeb5fa395990b8d3fc4 (patch)
treef05ea1e31d8da28607ee3d0e0e191b95fd37270c
parentaacb7797504183a90d66b19b1efb555cfe9b3eec (diff)
parentb5c5b67e02406fb48acf57cf2c30a570230fd6aa (diff)
Merge tag 'hwmon-for-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - Read tracking-mode voltage fault limits dynamically in the mp2975 PMBus driver instead of caching probe-time snapshots, avoiding false over-voltage alarms when CPU voltage changes at runtime. - Fix SCMI sensor probe by enabling supported sensors via firmware IDs before exposing channels and checking channel config allocations. - Fix runtime PM enable and reference count imbalances during probe and teardown in the gpio-fan driver. - Fix max31760 fan controller initialization and reporting, including leaving standby at probe, initial 0 RPM reporting, and swapped temperature limit registers. - Assorted minor sensor reading, interval clamping, and register handling fixes in other drivers. * tag 'hwmon-for-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (aht10) Fix update_interval overflow on 64-bit hwmon: (scmi) Configure sensors before exposing channels hwmon: (scmi) Check channel config allocation hwmon: (nct6775) Handle dual use registers hwmon: (scmi) Enable temperature sensors using their sensor IDs hwmon: (pmbus/mp2975) Get vout fault limits dynamically hwmon: (sy7636a) fix negative temperatures hwmon: (max31760) Report 0 RPM before the first fan speed measurement hwmon: (max31760) Leave standby mode at probe hwmon: (max31760) Fix the local temperature limit registers hwmon: (gpio-fan) Fix runtime PM imbalance in probe and teardown
-rw-r--r--drivers/hwmon/aht10.c2
-rw-r--r--drivers/hwmon/gpio-fan.c24
-rw-r--r--drivers/hwmon/max31760.c12
-rw-r--r--drivers/hwmon/nct6775-core.c6
-rw-r--r--drivers/hwmon/pmbus/mp2975.c207
-rw-r--r--drivers/hwmon/scmi-hwmon.c25
-rw-r--r--drivers/hwmon/sy7636a-hwmon.c2
7 files changed, 150 insertions, 128 deletions
diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c
index 89d18793137c..1a7580bf18b7 100644
--- a/drivers/hwmon/aht10.c
+++ b/drivers/hwmon/aht10.c
@@ -222,7 +222,7 @@ static int aht10_read_values(struct aht10_data *data)
static ssize_t aht10_interval_write(struct aht10_data *data,
long val)
{
- data->min_poll_interval = ms_to_ktime(clamp_val(val, 2000, LONG_MAX));
+ data->min_poll_interval = ms_to_ktime(clamp_val(val, 2000, INT_MAX));
return 0;
}
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index d95a00f1c863..55c812442b4f 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -528,8 +528,6 @@ static void gpio_fan_stop(void *data)
mutex_lock(&fan_data->lock);
set_fan_speed(data, 0);
mutex_unlock(&fan_data->lock);
-
- pm_runtime_disable(fan_data->dev);
}
static int gpio_fan_probe(struct platform_device *pdev)
@@ -556,6 +554,11 @@ static int gpio_fan_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(fan_data->supply),
"Failed to get fan-supply");
+ pm_runtime_set_suspended(dev);
+ err = devm_pm_runtime_enable(dev);
+ if (err)
+ return err;
+
/* Configure control GPIOs if available. */
if (fan_data->gpios && fan_data->num_gpios > 0) {
if (!fan_data->speed || fan_data->num_speed <= 1)
@@ -563,6 +566,12 @@ static int gpio_fan_probe(struct platform_device *pdev)
err = fan_ctrl_init(fan_data);
if (err)
return err;
+ /* If current GPIO state is active, mark RPM as active as well */
+ if (fan_data->speed_index > 0) {
+ err = pm_runtime_resume_and_get(dev);
+ if (err)
+ return err;
+ }
err = devm_add_action_or_reset(dev, gpio_fan_stop, fan_data);
if (err)
return err;
@@ -583,17 +592,6 @@ static int gpio_fan_probe(struct platform_device *pdev)
return err;
}
- pm_runtime_set_suspended(&pdev->dev);
- pm_runtime_enable(&pdev->dev);
- /* If current GPIO state is active, mark RPM as active as well */
- if (fan_data->speed_index > 0) {
- int ret;
-
- ret = pm_runtime_resume_and_get(&pdev->dev);
- if (ret)
- return ret;
- }
-
/* Optional cooling device register for Device tree platforms */
fan_data->cdev = devm_thermal_of_child_cooling_device_register(dev, np,
"gpio-fan",
diff --git a/drivers/hwmon/max31760.c b/drivers/hwmon/max31760.c
index d88c1eff9146..cf9ee0ed1389 100644
--- a/drivers/hwmon/max31760.c
+++ b/drivers/hwmon/max31760.c
@@ -27,8 +27,8 @@
#define REG_TACH(ch) (0x52 + (ch) * 2)
#define REG_TEMP_INPUT(ch) (0x56 + (ch) * 2)
-#define REG_TEMP_MAX(ch) (0x06 + (ch) * 2)
-#define REG_TEMP_CRIT(ch) (0x0A + (ch) * 2)
+#define REG_TEMP_MAX(ch) ((ch) ? 0x0C : 0x06)
+#define REG_TEMP_CRIT(ch) ((ch) ? 0x08 : 0x0A)
#define TEMP11_FROM_REG(reg) ((reg) / 32 * 125)
#define TEMP11_TO_REG(val) (DIV_ROUND_CLOSEST(clamp_val((val), -128000, \
@@ -68,8 +68,9 @@ static const int max31760_pwm_freq[] = {33, 150, 1500, 25000};
static int tach_to_rpm(u16 tach)
{
+ /* The count is 0 until the first measurement */
if (tach == 0)
- tach = 1;
+ return 0;
return 60 * 100000 / tach / 2;
}
@@ -533,8 +534,9 @@ static int max31760_probe(struct i2c_client *client)
dev_set_drvdata(dev, state);
- /* Set alert output to comparator mode */
- ret = regmap_set_bits(state->regmap, REG_CR2, CR2_ALERTS);
+ /* Leave standby mode, set alert output to comparator mode */
+ ret = regmap_update_bits(state->regmap, REG_CR2, CR2_STBY | CR2_ALERTS,
+ CR2_ALERTS);
if (ret)
return dev_err_probe(dev, ret, "cannot write register\n");
diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index 6e97e4f08b90..3515a962adac 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1188,15 +1188,13 @@ bool nct6775_reg_is_word_sized(struct nct6775_data *data, u16 reg)
case nct6106:
return reg == 0x20 || reg == 0x22 || reg == 0x24 ||
(reg >= 0x59 && reg < 0x69 && (reg & 1)) ||
- reg == 0xe0 || reg == 0xe2 || reg == 0xe4 ||
- reg == 0x111 || reg == 0x121 || reg == 0x131;
+ reg == 0xe0 || reg == 0xe2 || reg == 0xe4;
case nct6116:
case nct6126:
return reg == 0x20 || reg == 0x22 || reg == 0x24 ||
reg == 0x26 || reg == 0x28 || reg == 0x59 || reg == 0x5b ||
reg == 0xe0 || reg == 0xe2 || reg == 0xe4 || reg == 0xe6 ||
- reg == 0xe8 || reg == 0x111 || reg == 0x121 || reg == 0x131 ||
- reg == 0x191 || reg == 0x1a1;
+ reg == 0xe8;
case nct6775:
return (((reg & 0xff00) == 0x100 ||
(reg & 0xff00) == 0x200) &&
diff --git a/drivers/hwmon/pmbus/mp2975.c b/drivers/hwmon/pmbus/mp2975.c
index a11ec6756990..2ad6b7d831c8 100644
--- a/drivers/hwmon/pmbus/mp2975.c
+++ b/drivers/hwmon/pmbus/mp2975.c
@@ -109,10 +109,7 @@ struct mp2975_data {
int vout_scale;
int max_phases[MP2975_PAGE_NUM];
int vid_step[MP2975_PAGE_NUM];
- int vref[MP2975_PAGE_NUM];
- int vref_off[MP2975_PAGE_NUM];
int vout_max[MP2975_PAGE_NUM];
- int vout_ov_fixed[MP2975_PAGE_NUM];
int curr_sense_gain[MP2975_PAGE_NUM];
};
@@ -460,12 +457,77 @@ static int mp2973_write_word_data(struct i2c_client *client, int page,
return pmbus_write_word_data(client, 0, PMBUS_SMBALERT_MASK, ret);
}
+/*
+ * Let the PMBus core change the page, so that the page it caches matches the
+ * device. The core does not issue PAGE commands for a single rail
+ * configuration, thus change the page directly then.
+ */
+static int
+mp2975_page_set(struct i2c_client *client, struct mp2975_data *data, int page)
+{
+ if (data->info.pages > 1)
+ return pmbus_set_page(client, page, 0xff);
+
+ return i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
+}
+
+/*
+ * Voltage reference is available on page 3 only. The callers read a register
+ * of the rail through the core first, thus the core caches the rail page.
+ */
+static int
+mp2975_vref_get(struct i2c_client *client, struct mp2975_data *data, int page)
+{
+ int ret, vref;
+
+ ret = mp2975_page_set(client, data, 3);
+ if (ret < 0)
+ return ret;
+
+ vref = i2c_smbus_read_word_data(client, page ? MP2975_MFR_READ_VREF_R2 :
+ MP2975_MFR_READ_VREF_R1);
+
+ ret = mp2975_page_set(client, data, page);
+ if (ret < 0)
+ return ret;
+
+ return (vref < 0) ? vref : vref * data->vid_step[page];
+}
+
+static int
+mp2975_ovp2_offset_get(int ovp_th_set)
+{
+ switch ((ovp_th_set & GENMASK(5, 3)) >> 3) {
+ case 1:
+ return 140;
+ case 2:
+ return 220;
+ case 4:
+ return 400;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int
+mp2975_vout_ovp2_get(struct i2c_client *client, struct mp2975_data *data,
+ int page, int vref_off)
+{
+ int vref;
+
+ vref = mp2975_vref_get(client, data, page);
+ if (vref < 0)
+ return vref;
+
+ return vref + DIV_ROUND_CLOSEST(vref_off * data->vout_scale, 10);
+}
+
static int mp2975_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct mp2975_data *data = to_mp2975_data(info);
- int ret;
+ int ret, ovp1, vref_off, uv_off;
switch (reg) {
case PMBUS_OT_FAULT_LIMIT:
@@ -482,19 +544,35 @@ static int mp2975_read_word_data(struct i2c_client *client, int page,
break;
case PMBUS_VOUT_OV_FAULT_LIMIT:
/*
- * Register provides two values for over-voltage protection
- * threshold for fixed (ovp2) and tracking (ovp1) modes. The
- * minimum of these two values is provided as over-voltage
- * fault alarm.
+ * Device provides dual over-voltage protection. OVP1 is
+ * referred to the maximum reference voltage, while OVP2 is
+ * referred to the current voltage reference, which is changed
+ * at runtime. Protection is tripped by any of them, thus the
+ * minimum of the two is exposed as over-voltage fault alarm,
+ * and OVP2 is obtained on each read.
*/
ret = mp2975_read_word_helper(client, page, phase,
MP2975_MFR_OVP_TH_SET,
- GENMASK(2, 0));
+ GENMASK(5, 0));
if (ret < 0)
return ret;
- ret = min_t(int, data->vout_max[page] + 50 * (ret + 1),
- data->vout_ov_fixed[page]);
+ ovp1 = data->vout_max[page] + 50 * ((ret & GENMASK(2, 0)) + 1);
+
+ /* OVP1 still applies if the OVP2 threshold is unknown. */
+ vref_off = mp2975_ovp2_offset_get(ret);
+ if (vref_off < 0) {
+ dev_warn_once(&client->dev,
+ "unsupported OVP2 selector, reporting OVP1 threshold\n");
+ ret = ovp1;
+ break;
+ }
+
+ ret = mp2975_vout_ovp2_get(client, data, page, vref_off);
+ if (ret < 0)
+ return ret;
+
+ ret = min_t(int, ovp1, ret);
break;
case PMBUS_VOUT_UV_FAULT_LIMIT:
ret = mp2975_read_word_helper(client, page, phase,
@@ -503,8 +581,17 @@ static int mp2975_read_word_data(struct i2c_client *client, int page,
if (ret < 0)
return ret;
- ret = DIV_ROUND_CLOSEST(data->vref[page] * 10 - 50 *
- (ret + 1) * data->vout_scale, 10);
+ uv_off = 50 * (ret + 1) * data->vout_scale;
+
+ ret = mp2975_vref_get(client, data, page);
+ if (ret < 0)
+ return ret;
+
+ /*
+ * Offset can exceed the voltage reference, while a negative
+ * value would be reported as a read error.
+ */
+ ret = max_t(int, DIV_ROUND_CLOSEST(ret * 10 - uv_off, 10), 0);
break;
case PMBUS_VIRT_READ_POUT_MAX:
ret = mp2975_read_word_helper(client, page, phase,
@@ -754,60 +841,6 @@ mp2975_current_sense_gain_get(struct i2c_client *client,
}
static int
-mp2975_vref_get(struct i2c_client *client, struct mp2975_data *data,
- struct pmbus_driver_info *info)
-{
- int ret;
-
- ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 3);
- if (ret < 0)
- return ret;
-
- /* Get voltage reference value for rail 1. */
- ret = i2c_smbus_read_word_data(client, MP2975_MFR_READ_VREF_R1);
- if (ret < 0)
- return ret;
-
- data->vref[0] = ret * data->vid_step[0];
-
- /* Get voltage reference value for rail 2, if connected. */
- if (data->info.pages == MP2975_PAGE_NUM) {
- ret = i2c_smbus_read_word_data(client, MP2975_MFR_READ_VREF_R2);
- if (ret < 0)
- return ret;
-
- data->vref[1] = ret * data->vid_step[1];
- }
- return 0;
-}
-
-static int
-mp2975_vref_offset_get(struct i2c_client *client, struct mp2975_data *data,
- int page)
-{
- int ret;
-
- ret = i2c_smbus_read_word_data(client, MP2975_MFR_OVP_TH_SET);
- if (ret < 0)
- return ret;
-
- switch ((ret & GENMASK(5, 3)) >> 3) {
- case 1:
- data->vref_off[page] = 140;
- break;
- case 2:
- data->vref_off[page] = 220;
- break;
- case 4:
- data->vref_off[page] = 400;
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static int
mp2975_vout_max_get(struct i2c_client *client, struct mp2975_data *data,
struct pmbus_driver_info *info, int page)
{
@@ -911,25 +944,6 @@ mp2975_vout_per_rail_config_get(struct i2c_client *client,
ret = mp2975_vout_max_get(client, data, info, i);
if (ret < 0)
return ret;
-
- /* Skip if reading Vref is unsupported */
- if (data->chip_id != mp2975)
- continue;
-
- /* Obtain voltage reference offsets. */
- ret = mp2975_vref_offset_get(client, data, i);
- if (ret < 0)
- return ret;
-
- /*
- * Set over-voltage fixed value. Thresholds are provided as
- * fixed value, and tracking value. The minimum of them are
- * exposed as over-voltage critical threshold.
- */
- data->vout_ov_fixed[i] = data->vref[i] +
- DIV_ROUND_CLOSEST(data->vref_off[i] *
- data->vout_scale,
- 10);
}
return 0;
@@ -1042,11 +1056,6 @@ static int mp2975_probe(struct i2c_client *client)
if (ret)
return ret;
- /* Obtain voltage reference values. */
- ret = mp2975_vref_get(client, data, info);
- if (ret)
- return ret;
-
/* Obtain vout over-voltage scales. */
ret = mp2975_vout_ov_scale_get(client, data, info);
if (ret < 0)
@@ -1063,7 +1072,21 @@ static int mp2975_probe(struct i2c_client *client)
if (ret)
return ret;
- return pmbus_do_probe(client, info);
+ ret = pmbus_do_probe(client, info);
+ if (ret)
+ return ret;
+
+ /*
+ * Vout over- and under-voltage fault limits are relative to the
+ * voltage reference, which is changed at runtime. Do not allow the
+ * PMBus core to cache them.
+ */
+ if (data->chip_id == mp2975) {
+ pmbus_set_update(client, PMBUS_VOUT_OV_FAULT_LIMIT, true);
+ pmbus_set_update(client, PMBUS_VOUT_UV_FAULT_LIMIT, true);
+ }
+
+ return 0;
}
static const struct of_device_id mp2975_of_match[] = {
diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
index d4195d14a983..91a63e92c3ed 100644
--- a/drivers/hwmon/scmi-hwmon.c
+++ b/drivers/hwmon/scmi-hwmon.c
@@ -228,8 +228,8 @@ static int scmi_thermal_sensor_register(struct device *dev,
static int scmi_hwmon_probe(struct scmi_device *sdev)
{
- int i, idx;
u16 nr_sensors;
+ int i, idx, ret;
enum hwmon_sensor_types type;
struct scmi_sensors *scmi_sensors;
const struct scmi_sensor_info *sensor;
@@ -297,8 +297,12 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
if (!nr_count[type])
continue;
- scmi_hwmon_add_chan_info(scmi_hwmon_chan, dev, nr_count[type],
- type, hwmon_attributes[type]);
+ ret = scmi_hwmon_add_chan_info(scmi_hwmon_chan, dev,
+ nr_count[type], type,
+ hwmon_attributes[type]);
+ if (ret)
+ return ret;
+
*ptr_scmi_ci++ = scmi_hwmon_chan++;
scmi_sensors->info[type] =
@@ -321,6 +325,12 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
case ENERGY:
type = scmi_types[sensor->type];
idx = --nr_count[type];
+ ret = sensor_ops->config_set(ph, sensor->id, sensor_config);
+ if (ret) {
+ dev_err(dev, "Error enabling sensor %s. err=%d\n",
+ sensor->name, ret);
+ continue;
+ }
*(scmi_sensors->info[type] + idx) = sensor;
break;
}
@@ -333,19 +343,10 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
return PTR_ERR(hwdev);
for (i = 0; i < nr_count_temp; i++) {
- int ret;
-
sensor = *(scmi_sensors->info[hwmon_temp] + i);
if (!sensor)
continue;
- ret = sensor_ops->config_set(ph, i, sensor_config);
- if (ret) {
- dev_err(dev, "Error enabling sensor %s. err=%d\n",
- sensor->name, ret);
- continue;
- }
-
/*
* Warn on any misconfiguration related to thermal zones but
* bail out of probing only on memory errors.
diff --git a/drivers/hwmon/sy7636a-hwmon.c b/drivers/hwmon/sy7636a-hwmon.c
index d51daaf63d63..f01f368d68e5 100644
--- a/drivers/hwmon/sy7636a-hwmon.c
+++ b/drivers/hwmon/sy7636a-hwmon.c
@@ -29,7 +29,7 @@ static int sy7636a_read(struct device *dev, enum hwmon_sensor_types type,
if (ret)
return ret;
- *temp = reg_val * 1000;
+ *temp = (s8)reg_val * 1000;
return 0;
}