From patchwork Thu Jan 5 14:19:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 39609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp324704wrt; Thu, 5 Jan 2023 06:23:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXu9MW5hW/ePXEaNhkta28RheqRRe12c9HNDcslex9URq+TBNERRxDSZ69da/8OPP+p4l/FE X-Received: by 2002:a17:907:6d0c:b0:7c1:652:d109 with SMTP id sa12-20020a1709076d0c00b007c10652d109mr52201084ejc.35.1672928612864; Thu, 05 Jan 2023 06:23:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672928612; cv=none; d=google.com; s=arc-20160816; b=0Q19qZEYLT+24nfc3leAKa2WpsLtXNZRNz7Mp1/UGsY9T8TgOXCSN7cMFczk8PqnFo tfDLXtVV+ZSALv16ZA59LLOdWNttLmZ8njsHiV153JIVvhZknh3bz/kXk/gfyvsPxHJ7 ZS0VPrmipb+AQzdXHdC3OU7oIdW/WVlJi1eizKInl4XeQ3/VP1tYIg3FoMJ2n2RT3qah e9zi/0J8+hxp6Zl593NNUq8lZojCaZx2JfSOPcVDhFKoQLueZNmhyetbunJ04LF/hixg PbktBvIOtjSAGv/V/tgmiIkJqiMw3sj8cSofyGiVi1UQUJbfYEcbThEFi5NtXqKdlXEe ymdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o5Xy93OCUC6MuixC8jC80kz2igaEivv5DpBnbDRR8ao=; b=BzQoD9CtYQCnmNidIusYSneFFGNIgfYJEtXaFqlfUaA/ZnG+xu4qtiCcyKVqeuod9S EOquSuHsb9PHGlff4yQe4J/plgymTqcA0+U+gPeY2iV+c2Z0UKDYcSFPVJ4sQ7Ah0wvg FoTlaQJ5IiCCrXv3udBRCZVDsW3kvRiRP6LLoQRG7y7uQRs7xcsxFGf1kXJNqTF4E+UJ tebzSN38EHjIrXpCdTRMAqKXBtYVQt+g+pTMUbJz03iZ+UNG6gKNh4GwqGTCTMnZzG4c mwwUA5hrB1LtkK4zmvSNrHSpMMP7RO453gz6zqc4Ak3jkqWX7jdpWDCwln2fQdUEKeGs yczA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=dGdcS26g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p20-20020a1709060dd400b007c173f57c88si24119035eji.811.2023.01.05.06.23.08; Thu, 05 Jan 2023 06:23:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=dGdcS26g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232270AbjAEOTp (ORCPT + 99 others); Thu, 5 Jan 2023 09:19:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbjAEOTi (ORCPT ); Thu, 5 Jan 2023 09:19:38 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24ED0D2D7; Thu, 5 Jan 2023 06:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1672928361; bh=RjBrwrzDF0HUQvM108jehXVM85PyLM9sDZAL/eCo9+M=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=dGdcS26gJuZZ2JM/TaqRQOhLZAgS1TuCf57XTUmX8pFkmv/FMWLqCntIG0gqsljr0 +CUM1VAN35giGtNP7GRLyuHqyrPc6dw4M4BI/bVLOj6WafjP1B0cEVcLwaMSdgee7s kK1zZPS0RXIXzrLiNlT1FP/m/ewwaQwLchhQhiMn+y8xsH88MRMw6yPquz8r8oyLHS VOibJwiOoqMw1SuVbHPO91hsToSWUn4lyAlnWL2lErsARXu09wD4ZINVMEJow97ScX t5xId2KmWgwehzO+hdkAvGKOgNzA9XBYeY0F5YVXUfsAyc5Vsal0aMoJxNb5fEA/lt bbhRz12AxklwQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MvK4f-1ovuIq1zWL-00rFUK; Thu, 05 Jan 2023 15:19:21 +0100 From: Armin Wolf To: jdelvare@suse.com, linux@roeck-us.net Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] hwmon: (ftsteutates) Replace fanX_source with pwmX_auto_channels_temp Date: Thu, 5 Jan 2023 15:19:10 +0100 Message-Id: <20230105141911.8040-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230105141911.8040-1-W_Armin@gmx.de> References: <20230105141911.8040-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ru50W+qdfPb9At5rpiAcQ5PdK4qBfkTaf7yQw/v1zIQjyl4cADr amESEKh6KN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tczEOFfzDX7m7wJ8A0hNUXbbCpPbgVsvoGNO1bcaq/6nC/rNzdM5 Pnk9HxJnYLnc+ALv6gbuy1wJpTIo8YNUYaOl3QZioLOWkFOls7WYCzUpNTdFAsZ+MZx688/ym tM/t0LO8bH8TIRl5rnPfqonr4MU= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754192792650311439?= X-GMAIL-MSGID: =?utf-8?q?1754192792650311439?= Replace the nonstandard fanX_source attributes with the standardized pwmX_auto_channels_temp attributes and document the special behaviour associated with those attributes. Tested on a Fujitsu DS3401-B1. Signed-off-by: Armin Wolf --- Documentation/hwmon/ftsteutates.rst | 5 ++ drivers/hwmon/ftsteutates.c | 77 +++++++++++------------------ 2 files changed, 33 insertions(+), 49 deletions(-) -- 2.30.2 diff --git a/Documentation/hwmon/ftsteutates.rst b/Documentation/hwmon/ftsteutates.rst index 198fa8e2819d..b3bfec36661d 100644 --- a/Documentation/hwmon/ftsteutates.rst +++ b/Documentation/hwmon/ftsteutates.rst @@ -22,6 +22,11 @@ enhancements. It can monitor up to 4 voltages, 16 temperatures and 8 fans. It also contains an integrated watchdog which is currently implemented in this driver. +The ``pwmX_auto_channels_temp`` attributes show which temperature sensor +is currently driving which fan channel. This value might dynamically change +during runtime depending on the temperature sensor selected by +the fan control circuit. + The 4 voltages require a board-specific multiplier, since the BMC can only measure voltages up to 3.3V and thus relies on voltage dividers. Consult your motherboard manual for details. diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c index 23dc3a74f84b..0d8ab94250a9 100644 --- a/drivers/hwmon/ftsteutates.c +++ b/drivers/hwmon/ftsteutates.c @@ -6,9 +6,7 @@ * Thilo Cestonaro */ #include -#include #include -#include #include #include #include @@ -16,7 +14,6 @@ #include #include #include -#include #include #define FTS_DEVICE_ID_REG 0x0000 @@ -48,6 +45,8 @@ #define FTS_NO_TEMP_SENSORS 0x10 #define FTS_NO_VOLT_SENSORS 0x04 +#define FTS_FAN_SOURCE_INVALID 0xff + static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; static const struct i2c_device_id fts_id[] = { @@ -187,7 +186,7 @@ static int fts_update_device(struct fts_data *data) data->fan_source[i] = err; } else { data->fan_input[i] = 0; - data->fan_source[i] = 0; + data->fan_source[i] = FTS_FAN_SOURCE_INVALID; } } @@ -339,50 +338,6 @@ static int fts_watchdog_init(struct fts_data *data) return devm_watchdog_register_device(&data->client->dev, &data->wdd); } -static ssize_t fan_source_show(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct fts_data *data = dev_get_drvdata(dev); - int index = to_sensor_dev_attr(devattr)->index; - int err; - - err = fts_update_device(data); - if (err < 0) - return err; - - return sprintf(buf, "%u\n", data->fan_source[index]); -} - -static SENSOR_DEVICE_ATTR_RO(fan1_source, fan_source, 0); -static SENSOR_DEVICE_ATTR_RO(fan2_source, fan_source, 1); -static SENSOR_DEVICE_ATTR_RO(fan3_source, fan_source, 2); -static SENSOR_DEVICE_ATTR_RO(fan4_source, fan_source, 3); -static SENSOR_DEVICE_ATTR_RO(fan5_source, fan_source, 4); -static SENSOR_DEVICE_ATTR_RO(fan6_source, fan_source, 5); -static SENSOR_DEVICE_ATTR_RO(fan7_source, fan_source, 6); -static SENSOR_DEVICE_ATTR_RO(fan8_source, fan_source, 7); - -static struct attribute *fts_fan_attrs[] = { - &sensor_dev_attr_fan1_source.dev_attr.attr, - &sensor_dev_attr_fan2_source.dev_attr.attr, - &sensor_dev_attr_fan3_source.dev_attr.attr, - &sensor_dev_attr_fan4_source.dev_attr.attr, - &sensor_dev_attr_fan5_source.dev_attr.attr, - &sensor_dev_attr_fan6_source.dev_attr.attr, - &sensor_dev_attr_fan7_source.dev_attr.attr, - &sensor_dev_attr_fan8_source.dev_attr.attr, - NULL -}; - -static const struct attribute_group fts_attr_group = { - .attrs = fts_fan_attrs -}; - -static const struct attribute_group *fts_attr_groups[] = { - &fts_attr_group, - NULL -}; - static umode_t fts_is_visible(const void *devdata, enum hwmon_sensor_types type, u32 attr, int channel) { @@ -408,6 +363,7 @@ static umode_t fts_is_visible(const void *devdata, enum hwmon_sensor_types type, break; } break; + case hwmon_pwm: case hwmon_in: return 0444; default: @@ -460,6 +416,19 @@ static int fts_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, break; } break; + case hwmon_pwm: + switch (attr) { + case hwmon_pwm_auto_channels_temp: + if (data->fan_source[channel] == FTS_FAN_SOURCE_INVALID) + *val = 0; + else + *val = BIT(data->fan_source[channel]); + + return 0; + default: + break; + } + break; case hwmon_in: switch (attr) { case hwmon_in_input: @@ -576,6 +545,16 @@ static const struct hwmon_channel_info *fts_info[] = { HWMON_F_INPUT | HWMON_F_ALARM, HWMON_F_INPUT | HWMON_F_ALARM ), + 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_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_INPUT, @@ -672,7 +651,7 @@ static int fts_probe(struct i2c_client *client) revision = err; hwmon_dev = devm_hwmon_device_register_with_info(&client->dev, "ftsteutates", data, - &fts_chip_info, fts_attr_groups); + &fts_chip_info, NULL); if (IS_ERR(hwmon_dev)) return PTR_ERR(hwmon_dev);