From patchwork Sun Apr 16 04:25:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13212702 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 2D2E1C77B73 for ; Sun, 16 Apr 2023 04:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229956AbjDPEZl (ORCPT ); Sun, 16 Apr 2023 00:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjDPEZj (ORCPT ); Sun, 16 Apr 2023 00:25:39 -0400 Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [150.101.137.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3EE2C2738 for ; Sat, 15 Apr 2023 21:25:38 -0700 (PDT) IronPort-SDR: 643b78b9_xGcjUe+ijjAolYOlUiOEJHtZSFneNSEBGXyZV3gPMXczuLZ VokQ0zOt/qpIawAo1g3vnXj8FvY4vKCpGu5rPnQ== X-SMTP-MATCH: 0 X-IPAS-Result: A2C6AACkdztkjPQc8jxaHQEBAQEJARIBBQUBSYE1BQELAYItgk+WAp9dDwEPAQFEBAEBhQYChTwmNwYOAQIEAQEBAQMCAwEBAQEBAQMBAQYBAQEBAQEGBBQBAQEBQEWFaA2GBAIBAycLAQ0BATcBDxk4VwYBEoJ+gl2vBDOBAYIIAQEGgmKaaoFeCYFBAYt0gRaDNnpCP4FOgRWBPIE+b4sGmlaBNHEFgSAOSnKBBAIJAhFrgRAIaoF5QAINZAsOb4FJgU6BXAQCFEQOVAMJAwcFSUADCxgNFjoTLDUUIFxsLRISBQMLF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+TJ2kDk6UK4pa4OxdJbmI= 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 ipmail03.adl2.internode.on.net with ESMTP; 16 Apr 2023 13:55:30 +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 33G4PCj23415316 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 16 Apr 2023 14:25: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 33G4PCj23415316 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1681619125; bh=6XICiCPdXs6FtG/wrztpNl5BiWU75gOuSnpQhcWafkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ei9V3gkrrBLAqBDQdxfoEew0kSM2QGQXVkMxFzezF7B8FWg+Iv1kP8t7xnZijMH9i qPiDzhcyad1r4ZZuWD3wnycxEM8IrnFBlfzhBhDVB9E98VxJK/Krpzc5bkE0WWu4sc 8u/tqEM3l9x4wk/1/mgTu/rl0njTIC3kPggMAdIEZv96AxH5u2Qmg6vZvqiUxehEJY pqJahNydMgY5H4fNHGrfy0czwovHExsq3BSs8reRnEJMRnsUcavBZozH9/VjzaIVTv hBG70bQrCIaoxrsk0ed3I2I/AajZbuJW1JUXzzHXiaSIf1kvd88tejutDeyY3pqaIj SSpH8X1oX/vCg== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v2 1/4] hwmon: (it87) Disable SMBus access for environmental controller registers. Date: Sun, 16 Apr 2023 14:25:07 +1000 Message-Id: <20230416042510.1929077-2-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230416042510.1929077-1-frank@crawford.emu.id.au> References: <20230416042510.1929077-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]); Sun, 16 Apr 2023 14:25:25 +1000 (AEST) X-Virus-Scanned: clamav-milter 0.103.8 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add functions to disable and re-enable access by the SMBus for specific chips. Signed-off-by: Frank Crawford --- v2: * No change. --- drivers/hwmon/it87.c | 58 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index f774a0732a7c..b74dd861f0fe 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -162,8 +162,11 @@ static inline void superio_exit(int ioreg, bool noexit) #define IT8623E_DEVID 0x8623 #define IT8628E_DEVID 0x8628 #define IT87952E_DEVID 0x8695 -#define IT87_ACT_REG 0x30 -#define IT87_BASE_REG 0x60 + +/* Logical device 4 (Environmental Monitor) registers */ +#define IT87_ACT_REG 0x30 +#define IT87_BASE_REG 0x60 +#define IT87_SPECIAL_CFG_REG 0xf3 /* special configuration register */ /* Logical device 7 registers (IT8712F and later) */ #define IT87_SIO_GPIO1_REG 0x25 @@ -284,6 +287,8 @@ struct it87_devices { u32 features; u8 peci_mask; u8 old_peci_mask; + u8 smbus_bitmap; /* SMBus enable bits in extra config register */ + u8 ec_special_config; }; #define FEAT_12MV_ADC BIT(0) @@ -533,6 +538,8 @@ struct it87_sio_data { u8 skip_fan; u8 skip_pwm; u8 skip_temp; + u8 smbus_bitmap; + u8 ec_special_config; }; /* @@ -547,6 +554,9 @@ struct it87_data { u8 peci_mask; u8 old_peci_mask; + u8 smbus_bitmap; /* !=0 if SMBus needs to be disabled */ + u8 ec_special_config; /* EC special config register restore value */ + unsigned short addr; const char *name; struct mutex update_lock; @@ -701,6 +711,39 @@ static const unsigned int pwm_freq[8] = { 750000, }; +static int smbus_disable(struct it87_data *data) +{ + int err; + + if (data->smbus_bitmap) { + err = superio_enter(data->sioaddr); + if (err) + return err; + superio_select(data->sioaddr, PME); + superio_outb(data->sioaddr, IT87_SPECIAL_CFG_REG, + data->ec_special_config & ~data->smbus_bitmap); + superio_exit(data->sioaddr, has_conf_noexit(data)); + } + return 0; +} + +static int smbus_enable(struct it87_data *data) +{ + int err; + + if (data->smbus_bitmap) { + err = superio_enter(data->sioaddr); + if (err) + return err; + + superio_select(data->sioaddr, PME); + superio_outb(data->sioaddr, IT87_SPECIAL_CFG_REG, + data->ec_special_config); + superio_exit(data->sioaddr, has_conf_noexit(data)); + } + return 0; +} + /* * Must be called with data->update_lock held, except during initialization. * We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, @@ -2859,6 +2902,15 @@ static int __init it87_find(int sioaddr, unsigned short *address, if (dmi_data) sio_data->skip_pwm |= dmi_data->skip_pwm; + if (config->smbus_bitmap) { + u8 reg; + + superio_select(sioaddr, PME); + reg = superio_inb(sioaddr, IT87_SPECIAL_CFG_REG); + sio_data->ec_special_config = reg; + sio_data->smbus_bitmap = reg & config->smbus_bitmap; + } + exit: superio_exit(sioaddr, config ? has_conf_noexit(config) : false); return err; @@ -3094,6 +3146,8 @@ static int it87_probe(struct platform_device *pdev) data->addr = res->start; data->sioaddr = sio_data->sioaddr; data->type = sio_data->type; + data->smbus_bitmap = sio_data->smbus_bitmap; + data->ec_special_config = sio_data->ec_special_config; data->features = it87_devices[sio_data->type].features; data->peci_mask = it87_devices[sio_data->type].peci_mask; data->old_peci_mask = it87_devices[sio_data->type].old_peci_mask; From patchwork Sun Apr 16 04:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13212703 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 2034EC77B76 for ; Sun, 16 Apr 2023 04:25:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229462AbjDPEZm (ORCPT ); Sun, 16 Apr 2023 00:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbjDPEZk (ORCPT ); Sun, 16 Apr 2023 00:25:40 -0400 Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [150.101.137.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 73D832D4C for ; Sat, 15 Apr 2023 21:25:38 -0700 (PDT) IronPort-SDR: 643b78bc_346VmSdYT6N+7JQEOH1quHds0GXE6/TOou35kH2FZ4+rfAL WQglDyjH97FtK57y6FX0ReI3Pkeaudw4Cc8DL+w== X-SMTP-MATCH: 0 X-IPAS-Result: A2CwAACkdztkjPQc8jxaGwEBAQEBAQEBBQEBARIBAQEDAwEBAUmBRoIugk+uCIdXDwEPAQFEBAEBhQYChTwmOBMBAgQBAQEBAwIDAQEBAQEBAwEBBgEBAQEBAQYEFAEBAQFARYVoDYYEAgEDJwsBDQEBNwEPGThXBgESgn6CXa8EM4EBgggBAQaCYppqgV4JgUGLdYEWgzZ6Qj+BToEVgTyCLYEPiXeaVoE0doEgDkpygQQCCQIRa4EQCGp+e0ACDWQLDm+BSYMqBAIURA5UAwkDBwVJQAMLGA0WOhMsNRQgXGwtEhIFAwsVKkcECDgGGzQRAggPEg8sRAxCNzMTBlwBKQgDDhEDTkIZbASCCgYBJiSfGQd7E5VVA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cdxZ5bkNCUWnbYJNomC2ZkUSzGGPGZnU9g42I8oR0TyICqT3xqKIGCPIvJ9HeTAqxKEO pY/N/BxWASb/wfQiDIiXIonAaJ+xdwt7/o8IoLbH3YM6eajn2A4oaDr13bMgUEwSI9Tiuc7E ITacgyCHkG2hXd5n2zsrtFOClGnYOsrNRHN4+SozNonT54zkvlgUUUX4IuGu3+4NAhG/RXNs jjTOI7Q7ehpkrp3k6XWT65sOgSTKPHIbtquzjydidp0UI7wAZ/8jD9N8ljDFCZKDIQVQOVyx Oisssao/Ubrv4QWcmH+mruDHKxnvve3DftlGZ/zJklngCK9YdLd0yYC30uaKpV5tsxXyef6Z gm/aeq2LcU0XfUEzlJrSiFuKTQvIIWpUbXFugWGsOWqCDIR9SflPeGX3yblQk8DfxBZJqCkL BH/vsifw+xxraNONUciPO5nCZopG23Tc/IqWPOpvAbJE1TypE2Jv4bjsh8S6TvrLH2gO+Si6 LLnQinOTjiDiJvq/vp47bMr5gY2CUxji9YeZkgeot56qw6rBV48cNgyD880NYF2oAfTirfIP T3DVT53Q2G1FzFJag7179nfTx+STL5GcMvwIjsyuViYcWGqDYeHG6Fs7Tpk/2wwQDb40eW7M psLzxUc5PRqLk1BHo7/PsCGvNo= IronPort-HdrOrdr: A9a23:x3NlJatXpRn6UcqQI1lX3kM/7skDrNV00zEX/kB9WHVpm6yj/f xGUs576faSskdpZJlD8ersBEDkex/hHPFOkOos1NuZMzUO/VHYSL2KjrGSpQEIZReOlNK1vJ 0IG8ND4Z/LfD9HZK3BgDVQfexP/DEJnZrY/ds2t00dKD2Cc5sQkzuRFDzrb3GemzM2fqbQxf Knl7B6mwY= X-Talos-CUID: 9a23:5WWwS2/n/tYcd0Qh776Vv1c7Fcd1SFKH9lzzHGS4BmUzQeC6Y0DFrQ== X-Talos-MUID: 9a23:tAAvdwk5PcSgWCxwzq3gdnpuHedSxvSoJXxOroUUuMeFKHJ/JG202WE= 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 ipmail03.adl2.internode.on.net with ESMTP; 16 Apr 2023 13:55:33 +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 33G4PCj33415316 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 16 Apr 2023 14:25: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 33G4PCj33415316 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1681619128; bh=JbYOTgMbk5IKKqjYsYlQvml8l3PzjdpEW1kEeeNYd3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBXOJOYn84PmU0cSv3FzUQbN/GARSr6OUDecwDKFKY4b6i6MP0RwIthqCXswxsufc XSNk/6hUtxV0jJwWa+BmiWuEuO5PY0muOiRR6mWbRbELIzZstNVGveI6Q9bdsjIfg9 kaXjkQNkYj7Ah1nkM57m/wWDebBupUz2egHjnKvAEca7XOY+ze5XxJ3Re2CspM5/3Y aJSZszFPBXREVEq75exmY96rl7g8XVn/0aUdqoX4Z4ryAOvIs9fUrEQq3huekjLr2p JAVHqCUAR1m3Xnm0UE6L6jaB5b1+tXHtkdhLmIvKG79XgJypkI3VLzZVH75PzDDRpm 51Q+Ww5UeePSA== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v2 2/4] hwmon: (it87) Test for error in it87_update_device Date: Sun, 16 Apr 2023 14:25:08 +1000 Message-Id: <20230416042510.1929077-3-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230416042510.1929077-1-frank@crawford.emu.id.au> References: <20230416042510.1929077-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]); Sun, 16 Apr 2023 14:25:28 +1000 (AEST) X-Virus-Scanned: clamav-milter 0.103.8 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Handle errors from it87_update_device(), which currently only occurs if SMBus access locking fails. Signed-off-by: Frank Crawford --- v2: * Reorder patches within patchset. --- drivers/hwmon/it87.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index b74dd861f0fe..920fb9b6b2e2 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -942,6 +942,9 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, int index = sattr->index; int nr = sattr->nr; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", in_from_reg(data, nr, data->in[nr][index])); } @@ -1030,6 +1033,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, int index = sattr->index; struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr][index])); } @@ -1107,6 +1113,9 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, u8 reg = data->sensor; /* In case value is updated while used */ u8 extra = data->extra; + if (IS_ERR(data)) + return PTR_ERR(data); + 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 */ @@ -1197,6 +1206,9 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, int speed; struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + speed = has_16bit_fans(data) ? FAN16_FROM_REG(data->fan[nr][index]) : FAN_FROM_REG(data->fan[nr][index], @@ -1211,6 +1223,9 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%lu\n", DIV_FROM_REG(data->fan_div[nr])); } @@ -1221,6 +1236,9 @@ static ssize_t show_pwm_enable(struct device *dev, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_mode(data, nr)); } @@ -1231,6 +1249,9 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_from_reg(data, data->pwm_duty[nr])); } @@ -1244,6 +1265,9 @@ static ssize_t show_pwm_freq(struct device *dev, struct device_attribute *attr, unsigned int freq; int index; + if (IS_ERR(data)) + return PTR_ERR(data); + if (has_pwm_freq2(data) && nr == 1) index = (data->extra >> 4) & 0x07; else @@ -1531,6 +1555,9 @@ static ssize_t show_pwm_temp_map(struct device *dev, int nr = sensor_attr->index; int map; + if (IS_ERR(data)) + return PTR_ERR(data); + map = data->pwm_temp_map[nr]; if (map >= 3) map = 0; /* Should never happen */ @@ -1595,6 +1622,9 @@ static ssize_t show_auto_pwm(struct device *dev, struct device_attribute *attr, int nr = sensor_attr->nr; int point = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_from_reg(data, data->auto_pwm[nr][point])); } @@ -1631,6 +1661,9 @@ static ssize_t show_auto_pwm_slope(struct device *dev, struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", data->auto_pwm[nr][1] & 0x7f); } @@ -1664,6 +1697,9 @@ static ssize_t show_auto_temp(struct device *dev, struct device_attribute *attr, int point = sensor_attr->index; int reg; + if (IS_ERR(data)) + return PTR_ERR(data); + if (has_old_autopwm(data) || point) reg = data->auto_temp[nr][point]; else @@ -1884,6 +1920,9 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, { struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", data->alarms); } static DEVICE_ATTR_RO(alarms); @@ -1894,6 +1933,9 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int bitnr = to_sensor_dev_attr(attr)->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); } @@ -1949,6 +1991,9 @@ static ssize_t show_beep(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int bitnr = to_sensor_dev_attr(attr)->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", (data->beeps >> bitnr) & 1); } @@ -2022,6 +2067,9 @@ static ssize_t cpu0_vid_show(struct device *dev, { struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%ld\n", (long)vid_from_reg(data->vid, data->vrm)); } static DEVICE_ATTR_RO(cpu0_vid); From patchwork Sun Apr 16 04:25:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13212705 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 261B5C77B73 for ; Sun, 16 Apr 2023 04:25:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbjDPEZo (ORCPT ); Sun, 16 Apr 2023 00:25:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbjDPEZn (ORCPT ); Sun, 16 Apr 2023 00:25:43 -0400 Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [150.101.137.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61339271C for ; Sat, 15 Apr 2023 21:25:40 -0700 (PDT) IronPort-SDR: 643b78bf_TGXoHZXixJXO1ZUxpr+aFARaGwKPQT6GJydCcocVxMfx9yo cUUSO+6Zc7WUNpS1jtPyRO0hdLsorOP4qDd00Dg== X-SMTP-MATCH: 0 X-IPAS-Result: A2C6AACkdztkjPQc8jxaHQEBAQEJARIBBQUBSYE1BQELAYItgk+WAp9dDwEPAQFEBAEBhQYChTwmNwYOAQIEAQEBAQMCAwEBAQEBAQMBAQYBAQEBAQEGBBQBAQEBQEWFaA2GBAIBAycLAQ0BATcBDxk4VwYBEoJ+gl2vBDOBAYIIAQEGgmKaaoFeCYFBAYt0gRaDNnpCP4FOgRWBPIIthByGappWgTR2gSAOSnKBBAIJAhFrgRAIaoF5QAINZAsOb4FJgyoEAhREDlQDCQMHBUlAAwsYDRY6Eyw1FCBcbC0SEgUDCxUqRwQIOAYbNBECCA8SDyxEDEI3MxMGXAEpCw4RA05CGWwEggoGASYknyABWAE0MIF5B0oskjEBB7EJhAiBWZ8UTYFGgjeTUZF0LpdJIIIun2Qta4QsAgoHFoF5gX9NHxmDIk8DGQ+OIAwNCYIKkVFjPQIHCwEBAwmIbYJYAQE IronPort-PHdr: A9a23:jRBV0hPX93bZqLRrVVwl6nczWUAX0o4cdiYf64Y8zblUe7ut+I7ue kHa+LNsgBnAQNaT4uhP3uzRta2oQmkc+dCbvXUFbJEJVgdQh8kaxV5/CceJW0Gnc664Nn5oF 84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UVcazyj6VjehgV931DJrxh1snkWW/ZwVyFpkNautzj oWI4YLW3luanbMYUFL5upimFotL7sCcB9hSY9PFByRelxu/RcbT2gYyy125Dbdrk9ptwNata CXlScm3dP8TA8x8wl8MYQdgMh8tMYbFRYa+mjGYsNK3FQk70ybLCPiF5E3ZRzhXWQFQMqKvF zKuneil4+5pibhlBTgGNqlAOIB5KlqyYpkWXYT9mhfAB1b5n27YnKXpkCchzjT5CnOkNsLey rCdTzjccCWCgo35/Ot7gadT4CJOVG1chNMudH0z49R10jC2LFAXJNQnbKkpNMtmrTzQ5rrZO hf9NWcsMHCoF3AMOxDx+8/qUQqjF/QDcIWxbCAg+0SPLTy6HsWcCb9m7T1t+GpyZiCl9uy8N NUC4TflC3BdGH2yqTo7vZRXWdta+84= IronPort-HdrOrdr: A9a23:kcmRMamL8Wn38dBgV4IvDpyNw3DpDfL23DAbv31ZSRFFG/Fw9/ rFoB3U737JYVEqKQgdcbLpAsS9qBbnmaKdjrNhXotKMDOIhILsFvAH0WKA+UyHJ8SBzJ8+6U 4IScEXY+EYT2IK6voSizPZLz9P+re6GC/Ev5an854Ud3AOV0h51XYENu+EKDwKeOCYP+tDKH JMjvA33QadRQ== X-Talos-CUID: 9a23:n7yNDG1yJHdtA5CHdmkORbxfF9wuWyH2ljDsJl6WFUlFGbuoCgav9/Yx X-Talos-MUID: 9a23:zU9VbQTftOtbFPTiRXTPrW49OdYr5p+zUhwVmM1duOKDFwp/bmI= 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 ipmail03.adl2.internode.on.net with ESMTP; 16 Apr 2023 13:55:36 +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 33G4PCj43415316 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 16 Apr 2023 14:25:32 +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 33G4PCj43415316 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1681619132; bh=FzLyzpQ8eY6cpJNDC9SCzOjYHhQ33c38JIvf7wUhPdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MaChyRLquVUUdovLoNuluJ4IcmgHNLeC8/smVf+QQtGkzOzXygUjyXpuereR1CURE /sVArnvR59fh3DBLu5Jle6WLXxDJJU0UB3GLk56x9yizaoIfpZYtEy5ahQ3Im9asbX ln81KeQZFGzU/0l/3d1DbC8z33FpcRaE9VMx8BZbvgSsHXJAO8LclRcjlN69DQBGvz v4yMHBzNA0OJ/7Hry3NXuaDCJQL2QlY+cxQOo+epvKMWXVdk7AzavDXuw0hJ3k2G1M 3EWwBzee+EWjmtMDG09YIgua2mIdXTY90JxdjqHym0cIyKHk8O7ODMbEYy3wFzkXBU LLPxZl5L2vTgg== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v2 3/4] hwmon: (it87) Add calls to smbus_enable/smbus_disable as required Date: Sun, 16 Apr 2023 14:25:09 +1000 Message-Id: <20230416042510.1929077-4-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230416042510.1929077-1-frank@crawford.emu.id.au> References: <20230416042510.1929077-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]); Sun, 16 Apr 2023 14:25:32 +1000 (AEST) X-Virus-Scanned: clamav-milter 0.103.8 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Disable/re-enable access through SMBus for chip registers when they are are being read or written. For simple cases this is done at the same time as when a mutex is set, however, within loops or during initialisation it is done separately. Signed-off-by: Frank Crawford --- v2: * Reorder patches within patchset. * Remove spaces before tab. --- drivers/hwmon/it87.c | 181 ++++++++++++++++++++++++++++++++----------- 1 file changed, 135 insertions(+), 46 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 920fb9b6b2e2..2922f551b717 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -746,6 +746,7 @@ static int smbus_enable(struct it87_data *data) /* * Must be called with data->update_lock held, except during initialization. + * Must be called with SMBus accesses disabled. * We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, * would slow down the IT87 access and should not be necessary. */ @@ -757,6 +758,7 @@ static int it87_read_value(struct it87_data *data, u8 reg) /* * Must be called with data->update_lock held, except during initialization. + * Must be called with SMBus accesses disabled. * We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, * would slow down the IT87 access and should not be necessary. */ @@ -816,15 +818,39 @@ static void it87_update_pwm_ctrl(struct it87_data *data, int nr) } } +static int it87_lock(struct it87_data *data) +{ + int err; + + mutex_lock(&data->update_lock); + err = smbus_disable(data); + if (err) + mutex_unlock(&data->update_lock); + return err; +} + +static void it87_unlock(struct it87_data *data) +{ + smbus_enable(data); + mutex_unlock(&data->update_lock); +} + static struct it87_data *it87_update_device(struct device *dev) { struct it87_data *data = dev_get_drvdata(dev); + struct it87_data *ret = data; + int err; int i; mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || - !data->valid) { + !data->valid) { + err = smbus_disable(data); + if (err) { + ret = ERR_PTR(err); + goto unlock; + } if (update_vbat) { /* * Cleared after each update, so reenable. Value @@ -927,11 +953,11 @@ static struct it87_data *it87_update_device(struct device *dev) } data->last_updated = jiffies; data->valid = true; + smbus_enable(data); } - +unlock: mutex_unlock(&data->update_lock); - - return data; + return ret; } static ssize_t show_in(struct device *dev, struct device_attribute *attr, @@ -956,17 +982,21 @@ static ssize_t set_in(struct device *dev, struct device_attribute *attr, int index = sattr->index; int nr = sattr->nr; unsigned long val; + int err; if (kstrtoul(buf, 10, &val) < 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + data->in[nr][index] = in_to_reg(data, nr, val); it87_write_value(data, index == 1 ? IT87_REG_VIN_MIN(nr) : IT87_REG_VIN_MAX(nr), data->in[nr][index]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1048,11 +1078,14 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); long val; u8 reg, regval; + int err; if (kstrtol(buf, 10, &val) < 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; switch (index) { default: @@ -1075,7 +1108,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr, data->temp[nr][index] = TEMP_TO_REG(val); it87_write_value(data, reg, data->temp[nr][index]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1135,10 +1168,15 @@ static ssize_t set_temp_type(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); long val; u8 reg, extra; + int err; if (kstrtol(buf, 10, &val) < 0) return -EINVAL; + err = it87_lock(data); + if (err) + return err; + reg = it87_read_value(data, IT87_REG_TEMP_ENABLE); reg &= ~(1 << nr); reg &= ~(8 << nr); @@ -1161,17 +1199,19 @@ static ssize_t set_temp_type(struct device *dev, struct device_attribute *attr, reg |= (nr + 1) << 6; else if (has_temp_old_peci(data, nr) && val == 6) extra |= 0x80; - else if (val != 0) - return -EINVAL; + else if (val != 0) { + count = -EINVAL; + goto unlock; + } - mutex_lock(&data->update_lock); data->sensor = reg; data->extra = extra; it87_write_value(data, IT87_REG_TEMP_ENABLE, data->sensor); if (has_temp_old_peci(data, nr)) it87_write_value(data, IT87_REG_TEMP_EXTRA, data->extra); data->valid = false; /* Force cache refresh */ - mutex_unlock(&data->update_lock); +unlock: + it87_unlock(data); return count; } @@ -1287,12 +1327,15 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); long val; + int err; u8 reg; if (kstrtol(buf, 10, &val) < 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; if (has_16bit_fans(data)) { data->fan[nr][index] = FAN16_TO_REG(val); @@ -1319,7 +1362,7 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *attr, data->fan[nr][index]); } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1330,13 +1373,16 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; unsigned long val; - int min; + int min, err; u8 old; if (kstrtoul(buf, 10, &val) < 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + old = it87_read_value(data, IT87_REG_FAN_DIV); /* Save fan min limit */ @@ -1364,7 +1410,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, data->fan[nr][1] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); it87_write_value(data, IT87_REG_FAN_MIN[nr], data->fan[nr][1]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1405,6 +1451,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; long val; + int err; if (kstrtol(buf, 10, &val) < 0 || val < 0 || val > 2) return -EINVAL; @@ -1415,7 +1462,9 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, return -EINVAL; } - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; if (val == 0) { if (nr < 3 && data->type != it8603) { @@ -1466,7 +1515,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, } } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1477,11 +1526,15 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; long val; + int err; if (kstrtol(buf, 10, &val) < 0 || val < 0 || val > 255) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + it87_update_pwm_ctrl(data, nr); if (has_newer_autopwm(data)) { /* @@ -1489,8 +1542,8 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, * is read-only so we can't write the value. */ if (data->pwm_ctrl[nr] & 0x80) { - mutex_unlock(&data->update_lock); - return -EBUSY; + count = -EBUSY; + goto unlock; } data->pwm_duty[nr] = pwm_to_reg(data, val); it87_write_value(data, IT87_REG_PWM_DUTY[nr], @@ -1507,7 +1560,8 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, data->pwm_ctrl[nr]); } } - mutex_unlock(&data->update_lock); +unlock: + it87_unlock(data); return count; } @@ -1518,6 +1572,7 @@ static ssize_t set_pwm_freq(struct device *dev, struct device_attribute *attr, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; unsigned long val; + int err; int i; if (kstrtoul(buf, 10, &val) < 0) @@ -1532,7 +1587,10 @@ static ssize_t set_pwm_freq(struct device *dev, struct device_attribute *attr, break; } - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + if (nr == 0) { data->fan_ctl = it87_read_value(data, IT87_REG_FAN_CTL) & 0x8f; data->fan_ctl |= i << 4; @@ -1542,7 +1600,7 @@ static ssize_t set_pwm_freq(struct device *dev, struct device_attribute *attr, data->extra |= i << 4; it87_write_value(data, IT87_REG_TEMP_EXTRA, data->extra); } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1575,6 +1633,7 @@ static ssize_t set_pwm_temp_map(struct device *dev, struct it87_data *data = dev_get_drvdata(dev); int nr = sensor_attr->index; long val; + int err; u8 reg; if (kstrtol(buf, 10, &val) < 0) @@ -1597,7 +1656,10 @@ static ssize_t set_pwm_temp_map(struct device *dev, return -EINVAL; } - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + it87_update_pwm_ctrl(data, nr); data->pwm_temp_map[nr] = reg; /* @@ -1609,7 +1671,7 @@ static ssize_t set_pwm_temp_map(struct device *dev, data->pwm_temp_map[nr]; it87_write_value(data, IT87_REG_PWM[nr], data->pwm_ctrl[nr]); } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1639,18 +1701,22 @@ static ssize_t set_auto_pwm(struct device *dev, struct device_attribute *attr, int point = sensor_attr->index; int regaddr; long val; + int err; if (kstrtol(buf, 10, &val) < 0 || val < 0 || val > 255) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + data->auto_pwm[nr][point] = pwm_to_reg(data, val); if (has_newer_autopwm(data)) regaddr = IT87_REG_AUTO_TEMP(nr, 3); else regaddr = IT87_REG_AUTO_PWM(nr, point); it87_write_value(data, regaddr, data->auto_pwm[nr][point]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1675,15 +1741,19 @@ static ssize_t set_auto_pwm_slope(struct device *dev, struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int nr = sensor_attr->index; unsigned long val; + int err; if (kstrtoul(buf, 10, &val) < 0 || val > 127) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + data->auto_pwm[nr][1] = (data->auto_pwm[nr][1] & 0x80) | val; it87_write_value(data, IT87_REG_AUTO_TEMP(nr, 4), data->auto_pwm[nr][1]); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1718,11 +1788,15 @@ static ssize_t set_auto_temp(struct device *dev, struct device_attribute *attr, int point = sensor_attr->index; long val; int reg; + int err; if (kstrtol(buf, 10, &val) < 0 || val < -128000 || val > 127000) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + if (has_newer_autopwm(data) && !point) { reg = data->auto_temp[nr][1] - TEMP_TO_REG(val); reg = clamp_val(reg, 0, 0x1f) | (data->auto_temp[nr][0] & 0xe0); @@ -1735,7 +1809,7 @@ static ssize_t set_auto_temp(struct device *dev, struct device_attribute *attr, point--; it87_write_value(data, IT87_REG_AUTO_TEMP(nr, point), reg); } - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -1944,13 +2018,16 @@ static ssize_t clear_intrusion(struct device *dev, size_t count) { struct it87_data *data = dev_get_drvdata(dev); - int config; + int err, config; long val; if (kstrtol(buf, 10, &val) < 0 || val != 0) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + config = it87_read_value(data, IT87_REG_CONFIG); if (config < 0) { count = config; @@ -1960,8 +2037,7 @@ static ssize_t clear_intrusion(struct device *dev, /* Invalidate cache to force re-read */ data->valid = false; } - mutex_unlock(&data->update_lock); - + it87_unlock(data); return count; } @@ -2003,18 +2079,22 @@ static ssize_t set_beep(struct device *dev, struct device_attribute *attr, int bitnr = to_sensor_dev_attr(attr)->index; struct it87_data *data = dev_get_drvdata(dev); long val; + int err; if (kstrtol(buf, 10, &val) < 0 || (val != 0 && val != 1)) return -EINVAL; - mutex_lock(&data->update_lock); + err = it87_lock(data); + if (err) + return err; + data->beeps = it87_read_value(data, IT87_REG_BEEP_ENABLE); if (val) data->beeps |= BIT(bitnr); else data->beeps &= ~BIT(bitnr); it87_write_value(data, IT87_REG_BEEP_ENABLE, data->beeps); - mutex_unlock(&data->update_lock); + it87_unlock(data); return count; } @@ -3177,6 +3257,7 @@ static int it87_probe(struct platform_device *pdev) struct it87_sio_data *sio_data = dev_get_platdata(dev); int enable_pwm_interface; struct device *hwmon_dev; + int err; res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!devm_request_region(&pdev->dev, res->start, IT87_EC_EXTENT, @@ -3222,15 +3303,21 @@ static int it87_probe(struct platform_device *pdev) break; } - /* Now, we do the remaining detection. */ - if ((it87_read_value(data, IT87_REG_CONFIG) & 0x80) || - it87_read_value(data, IT87_REG_CHIPID) != 0x90) - return -ENODEV; - platform_set_drvdata(pdev, data); mutex_init(&data->update_lock); + err = smbus_disable(data); + if (err) + return err; + + /* Now, we do the remaining detection. */ + if ((it87_read_value(data, IT87_REG_CONFIG) & 0x80) || + it87_read_value(data, IT87_REG_CHIPID) != 0x90) { + smbus_enable(data); + return -ENODEV; + } + /* Check PWM configuration */ enable_pwm_interface = it87_check_pwm(dev); if (!enable_pwm_interface) @@ -3291,6 +3378,8 @@ static int it87_probe(struct platform_device *pdev) /* Initialize the IT87 chip */ it87_init_device(pdev); + smbus_enable(data); + if (!sio_data->skip_vid) { data->has_vid = true; data->vrm = vid_which_vrm(); @@ -3358,7 +3447,7 @@ static int it87_resume(struct device *dev) it87_resume_sio(pdev); - mutex_lock(&data->update_lock); + it87_lock(data); it87_check_pwm(dev); it87_check_limit_regs(data); @@ -3371,7 +3460,7 @@ static int it87_resume(struct device *dev) /* force update */ data->valid = false; - mutex_unlock(&data->update_lock); + it87_unlock(data); it87_update_device(dev); From patchwork Sun Apr 16 04:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13212704 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 0F93DC77B61 for ; Sun, 16 Apr 2023 04:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbjDPEZn (ORCPT ); Sun, 16 Apr 2023 00:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbjDPEZm (ORCPT ); Sun, 16 Apr 2023 00:25:42 -0400 Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [150.101.137.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 023542D4C for ; Sat, 15 Apr 2023 21:25:40 -0700 (PDT) IronPort-SDR: 643b78c3_2F9B1D0oTPNsjasTbE69YPfHHiXBniVAFLCyukcUH1a9Hs/ Uvfx1xio4ETL28FP604p5JRRcM8PfHznr9+1HLA== X-SMTP-MATCH: 0 X-IPAS-Result: A2ArAACkdztkjPQc8jxaHAEBAQEBAQcBARIBAQQEAQFJgTMGAQELAYItgk+zYYF+DwEPAQFEBAEBhQYChTwmNQgOAQIEAQEBAQMCAwEBAQEBAQMBAQYBAQEBAQEGBBQBAQEBQEWFaA2GBAIBAzIBDQEBNwEPGThXBgESgn6CXa83gQGCCAEBBoJimmqBXgmBQQGLdIEWgzZ6Qj+BToR+gQWKAZpWgTR2gSAOSnKBBAIJAhFrgRAIaoF5QAINZAsOb4FJgyoEAhREDlQDCQMHBUlAAwsYDRY6Eyw1FCBcbC0SEgUDCxUqRwQIOAYbNBECCA8SDyxEDEI3MxMGXAEpCw4RA05CGWwEggoGASYknx8BWTWkSqIehAiBWZ8UTYFGp3yXdyCiEoEYhCwCCgcWgWQBghNNHxmDIk8DGQ+OIBcCghORUWM9AgcLAQEDCYtFAQE IronPort-PHdr: A9a23:bAiebxLiQmneXPO+JdmcuVEyDhhOgF28FgQU9oFhgKhHbaqk5ZikM UnCo/RhylbUDs3S8fkRje3Qvuj7XHAYp4yMtXcefdlNT0oLhclMzVMpCcLXBRGkfKyzPX4xF p0aBlRupy7TDA== IronPort-Data: A9a23:9W00k6gVoYqjL89In+hDM+nkX161dBQKZh0ujC45NGQN5FlHY01je htvUG3TMquMMWX2Loslb4jjoUJUvsXVnNY1Sws6rC4wQioT9JPPX4nDJx+pNHvDdcOfFR06s MtGZIabdMk9RS/WrT6gY+PrxZVe/fjYHuCmVIYoGczQqStMEnpJZcdLwrZh6mJ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Wcsb7flD0l2zHBKl+ANO3Yu ZvlZBzPRC6eiZHy7uNyktJN50UMLXNHn+MPUFoX+Id2hxCEHWc2F7khHqtcOK5EsB7Z9c/eV GjBYlJ3XG+5FX5BfA7n6dvuYhaHC6Zccp3lLzgu5AWPZz3wGIqEB6B7+zx952ttPAHu1/yjN cpU70iY0sJdGX21bb17CiSHvNpa IronPort-HdrOrdr: A9a23:Kd6lCa4RueerDBX71gPXwBLXdLJyesId70hD6qkQc3ZomwKj9v xG+85rrCMd6l4qNU3I/OrtBEDuewK+yXcY2+Ys1PKZLW3bUQiTXedfBPXZsl/d8kTFn4Y36U 4jSdkYNDSaNzhHZKjBjjVRnLsbsaG6GdiT9ILjJm9WPH1Xgr9bnnpE49mgYzZLrNgvP+tCKK ah X-Talos-CUID: 9a23:6q2himi3i4lfbjzxSRoOWT2/lDJuWXPZ91jacl2DDjhKZeGZGWDXof5Eqp87 X-Talos-MUID: 9a23:KZWxMQX7fR+MuADq/AHmujJ/F8E42IuvORoGwJcW58OKKBUlbg== 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 ipmail03.adl2.internode.on.net with ESMTP; 16 Apr 2023 13:55:40 +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 33G4PCj53415316 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 16 Apr 2023 14:25:36 +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 33G4PCj53415316 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1681619136; bh=U6BktsoWzMH67w/TwPnlaIRCOv4RVUAHhIuHtUPVPf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CZwPdFm98aEvH2ToOjyYBSYfC7fZfdKNp+JYSkb+24UMmKF33WohszdAfzuUPB7e9 YsuoIF9uPGcS8vppAsVeHkJ7mTlPxfJOdgF+9s/8FiGezGyG/B7cinvY1yPFUdAetL TuNAMcxJZprr+VPG6CDodMu+DQo3cpjbD9eH42q2GDGwulI8TZGna9H38lJV5BCe0i PdFSM09yiYQxgmdIqJqHrnrXAiRHdjAhmivBBIQS1BAldmvmPMKm8n6nbMBYqf/HkC FH0NBuJ13tuW9G2Lfsnccmb8gH8hGzMuwhHMoL6646T6xwEEpOPFR3Aw9zvUUH9XuC 7I99mSyN73J+g== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v2 4/4] hwmon: (it87) Disable/enable SMBus access for IT8622E chipset Date: Sun, 16 Apr 2023 14:25:10 +1000 Message-Id: <20230416042510.1929077-5-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230416042510.1929077-1-frank@crawford.emu.id.au> References: <20230416042510.1929077-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]); Sun, 16 Apr 2023 14:25:36 +1000 (AEST) X-Virus-Scanned: clamav-milter 0.103.8 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Configure the IT8622E chip to disable/re-enable access via an SMBus when reading or writing the chip's registers. Signed-off-by: Frank Crawford --- v2: * No change. --- drivers/hwmon/it87.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 2922f551b717..9b7628b2a678 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -474,6 +474,7 @@ static const struct it87_devices it87_devices[] = { | FEAT_FIVE_PWM | FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2 | FEAT_AVCC3 | FEAT_VIN3_5V, .peci_mask = 0x07, + .smbus_bitmap = BIT(1) | BIT(2), }, [it8628] = { .name = "it8628",