From patchwork Fri Jul 7 12:29:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13304865 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 6CD81C0015E for ; Fri, 7 Jul 2023 12:30:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbjGGMav (ORCPT ); Fri, 7 Jul 2023 08:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232151AbjGGMat (ORCPT ); Fri, 7 Jul 2023 08:30:49 -0400 Received: from ipmail06.adl3.internode.on.net (ipmail06.adl3.internode.on.net [150.101.137.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5FDEC1FE6 for ; Fri, 7 Jul 2023 05:30:46 -0700 (PDT) IronPort-SDR: 64a80565_92LQFesX7kbcdCy7AWv5J69SbIpLlyR9Qbpb4NThCiK5fO7 EBpUhTU7ygLLTCzm7bYR/xHeFCEiASrYQnBvEfA== X-SMTP-MATCH: 0 X-IPAS-Result: A2C5AAASBahkjPQc8jxaHQEBAQEJARIBBQUBSYE1BQELAYIyglG2Hw8BDwEBRAQBAYUGAoYVJjcGDgECBAEBAQEDAgMBAQEBAQEDAQEGAQEBAQEBBgQUAQEBAUBFhWgNhgUCAQMnCwENAQE3AQ8ZOFcGARKCfoJdqWMzgQGCCQEBBoJlrjGBXwmBQgGMH4EZgzt6Qj+BToEVgTyBPm+LBo4ghV0HMo0UgSdvgR43Z3oCCQIRZ4EICF+Bbj4CDVQLC2OBHIEqgSQCAhE6FFNfGR0DBwOBBRAvBwQyJgYJGC8lBlEHFxYk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vQFQac1K2YXwLUE/iM0lgvShcgUlbg== X-IronPort-Anti-Spam-Filtered: true Received: from 60-242-28-244.static.tpgi.com.au (HELO bits.crawford.emu.id.au) ([60.242.28.244]) by ipmail06.adl3.internode.on.net with ESMTP; 07 Jul 2023 22:00:29 +0930 Received: from agc.crawford.emu.id.au (agc.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc07]) (authenticated bits=0) by bits.crawford.emu.id.au (8.17.1/8.17.1) with ESMTPSA id 367CU7bK2026771 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 7 Jul 2023 22:30:21 +1000 Authentication-Results: bits.crawford.emu.id.au; arc=none smtp.remote-ip=fdd2:7aad:d478:1::cb10:cc07 DKIM-Filter: OpenDKIM Filter v2.11.0 bits.crawford.emu.id.au 367CU7bK2026771 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1688733022; bh=vO9iS60rDSU0yqJU6pRxERHjUfpLe5PC2SHm5W8r7tU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UA7aE1mskWUWHjZNGEl1KBmy+LMF5ihPyc6krNX9sIaFvqb1ODrA7i3CUAo56E3vG YhIv6fDrBBjquvWauc1tFT48kIlMS12HUsfQ5u84avY4LdKvQ8X/iLCLlScn5IunH8 G82OO5Ct1Cy5NOYFmNr1SpWEjbOihH8ll69HJXE2LM8UzlujQi9VpTrB/Pp1PPf5VM qU2PVZJfwVSBPIwEdLmeRitt3aCi72iHMQYH2l0zfS4kLV0XU2cxnB8PPSVIquadXe nf+j5E6F9wfwQBMI1fDLo/b0l0nuB9e6DuAXX14v4Jq5PhYFYJUBPpYwTTdTxFOpFI gnLlWobv//5Ng== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v2 1/3] hwmon: (it87) Split temperature sensor detection to separate function Date: Fri, 7 Jul 2023 22:29:50 +1000 Message-ID: <20230707123005.956415-2-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230707123005.956415-1-frank@crawford.emu.id.au> References: <20230707123005.956415-1-frank@crawford.emu.id.au> MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (bits.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc01]); Fri, 07 Jul 2023 22:30:22 +1000 (AEST) X-Virus-Scanned: clamav-milter 1.0.1 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The temperature sensor type will need to be used in multiple places, so split it out into its own function. Signed-off-by: Frank Crawford --- v2: * Split single patch into multi-patch set following review. --- drivers/hwmon/it87.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 5deff5e5f693..7a1224ddc8b1 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -1159,28 +1159,45 @@ static SENSOR_DEVICE_ATTR_2(temp4_input, S_IRUGO, show_temp, NULL, 3, 0); static SENSOR_DEVICE_ATTR_2(temp5_input, S_IRUGO, show_temp, NULL, 4, 0); static SENSOR_DEVICE_ATTR_2(temp6_input, S_IRUGO, show_temp, NULL, 5, 0); +static int get_temp_type(struct it87_data *data, int index) +{ + /* + * 2 is deprecated; + * 3 = thermal diode; + * 4 = thermistor; + * 5 = AMDTSI; + * 6 = Intel PECI; + * 0 = disabled + */ + u8 reg, extra; + int type = 0; + + reg = data->sensor; /* In case value is updated while used */ + extra = data->extra; + + if ((has_temp_peci(data, index) && (reg >> 6 == index + 1)) || + (has_temp_old_peci(data, index) && (extra & 0x80))) + type = 6; /* Intel PECI */ + else if (reg & BIT(index)) + type = 3; /* thermal diode */ + else if (reg & BIT(index + 3)) + type = 4; /* thermistor */ + + return type; +} + static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); - int nr = sensor_attr->index; struct it87_data *data = it87_update_device(dev); - u8 reg, extra; + int type; if (IS_ERR(data)) return PTR_ERR(data); - reg = data->sensor; /* In case value is updated while used */ - extra = data->extra; - - if ((has_temp_peci(data, nr) && (reg >> 6 == nr + 1)) || - (has_temp_old_peci(data, nr) && (extra & 0x80))) - return sprintf(buf, "6\n"); /* Intel PECI */ - if (reg & (1 << nr)) - return sprintf(buf, "3\n"); /* thermal diode */ - if (reg & (8 << nr)) - return sprintf(buf, "4\n"); /* thermistor */ - return sprintf(buf, "0\n"); /* disabled */ + type = get_temp_type(data, sensor_attr->index); + return sprintf(buf, "%d\n", type); } static ssize_t set_temp_type(struct device *dev, struct device_attribute *attr, From patchwork Fri Jul 7 12:29:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13304863 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 D15C0EB64D9 for ; Fri, 7 Jul 2023 12:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231627AbjGGMat (ORCPT ); Fri, 7 Jul 2023 08:30:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbjGGMas (ORCPT ); Fri, 7 Jul 2023 08:30:48 -0400 Received: from ipmail06.adl3.internode.on.net (ipmail06.adl3.internode.on.net [150.101.137.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 724CA2110 for ; Fri, 7 Jul 2023 05:30:46 -0700 (PDT) IronPort-S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LU5Mj0a giYOSFmQW/4UC9feBrx3MX7U03NTqYSM9P+PXoy81nSdy6yA5iaDaB88jt7pU17YSbn0PrtP OR2Fqcc5fRt6soBqT4v28GG IronPort-HdrOrdr: A9a23:B9/QNa3HsdDvE1IvbZtp/AqjBGgkLtp133Aq2lEZdPU0SKalfg 6V/cjzsiWE8Qr4Ohkb9OxoXZPtfZqyz+8X3WB8B9iftUzdyQ+VxeJZnO3fKl/bak/DH4dmvM 8KT0E9MqyWMbEQt6bHCWeDferJT7S8gdiVbJ/lvhJQpBlRGt1dBhlCe3um+5JNNXJ77UtQLu vn2vZ6 X-Talos-CUID: 9a23:SOVwPWkM+y7P2tXrBloUPDePu4/XOSPZ41H9LRK6MFZSUbCsFUDM+rtAyfM7zg== X-Talos-MUID: 9a23:0CAIcg0MmqS8PfGgo1OOdWHGgzUj5IuyBlo3ko8/gdSebzVfH2adqAWqTdpy X-IronPort-Anti-Spam-Filtered: true Received: from 60-242-28-244.static.tpgi.com.au (HELO bits.crawford.emu.id.au) ([60.242.28.244]) by ipmail06.adl3.internode.on.net with ESMTP; 07 Jul 2023 22:00:29 +0930 Received: from agc.crawford.emu.id.au (agc.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc07]) (authenticated bits=0) by bits.crawford.emu.id.au (8.17.1/8.17.1) with ESMTPSA id 367CU7bL2026771 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 7 Jul 2023 22:30:25 +1000 Authentication-Results: bits.crawford.emu.id.au; arc=none smtp.remote-ip=fdd2:7aad:d478:1::cb10:cc07 DKIM-Filter: OpenDKIM Filter v2.11.0 bits.crawford.emu.id.au 367CU7bL2026771 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1688733025; bh=KaTcNhtT+ISNshmuM37/JCO1IUVbv9wjlBS2DrUHwH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6nwapHxfnyyDcH3r0nzTBVNpqPIuWtD/C/IFMBAcbZgmGkgelDJij5EZJRRngH4E g0NE52EkEBIpMQ3Mo4PdqAWhY7aiUkg6S8tE3ct/XOxyMmbgnrutEMd3mi6wzXcO0+ ESj9w+MN7h1B/n1a07VEqAItEizG9rR/CnogCHmIU1mguUZxkVXpfS3qG5Nyl+h6BH 2fSSUkSB/K/bjS7wxPeHbQYXA/F2DoEtqY4cG/+Jy0Ln3SAQndu8W/vTXFzAC7L78z jJZrW94lkqS+ys0BbDQ5CCOPe2aDZzV1yU3+11b0aJ7Ft3isF6QJB5gqIdStkhlImN TiAgBccp6yGGw== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v2 2/3] hwmon: (it87) Improve temperature reporting support Date: Fri, 7 Jul 2023 22:29:51 +1000 Message-ID: <20230707123005.956415-3-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230707123005.956415-1-frank@crawford.emu.id.au> References: <20230707123005.956415-1-frank@crawford.emu.id.au> MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (bits.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc01]); Fri, 07 Jul 2023 22:30:25 +1000 (AEST) X-Virus-Scanned: clamav-milter 1.0.1 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add test if thermistor sensor type attribute should be visible, i.e. test if the attribute is defined. Signed-off-by: Frank Crawford --- v2: * Split single patch into multi-patch set following review. --- drivers/hwmon/it87.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 7a1224ddc8b1..fb62f2a7017a 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -2330,6 +2330,14 @@ static umode_t it87_temp_is_visible(struct kobject *kobj, if (!(data->has_temp & BIT(i))) return 0; + if (a == 3) { + int type = get_temp_type(data, i); + + if (type == 0) + return 0; + return attr->mode; + } + if (a == 5 && !has_temp_offset(data)) return 0; From patchwork Fri Jul 7 12:29:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13304864 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 5F584EB64DA for ; Fri, 7 Jul 2023 12:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbjGGMav (ORCPT ); Fri, 7 Jul 2023 08:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbjGGMau (ORCPT ); Fri, 7 Jul 2023 08:30:50 -0400 Received: from ipmail06.adl3.internode.on.net (ipmail06.adl3.internode.on.net [150.101.137.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5FBDE19BD for ; Fri, 7 Jul 2023 05:30:49 -0700 (PDT) IronPort-SDR: 64a80568_xpBb06rxlStmKCUdsntSLoj8Lz1cEsV/kM7PO8vIrAvnz98 tJM3aAChdtYQbkFw54/8WSl6tVsm7SCJK+ibT5w== X-SMTP-MATCH: 0 X-IPAS-Result: A2AKAwASBahkjPQc8jxaHQEBAQEJARIBBQUBSYFGgjOCUbYfDwEPAQFEBAEBhQYChhUmOBMBAgQBAQEBAwIDAQEBAQEBAwEBBgEBAQEBAQYEFAEBAQFARYVoDYYFAgEDJwsBDQEBNwEPGThXBgESgn6CXaljM4EBggkBAQaCZa4xgV8JgUKMIIEZgzt6Qj+BToEVgTyBPm+LBo4ghV0HMo0UgSdvgR43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rxfA8Y5XFeNlivsJl6mJ1xsTJm4WQKp0fYx X-Talos-MUID: 9a23:1EQHNQt9V9arPus8zM2numh9D5kx5aKXU11TjoghsuebHGtQNGLI X-IronPort-Anti-Spam-Filtered: true Received: from 60-242-28-244.static.tpgi.com.au (HELO bits.crawford.emu.id.au) ([60.242.28.244]) by ipmail06.adl3.internode.on.net with ESMTP; 07 Jul 2023 22:00:32 +0930 Received: from agc.crawford.emu.id.au (agc.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc07]) (authenticated bits=0) by bits.crawford.emu.id.au (8.17.1/8.17.1) with ESMTPSA id 367CU7bM2026771 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 7 Jul 2023 22:30:28 +1000 Authentication-Results: bits.crawford.emu.id.au; arc=none smtp.remote-ip=fdd2:7aad:d478:1::cb10:cc07 DKIM-Filter: OpenDKIM Filter v2.11.0 bits.crawford.emu.id.au 367CU7bM2026771 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1688733028; bh=mKCGVZ5x8xE6L93ndv2Q/Q1AZxKevto8TXRk8sy6cyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I0l9H3yXf6LZWGo8h6RCx5mG4+AhH6L6xsFBlK//Ps8dkJlS7fT5aWtydzJO02Wp9 PjOJY1SYnrgH/9+4Ei0fhWzDKIOtGE24HtWnGoyP1AUiVehgobSkXkdhwDL27oV/gY bP42wDnXnzoWjZpAo2RLDdX4XfFGsssN+CP3xMJpT+rvyLKV0OZMus/YxIdPL+xH0Y RUd7xOVa/33V7PF73CHLYAzERFEmqxWfVapMz8SbP4ppBW21+ix5dv27efVEjbUTzN cwmp4w2FV7Qkagu0EtmcNb2CCBez4n7GnGM7o0IEGKxcPsmrlL4JPyhhxxtwrYvNOB Bo/O1w89qIYoA== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v2 3/3] hwmon: (it87) Add support to detect sensor type AMDTSI Date: Fri, 7 Jul 2023 22:29:52 +1000 Message-ID: <20230707123005.956415-4-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230707123005.956415-1-frank@crawford.emu.id.au> References: <20230707123005.956415-1-frank@crawford.emu.id.au> MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (bits.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc01]); Fri, 07 Jul 2023 22:30:28 +1000 (AEST) X-Virus-Scanned: clamav-milter 1.0.1 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add test for sensor type AMDTSI which is available on certain recent chipsets. Signed-off-by: Frank Crawford --- v2: * Split single patch into multi-patch set following review. --- drivers/hwmon/it87.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index fb62f2a7017a..ba75f33301ce 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -221,6 +221,10 @@ static bool fix_pwm_polarity; * Super-I/O configuration space. */ #define IT87_REG_VID 0x0a + +/* Interface Selection register on other chips */ +#define IT87_REG_IFSEL 0x0a + /* * The IT8705F and IT8712F earlier than revision 0x08 use register 0x0b * for fan divisors. Later IT8712F revisions must use 16-bit tachometer @@ -1170,14 +1174,37 @@ static int get_temp_type(struct it87_data *data, int index) * 0 = disabled */ u8 reg, extra; - int type = 0; + int ttype, type = 0; + + /* Detect PECI vs. AMDTSI */ + ttype = 6; + if ((has_temp_peci(data, index)) || data->type == it8721 || + data->type == it8720) { + extra = it87_read_value(data, IT87_REG_IFSEL); + if ((extra & 0x70) == 0x40) + ttype = 5; + } - reg = data->sensor; /* In case value is updated while used */ - extra = data->extra; + reg = it87_read_value(data, IT87_REG_TEMP_ENABLE); + + /* Per chip special detection */ + switch (data->type) { + case it8622: + if (!(reg & 0xc0) && index == 3) + type = ttype; + break; + default: + break; + } + + if (type || index >= 3) + return type; + + extra = it87_read_value(data, IT87_REG_TEMP_EXTRA); if ((has_temp_peci(data, index) && (reg >> 6 == index + 1)) || (has_temp_old_peci(data, index) && (extra & 0x80))) - type = 6; /* Intel PECI */ + type = ttype; /* Intel PECI or AMDTSI */ else if (reg & BIT(index)) type = 3; /* thermal diode */ else if (reg & BIT(index + 3))