From patchwork Thu Feb 24 06:12:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12757897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F95AC433FE for ; Thu, 24 Feb 2022 06:12:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbiBXGNB (ORCPT ); Thu, 24 Feb 2022 01:13:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbiBXGNA (ORCPT ); Thu, 24 Feb 2022 01:13:00 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B005E23401D; Wed, 23 Feb 2022 22:12:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1645683133; bh=Mb3YF6LNh1Tn63N2V2L8UfDPfSHx3GY0TsdhMMwZ8Uc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=hDCiTKt7CkBj/c6pcvwp8/xT3uC98wT9Dp5GoHFJGhtrOQq+gTvMORi7Y+/AelgY6 Tpqm8esAYTqg6MTTNkw/8jHAqdPkusZZgMIfZrfqI4f+ePVdnOHTuwI/H3IuIjV6RD 513ghLLiOhny3WwcQiMwL+kZt+mKbpTCQZay4eAs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MRTRH-1nZ2081xpN-00NPNf; Thu, 24 Feb 2022 07:12:13 +0100 From: Armin Wolf To: hdegoede@redhat.com Cc: jdelvare@suse.com, linux@roeck-us.net, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] hwmon: (core) Add support for pwm auto channels attribute Date: Thu, 24 Feb 2022 07:12:09 +0100 Message-Id: <20220224061210.16452-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220224061210.16452-1-W_Armin@gmx.de> References: <20220224061210.16452-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:WcR05tWVrGreQVqALpf9O/Z9KH/Jv8dfAsNh6Mnr60OjMPyUN70 6il9QpTHTHgCtVQ2RuVBExaHgXGiIkd6q6OYU+5OvKtvO7uO4/wPboprkojedXhHl2VC4kg 9ZoquNvz+1ww2ZnabqFbptEHE9F8aTIc544Il6vJgRN6G5CwEKDkLLUiWwzowfEAnHCRzZc 67HEPsVt880Z/GoSH/7ag== X-UI-Out-Filterresults: notjunk:1;V03:K0:DGm0KxSSDQM=:hcgASVxeH33O/vzeK/HAuD xRzbltXi7YWGdscKBPAVv8sHV3YmbxqT2wl3iszn0gvLZpFZ4PeTTLKcGbmVibk7Bv3BesLcy zb/ngu0IyiTT2RUk07PajgrI2apfUnCh3O0cAMaMLqDwVQ4Tj9MgefibpsZjAnZQtsmoWvoZw mzHp+OWju1IhrR3HUmFwJZvG/8PZGjDlFzEQpGYY57Bh/UWqRHdR+W581XMBPwBDumuOpD67K CrdG8Jx+PR6nEXEw4ShaAdKYsuYZkT40Lxn2b05E19y5oVx4ymWU0jQ1EyJc0H8NCybayVn9V xyRoun778EmFmrqitz1SrQhHdHyZSnhFMY1B/5N1CReHMtLshD/ID3s0BA9cRFAl58z1rr9UK TMqoOKZSF1fTHGskx/OR+HYGZLMVun55TOZdPj4F11jJ7pq8xXhB1eGMEt0qFT028Y7LD0qYY /jwJiibCYavWc0Pl9PPGFLnSk0OVDo9YE/BrZp3fNzt4qYJUWJFAGeRkC3zN2GaaAynoAmSpP SNxwA1/DSpj48SDv8G8NRz92SNVqG2Uhy/KXqAwwRTiefW4K84qmuJBRxZSRFjU1dU64yIF0I 4Dro4t7aIqIvIl1d0FU2/9+/CEcN4JLdr7pH9TzzowZwtxsxewvqYOSzy2Wm4ofVnun6e7Ssj jV1S5Uqmmw3WYMfzMbehTALVE9t+LnfTr9xE6i4hT93Jk9wnXvAVhe9vF+Q3S6xG41Pp1mNIK GdRyWPanCJHXmxAC6FMNk55Renewc58o2r9JLFUc9Q0XnSbd+pP2ispuiwMrNQrIFPyGtkdTW XcJoKH6kal60Bfu8JVLXGXiB/vh49yd1SIUUYOkTYGB1Ix67KUy4Y7b+ohr1OqfM+DOsFnllQ ybdjEgSr5Rz23irmUmIW0NzjWOCObPmyTlYyLQAHpXujdbRsNUmAwmigwo3sYqY5wpjsx2GEv ah45vs2uWQ1KU5W4+PO+AQz2Wvi/w+oTSKyfSfgdrnKZ2GkjHoN8Tvs2hkq3ARCK77G2rIEeJ UMNr3wmynANBwdT9rdJvUFCzHSwEDTpHg1BpgsYtLWKLJiIeAO4IdMnwnn1cuXzRbJpB3BVHv otKPKM20zfv3II= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org 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 --- 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, From patchwork Thu Feb 24 06:12:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12757898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4ECF2C433FE for ; Thu, 24 Feb 2022 06:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231127AbiBXGND (ORCPT ); Thu, 24 Feb 2022 01:13:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbiBXGNB (ORCPT ); Thu, 24 Feb 2022 01:13:01 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5180423400B; Wed, 23 Feb 2022 22:12:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1645683134; bh=z3PgjpSeI45p8e/Kj/ULmEws1DrF6f9e5OhfTUmeyrs=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=LArIAWTPOrSw33/npDGbYQYcSBa1u6FQnZLZZPz5k/Erv8E2uEmjPQx9FGmOc6QF3 BlVR2cIIrwYNZxMeKHRPZqBRzzINkV73dQ/uBmpcqT4NW41Th7pq7zWTA8xcqzhCcQ eEG8JKaXwFqD4oXSr3GGpffNZw6+xdhVH+P+heEI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MlNtP-1o63Pf36qL-00lmSA; Thu, 24 Feb 2022 07:12:14 +0100 From: Armin Wolf To: hdegoede@redhat.com Cc: jdelvare@suse.com, linux@roeck-us.net, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] hwmon: (sch5627) Add pwmX_auto_channels_temp support Date: Thu, 24 Feb 2022 07:12:10 +0100 Message-Id: <20220224061210.16452-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220224061210.16452-1-W_Armin@gmx.de> References: <20220224061210.16452-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:6LzVNnlmx1VGAgyWfxK4fWce312xtxahIHUVXlu4cZNAV/3H0ZO BCFSfpp61O621PjFeFqR5LGPvg4J++3E41dq+6qpcWVSJ1R45SoZrp8sA55LUYbtDDVHWLv XN+AdfcpbccRf1xHPrp3RVoR3wFg0Lwd2TNsxM/cotVdriFDtsbMiUODzegABlhiDIbyyA4 aNz0+l4rx5LnVnOZ0vhHQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:b7sw0nFPI0Q=:LTs5LGlmNBU7Gkp47C0ttd TuQGI5/CuGtGErgqXll2u9y+j2N4u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/tpA= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org 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 --- 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,