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
This commit is contained in:
Linus Torvalds
2026-11-14 10:57:26 -08:00
7 changed files with 150 additions and 128 deletions
+1 -1
View File
@@ -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;
}
+11 -13
View File
@@ -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",
+7 -5
View File
@@ -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");
+2 -4
View File
@@ -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) &&
+115 -92
View File
@@ -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,
@@ -753,60 +840,6 @@ mp2975_current_sense_gain_get(struct i2c_client *client,
return 0;
}
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[] = {
+13 -12
View File
@@ -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.
+1 -1
View File
@@ -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;
}