* [PATCH v2 0/2] hwmon: (sch5627) Add pwmX_auto_channels_temp attributes @ 2022-02-24 6:12 Armin Wolf 2022-02-24 6:12 ` [PATCH v2 1/2] hwmon: (core) Add support for pwm auto channels attribute Armin Wolf 2022-02-24 6:12 ` [PATCH v2 2/2] hwmon: (sch5627) Add pwmX_auto_channels_temp support Armin Wolf 0 siblings, 2 replies; 5+ messages in thread From: Armin Wolf @ 2022-02-24 6:12 UTC (permalink / raw) To: hdegoede; +Cc: jdelvare, linux, linux-hwmon, linux-kernel After doing some research, i found out that Fujitsu's hardware mointoring solution inside the SCH5627 exports data thru registers 0xA0 - 0xA3 regarding the mapping between temperature sensors and fans. If those registers are set to 0, the fans are forced to full speed. The first patch adds support for pwmX_auto_channels_temp attributes to the hwmon core, while the second patch does extend the sch5627 driver. Both patches have been tested on a Fujitsu Esprimo P720. --- Changes in v2: - acquire mutex before doing register reads/writes Armin Wolf (2): hwmon: (core) Add support for pwm auto channels attribute hwmon: (sch5627) Add pwmX_auto_channels_temp support Documentation/hwmon/sch5627.rst | 4 +++ drivers/hwmon/hwmon.c | 1 + drivers/hwmon/sch5627.c | 61 +++++++++++++++++++++++++++++++++ include/linux/hwmon.h | 2 ++ 4 files changed, 68 insertions(+) -- 2.30.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] hwmon: (core) Add support for pwm auto channels attribute 2022-02-24 6:12 [PATCH v2 0/2] hwmon: (sch5627) Add pwmX_auto_channels_temp attributes Armin Wolf @ 2022-02-24 6:12 ` Armin Wolf 2022-02-25 2:09 ` Guenter Roeck 2022-02-24 6:12 ` [PATCH v2 2/2] hwmon: (sch5627) Add pwmX_auto_channels_temp support Armin Wolf 1 sibling, 1 reply; 5+ messages in thread From: Armin Wolf @ 2022-02-24 6:12 UTC (permalink / raw) To: hdegoede; +Cc: jdelvare, linux, linux-hwmon, linux-kernel pwm[1-*]_auto_channels_temp is documented as an official hwmon sysfs attribute, yet there is no support for it in the new with_info-API. Fix that. Signed-off-by: Armin Wolf <W_Armin@gmx.de> --- drivers/hwmon/hwmon.c | 1 + include/linux/hwmon.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 0d6c6809f26c..989e2c8496dd 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -604,6 +604,7 @@ static const char * const hwmon_pwm_attr_templates[] = { [hwmon_pwm_enable] = "pwm%d_enable", [hwmon_pwm_mode] = "pwm%d_mode", [hwmon_pwm_freq] = "pwm%d_freq", + [hwmon_pwm_auto_channels_temp] = "pwm%d_auto_channels_temp", }; static const char * const hwmon_intrusion_attr_templates[] = { diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h index fad1f1df26df..eba380b76d15 100644 --- a/include/linux/hwmon.h +++ b/include/linux/hwmon.h @@ -332,12 +332,14 @@ enum hwmon_pwm_attributes { hwmon_pwm_enable, hwmon_pwm_mode, hwmon_pwm_freq, + hwmon_pwm_auto_channels_temp, }; #define HWMON_PWM_INPUT BIT(hwmon_pwm_input) #define HWMON_PWM_ENABLE BIT(hwmon_pwm_enable) #define HWMON_PWM_MODE BIT(hwmon_pwm_mode) #define HWMON_PWM_FREQ BIT(hwmon_pwm_freq) +#define HWMON_PWM_AUTO_CHANNELS_TEMP BIT(hwmon_pwm_auto_channels_temp) enum hwmon_intrusion_attributes { hwmon_intrusion_alarm, -- 2.30.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] hwmon: (core) Add support for pwm auto channels attribute 2022-02-24 6:12 ` [PATCH v2 1/2] hwmon: (core) Add support for pwm auto channels attribute Armin Wolf @ 2022-02-25 2:09 ` Guenter Roeck 0 siblings, 0 replies; 5+ messages in thread From: Guenter Roeck @ 2022-02-25 2:09 UTC (permalink / raw) To: Armin Wolf; +Cc: hdegoede, jdelvare, linux-hwmon, linux-kernel On Thu, Feb 24, 2022 at 07:12:09AM +0100, Armin Wolf wrote: > pwm[1-*]_auto_channels_temp is documented as an official > hwmon sysfs attribute, yet there is no support for it in > the new with_info-API. Fix that. > > Signed-off-by: Armin Wolf <W_Armin@gmx.de> Applied to hwmon-next. Thanks, Guenter > --- > drivers/hwmon/hwmon.c | 1 + > include/linux/hwmon.h | 2 ++ > 2 files changed, 3 insertions(+) > > -- > 2.30.2 > > diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c > index 0d6c6809f26c..989e2c8496dd 100644 > --- a/drivers/hwmon/hwmon.c > +++ b/drivers/hwmon/hwmon.c > @@ -604,6 +604,7 @@ static const char * const hwmon_pwm_attr_templates[] = { > [hwmon_pwm_enable] = "pwm%d_enable", > [hwmon_pwm_mode] = "pwm%d_mode", > [hwmon_pwm_freq] = "pwm%d_freq", > + [hwmon_pwm_auto_channels_temp] = "pwm%d_auto_channels_temp", > }; > > static const char * const hwmon_intrusion_attr_templates[] = { > diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h > index fad1f1df26df..eba380b76d15 100644 > --- a/include/linux/hwmon.h > +++ b/include/linux/hwmon.h > @@ -332,12 +332,14 @@ enum hwmon_pwm_attributes { > hwmon_pwm_enable, > hwmon_pwm_mode, > hwmon_pwm_freq, > + hwmon_pwm_auto_channels_temp, > }; > > #define HWMON_PWM_INPUT BIT(hwmon_pwm_input) > #define HWMON_PWM_ENABLE BIT(hwmon_pwm_enable) > #define HWMON_PWM_MODE BIT(hwmon_pwm_mode) > #define HWMON_PWM_FREQ BIT(hwmon_pwm_freq) > +#define HWMON_PWM_AUTO_CHANNELS_TEMP BIT(hwmon_pwm_auto_channels_temp) > > enum hwmon_intrusion_attributes { > hwmon_intrusion_alarm, ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] hwmon: (sch5627) Add pwmX_auto_channels_temp support 2022-02-24 6:12 [PATCH v2 0/2] hwmon: (sch5627) Add pwmX_auto_channels_temp attributes Armin Wolf 2022-02-24 6:12 ` [PATCH v2 1/2] hwmon: (core) Add support for pwm auto channels attribute Armin Wolf @ 2022-02-24 6:12 ` Armin Wolf 2022-02-25 2:10 ` Guenter Roeck 1 sibling, 1 reply; 5+ messages in thread From: Armin Wolf @ 2022-02-24 6:12 UTC (permalink / raw) To: hdegoede; +Cc: jdelvare, linux, linux-hwmon, linux-kernel After doing some research, it seems that Fujitsu's hardware monitoring solution exports data describing which temperature sensors affect which fans, similar to the data in fan_source of the ftsteutates driver. Writing 0 into these registers forces the fans to full speed. Export this data with standard attributes. Signed-off-by: Armin Wolf <W_Armin@gmx.de> --- Documentation/hwmon/sch5627.rst | 4 +++ drivers/hwmon/sch5627.c | 61 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/Documentation/hwmon/sch5627.rst b/Documentation/hwmon/sch5627.rst index 187682e99114..ecb4fc84d045 100644 --- a/Documentation/hwmon/sch5627.rst +++ b/Documentation/hwmon/sch5627.rst @@ -20,6 +20,10 @@ Description SMSC SCH5627 Super I/O chips include complete hardware monitoring capabilities. They can monitor up to 5 voltages, 4 fans and 8 temperatures. +In addition, the SCH5627 exports data describing which temperature sensors +affect the speed of each fan. Setting pwmX_auto_channels_temp to 0 forces +the corresponding fan to full speed until another value is written. + The SMSC SCH5627 hardware monitoring part also contains an integrated watchdog. In order for this watchdog to function some motherboard specific initialization most be done by the BIOS, so if the watchdog is not enabled diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c index 72c3f6757e34..25fbbd4c9a2b 100644 --- a/drivers/hwmon/sch5627.c +++ b/drivers/hwmon/sch5627.c @@ -52,6 +52,9 @@ static const u16 SCH5627_REG_FAN[SCH5627_NO_FANS] = { static const u16 SCH5627_REG_FAN_MIN[SCH5627_NO_FANS] = { 0x62, 0x64, 0x66, 0x68 }; +static const u16 SCH5627_REG_PWM_MAP[SCH5627_NO_FANS] = { + 0xA0, 0xA1, 0xA2, 0xA3 }; + static const u16 SCH5627_REG_IN_MSB[SCH5627_NO_IN] = { 0x22, 0x23, 0x24, 0x25, 0x189 }; static const u16 SCH5627_REG_IN_LSN[SCH5627_NO_IN] = { @@ -223,6 +226,9 @@ static int reg_to_rpm(u16 reg) static umode_t sch5627_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, int channel) { + if (type == hwmon_pwm && attr == hwmon_pwm_auto_channels_temp) + return 0644; + return 0444; } @@ -278,6 +284,23 @@ static int sch5627_read(struct device *dev, enum hwmon_sensor_types type, u32 at break; } break; + case hwmon_pwm: + switch (attr) { + case hwmon_pwm_auto_channels_temp: + mutex_lock(&data->update_lock); + ret = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_PWM_MAP[channel]); + mutex_unlock(&data->update_lock); + + if (ret < 0) + return ret; + + *val = ret; + + return 0; + default: + break; + } + break; case hwmon_in: ret = sch5627_update_in(data); if (ret < 0) @@ -318,10 +341,42 @@ static int sch5627_read_string(struct device *dev, enum hwmon_sensor_types type, return -EOPNOTSUPP; } +static int sch5627_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, + long val) +{ + struct sch5627_data *data = dev_get_drvdata(dev); + int ret; + + switch (type) { + case hwmon_pwm: + switch (attr) { + case hwmon_pwm_auto_channels_temp: + /* registers are 8 bit wide */ + if (val > U8_MAX || val < 0) + return -EINVAL; + + mutex_lock(&data->update_lock); + ret = sch56xx_write_virtual_reg(data->addr, SCH5627_REG_PWM_MAP[channel], + val); + mutex_unlock(&data->update_lock); + + return ret; + default: + break; + } + break; + default: + break; + } + + return -EOPNOTSUPP; +} + static const struct hwmon_ops sch5627_ops = { .is_visible = sch5627_is_visible, .read = sch5627_read, .read_string = sch5627_read_string, + .write = sch5627_write, }; static const struct hwmon_channel_info *sch5627_info[] = { @@ -342,6 +397,12 @@ static const struct hwmon_channel_info *sch5627_info[] = { HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_FAULT, HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_FAULT ), + HWMON_CHANNEL_INFO(pwm, + HWMON_PWM_AUTO_CHANNELS_TEMP, + HWMON_PWM_AUTO_CHANNELS_TEMP, + HWMON_PWM_AUTO_CHANNELS_TEMP, + HWMON_PWM_AUTO_CHANNELS_TEMP + ), HWMON_CHANNEL_INFO(in, HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, -- 2.30.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] hwmon: (sch5627) Add pwmX_auto_channels_temp support 2022-02-24 6:12 ` [PATCH v2 2/2] hwmon: (sch5627) Add pwmX_auto_channels_temp support Armin Wolf @ 2022-02-25 2:10 ` Guenter Roeck 0 siblings, 0 replies; 5+ messages in thread From: Guenter Roeck @ 2022-02-25 2:10 UTC (permalink / raw) To: Armin Wolf; +Cc: hdegoede, jdelvare, linux-hwmon, linux-kernel On Thu, Feb 24, 2022 at 07:12:10AM +0100, Armin Wolf wrote: > After doing some research, it seems that Fujitsu's > hardware monitoring solution exports data describing > which temperature sensors affect which fans, similar > to the data in fan_source of the ftsteutates driver. > Writing 0 into these registers forces the fans to > full speed. > Export this data with standard attributes. > > Signed-off-by: Armin Wolf <W_Armin@gmx.de> Applied to hwmon-next. Thanks, Guenter > --- > Documentation/hwmon/sch5627.rst | 4 +++ > drivers/hwmon/sch5627.c | 61 +++++++++++++++++++++++++++++++++ > 2 files changed, 65 insertions(+) > > -- > 2.30.2 > > diff --git a/Documentation/hwmon/sch5627.rst b/Documentation/hwmon/sch5627.rst > index 187682e99114..ecb4fc84d045 100644 > --- a/Documentation/hwmon/sch5627.rst > +++ b/Documentation/hwmon/sch5627.rst > @@ -20,6 +20,10 @@ Description > SMSC SCH5627 Super I/O chips include complete hardware monitoring > capabilities. They can monitor up to 5 voltages, 4 fans and 8 temperatures. > > +In addition, the SCH5627 exports data describing which temperature sensors > +affect the speed of each fan. Setting pwmX_auto_channels_temp to 0 forces > +the corresponding fan to full speed until another value is written. > + > The SMSC SCH5627 hardware monitoring part also contains an integrated > watchdog. In order for this watchdog to function some motherboard specific > initialization most be done by the BIOS, so if the watchdog is not enabled > diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c > index 72c3f6757e34..25fbbd4c9a2b 100644 > --- a/drivers/hwmon/sch5627.c > +++ b/drivers/hwmon/sch5627.c > @@ -52,6 +52,9 @@ static const u16 SCH5627_REG_FAN[SCH5627_NO_FANS] = { > static const u16 SCH5627_REG_FAN_MIN[SCH5627_NO_FANS] = { > 0x62, 0x64, 0x66, 0x68 }; > > +static const u16 SCH5627_REG_PWM_MAP[SCH5627_NO_FANS] = { > + 0xA0, 0xA1, 0xA2, 0xA3 }; > + > static const u16 SCH5627_REG_IN_MSB[SCH5627_NO_IN] = { > 0x22, 0x23, 0x24, 0x25, 0x189 }; > static const u16 SCH5627_REG_IN_LSN[SCH5627_NO_IN] = { > @@ -223,6 +226,9 @@ static int reg_to_rpm(u16 reg) > static umode_t sch5627_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, > int channel) > { > + if (type == hwmon_pwm && attr == hwmon_pwm_auto_channels_temp) > + return 0644; > + > return 0444; > } > > @@ -278,6 +284,23 @@ static int sch5627_read(struct device *dev, enum hwmon_sensor_types type, u32 at > break; > } > break; > + case hwmon_pwm: > + switch (attr) { > + case hwmon_pwm_auto_channels_temp: > + mutex_lock(&data->update_lock); > + ret = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_PWM_MAP[channel]); > + mutex_unlock(&data->update_lock); > + > + if (ret < 0) > + return ret; > + > + *val = ret; > + > + return 0; > + default: > + break; > + } > + break; > case hwmon_in: > ret = sch5627_update_in(data); > if (ret < 0) > @@ -318,10 +341,42 @@ static int sch5627_read_string(struct device *dev, enum hwmon_sensor_types type, > return -EOPNOTSUPP; > } > > +static int sch5627_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, > + long val) > +{ > + struct sch5627_data *data = dev_get_drvdata(dev); > + int ret; > + > + switch (type) { > + case hwmon_pwm: > + switch (attr) { > + case hwmon_pwm_auto_channels_temp: > + /* registers are 8 bit wide */ > + if (val > U8_MAX || val < 0) > + return -EINVAL; > + > + mutex_lock(&data->update_lock); > + ret = sch56xx_write_virtual_reg(data->addr, SCH5627_REG_PWM_MAP[channel], > + val); > + mutex_unlock(&data->update_lock); > + > + return ret; > + default: > + break; > + } > + break; > + default: > + break; > + } > + > + return -EOPNOTSUPP; > +} > + > static const struct hwmon_ops sch5627_ops = { > .is_visible = sch5627_is_visible, > .read = sch5627_read, > .read_string = sch5627_read_string, > + .write = sch5627_write, > }; > > static const struct hwmon_channel_info *sch5627_info[] = { > @@ -342,6 +397,12 @@ static const struct hwmon_channel_info *sch5627_info[] = { > HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_FAULT, > HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_FAULT > ), > + HWMON_CHANNEL_INFO(pwm, > + HWMON_PWM_AUTO_CHANNELS_TEMP, > + HWMON_PWM_AUTO_CHANNELS_TEMP, > + HWMON_PWM_AUTO_CHANNELS_TEMP, > + HWMON_PWM_AUTO_CHANNELS_TEMP > + ), > HWMON_CHANNEL_INFO(in, > HWMON_I_INPUT | HWMON_I_LABEL, > HWMON_I_INPUT | HWMON_I_LABEL, ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-25 2:10 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-02-24 6:12 [PATCH v2 0/2] hwmon: (sch5627) Add pwmX_auto_channels_temp attributes Armin Wolf 2022-02-24 6:12 ` [PATCH v2 1/2] hwmon: (core) Add support for pwm auto channels attribute Armin Wolf 2022-02-25 2:09 ` Guenter Roeck 2022-02-24 6:12 ` [PATCH v2 2/2] hwmon: (sch5627) Add pwmX_auto_channels_temp support Armin Wolf 2022-02-25 2:10 ` Guenter Roeck
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox