Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'hwmon-for-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon updates from Guenter Roeck:
"New drivers:
- Apple Silicon SMC
- TSC1641 I2C power monitor
- MPS MP9945
- MAX17616
- MP2925 and MP2929

Added support for new devices to existing drivers:
- dell-smm: Add Dell G5 5505 to fan control whitelist
- aspeed-g6-pwm-tach: Support for AST2700
- asus-ec-sensors: Support for ROG STRIX X470-I GAMING, ROG STRIX
X870-F GAMING WIFI, ROG STRIX X870E-H GAMING WIFI7, and Pro WS
TRX50-SAGE WIFI
- k10temp: Support for AMD Steam Deck APU ID
- pmbus/isl68137: Support for raa229141
- aht10: Support for dht20
- adt7410: Support for ADT7422
- peci: Support for Intel Emerald Rapids
- nct6775: Support for ASUS ROG STRIX X870E-H GAMING WIFI7
- pmbus/max34440: Support for ADPM12200
- ntc-thermistor: Support for Murata ncp18wm474

Infrastructure updates:
- Utilize subsystem locking in various drivers
- ltc4282, ltc2947: Use the new energy64 attribute

Bug fixes:
- Various drivers: Fixes to avoid TOCTOU, mostly in macro functions
evaluating parameters multiple times, as well as missing locks
- max6697: Fix regmap leak on probe failure
- sy7636a: Fix regulator_enable resource leak on error path
- asus-ec-sensors: Correct Pro WS TRX50-SAGE WIFI entry

Other changes and improvements:
- w83781d, lm78: Drop REALLY_SLOW_IO
- Fix broken datasheet links in various drivers

And various other minor fixes and improvements"

* tag 'hwmon-for-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (110 commits)
hwmon: (dell-smm) Add Dell G5 5505 to fan control whitelist
hwmon: (max16065) Use local variable to avoid TOCTOU
hwmon: (w83l786ng) Convert macros to functions to avoid TOCTOU
hwmon: (max6697) fix regmap leak on probe failure
hwmon/w83781d: Drop REALLY_SLOW_IO setting
hwmon/lm78: Drop REALLY_SLOW_IO setting
hwmon: sy7636a: Fix regulator_enable resource leak on error path
hwmon: (adm1026) Convert macros to functions to avoid TOCTOU
hwmon: (adm1029) Add locking to avoid TOCTOU
hwmon: (lm87) Convert macros to functions to avoid TOCTOU
hwmon: (asus-ec-sensors) correct Pro WS TRX50-SAGE WIFI entry
hwmon: (vt8231) Convert macros to functions to avoid TOCTOU
hwmon: (emc2103) Add locking to avoid TOCTOU
hwmon: (aspeed-g6-pwm-tach): Add AST2700 compatible string
dt-bindings: hwmon: Add AST2700 compatible
hwmon: (asus-ec-sensors) add ROG STRIX X470-I GAMING
hwmon: (vt1211) Convert macros to functions to avoid TOCTOU
hwmon: (k10temp) Add AMD Steam Deck APU ID
hwmon: Add Apple Silicon SMC hwmon driver
Documentation/hwmon: Fix broken datasheet links for zl6100
...

+3852 -1284
+30
Documentation/devicetree/bindings/hwmon/apm,xgene-slimpro-hwmon.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/hwmon/apm,xgene-slimpro-hwmon.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: APM X-Gene SLIMpro hwmon 8 + 9 + maintainers: 10 + - Khuong Dinh <khuong@os.amperecomputing.com> 11 + 12 + properties: 13 + compatible: 14 + const: apm,xgene-slimpro-hwmon 15 + 16 + mboxes: 17 + maxItems: 1 18 + 19 + required: 20 + - compatible 21 + - mboxes 22 + 23 + additionalProperties: false 24 + 25 + examples: 26 + - | 27 + hwmon { 28 + compatible = "apm,xgene-slimpro-hwmon"; 29 + mboxes = <&mailbox 7>; 30 + };
-14
Documentation/devicetree/bindings/hwmon/apm-xgene-hwmon.txt
··· 1 - APM X-Gene hwmon driver 2 - 3 - APM X-Gene SOC sensors are accessed over the "SLIMpro" mailbox. 4 - 5 - Required properties : 6 - - compatible : should be "apm,xgene-slimpro-hwmon" 7 - - mboxes : use the label reference for the mailbox as the first parameter. 8 - The second parameter is the channel number. 9 - 10 - Example : 11 - hwmonslimpro { 12 - compatible = "apm,xgene-slimpro-hwmon"; 13 - mboxes = <&mailbox 7>; 14 - };
+5 -2
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
··· 18 18 19 19 properties: 20 20 compatible: 21 - enum: 22 - - aspeed,ast2600-pwm-tach 21 + oneOf: 22 + - items: 23 + - const: aspeed,ast2700-pwm-tach 24 + - const: aspeed,ast2600-pwm-tach 25 + - const: aspeed,ast2600-pwm-tach 23 26 24 27 reg: 25 28 maxItems: 1
-22
Documentation/devicetree/bindings/hwmon/max31785.txt
··· 1 - Bindings for the Maxim MAX31785 Intelligent Fan Controller 2 - ========================================================== 3 - 4 - Reference: 5 - 6 - https://datasheets.maximintegrated.com/en/ds/MAX31785.pdf 7 - 8 - The Maxim MAX31785 is a PMBus device providing closed-loop, multi-channel fan 9 - management with temperature and remote voltage sensing. Various fan control 10 - features are provided, including PWM frequency control, temperature hysteresis, 11 - dual tachometer measurements, and fan health monitoring. 12 - 13 - Required properties: 14 - - compatible : One of "maxim,max31785" or "maxim,max31785a" 15 - - reg : I2C address, one of 0x52, 0x53, 0x54, 0x55. 16 - 17 - Example: 18 - 19 - fans@52 { 20 - compatible = "maxim,max31785"; 21 - reg = <0x52>; 22 - };
+18 -4
Documentation/devicetree/bindings/hwmon/maxim,max31790.yaml
··· 20 20 21 21 properties: 22 22 compatible: 23 - const: maxim,max31790 23 + enum: 24 + - maxim,max31785 25 + - maxim,max31785a 26 + - maxim,max31785b 27 + - maxim,max31790 24 28 25 29 reg: 26 30 maxItems: 1 ··· 35 31 resets: 36 32 maxItems: 1 37 33 34 + '#address-cells': 35 + const: 1 36 + 37 + '#size-cells': 38 + const: 0 39 + 38 40 "#pwm-cells": 39 41 const: 1 40 42 41 43 patternProperties: 42 - "^fan-[0-9]+$": 44 + "^fan@[0-9]+$": 43 45 $ref: fan-common.yaml# 44 46 unevaluatedProperties: false 45 47 ··· 66 56 reg = <0x20>; 67 57 clocks = <&sys_clk>; 68 58 resets = <&reset 0>; 59 + #address-cells = <1>; 69 60 #pwm-cells = <1>; 61 + #size-cells = <0>; 70 62 71 - fan-0 { 63 + fan@0 { 64 + reg = <0x0>; 72 65 pwms = <&pwm_provider 1>; 73 66 }; 74 67 75 - fan-1 { 68 + fan@1 { 69 + reg = <0x1>; 76 70 pwms = <&pwm_provider 2>; 77 71 }; 78 72 };
+1
Documentation/devicetree/bindings/hwmon/ntc-thermistor.yaml
··· 75 75 - const: murata,ncp15wl333 76 76 - const: murata,ncp03wf104 77 77 - const: murata,ncp15xh103 78 + - const: murata,ncp18wm474 78 79 - const: samsung,1404-001221 79 80 # Deprecated "ntc," compatible strings 80 81 - const: ntc,ncp15wb473
+52
Documentation/devicetree/bindings/hwmon/pmbus/adi,max17616.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/hwmon/pmbus/adi,max17616.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Analog Devices MAX17616/MAX17616A Current-Limiter with PMBus Interface 8 + 9 + maintainers: 10 + - Kim Seer Paller <kimseer.paller@analog.com> 11 + 12 + description: | 13 + The MAX17616/MAX17616A is a 3V to 80V, 7A current-limiter with overvoltage, 14 + surge, undervoltage, reverse polarity, and loss of ground protection. It allows 15 + monitoring of input/output voltage, output current and temperature through the 16 + PMBus serial interface. 17 + Datasheet: 18 + https://www.analog.com/en/products/max17616.html 19 + 20 + properties: 21 + compatible: 22 + const: adi,max17616 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + vcc-supply: true 28 + 29 + interrupts: 30 + description: Fault condition signal provided on SMBALERT pin. 31 + maxItems: 1 32 + 33 + required: 34 + - compatible 35 + - reg 36 + - vcc-supply 37 + 38 + additionalProperties: false 39 + 40 + examples: 41 + - | 42 + i2c { 43 + #address-cells = <1>; 44 + #size-cells = <0>; 45 + 46 + hwmon@16 { 47 + compatible = "adi,max17616"; 48 + reg = <0x16>; 49 + vcc-supply = <&vcc>; 50 + }; 51 + }; 52 + ...
+63
Documentation/devicetree/bindings/hwmon/st,tsc1641.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/hwmon/st,tsc1641.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: ST Microelectronics TSC1641 I2C power monitor 8 + 9 + maintainers: 10 + - Igor Reznichenko <igor@reznichenko.net> 11 + 12 + description: | 13 + TSC1641 is a 60 V, 16-bit high-precision power monitor with I2C and 14 + MIPI I3C interface 15 + 16 + Datasheets: 17 + https://www.st.com/resource/en/datasheet/tsc1641.pdf 18 + 19 + properties: 20 + compatible: 21 + const: st,tsc1641 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + interrupts: 27 + description: Optional alert interrupt. 28 + maxItems: 1 29 + 30 + shunt-resistor-micro-ohms: 31 + description: Shunt resistor value in micro-ohms. Since device has internal 32 + 16-bit RSHUNT register with 10 uOhm LSB, the maximum value is capped at 33 + 655.35 mOhm. 34 + minimum: 100 35 + default: 1000 36 + maximum: 655350 37 + 38 + st,alert-polarity-active-high: 39 + $ref: /schemas/types.yaml#/definitions/flag 40 + description: Default value is 0 which configures the normal polarity of the 41 + ALERT pin, being active low open-drain. Setting this to 1 configures the 42 + polarity of the ALERT pin to be inverted and active high open-drain. 43 + Specify this property to set the alert polarity to active-high. 44 + 45 + required: 46 + - compatible 47 + - reg 48 + 49 + additionalProperties: false 50 + 51 + examples: 52 + - | 53 + i2c { 54 + #address-cells = <1>; 55 + #size-cells = <0>; 56 + 57 + power-sensor@40 { 58 + compatible = "st,tsc1641"; 59 + reg = <0x40>; 60 + shunt-resistor-micro-ohms = <1000>; 61 + st,alert-polarity-active-high; 62 + }; 63 + };
+12
Documentation/devicetree/bindings/trivial-devices.yaml
··· 43 43 - adi,ad5110 44 44 # Temperature sensor with integrated fan control 45 45 - adi,adm1027 46 + # Analog Devices ADT7410 High Accuracy Digital Temperature Sensor 47 + - adi,adt7410 46 48 # Analog Devices ADT7411 Temperature Sensor and 8-channel ADC 47 49 - adi,adt7411 50 + # Analog Devices ADT7420 High Accuracy Digital Temperature Sensor 51 + - adi,adt7420 52 + # Analog Devices ADT7422 High Accuracy Digital Temperature Sensor 53 + - adi,adt7422 48 54 # Temperature sensor with integrated fan control 49 55 - adi,adt7463 50 56 # Temperature sensor with integrated fan control ··· 305 299 - mps,mp2888 306 300 # Monolithic Power Systems Inc. multi-phase controller mp2891 307 301 - mps,mp2891 302 + # Monolithic Power Systems Inc. multi-phase controller mp2925 303 + - mps,mp2925 304 + # Monolithic Power Systems Inc. multi-phase controller mp2929 305 + - mps,mp2929 308 306 # Monolithic Power Systems Inc. multi-phase controller mp29502 309 307 - mps,mp29502 310 308 # Monolithic Power Systems Inc. multi-phase controller mp29608 ··· 329 319 - mps,mp5998 330 320 # Monolithic Power Systems Inc. digital step-down converter mp9941 331 321 - mps,mp9941 322 + # Monolithic Power Systems Inc. digital step-down converter mp9945 323 + - mps,mp9945 332 324 # Temperature sensor with integrated fan control 333 325 - national,lm63 334 326 # Temperature sensor with integrated fan control
+9 -1
Documentation/hwmon/aht10.rst
··· 20 20 21 21 English: http://www.aosong.com/userfiles/files/media/Data%20Sheet%20AHT20.pdf 22 22 23 + * Aosong DHT20 24 + 25 + Prefix: 'dht20' 26 + 27 + Addresses scanned: None 28 + 29 + Datasheet: https://www.digikey.co.nz/en/htmldatasheets/production/9184855/0/0/1/101020932 30 + 23 31 Author: Johannes Cornelis Draaijer <jcdra1@gmail.com> 24 32 25 33 ··· 41 33 Special Features 42 34 ---------------- 43 35 44 - AHT20 has additional CRC8 support which is sent as the last byte of the sensor 36 + AHT20, DHT20 has additional CRC8 support which is sent as the last byte of the sensor 45 37 values. 46 38 47 39 Usage Notes
+4
Documentation/hwmon/asus_ec_sensors.rst
··· 9 9 * PRIME X570-PRO 10 10 * PRIME X670E-PRO WIFI 11 11 * PRIME Z270-A 12 + * Pro WS TRX50-SAGE WIFI 12 13 * Pro WS X570-ACE 13 14 * Pro WS WRX90E-SAGE SE 14 15 * ProArt X570-CREATOR WIFI ··· 30 29 * ROG STRIX B550-I GAMING 31 30 * ROG STRIX B650E-I GAMING WIFI 32 31 * ROG STRIX B850-I GAMING WIFI 32 + * ROG STRIX X470-I GAMING 33 33 * ROG STRIX X570-E GAMING 34 34 * ROG STRIX X570-E GAMING WIFI II 35 35 * ROG STRIX X570-F GAMING 36 36 * ROG STRIX X570-I GAMING 37 37 * ROG STRIX X670E-E GAMING WIFI 38 38 * ROG STRIX X670E-I GAMING WIFI 39 + * ROG STRIX X870-F GAMING WIFI 39 40 * ROG STRIX X870-I GAMING WIFI 40 41 * ROG STRIX X870E-E GAMING WIFI 42 + * ROG STRIX X870E-H GAMING WIFI7 41 43 * ROG STRIX Z390-F GAMING 42 44 * ROG STRIX Z490-F GAMING 43 45 * ROG STRIX Z690-A GAMING WIFI D4
+5 -5
Documentation/hwmon/ds1621.rst
··· 9 9 10 10 Addresses scanned: none 11 11 12 - Datasheet: Publicly available from www.maximintegrated.com 12 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/DS1621.pdf 13 13 14 14 * Dallas Semiconductor DS1625 15 15 ··· 17 17 18 18 Addresses scanned: none 19 19 20 - Datasheet: Publicly available from www.datasheetarchive.com 20 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/DS1620.pdf 21 21 22 22 * Maxim Integrated DS1631 23 23 ··· 25 25 26 26 Addresses scanned: none 27 27 28 - Datasheet: Publicly available from www.maximintegrated.com 28 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/DS1631-DS1731.pdf 29 29 30 30 * Maxim Integrated DS1721 31 31 ··· 33 33 34 34 Addresses scanned: none 35 35 36 - Datasheet: Publicly available from www.maximintegrated.com 36 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/DS1721.pdf 37 37 38 38 * Maxim Integrated DS1731 39 39 ··· 41 41 42 42 Addresses scanned: none 43 43 44 - Datasheet: Publicly available from www.maximintegrated.com 44 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/DS1631-DS1731.pdf 45 45 46 46 Authors: 47 47 - Christian W. Zuckschwerdt <zany@triq.net>
+5
Documentation/hwmon/index.rst
··· 144 144 ltc4261 145 145 ltc4282 146 146 ltc4286 147 + macsmc-hwmon 147 148 max127 148 149 max15301 149 150 max16064 ··· 152 151 max1619 153 152 max16601 154 153 max1668 154 + max17616 155 155 max197 156 156 max20730 157 157 max20751 ··· 179 177 mp2869 180 178 mp2888 181 179 mp2891 180 + mp2925 182 181 mp29502 183 182 mp2975 184 183 mp2993 ··· 187 184 mp5920 188 185 mp5990 189 186 mp9941 187 + mp9945 190 188 mpq8785 191 189 nct6683 192 190 nct6775 ··· 257 253 tps40422 258 254 tps53679 259 255 tps546d24 256 + tsc1641 260 257 twl4030-madc-hwmon 261 258 ucd9000 262 259 ucd9200
+10
Documentation/hwmon/isl68137.rst
··· 414 414 415 415 Publicly available (after August 2020 launch) at the Renesas website 416 416 417 + * Renesas RAA229141 418 + 419 + Prefix: 'raa229141' 420 + 421 + Addresses scanned: - 422 + 423 + Datasheet: 424 + 425 + Provided by Renesas upon request and NDA 426 + 417 427 Authors: 418 428 - Maxim Sloyko <maxims@google.com> 419 429 - Robert Lippert <rlippert@google.com>
+1 -1
Documentation/hwmon/jc42.rst
··· 33 33 34 34 Datasheets: 35 35 36 - http://datasheets.maxim-ic.com/en/ds/MAX6604.pdf 36 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6604.pdf 37 37 38 38 * Microchip MCP9804, MCP9805, MCP9808, MCP98242, MCP98243, MCP98244, MCP9843 39 39
+8 -5
Documentation/hwmon/lm75.rst
··· 23 23 24 24 http://www.national.com/ 25 25 26 - * Dallas Semiconductor (now Maxim) DS75, DS1775, DS7505 26 + * Dallas Semiconductor (now Analog Devices) DS75, DS1775, DS7505 27 27 28 28 Prefixes: 'ds75', 'ds1775', 'ds7505' 29 29 30 30 Addresses scanned: none 31 31 32 - Datasheet: Publicly available at the Maxim website 32 + Datasheets: 33 33 34 - https://www.maximintegrated.com/ 34 + https://www.analog.com/media/en/technical-documentation/data-sheets/DS75.pdf 35 + https://www.analog.com/media/en/technical-documentation/data-sheets/DS1775.pdf 36 + https://www.analog.com/media/en/technical-documentation/data-sheets/DS7505.pdf 35 37 36 38 * Maxim MAX6625, MAX6626, MAX31725, MAX31726 37 39 ··· 41 39 42 40 Addresses scanned: none 43 41 44 - Datasheet: Publicly available at the Maxim website 42 + Datasheets: 45 43 46 - http://www.maxim-ic.com/ 44 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6625-MAX6626.pdf 45 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31725-MAX31726.pdf 47 46 48 47 * Microchip (TelCom) TCN75 49 48
+73 -54
Documentation/hwmon/lm90.rst
··· 9 9 10 10 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 11 11 12 - Datasheet: Publicly available at the National Semiconductor website 12 + Datasheet: Publicly available at the TI website 13 + 14 + https://www.ti.com/lit/ds/symlink/lm84.pdf 13 15 14 16 * National Semiconductor LM90 15 17 ··· 19 17 20 18 Addresses scanned: I2C 0x4c 21 19 22 - Datasheet: Publicly available at the National Semiconductor website 20 + Datasheet: Publicly available at the TI website 23 21 24 - http://www.national.com/pf/LM/LM90.html 22 + https://www.ti.com/lit/ds/symlink/lm90.pdf 25 23 26 24 * National Semiconductor LM89 27 25 ··· 29 27 30 28 Addresses scanned: I2C 0x4c and 0x4d 31 29 32 - Datasheet: Publicly available at the National Semiconductor website 30 + Datasheet: Publicly available at the TI website 33 31 34 - http://www.national.com/mpf/LM/LM89.html 32 + https://www.ti.com/lit/ds/symlink/lm89.pdf 35 33 36 34 * National Semiconductor LM99 37 35 ··· 39 37 40 38 Addresses scanned: I2C 0x4c and 0x4d 41 39 42 - Datasheet: Publicly available at the National Semiconductor website 40 + Datasheet: Publicly available at the TI website 43 41 44 - http://www.national.com/pf/LM/LM99.html 42 + https://www.ti.com/lit/ds/symlink/lm99.pdf 45 43 46 44 * National Semiconductor LM86 47 45 ··· 49 47 50 48 Addresses scanned: I2C 0x4c 51 49 52 - Datasheet: Publicly available at the National Semiconductor website 50 + Datasheet: Publicly available at the TI website 53 51 54 - http://www.national.com/mpf/LM/LM86.html 52 + https://www.ti.com/lit/ds/symlink/lm86.pdf 55 53 56 54 * Analog Devices ADM1020 57 55 ··· 59 57 60 58 Addresses scanned: I2C 0x4c - 0x4e 61 59 62 - Datasheet: Publicly available at the Analog Devices website 60 + Datasheet: Publicly available at the DigiKey website 61 + 62 + https://media.digikey.com/pdf/Data%20Sheets/Analog%20Devices%20PDFs/ADM1020.pdf 63 63 64 64 * Analog Devices ADM1021 65 65 ··· 69 65 70 66 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 71 67 72 - Datasheet: Publicly available at the Analog Devices website 68 + Datasheet: Publicly available at the DigiKey website 69 + 70 + https://media.digikey.com/pdf/Data%20Sheets/Analog%20Devices%20PDFs/ADM1021.pdf 73 71 74 72 * Analog Devices ADM1021A/ADM1023 75 73 ··· 81 75 82 76 Datasheet: Publicly available at the Analog Devices website 83 77 78 + https://media.digikey.com/pdf/Data%20Sheets/Analog%20Devices%20PDFs/ADM1021A.pdf 79 + https://media.digikey.com/pdf/Data%20Sheets/Analog%20Devices%20PDFs/ADM1023.pdf 80 + 84 81 * Analog Devices ADM1032 85 82 86 83 Prefix: 'adm1032' 87 84 88 85 Addresses scanned: I2C 0x4c and 0x4d 89 86 90 - Datasheet: Publicly available at the ON Semiconductor website 87 + Datasheet: Publicly available at the DigiKey website 91 88 92 - https://www.onsemi.com/PowerSolutions/product.do?id=ADM1032 89 + https://www.digikey.com/htmldatasheets/production/53140/0/0/1/ADM1032.pdf 93 90 94 91 * Analog Devices ADT7461 95 92 ··· 120 111 121 112 Addresses scanned: I2C 0x4b and 0x4c 122 113 123 - Datasheet: Publicly available at the ON Semiconductor website 114 + Datasheet: Publicly available at the DigiKey website 124 115 125 - https://www.onsemi.com/PowerSolutions/product.do?id=ADT7481 116 + https://www.digikey.com/htmldatasheets/production/234607/0/0/1/ADT7481.pdf 126 117 127 118 * Analog Devices ADT7482 128 119 ··· 200 191 201 192 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 202 193 203 - Datasheet: Publicly available at the Maxim website 194 + Datasheet: Publicly available at the Analog Devices website 195 + 196 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX1617.pdf 204 197 205 198 * Maxim MAX1617A 206 199 ··· 210 199 211 200 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 212 201 213 - Datasheet: Publicly available at the Maxim website 202 + Datasheet: Publicly available at the Analog Devices website 203 + 204 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX1617A.pdf 214 205 215 206 * Maxim MAX6642 216 207 ··· 220 207 221 208 Addresses scanned: I2C 0x48-0x4f 222 209 223 - Datasheet: Publicly available at the Maxim website 210 + Datasheet: Publicly available at the Analog Devices website 224 211 225 - http://datasheets.maxim-ic.com/en/ds/MAX6642.pdf 212 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6642.pdf 226 213 227 214 * Maxim MAX6646 228 215 ··· 230 217 231 218 Addresses scanned: I2C 0x4d 232 219 233 - Datasheet: Publicly available at the Maxim website 220 + Datasheet: Publicly available at the Analog Devices website 234 221 235 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3497 222 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6646-MAX6649.pdf 236 223 237 224 * Maxim MAX6647 238 225 ··· 240 227 241 228 Addresses scanned: I2C 0x4e 242 229 243 - Datasheet: Publicly available at the Maxim website 230 + Datasheet: Publicly available at the Analog Devices website 244 231 245 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3497 232 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6646-MAX6649.pdf 246 233 247 234 * Maxim MAX6648 248 235 ··· 250 237 251 238 Addresses scanned: I2C 0x4c 252 239 253 - Datasheet: Publicly available at the Maxim website 240 + Datasheet: Publicly available at the Analog Devices website 254 241 255 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3500 242 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6648-MAX6692.pdf 256 243 257 244 * Maxim MAX6649 258 245 ··· 260 247 261 248 Addresses scanned: I2C 0x4c 262 249 263 - Datasheet: Publicly available at the Maxim website 250 + Datasheet: Publicly available at the Analog Devices website 264 251 265 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3497 252 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX1617.pdf 266 253 267 254 * Maxim MAX6654 268 255 ··· 272 259 273 260 0x4c, 0x4d and 0x4e 274 261 275 - Datasheet: Publicly available at the Maxim website 262 + Datasheet: Publicly available at the Analog Devices website 276 263 277 - https://www.maximintegrated.com/en/products/sensors/MAX6654.html 264 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6654.pdf 278 265 279 266 * Maxim MAX6657 280 267 ··· 282 269 283 270 Addresses scanned: I2C 0x4c 284 271 285 - Datasheet: Publicly available at the Maxim website 272 + Datasheet: Publicly available at the Analog Devices website 286 273 287 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 274 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6657-MAX6659.pdf 288 275 289 276 * Maxim MAX6658 290 277 ··· 292 279 293 280 Addresses scanned: I2C 0x4c 294 281 295 - Datasheet: Publicly available at the Maxim website 282 + Datasheet: Publicly available at the Analog Devices website 296 283 297 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 284 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6657-MAX6659.pdf 298 285 299 286 * Maxim MAX6659 300 287 ··· 302 289 303 290 Addresses scanned: I2C 0x4c, 0x4d, 0x4e 304 291 305 - Datasheet: Publicly available at the Maxim website 292 + Datasheet: Publicly available at the Analog Devices website 306 293 307 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 294 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6657-MAX6659.pdf 308 295 309 296 * Maxim MAX6680 310 297 ··· 314 301 315 302 0x4c, 0x4d and 0x4e 316 303 317 - Datasheet: Publicly available at the Maxim website 304 + Datasheet: Publicly available at the Analog Devices website 318 305 319 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3370 306 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6680-MAX6681.pdf 320 307 321 308 * Maxim MAX6681 322 309 ··· 326 313 327 314 0x4c, 0x4d and 0x4e 328 315 329 - Datasheet: Publicly available at the Maxim website 316 + Datasheet: Publicly available at the Analog Devices website 330 317 331 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3370 318 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6680-MAX6681.pdf 332 319 333 320 * Maxim MAX6692 334 321 ··· 336 323 337 324 Addresses scanned: I2C 0x4c 338 325 339 - Datasheet: Publicly available at the Maxim website 326 + Datasheet: Publicly available at the Analog Devices website 340 327 341 - http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3500 328 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6648-MAX6692.pdf 342 329 343 330 * Maxim MAX6695 344 331 ··· 346 333 347 334 Addresses scanned: I2C 0x18 348 335 349 - Datasheet: Publicly available at the Maxim website 336 + Datasheet: Publicly available at the Analog Devices website 350 337 351 - http://www.maxim-ic.com/datasheet/index.mvp/id/4199 338 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6695-MAX6696.pdf 352 339 353 340 * Maxim MAX6696 354 341 ··· 358 345 359 346 0x4c, 0x4d and 0x4e 360 347 361 - Datasheet: Publicly available at the Maxim website 348 + Datasheet: Publicly available at the Analog Devices website 362 349 363 - http://www.maxim-ic.com/datasheet/index.mvp/id/4199 350 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6695-MAX6696.pdf 364 351 365 352 * Winbond/Nuvoton W83L771W/G 366 353 ··· 368 355 369 356 Addresses scanned: I2C 0x4c 370 357 371 - Datasheet: No longer available 358 + Datasheet: Publicly available at the DigiKey website 359 + 360 + https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/1128/W83L771W%2CW83L771G.pdf 372 361 373 362 * Winbond/Nuvoton W83L771AWG/ASG 374 363 ··· 396 381 397 382 Datasheet: Publicly available at Nuvoton website 398 383 399 - https://www.nuvoton.com/resource-files/Nuvoton_NCT7717U_Datasheet_V111.pdf 384 + https://www.nuvoton.com/resource-files/Nuvoton_NCT7717U_Datasheet_V111.pdf 400 385 401 386 * Nuvoton NCT7718 402 387 ··· 406 391 407 392 Datasheet: Publicly available at Nuvoton website 408 393 409 - https://www.nuvoton.com/resource-files/Nuvoton_NCT7718W_Datasheet_V11.pdf 394 + https://www.nuvoton.com/resource-files/Nuvoton_NCT7718W_Datasheet_V11.pdf 410 395 411 396 * Philips/NXP SA56004X 412 397 ··· 416 401 417 402 Datasheet: Publicly available at NXP website 418 403 419 - http://ics.nxp.com/products/interface/datasheet/sa56004x.pdf 404 + https://www.nxp.com/docs/en/data-sheet/SA56004X.pdf 420 405 421 406 * GMT G781 422 407 ··· 452 437 453 438 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 454 439 455 - Datasheets: Publicly available at the Philips website 440 + Datasheets: Publicly available at the DigiKey website 441 + 442 + https://www.digikey.com/htmldatasheets/production/97606/0/0/1/ne1617.pdf 456 443 457 444 * Philips NE1618 458 445 ··· 462 445 463 446 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 464 447 465 - Datasheets: Publicly available at the Philips website 448 + Datasheets: Publicly available at the DigiKey website 449 + 450 + https://media.digikey.com/pdf/Data%20Sheets/NXP%20PDFs/NE1618.pdf 466 451 467 452 * Genesys Logic GL523SM 468 453 ··· 472 453 473 454 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 474 455 475 - Datasheet: 456 + Datasheet: No longer available at Genesys Logic website 476 457 477 458 * TI THMC10 478 459 ··· 480 461 481 462 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 482 463 483 - Datasheet: Publicly available at the TI website 464 + Datasheet: No longer available at the TI website 484 465 485 466 * Onsemi MC1066 486 467 ··· 488 469 489 470 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 490 471 491 - Datasheet: Publicly available at the Onsemi website 472 + Datasheet: No longer available at the Onsemi website 492 473 493 474 Author: Jean Delvare <jdelvare@suse.de> 494 475
+71
Documentation/hwmon/macsmc-hwmon.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0-only 2 + 3 + Kernel driver macsmc-hwmon 4 + ========================== 5 + 6 + Supported hardware 7 + 8 + * Apple Silicon Macs (M1 and up) 9 + 10 + Author: James Calligeros <jcalligeros99@gmail.com> 11 + 12 + Description 13 + ----------- 14 + 15 + macsmc-hwmon exposes the Apple System Management controller's 16 + temperature, voltage, current and power sensors, as well as 17 + fan speed and control capabilities, via hwmon. 18 + 19 + Because each Apple Silicon Mac exposes a different set of sensors 20 + (e.g. the MacBooks expose battery telemetry that is not present on 21 + the desktop Macs), sensors present on any given machine are described 22 + via Devicetree. The driver picks these up and registers them with 23 + hwmon when probed. 24 + 25 + Manual fan speed is supported via the fan_control module parameter. This 26 + is disabled by default and marked as unsafe, as it cannot be proven that 27 + the system will fail safe if overheating due to manual fan control being 28 + used. 29 + 30 + sysfs interface 31 + --------------- 32 + 33 + currX_input 34 + Ammeter value 35 + 36 + currX_label 37 + Ammeter label 38 + 39 + fanX_input 40 + Current fan speed 41 + 42 + fanX_label 43 + Fan label 44 + 45 + fanX_min 46 + Minimum possible fan speed 47 + 48 + fanX_max 49 + Maximum possible fan speed 50 + 51 + fanX_target 52 + Current fan setpoint 53 + 54 + inX_input 55 + Voltmeter value 56 + 57 + inX_label 58 + Voltmeter label 59 + 60 + powerX_input 61 + Power meter value 62 + 63 + powerX_label 64 + Power meter label 65 + 66 + tempX_input 67 + Temperature sensor value 68 + 69 + tempX_label 70 + Temperature sensor label 71 +
+1 -1
Documentation/hwmon/max127.rst
··· 13 13 14 14 Prefix: 'max127' 15 15 16 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX127-MAX128.pdf 16 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max127-max128.pdf 17 17 18 18 Description 19 19 -----------
+1 -1
Documentation/hwmon/max15301.rst
··· 11 11 12 12 Addresses scanned: - 13 13 14 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX15301.pdf 14 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max15301.pdf 15 15 16 16 * Maxim MAX15303 17 17
+1 -1
Documentation/hwmon/max16064.rst
··· 9 9 10 10 Addresses scanned: - 11 11 12 - Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX16064.pdf 12 + Datasheet: https://www.digikey.com/en/htmldatasheets/production/701833/0/0/1/max16064 13 13 14 14 Author: Guenter Roeck <linux@roeck-us.net> 15 15
+4 -4
Documentation/hwmon/max16065.rst
··· 12 12 13 13 Datasheet: 14 14 15 - http://datasheets.maxim-ic.com/en/ds/MAX16065-MAX16066.pdf 15 + https://www.analog.com/media/en/technical-documentation/data-sheets/max16065-max16066.pdf 16 16 17 17 * Maxim MAX16067 18 18 ··· 22 22 23 23 Datasheet: 24 24 25 - http://datasheets.maxim-ic.com/en/ds/MAX16067.pdf 25 + https://www.analog.com/media/en/technical-documentation/data-sheets/max16067.pdf 26 26 27 27 * Maxim MAX16068 28 28 ··· 32 32 33 33 Datasheet: 34 34 35 - http://datasheets.maxim-ic.com/en/ds/MAX16068.pdf 35 + https://www.analog.com/media/en/technical-documentation/data-sheets/max16068.pdf 36 36 37 37 * Maxim MAX16070/MAX16071 38 38 ··· 42 42 43 43 Datasheet: 44 44 45 - http://datasheets.maxim-ic.com/en/ds/MAX16070-MAX16071.pdf 45 + https://www.analog.com/media/en/technical-documentation/data-sheets/max16070-max16071.pdf 46 46 47 47 Author: Guenter Roeck <linux@roeck-us.net> 48 48
+2 -2
Documentation/hwmon/max1619.rst
··· 9 9 10 10 Addresses scanned: I2C 0x18-0x1a, 0x29-0x2b, 0x4c-0x4e 11 11 12 - Datasheet: Publicly available at the Maxim website 12 + Datasheet: 13 13 14 - http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf 14 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX1619.pdf 15 15 16 16 Authors: 17 17 - Oleksij Rempel <bug-track@fisher-privat.net>,
+1 -1
Documentation/hwmon/max16601.rst
··· 35 35 36 36 Addresses scanned: - 37 37 38 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX16602.pdf 38 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max16602.pdf 39 39 40 40 Author: Guenter Roeck <linux@roeck-us.net> 41 41
+1 -1
Documentation/hwmon/max1668.rst
··· 9 9 10 10 Addresses scanned: I2C 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e 11 11 12 - Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX1668-MAX1989.pdf 12 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX1668-MAX1989.pdf 13 13 14 14 Author: 15 15
+62
Documentation/hwmon/max17616.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Kernel driver max17616 4 + ====================== 5 + 6 + Supported chips: 7 + 8 + * Analog Devices MAX17616/MAX17616A 9 + 10 + Prefix: 'max17616' 11 + 12 + Addresses scanned: - 13 + 14 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max17616-max17616a.pdf 15 + 16 + Author: 17 + 18 + - Kim Seer Paller <kimseer.paller@analog.com> 19 + 20 + 21 + Description 22 + ----------- 23 + 24 + This driver supports hardware monitoring for Analog Devices MAX17616/MAX17616A 25 + Current-Limiter with OV/Surge, UV, Reverse Polarity, Loss of Ground Protection 26 + with PMBus Interface. 27 + 28 + The MAX17616/MAX17616A is a 3V to 80V, 7A current-limiter with overvoltage, 29 + surge, undervoltage, reverse polarity, and loss of ground protection. Through 30 + the PMBus interface, the device can monitor input/output voltages, output current 31 + and temperature. 32 + 33 + The driver is a client driver to the core PMBus driver. Please see 34 + Documentation/hwmon/pmbus.rst for details on PMBus client drivers. 35 + 36 + Usage Notes 37 + ----------- 38 + 39 + This driver does not auto-detect devices. You will have to instantiate 40 + the devices explicitly. Please see Documentation/i2c/instantiating-devices.rst 41 + for details. 42 + 43 + Platform data support 44 + --------------------- 45 + 46 + The driver supports standard PMBus driver platform data. 47 + 48 + Sysfs entries 49 + ------------- 50 + 51 + ================= ======================================== 52 + in1_label "vin" 53 + in1_input Measured input voltage 54 + in1_alarm Input voltage alarm 55 + in2_label "vout1" 56 + in2_input Measured output voltage 57 + curr1_label "iout1" 58 + curr1_input Measured output current. 59 + curr1_alarm Output current alarm 60 + temp1_input Measured temperature 61 + temp1_alarm Chip temperature alarm 62 + ================= ========================================
+2 -2
Documentation/hwmon/max197.rst
··· 11 11 12 12 Prefix: 'max197' 13 13 14 - Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX197.pdf 14 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX197.pdf 15 15 16 16 * Maxim MAX199 17 17 18 18 Prefix: 'max199' 19 19 20 - Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX199.pdf 20 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX199.pdf 21 21 22 22 Description 23 23 -----------
+4 -4
Documentation/hwmon/max20730.rst
··· 11 11 12 12 Addresses scanned: - 13 13 14 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX20710.pdf 14 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max20710.pdf 15 15 16 16 * Maxim MAX20730 17 17 ··· 19 19 20 20 Addresses scanned: - 21 21 22 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX20730.pdf 22 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max20730.pdf 23 23 24 24 * Maxim MAX20734 25 25 ··· 27 27 28 28 Addresses scanned: - 29 29 30 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX20734.pdf 30 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max20734.pdf 31 31 32 32 * Maxim MAX20743 33 33 ··· 35 35 36 36 Addresses scanned: - 37 37 38 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX20743.pdf 38 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max20743.pdf 39 39 40 40 Author: Guenter Roeck <linux@roeck-us.net> 41 41
+2 -2
Documentation/hwmon/max31722.rst
··· 11 11 12 12 Addresses scanned: - 13 13 14 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX31722-MAX31723.pdf 14 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max31722-max31723.pdf 15 15 16 16 * Maxim Integrated MAX31723 17 17 ··· 21 21 22 22 Addresses scanned: - 23 23 24 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX31722-MAX31723.pdf 24 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max31722-max31723.pdf 25 25 26 26 Author: Tiberiu Breana <tiberiu.a.breana@intel.com> 27 27
+1 -1
Documentation/hwmon/max31730.rst
··· 9 9 10 10 Addresses scanned: 0x1c, 0x1d, 0x1e, 0x1f, 0x4c, 0x4d, 0x4e, 0x4f 11 11 12 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX31730.pdf 12 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max31730.pdf 13 13 14 14 Author: Guenter Roeck <linux@roeck-us.net> 15 15
+1 -1
Documentation/hwmon/max31785.rst
··· 9 9 10 10 Addresses scanned: - 11 11 12 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX31785.pdf 12 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max31785.pdf 13 13 14 14 Author: Andrew Jeffery <andrew@aj.id.au> 15 15
+1 -1
Documentation/hwmon/max31790.rst
··· 9 9 10 10 Addresses scanned: - 11 11 12 - Datasheet: https://pdfserv.maximintegrated.com/en/ds/MAX31790.pdf 12 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31790.pdf 13 13 14 14 Author: Il Han <corone.il.han@gmail.com> 15 15
+3 -3
Documentation/hwmon/max31827.rst
··· 11 11 12 12 Addresses scanned: I2C 0x40 - 0x5f 13 13 14 - Datasheet: Publicly available at the Analog Devices website 14 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31827-MAX31829.pdf 15 15 16 16 * Maxim MAX31828 17 17 ··· 19 19 20 20 Addresses scanned: I2C 0x40 - 0x5f 21 21 22 - Datasheet: Publicly available at the Analog Devices website 22 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31827-MAX31829.pdf 23 23 24 24 * Maxim MAX31829 25 25 ··· 27 27 28 28 Addresses scanned: I2C 0x40 - 0x5f 29 29 30 - Datasheet: Publicly available at the Analog Devices website 30 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31827-MAX31829.pdf 31 31 32 32 33 33 Authors:
+24 -13
Documentation/hwmon/max34440.rst
··· 11 11 12 12 Datasheet: - 13 13 14 + * ADI ADPM12200 15 + 16 + Prefixes: 'adpm12200' 17 + 18 + Addresses scanned: - 19 + 20 + Datasheet: - 21 + 14 22 * Maxim MAX34440 15 23 16 24 Prefixes: 'max34440' 17 25 18 26 Addresses scanned: - 19 27 20 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX34440.pdf 28 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max34440.pdf 21 29 22 30 * Maxim MAX34441 23 31 ··· 35 27 36 28 Addresses scanned: - 37 29 38 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX34441.pdf 30 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max34441.pdf 39 31 40 32 * Maxim MAX34446 41 33 ··· 45 37 46 38 Addresses scanned: - 47 39 48 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX34446.pdf 40 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max34446.pdf 49 41 50 42 * Maxim MAX34451 51 43 ··· 55 47 56 48 Addresses scanned: - 57 49 58 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX34451.pdf 50 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max34451.pdf 59 51 60 52 * Maxim MAX34460 61 53 ··· 65 57 66 58 Addresses scanned: - 67 59 68 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX34460.pdf 60 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max34460.pdf 69 61 70 62 * Maxim MAX34461 71 63 ··· 75 67 76 68 Addresses scanned: - 77 69 78 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX34461.pdf 70 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max34461.pdf 79 71 80 72 Author: Guenter Roeck <linux@roeck-us.net> 81 73 ··· 87 79 PMBus 6-Channel Power-Supply Manager, MAX34441 PMBus 5-Channel Power-Supply 88 80 Manager and Intelligent Fan Controller, and MAX34446 PMBus Power-Supply Data 89 81 Logger; PMBus Voltage Monitor and Sequencers for MAX34451, MAX34460, and 90 - MAX34461; PMBus DC/DC Power Module ADPM12160. The MAX34451 supports monitoring 91 - voltage or current of 12 channels based on GIN pins. The MAX34460 supports 12 92 - voltage channels, and the MAX34461 supports 16 voltage channels. The ADPM1260 93 - also monitors both input and output of voltage and current. 82 + MAX34461; PMBus DC/DC Power Module ADPM12160, and ADPM12200. The MAX34451 83 + supports monitoring voltage or current of 12 channels based on GIN pins. The 84 + MAX34460 supports 12 voltage channels, and the MAX34461 supports 16 voltage 85 + channels. The ADPM12160, and ADPM12200 also monitors both input and output 86 + of voltage and current. 94 87 95 88 The driver is a client driver to the core PMBus driver. Please see 96 89 Documentation/hwmon/pmbus.rst for details on PMBus client drivers. ··· 149 140 .. note:: 150 141 151 142 - MAX34446 only supports in[1-4]. 152 - - ADPM12160 only supports in[1-2]. Label is "vin1" and "vout1" respectively. 143 + - ADPM12160, and ADPM12200 only supports in[1-2]. Label is "vin1" 144 + and "vout1" respectively. 153 145 154 146 Curr 155 147 ~~~~ ··· 172 162 173 163 - in6 and curr6 attributes only exist for MAX34440. 174 164 - MAX34446 only supports curr[1-4]. 175 - - For ADPM12160, curr[1] is "iin1" and curr[2-6] are "iout[1-5]. 165 + - For ADPM12160, and ADPM12200, curr[1] is "iin1" and curr[2-6] 166 + are "iout[1-5]". 176 167 177 168 Power 178 169 ~~~~~ ··· 209 198 .. note:: 210 199 - temp7 and temp8 attributes only exist for MAX34440. 211 200 - MAX34446 only supports temp[1-3]. 212 - - ADPM12160 only supports temp[1]. 201 + - ADPM12160, and ADPM12200 only supports temp[1]. 213 202 214 203 215 204 .. note::
+1 -1
Documentation/hwmon/max6639.rst
··· 9 9 10 10 Addresses scanned: I2C 0x2c, 0x2e, 0x2f 11 11 12 - Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf 12 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6639-max6639f.pdf 13 13 14 14 Authors: 15 15 - He Changqing <hechangqing@semptian.com>
+2 -2
Documentation/hwmon/max6650.rst
··· 9 9 10 10 Addresses scanned: none 11 11 12 - Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf 12 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6650-MAX6651.pdf 13 13 14 14 * Maxim MAX6651 15 15 ··· 17 17 18 18 Addresses scanned: none 19 19 20 - Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf 20 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX6650-MAX6651.pdf 21 21 22 22 Authors: 23 23 - Hans J. Koch <hjk@hansjkoch.de>
+10 -10
Documentation/hwmon/max6697.rst
··· 7 7 8 8 Prefix: 'max6581' 9 9 10 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6581.pdf 10 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6581.pdf 11 11 12 12 * Maxim MAX6602 13 13 14 14 Prefix: 'max6602' 15 15 16 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6602.pdf 16 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6602.pdf 17 17 18 18 * Maxim MAX6622 19 19 20 20 Prefix: 'max6622' 21 21 22 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6622.pdf 22 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6622.pdf 23 23 24 24 * Maxim MAX6636 25 25 26 26 Prefix: 'max6636' 27 27 28 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6636.pdf 28 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6636.pdf 29 29 30 30 * Maxim MAX6689 31 31 32 32 Prefix: 'max6689' 33 33 34 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6689.pdf 34 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6689.pdf 35 35 36 36 * Maxim MAX6693 37 37 38 38 Prefix: 'max6693' 39 39 40 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6693.pdf 40 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6693.pdf 41 41 42 42 * Maxim MAX6694 43 43 44 44 Prefix: 'max6694' 45 45 46 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6694.pdf 46 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6694.pdf 47 47 48 48 * Maxim MAX6697 49 49 50 50 Prefix: 'max6697' 51 51 52 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6697.pdf 52 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6697.pdf 53 53 54 54 * Maxim MAX6698 55 55 56 56 Prefix: 'max6698' 57 57 58 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6698.pdf 58 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6698.pdf 59 59 60 60 * Maxim MAX6699 61 61 62 62 Prefix: 'max6699' 63 63 64 - Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX6699.pdf 64 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6699.pdf 65 65 66 66 Author: 67 67
+3 -1
Documentation/hwmon/max77705.rst
··· 11 11 12 12 Addresses scanned: none 13 13 14 - Datasheet: Not available 14 + Datasheet: 15 + 16 + https://www.analog.com/media/en/technical-documentation/data-sheets/max77505.pdf 15 17 16 18 Authors: 17 19 - Dzmitry Sankouski <dsankouski@gmail.com>
+1 -1
Documentation/hwmon/max8688.rst
··· 9 9 10 10 Addresses scanned: - 11 11 12 - Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX8688.pdf 12 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max8688.pdf 13 13 14 14 Author: Guenter Roeck <linux@roeck-us.net> 15 15
+151
Documentation/hwmon/mp2925.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Kernel driver mp2925 4 + ==================== 5 + 6 + Supported chips: 7 + 8 + * MPS mp2925 9 + 10 + Prefix: 'mp2925' 11 + 12 + * MPS mp2929 13 + 14 + Prefix: 'mp2929' 15 + 16 + Author: 17 + 18 + Wensheng Wang <wenswang@yeah.net> 19 + 20 + Description 21 + ----------- 22 + 23 + This driver implements support for Monolithic Power Systems, Inc. (MPS) 24 + MP2925 Dual Loop Digital Multi-phase Controller. 25 + 26 + Device compliant with: 27 + 28 + - PMBus rev 1.3 interface. 29 + 30 + The driver exports the following attributes via the 'sysfs' files 31 + for input voltage: 32 + 33 + **in1_input** 34 + 35 + **in1_label** 36 + 37 + **in1_crit** 38 + 39 + **in1_crit_alarm** 40 + 41 + **in1_lcrit** 42 + 43 + **in1_lcrit_alarm** 44 + 45 + **in1_max** 46 + 47 + **in1_max_alarm** 48 + 49 + **in1_min** 50 + 51 + **in1_min_alarm** 52 + 53 + The driver provides the following attributes for output voltage: 54 + 55 + **in2_input** 56 + 57 + **in2_label** 58 + 59 + **in2_crit** 60 + 61 + **in2_crit_alarm** 62 + 63 + **in2_lcrit** 64 + 65 + **in2_lcrit_alarm** 66 + 67 + **in3_input** 68 + 69 + **in3_label** 70 + 71 + **in3_crit** 72 + 73 + **in3_crit_alarm** 74 + 75 + **in3_lcrit** 76 + 77 + **in3_lcrit_alarm** 78 + 79 + The driver provides the following attributes for input current: 80 + 81 + **curr1_input** 82 + 83 + **curr1_label** 84 + 85 + The driver provides the following attributes for output current: 86 + 87 + **curr2_input** 88 + 89 + **curr2_label** 90 + 91 + **curr2_crit** 92 + 93 + **curr2_crit_alarm** 94 + 95 + **curr2_max** 96 + 97 + **curr2_max_alarm** 98 + 99 + **curr3_input** 100 + 101 + **curr3_label** 102 + 103 + **curr3_crit** 104 + 105 + **curr3_crit_alarm** 106 + 107 + **curr3_max** 108 + 109 + **curr3_max_alarm** 110 + 111 + The driver provides the following attributes for input power: 112 + 113 + **power1_input** 114 + 115 + **power1_label** 116 + 117 + **power2_input** 118 + 119 + **power2_label** 120 + 121 + The driver provides the following attributes for output power: 122 + 123 + **power3_input** 124 + 125 + **power3_label** 126 + 127 + **power4_input** 128 + 129 + **power4_label** 130 + 131 + The driver provides the following attributes for temperature: 132 + 133 + **temp1_input** 134 + 135 + **temp1_crit** 136 + 137 + **temp1_crit_alarm** 138 + 139 + **temp1_max** 140 + 141 + **temp1_max_alarm** 142 + 143 + **temp2_input** 144 + 145 + **temp2_crit** 146 + 147 + **temp2_crit_alarm** 148 + 149 + **temp2_max** 150 + 151 + **temp2_max_alarm**
+117
Documentation/hwmon/mp9945.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Kernel driver mp9945 4 + ===================== 5 + 6 + Supported chips: 7 + 8 + * MPS mp9945 9 + 10 + Prefix: 'mp9945' 11 + 12 + Author: 13 + 14 + Cosmo Chou <chou.cosmo@gmail.com> 15 + 16 + Description 17 + ----------- 18 + 19 + This driver implements support for Monolithic Power Systems, Inc. (MPS) 20 + MP9945 Digital Single-phase Controller. 21 + 22 + Device compliant with: 23 + 24 + - PMBus rev 1.3 interface. 25 + 26 + The driver exports the following attributes via the 'sysfs' files 27 + for input voltage: 28 + 29 + **in1_input** 30 + 31 + **in1_label** 32 + 33 + **in1_crit** 34 + 35 + **in1_crit_alarm** 36 + 37 + **in1_lcrit** 38 + 39 + **in1_lcrit_alarm** 40 + 41 + **in1_max** 42 + 43 + **in1_max_alarm** 44 + 45 + **in1_min** 46 + 47 + **in1_min_alarm** 48 + 49 + The driver provides the following attributes for output voltage: 50 + 51 + **in2_input** 52 + 53 + **in2_label** 54 + 55 + **in2_crit** 56 + 57 + **in2_crit_alarm** 58 + 59 + **in2_lcrit** 60 + 61 + **in2_lcrit_alarm** 62 + 63 + **in2_min** 64 + 65 + **in2_min_alarm** 66 + 67 + The driver provides the following attributes for input current: 68 + 69 + **curr1_input** 70 + 71 + **curr1_label** 72 + 73 + **curr1_max** 74 + 75 + **curr1_max_alarm** 76 + 77 + The driver provides the following attributes for output current: 78 + 79 + **curr2_input** 80 + 81 + **curr2_label** 82 + 83 + **curr2_crit** 84 + 85 + **curr2_crit_alarm** 86 + 87 + **curr2_max** 88 + 89 + **curr2_max_alarm** 90 + 91 + The driver provides the following attributes for input power: 92 + 93 + **power1_input** 94 + 95 + **power1_label** 96 + 97 + The driver provides the following attributes for output power: 98 + 99 + **power2_input** 100 + 101 + **power2_label** 102 + 103 + **power2_max** 104 + 105 + **power2_max_alarm** 106 + 107 + The driver provides the following attributes for temperature: 108 + 109 + **temp1_input** 110 + 111 + **temp1_crit** 112 + 113 + **temp1_crit_alarm** 114 + 115 + **temp1_max** 116 + 117 + **temp1_max_alarm**
+1 -1
Documentation/hwmon/pmbus.rst
··· 74 74 75 75 Datasheet: 76 76 77 - Not published 77 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX20796.pdf 78 78 79 79 * Generic PMBus devices 80 80
+2 -2
Documentation/hwmon/sy7636a-hwmon.rst
··· 17 17 The following sensors are supported 18 18 19 19 * Temperature 20 - - SoC on-die temperature in milli-degree C 20 + - Temperature of external NTC in milli-degree C 21 21 22 22 sysfs-Interface 23 23 --------------- 24 24 25 25 temp0_input 26 - - SoC on-die temperature (milli-degree C) 26 + - Temperature of external NTC (milli-degree C)
+87
Documentation/hwmon/tsc1641.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0-only 2 + 3 + Kernel driver tsc1641 4 + ===================== 5 + 6 + Supported chips: 7 + 8 + * ST TSC1641 9 + 10 + Prefix: 'tsc1641' 11 + 12 + Addresses scanned: - 13 + 14 + Datasheet: 15 + https://www.st.com/resource/en/datasheet/tsc1641.pdf 16 + 17 + Author: 18 + - Igor Reznichenko <igor@reznichenko.net> 19 + 20 + 21 + Description 22 + ----------- 23 + 24 + The TSC1641 is a high-precision current, voltage, power, and temperature 25 + monitoring analog front-end (AFE). It monitors bidirectional current into a 26 + shunt resistor and load voltage up to 60 V in a synchronized way. Digital bus 27 + interface is I2C/SMbus. The TSC1641 allows the assertion of several alerts 28 + regarding the voltage, current, power and temperature. 29 + 30 + Usage Notes 31 + ----------- 32 + 33 + The TSC1641 driver requires the value of the external shunt resistor to 34 + correctly compute current and power measurements. The resistor value, in 35 + micro-ohms, should be provided either through the device tree property 36 + "shunt-resistor-micro-ohms" or via writable sysfs attribute "shunt_resistor". 37 + Please refer to the Documentation/devicetree/bindings/hwmon/st,tsc1641.yaml 38 + for bindings if the device tree is used. 39 + 40 + Supported range of shunt resistor values is from 100 uOhm to 655.35 mOhm, in 41 + 10 uOhm steps. 42 + When selecting the value keep in mind device maximum DC power measurement is 43 + 1600W. See datasheet p.22 for ST recommendations on selecting shunt value. 44 + 45 + If the shunt resistor value is not specified in the device tree, the driver 46 + initializes it to 1000 uOhm by default. Users may configure the correct shunt 47 + resistor value at runtime by writing to the "shunt_resistor" sysfs attribute. 48 + 49 + The driver only supports continuous operating mode. 50 + Measurement ranges: 51 + 52 + ================ =============================================================== 53 + Current Bidirectional, dependent on shunt 54 + Bus voltage 0-60V 55 + Maximum DC power 1600W 56 + Temperature -40C to +125C 57 + ================ =============================================================== 58 + 59 + Sysfs entries 60 + ------------- 61 + 62 + ==================== =========================================================== 63 + in0_input bus voltage (mV) 64 + in0_max bus voltage max alarm limit (mV) 65 + in0_max_alarm bus voltage max alarm limit exceeded 66 + in0_min bus voltage min alarm limit (mV) 67 + in0_min_alarm bus voltage min alarm limit exceeded 68 + 69 + curr1_input current measurement (mA) 70 + curr1_max current max alarm limit (mA) 71 + curr1_max_alarm current max alarm limit exceeded 72 + curr1_min current min alarm limit (mA) 73 + curr1_min_alarm current min alarm limit exceeded 74 + 75 + power1_input power measurement (uW) 76 + power1_max power max alarm limit (uW) 77 + power1_max_alarm power max alarm limit exceeded 78 + 79 + shunt_resistor shunt resistor value (uOhms) 80 + 81 + temp1_input temperature measurement (mdegC) 82 + temp1_max temperature max alarm limit (mdegC) 83 + temp1_max_alarm temperature max alarm limit exceeded 84 + 85 + update_interval data conversion time (1 - 33ms), longer conversion time 86 + corresponds to higher effective resolution in bits 87 + ==================== ===========================================================
+8 -8
Documentation/hwmon/zl6100.rst
··· 9 9 10 10 Addresses scanned: - 11 11 12 - Datasheet: https://www.renesas.com/us/en/document/dst/zl2004-datasheet.pdf 12 + Datasheet: https://www.renesas.com/us/en/document/dst/zl2004-datasheet 13 13 14 14 * Renesas / Intersil / Zilker Labs ZL2005 15 15 ··· 17 17 18 18 Addresses scanned: - 19 19 20 - Datasheet: https://www.renesas.com/us/en/document/dst/zl2005-datasheet.pdf 20 + Datasheet: https://www.renesas.com/us/en/document/dst/zl2005-datasheet 21 21 22 22 * Renesas / Intersil / Zilker Labs ZL2006 23 23 ··· 25 25 26 26 Addresses scanned: - 27 27 28 - Datasheet: https://www.renesas.com/us/en/document/dst/zl2006-datasheet.pdf 28 + Datasheet: https://www.renesas.com/us/en/document/dst/zl2006-datasheet 29 29 30 30 * Renesas / Intersil / Zilker Labs ZL2008 31 31 ··· 33 33 34 34 Addresses scanned: - 35 35 36 - Datasheet: https://www.renesas.com/us/en/document/dst/zl2008-datasheet.pdf 36 + Datasheet: https://www.renesas.com/us/en/document/dst/zl2008-datasheet 37 37 38 38 * Renesas / Intersil / Zilker Labs ZL2105 39 39 ··· 41 41 42 42 Addresses scanned: - 43 43 44 - Datasheet: https://www.renesas.com/us/en/document/dst/zl2105-datasheet.pdf 44 + Datasheet: https://www.renesas.com/us/en/document/dst/zl2105-datasheet 45 45 46 46 * Renesas / Intersil / Zilker Labs ZL2106 47 47 ··· 49 49 50 50 Addresses scanned: - 51 51 52 - Datasheet: https://www.renesas.com/us/en/document/dst/zl2106-datasheet.pdf 52 + Datasheet: https://www.renesas.com/us/en/document/dst/zl2106-datasheet 53 53 54 54 * Renesas / Intersil / Zilker Labs ZL6100 55 55 ··· 57 57 58 58 Addresses scanned: - 59 59 60 - Datasheet: https://www.renesas.com/us/en/document/dst/zl6100-datasheet.pdf 60 + Datasheet: https://www.renesas.com/us/en/document/dst/zl6100-datasheet 61 61 62 62 * Renesas / Intersil / Zilker Labs ZL6105 63 63 ··· 65 65 66 66 Addresses scanned: - 67 67 68 - Datasheet: https://www.renesas.com/us/en/document/dst/zl6105-datasheet.pdf 68 + Datasheet: https://www.renesas.com/us/en/document/dst/zl6105-datasheet 69 69 70 70 * Renesas / Intersil / Zilker Labs ZL8802 71 71
+33
MAINTAINERS
··· 2468 2468 F: Documentation/devicetree/bindings/spi/apple,spi.yaml 2469 2469 F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml 2470 2470 F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml 2471 + F: Documentation/hwmon/macsmc-hwmon.rst 2471 2472 F: arch/arm64/boot/dts/apple/ 2472 2473 F: drivers/bluetooth/hci_bcm4377.c 2473 2474 F: drivers/clk/clk-apple-nco.c 2474 2475 F: drivers/cpufreq/apple-soc-cpufreq.c 2475 2476 F: drivers/dma/apple-admac.c 2476 2477 F: drivers/gpio/gpio-macsmc.c 2478 + F: drivers/hwmon/macsmc-hwmon.c 2477 2479 F: drivers/pmdomain/apple/ 2478 2480 F: drivers/i2c/busses/i2c-pasemi-core.c 2479 2481 F: drivers/i2c/busses/i2c-pasemi-platform.c ··· 15230 15228 F: Documentation/hwmon/max15301.rst 15231 15229 F: drivers/hwmon/pmbus/max15301.c 15232 15230 15231 + MAX17616 HARDWARE MONITOR DRIVER 15232 + M: Kim Seer Paller <kimseer.paller@analog.com> 15233 + L: linux-hwmon@vger.kernel.org 15234 + S: Supported 15235 + W: https://ez.analog.com/linux-software-drivers 15236 + F: Documentation/devicetree/bindings/hwmon/pmbus/adi,max17616.yaml 15237 + F: Documentation/hwmon/max17616.rst 15238 + F: drivers/hwmon/pmbus/max17616.c 15239 + 15233 15240 MAX2175 SDR TUNER DRIVER 15234 15241 M: Ramesh Shanmugasundaram <rashanmu@gmail.com> 15235 15242 L: linux-media@vger.kernel.org ··· 17556 17545 F: Documentation/hwmon/mp2891.rst 17557 17546 F: drivers/hwmon/pmbus/mp2891.c 17558 17547 17548 + MPS MP2925 DRIVER 17549 + M: Noah Wang <wenswang@yeah.net> 17550 + L: linux-hwmon@vger.kernel.org 17551 + S: Maintained 17552 + F: Documentation/hwmon/mp2925.rst 17553 + F: drivers/hwmon/pmbus/mp2925.c 17554 + 17559 17555 MPS MP29502 DRIVER 17560 17556 M: Wensheng Wang <wenswang@yeah.net> 17561 17557 L: linux-hwmon@vger.kernel.org ··· 17583 17565 S: Maintained 17584 17566 F: Documentation/hwmon/mp9941.rst 17585 17567 F: drivers/hwmon/pmbus/mp9941.c 17568 + 17569 + MPS MP9945 DRIVER 17570 + M: Cosmo Chou <chou.cosmo@gmail.com> 17571 + L: linux-hwmon@vger.kernel.org 17572 + S: Maintained 17573 + F: Documentation/hwmon/mp9945.rst 17574 + F: drivers/hwmon/pmbus/mp9945.c 17586 17575 17587 17576 MR800 AVERMEDIA USB FM RADIO DRIVER 17588 17577 M: Alexey Klimov <alexey.klimov@linaro.org> ··· 24517 24492 S: Maintained 24518 24493 F: Documentation/hwmon/stpddc60.rst 24519 24494 F: drivers/hwmon/pmbus/stpddc60.c 24495 + 24496 + ST TSC1641 DRIVER 24497 + M: Igor Reznichenko <igor@reznichenko.net> 24498 + L: linux-hwmon@vger.kernel.org 24499 + S: Maintained 24500 + F: Documentation/devicetree/bindings/hwmon/st,tsc1641.yaml 24501 + F: Documentation/hwmon/tsc1641.rst 24502 + F: drivers/hwmon/tsc1641.c 24520 24503 24521 24504 ST VD55G1 DRIVER 24522 24505 M: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
+30 -6
drivers/hwmon/Kconfig
··· 175 175 select REGMAP 176 176 help 177 177 This module contains common code shared by the ADT7310/ADT7320 and 178 - ADT7410/ADT7420 temperature monitoring chip drivers. 178 + ADT7410/ADT7420/ADT7422 temperature monitoring chip drivers. 179 179 180 180 If built as a module, the module will be called adt7x10. 181 181 ··· 191 191 will be called adt7310. 192 192 193 193 config SENSORS_ADT7410 194 - tristate "Analog Devices ADT7410/ADT7420" 194 + tristate "Analog Devices ADT7410/ADT7420/ADT7422" 195 195 depends on I2C 196 196 select SENSORS_ADT7X10 197 197 help 198 198 If you say yes here you get support for the Analog Devices 199 - ADT7410 and ADT7420 temperature monitoring chips. 199 + ADT7410, ADT7420 and ADT7422 temperature monitoring chips. 200 200 201 201 This driver can also be built as a module. If so, the module 202 202 will be called adt7410. ··· 245 245 will be called adt7475. 246 246 247 247 config SENSORS_AHT10 248 - tristate "Aosong AHT10, AHT20" 248 + tristate "Aosong AHT10, AHT20, DHT20" 249 249 depends on I2C 250 250 select CRC8 251 251 help 252 - If you say yes here, you get support for the Aosong AHT10 and AHT20 253 - temperature and humidity sensors 252 + If you say yes here, you get support for the Aosong AHT10, AHT20 and 253 + DHT20 temperature and humidity sensors 254 254 255 255 This driver can also be built as a module. If so, the module 256 256 will be called aht10. ··· 1173 1173 help 1174 1174 If you say yes here you get support for the temperature 1175 1175 sensor inside your CPU. 1176 + 1177 + config SENSORS_MACSMC_HWMON 1178 + tristate "Apple SMC (Apple Silicon)" 1179 + depends on MFD_MACSMC && OF 1180 + help 1181 + This driver enables hwmon support for current, power, temperature, 1182 + and voltage sensors, as well as fan speed reporting and control 1183 + on Apple Silicon devices. Say Y here if you have an Apple Silicon 1184 + device. 1185 + 1186 + This driver can also be built as a module. If so, the module will 1187 + be called macsmc-hwmon. 1176 1188 1177 1189 config SENSORS_MAX1111 1178 1190 tristate "Maxim MAX1111 Serial 8-bit ADC chip and compatibles" ··· 2445 2433 2446 2434 This driver can also be built as a module. If so, the module 2447 2435 will be called tmp513. 2436 + 2437 + config SENSORS_TSC1641 2438 + tristate "ST Microelectronics TSC1641 Power Monitor" 2439 + depends on I2C 2440 + select REGMAP_I2C 2441 + help 2442 + If you say yes here you get support for TSC1641 power monitor chip. 2443 + The TSC1641 driver is configured for the default configuration of 2444 + the part except temperature is enabled by default. 2445 + 2446 + This driver can also be built as a module. If so, the module 2447 + will be called tsc1641. 2448 2448 2449 2449 config SENSORS_VEXPRESS 2450 2450 tristate "Versatile Express"
+2
drivers/hwmon/Makefile
··· 148 148 obj-$(CONFIG_SENSORS_LTC4261) += ltc4261.o 149 149 obj-$(CONFIG_SENSORS_LTC4282) += ltc4282.o 150 150 obj-$(CONFIG_SENSORS_LTQ_CPUTEMP) += ltq-cputemp.o 151 + obj-$(CONFIG_SENSORS_MACSMC_HWMON) += macsmc-hwmon.o 151 152 obj-$(CONFIG_SENSORS_MAX1111) += max1111.o 152 153 obj-$(CONFIG_SENSORS_MAX127) += max127.o 153 154 obj-$(CONFIG_SENSORS_MAX16065) += max16065.o ··· 234 233 obj-$(CONFIG_SENSORS_TMP421) += tmp421.o 235 234 obj-$(CONFIG_SENSORS_TMP464) += tmp464.o 236 235 obj-$(CONFIG_SENSORS_TMP513) += tmp513.o 236 + obj-$(CONFIG_SENSORS_TSC1641) += tsc1641.o 237 237 obj-$(CONFIG_SENSORS_VEXPRESS) += vexpress-hwmon.o 238 238 obj-$(CONFIG_SENSORS_VIA_CPUTEMP)+= via-cputemp.o 239 239 obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
+12 -4
drivers/hwmon/adm1026.c
··· 197 197 #define FAN_TO_REG(val, div) ((val) <= 0 ? 0xff : \ 198 198 clamp_val(1350000 / ((val) * (div)), \ 199 199 1, 254)) 200 - #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : (val) == 0xff ? 0 : \ 201 - 1350000 / ((val) * (div))) 200 + 201 + static int fan_from_reg(int val, int div) 202 + { 203 + if (val == 0) 204 + return -1; 205 + if (val == 0xff) 206 + return 0; 207 + return 1350000 / (val * div); 208 + } 209 + 202 210 #define DIV_FROM_REG(val) (1 << (val)) 203 211 #define DIV_TO_REG(val) ((val) >= 8 ? 3 : (val) >= 4 ? 2 : (val) >= 2 ? 1 : 0) 204 212 ··· 664 656 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 665 657 int nr = sensor_attr->index; 666 658 struct adm1026_data *data = adm1026_update_device(dev); 667 - return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], 659 + return sprintf(buf, "%d\n", fan_from_reg(data->fan[nr], 668 660 data->fan_div[nr])); 669 661 } 670 662 static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr, ··· 673 665 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 674 666 int nr = sensor_attr->index; 675 667 struct adm1026_data *data = adm1026_update_device(dev); 676 - return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], 668 + return sprintf(buf, "%d\n", fan_from_reg(data->fan_min[nr], 677 669 data->fan_div[nr])); 678 670 } 679 671 static ssize_t fan_min_store(struct device *dev,
+3
drivers/hwmon/adm1029.c
··· 171 171 struct adm1029_data *data = adm1029_update_device(dev); 172 172 u16 val; 173 173 174 + mutex_lock(&data->update_lock); 174 175 if (data->fan[attr->index] == 0 || 175 176 (data->fan_div[attr->index] & 0xC0) == 0 || 176 177 data->fan[attr->index] == 255) { 178 + mutex_unlock(&data->update_lock); 177 179 return sprintf(buf, "0\n"); 178 180 } 179 181 180 182 val = 1880 * 120 / DIV_FROM_REG(data->fan_div[attr->index]) 181 183 / data->fan[attr->index]; 184 + mutex_unlock(&data->update_lock); 182 185 return sprintf(buf, "%d\n", val); 183 186 } 184 187
+2 -15
drivers/hwmon/adm9240.c
··· 37 37 #include <linux/hwmon.h> 38 38 #include <linux/hwmon-vid.h> 39 39 #include <linux/err.h> 40 - #include <linux/mutex.h> 41 40 #include <linux/regmap.h> 42 41 43 42 /* Addresses to scan */ ··· 124 125 struct adm9240_data { 125 126 struct device *dev; 126 127 struct regmap *regmap; 127 - struct mutex update_lock; 128 128 129 129 u8 fan_div[2]; /* rw fan1_div, read-only accessor */ 130 130 u8 vrm; /* -- vrm set on startup, no accessor */ ··· 168 170 u8 fan_min; 169 171 int err; 170 172 171 - mutex_lock(&data->update_lock); 172 - 173 173 if (!val) { 174 174 fan_min = 255; 175 175 new_div = data->fan_div[channel]; ··· 201 205 adm9240_write_fan_div(data, channel, new_div); 202 206 } 203 207 err = regmap_write(data->regmap, ADM9240_REG_FAN_MIN(channel), fan_min); 204 - 205 - mutex_unlock(&data->update_lock); 206 208 207 209 return err; 208 210 } ··· 495 501 496 502 switch (attr) { 497 503 case hwmon_fan_input: 498 - mutex_lock(&data->update_lock); 499 504 err = regmap_read(data->regmap, ADM9240_REG_FAN(channel), &regval); 500 - if (err < 0) { 501 - mutex_unlock(&data->update_lock); 505 + if (err < 0) 502 506 return err; 503 - } 504 507 if (regval == 255 && data->fan_div[channel] < 3) { 505 508 /* adjust fan clock divider on overflow */ 506 509 err = adm9240_write_fan_div(data, channel, 507 510 ++data->fan_div[channel]); 508 - if (err) { 509 - mutex_unlock(&data->update_lock); 511 + if (err) 510 512 return err; 511 - } 512 513 } 513 514 *val = FAN_FROM_REG(regval, BIT(data->fan_div[channel])); 514 - mutex_unlock(&data->update_lock); 515 515 break; 516 516 case hwmon_fan_div: 517 517 *val = BIT(data->fan_div[channel]); ··· 779 791 return -ENOMEM; 780 792 781 793 data->dev = dev; 782 - mutex_init(&data->update_lock); 783 794 data->regmap = devm_regmap_init_i2c(client, &adm9240_regmap_config); 784 795 if (IS_ERR(data->regmap)) 785 796 return PTR_ERR(data->regmap);
+11
drivers/hwmon/adt7410.c
··· 7 7 */ 8 8 9 9 #include <linux/module.h> 10 + #include <linux/mod_devicetable.h> 10 11 #include <linux/init.h> 11 12 #include <linux/i2c.h> 12 13 #include <linux/regmap.h> ··· 91 90 static const struct i2c_device_id adt7410_ids[] = { 92 91 { "adt7410" }, 93 92 { "adt7420" }, 93 + { "adt7422" }, 94 94 {} 95 95 }; 96 96 MODULE_DEVICE_TABLE(i2c, adt7410_ids); 97 + 98 + static const struct of_device_id adt7410_of_match[] = { 99 + { .compatible = "adi,adt7410" }, 100 + { .compatible = "adi,adt7420" }, 101 + { .compatible = "adi,adt7422" }, 102 + { } 103 + }; 104 + MODULE_DEVICE_TABLE(of, adt7410_of_match); 97 105 98 106 static struct i2c_driver adt7410_driver = { 99 107 .driver = { 100 108 .name = "adt7410", 101 109 .pm = pm_sleep_ptr(&adt7x10_dev_pm_ops), 110 + .of_match_table = adt7410_of_match, 102 111 }, 103 112 .probe = adt7410_i2c_probe, 104 113 .id_table = adt7410_ids,
+16 -43
drivers/hwmon/adt7411.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/init.h> 13 13 #include <linux/err.h> 14 - #include <linux/mutex.h> 15 14 #include <linux/jiffies.h> 16 15 #include <linux/i2c.h> 17 16 #include <linux/hwmon.h> ··· 98 99 }; 99 100 100 101 struct adt7411_data { 101 - struct mutex device_lock; /* for "atomic" device accesses */ 102 - struct mutex update_lock; 103 102 unsigned long next_update; 104 103 long vref_cached; 105 104 struct i2c_client *client; ··· 107 110 /* 108 111 * When reading a register containing (up to 4) lsb, all associated 109 112 * msb-registers get locked by the hardware. After _one_ of those msb is read, 110 - * _all_ are unlocked. In order to use this locking correctly, reading lsb/msb 111 - * is protected here with a mutex, too. 113 + * _all_ are unlocked. 112 114 */ 113 115 static int adt7411_read_10_bit(struct i2c_client *client, u8 lsb_reg, 114 - u8 msb_reg, u8 lsb_shift) 116 + u8 msb_reg, u8 lsb_shift) 115 117 { 116 - struct adt7411_data *data = i2c_get_clientdata(client); 117 118 int val, tmp; 118 - 119 - mutex_lock(&data->device_lock); 120 119 121 120 val = i2c_smbus_read_byte_data(client, lsb_reg); 122 121 if (val < 0) 123 - goto exit_unlock; 122 + return val; 124 123 125 124 tmp = (val >> lsb_shift) & 3; 126 125 val = i2c_smbus_read_byte_data(client, msb_reg); 126 + if (val < 0) 127 + return val; 127 128 128 - if (val >= 0) 129 - val = (val << 2) | tmp; 130 - 131 - exit_unlock: 132 - mutex_unlock(&data->device_lock); 133 - 129 + val = (val << 2) | tmp; 134 130 return val; 135 131 } 136 132 137 133 static int adt7411_modify_bit(struct i2c_client *client, u8 reg, u8 bit, 138 - bool flag) 134 + bool flag) 139 135 { 140 - struct adt7411_data *data = i2c_get_clientdata(client); 141 136 int ret, val; 142 - 143 - mutex_lock(&data->device_lock); 144 137 145 138 ret = i2c_smbus_read_byte_data(client, reg); 146 139 if (ret < 0) 147 - goto exit_unlock; 140 + return ret; 148 141 149 142 if (flag) 150 143 val = ret | bit; 151 144 else 152 145 val = ret & ~bit; 153 146 154 - ret = i2c_smbus_write_byte_data(client, reg, val); 155 - 156 - exit_unlock: 157 - mutex_unlock(&data->device_lock); 158 - return ret; 147 + return i2c_smbus_write_byte_data(client, reg, val); 159 148 } 160 149 161 150 static ssize_t adt7411_show_bit(struct device *dev, ··· 169 186 if (ret || flag > 1) 170 187 return -EINVAL; 171 188 189 + hwmon_lock(dev); 172 190 ret = adt7411_modify_bit(client, s_attr2->index, s_attr2->nr, flag); 173 - 174 191 /* force update */ 175 - mutex_lock(&data->update_lock); 176 192 data->next_update = jiffies; 177 - mutex_unlock(&data->update_lock); 193 + hwmon_unlock(dev); 178 194 179 195 return ret < 0 ? ret : count; 180 196 } ··· 276 294 int reg, lsb_reg, lsb_shift; 277 295 int nr = channel - 1; 278 296 279 - mutex_lock(&data->update_lock); 280 297 ret = adt7411_update_vref(dev); 281 298 if (ret < 0) 282 - goto exit_unlock; 299 + return ret; 283 300 284 301 switch (attr) { 285 302 case hwmon_in_input: ··· 288 307 ADT7411_REG_EXT_TEMP_AIN1_MSB + nr, 289 308 lsb_shift); 290 309 if (ret < 0) 291 - goto exit_unlock; 310 + return ret; 292 311 *val = ret * data->vref_cached / 1024; 293 312 ret = 0; 294 313 break; ··· 299 318 : ADT7411_REG_IN_HIGH(channel); 300 319 ret = i2c_smbus_read_byte_data(client, reg); 301 320 if (ret < 0) 302 - goto exit_unlock; 321 + return ret; 303 322 *val = ret * data->vref_cached / 256; 304 323 ret = 0; 305 324 break; ··· 310 329 ret = -EOPNOTSUPP; 311 330 break; 312 331 } 313 - exit_unlock: 314 - mutex_unlock(&data->update_lock); 315 332 return ret; 316 333 } 317 334 ··· 436 457 struct i2c_client *client = data->client; 437 458 int ret, reg; 438 459 439 - mutex_lock(&data->update_lock); 440 460 ret = adt7411_update_vref(dev); 441 461 if (ret < 0) 442 - goto exit_unlock; 462 + return ret; 443 463 val = clamp_val(val, 0, 255 * data->vref_cached / 256); 444 464 val = DIV_ROUND_CLOSEST(val * 256, data->vref_cached); 445 465 ··· 450 472 reg = ADT7411_REG_IN_HIGH(channel); 451 473 break; 452 474 default: 453 - ret = -EOPNOTSUPP; 454 - goto exit_unlock; 475 + return -EOPNOTSUPP; 455 476 } 456 477 457 478 ret = i2c_smbus_write_byte_data(client, reg, val); 458 - exit_unlock: 459 - mutex_unlock(&data->update_lock); 460 479 return ret; 461 480 } 462 481 ··· 654 679 655 680 i2c_set_clientdata(client, data); 656 681 data->client = client; 657 - mutex_init(&data->device_lock); 658 - mutex_init(&data->update_lock); 659 682 660 683 ret = adt7411_init_device(data); 661 684 if (ret < 0)
+5 -22
drivers/hwmon/adt7x10.c
··· 15 15 #include <linux/jiffies.h> 16 16 #include <linux/hwmon.h> 17 17 #include <linux/err.h> 18 - #include <linux/mutex.h> 19 18 #include <linux/delay.h> 20 19 #include <linux/interrupt.h> 21 20 #include <linux/regmap.h> ··· 54 55 /* Each client has this additional data */ 55 56 struct adt7x10_data { 56 57 struct regmap *regmap; 57 - struct mutex update_lock; 58 58 u8 config; 59 59 u8 oldconfig; 60 60 bool valid; /* true if temperature valid */ ··· 135 137 unsigned int regval; 136 138 int ret; 137 139 138 - mutex_lock(&data->update_lock); 139 140 if (index == adt7x10_temperature && !data->valid) { 140 141 /* wait for valid temperature */ 141 142 ret = adt7x10_temp_ready(data->regmap); 142 - if (ret) { 143 - mutex_unlock(&data->update_lock); 143 + if (ret) 144 144 return ret; 145 - } 146 145 data->valid = true; 147 146 } 148 - mutex_unlock(&data->update_lock); 149 147 150 148 ret = regmap_read(data->regmap, ADT7X10_REG_TEMP[index], &regval); 151 149 if (ret) ··· 153 159 154 160 static int adt7x10_temp_write(struct adt7x10_data *data, int index, long temp) 155 161 { 156 - int ret; 157 - 158 - mutex_lock(&data->update_lock); 159 - ret = regmap_write(data->regmap, ADT7X10_REG_TEMP[index], 160 - ADT7X10_TEMP_TO_REG(temp)); 161 - mutex_unlock(&data->update_lock); 162 - return ret; 162 + return regmap_write(data->regmap, ADT7X10_REG_TEMP[index], 163 + ADT7X10_TEMP_TO_REG(temp)); 163 164 } 164 165 165 166 static int adt7x10_hyst_read(struct adt7x10_data *data, int index, long *val) ··· 186 197 unsigned int regval; 187 198 int limit, ret; 188 199 189 - mutex_lock(&data->update_lock); 190 - 191 200 /* convert absolute hysteresis value to a 4 bit delta value */ 192 201 ret = regmap_read(data->regmap, ADT7X10_T_ALARM_HIGH, &regval); 193 202 if (ret < 0) 194 - goto abort; 203 + return ret; 195 204 196 205 limit = ADT7X10_REG_TO_TEMP(data, regval); 197 206 198 207 hyst = clamp_val(hyst, ADT7X10_TEMP_MIN, ADT7X10_TEMP_MAX); 199 208 regval = clamp_val(DIV_ROUND_CLOSEST(limit - hyst, 1000), 0, 200 209 ADT7X10_T_HYST_MASK); 201 - ret = regmap_write(data->regmap, ADT7X10_T_HYST, regval); 202 - abort: 203 - mutex_unlock(&data->update_lock); 204 - return ret; 210 + return regmap_write(data->regmap, ADT7X10_T_HYST, regval); 205 211 } 206 212 207 213 static int adt7x10_alarm_read(struct adt7x10_data *data, int index, long *val) ··· 328 344 data->regmap = regmap; 329 345 330 346 dev_set_drvdata(dev, data); 331 - mutex_init(&data->update_lock); 332 347 333 348 /* configure as specified */ 334 349 ret = regmap_read(regmap, ADT7X10_CONFIG, &config);
+19 -24
drivers/hwmon/aht10.c
··· 37 37 #define AHT10_CMD_MEAS 0b10101100 38 38 #define AHT10_CMD_RST 0b10111010 39 39 40 + #define DHT20_CMD_INIT 0x71 41 + 40 42 /* 41 43 * Flags in the answer byte/command 42 44 */ ··· 50 48 51 49 #define AHT10_MAX_POLL_INTERVAL_LEN 30 52 50 53 - enum aht10_variant { aht10, aht20 }; 51 + enum aht10_variant { aht10, aht20, dht20}; 54 52 55 53 static const struct i2c_device_id aht10_id[] = { 56 54 { "aht10", aht10 }, 57 55 { "aht20", aht20 }, 56 + { "dht20", dht20 }, 58 57 { }, 59 58 }; 60 59 MODULE_DEVICE_TABLE(i2c, aht10_id); ··· 63 60 /** 64 61 * struct aht10_data - All the data required to operate an AHT10/AHT20 chip 65 62 * @client: the i2c client associated with the AHT10/AHT20 66 - * @lock: a mutex that is used to prevent parallel access to the 67 - * i2c client 68 63 * @min_poll_interval: the minimum poll interval 69 64 * While the poll rate limit is not 100% necessary, 70 65 * the datasheet recommends that a measurement ··· 78 77 * AHT10/AHT20 79 78 * @crc8: crc8 support flag 80 79 * @meas_size: measurements data size 80 + * @init_cmd: Initialization command 81 81 */ 82 82 83 83 struct aht10_data { 84 84 struct i2c_client *client; 85 - /* 86 - * Prevent simultaneous access to the i2c 87 - * client and previous_poll_time 88 - */ 89 - struct mutex lock; 90 85 ktime_t min_poll_interval; 91 86 ktime_t previous_poll_time; 92 87 int temperature; 93 88 int humidity; 94 89 bool crc8; 95 90 unsigned int meas_size; 91 + u8 init_cmd; 96 92 }; 97 93 98 94 /* ··· 99 101 */ 100 102 static int aht10_init(struct aht10_data *data) 101 103 { 102 - const u8 cmd_init[] = {AHT10_CMD_INIT, AHT10_CAL_ENABLED | AHT10_MODE_CYC, 104 + const u8 cmd_init[] = {data->init_cmd, AHT10_CAL_ENABLED | AHT10_MODE_CYC, 103 105 0x00}; 104 106 int res; 105 107 u8 status; 106 108 struct i2c_client *client = data->client; 107 109 108 - res = i2c_master_send(client, cmd_init, 3); 110 + res = i2c_master_send(client, cmd_init, sizeof(cmd_init)); 109 111 if (res < 0) 110 112 return res; 111 113 ··· 166 168 u8 raw_data[AHT20_MEAS_SIZE]; 167 169 struct i2c_client *client = data->client; 168 170 169 - mutex_lock(&data->lock); 170 - if (!aht10_polltime_expired(data)) { 171 - mutex_unlock(&data->lock); 171 + if (!aht10_polltime_expired(data)) 172 172 return 0; 173 - } 174 173 175 174 res = i2c_master_send(client, cmd_meas, sizeof(cmd_meas)); 176 - if (res < 0) { 177 - mutex_unlock(&data->lock); 175 + if (res < 0) 178 176 return res; 179 - } 180 177 181 178 usleep_range(AHT10_MEAS_DELAY, AHT10_MEAS_DELAY + AHT10_DELAY_EXTRA); 182 179 183 180 res = i2c_master_recv(client, raw_data, data->meas_size); 184 181 if (res != data->meas_size) { 185 - mutex_unlock(&data->lock); 186 182 if (res >= 0) 187 183 return -ENODATA; 188 184 return res; 189 185 } 190 186 191 - if (data->crc8 && crc8_check(raw_data, data->meas_size)) { 192 - mutex_unlock(&data->lock); 187 + if (data->crc8 && crc8_check(raw_data, data->meas_size)) 193 188 return -EIO; 194 - } 195 189 196 190 hum = ((u32)raw_data[1] << 12u) | 197 191 ((u32)raw_data[2] << 4u) | ··· 200 210 data->humidity = hum; 201 211 data->previous_poll_time = ktime_get_boottime(); 202 212 203 - mutex_unlock(&data->lock); 204 213 return 0; 205 214 } 206 215 ··· 341 352 data->meas_size = AHT20_MEAS_SIZE; 342 353 data->crc8 = true; 343 354 crc8_populate_msb(crc8_table, AHT20_CRC8_POLY); 355 + data->init_cmd = AHT10_CMD_INIT; 356 + break; 357 + case dht20: 358 + data->meas_size = AHT20_MEAS_SIZE; 359 + data->crc8 = true; 360 + crc8_populate_msb(crc8_table, AHT20_CRC8_POLY); 361 + data->init_cmd = DHT20_CMD_INIT; 344 362 break; 345 363 default: 346 364 data->meas_size = AHT10_MEAS_SIZE; 365 + data->init_cmd = AHT10_CMD_INIT; 347 366 break; 348 367 } 349 - 350 - mutex_init(&data->lock); 351 368 352 369 res = aht10_init(data); 353 370 if (res < 0)
+6 -31
drivers/hwmon/aquacomputer_d5next.c
··· 20 20 #include <linux/jiffies.h> 21 21 #include <linux/ktime.h> 22 22 #include <linux/module.h> 23 - #include <linux/mutex.h> 24 23 #include <linux/seq_file.h> 25 24 #include <linux/unaligned.h> 26 25 ··· 550 551 struct hid_device *hdev; 551 552 struct device *hwmon_dev; 552 553 struct dentry *debugfs; 553 - struct mutex mutex; /* Used for locking access when reading and writing PWM values */ 554 554 enum kinds kind; 555 555 const char *name; 556 556 ··· 660 662 } 661 663 } 662 664 663 - /* Expects the mutex to be locked */ 664 665 static int aqc_get_ctrl_data(struct aqc_data *priv) 665 666 { 666 667 int ret; ··· 677 680 return ret; 678 681 } 679 682 680 - /* Expects the mutex to be locked */ 681 683 static int aqc_send_ctrl_data(struct aqc_data *priv) 682 684 { 683 685 int ret; ··· 717 721 { 718 722 int ret; 719 723 720 - mutex_lock(&priv->mutex); 721 - 722 724 ret = aqc_get_ctrl_data(priv); 723 725 if (ret < 0) 724 - goto unlock_and_return; 726 + return ret; 725 727 726 728 switch (type) { 727 729 case AQC_BE16: ··· 731 737 default: 732 738 ret = -EINVAL; 733 739 } 734 - 735 - unlock_and_return: 736 - mutex_unlock(&priv->mutex); 737 740 return ret; 738 741 } 739 742 ··· 738 747 { 739 748 int ret, i; 740 749 741 - mutex_lock(&priv->mutex); 742 - 743 750 ret = aqc_get_ctrl_data(priv); 744 751 if (ret < 0) 745 - goto unlock_and_return; 752 + return ret; 746 753 747 754 for (i = 0; i < len; i++) { 748 755 switch (types[i]) { ··· 751 762 priv->buffer[offsets[i]] = (u8)vals[i]; 752 763 break; 753 764 default: 754 - ret = -EINVAL; 765 + return -EINVAL; 755 766 } 756 767 } 757 768 758 - if (ret < 0) 759 - goto unlock_and_return; 760 - 761 - ret = aqc_send_ctrl_data(priv); 762 - 763 - unlock_and_return: 764 - mutex_unlock(&priv->mutex); 765 - return ret; 769 + return aqc_send_ctrl_data(priv); 766 770 } 767 771 768 772 static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type) ··· 935 953 { 936 954 int ret, i, sensor_value; 937 955 938 - mutex_lock(&priv->mutex); 939 - 940 956 memset(priv->buffer, 0x00, priv->buffer_size); 941 957 ret = hid_hw_raw_request(priv->hdev, priv->status_report_id, priv->buffer, 942 958 priv->buffer_size, HID_FEATURE_REPORT, HID_REQ_GET_REPORT); 943 959 if (ret < 0) 944 - goto unlock_and_return; 960 + return ret; 945 961 946 962 /* Temperature sensor readings */ 947 963 for (i = 0; i < priv->num_temp_sensors; i++) { ··· 1000 1020 } 1001 1021 1002 1022 priv->updated = jiffies; 1003 - 1004 - unlock_and_return: 1005 - mutex_unlock(&priv->mutex); 1006 - return ret; 1023 + return 0; 1007 1024 } 1008 1025 1009 1026 static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, ··· 1846 1869 ret = -ENOMEM; 1847 1870 goto fail_and_close; 1848 1871 } 1849 - 1850 - mutex_init(&priv->mutex); 1851 1872 1852 1873 priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, priv->name, priv, 1853 1874 &aqc_chip_info, NULL);
+3
drivers/hwmon/aspeed-g6-pwm-tach.c
··· 528 528 { 529 529 .compatible = "aspeed,ast2600-pwm-tach", 530 530 }, 531 + { 532 + .compatible = "aspeed,ast2700-pwm-tach", 533 + }, 531 534 {}, 532 535 }; 533 536 MODULE_DEVICE_TABLE(of, aspeed_pwm_tach_match);
+65 -2
drivers/hwmon/asus-ec-sensors.c
··· 113 113 ec_sensor_temp_t_sensor, 114 114 /* VRM temperature [℃] */ 115 115 ec_sensor_temp_vrm, 116 + /* VRM east (right) temperature [℃] */ 117 + ec_sensor_temp_vrme, 118 + /* VRM west (left) temperature [℃] */ 119 + ec_sensor_temp_vrmw, 116 120 /* CPU Core voltage [mV] */ 117 121 ec_sensor_in_cpu_core, 118 122 /* CPU_Opt fan [RPM] */ 119 123 ec_sensor_fan_cpu_opt, 120 124 /* VRM heat sink fan [RPM] */ 121 125 ec_sensor_fan_vrm_hs, 122 - /* VRM east heat sink fan [RPM] */ 126 + /* VRM east (right) heat sink fan [RPM] */ 123 127 ec_sensor_fan_vrme_hs, 124 - /* VRM west heat sink fan [RPM] */ 128 + /* VRM west (left) heat sink fan [RPM] */ 125 129 ec_sensor_fan_vrmw_hs, 126 130 /* Chipset fan [RPM] */ 127 131 ec_sensor_fan_chipset, ··· 161 157 #define SENSOR_TEMP_MB BIT(ec_sensor_temp_mb) 162 158 #define SENSOR_TEMP_T_SENSOR BIT(ec_sensor_temp_t_sensor) 163 159 #define SENSOR_TEMP_VRM BIT(ec_sensor_temp_vrm) 160 + #define SENSOR_TEMP_VRME BIT(ec_sensor_temp_vrme) 161 + #define SENSOR_TEMP_VRMW BIT(ec_sensor_temp_vrmw) 164 162 #define SENSOR_IN_CPU_CORE BIT(ec_sensor_in_cpu_core) 165 163 #define SENSOR_FAN_CPU_OPT BIT(ec_sensor_fan_cpu_opt) 166 164 #define SENSOR_FAN_VRM_HS BIT(ec_sensor_fan_vrm_hs) ··· 188 182 family_amd_500_series, 189 183 family_amd_600_series, 190 184 family_amd_800_series, 185 + family_amd_trx_50, 191 186 family_amd_wrx_90, 192 187 family_intel_200_series, 193 188 family_intel_300_series, ··· 299 292 EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x36), 300 293 [ec_sensor_fan_cpu_opt] = 301 294 EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0), 295 + }; 296 + 297 + static const struct ec_sensor_info sensors_family_amd_trx_50[] = { 298 + [ec_sensor_temp_cpu] = EC_SENSOR("CPU", hwmon_temp, 1, 0x00, 0x30), 299 + [ec_sensor_temp_cpu_package] = 300 + EC_SENSOR("CPU Package", hwmon_temp, 1, 0x00, 0x31), 301 + [ec_sensor_temp_vrme] = EC_SENSOR("VRM_E", hwmon_temp, 1, 0x00, 0x33), 302 + [ec_sensor_temp_vrmw] = EC_SENSOR("VRM_W", hwmon_temp, 1, 0x00, 0x34), 303 + [ec_sensor_fan_cpu_opt] = EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0), 304 + [ec_sensor_fan_vrmw_hs] = EC_SENSOR("VRM_E HS", hwmon_fan, 2, 0x00, 0xb4), 305 + [ec_sensor_fan_vrme_hs] = EC_SENSOR("VRM_W HS", hwmon_fan, 2, 0x00, 0xbc), 306 + [ec_sensor_temp_t_sensor] = 307 + EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x01, 0x04), 302 308 }; 303 309 304 310 static const struct ec_sensor_info sensors_family_amd_wrx_90[] = { ··· 553 533 .family = family_amd_800_series, 554 534 }; 555 535 536 + static const struct ec_board_info board_info_pro_ws_trx50_sage_wifi = { 537 + /* Board also has a nct6798 */ 538 + .sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE | SENSOR_TEMP_VRME | 539 + SENSOR_TEMP_VRMW | SENSOR_FAN_CPU_OPT | SENSOR_FAN_VRME_HS | 540 + SENSOR_FAN_VRMW_HS | SENSOR_TEMP_T_SENSOR, 541 + .mutex_path = ASUS_HW_ACCESS_MUTEX_RMTW_ASMX, 542 + .family = family_amd_trx_50, 543 + }; 544 + 556 545 static const struct ec_board_info board_info_pro_ws_wrx90e_sage_se = { 557 546 /* Board also has a nct6798 with 7 more fans and temperatures */ 558 547 .sensors = SENSOR_TEMP_CPU_PACKAGE | SENSOR_TEMP_T_SENSOR | ··· 608 579 SENSOR_TEMP_MB | SENSOR_TEMP_VRM, 609 580 .mutex_path = ACPI_GLOBAL_LOCK_PSEUDO_PATH, 610 581 .family = family_amd_800_series, 582 + }; 583 + 584 + static const struct ec_board_info board_info_strix_x470_i_gaming = { 585 + .sensors = SENSOR_SET_TEMP_CHIPSET_CPU_MB | 586 + SENSOR_TEMP_T_SENSOR | SENSOR_TEMP_VRM | 587 + SENSOR_CURR_CPU | SENSOR_IN_CPU_CORE, 588 + .mutex_path = ASUS_HW_ACCESS_MUTEX_ASMX, 589 + .family = family_amd_400_series, 611 590 }; 612 591 613 592 static const struct ec_board_info board_info_strix_x570_e_gaming = { ··· 665 628 .family = family_amd_600_series, 666 629 }; 667 630 631 + static const struct ec_board_info board_info_strix_x870_f_gaming_wifi = { 632 + .sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE | 633 + SENSOR_TEMP_MB | SENSOR_TEMP_VRM | SENSOR_TEMP_T_SENSOR, 634 + .mutex_path = ASUS_HW_ACCESS_MUTEX_SB_PCI0_SBRG_SIO1_MUT0, 635 + .family = family_amd_800_series, 636 + }; 637 + 668 638 static const struct ec_board_info board_info_strix_x870_i_gaming_wifi = { 669 639 .sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE | 670 640 SENSOR_TEMP_MB | SENSOR_TEMP_VRM, ··· 682 638 static const struct ec_board_info board_info_strix_x870e_e_gaming_wifi = { 683 639 .sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE | 684 640 SENSOR_TEMP_MB | SENSOR_TEMP_VRM | 641 + SENSOR_FAN_CPU_OPT, 642 + .mutex_path = ASUS_HW_ACCESS_MUTEX_SB_PCI0_SBRG_SIO1_MUT0, 643 + .family = family_amd_800_series, 644 + }; 645 + 646 + static const struct ec_board_info board_info_strix_x870e_h_gaming_wifi7 = { 647 + .sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE | 648 + SENSOR_TEMP_MB | SENSOR_TEMP_VRM | SENSOR_TEMP_T_SENSOR | 685 649 SENSOR_FAN_CPU_OPT, 686 650 .mutex_path = ASUS_HW_ACCESS_MUTEX_SB_PCI0_SBRG_SIO1_MUT0, 687 651 .family = family_amd_800_series, ··· 791 739 &board_info_pro_art_x670E_creator_wifi), 792 740 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ProArt X870E-CREATOR WIFI", 793 741 &board_info_pro_art_x870E_creator_wifi), 742 + DMI_EXACT_MATCH_ASUS_BOARD_NAME("Pro WS TRX50-SAGE WIFI", 743 + &board_info_pro_ws_trx50_sage_wifi), 794 744 DMI_EXACT_MATCH_ASUS_BOARD_NAME("Pro WS WRX90E-SAGE SE", 795 745 &board_info_pro_ws_wrx90e_sage_se), 796 746 DMI_EXACT_MATCH_ASUS_BOARD_NAME("Pro WS X570-ACE", ··· 825 771 &board_info_strix_b650e_i_gaming), 826 772 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX B850-I GAMING WIFI", 827 773 &board_info_strix_b850_i_gaming_wifi), 774 + DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X470-I GAMING", 775 + &board_info_strix_x470_i_gaming), 828 776 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X570-E GAMING", 829 777 &board_info_strix_x570_e_gaming), 830 778 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X570-E GAMING WIFI II", ··· 839 783 &board_info_strix_x670e_e_gaming_wifi), 840 784 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X670E-I GAMING WIFI", 841 785 &board_info_strix_x670e_i_gaming_wifi), 786 + DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X870-F GAMING WIFI", 787 + &board_info_strix_x870_f_gaming_wifi), 842 788 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X870-I GAMING WIFI", 843 789 &board_info_strix_x870_i_gaming_wifi), 844 790 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X870E-E GAMING WIFI", 845 791 &board_info_strix_x870e_e_gaming_wifi), 792 + DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X870E-H GAMING WIFI7", 793 + &board_info_strix_x870e_h_gaming_wifi7), 846 794 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX Z390-F GAMING", 847 795 &board_info_strix_z390_f_gaming), 848 796 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX Z490-F GAMING", ··· 1333 1273 break; 1334 1274 case family_amd_800_series: 1335 1275 ec_data->sensors_info = sensors_family_amd_800; 1276 + break; 1277 + case family_amd_trx_50: 1278 + ec_data->sensors_info = sensors_family_amd_trx_50; 1336 1279 break; 1337 1280 case family_amd_wrx_90: 1338 1281 ec_data->sensors_info = sensors_family_amd_wrx_90;
+9 -39
drivers/hwmon/asus_rog_ryujin.c
··· 81 81 struct rog_ryujin_data { 82 82 struct hid_device *hdev; 83 83 struct device *hwmon_dev; 84 - /* For locking access to buffer */ 85 - struct mutex buffer_lock; 86 - /* For queueing multiple readers */ 87 - struct mutex status_report_request_mutex; 88 84 /* For reinitializing the completions below */ 89 85 spinlock_t status_report_request_lock; 90 86 struct completion cooler_status_received; ··· 149 153 /* Writes the command to the device with the rest of the report filled with zeroes */ 150 154 static int rog_ryujin_write_expanded(struct rog_ryujin_data *priv, const u8 *cmd, int cmd_length) 151 155 { 152 - int ret; 153 - 154 - mutex_lock(&priv->buffer_lock); 155 - 156 156 memcpy_and_pad(priv->buffer, MAX_REPORT_LENGTH, cmd, cmd_length, 0x00); 157 - ret = hid_hw_output_report(priv->hdev, priv->buffer, MAX_REPORT_LENGTH); 158 - 159 - mutex_unlock(&priv->buffer_lock); 160 - return ret; 157 + return hid_hw_output_report(priv->hdev, priv->buffer, MAX_REPORT_LENGTH); 161 158 } 162 159 163 - /* Assumes priv->status_report_request_mutex is locked */ 164 160 static int rog_ryujin_execute_cmd(struct rog_ryujin_data *priv, const u8 *cmd, int cmd_length, 165 161 struct completion *status_completion) 166 162 { ··· 184 196 185 197 static int rog_ryujin_get_status(struct rog_ryujin_data *priv) 186 198 { 187 - int ret = mutex_lock_interruptible(&priv->status_report_request_mutex); 188 - 189 - if (ret < 0) 190 - return ret; 199 + int ret; 191 200 192 201 if (!time_after(jiffies, priv->updated + msecs_to_jiffies(STATUS_VALIDITY))) { 193 202 /* Data is up to date */ 194 - goto unlock_and_return; 203 + return 0; 195 204 } 196 205 197 206 /* Retrieve cooler status */ ··· 196 211 rog_ryujin_execute_cmd(priv, get_cooler_status_cmd, GET_CMD_LENGTH, 197 212 &priv->cooler_status_received); 198 213 if (ret < 0) 199 - goto unlock_and_return; 214 + return ret; 200 215 201 216 /* Retrieve controller status (speeds) */ 202 217 ret = 203 218 rog_ryujin_execute_cmd(priv, get_controller_speed_cmd, GET_CMD_LENGTH, 204 219 &priv->controller_status_received); 205 220 if (ret < 0) 206 - goto unlock_and_return; 221 + return ret; 207 222 208 223 /* Retrieve cooler duty */ 209 224 ret = 210 225 rog_ryujin_execute_cmd(priv, get_cooler_duty_cmd, GET_CMD_LENGTH, 211 226 &priv->cooler_duty_received); 212 227 if (ret < 0) 213 - goto unlock_and_return; 228 + return ret; 214 229 215 230 /* Retrieve controller duty */ 216 231 ret = 217 232 rog_ryujin_execute_cmd(priv, get_controller_duty_cmd, GET_CMD_LENGTH, 218 233 &priv->controller_duty_received); 219 234 if (ret < 0) 220 - goto unlock_and_return; 221 - 222 - priv->updated = jiffies; 223 - 224 - unlock_and_return: 225 - mutex_unlock(&priv->status_report_request_mutex); 226 - if (ret < 0) 227 235 return ret; 228 236 237 + priv->updated = jiffies; 229 238 return 0; 230 239 } 231 240 ··· 282 303 * Retrieve cooler duty since both pump and internal fan are set 283 304 * together, then write back with one of them modified. 284 305 */ 285 - ret = mutex_lock_interruptible(&priv->status_report_request_mutex); 286 - if (ret < 0) 287 - return ret; 288 306 ret = 289 307 rog_ryujin_execute_cmd(priv, get_cooler_duty_cmd, GET_CMD_LENGTH, 290 308 &priv->cooler_duty_received); 291 309 if (ret < 0) 292 - goto unlock_and_return; 310 + return ret; 293 311 294 312 memcpy(set_cmd, set_cooler_duty_cmd, SET_CMD_LENGTH); 295 313 ··· 305 329 set_cmd[RYUJIN_SET_COOLER_FAN_DUTY_OFFSET] = val; 306 330 } 307 331 308 - ret = rog_ryujin_execute_cmd(priv, set_cmd, SET_CMD_LENGTH, &priv->cooler_duty_set); 309 - unlock_and_return: 310 - mutex_unlock(&priv->status_report_request_mutex); 311 - if (ret < 0) 312 - return ret; 332 + return rog_ryujin_execute_cmd(priv, set_cmd, SET_CMD_LENGTH, &priv->cooler_duty_set); 313 333 } else { 314 334 /* 315 335 * Controller fan duty (channel == 2). No need to retrieve current ··· 510 538 goto fail_and_close; 511 539 } 512 540 513 - mutex_init(&priv->status_report_request_mutex); 514 - mutex_init(&priv->buffer_lock); 515 541 spin_lock_init(&priv->status_report_request_lock); 516 542 init_completion(&priv->cooler_status_received); 517 543 init_completion(&priv->controller_status_received);
-7
drivers/hwmon/chipcap2.c
··· 81 81 struct completion complete; 82 82 struct device *hwmon; 83 83 struct i2c_client *client; 84 - struct mutex dev_access_lock; /* device access lock */ 85 84 struct regulator *regulator; 86 85 const char *name; 87 86 int irq_ready; ··· 557 558 { 558 559 struct cc2_data *data = dev_get_drvdata(dev); 559 560 560 - guard(mutex)(&data->dev_access_lock); 561 - 562 561 switch (type) { 563 562 case hwmon_temp: 564 563 return cc2_measurement(data, type, val); ··· 596 599 597 600 if (val < 0 || val > CC2_RH_MAX) 598 601 return -EINVAL; 599 - 600 - guard(mutex)(&data->dev_access_lock); 601 602 602 603 switch (attr) { 603 604 case hwmon_humidity_min: ··· 702 707 return -ENOMEM; 703 708 704 709 i2c_set_clientdata(client, data); 705 - 706 - mutex_init(&data->dev_access_lock); 707 710 708 711 data->client = client; 709 712
+4 -4
drivers/hwmon/corsair-cpro.c
··· 40 40 #define CTL_GET_TMP 0x11 /* 41 41 * send: byte 1 is channel, rest zero 42 42 * rcv: returns temp for channel in centi-degree celsius 43 - * in bytes 1 and 2 43 + * in bytes 1 and 2 as a two's complement value 44 44 * returns 0x11 in byte 0 if no sensor is connected 45 45 */ 46 46 #define CTL_GET_VOLT 0x12 /* ··· 90 90 u8 *cmd_buffer; 91 91 u8 *buffer; 92 92 int buffer_recv_size; /* number of received bytes in buffer */ 93 - int target[6]; 93 + int target[NUM_FANS]; 94 94 DECLARE_BITMAP(temp_cnct, NUM_TEMP_SENSORS); 95 95 DECLARE_BITMAP(fan_cnct, NUM_FANS); 96 - char fan_label[6][LABEL_LENGTH]; 96 + char fan_label[NUM_FANS][LABEL_LENGTH]; 97 97 u8 firmware_ver[3]; 98 98 u8 bootloader_ver[2]; 99 99 }; ··· 258 258 ret = get_data(ccp, CTL_GET_TMP, channel, true); 259 259 if (ret < 0) 260 260 return ret; 261 - *val = ret * 10; 261 + *val = (s16)ret * 10; 262 262 return 0; 263 263 default: 264 264 break;
+2 -11
drivers/hwmon/corsair-psu.c
··· 9 9 #include <linux/errno.h> 10 10 #include <linux/hid.h> 11 11 #include <linux/hwmon.h> 12 - #include <linux/hwmon-sysfs.h> 13 12 #include <linux/jiffies.h> 14 13 #include <linux/kernel.h> 15 14 #include <linux/module.h> 16 - #include <linux/mutex.h> 17 15 #include <linux/slab.h> 18 16 #include <linux/types.h> 19 17 ··· 122 124 struct device *hwmon_dev; 123 125 struct dentry *debugfs; 124 126 struct completion wait_completion; 125 - struct mutex lock; /* for locking access to cmd_buffer */ 126 127 u8 *cmd_buffer; 127 128 char vendor[REPLY_SIZE]; 128 129 char product[REPLY_SIZE]; ··· 217 220 { 218 221 int ret; 219 222 220 - mutex_lock(&priv->lock); 221 223 switch (cmd) { 222 224 case PSU_CMD_RAIL_VOLTS_HCRIT: 223 225 case PSU_CMD_RAIL_VOLTS_LCRIT: ··· 226 230 case PSU_CMD_RAIL_WATTS: 227 231 ret = corsairpsu_usb_cmd(priv, 2, PSU_CMD_SELECT_RAIL, rail, NULL); 228 232 if (ret < 0) 229 - goto cmd_fail; 233 + return ret; 230 234 break; 231 235 default: 232 236 break; 233 237 } 234 238 235 - ret = corsairpsu_usb_cmd(priv, 3, cmd, 0, data); 236 - 237 - cmd_fail: 238 - mutex_unlock(&priv->lock); 239 - return ret; 239 + return corsairpsu_usb_cmd(priv, 3, cmd, 0, data); 240 240 } 241 241 242 242 static int corsairpsu_get_value(struct corsairpsu_data *priv, u8 cmd, u8 rail, long *val) ··· 789 797 790 798 priv->hdev = hdev; 791 799 hid_set_drvdata(hdev, priv); 792 - mutex_init(&priv->lock); 793 800 init_completion(&priv->wait_completion); 794 801 795 802 hid_device_io_start(hdev);
+9
drivers/hwmon/dell-smm-hwmon.c
··· 1534 1534 1535 1535 static const struct dmi_system_id i8k_whitelist_fan_control[] __initconst = { 1536 1536 { 1537 + .ident = "Dell G5 5505", 1538 + .matches = { 1539 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1540 + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G5 5505"), 1541 + 1542 + }, 1543 + .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3], 1544 + }, 1545 + { 1537 1546 .ident = "Dell Latitude 5480", 1538 1547 .matches = { 1539 1548 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
-5
drivers/hwmon/drivetemp.c
··· 102 102 #include <linux/kernel.h> 103 103 #include <linux/list.h> 104 104 #include <linux/module.h> 105 - #include <linux/mutex.h> 106 105 #include <scsi/scsi_cmnd.h> 107 106 #include <scsi/scsi_device.h> 108 107 #include <scsi/scsi_driver.h> ··· 109 110 110 111 struct drivetemp_data { 111 112 struct list_head list; /* list of instantiated devices */ 112 - struct mutex lock; /* protect data buffer accesses */ 113 113 struct scsi_device *sdev; /* SCSI device */ 114 114 struct device *dev; /* instantiating device */ 115 115 struct device *hwdev; /* hardware monitoring device */ ··· 460 462 case hwmon_temp_input: 461 463 case hwmon_temp_lowest: 462 464 case hwmon_temp_highest: 463 - mutex_lock(&st->lock); 464 465 err = st->get_temp(st, attr, val); 465 - mutex_unlock(&st->lock); 466 466 break; 467 467 case hwmon_temp_lcrit: 468 468 *val = st->temp_lcrit; ··· 562 566 563 567 st->sdev = sdev; 564 568 st->dev = dev; 565 - mutex_init(&st->lock); 566 569 567 570 if (drivetemp_identify(st)) { 568 571 err = -ENODEV;
+10 -36
drivers/hwmon/emc1403.c
··· 17 17 #include <linux/hwmon-sysfs.h> 18 18 #include <linux/err.h> 19 19 #include <linux/sysfs.h> 20 - #include <linux/mutex.h> 21 20 #include <linux/regmap.h> 22 21 #include <linux/util_macros.h> 23 22 ··· 29 30 struct thermal_data { 30 31 enum emc1403_chip chip; 31 32 struct regmap *regmap; 32 - struct mutex mutex; 33 33 }; 34 34 35 35 static ssize_t power_state_show(struct device *dev, struct device_attribute *attr, char *buf) ··· 266 268 }, 267 269 }; 268 270 269 - static int __emc1403_get_temp(struct thermal_data *data, int channel, 270 - enum emc1403_reg_map map, long *val) 271 + static int emc1403_get_temp(struct thermal_data *data, int channel, 272 + enum emc1403_reg_map map, long *val) 271 273 { 272 274 unsigned int regvalh; 273 275 unsigned int regvall = 0; ··· 293 295 return 0; 294 296 } 295 297 296 - static int emc1403_get_temp(struct thermal_data *data, int channel, 297 - enum emc1403_reg_map map, long *val) 298 - { 299 - int ret; 300 - 301 - mutex_lock(&data->mutex); 302 - ret = __emc1403_get_temp(data, channel, map, val); 303 - mutex_unlock(&data->mutex); 304 - 305 - return ret; 306 - } 307 - 308 298 static int emc1403_get_hyst(struct thermal_data *data, int channel, 309 299 enum emc1403_reg_map map, long *val) 310 300 { 311 301 int hyst, ret; 312 302 long limit; 313 303 314 - mutex_lock(&data->mutex); 315 - ret = __emc1403_get_temp(data, channel, map, &limit); 304 + ret = emc1403_get_temp(data, channel, map, &limit); 316 305 if (ret < 0) 317 - goto unlock; 306 + return ret; 318 307 ret = regmap_read(data->regmap, 0x21, &hyst); 319 308 if (ret < 0) 320 - goto unlock; 309 + return ret; 321 310 if (map == temp_min) 322 311 *val = limit + hyst * 1000; 323 312 else 324 313 *val = limit - hyst * 1000; 325 - unlock: 326 - mutex_unlock(&data->mutex); 327 - return ret; 314 + return 0; 328 315 } 329 316 330 317 static int emc1403_temp_read(struct thermal_data *data, u32 attr, int channel, long *val) ··· 434 451 else 435 452 val = clamp_val(val, 0, 255000); 436 453 437 - mutex_lock(&data->mutex); 438 - ret = __emc1403_get_temp(data, 0, temp_crit, &limit); 454 + ret = emc1403_get_temp(data, 0, temp_crit, &limit); 439 455 if (ret < 0) 440 - goto unlock; 456 + return ret; 441 457 442 458 hyst = limit - val; 443 459 if (data->chip == emc1428) 444 460 hyst = clamp_val(DIV_ROUND_CLOSEST(hyst, 1000), 0, 127); 445 461 else 446 462 hyst = clamp_val(DIV_ROUND_CLOSEST(hyst, 1000), 0, 255); 447 - ret = regmap_write(data->regmap, 0x21, hyst); 448 - unlock: 449 - mutex_unlock(&data->mutex); 450 - return ret; 463 + return regmap_write(data->regmap, 0x21, hyst); 451 464 } 452 465 453 466 static int emc1403_set_temp(struct thermal_data *data, int channel, ··· 457 478 regh = emc1403_temp_regs[channel][map]; 458 479 regl = emc1403_temp_regs_low[channel][map]; 459 480 460 - mutex_lock(&data->mutex); 461 481 if (regl >= 0) { 462 482 if (data->chip == emc1428) 463 483 val = clamp_val(val, -128000, 127875); ··· 465 487 regval = DIV_ROUND_CLOSEST(val, 125); 466 488 ret = regmap_write(data->regmap, regh, (regval >> 3) & 0xff); 467 489 if (ret < 0) 468 - goto unlock; 490 + return ret; 469 491 ret = regmap_write(data->regmap, regl, (regval & 0x07) << 5); 470 492 } else { 471 493 if (data->chip == emc1428) ··· 475 497 regval = DIV_ROUND_CLOSEST(val, 1000); 476 498 ret = regmap_write(data->regmap, regh, regval); 477 499 } 478 - unlock: 479 - mutex_unlock(&data->mutex); 480 500 return ret; 481 501 } 482 502 ··· 670 694 data->regmap = devm_regmap_init_i2c(client, &emc1403_regmap_config); 671 695 if (IS_ERR(data->regmap)) 672 696 return PTR_ERR(data->regmap); 673 - 674 - mutex_init(&data->mutex); 675 697 676 698 hwmon_dev = devm_hwmon_device_register_with_info(&client->dev, 677 699 client->name, data,
+4
drivers/hwmon/emc2103.c
··· 277 277 { 278 278 struct emc2103_data *data = emc2103_update_device(dev); 279 279 int rpm = 0; 280 + mutex_lock(&data->update_lock); 280 281 if (data->fan_tach != 0) 281 282 rpm = (FAN_RPM_FACTOR * data->fan_multiplier) / data->fan_tach; 283 + mutex_unlock(&data->update_lock); 282 284 return sprintf(buf, "%d\n", rpm); 283 285 } 284 286 ··· 365 363 struct emc2103_data *data = emc2103_update_device(dev); 366 364 int rpm = 0; 367 365 366 + mutex_lock(&data->update_lock); 368 367 /* high byte of 0xff indicates disabled so return 0 */ 369 368 if ((data->fan_target != 0) && ((data->fan_target & 0x1fe0) != 0x1fe0)) 370 369 rpm = (FAN_RPM_FACTOR * data->fan_multiplier) 371 370 / data->fan_target; 371 + mutex_unlock(&data->update_lock); 372 372 373 373 return sprintf(buf, "%d\n", rpm); 374 374 }
+25 -59
drivers/hwmon/ftsteutates.c
··· 12 12 #include <linux/jiffies.h> 13 13 #include <linux/math.h> 14 14 #include <linux/module.h> 15 - #include <linux/mutex.h> 16 15 #include <linux/slab.h> 17 16 #include <linux/watchdog.h> 18 17 ··· 61 62 62 63 struct fts_data { 63 64 struct i2c_client *client; 64 - /* update sensor data lock */ 65 - struct mutex update_lock; 66 - /* read/write register lock */ 67 - struct mutex access_lock; 68 65 unsigned long last_updated; /* in jiffies */ 69 66 struct watchdog_device wdd; 70 67 enum WATCHDOG_RESOLUTION resolution; ··· 93 98 { 94 99 int ret; 95 100 unsigned char page = reg >> 8; 96 - struct fts_data *data = dev_get_drvdata(&client->dev); 97 - 98 - mutex_lock(&data->access_lock); 99 101 100 102 dev_dbg(&client->dev, "page select - page: 0x%.02x\n", page); 101 103 ret = i2c_smbus_write_byte_data(client, FTS_PAGE_SELECT_REG, page); 102 104 if (ret < 0) 103 - goto error; 105 + return ret; 104 106 105 107 reg &= 0xFF; 106 108 ret = i2c_smbus_read_byte_data(client, reg); 107 109 dev_dbg(&client->dev, "read - reg: 0x%.02x: val: 0x%.02x\n", reg, ret); 108 - 109 - error: 110 - mutex_unlock(&data->access_lock); 111 110 return ret; 112 111 } 113 112 ··· 110 121 { 111 122 int ret; 112 123 unsigned char page = reg >> 8; 113 - struct fts_data *data = dev_get_drvdata(&client->dev); 114 - 115 - mutex_lock(&data->access_lock); 116 124 117 125 dev_dbg(&client->dev, "page select - page: 0x%.02x\n", page); 118 126 ret = i2c_smbus_write_byte_data(client, FTS_PAGE_SELECT_REG, page); 119 127 if (ret < 0) 120 - goto error; 128 + return ret; 121 129 122 130 reg &= 0xFF; 123 131 dev_dbg(&client->dev, 124 132 "write - reg: 0x%.02x: val: 0x%.02x\n", reg, value); 125 133 ret = i2c_smbus_write_byte_data(client, reg, value); 126 - 127 - error: 128 - mutex_unlock(&data->access_lock); 129 134 return ret; 130 135 } 131 136 ··· 128 145 /*****************************************************************************/ 129 146 static int fts_update_device(struct fts_data *data) 130 147 { 131 - int i; 132 - int err = 0; 148 + int i, err; 133 149 134 - mutex_lock(&data->update_lock); 135 150 if (!time_after(jiffies, data->last_updated + 2 * HZ) && data->valid) 136 - goto exit; 151 + return 0; 137 152 138 153 err = fts_read_byte(data->client, FTS_DEVICE_STATUS_REG); 139 154 if (err < 0) 140 - goto exit; 155 + return err; 141 156 142 157 data->valid = !!(err & 0x02); /* Data not ready yet */ 143 - if (unlikely(!data->valid)) { 144 - err = -EAGAIN; 145 - goto exit; 146 - } 158 + if (unlikely(!data->valid)) 159 + return -EAGAIN; 147 160 148 161 err = fts_read_byte(data->client, FTS_FAN_PRESENT_REG); 149 162 if (err < 0) 150 - goto exit; 163 + return err; 151 164 data->fan_present = err; 152 165 153 166 err = fts_read_byte(data->client, FTS_FAN_EVENT_REG); 154 167 if (err < 0) 155 - goto exit; 168 + return err; 156 169 data->fan_alarm = err; 157 170 158 171 for (i = 0; i < FTS_NO_FAN_SENSORS; i++) { 159 172 if (data->fan_present & BIT(i)) { 160 173 err = fts_read_byte(data->client, FTS_REG_FAN_INPUT(i)); 161 174 if (err < 0) 162 - goto exit; 175 + return err; 163 176 data->fan_input[i] = err; 164 177 165 178 err = fts_read_byte(data->client, 166 179 FTS_REG_FAN_SOURCE(i)); 167 180 if (err < 0) 168 - goto exit; 181 + return err; 169 182 data->fan_source[i] = err; 170 183 } else { 171 184 data->fan_input[i] = 0; ··· 171 192 172 193 err = fts_read_byte(data->client, FTS_SENSOR_EVENT_REG); 173 194 if (err < 0) 174 - goto exit; 195 + return err; 175 196 data->temp_alarm = err; 176 197 177 198 for (i = 0; i < FTS_NO_TEMP_SENSORS; i++) { 178 199 err = fts_read_byte(data->client, FTS_REG_TEMP_INPUT(i)); 179 200 if (err < 0) 180 - goto exit; 201 + return err; 181 202 data->temp_input[i] = err; 182 203 } 183 204 184 205 for (i = 0; i < FTS_NO_VOLT_SENSORS; i++) { 185 206 err = fts_read_byte(data->client, FTS_REG_VOLT(i)); 186 207 if (err < 0) 187 - goto exit; 208 + return err; 188 209 data->volt[i] = err; 189 210 } 190 211 data->last_updated = jiffies; 191 - err = 0; 192 - exit: 193 - mutex_unlock(&data->update_lock); 194 - return err; 212 + return 0; 195 213 } 196 214 197 215 /*****************************************************************************/ ··· 446 470 if (val) 447 471 return -EINVAL; 448 472 449 - mutex_lock(&data->update_lock); 450 473 ret = fts_read_byte(data->client, FTS_REG_TEMP_CONTROL(channel)); 451 - if (ret >= 0) 452 - ret = fts_write_byte(data->client, FTS_REG_TEMP_CONTROL(channel), 453 - ret | 0x1); 454 - if (ret >= 0) 455 - data->valid = false; 456 - 457 - mutex_unlock(&data->update_lock); 458 474 if (ret < 0) 459 475 return ret; 460 - 476 + ret = fts_write_byte(data->client, FTS_REG_TEMP_CONTROL(channel), 477 + ret | 0x1); 478 + if (ret < 0) 479 + return ret; 480 + data->valid = false; 461 481 return 0; 462 482 default: 463 483 break; ··· 465 493 if (val) 466 494 return -EINVAL; 467 495 468 - mutex_lock(&data->update_lock); 469 496 ret = fts_read_byte(data->client, FTS_REG_FAN_CONTROL(channel)); 470 - if (ret >= 0) 471 - ret = fts_write_byte(data->client, FTS_REG_FAN_CONTROL(channel), 472 - ret | 0x1); 473 - if (ret >= 0) 474 - data->valid = false; 475 - 476 - mutex_unlock(&data->update_lock); 477 497 if (ret < 0) 478 498 return ret; 479 - 499 + ret = fts_write_byte(data->client, FTS_REG_FAN_CONTROL(channel), 500 + ret | 0x1); 501 + if (ret < 0) 502 + return ret; 503 + data->valid = false; 480 504 return 0; 481 505 default: 482 506 break; ··· 616 648 if (!data) 617 649 return -ENOMEM; 618 650 619 - mutex_init(&data->update_lock); 620 - mutex_init(&data->access_lock); 621 651 data->client = client; 622 652 dev_set_drvdata(&client->dev, data); 623 653
+13 -43
drivers/hwmon/gpd-fan.c
··· 26 26 static char *gpd_fan_board = ""; 27 27 module_param(gpd_fan_board, charp, 0444); 28 28 29 - // EC read/write locker, protecting a sequence of EC operations 30 - static DEFINE_MUTEX(gpd_fan_sequence_lock); 31 - 32 29 enum gpd_board { 33 30 win_mini, 34 31 win4_6800u, ··· 478 481 { 479 482 int ret; 480 483 481 - ret = mutex_lock_interruptible(&gpd_fan_sequence_lock); 482 - if (ret) 483 - return ret; 484 - 485 484 if (type == hwmon_fan) { 486 485 if (attr == hwmon_fan_input) { 487 486 ret = gpd_read_rpm(); 488 487 489 488 if (ret < 0) 490 - goto OUT; 489 + return ret; 491 490 492 491 *val = ret; 493 - ret = 0; 494 - goto OUT; 492 + return 0; 495 493 } 496 494 } else if (type == hwmon_pwm) { 497 495 switch (attr) { 498 496 case hwmon_pwm_enable: 499 497 *val = gpd_driver_priv.pwm_enable; 500 - ret = 0; 501 - goto OUT; 498 + return 0; 502 499 case hwmon_pwm_input: 503 500 ret = gpd_read_pwm(); 504 501 505 502 if (ret < 0) 506 - goto OUT; 503 + return ret; 507 504 508 505 *val = ret; 509 - ret = 0; 510 - goto OUT; 506 + return 0; 511 507 } 512 508 } 513 509 514 - ret = -EOPNOTSUPP; 515 - 516 - OUT: 517 - mutex_unlock(&gpd_fan_sequence_lock); 518 - return ret; 510 + return -EOPNOTSUPP; 519 511 } 520 512 521 513 static int gpd_fan_hwmon_write(__always_unused struct device *dev, 522 514 enum hwmon_sensor_types type, u32 attr, 523 515 __always_unused int channel, long val) 524 516 { 525 - int ret; 526 - 527 - ret = mutex_lock_interruptible(&gpd_fan_sequence_lock); 528 - if (ret) 529 - return ret; 530 - 531 517 if (type == hwmon_pwm) { 532 518 switch (attr) { 533 519 case hwmon_pwm_enable: 534 - if (!in_range(val, 0, 3)) { 535 - ret = -EINVAL; 536 - goto OUT; 537 - } 520 + if (!in_range(val, 0, 3)) 521 + return -EINVAL; 538 522 539 523 gpd_driver_priv.pwm_enable = val; 540 524 541 525 gpd_set_pwm_enable(gpd_driver_priv.pwm_enable); 542 - ret = 0; 543 - goto OUT; 526 + return 0; 544 527 case hwmon_pwm_input: 545 - if (!in_range(val, 0, 256)) { 546 - ret = -ERANGE; 547 - goto OUT; 548 - } 528 + if (!in_range(val, 0, 256)) 529 + return -EINVAL; 549 530 550 531 gpd_driver_priv.pwm_value = val; 551 532 552 - ret = gpd_write_pwm(val); 553 - goto OUT; 533 + return gpd_write_pwm(val); 554 534 } 555 535 } 556 536 557 - ret = -EOPNOTSUPP; 558 - 559 - OUT: 560 - mutex_unlock(&gpd_fan_sequence_lock); 561 - return ret; 537 + return -EOPNOTSUPP; 562 538 } 563 539 564 540 static const struct hwmon_ops gpd_fan_ops = {
+1 -9
drivers/hwmon/hs3001.c
··· 42 42 43 43 struct hs3001_data { 44 44 struct i2c_client *client; 45 - struct mutex i2c_lock; /* lock for sending i2c commands */ 46 45 u32 wait_time; /* in us */ 47 46 int temperature; /* in milli degree */ 48 47 u32 humidity; /* in milli % */ ··· 111 112 struct i2c_client *client = data->client; 112 113 int ret; 113 114 114 - mutex_lock(&data->i2c_lock); 115 115 ret = i2c_master_send(client, NULL, 0); 116 - if (ret < 0) { 117 - mutex_unlock(&data->i2c_lock); 116 + if (ret < 0) 118 117 return ret; 119 - } 120 118 121 119 /* 122 120 * Sensor needs some time to process measurement depending on ··· 122 126 fsleep(data->wait_time); 123 127 124 128 ret = hs3001_data_fetch_command(client, data); 125 - mutex_unlock(&data->i2c_lock); 126 - 127 129 if (ret < 0) 128 130 return ret; 129 131 ··· 204 210 */ 205 211 data->wait_time = (HS3001_WAKEUP_TIME + HS3001_14BIT_RESOLUTION + 206 212 HS3001_14BIT_RESOLUTION); 207 - 208 - mutex_init(&data->i2c_lock); 209 213 210 214 hwmon_dev = devm_hwmon_device_register_with_info(dev, 211 215 client->name,
-3
drivers/hwmon/i5500_temp.c
··· 8 8 #include <linux/bitops.h> 9 9 #include <linux/module.h> 10 10 #include <linux/init.h> 11 - #include <linux/slab.h> 12 - #include <linux/jiffies.h> 13 11 #include <linux/device.h> 14 12 #include <linux/pci.h> 15 13 #include <linux/hwmon.h> 16 14 #include <linux/err.h> 17 - #include <linux/mutex.h> 18 15 19 16 /* Register definitions from datasheet */ 20 17 #define REG_TSTHRCATA 0xE2
+5 -21
drivers/hwmon/ina238.c
··· 117 117 struct ina238_data { 118 118 const struct ina238_config *config; 119 119 struct i2c_client *client; 120 - struct mutex config_lock; 121 120 struct regmap *regmap; 122 121 u32 rshunt; 123 122 int gain; ··· 606 607 static int ina238_write(struct device *dev, enum hwmon_sensor_types type, 607 608 u32 attr, int channel, long val) 608 609 { 609 - struct ina238_data *data = dev_get_drvdata(dev); 610 - int err; 611 - 612 - mutex_lock(&data->config_lock); 613 - 614 610 switch (type) { 615 611 case hwmon_in: 616 - err = ina238_write_in(dev, attr, channel, val); 617 - break; 612 + return ina238_write_in(dev, attr, channel, val); 618 613 case hwmon_curr: 619 - err = ina238_write_curr(dev, attr, val); 620 - break; 614 + return ina238_write_curr(dev, attr, val); 621 615 case hwmon_power: 622 - err = ina238_write_power_max(dev, val); 623 - break; 616 + return ina238_write_power_max(dev, val); 624 617 case hwmon_temp: 625 - err = ina238_write_temp_max(dev, val); 626 - break; 618 + return ina238_write_temp_max(dev, val); 627 619 default: 628 - err = -EOPNOTSUPP; 629 - break; 620 + return -EOPNOTSUPP; 630 621 } 631 - 632 - mutex_unlock(&data->config_lock); 633 - return err; 634 622 } 635 623 636 624 static umode_t ina238_is_visible(const void *drvdata, ··· 742 756 data->client = client; 743 757 /* set the device type */ 744 758 data->config = &ina238_config[chip]; 745 - 746 - mutex_init(&data->config_lock); 747 759 748 760 data->regmap = devm_regmap_init_i2c(client, &ina238_regmap_config); 749 761 if (IS_ERR(data->regmap)) {
+10 -18
drivers/hwmon/ina2xx.c
··· 156 156 long rshunt; 157 157 long current_lsb_uA; 158 158 long power_lsb_uW; 159 - struct mutex config_lock; 160 159 struct regmap *regmap; 161 160 struct i2c_client *client; 162 161 }; ··· 389 390 int regval; 390 391 int ret; 391 392 392 - mutex_lock(&data->config_lock); 393 393 ret = regmap_read(regmap, INA226_MASK_ENABLE, &regval); 394 394 if (ret) 395 - goto abort; 395 + return ret; 396 396 397 397 if (regval & mask) { 398 398 ret = regmap_read(regmap, INA226_ALERT_LIMIT, &regval); 399 399 if (ret) 400 - goto abort; 400 + return ret; 401 401 *val = ina2xx_get_value(data, reg, regval); 402 402 } else { 403 403 *val = 0; 404 404 } 405 - abort: 406 - mutex_unlock(&data->config_lock); 407 - return ret; 405 + return 0; 408 406 } 409 407 410 408 static int ina226_alert_limit_write(struct ina2xx_data *data, u32 mask, int reg, long val) ··· 417 421 * due to register write sequence. Then, only enable the alert 418 422 * if the value is non-zero. 419 423 */ 420 - mutex_lock(&data->config_lock); 421 424 ret = regmap_update_bits(regmap, INA226_MASK_ENABLE, 422 425 INA226_ALERT_CONFIG_MASK, 0); 423 426 if (ret < 0) 424 - goto abort; 427 + return ret; 425 428 426 429 ret = regmap_write(regmap, INA226_ALERT_LIMIT, 427 430 ina226_alert_to_reg(data, reg, val)); 428 431 if (ret < 0) 429 - goto abort; 432 + return ret; 430 433 431 434 if (val) 432 - ret = regmap_update_bits(regmap, INA226_MASK_ENABLE, 433 - INA226_ALERT_CONFIG_MASK, mask); 434 - abort: 435 - mutex_unlock(&data->config_lock); 436 - return ret; 435 + return regmap_update_bits(regmap, INA226_MASK_ENABLE, 436 + INA226_ALERT_CONFIG_MASK, mask); 437 + return 0; 437 438 } 438 439 439 440 static int ina2xx_chip_read(struct device *dev, u32 attr, long *val) ··· 852 859 if (status < 0) 853 860 return status; 854 861 855 - mutex_lock(&data->config_lock); 862 + hwmon_lock(dev); 856 863 status = ina2xx_set_shunt(data, val); 857 - mutex_unlock(&data->config_lock); 864 + hwmon_unlock(dev); 858 865 if (status < 0) 859 866 return status; 860 867 return count; ··· 944 951 data->client = client; 945 952 data->config = &ina2xx_config[chip]; 946 953 data->chip = chip; 947 - mutex_init(&data->config_lock); 948 954 949 955 data->regmap = devm_regmap_init_i2c(client, &ina2xx_regmap_config); 950 956 if (IS_ERR(data->regmap)) {
-19
drivers/hwmon/ina3221.c
··· 11 11 #include <linux/hwmon-sysfs.h> 12 12 #include <linux/i2c.h> 13 13 #include <linux/module.h> 14 - #include <linux/mutex.h> 15 14 #include <linux/of.h> 16 15 #include <linux/pm_runtime.h> 17 16 #include <linux/regmap.h> ··· 114 115 * @regmap: Register map of the device 115 116 * @fields: Register fields of the device 116 117 * @inputs: Array of channel input source specific structures 117 - * @lock: mutex lock to serialize sysfs attribute accesses 118 118 * @reg_config: Register value of INA3221_CONFIG 119 119 * @summation_shunt_resistor: equivalent shunt resistor value for summation 120 120 * @summation_channel_control: Value written to SCC field in INA3221_MASK_ENABLE ··· 124 126 struct regmap *regmap; 125 127 struct regmap_field *fields[F_MAX_FIELDS]; 126 128 struct ina3221_input inputs[INA3221_NUM_CHANNELS]; 127 - struct mutex lock; 128 129 u32 reg_config; 129 130 int summation_shunt_resistor; 130 131 u32 summation_channel_control; ··· 527 530 static int ina3221_read(struct device *dev, enum hwmon_sensor_types type, 528 531 u32 attr, int channel, long *val) 529 532 { 530 - struct ina3221_data *ina = dev_get_drvdata(dev); 531 533 int ret; 532 - 533 - mutex_lock(&ina->lock); 534 534 535 535 switch (type) { 536 536 case hwmon_chip: ··· 544 550 ret = -EOPNOTSUPP; 545 551 break; 546 552 } 547 - 548 - mutex_unlock(&ina->lock); 549 - 550 553 return ret; 551 554 } 552 555 553 556 static int ina3221_write(struct device *dev, enum hwmon_sensor_types type, 554 557 u32 attr, int channel, long val) 555 558 { 556 - struct ina3221_data *ina = dev_get_drvdata(dev); 557 559 int ret; 558 - 559 - mutex_lock(&ina->lock); 560 560 561 561 switch (type) { 562 562 case hwmon_chip: ··· 567 579 ret = -EOPNOTSUPP; 568 580 break; 569 581 } 570 - 571 - mutex_unlock(&ina->lock); 572 - 573 582 return ret; 574 583 } 575 584 ··· 871 886 } 872 887 873 888 ina->pm_dev = dev; 874 - mutex_init(&ina->lock); 875 889 dev_set_drvdata(dev, ina); 876 890 877 891 /* Enable PM runtime -- status is suspended by default */ ··· 909 925 /* pm_runtime_put_noidle() will decrease the PM refcount until 0 */ 910 926 for (i = 0; i < INA3221_NUM_CHANNELS; i++) 911 927 pm_runtime_put_noidle(ina->pm_dev); 912 - mutex_destroy(&ina->lock); 913 928 914 929 return ret; 915 930 } ··· 924 941 /* pm_runtime_put_noidle() will decrease the PM refcount until 0 */ 925 942 for (i = 0; i < INA3221_NUM_CHANNELS; i++) 926 943 pm_runtime_put_noidle(ina->pm_dev); 927 - 928 - mutex_destroy(&ina->lock); 929 944 } 930 945 931 946 static int ina3221_suspend(struct device *dev)
-11
drivers/hwmon/jc42.c
··· 19 19 #include <linux/i2c.h> 20 20 #include <linux/hwmon.h> 21 21 #include <linux/err.h> 22 - #include <linux/mutex.h> 23 22 #include <linux/regmap.h> 24 23 25 24 /* Addresses to scan */ ··· 178 179 179 180 /* Each client has this additional data */ 180 181 struct jc42_data { 181 - struct mutex update_lock; /* protect register access */ 182 182 struct regmap *regmap; 183 183 bool extended; /* true if extended range supported */ 184 184 bool valid; ··· 213 215 struct jc42_data *data = dev_get_drvdata(dev); 214 216 unsigned int regval; 215 217 int ret, temp, hyst; 216 - 217 - mutex_lock(&data->update_lock); 218 218 219 219 switch (attr) { 220 220 case hwmon_temp_input: ··· 291 295 break; 292 296 } 293 297 294 - mutex_unlock(&data->update_lock); 295 - 296 298 return ret; 297 299 } 298 300 ··· 301 307 unsigned int regval; 302 308 int diff, hyst; 303 309 int ret; 304 - 305 - mutex_lock(&data->update_lock); 306 310 307 311 switch (attr) { 308 312 case hwmon_temp_min: ··· 347 355 ret = -EOPNOTSUPP; 348 356 break; 349 357 } 350 - 351 - mutex_unlock(&data->update_lock); 352 358 353 359 return ret; 354 360 } ··· 488 498 return PTR_ERR(data->regmap); 489 499 490 500 i2c_set_clientdata(client, data); 491 - mutex_init(&data->update_lock); 492 501 493 502 ret = regmap_read(data->regmap, JC42_REG_CAP, &cap); 494 503 if (ret)
+7 -5
drivers/hwmon/k10temp.c
··· 31 31 module_param(force, bool, 0444); 32 32 MODULE_PARM_DESC(force, "force loading on processors with erratum 319"); 33 33 34 - /* Provide lock for writing to NB_SMU_IND_ADDR */ 35 - static DEFINE_MUTEX(nb_smu_ind_mutex); 36 - 37 34 #ifndef PCI_DEVICE_ID_AMD_15H_M70H_NB_F3 38 35 #define PCI_DEVICE_ID_AMD_15H_M70H_NB_F3 0x15b3 39 36 #endif ··· 80 83 * Do not round off to zero for negative Tctl or Tdie values if the flag is set 81 84 */ 82 85 #define AMD_I3255_STR "3255" 86 + 87 + /* 88 + * PCI Device IDs for AMD's Family 17h-based SOCs. 89 + * Defining locally as IDs are not shared. 90 + */ 91 + #define PCI_DEVICE_ID_AMD_17H_M90H_DF_F3 0x1663 83 92 84 93 /* 85 94 * PCI Device IDs for AMD's Family 1Ah-based SOCs. ··· 140 137 static void amd_nb_index_read(struct pci_dev *pdev, unsigned int devfn, 141 138 unsigned int base, int offset, u32 *val) 142 139 { 143 - mutex_lock(&nb_smu_ind_mutex); 144 140 pci_bus_write_config_dword(pdev->bus, devfn, 145 141 base, offset); 146 142 pci_bus_read_config_dword(pdev->bus, devfn, 147 143 base + 4, val); 148 - mutex_unlock(&nb_smu_ind_mutex); 149 144 } 150 145 151 146 static void read_htcreg_nb_f15(struct pci_dev *pdev, u32 *regval) ··· 554 553 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M40H_DF_F3) }, 555 554 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M60H_DF_F3) }, 556 555 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F3) }, 556 + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M90H_DF_F3) }, 557 557 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_MA0H_DF_F3) }, 558 558 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_19H_DF_F3) }, 559 559 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_19H_M10H_DF_F3) },
+3 -2
drivers/hwmon/lm78.c
··· 843 843 } 844 844 } 845 845 846 - #define REALLY_SLOW_IO 847 846 /* 848 847 * We need the timeouts for at least some LM78-like 849 848 * chips. But only if we read 'undefined' registers. 849 + * There used to be a "#define REALLY_SLOW_IO" to enforce that, but 850 + * this has been without any effect since more than a decade, so it 851 + * has been dropped. 850 852 */ 851 853 val = inb_p(address + 1); 852 854 if (inb_p(address + 2) != val 853 855 || inb_p(address + 3) != val 854 856 || inb_p(address + 7) != val) 855 857 goto release; 856 - #undef REALLY_SLOW_IO 857 858 858 859 /* 859 860 * We should be able to change the 7 LSB of the address port. The
+11 -5
drivers/hwmon/lm87.c
··· 116 116 (((val) < 0 ? (val) - 500 : \ 117 117 (val) + 500) / 1000)) 118 118 119 - #define FAN_FROM_REG(reg, div) ((reg) == 255 || (reg) == 0 ? 0 : \ 120 - (1350000 + (reg)*(div) / 2) / ((reg) * (div))) 119 + static int fan_from_reg(int reg, int div) 120 + { 121 + if (reg == 255 || reg == 0) 122 + return 0; 123 + 124 + return (1350000 + reg * div / 2) / (reg * div); 125 + } 126 + 121 127 #define FAN_TO_REG(val, div) ((val) * (div) * 255 <= 1350000 ? 255 : \ 122 128 (1350000 + (val)*(div) / 2) / ((val) * (div))) 123 129 ··· 471 465 struct lm87_data *data = lm87_update_device(dev); 472 466 int nr = to_sensor_dev_attr(attr)->index; 473 467 474 - return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], 468 + return sprintf(buf, "%d\n", fan_from_reg(data->fan[nr], 475 469 FAN_DIV_FROM_REG(data->fan_div[nr]))); 476 470 } 477 471 ··· 481 475 struct lm87_data *data = lm87_update_device(dev); 482 476 int nr = to_sensor_dev_attr(attr)->index; 483 477 484 - return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], 478 + return sprintf(buf, "%d\n", fan_from_reg(data->fan_min[nr], 485 479 FAN_DIV_FROM_REG(data->fan_div[nr]))); 486 480 } 487 481 ··· 540 534 return err; 541 535 542 536 mutex_lock(&data->update_lock); 543 - min = FAN_FROM_REG(data->fan_min[nr], 537 + min = fan_from_reg(data->fan_min[nr], 544 538 FAN_DIV_FROM_REG(data->fan_div[nr])); 545 539 546 540 switch (val) {
+4 -21
drivers/hwmon/lm90.c
··· 108 108 #include <linux/hwmon.h> 109 109 #include <linux/kstrtox.h> 110 110 #include <linux/module.h> 111 - #include <linux/mutex.h> 112 111 #include <linux/of.h> 113 112 #include <linux/regulator/consumer.h> 114 113 #include <linux/slab.h> ··· 734 735 struct hwmon_channel_info temp_info; 735 736 const struct hwmon_channel_info *info[3]; 736 737 struct hwmon_chip_info chip; 737 - struct mutex update_lock; 738 738 struct delayed_work alert_work; 739 739 struct work_struct report_work; 740 740 bool valid; /* true if register values are valid */ ··· 1224 1226 { 1225 1227 int err; 1226 1228 1227 - mutex_lock(&data->update_lock); 1229 + hwmon_lock(data->hwmon_dev); 1228 1230 err = lm90_update_alarms_locked(data, force); 1229 - mutex_unlock(&data->update_lock); 1231 + hwmon_unlock(data->hwmon_dev); 1230 1232 1231 1233 return err; 1232 1234 } ··· 1517 1519 int err; 1518 1520 u16 bit; 1519 1521 1520 - mutex_lock(&data->update_lock); 1521 1522 err = lm90_update_device(dev); 1522 - mutex_unlock(&data->update_lock); 1523 1523 if (err) 1524 1524 return err; 1525 1525 ··· 1586 1590 struct lm90_data *data = dev_get_drvdata(dev); 1587 1591 int err; 1588 1592 1589 - mutex_lock(&data->update_lock); 1590 - 1591 1593 err = lm90_update_device(dev); 1592 1594 if (err) 1593 - goto error; 1595 + return err; 1594 1596 1595 1597 switch (attr) { 1596 1598 case hwmon_temp_min: ··· 1618 1624 err = -EOPNOTSUPP; 1619 1625 break; 1620 1626 } 1621 - error: 1622 - mutex_unlock(&data->update_lock); 1623 - 1624 1627 return err; 1625 1628 } 1626 1629 ··· 1653 1662 struct lm90_data *data = dev_get_drvdata(dev); 1654 1663 int err; 1655 1664 1656 - mutex_lock(&data->update_lock); 1657 1665 err = lm90_update_device(dev); 1658 - mutex_unlock(&data->update_lock); 1659 1666 if (err) 1660 1667 return err; 1661 1668 ··· 1699 1710 struct i2c_client *client = data->client; 1700 1711 int err; 1701 1712 1702 - mutex_lock(&data->update_lock); 1703 - 1704 1713 err = lm90_update_device(dev); 1705 1714 if (err) 1706 - goto error; 1715 + return err; 1707 1716 1708 1717 switch (attr) { 1709 1718 case hwmon_chip_update_interval: ··· 1715 1728 err = -EOPNOTSUPP; 1716 1729 break; 1717 1730 } 1718 - error: 1719 - mutex_unlock(&data->update_lock); 1720 - 1721 1731 return err; 1722 1732 } 1723 1733 ··· 2777 2793 2778 2794 data->client = client; 2779 2795 i2c_set_clientdata(client, data); 2780 - mutex_init(&data->update_lock); 2781 2796 INIT_DELAYED_WORK(&data->alert_work, lm90_alert_work); 2782 2797 INIT_WORK(&data->report_work, lm90_report_alarms); 2783 2798
+2 -9
drivers/hwmon/lm92.c
··· 32 32 #include <linux/i2c.h> 33 33 #include <linux/init.h> 34 34 #include <linux/module.h> 35 - #include <linux/mutex.h> 36 35 #include <linux/regmap.h> 37 36 #include <linux/slab.h> 38 37 ··· 77 78 /* Client data (each client gets its own) */ 78 79 struct lm92_data { 79 80 struct regmap *regmap; 80 - struct mutex update_lock; 81 81 int resolution; 82 82 }; 83 83 ··· 197 199 break; 198 200 case hwmon_temp_crit_hyst: 199 201 val = clamp_val(val, -120000, 220000); 200 - mutex_lock(&data->update_lock); 201 202 err = regmap_read(regmap, LM92_REG_TEMP_CRIT, &temp); 202 203 if (err) 203 - goto unlock; 204 + return err; 204 205 val = TEMP_TO_REG(TEMP_FROM_REG(temp) - val, data->resolution); 205 - err = regmap_write(regmap, LM92_REG_TEMP_HYST, val); 206 - unlock: 207 - mutex_unlock(&data->update_lock); 208 - return err; 206 + return regmap_write(regmap, LM92_REG_TEMP_HYST, val); 209 207 default: 210 208 return -EOPNOTSUPP; 211 209 } ··· 390 396 391 397 data->regmap = regmap; 392 398 data->resolution = (unsigned long)i2c_get_match_data(client); 393 - mutex_init(&data->update_lock); 394 399 395 400 /* Initialize the chipset */ 396 401 err = lm92_init_client(regmap);
+2 -10
drivers/hwmon/lm95234.c
··· 14 14 #include <linux/init.h> 15 15 #include <linux/module.h> 16 16 #include <linux/slab.h> 17 - #include <linux/mutex.h> 18 17 #include <linux/regmap.h> 19 18 #include <linux/util_macros.h> 20 19 ··· 53 54 /* Client data (each client gets its own) */ 54 55 struct lm95234_data { 55 56 struct regmap *regmap; 56 - struct mutex update_lock; 57 57 enum chips type; 58 58 }; 59 59 ··· 105 107 u32 tcrit; 106 108 int ret; 107 109 108 - mutex_lock(&data->update_lock); 109 - 110 110 ret = regmap_read(data->regmap, LM95234_REG_TCRIT1(0), &tcrit); 111 111 if (ret) 112 - goto unlock; 112 + return ret; 113 113 114 114 val = DIV_ROUND_CLOSEST(clamp_val(val, -255000, 255000), 1000); 115 115 val = clamp_val((int)tcrit - val, 0, 31); 116 116 117 - ret = regmap_write(data->regmap, LM95234_REG_TCRIT_HYST, val); 118 - unlock: 119 - mutex_unlock(&data->update_lock); 120 - return ret; 117 + return regmap_write(data->regmap, LM95234_REG_TCRIT_HYST, val); 121 118 } 122 119 123 120 static int lm95234_crit_reg(int channel) ··· 519 526 return PTR_ERR(regmap); 520 527 521 528 data->regmap = regmap; 522 - mutex_init(&data->update_lock); 523 529 524 530 /* Initialize the LM95234 chip */ 525 531 err = lm95234_init_client(dev, regmap);
-16
drivers/hwmon/lm95241.c
··· 15 15 #include <linux/jiffies.h> 16 16 #include <linux/hwmon.h> 17 17 #include <linux/module.h> 18 - #include <linux/mutex.h> 19 18 #include <linux/slab.h> 20 19 21 20 #define DEVNAME "lm95241" ··· 74 75 /* Client data (each client gets its own) */ 75 76 struct lm95241_data { 76 77 struct i2c_client *client; 77 - struct mutex update_lock; 78 78 unsigned long last_updated; /* in jiffies */ 79 79 unsigned long interval; /* in milli-seconds */ 80 80 bool valid; /* false until following fields are valid */ ··· 100 102 struct lm95241_data *data = dev_get_drvdata(dev); 101 103 struct i2c_client *client = data->client; 102 104 103 - mutex_lock(&data->update_lock); 104 - 105 105 if (time_after(jiffies, data->last_updated 106 106 + msecs_to_jiffies(data->interval)) || 107 107 !data->valid) { ··· 116 120 data->last_updated = jiffies; 117 121 data->valid = true; 118 122 } 119 - 120 - mutex_unlock(&data->update_lock); 121 - 122 123 return data; 123 124 } 124 125 ··· 197 204 u8 config; 198 205 int ret; 199 206 200 - mutex_lock(&data->update_lock); 201 - 202 207 switch (attr) { 203 208 case hwmon_chip_update_interval: 204 209 config = data->config & ~CFG_CRMASK; ··· 222 231 ret = -EOPNOTSUPP; 223 232 break; 224 233 } 225 - mutex_unlock(&data->update_lock); 226 234 return ret; 227 235 } 228 236 ··· 231 241 struct lm95241_data *data = dev_get_drvdata(dev); 232 242 struct i2c_client *client = data->client; 233 243 int ret; 234 - 235 - mutex_lock(&data->update_lock); 236 244 237 245 switch (attr) { 238 246 case hwmon_temp_min: ··· 301 313 ret = -EOPNOTSUPP; 302 314 break; 303 315 } 304 - 305 - mutex_unlock(&data->update_lock); 306 - 307 316 return ret; 308 317 } 309 318 ··· 428 443 return -ENOMEM; 429 444 430 445 data->client = client; 431 - mutex_init(&data->update_lock); 432 446 433 447 /* Initialize the LM95241 chip */ 434 448 lm95241_init_client(client, data);
+2 -14
drivers/hwmon/lm95245.c
··· 13 13 #include <linux/hwmon.h> 14 14 #include <linux/i2c.h> 15 15 #include <linux/module.h> 16 - #include <linux/mutex.h> 17 16 #include <linux/regmap.h> 18 17 #include <linux/slab.h> 19 18 ··· 85 86 /* Client data (each client gets its own) */ 86 87 struct lm95245_data { 87 88 struct regmap *regmap; 88 - struct mutex update_lock; 89 89 int interval; /* in msecs */ 90 90 }; 91 91 ··· 277 279 ret = regmap_write(regmap, reg, val); 278 280 return ret; 279 281 case hwmon_temp_crit_hyst: 280 - mutex_lock(&data->update_lock); 281 282 ret = regmap_read(regmap, LM95245_REG_RW_LOCAL_OS_TCRIT_LIMIT, 282 283 &regval); 283 - if (ret < 0) { 284 - mutex_unlock(&data->update_lock); 284 + if (ret < 0) 285 285 return ret; 286 - } 287 286 /* Clamp to reasonable range to prevent overflow */ 288 287 val = clamp_val(val, -1000000, 1000000); 289 288 val = regval - val / 1000; 290 289 val = clamp_val(val, 0, 31); 291 290 ret = regmap_write(regmap, LM95245_REG_RW_COMMON_HYSTERESIS, 292 291 val); 293 - mutex_unlock(&data->update_lock); 294 292 return ret; 295 293 case hwmon_temp_offset: 296 294 val = clamp_val(val, -128000, 127875); ··· 326 332 long val) 327 333 { 328 334 struct lm95245_data *data = dev_get_drvdata(dev); 329 - int ret; 330 335 331 336 switch (attr) { 332 337 case hwmon_chip_update_interval: 333 - mutex_lock(&data->update_lock); 334 - ret = lm95245_set_conversion_rate(data, val); 335 - mutex_unlock(&data->update_lock); 336 - return ret; 338 + return lm95245_set_conversion_rate(data, val); 337 339 default: 338 340 return -EOPNOTSUPP; 339 341 } ··· 531 541 data->regmap = devm_regmap_init_i2c(client, &lm95245_regmap_config); 532 542 if (IS_ERR(data->regmap)) 533 543 return PTR_ERR(data->regmap); 534 - 535 - mutex_init(&data->update_lock); 536 544 537 545 /* Initialize the LM95245 chip */ 538 546 ret = lm95245_init_client(data);
+3 -15
drivers/hwmon/lochnagar-hwmon.c
··· 10 10 11 11 #include <linux/delay.h> 12 12 #include <linux/hwmon.h> 13 - #include <linux/hwmon-sysfs.h> 14 13 #include <linux/math64.h> 15 14 #include <linux/mfd/lochnagar.h> 16 15 #include <linux/mfd/lochnagar2_regs.h> ··· 41 42 struct regmap *regmap; 42 43 43 44 long power_nsamples[ARRAY_SIZE(lochnagar_chan_names)]; 44 - 45 - /* Lock to ensure only a single sensor is read at a time */ 46 - struct mutex sensor_lock; 47 45 }; 48 46 49 47 enum lochnagar_measure_mode { ··· 174 178 u32 data; 175 179 int ret; 176 180 177 - mutex_lock(&priv->sensor_lock); 178 - 179 181 ret = do_measurement(regmap, chan, mode, nsamples); 180 182 if (ret < 0) { 181 183 dev_err(dev, "Failed to perform measurement: %d\n", ret); 182 - goto error; 184 + return ret; 183 185 } 184 186 185 187 ret = request_data(regmap, chan, &data); 186 188 if (ret < 0) { 187 189 dev_err(dev, "Failed to read measurement: %d\n", ret); 188 - goto error; 190 + return ret; 189 191 } 190 192 191 193 *val = float_to_long(data, precision); 192 - 193 - error: 194 - mutex_unlock(&priv->sensor_lock); 195 - 196 - return ret; 194 + return 0; 197 195 } 198 196 199 197 static int read_power(struct device *dev, int chan, long *val) ··· 367 377 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 368 378 if (!priv) 369 379 return -ENOMEM; 370 - 371 - mutex_init(&priv->sensor_lock); 372 380 373 381 priv->regmap = dev_get_regmap(dev->parent, NULL); 374 382 if (!priv->regmap) {
+31 -61
drivers/hwmon/ltc2947-core.c
··· 9 9 #include <linux/clk.h> 10 10 #include <linux/device.h> 11 11 #include <linux/hwmon.h> 12 - #include <linux/hwmon-sysfs.h> 13 12 #include <linux/module.h> 13 + #include <linux/math64.h> 14 14 #include <linux/mod_devicetable.h> 15 15 #include <linux/property.h> 16 16 #include <linux/regmap.h> ··· 120 120 struct ltc2947_data { 121 121 struct regmap *map; 122 122 struct device *dev; 123 - /* 124 - * The mutex is needed because the device has 2 memory pages. When 125 - * reading/writing the correct page needs to be set so that, the 126 - * complete sequence select_page->read/write needs to be protected. 127 - */ 128 - struct mutex lock; 129 123 u32 lsb_energy; 130 124 bool gpio_out; 131 125 }; ··· 175 181 int ret; 176 182 u64 __val = 0; 177 183 178 - mutex_lock(&st->lock); 179 - 180 184 ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, page); 181 - if (ret) { 182 - mutex_unlock(&st->lock); 185 + if (ret) 183 186 return ret; 184 - } 185 187 186 188 dev_dbg(st->dev, "Read val, reg:%02X, p:%d sz:%zu\n", reg, page, 187 189 size); ··· 196 206 ret = -EINVAL; 197 207 break; 198 208 } 199 - 200 - mutex_unlock(&st->lock); 201 209 202 210 if (ret) 203 211 return ret; ··· 230 242 { 231 243 int ret; 232 244 233 - mutex_lock(&st->lock); 234 245 /* set device on correct page */ 235 246 ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, page); 236 - if (ret) { 237 - mutex_unlock(&st->lock); 247 + if (ret) 238 248 return ret; 239 - } 240 249 241 250 dev_dbg(st->dev, "Write val, r:%02X, p:%d, sz:%zu, val:%016llX\n", 242 251 reg, page, size, val); ··· 249 264 ret = -EINVAL; 250 265 break; 251 266 } 252 - 253 - mutex_unlock(&st->lock); 254 267 255 268 return ret; 256 269 } ··· 278 295 279 296 memset(alarms, 0, sizeof(alarms)); 280 297 281 - mutex_lock(&st->lock); 282 - 283 298 ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, LTC2947_PAGE0); 284 299 if (ret) 285 - goto unlock; 300 + return ret; 286 301 287 302 dev_dbg(st->dev, "Read alarm, reg:%02X, mask:%02X\n", reg, mask); 288 303 /* ··· 291 310 ret = regmap_bulk_read(st->map, LTC2947_REG_STATUS, alarms, 292 311 sizeof(alarms)); 293 312 if (ret) 294 - goto unlock; 313 + return ret; 295 314 296 315 /* get the alarm */ 297 316 *val = !!(alarms[offset] & mask); 298 - unlock: 299 - mutex_unlock(&st->lock); 300 - return ret; 301 - } 302 - 303 - static ssize_t ltc2947_show_value(struct device *dev, 304 - struct device_attribute *da, char *buf) 305 - { 306 - struct ltc2947_data *st = dev_get_drvdata(dev); 307 - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); 308 - int ret; 309 - s64 val = 0; 310 - 311 - ret = ltc2947_val_read(st, attr->index, LTC2947_PAGE0, 6, &val); 312 - if (ret) 313 - return ret; 314 - 315 - /* value in microJoule. st->lsb_energy was multiplied by 10E9 */ 316 - val = div_s64(val * st->lsb_energy, 1000); 317 - 318 - return sprintf(buf, "%lld\n", val); 317 + return 0; 319 318 } 320 319 321 320 static int ltc2947_read_temp(struct device *dev, const u32 attr, long *val, ··· 549 588 return 0; 550 589 } 551 590 591 + static int ltc2947_read_energy(struct device *dev, s64 *val, const int channel) 592 + { 593 + int reg = channel ? LTC2947_REG_ENERGY2 : LTC2947_REG_ENERGY1; 594 + struct ltc2947_data *st = dev_get_drvdata(dev); 595 + s64 __val = 0; 596 + int ret; 597 + 598 + ret = ltc2947_val_read(st, reg, LTC2947_PAGE0, 6, &__val); 599 + if (ret) 600 + return ret; 601 + 602 + /* value in microJoule. st->lsb_energy was multiplied by 10E9 */ 603 + *val = DIV_S64_ROUND_CLOSEST(__val * st->lsb_energy, 1000); 604 + 605 + return 0; 606 + } 607 + 552 608 static int ltc2947_read(struct device *dev, enum hwmon_sensor_types type, 553 609 u32 attr, int channel, long *val) 554 610 { ··· 578 600 return ltc2947_read_power(dev, attr, val); 579 601 case hwmon_temp: 580 602 return ltc2947_read_temp(dev, attr, val, channel); 603 + case hwmon_energy64: 604 + return ltc2947_read_energy(dev, (s64 *)val, channel); 581 605 default: 582 606 return -ENOTSUPP; 583 607 } ··· 877 897 return ltc2947_power_is_visible(attr); 878 898 case hwmon_temp: 879 899 return ltc2947_temp_is_visible(attr); 900 + case hwmon_energy64: 901 + return 0444; 880 902 default: 881 903 return 0; 882 904 } ··· 911 929 HWMON_T_LABEL, 912 930 HWMON_T_MAX_ALARM | HWMON_T_MIN_ALARM | HWMON_T_MAX | 913 931 HWMON_T_MIN | HWMON_T_LABEL), 932 + HWMON_CHANNEL_INFO(energy64, 933 + HWMON_E_INPUT, 934 + HWMON_E_INPUT), 914 935 NULL 915 936 }; 916 937 ··· 928 943 .ops = &ltc2947_hwmon_ops, 929 944 .info = ltc2947_info, 930 945 }; 931 - 932 - /* energy attributes are 6bytes wide so we need u64 */ 933 - static SENSOR_DEVICE_ATTR(energy1_input, 0444, ltc2947_show_value, NULL, 934 - LTC2947_REG_ENERGY1); 935 - static SENSOR_DEVICE_ATTR(energy2_input, 0444, ltc2947_show_value, NULL, 936 - LTC2947_REG_ENERGY2); 937 - 938 - static struct attribute *ltc2947_attrs[] = { 939 - &sensor_dev_attr_energy1_input.dev_attr.attr, 940 - &sensor_dev_attr_energy2_input.dev_attr.attr, 941 - NULL, 942 - }; 943 - ATTRIBUTE_GROUPS(ltc2947); 944 946 945 947 static int ltc2947_setup(struct ltc2947_data *st) 946 948 { ··· 1079 1107 st->map = map; 1080 1108 st->dev = dev; 1081 1109 dev_set_drvdata(dev, st); 1082 - mutex_init(&st->lock); 1083 1110 1084 1111 ret = ltc2947_setup(st); 1085 1112 if (ret) 1086 1113 return ret; 1087 1114 1088 1115 hwmon = devm_hwmon_device_register_with_info(dev, name, st, 1089 - &ltc2947_chip_info, 1090 - ltc2947_groups); 1116 + &ltc2947_chip_info, NULL); 1091 1117 return PTR_ERR_OR_ZERO(hwmon); 1092 1118 } 1093 1119 EXPORT_SYMBOL_GPL(ltc2947_core_probe);
-8
drivers/hwmon/ltc4245.c
··· 18 18 #include <linux/slab.h> 19 19 #include <linux/i2c.h> 20 20 #include <linux/hwmon.h> 21 - #include <linux/hwmon-sysfs.h> 22 21 #include <linux/jiffies.h> 23 22 #include <linux/platform_data/ltc4245.h> 24 23 ··· 50 51 struct ltc4245_data { 51 52 struct i2c_client *client; 52 53 53 - struct mutex update_lock; 54 54 bool valid; 55 55 unsigned long last_updated; /* in jiffies */ 56 56 ··· 130 132 s32 val; 131 133 int i; 132 134 133 - mutex_lock(&data->update_lock); 134 - 135 135 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 136 - 137 136 /* Read control registers -- 0x00 to 0x07 */ 138 137 for (i = 0; i < ARRAY_SIZE(data->cregs); i++) { 139 138 val = i2c_smbus_read_byte_data(client, i); ··· 155 160 data->last_updated = jiffies; 156 161 data->valid = true; 157 162 } 158 - 159 - mutex_unlock(&data->update_lock); 160 163 161 164 return data; 162 165 } ··· 447 454 return -ENOMEM; 448 455 449 456 data->client = client; 450 - mutex_init(&data->update_lock); 451 457 data->use_extra_gpios = ltc4245_use_extra_gpios(client); 452 458 453 459 /* Initialize the LTC4245 chip */
+13 -55
drivers/hwmon/ltc4282.c
··· 12 12 #include <linux/delay.h> 13 13 #include <linux/device.h> 14 14 #include <linux/hwmon.h> 15 - #include <linux/hwmon-sysfs.h> 16 15 #include <linux/i2c.h> 17 16 #include <linux/math.h> 18 17 #include <linux/minmax.h> 19 18 #include <linux/module.h> 20 19 #include <linux/mod_devicetable.h> 21 - #include <linux/mutex.h> 22 20 #include <linux/regmap.h> 23 21 #include <linux/property.h> 24 22 #include <linux/string.h> ··· 130 132 131 133 struct ltc4282_state { 132 134 struct regmap *map; 133 - /* Protect against multiple accesses to the device registers */ 134 - struct mutex lock; 135 135 struct clk_hw clk_hw; 136 136 /* 137 137 * Used to cache values for VDD/VSOURCE depending which will be used ··· 278 282 static int ltc4282_read_alarm(struct ltc4282_state *st, u32 reg, u32 mask, 279 283 long *val) 280 284 { 281 - guard(mutex)(&st->lock); 282 285 return __ltc4282_read_alarm(st, reg, mask, val); 283 286 } 284 287 285 288 static int ltc4282_vdd_source_read_in(struct ltc4282_state *st, u32 channel, 286 289 long *val) 287 290 { 288 - guard(mutex)(&st->lock); 289 291 if (!st->in0_1_cache[channel].en) 290 292 return -ENODATA; 291 293 ··· 295 301 { 296 302 int ret; 297 303 298 - guard(mutex)(&st->lock); 299 304 if (!st->in0_1_cache[channel].en) { 300 305 *val = *cached; 301 306 return 0; ··· 311 318 static int ltc4282_vdd_source_read_lim(struct ltc4282_state *st, u32 reg, 312 319 u32 channel, u32 *cached, long *val) 313 320 { 314 - guard(mutex)(&st->lock); 315 321 if (!st->in0_1_cache[channel].en) 316 322 return ltc4282_read_voltage_byte_cached(st, reg, st->vfs_out, 317 323 val, cached); ··· 321 329 static int ltc4282_vdd_source_read_alm(struct ltc4282_state *st, u32 mask, 322 330 u32 channel, long *val) 323 331 { 324 - guard(mutex)(&st->lock); 325 332 if (!st->in0_1_cache[channel].en) { 326 333 /* 327 334 * Do this otherwise alarms can get confused because we clear ··· 404 413 channel, 405 414 &st->in0_1_cache[channel].in_min_raw, val); 406 415 case hwmon_in_enable: 407 - scoped_guard(mutex, &st->lock) { 408 - *val = st->in0_1_cache[channel].en; 409 - } 416 + *val = st->in0_1_cache[channel].en; 410 417 return 0; 411 418 case hwmon_in_fault: 412 419 /* ··· 530 541 return 0; 531 542 } 532 543 533 - static int ltc4282_read_energy(const struct ltc4282_state *st, u64 *val) 544 + static int ltc4282_read_energy(const struct ltc4282_state *st, s64 *val) 534 545 { 535 546 u64 temp, energy; 536 547 __be64 raw; ··· 602 613 case hwmon_power: 603 614 return ltc4282_read_power(st, attr, val); 604 615 case hwmon_energy: 605 - scoped_guard(mutex, &st->lock) { 606 - *val = st->energy_en; 607 - } 616 + *val = st->energy_en; 608 617 return 0; 618 + case hwmon_energy64: 619 + if (st->energy_en) 620 + return ltc4282_read_energy(st, (s64 *)val); 621 + return -ENODATA; 609 622 default: 610 623 return -EOPNOTSUPP; 611 624 } ··· 674 683 static int ltc4282_in_write_history(struct ltc4282_state *st, u32 reg, 675 684 long lowest, long highest, u32 fs) 676 685 { 677 - guard(mutex)(&st->lock); 678 686 return __ltc4282_in_write_history(st, reg, lowest, highest, fs); 679 687 } 680 688 681 689 static int ltc4282_power_reset_hist(struct ltc4282_state *st) 682 690 { 683 691 int ret; 684 - 685 - guard(mutex)(&st->lock); 686 692 687 693 ret = ltc4282_write_power_word(st, LTC4282_POWER_LOWEST, 688 694 st->power_max); ··· 786 798 { 787 799 int ret; 788 800 789 - guard(mutex)(&st->lock); 790 801 if (st->in0_1_cache[channel].en) 791 802 ret = ltc4282_write_voltage_byte(st, reg, st->vfs_out, val); 792 803 else ··· 803 816 if (channel == LTC4282_CHAN_VDD) 804 817 lowest = st->vdd; 805 818 806 - guard(mutex)(&st->lock); 807 819 if (st->in0_1_cache[channel].en) { 808 820 ret = __ltc4282_in_write_history(st, LTC4282_VSOURCE_LOWEST, 809 821 lowest, 0, st->vfs_out); ··· 842 856 int ret, other_chan = ~channel & 0x1; 843 857 u8 __val = val; 844 858 845 - guard(mutex)(&st->lock); 846 859 if (st->in0_1_cache[channel].en == !!val) 847 860 return 0; 848 861 ··· 918 933 { 919 934 int ret; 920 935 921 - guard(mutex)(&st->lock); 922 - 923 936 ret = __ltc4282_in_write_history(st, LTC4282_VSENSE_LOWEST, 924 937 st->vsense_max, 0, 40 * MILLI); 925 938 if (ret) ··· 952 969 { 953 970 int ret; 954 971 955 - guard(mutex)(&st->lock); 956 972 /* setting the bit halts the meter */ 957 973 ret = regmap_update_bits(st->map, LTC4282_ADC_CTRL, 958 974 LTC4282_METER_HALT_MASK, ··· 1060 1078 case hwmon_energy: 1061 1079 /* hwmon_energy_enable */ 1062 1080 return 0644; 1081 + case hwmon_energy64: 1082 + /* hwmon_energy_input */ 1083 + return 0444; 1063 1084 default: 1064 1085 return 0; 1065 1086 } ··· 1089 1104 default: 1090 1105 return -EOPNOTSUPP; 1091 1106 } 1092 - } 1093 - 1094 - static ssize_t ltc4282_energy_show(struct device *dev, 1095 - struct device_attribute *da, char *buf) 1096 - { 1097 - struct ltc4282_state *st = dev_get_drvdata(dev); 1098 - u64 energy; 1099 - int ret; 1100 - 1101 - guard(mutex)(&st->lock); 1102 - if (!st->energy_en) 1103 - return -ENODATA; 1104 - 1105 - ret = ltc4282_read_energy(st, &energy); 1106 - if (ret < 0) 1107 - return ret; 1108 - 1109 - return sysfs_emit(buf, "%llu\n", energy); 1110 1107 } 1111 1108 1112 1109 static const struct clk_ops ltc4282_ops = { ··· 1555 1588 HWMON_P_RESET_HISTORY | HWMON_P_LABEL), 1556 1589 HWMON_CHANNEL_INFO(energy, 1557 1590 HWMON_E_ENABLE), 1591 + HWMON_CHANNEL_INFO(energy64, 1592 + HWMON_E_INPUT), 1558 1593 NULL 1559 1594 }; 1560 1595 ··· 1571 1602 .ops = &ltc4282_hwmon_ops, 1572 1603 .info = ltc4282_info, 1573 1604 }; 1574 - 1575 - /* energy attributes are 6bytes wide so we need u64 */ 1576 - static SENSOR_DEVICE_ATTR_RO(energy1_input, ltc4282_energy, 0); 1577 - 1578 - static struct attribute *ltc4282_attrs[] = { 1579 - &sensor_dev_attr_energy1_input.dev_attr.attr, 1580 - NULL 1581 - }; 1582 - ATTRIBUTE_GROUPS(ltc4282); 1583 1605 1584 1606 static int ltc4282_show_fault_log(void *arg, u64 *val, u32 mask) 1585 1607 { ··· 1676 1716 if (ret) 1677 1717 return ret; 1678 1718 1679 - mutex_init(&st->lock); 1680 1719 hwmon = devm_hwmon_device_register_with_info(dev, "ltc4282", st, 1681 - &ltc4282_chip_info, 1682 - ltc4282_groups); 1720 + &ltc4282_chip_info, NULL); 1683 1721 if (IS_ERR(hwmon)) 1684 1722 return PTR_ERR(hwmon); 1685 1723
+851
drivers/hwmon/macsmc-hwmon.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only OR MIT 2 + /* 3 + * Apple SMC hwmon driver for Apple Silicon platforms 4 + * 5 + * The System Management Controller on Apple Silicon devices is responsible for 6 + * measuring data from sensors across the SoC and machine. These include power, 7 + * temperature, voltage and current sensors. Some "sensors" actually expose 8 + * derived values. An example of this is the key PHPC, which is an estimate 9 + * of the heat energy being dissipated by the SoC. 10 + * 11 + * While each SoC only has one SMC variant, each platform exposes a different 12 + * set of sensors. For example, M1 MacBooks expose battery telemetry sensors 13 + * which are not present on the M1 Mac mini. For this reason, the available 14 + * sensors for a given platform are described in the device tree in a child 15 + * node of the SMC device. We must walk this list of available sensors and 16 + * populate the required hwmon data structures at runtime. 17 + * 18 + * Originally based on a concept by Jean-Francois Bortolotti <jeff@borto.fr> 19 + * 20 + * Copyright The Asahi Linux Contributors 21 + */ 22 + 23 + #include <linux/bitfield.h> 24 + #include <linux/hwmon.h> 25 + #include <linux/mfd/macsmc.h> 26 + #include <linux/module.h> 27 + #include <linux/of.h> 28 + #include <linux/platform_device.h> 29 + 30 + #define MAX_LABEL_LENGTH 32 31 + 32 + /* Temperature, voltage, current, power, fan(s) */ 33 + #define NUM_SENSOR_TYPES 5 34 + 35 + #define FLT_EXP_BIAS 127 36 + #define FLT_EXP_MASK GENMASK(30, 23) 37 + #define FLT_MANT_BIAS 23 38 + #define FLT_MANT_MASK GENMASK(22, 0) 39 + #define FLT_SIGN_MASK BIT(31) 40 + 41 + static bool fan_control; 42 + module_param_unsafe(fan_control, bool, 0644); 43 + MODULE_PARM_DESC(fan_control, 44 + "Override the SMC to set your own fan speeds on supported machines"); 45 + 46 + struct macsmc_hwmon_sensor { 47 + struct apple_smc_key_info info; 48 + smc_key macsmc_key; 49 + char label[MAX_LABEL_LENGTH]; 50 + u32 attrs; 51 + }; 52 + 53 + struct macsmc_hwmon_fan { 54 + struct macsmc_hwmon_sensor now; 55 + struct macsmc_hwmon_sensor min; 56 + struct macsmc_hwmon_sensor max; 57 + struct macsmc_hwmon_sensor set; 58 + struct macsmc_hwmon_sensor mode; 59 + char label[MAX_LABEL_LENGTH]; 60 + u32 attrs; 61 + bool manual; 62 + }; 63 + 64 + struct macsmc_hwmon_sensors { 65 + struct hwmon_channel_info channel_info; 66 + struct macsmc_hwmon_sensor *sensors; 67 + u32 count; 68 + }; 69 + 70 + struct macsmc_hwmon_fans { 71 + struct hwmon_channel_info channel_info; 72 + struct macsmc_hwmon_fan *fans; 73 + u32 count; 74 + }; 75 + 76 + struct macsmc_hwmon { 77 + struct device *dev; 78 + struct apple_smc *smc; 79 + struct device *hwmon_dev; 80 + struct hwmon_chip_info chip_info; 81 + /* Chip + sensor types + NULL */ 82 + const struct hwmon_channel_info *channel_infos[1 + NUM_SENSOR_TYPES + 1]; 83 + struct macsmc_hwmon_sensors temp; 84 + struct macsmc_hwmon_sensors volt; 85 + struct macsmc_hwmon_sensors curr; 86 + struct macsmc_hwmon_sensors power; 87 + struct macsmc_hwmon_fans fan; 88 + }; 89 + 90 + static int macsmc_hwmon_read_label(struct device *dev, 91 + enum hwmon_sensor_types type, u32 attr, 92 + int channel, const char **str) 93 + { 94 + struct macsmc_hwmon *hwmon = dev_get_drvdata(dev); 95 + 96 + switch (type) { 97 + case hwmon_temp: 98 + *str = hwmon->temp.sensors[channel].label; 99 + break; 100 + case hwmon_in: 101 + *str = hwmon->volt.sensors[channel].label; 102 + break; 103 + case hwmon_curr: 104 + *str = hwmon->curr.sensors[channel].label; 105 + break; 106 + case hwmon_power: 107 + *str = hwmon->power.sensors[channel].label; 108 + break; 109 + case hwmon_fan: 110 + *str = hwmon->fan.fans[channel].label; 111 + break; 112 + default: 113 + return -EOPNOTSUPP; 114 + } 115 + 116 + return 0; 117 + } 118 + 119 + /* 120 + * A number of sensors report data in a 48.16 fixed-point decimal format that is 121 + * not used by any other function of the SMC. 122 + */ 123 + static int macsmc_hwmon_read_ioft_scaled(struct apple_smc *smc, smc_key key, 124 + u64 *p, int scale) 125 + { 126 + u64 val; 127 + int ret; 128 + 129 + ret = apple_smc_read_u64(smc, key, &val); 130 + if (ret < 0) 131 + return ret; 132 + 133 + *p = mult_frac(val, scale, 65536); 134 + 135 + return 0; 136 + } 137 + 138 + /* 139 + * Many sensors report their data as IEEE-754 floats. No other SMC function uses 140 + * them. 141 + */ 142 + static int macsmc_hwmon_read_f32_scaled(struct apple_smc *smc, smc_key key, 143 + int *p, int scale) 144 + { 145 + u32 fval; 146 + u64 val; 147 + int ret, exp; 148 + 149 + ret = apple_smc_read_u32(smc, key, &fval); 150 + if (ret < 0) 151 + return ret; 152 + 153 + val = ((u64)((fval & FLT_MANT_MASK) | BIT(23))); 154 + exp = ((fval >> 23) & 0xff) - FLT_EXP_BIAS - FLT_MANT_BIAS; 155 + 156 + /* We never have negatively scaled SMC floats */ 157 + val *= scale; 158 + 159 + if (exp > 63) 160 + val = U64_MAX; 161 + else if (exp < -63) 162 + val = 0; 163 + else if (exp < 0) 164 + val >>= -exp; 165 + else if (exp != 0 && (val & ~((1UL << (64 - exp)) - 1))) /* overflow */ 166 + val = U64_MAX; 167 + else 168 + val <<= exp; 169 + 170 + if (fval & FLT_SIGN_MASK) { 171 + if (val > (-(s64)INT_MIN)) 172 + *p = INT_MIN; 173 + else 174 + *p = -val; 175 + } else { 176 + if (val > INT_MAX) 177 + *p = INT_MAX; 178 + else 179 + *p = val; 180 + } 181 + 182 + return 0; 183 + } 184 + 185 + /* 186 + * The SMC has keys of multiple types, denoted by a FourCC of the same format 187 + * as the key ID. We don't know what data type a key encodes until we poke at it. 188 + */ 189 + static int macsmc_hwmon_read_key(struct apple_smc *smc, 190 + struct macsmc_hwmon_sensor *sensor, int scale, 191 + long *val) 192 + { 193 + int ret; 194 + 195 + switch (sensor->info.type_code) { 196 + /* 32-bit IEEE 754 float */ 197 + case __SMC_KEY('f', 'l', 't', ' '): { 198 + u32 flt_ = 0; 199 + 200 + ret = macsmc_hwmon_read_f32_scaled(smc, sensor->macsmc_key, 201 + &flt_, scale); 202 + if (ret) 203 + return ret; 204 + 205 + *val = flt_; 206 + break; 207 + } 208 + /* 48.16 fixed point decimal */ 209 + case __SMC_KEY('i', 'o', 'f', 't'): { 210 + u64 ioft = 0; 211 + 212 + ret = macsmc_hwmon_read_ioft_scaled(smc, sensor->macsmc_key, 213 + &ioft, scale); 214 + if (ret) 215 + return ret; 216 + 217 + *val = (long)ioft; 218 + break; 219 + } 220 + default: 221 + return -EOPNOTSUPP; 222 + } 223 + 224 + return 0; 225 + } 226 + 227 + static int macsmc_hwmon_write_f32(struct apple_smc *smc, smc_key key, int value) 228 + { 229 + u64 val; 230 + u32 fval = 0; 231 + int exp = 0, neg; 232 + 233 + val = abs(value); 234 + neg = val != value; 235 + 236 + if (val) { 237 + int msb = __fls(val) - exp; 238 + 239 + if (msb > 23) { 240 + val >>= msb - FLT_MANT_BIAS; 241 + exp -= msb - FLT_MANT_BIAS; 242 + } else if (msb < 23) { 243 + val <<= FLT_MANT_BIAS - msb; 244 + exp += msb; 245 + } 246 + 247 + fval = FIELD_PREP(FLT_SIGN_MASK, neg) | 248 + FIELD_PREP(FLT_EXP_MASK, exp + FLT_EXP_BIAS) | 249 + FIELD_PREP(FLT_MANT_MASK, val); 250 + } 251 + 252 + return apple_smc_write_u32(smc, key, fval); 253 + } 254 + 255 + static int macsmc_hwmon_write_key(struct apple_smc *smc, 256 + struct macsmc_hwmon_sensor *sensor, long val) 257 + { 258 + switch (sensor->info.type_code) { 259 + /* 32-bit IEEE 754 float */ 260 + case __SMC_KEY('f', 'l', 't', ' '): 261 + return macsmc_hwmon_write_f32(smc, sensor->macsmc_key, val); 262 + /* unsigned 8-bit integer */ 263 + case __SMC_KEY('u', 'i', '8', ' '): 264 + return apple_smc_write_u8(smc, sensor->macsmc_key, val); 265 + default: 266 + return -EOPNOTSUPP; 267 + } 268 + } 269 + 270 + static int macsmc_hwmon_read_fan(struct macsmc_hwmon *hwmon, u32 attr, int chan, 271 + long *val) 272 + { 273 + switch (attr) { 274 + case hwmon_fan_input: 275 + return macsmc_hwmon_read_key(hwmon->smc, 276 + &hwmon->fan.fans[chan].now, 1, val); 277 + case hwmon_fan_min: 278 + return macsmc_hwmon_read_key(hwmon->smc, 279 + &hwmon->fan.fans[chan].min, 1, val); 280 + case hwmon_fan_max: 281 + return macsmc_hwmon_read_key(hwmon->smc, 282 + &hwmon->fan.fans[chan].max, 1, val); 283 + case hwmon_fan_target: 284 + return macsmc_hwmon_read_key(hwmon->smc, 285 + &hwmon->fan.fans[chan].set, 1, val); 286 + default: 287 + return -EOPNOTSUPP; 288 + } 289 + } 290 + 291 + static int macsmc_hwmon_write_fan(struct device *dev, u32 attr, int channel, 292 + long val) 293 + { 294 + struct macsmc_hwmon *hwmon = dev_get_drvdata(dev); 295 + long min, max; 296 + int ret; 297 + 298 + if (!fan_control || hwmon->fan.fans[channel].mode.macsmc_key == 0) 299 + return -EOPNOTSUPP; 300 + 301 + /* 302 + * The SMC does no sanity checks on requested fan speeds, so we need to. 303 + */ 304 + ret = macsmc_hwmon_read_key(hwmon->smc, &hwmon->fan.fans[channel].min, 305 + 1, &min); 306 + if (ret) 307 + return ret; 308 + 309 + ret = macsmc_hwmon_read_key(hwmon->smc, &hwmon->fan.fans[channel].max, 310 + 1, &max); 311 + if (ret) 312 + return ret; 313 + 314 + if (val >= min && val <= max) { 315 + if (!hwmon->fan.fans[channel].manual) { 316 + /* Write 1 to mode key for manual control */ 317 + ret = macsmc_hwmon_write_key(hwmon->smc, 318 + &hwmon->fan.fans[channel].mode, 1); 319 + if (ret < 0) 320 + return ret; 321 + 322 + hwmon->fan.fans[channel].manual = true; 323 + } 324 + return macsmc_hwmon_write_key(hwmon->smc, 325 + &hwmon->fan.fans[channel].set, val); 326 + } else if (!val) { 327 + if (hwmon->fan.fans[channel].manual) { 328 + ret = macsmc_hwmon_write_key(hwmon->smc, 329 + &hwmon->fan.fans[channel].mode, 0); 330 + if (ret < 0) 331 + return ret; 332 + 333 + hwmon->fan.fans[channel].manual = false; 334 + } 335 + } else { 336 + return -EINVAL; 337 + } 338 + 339 + return 0; 340 + } 341 + 342 + static int macsmc_hwmon_read(struct device *dev, enum hwmon_sensor_types type, 343 + u32 attr, int channel, long *val) 344 + { 345 + struct macsmc_hwmon *hwmon = dev_get_drvdata(dev); 346 + int ret = 0; 347 + 348 + switch (type) { 349 + case hwmon_temp: 350 + ret = macsmc_hwmon_read_key(hwmon->smc, 351 + &hwmon->temp.sensors[channel], 1000, val); 352 + break; 353 + case hwmon_in: 354 + ret = macsmc_hwmon_read_key(hwmon->smc, 355 + &hwmon->volt.sensors[channel], 1000, val); 356 + break; 357 + case hwmon_curr: 358 + ret = macsmc_hwmon_read_key(hwmon->smc, 359 + &hwmon->curr.sensors[channel], 1000, val); 360 + break; 361 + case hwmon_power: 362 + /* SMC returns power in Watts with acceptable precision to scale to uW */ 363 + ret = macsmc_hwmon_read_key(hwmon->smc, 364 + &hwmon->power.sensors[channel], 365 + 1000000, val); 366 + break; 367 + case hwmon_fan: 368 + ret = macsmc_hwmon_read_fan(hwmon, attr, channel, val); 369 + break; 370 + default: 371 + return -EOPNOTSUPP; 372 + } 373 + 374 + return ret; 375 + } 376 + 377 + static int macsmc_hwmon_write(struct device *dev, enum hwmon_sensor_types type, 378 + u32 attr, int channel, long val) 379 + { 380 + switch (type) { 381 + case hwmon_fan: 382 + return macsmc_hwmon_write_fan(dev, attr, channel, val); 383 + default: 384 + return -EOPNOTSUPP; 385 + } 386 + } 387 + 388 + static umode_t macsmc_hwmon_fan_is_visible(const struct macsmc_hwmon_fan *fan, 389 + u32 attr) 390 + { 391 + if (fan->attrs & BIT(attr)) { 392 + if (attr == hwmon_fan_target && fan_control && fan->mode.macsmc_key) 393 + return 0644; 394 + 395 + return 0444; 396 + } 397 + 398 + return 0; 399 + } 400 + 401 + static umode_t macsmc_hwmon_is_visible(const void *data, 402 + enum hwmon_sensor_types type, u32 attr, 403 + int channel) 404 + { 405 + const struct macsmc_hwmon *hwmon = data; 406 + struct macsmc_hwmon_sensor *sensor; 407 + 408 + switch (type) { 409 + case hwmon_in: 410 + sensor = &hwmon->volt.sensors[channel]; 411 + break; 412 + case hwmon_curr: 413 + sensor = &hwmon->curr.sensors[channel]; 414 + break; 415 + case hwmon_power: 416 + sensor = &hwmon->power.sensors[channel]; 417 + break; 418 + case hwmon_temp: 419 + sensor = &hwmon->temp.sensors[channel]; 420 + break; 421 + case hwmon_fan: 422 + return macsmc_hwmon_fan_is_visible(&hwmon->fan.fans[channel], attr); 423 + default: 424 + return 0; 425 + } 426 + 427 + /* Sensors only register ro attributes */ 428 + if (sensor->attrs & BIT(attr)) 429 + return 0444; 430 + 431 + return 0; 432 + } 433 + 434 + static const struct hwmon_ops macsmc_hwmon_ops = { 435 + .is_visible = macsmc_hwmon_is_visible, 436 + .read = macsmc_hwmon_read, 437 + .read_string = macsmc_hwmon_read_label, 438 + .write = macsmc_hwmon_write, 439 + }; 440 + 441 + /* 442 + * Get the key metadata, including key data type, from the SMC. 443 + */ 444 + static int macsmc_hwmon_parse_key(struct device *dev, struct apple_smc *smc, 445 + struct macsmc_hwmon_sensor *sensor, 446 + const char *key) 447 + { 448 + int ret; 449 + 450 + ret = apple_smc_get_key_info(smc, _SMC_KEY(key), &sensor->info); 451 + if (ret) { 452 + dev_dbg(dev, "Failed to retrieve key info for %s\n", key); 453 + return ret; 454 + } 455 + 456 + sensor->macsmc_key = _SMC_KEY(key); 457 + 458 + return 0; 459 + } 460 + 461 + /* 462 + * A sensor is a single key-value pair as made available by the SMC. 463 + * The devicetree gives us the SMC key ID and a friendly name where the 464 + * purpose of the sensor is known. 465 + */ 466 + static int macsmc_hwmon_create_sensor(struct device *dev, struct apple_smc *smc, 467 + struct device_node *sensor_node, 468 + struct macsmc_hwmon_sensor *sensor) 469 + { 470 + const char *key, *label; 471 + int ret; 472 + 473 + ret = of_property_read_string(sensor_node, "apple,key-id", &key); 474 + if (ret) { 475 + dev_dbg(dev, "Could not find apple,key-id in sensor node\n"); 476 + return ret; 477 + } 478 + 479 + ret = macsmc_hwmon_parse_key(dev, smc, sensor, key); 480 + if (ret) 481 + return ret; 482 + 483 + ret = of_property_read_string(sensor_node, "label", &label); 484 + if (ret) 485 + dev_dbg(dev, "No label found for sensor %s\n", key); 486 + else 487 + strscpy_pad(sensor->label, label, sizeof(sensor->label)); 488 + 489 + return 0; 490 + } 491 + 492 + /* 493 + * Fan data is exposed by the SMC as multiple sensors. 494 + * 495 + * The devicetree schema reuses apple,key-id for the actual fan speed sensor. 496 + * Min, max and target keys do not need labels, so we can reuse label 497 + * for naming the entire fan. 498 + */ 499 + static int macsmc_hwmon_create_fan(struct device *dev, struct apple_smc *smc, 500 + struct device_node *fan_node, 501 + struct macsmc_hwmon_fan *fan) 502 + { 503 + const char *label, *now, *min, *max, *set, *mode; 504 + int ret; 505 + 506 + ret = of_property_read_string(fan_node, "apple,key-id", &now); 507 + if (ret) { 508 + dev_err(dev, "apple,key-id not found in fan node!\n"); 509 + return ret; 510 + } 511 + 512 + ret = macsmc_hwmon_parse_key(dev, smc, &fan->now, now); 513 + if (ret) 514 + return ret; 515 + 516 + fan->attrs = HWMON_F_INPUT; 517 + 518 + ret = of_property_read_string(fan_node, "label", &label); 519 + if (ret) { 520 + dev_dbg(dev, "No label found for fan %s\n", now); 521 + } else { 522 + strscpy_pad(fan->label, label, sizeof(fan->label)); 523 + fan->attrs |= HWMON_F_LABEL; 524 + } 525 + 526 + /* The following keys are not required to simply monitor fan speed */ 527 + if (!of_property_read_string(fan_node, "apple,fan-minimum", &min)) { 528 + ret = macsmc_hwmon_parse_key(dev, smc, &fan->min, min); 529 + if (ret) 530 + return ret; 531 + 532 + fan->attrs |= HWMON_F_MIN; 533 + } 534 + 535 + if (!of_property_read_string(fan_node, "apple,fan-maximum", &max)) { 536 + ret = macsmc_hwmon_parse_key(dev, smc, &fan->max, max); 537 + if (ret) 538 + return ret; 539 + 540 + fan->attrs |= HWMON_F_MAX; 541 + } 542 + 543 + if (!of_property_read_string(fan_node, "apple,fan-target", &set)) { 544 + ret = macsmc_hwmon_parse_key(dev, smc, &fan->set, set); 545 + if (ret) 546 + return ret; 547 + 548 + fan->attrs |= HWMON_F_TARGET; 549 + } 550 + 551 + if (!of_property_read_string(fan_node, "apple,fan-mode", &mode)) { 552 + ret = macsmc_hwmon_parse_key(dev, smc, &fan->mode, mode); 553 + if (ret) 554 + return ret; 555 + } 556 + 557 + /* Initialise fan control mode to automatic */ 558 + fan->manual = false; 559 + 560 + return 0; 561 + } 562 + 563 + static int macsmc_hwmon_populate_sensors(struct macsmc_hwmon *hwmon, 564 + struct device_node *hwmon_node) 565 + { 566 + struct device_node *key_node __maybe_unused; 567 + struct macsmc_hwmon_sensor *sensor; 568 + u32 n_current = 0, n_fan = 0, n_power = 0, n_temperature = 0, n_voltage = 0; 569 + 570 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "current-") { 571 + n_current++; 572 + } 573 + 574 + if (n_current) { 575 + hwmon->curr.sensors = devm_kcalloc(hwmon->dev, n_current, 576 + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL); 577 + if (!hwmon->curr.sensors) 578 + return -ENOMEM; 579 + 580 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "current-") { 581 + sensor = &hwmon->curr.sensors[hwmon->curr.count]; 582 + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { 583 + sensor->attrs = HWMON_C_INPUT; 584 + 585 + if (*sensor->label) 586 + sensor->attrs |= HWMON_C_LABEL; 587 + 588 + hwmon->curr.count++; 589 + } 590 + } 591 + } 592 + 593 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "fan-") { 594 + n_fan++; 595 + } 596 + 597 + if (n_fan) { 598 + hwmon->fan.fans = devm_kcalloc(hwmon->dev, n_fan, 599 + sizeof(struct macsmc_hwmon_fan), GFP_KERNEL); 600 + if (!hwmon->fan.fans) 601 + return -ENOMEM; 602 + 603 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "fan-") { 604 + if (!macsmc_hwmon_create_fan(hwmon->dev, hwmon->smc, key_node, 605 + &hwmon->fan.fans[hwmon->fan.count])) 606 + hwmon->fan.count++; 607 + } 608 + } 609 + 610 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "power-") { 611 + n_power++; 612 + } 613 + 614 + if (n_power) { 615 + hwmon->power.sensors = devm_kcalloc(hwmon->dev, n_power, 616 + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL); 617 + if (!hwmon->power.sensors) 618 + return -ENOMEM; 619 + 620 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "power-") { 621 + sensor = &hwmon->power.sensors[hwmon->power.count]; 622 + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { 623 + sensor->attrs = HWMON_P_INPUT; 624 + 625 + if (*sensor->label) 626 + sensor->attrs |= HWMON_P_LABEL; 627 + 628 + hwmon->power.count++; 629 + } 630 + } 631 + } 632 + 633 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "temperature-") { 634 + n_temperature++; 635 + } 636 + 637 + if (n_temperature) { 638 + hwmon->temp.sensors = devm_kcalloc(hwmon->dev, n_temperature, 639 + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL); 640 + if (!hwmon->temp.sensors) 641 + return -ENOMEM; 642 + 643 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "temperature-") { 644 + sensor = &hwmon->temp.sensors[hwmon->temp.count]; 645 + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { 646 + sensor->attrs = HWMON_T_INPUT; 647 + 648 + if (*sensor->label) 649 + sensor->attrs |= HWMON_T_LABEL; 650 + 651 + hwmon->temp.count++; 652 + } 653 + } 654 + } 655 + 656 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "voltage-") { 657 + n_voltage++; 658 + } 659 + 660 + if (n_voltage) { 661 + hwmon->volt.sensors = devm_kcalloc(hwmon->dev, n_voltage, 662 + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL); 663 + if (!hwmon->volt.sensors) 664 + return -ENOMEM; 665 + 666 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "volt-") { 667 + sensor = &hwmon->temp.sensors[hwmon->temp.count]; 668 + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { 669 + sensor->attrs = HWMON_I_INPUT; 670 + 671 + if (*sensor->label) 672 + sensor->attrs |= HWMON_I_LABEL; 673 + 674 + hwmon->volt.count++; 675 + } 676 + } 677 + } 678 + 679 + return 0; 680 + } 681 + 682 + /* Create NULL-terminated config arrays */ 683 + static void macsmc_hwmon_populate_configs(u32 *configs, const struct macsmc_hwmon_sensors *sensors) 684 + { 685 + int idx; 686 + 687 + for (idx = 0; idx < sensors->count; idx++) 688 + configs[idx] = sensors->sensors[idx].attrs; 689 + } 690 + 691 + static void macsmc_hwmon_populate_fan_configs(u32 *configs, const struct macsmc_hwmon_fans *fans) 692 + { 693 + int idx; 694 + 695 + for (idx = 0; idx < fans->count; idx++) 696 + configs[idx] = fans->fans[idx].attrs; 697 + } 698 + 699 + static const struct hwmon_channel_info *const macsmc_chip_channel_info = 700 + HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ); 701 + 702 + static int macsmc_hwmon_create_infos(struct macsmc_hwmon *hwmon) 703 + { 704 + struct hwmon_channel_info *channel_info; 705 + int i = 0; 706 + 707 + /* chip */ 708 + hwmon->channel_infos[i++] = macsmc_chip_channel_info; 709 + 710 + if (hwmon->curr.count) { 711 + channel_info = &hwmon->curr.channel_info; 712 + channel_info->type = hwmon_curr; 713 + channel_info->config = devm_kcalloc(hwmon->dev, hwmon->curr.count + 1, 714 + sizeof(u32), GFP_KERNEL); 715 + if (!channel_info->config) 716 + return -ENOMEM; 717 + 718 + macsmc_hwmon_populate_configs((u32 *)channel_info->config, &hwmon->curr); 719 + hwmon->channel_infos[i++] = channel_info; 720 + } 721 + 722 + if (hwmon->fan.count) { 723 + channel_info = &hwmon->fan.channel_info; 724 + channel_info->type = hwmon_fan; 725 + channel_info->config = devm_kcalloc(hwmon->dev, hwmon->fan.count + 1, 726 + sizeof(u32), GFP_KERNEL); 727 + if (!channel_info->config) 728 + return -ENOMEM; 729 + 730 + macsmc_hwmon_populate_fan_configs((u32 *)channel_info->config, &hwmon->fan); 731 + hwmon->channel_infos[i++] = channel_info; 732 + } 733 + 734 + if (hwmon->power.count) { 735 + channel_info = &hwmon->power.channel_info; 736 + channel_info->type = hwmon_power; 737 + channel_info->config = devm_kcalloc(hwmon->dev, hwmon->power.count + 1, 738 + sizeof(u32), GFP_KERNEL); 739 + if (!channel_info->config) 740 + return -ENOMEM; 741 + 742 + macsmc_hwmon_populate_configs((u32 *)channel_info->config, &hwmon->power); 743 + hwmon->channel_infos[i++] = channel_info; 744 + } 745 + 746 + if (hwmon->temp.count) { 747 + channel_info = &hwmon->temp.channel_info; 748 + channel_info->type = hwmon_temp; 749 + channel_info->config = devm_kcalloc(hwmon->dev, hwmon->temp.count + 1, 750 + sizeof(u32), GFP_KERNEL); 751 + if (!channel_info->config) 752 + return -ENOMEM; 753 + 754 + macsmc_hwmon_populate_configs((u32 *)channel_info->config, &hwmon->temp); 755 + hwmon->channel_infos[i++] = channel_info; 756 + } 757 + 758 + if (hwmon->volt.count) { 759 + channel_info = &hwmon->volt.channel_info; 760 + channel_info->type = hwmon_in; 761 + channel_info->config = devm_kcalloc(hwmon->dev, hwmon->volt.count + 1, 762 + sizeof(u32), GFP_KERNEL); 763 + if (!channel_info->config) 764 + return -ENOMEM; 765 + 766 + macsmc_hwmon_populate_configs((u32 *)channel_info->config, &hwmon->volt); 767 + hwmon->channel_infos[i++] = channel_info; 768 + } 769 + 770 + return 0; 771 + } 772 + 773 + static int macsmc_hwmon_probe(struct platform_device *pdev) 774 + { 775 + struct apple_smc *smc = dev_get_drvdata(pdev->dev.parent); 776 + struct macsmc_hwmon *hwmon; 777 + int ret; 778 + 779 + /* 780 + * The MFD driver will try to probe us unconditionally. Some devices 781 + * with the SMC do not have hwmon capabilities. Only probe if we have 782 + * a hwmon node. 783 + */ 784 + if (!pdev->dev.of_node) 785 + return -ENODEV; 786 + 787 + hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), 788 + GFP_KERNEL); 789 + if (!hwmon) 790 + return -ENOMEM; 791 + 792 + hwmon->dev = &pdev->dev; 793 + hwmon->smc = smc; 794 + 795 + ret = macsmc_hwmon_populate_sensors(hwmon, hwmon->dev->of_node); 796 + if (ret) { 797 + dev_err(hwmon->dev, "Could not parse sensors\n"); 798 + return ret; 799 + } 800 + 801 + if (!hwmon->curr.count && !hwmon->fan.count && 802 + !hwmon->power.count && !hwmon->temp.count && 803 + !hwmon->volt.count) { 804 + dev_err(hwmon->dev, 805 + "No valid sensors found of any supported type\n"); 806 + return -ENODEV; 807 + } 808 + 809 + ret = macsmc_hwmon_create_infos(hwmon); 810 + if (ret) 811 + return ret; 812 + 813 + hwmon->chip_info.ops = &macsmc_hwmon_ops; 814 + hwmon->chip_info.info = 815 + (const struct hwmon_channel_info *const *)&hwmon->channel_infos; 816 + 817 + hwmon->hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, 818 + "macsmc_hwmon", hwmon, 819 + &hwmon->chip_info, NULL); 820 + if (IS_ERR(hwmon->hwmon_dev)) 821 + return dev_err_probe(hwmon->dev, PTR_ERR(hwmon->hwmon_dev), 822 + "Probing SMC hwmon device failed\n"); 823 + 824 + dev_dbg(hwmon->dev, "Registered SMC hwmon device. Sensors:\n"); 825 + dev_dbg(hwmon->dev, 826 + "Current: %d, Fans: %d, Power: %d, Temperature: %d, Voltage: %d", 827 + hwmon->curr.count, hwmon->fan.count, 828 + hwmon->power.count, hwmon->temp.count, 829 + hwmon->volt.count); 830 + 831 + return 0; 832 + } 833 + 834 + static const struct of_device_id macsmc_hwmon_of_table[] = { 835 + { .compatible = "apple,smc-hwmon" }, 836 + {} 837 + }; 838 + MODULE_DEVICE_TABLE(of, macsmc_hwmon_of_table); 839 + 840 + static struct platform_driver macsmc_hwmon_driver = { 841 + .probe = macsmc_hwmon_probe, 842 + .driver = { 843 + .name = "macsmc-hwmon", 844 + .of_match_table = macsmc_hwmon_of_table, 845 + }, 846 + }; 847 + module_platform_driver(macsmc_hwmon_driver); 848 + 849 + MODULE_DESCRIPTION("Apple Silicon SMC hwmon driver"); 850 + MODULE_AUTHOR("James Calligeros <jcalligeros99@gmail.com>"); 851 + MODULE_LICENSE("Dual MIT/GPL");
+3 -20
drivers/hwmon/max127.c
··· 45 45 #define MAX127_SIGN_BIT BIT(11) 46 46 47 47 struct max127_data { 48 - struct mutex lock; 49 48 struct i2c_client *client; 50 49 u8 ctrl_byte[MAX127_NUM_CHANNELS]; 51 50 }; ··· 120 121 struct i2c_client *client = data->client; 121 122 u8 ctrl_byte = data->ctrl_byte[channel]; 122 123 123 - mutex_lock(&data->lock); 124 - 125 124 status = max127_select_channel(client, ctrl_byte); 126 125 if (status) 127 - goto exit; 126 + return status; 128 127 129 128 status = max127_read_channel(client, &raw); 130 129 if (status) 131 - goto exit; 130 + return status; 132 131 133 132 *val = max127_process_raw(ctrl_byte, raw); 134 - 135 - exit: 136 - mutex_unlock(&data->lock); 137 - return status; 133 + return 0; 138 134 } 139 135 140 136 static int max127_read_min(struct max127_data *data, int channel, long *val) ··· 164 170 { 165 171 u8 ctrl; 166 172 167 - mutex_lock(&data->lock); 168 - 169 173 ctrl = data->ctrl_byte[channel]; 170 174 if (val <= -MAX127_FULL_RANGE) { 171 175 ctrl |= (MAX127_CTRL_RNG | MAX127_CTRL_BIP); ··· 174 182 ctrl &= ~MAX127_CTRL_BIP; 175 183 } 176 184 data->ctrl_byte[channel] = ctrl; 177 - 178 - mutex_unlock(&data->lock); 179 - 180 185 return 0; 181 186 } 182 187 183 188 static int max127_write_max(struct max127_data *data, int channel, long val) 184 189 { 185 - mutex_lock(&data->lock); 186 - 187 190 if (val >= MAX127_FULL_RANGE) 188 191 data->ctrl_byte[channel] |= MAX127_CTRL_RNG; 189 192 else 190 193 data->ctrl_byte[channel] &= ~MAX127_CTRL_RNG; 191 - 192 - mutex_unlock(&data->lock); 193 - 194 194 return 0; 195 195 } 196 196 ··· 299 315 return -ENOMEM; 300 316 301 317 data->client = client; 302 - mutex_init(&data->lock); 303 318 for (i = 0; i < ARRAY_SIZE(data->ctrl_byte); i++) 304 319 data->ctrl_byte[i] = (MAX127_CTRL_START | 305 320 MAX127_SET_CHANNEL(i));
+4 -3
drivers/hwmon/max16065.c
··· 216 216 struct device_attribute *da, char *buf) 217 217 { 218 218 struct max16065_data *data = max16065_update_device(dev); 219 + int curr_sense = data->curr_sense; 219 220 220 - if (unlikely(data->curr_sense < 0)) 221 - return data->curr_sense; 221 + if (unlikely(curr_sense < 0)) 222 + return curr_sense; 222 223 223 224 return sysfs_emit(buf, "%d\n", 224 - ADC_TO_CURR(data->curr_sense, data->curr_gain)); 225 + ADC_TO_CURR(curr_sense, data->curr_gain)); 225 226 } 226 227 227 228 static ssize_t max16065_limit_store(struct device *dev,
+11 -37
drivers/hwmon/max31790.c
··· 57 57 */ 58 58 struct max31790_data { 59 59 struct i2c_client *client; 60 - struct mutex update_lock; 61 60 bool valid; /* zero until following fields are valid */ 62 61 unsigned long last_updated; /* in jiffies */ 63 62 ··· 73 74 { 74 75 struct max31790_data *data = dev_get_drvdata(dev); 75 76 struct i2c_client *client = data->client; 76 - struct max31790_data *ret = data; 77 - int i; 78 - int rv; 79 - 80 - mutex_lock(&data->update_lock); 77 + int i, rv; 81 78 82 79 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 80 + data->valid = false; 83 81 rv = i2c_smbus_read_byte_data(client, 84 82 MAX31790_REG_FAN_FAULT_STATUS1); 85 83 if (rv < 0) 86 - goto abort; 84 + return ERR_PTR(rv); 87 85 data->fault_status |= rv & 0x3F; 88 86 89 87 rv = i2c_smbus_read_byte_data(client, 90 88 MAX31790_REG_FAN_FAULT_STATUS2); 91 89 if (rv < 0) 92 - goto abort; 90 + return ERR_PTR(rv); 93 91 data->fault_status |= (rv & 0x3F) << 6; 94 92 95 93 for (i = 0; i < NR_CHANNEL; i++) { 96 94 rv = i2c_smbus_read_word_swapped(client, 97 95 MAX31790_REG_TACH_COUNT(i)); 98 96 if (rv < 0) 99 - goto abort; 97 + return ERR_PTR(rv); 100 98 data->tach[i] = rv; 101 99 102 100 if (data->fan_config[i] ··· 102 106 MAX31790_REG_TACH_COUNT(NR_CHANNEL 103 107 + i)); 104 108 if (rv < 0) 105 - goto abort; 109 + return ERR_PTR(rv); 106 110 data->tach[NR_CHANNEL + i] = rv; 107 111 } else { 108 112 rv = i2c_smbus_read_word_swapped(client, 109 113 MAX31790_REG_PWM_DUTY_CYCLE(i)); 110 114 if (rv < 0) 111 - goto abort; 115 + return ERR_PTR(rv); 112 116 data->pwm[i] = rv; 113 117 114 118 rv = i2c_smbus_read_word_swapped(client, 115 119 MAX31790_REG_TARGET_COUNT(i)); 116 120 if (rv < 0) 117 - goto abort; 121 + return ERR_PTR(rv); 118 122 data->target_count[i] = rv; 119 123 } 120 124 } ··· 122 126 data->last_updated = jiffies; 123 127 data->valid = true; 124 128 } 125 - goto done; 126 - 127 - abort: 128 - data->valid = false; 129 - ret = ERR_PTR(rv); 130 - 131 - done: 132 - mutex_unlock(&data->update_lock); 133 - 134 - return ret; 129 + return data; 135 130 } 136 131 137 132 static const u8 tach_period[8] = { 1, 2, 4, 8, 16, 32, 32, 32 }; ··· 176 189 *val = rpm; 177 190 return 0; 178 191 case hwmon_fan_fault: 179 - mutex_lock(&data->update_lock); 180 192 *val = !!(data->fault_status & (1 << channel)); 181 193 data->fault_status &= ~(1 << channel); 182 194 /* ··· 186 200 if (*val) { 187 201 int reg = MAX31790_REG_TARGET_COUNT(channel % NR_CHANNEL); 188 202 189 - i2c_smbus_write_byte_data(data->client, reg, 190 - data->target_count[channel % NR_CHANNEL] >> 8); 203 + return i2c_smbus_write_byte_data(data->client, reg, 204 + data->target_count[channel % NR_CHANNEL] >> 8); 191 205 } 192 - mutex_unlock(&data->update_lock); 193 206 return 0; 194 207 case hwmon_fan_enable: 195 208 *val = !!(data->fan_config[channel] & MAX31790_FAN_CFG_TACH_INPUT_EN); ··· 207 222 int err = 0; 208 223 u8 bits, fan_config; 209 224 int sr; 210 - 211 - mutex_lock(&data->update_lock); 212 225 213 226 switch (attr) { 214 227 case hwmon_fan_target: ··· 253 270 err = -EOPNOTSUPP; 254 271 break; 255 272 } 256 - 257 - mutex_unlock(&data->update_lock); 258 - 259 273 return err; 260 274 } 261 275 ··· 318 338 u8 fan_config; 319 339 int err = 0; 320 340 321 - mutex_lock(&data->update_lock); 322 - 323 341 switch (attr) { 324 342 case hwmon_pwm_input: 325 343 if (val < 0 || val > 255) { ··· 367 389 err = -EOPNOTSUPP; 368 390 break; 369 391 } 370 - 371 - mutex_unlock(&data->update_lock); 372 - 373 392 return err; 374 393 } 375 394 ··· 500 525 return -ENOMEM; 501 526 502 527 data->client = client; 503 - mutex_init(&data->update_lock); 504 528 505 529 /* 506 530 * Initialize the max31790 chip
+14 -46
drivers/hwmon/max31827.c
··· 10 10 #include <linux/delay.h> 11 11 #include <linux/hwmon.h> 12 12 #include <linux/i2c.h> 13 - #include <linux/mutex.h> 14 13 #include <linux/of_device.h> 15 14 #include <linux/regmap.h> 16 15 #include <linux/regulator/consumer.h> ··· 98 99 /* 99 100 * Prevent simultaneous access to the i2c client. 100 101 */ 101 - struct mutex lock; 102 102 struct regmap *regmap; 103 103 bool enable; 104 104 unsigned int resolution; ··· 121 123 * Before the Temperature Threshold Alarm, Alarm Hysteresis Threshold 122 124 * and Resolution bits from Configuration register are changed over I2C, 123 125 * the part must be in shutdown mode. 124 - * 125 - * Mutex is used to ensure, that some other process doesn't change the 126 - * configuration register. 127 126 */ 128 - mutex_lock(&st->lock); 129 - 130 127 if (!st->enable) { 131 128 if (!mask) 132 - ret = regmap_write(st->regmap, reg, val); 133 - else 134 - ret = regmap_update_bits(st->regmap, reg, mask, val); 135 - goto unlock; 129 + return regmap_write(st->regmap, reg, val); 130 + return regmap_update_bits(st->regmap, reg, mask, val); 136 131 } 137 132 138 133 ret = regmap_read(st->regmap, MAX31827_CONFIGURATION_REG, &cfg); 139 134 if (ret) 140 - goto unlock; 135 + return ret; 141 136 142 137 cnv_rate = MAX31827_CONFIGURATION_CNV_RATE_MASK & cfg; 143 138 cfg = cfg & ~(MAX31827_CONFIGURATION_1SHOT_MASK | 144 139 MAX31827_CONFIGURATION_CNV_RATE_MASK); 145 140 ret = regmap_write(st->regmap, MAX31827_CONFIGURATION_REG, cfg); 146 141 if (ret) 147 - goto unlock; 142 + return ret; 148 143 149 144 if (!mask) 150 145 ret = regmap_write(st->regmap, reg, val); ··· 145 154 ret = regmap_update_bits(st->regmap, reg, mask, val); 146 155 147 156 if (ret) 148 - goto unlock; 157 + return ret; 149 158 150 - ret = regmap_update_bits(st->regmap, MAX31827_CONFIGURATION_REG, 151 - MAX31827_CONFIGURATION_CNV_RATE_MASK, 152 - cnv_rate); 153 - 154 - unlock: 155 - mutex_unlock(&st->lock); 156 - return ret; 159 + return regmap_update_bits(st->regmap, MAX31827_CONFIGURATION_REG, 160 + MAX31827_CONFIGURATION_CNV_RATE_MASK, 161 + cnv_rate); 157 162 } 158 163 159 164 static int write_alarm_val(struct max31827_state *st, unsigned int reg, ··· 210 223 211 224 break; 212 225 case hwmon_temp_input: 213 - mutex_lock(&st->lock); 214 - 215 226 if (!st->enable) { 216 - /* 217 - * This operation requires mutex protection, 218 - * because the chip configuration should not 219 - * be changed during the conversion process. 220 - */ 221 - 222 227 ret = regmap_update_bits(st->regmap, 223 228 MAX31827_CONFIGURATION_REG, 224 229 MAX31827_CONFIGURATION_1SHOT_MASK, 225 230 1); 226 - if (ret) { 227 - mutex_unlock(&st->lock); 231 + if (ret) 228 232 return ret; 229 - } 230 233 msleep(max31827_conv_times[st->resolution]); 231 234 } 232 235 ··· 230 253 usleep_range(15000, 20000); 231 254 232 255 ret = regmap_read(st->regmap, MAX31827_T_REG, &uval); 233 - 234 - mutex_unlock(&st->lock); 235 256 236 257 if (ret) 237 258 break; ··· 327 352 if (val >> 1) 328 353 return -EINVAL; 329 354 330 - mutex_lock(&st->lock); 331 355 /** 332 356 * The chip should not be enabled while a conversion is 333 357 * performed. Neither should the chip be enabled when ··· 335 361 336 362 st->enable = val; 337 363 338 - ret = regmap_update_bits(st->regmap, 339 - MAX31827_CONFIGURATION_REG, 340 - MAX31827_CONFIGURATION_1SHOT_MASK | 341 - MAX31827_CONFIGURATION_CNV_RATE_MASK, 342 - MAX31827_DEVICE_ENABLE(val)); 343 - 344 - mutex_unlock(&st->lock); 345 - 346 - return ret; 364 + return regmap_update_bits(st->regmap, 365 + MAX31827_CONFIGURATION_REG, 366 + MAX31827_CONFIGURATION_1SHOT_MASK | 367 + MAX31827_CONFIGURATION_CNV_RATE_MASK, 368 + MAX31827_DEVICE_ENABLE(val)); 347 369 348 370 case hwmon_temp_max: 349 371 return write_alarm_val(st, MAX31827_TH_REG, val); ··· 592 622 st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL); 593 623 if (!st) 594 624 return -ENOMEM; 595 - 596 - mutex_init(&st->lock); 597 625 598 626 st->regmap = devm_regmap_init_i2c(client, &max31827_regmap); 599 627 if (IS_ERR(st->regmap))
+12 -31
drivers/hwmon/max6620.c
··· 130 130 131 131 struct max6620_data { 132 132 struct i2c_client *client; 133 - struct mutex update_lock; 134 133 bool valid; /* false until following fields are valid */ 135 134 unsigned long last_updated; /* in jiffies */ 136 135 ··· 160 161 { 161 162 struct max6620_data *data = dev_get_drvdata(dev); 162 163 struct i2c_client *client = data->client; 163 - int i; 164 - int ret = 0; 165 - 166 - mutex_lock(&data->update_lock); 164 + int i, ret; 167 165 168 166 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 169 167 for (i = 0; i < 4; i++) { 170 168 ret = i2c_smbus_read_byte_data(client, config_reg[i]); 171 169 if (ret < 0) 172 - goto error; 170 + return ret; 173 171 data->fancfg[i] = ret; 174 172 175 173 ret = i2c_smbus_read_byte_data(client, dyn_reg[i]); 176 174 if (ret < 0) 177 - goto error; 175 + return ret; 178 176 data->fandyn[i] = ret; 179 177 180 178 ret = i2c_smbus_read_byte_data(client, tach_reg[i]); 181 179 if (ret < 0) 182 - goto error; 180 + return ret; 183 181 data->tach[i] = (ret << 3) & 0x7f8; 184 182 ret = i2c_smbus_read_byte_data(client, tach_reg[i] + 1); 185 183 if (ret < 0) 186 - goto error; 184 + return ret; 187 185 data->tach[i] |= (ret >> 5) & 0x7; 188 186 189 187 ret = i2c_smbus_read_byte_data(client, target_reg[i]); 190 188 if (ret < 0) 191 - goto error; 189 + return ret; 192 190 data->target[i] = (ret << 3) & 0x7f8; 193 191 ret = i2c_smbus_read_byte_data(client, target_reg[i] + 1); 194 192 if (ret < 0) 195 - goto error; 193 + return ret; 196 194 data->target[i] |= (ret >> 5) & 0x7; 197 195 } 198 196 ··· 200 204 */ 201 205 ret = i2c_smbus_read_byte_data(client, MAX6620_REG_FAULT); 202 206 if (ret < 0) 203 - goto error; 207 + return ret; 204 208 data->fault |= (ret >> 4) & (ret & 0x0F); 205 209 206 210 data->last_updated = jiffies; 207 211 data->valid = true; 208 212 } 209 - 210 - error: 211 - mutex_unlock(&data->update_lock); 212 - return ret; 213 + return 0; 213 214 } 214 215 215 216 static umode_t ··· 254 261 case hwmon_fan: 255 262 switch (attr) { 256 263 case hwmon_fan_alarm: 257 - mutex_lock(&data->update_lock); 258 264 *val = !!(data->fault & BIT(channel)); 259 265 260 266 /* Setting TACH count to re-enable fan fault detection */ ··· 262 270 val2 = (data->target[channel] << 5) & 0xe0; 263 271 ret = i2c_smbus_write_byte_data(client, 264 272 target_reg[channel], val1); 265 - if (ret < 0) { 266 - mutex_unlock(&data->update_lock); 273 + if (ret < 0) 267 274 return ret; 268 - } 269 275 ret = i2c_smbus_write_byte_data(client, 270 276 target_reg[channel] + 1, val2); 271 - if (ret < 0) { 272 - mutex_unlock(&data->update_lock); 277 + if (ret < 0) 273 278 return ret; 274 - } 275 279 276 280 data->fault &= ~BIT(channel); 277 281 } 278 - mutex_unlock(&data->update_lock); 279 - 280 282 break; 281 283 case hwmon_fan_div: 282 284 *val = max6620_fan_div_from_reg(data->fandyn[channel]); ··· 320 334 return ret; 321 335 data = dev_get_drvdata(dev); 322 336 client = data->client; 323 - mutex_lock(&data->update_lock); 324 337 325 338 switch (type) { 326 339 case hwmon_fan: ··· 345 360 div = 5; 346 361 break; 347 362 default: 348 - ret = -EINVAL; 349 - goto error; 363 + return -EINVAL; 350 364 } 351 365 data->fandyn[channel] &= 0x1F; 352 366 data->fandyn[channel] |= div << 5; ··· 380 396 break; 381 397 } 382 398 383 - error: 384 - mutex_unlock(&data->update_lock); 385 399 return ret; 386 400 } 387 401 ··· 460 478 return -ENOMEM; 461 479 462 480 data->client = client; 463 - mutex_init(&data->update_lock); 464 481 465 482 err = max6620_init_client(data); 466 483 if (err)
+4 -19
drivers/hwmon/max6639.c
··· 16 16 #include <linux/jiffies.h> 17 17 #include <linux/i2c.h> 18 18 #include <linux/hwmon.h> 19 - #include <linux/hwmon-sysfs.h> 20 19 #include <linux/err.h> 21 - #include <linux/mutex.h> 22 20 #include <linux/regmap.h> 23 21 #include <linux/util_macros.h> 24 22 ··· 73 75 */ 74 76 struct max6639_data { 75 77 struct regmap *regmap; 76 - struct mutex update_lock; 77 78 78 79 /* Register values initialized only once */ 79 80 u8 ppr[MAX6639_NUM_CHANNELS]; /* Pulses per rotation 0..3 for 1..4 ppr */ ··· 246 249 if (val <= 0 || val > 4) 247 250 return -EINVAL; 248 251 249 - mutex_lock(&data->update_lock); 250 252 /* Set Fan pulse per revolution */ 251 253 err = max6639_set_ppr(data, channel, val); 252 - if (err < 0) { 253 - mutex_unlock(&data->update_lock); 254 + if (err < 0) 254 255 return err; 255 - } 256 256 data->ppr[channel] = val; 257 - 258 - mutex_unlock(&data->update_lock); 259 257 return 0; 260 258 default: 261 259 return -EOPNOTSUPP; ··· 312 320 case hwmon_pwm_input: 313 321 if (val < 0 || val > 255) 314 322 return -EINVAL; 315 - err = regmap_write(data->regmap, MAX6639_REG_TARGTDUTY(channel), 316 - val * 120 / 255); 317 - return err; 323 + return regmap_write(data->regmap, MAX6639_REG_TARGTDUTY(channel), 324 + val * 120 / 255); 318 325 case hwmon_pwm_freq: 319 326 val = clamp_val(val, 0, 25000); 320 327 321 328 i = find_closest(val, freq_table, ARRAY_SIZE(freq_table)); 322 329 323 - mutex_lock(&data->update_lock); 324 330 err = regmap_update_bits(data->regmap, MAX6639_REG_FAN_CONFIG3(channel), 325 331 MAX6639_FAN_CONFIG3_FREQ_MASK, i); 326 - if (err < 0) { 327 - mutex_unlock(&data->update_lock); 332 + if (err < 0) 328 333 return err; 329 - } 330 334 331 335 if (i >> 2) 332 336 err = regmap_set_bits(data->regmap, MAX6639_REG_GCONFIG, ··· 331 343 err = regmap_clear_bits(data->regmap, MAX6639_REG_GCONFIG, 332 344 MAX6639_GCONFIG_PWM_FREQ_HI); 333 345 334 - mutex_unlock(&data->update_lock); 335 346 return err; 336 347 default: 337 348 return -EOPNOTSUPP; ··· 739 752 return err; 740 753 } 741 754 } 742 - 743 - mutex_init(&data->update_lock); 744 755 745 756 /* Initialize the max6639 chip */ 746 757 err = max6639_init_client(client, data);
+2 -9
drivers/hwmon/max6697.c
··· 13 13 #include <linux/i2c.h> 14 14 #include <linux/init.h> 15 15 #include <linux/module.h> 16 - #include <linux/mutex.h> 17 16 #include <linux/of.h> 18 17 #include <linux/regmap.h> 19 18 #include <linux/slab.h> ··· 89 90 const struct max6697_chip_data *chip; 90 91 91 92 int temp_offset; /* in degrees C */ 92 - 93 - struct mutex update_lock; 94 93 95 94 #define MAX6697_TEMP_INPUT 0 96 95 #define MAX6697_TEMP_EXT 1 ··· 299 302 val = clamp_val(val, 0, 255); 300 303 return regmap_write(regmap, MAX6697_REG_MIN, val); 301 304 case hwmon_temp_offset: 302 - mutex_lock(&data->update_lock); 303 305 val = clamp_val(val, MAX6581_OFFSET_MIN, MAX6581_OFFSET_MAX); 304 306 val = DIV_ROUND_CLOSEST(val, 250); 305 307 if (!val) { /* disable this (and only this) channel */ ··· 309 313 ret = regmap_set_bits(regmap, MAX6581_REG_OFFSET_SELECT, 310 314 BIT(channel - 1)); 311 315 if (ret) 312 - goto unlock; 316 + return ret; 313 317 ret = regmap_write(regmap, MAX6581_REG_OFFSET, val); 314 318 } 315 - unlock: 316 - mutex_unlock(&data->update_lock); 317 319 return ret; 318 320 default: 319 321 return -EOPNOTSUPP; ··· 542 548 struct regmap *regmap; 543 549 int err; 544 550 545 - regmap = regmap_init_i2c(client, &max6697_regmap_config); 551 + regmap = devm_regmap_init_i2c(client, &max6697_regmap_config); 546 552 if (IS_ERR(regmap)) 547 553 return PTR_ERR(regmap); 548 554 ··· 553 559 data->regmap = regmap; 554 560 data->type = (uintptr_t)i2c_get_match_data(client); 555 561 data->chip = &max6697_chip_data[data->type]; 556 - mutex_init(&data->update_lock); 557 562 558 563 err = max6697_init_chip(client->dev.of_node, data); 559 564 if (err)
-1
drivers/hwmon/mr75203.c
··· 14 14 #include <linux/kstrtox.h> 15 15 #include <linux/module.h> 16 16 #include <linux/mod_devicetable.h> 17 - #include <linux/mutex.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/property.h> 20 19 #include <linux/regmap.h>
+1
drivers/hwmon/nct6775-platform.c
··· 1403 1403 "ROG STRIX X670E-E GAMING WIFI", 1404 1404 "ROG STRIX X670E-F GAMING WIFI", 1405 1405 "ROG STRIX X670E-I GAMING WIFI", 1406 + "ROG STRIX X870E-H GAMING WIFI7", 1406 1407 "ROG STRIX Z590-A GAMING WIFI", 1407 1408 "ROG STRIX Z590-A GAMING WIFI II", 1408 1409 "ROG STRIX Z590-E GAMING WIFI",
-2
drivers/hwmon/nct7363.c
··· 7 7 #include <linux/bits.h> 8 8 #include <linux/err.h> 9 9 #include <linux/hwmon.h> 10 - #include <linux/hwmon-sysfs.h> 11 10 #include <linux/i2c.h> 12 11 #include <linux/module.h> 13 - #include <linux/mutex.h> 14 12 #include <linux/regmap.h> 15 13 #include <linux/slab.h> 16 14
+24 -39
drivers/hwmon/nct7904.c
··· 21 21 #include <linux/device.h> 22 22 #include <linux/init.h> 23 23 #include <linux/i2c.h> 24 - #include <linux/mutex.h> 25 24 #include <linux/hwmon.h> 26 25 #include <linux/watchdog.h> 27 26 ··· 127 128 struct nct7904_data { 128 129 struct i2c_client *client; 129 130 struct watchdog_device wdt; 130 - struct mutex bank_lock; 131 131 int bank_sel; 132 132 u32 fanin_mask; 133 133 u32 vsen_mask; ··· 140 142 }; 141 143 142 144 /* Access functions */ 143 - static int nct7904_bank_lock(struct nct7904_data *data, unsigned int bank) 145 + static int nct7904_bank_select(struct nct7904_data *data, unsigned int bank) 144 146 { 145 147 int ret; 146 148 147 - mutex_lock(&data->bank_lock); 148 149 if (data->bank_sel == bank) 149 150 return 0; 150 151 ret = i2c_smbus_write_byte_data(data->client, BANK_SEL_REG, bank); 151 - if (ret == 0) 152 - data->bank_sel = bank; 153 - else 152 + if (ret < 0) { 154 153 data->bank_sel = -1; 155 - return ret; 156 - } 157 - 158 - static inline void nct7904_bank_release(struct nct7904_data *data) 159 - { 160 - mutex_unlock(&data->bank_lock); 154 + return ret; 155 + } 156 + data->bank_sel = bank; 157 + return 0; 161 158 } 162 159 163 160 /* Read 1-byte register. Returns unsigned reg or -ERRNO on error. */ ··· 162 169 struct i2c_client *client = data->client; 163 170 int ret; 164 171 165 - ret = nct7904_bank_lock(data, bank); 166 - if (ret == 0) 167 - ret = i2c_smbus_read_byte_data(client, reg); 168 - 169 - nct7904_bank_release(data); 170 - return ret; 172 + ret = nct7904_bank_select(data, bank); 173 + if (ret < 0) 174 + return ret; 175 + return i2c_smbus_read_byte_data(client, reg); 171 176 } 172 177 173 178 /* ··· 178 187 struct i2c_client *client = data->client; 179 188 int ret, hi; 180 189 181 - ret = nct7904_bank_lock(data, bank); 182 - if (ret == 0) { 183 - ret = i2c_smbus_read_byte_data(client, reg); 184 - if (ret >= 0) { 185 - hi = ret; 186 - ret = i2c_smbus_read_byte_data(client, reg + 1); 187 - if (ret >= 0) 188 - ret |= hi << 8; 189 - } 190 - } 191 - 192 - nct7904_bank_release(data); 193 - return ret; 190 + ret = nct7904_bank_select(data, bank); 191 + if (ret < 0) 192 + return ret; 193 + hi = i2c_smbus_read_byte_data(client, reg); 194 + if (hi < 0) 195 + return hi; 196 + ret = i2c_smbus_read_byte_data(client, reg + 1); 197 + if (ret < 0) 198 + return ret; 199 + return ret | (hi << 8); 194 200 } 195 201 196 202 /* Write 1-byte register. Returns 0 or -ERRNO on error. */ ··· 197 209 struct i2c_client *client = data->client; 198 210 int ret; 199 211 200 - ret = nct7904_bank_lock(data, bank); 201 - if (ret == 0) 202 - ret = i2c_smbus_write_byte_data(client, reg, val); 203 - 204 - nct7904_bank_release(data); 205 - return ret; 212 + ret = nct7904_bank_select(data, bank); 213 + if (ret < 0) 214 + return ret; 215 + return i2c_smbus_write_byte_data(client, reg, val); 206 216 } 207 217 208 218 static int nct7904_read_fan(struct device *dev, u32 attr, int channel, ··· 1009 1023 return -ENOMEM; 1010 1024 1011 1025 data->client = client; 1012 - mutex_init(&data->bank_lock); 1013 1026 data->bank_sel = -1; 1014 1027 1015 1028 /* Setup sensor groups. */
+1 -10
drivers/hwmon/npcm750-pwm-fan.c
··· 4 4 #include <linux/clk.h> 5 5 #include <linux/device.h> 6 6 #include <linux/hwmon.h> 7 - #include <linux/hwmon-sysfs.h> 8 7 #include <linux/interrupt.h> 9 8 #include <linux/kernel.h> 10 9 #include <linux/module.h> ··· 197 198 int pwm_modules; 198 199 struct clk *pwm_clk; 199 200 struct clk *fan_clk; 200 - struct mutex pwm_lock[NPCM7XX_PWM_MAX_MODULES]; 201 201 spinlock_t fan_lock[NPCM7XX_FAN_MAX_MODULE]; 202 202 int fan_irq[NPCM7XX_FAN_MAX_MODULE]; 203 203 bool pwm_present[NPCM7XX_PWM_MAX_CHN_NUM]; ··· 219 221 /* 220 222 * Config PWM Comparator register for setting duty cycle 221 223 */ 222 - mutex_lock(&data->pwm_lock[module]); 223 224 224 225 /* write new CMR value */ 225 226 iowrite32(val, NPCM7XX_PWM_REG_CMRx(data->pwm_base, module, pwm_ch)); ··· 242 245 env_bit = NPCM7XX_PWM_CTRL_CH3_INV_BIT; 243 246 break; 244 247 default: 245 - mutex_unlock(&data->pwm_lock[module]); 246 248 return -ENODEV; 247 249 } 248 250 ··· 256 260 } 257 261 258 262 iowrite32(tmp_buf, NPCM7XX_PWM_REG_CR(data->pwm_base, module)); 259 - mutex_unlock(&data->pwm_lock[module]); 260 - 261 263 return 0; 262 264 } 263 265 ··· 926 932 struct resource *res; 927 933 struct device *hwmon; 928 934 char name[20]; 929 - int ret, cnt; 930 935 u32 output_freq; 936 + int ret; 931 937 u32 i; 932 938 933 939 np = dev->of_node; ··· 978 984 979 985 output_freq = npcm7xx_pwm_init(data); 980 986 npcm7xx_fan_init(data); 981 - 982 - for (cnt = 0; cnt < data->pwm_modules; cnt++) 983 - mutex_init(&data->pwm_lock[cnt]); 984 987 985 988 for (i = 0; i < NPCM7XX_FAN_MAX_MODULE; i++) { 986 989 spin_lock_init(&data->fan_lock[i]);
+43
drivers/hwmon/ntc_thermistor.c
··· 24 24 TYPE_NCPXXWF104, 25 25 TYPE_NCPXXWL333, 26 26 TYPE_NCPXXXH103, 27 + TYPE_NCPXXWM474, 27 28 }; 28 29 29 30 struct ntc_compensation { ··· 47 46 NTC_NCP18WB473, 48 47 NTC_NCP21WB473, 49 48 NTC_SSG1404001221, 49 + NTC_NCP18WM474, 50 50 NTC_LAST, 51 51 }; 52 52 ··· 62 60 [NTC_NCP18WB473] = { "ncp18wb473", TYPE_NCPXXWB473 }, 63 61 [NTC_NCP21WB473] = { "ncp21wb473", TYPE_NCPXXWB473 }, 64 62 [NTC_SSG1404001221] = { "ssg1404_001221", TYPE_NCPXXWB473 }, 63 + [NTC_NCP18WM474] = { "ncp18wm474", TYPE_NCPXXWM474 }, 65 64 [NTC_LAST] = { }, 66 65 }; 67 66 MODULE_DEVICE_TABLE(platform, ntc_thermistor_id); ··· 220 217 { .temp_c = 125, .ohm = 531 }, 221 218 }; 222 219 220 + static const struct ntc_compensation ncpXXwm474[] = { 221 + { .temp_c = -40, .ohm = 10900000 }, 222 + { .temp_c = -35, .ohm = 9600000 }, 223 + { .temp_c = -30, .ohm = 8300000 }, 224 + { .temp_c = -25, .ohm = 7000000 }, 225 + { .temp_c = -20, .ohm = 5980000 }, 226 + { .temp_c = -15, .ohm = 4960000 }, 227 + { .temp_c = -10, .ohm = 3940000 }, 228 + { .temp_c = -5, .ohm = 2920000 }, 229 + { .temp_c = 0, .ohm = 1900000 }, 230 + { .temp_c = 5, .ohm = 1614000 }, 231 + { .temp_c = 10, .ohm = 1328000 }, 232 + { .temp_c = 15, .ohm = 1042000 }, 233 + { .temp_c = 20, .ohm = 756000 }, 234 + { .temp_c = 25, .ohm = 470000 }, 235 + { .temp_c = 30, .ohm = 404000 }, 236 + { .temp_c = 35, .ohm = 338000 }, 237 + { .temp_c = 40, .ohm = 272000 }, 238 + { .temp_c = 45, .ohm = 206000 }, 239 + { .temp_c = 50, .ohm = 140000 }, 240 + { .temp_c = 55, .ohm = 122000 }, 241 + { .temp_c = 60, .ohm = 104000 }, 242 + { .temp_c = 65, .ohm = 86000 }, 243 + { .temp_c = 70, .ohm = 68000 }, 244 + { .temp_c = 75, .ohm = 50000 }, 245 + { .temp_c = 80, .ohm = 44200 }, 246 + { .temp_c = 85, .ohm = 38400 }, 247 + { .temp_c = 90, .ohm = 32600 }, 248 + { .temp_c = 95, .ohm = 26800 }, 249 + { .temp_c = 100, .ohm = 21000 }, 250 + { .temp_c = 105, .ohm = 18600 }, 251 + { .temp_c = 110, .ohm = 16200 }, 252 + { .temp_c = 115, .ohm = 13800 }, 253 + { .temp_c = 120, .ohm = 11400 }, 254 + { .temp_c = 125, .ohm = 9000 }, 255 + }; 256 + 223 257 /* 224 258 * The following compensation tables are from the specifications in EPCOS NTC 225 259 * Thermistors Datasheets ··· 359 319 NTC_TYPE(TYPE_NCPXXWF104, ncpXXwf104), 360 320 NTC_TYPE(TYPE_NCPXXWL333, ncpXXwl333), 361 321 NTC_TYPE(TYPE_NCPXXXH103, ncpXXxh103), 322 + NTC_TYPE(TYPE_NCPXXWM474, ncpXXwm474), 362 323 }; 363 324 364 325 /* ··· 716 675 .data = &ntc_thermistor_id[NTC_NCP21WB473] }, 717 676 { .compatible = "samsung,1404-001221", 718 677 .data = &ntc_thermistor_id[NTC_SSG1404001221] }, 678 + { .compatible = "murata,ncp18wm474", 679 + .data = &ntc_thermistor_id[NTC_NCP18WM474] }, 719 680 720 681 /* Usage of vendor name "ntc" is deprecated */ 721 682 { .compatible = "ntc,ncp03wb473",
-3
drivers/hwmon/peci/common.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 2 /* Copyright (c) 2021 Intel Corporation */ 3 3 4 - #include <linux/mutex.h> 5 4 #include <linux/types.h> 6 5 7 6 #ifndef __PECI_HWMON_COMMON_H ··· 12 13 * struct peci_sensor_state - PECI state information 13 14 * @valid: flag to indicate the sensor value is valid 14 15 * @last_updated: time of the last update in jiffies 15 - * @lock: mutex to protect sensor access 16 16 */ 17 17 struct peci_sensor_state { 18 18 bool valid; 19 19 unsigned long last_updated; 20 - struct mutex lock; /* protect sensor access */ 21 20 }; 22 21 23 22 /**
+37 -53
drivers/hwmon/peci/cputemp.c
··· 116 116 { 117 117 int ret; 118 118 119 - mutex_lock(&priv->temp.target.state.lock); 120 - 121 119 ret = update_temp_target(priv); 122 120 if (ret) 123 - goto unlock; 121 + return ret; 124 122 125 123 switch (type) { 126 124 case tcontrol_type: ··· 137 139 ret = -EOPNOTSUPP; 138 140 break; 139 141 } 140 - unlock: 141 - mutex_unlock(&priv->temp.target.state.lock); 142 - 143 142 return ret; 144 143 } 145 144 ··· 172 177 173 178 static int get_die_temp(struct peci_cputemp *priv, long *val) 174 179 { 175 - int ret = 0; 176 180 long tjmax; 177 181 u16 temp; 182 + int ret; 178 183 179 - mutex_lock(&priv->temp.die.state.lock); 180 184 if (!peci_sensor_need_update(&priv->temp.die.state)) 181 185 goto skip_update; 182 186 183 187 ret = peci_temp_read(priv->peci_dev, &temp); 184 188 if (ret) 185 - goto err_unlock; 189 + return ret; 186 190 187 - if (!dts_valid(temp)) { 188 - ret = -EIO; 189 - goto err_unlock; 190 - } 191 + if (!dts_valid(temp)) 192 + return -EIO; 191 193 192 194 ret = get_temp_target(priv, tjmax_type, &tjmax); 193 195 if (ret) 194 - goto err_unlock; 196 + return ret; 195 197 196 198 priv->temp.die.value = (s32)tjmax + dts_ten_dot_six_to_millidegree(temp); 197 199 ··· 196 204 197 205 skip_update: 198 206 *val = priv->temp.die.value; 199 - err_unlock: 200 - mutex_unlock(&priv->temp.die.state.lock); 201 - return ret; 207 + return 0; 202 208 } 203 209 204 210 static int get_dts(struct peci_cputemp *priv, long *val) 205 211 { 206 - int ret = 0; 207 212 u16 thermal_margin; 208 213 long tcontrol; 209 214 u32 pcs; 215 + int ret; 210 216 211 - mutex_lock(&priv->temp.dts.state.lock); 212 217 if (!peci_sensor_need_update(&priv->temp.dts.state)) 213 218 goto skip_update; 214 219 215 220 ret = peci_pcs_read(priv->peci_dev, PECI_PCS_THERMAL_MARGIN, 0, &pcs); 216 221 if (ret) 217 - goto err_unlock; 222 + return ret; 218 223 219 224 thermal_margin = FIELD_GET(DTS_MARGIN_MASK, pcs); 220 - if (!dts_valid(thermal_margin)) { 221 - ret = -EIO; 222 - goto err_unlock; 223 - } 225 + if (!dts_valid(thermal_margin)) 226 + return -EIO; 224 227 225 228 ret = get_temp_target(priv, tcontrol_type, &tcontrol); 226 229 if (ret) 227 - goto err_unlock; 230 + return ret; 228 231 229 232 /* Note that the tcontrol should be available before calling it */ 230 233 priv->temp.dts.value = ··· 229 242 230 243 skip_update: 231 244 *val = priv->temp.dts.value; 232 - err_unlock: 233 - mutex_unlock(&priv->temp.dts.state.lock); 234 - return ret; 245 + return 0; 235 246 } 236 247 237 248 static int get_core_temp(struct peci_cputemp *priv, int core_index, long *val) 238 249 { 239 - int ret = 0; 240 250 u16 core_dts_margin; 241 251 long tjmax; 242 252 u32 pcs; 253 + int ret; 243 254 244 - mutex_lock(&priv->temp.core[core_index].state.lock); 245 255 if (!peci_sensor_need_update(&priv->temp.core[core_index].state)) 246 256 goto skip_update; 247 257 248 258 ret = peci_pcs_read(priv->peci_dev, PECI_PCS_MODULE_TEMP, core_index, &pcs); 249 259 if (ret) 250 - goto err_unlock; 260 + return ret; 251 261 252 262 core_dts_margin = FIELD_GET(PCS_MODULE_TEMP_MASK, pcs); 253 - if (!dts_valid(core_dts_margin)) { 254 - ret = -EIO; 255 - goto err_unlock; 256 - } 263 + if (!dts_valid(core_dts_margin)) 264 + return -EIO; 257 265 258 266 ret = get_temp_target(priv, tjmax_type, &tjmax); 259 267 if (ret) 260 - goto err_unlock; 268 + return ret; 261 269 262 270 /* Note that the tjmax should be available before calling it */ 263 271 priv->temp.core[core_index].value = ··· 262 280 263 281 skip_update: 264 282 *val = priv->temp.core[core_index].value; 265 - err_unlock: 266 - mutex_unlock(&priv->temp.core[core_index].state.lock); 267 - return ret; 283 + return 0; 268 284 } 269 285 270 286 static int cputemp_read_string(struct device *dev, enum hwmon_sensor_types type, ··· 344 364 case INTEL_ICELAKE_X: 345 365 case INTEL_ICELAKE_D: 346 366 case INTEL_SAPPHIRERAPIDS_X: 367 + case INTEL_EMERALDRAPIDS_X: 347 368 ret = peci_ep_pci_local_read(peci_dev, 0, reg->bus, reg->dev, 348 369 reg->func, reg->offset + 4, &data); 349 370 if (ret) ··· 411 430 bitmap_zero(priv->core_mask, CORE_NUMS_MAX); 412 431 } 413 432 414 - static void sensor_init(struct peci_cputemp *priv) 415 - { 416 - int i; 417 - 418 - mutex_init(&priv->temp.target.state.lock); 419 - mutex_init(&priv->temp.die.state.lock); 420 - mutex_init(&priv->temp.dts.state.lock); 421 - 422 - for_each_set_bit(i, priv->core_mask, CORE_NUMS_MAX) 423 - mutex_init(&priv->temp.core[i].state.lock); 424 - } 425 - 426 433 static const struct hwmon_ops peci_cputemp_ops = { 427 434 .is_visible = cputemp_is_visible, 428 435 .read_string = cputemp_read_string, ··· 475 506 476 507 check_resolved_cores(priv); 477 508 478 - sensor_init(priv); 479 - 480 509 hwmon_dev = devm_hwmon_device_register_with_info(priv->dev, priv->name, 481 510 priv, &peci_cputemp_chip_info, NULL); 482 511 ··· 506 539 .offset = 0x80, 507 540 }; 508 541 542 + static struct resolved_cores_reg resolved_cores_reg_emr = { 543 + .bus = 31, 544 + .dev = 30, 545 + .func = 6, 546 + .offset = 0x80, 547 + }; 548 + 509 549 static const struct cpu_info cpu_hsx = { 510 550 .reg = &resolved_cores_reg_hsx, 511 551 .min_peci_revision = 0x33, ··· 533 559 534 560 static const struct cpu_info cpu_spr = { 535 561 .reg = &resolved_cores_reg_spr, 562 + .min_peci_revision = 0x40, 563 + .thermal_margin_to_millidegree = &dts_ten_dot_six_to_millidegree, 564 + }; 565 + 566 + static const struct cpu_info cpu_emr = { 567 + .reg = &resolved_cores_reg_emr, 536 568 .min_peci_revision = 0x40, 537 569 .thermal_margin_to_millidegree = &dts_ten_dot_six_to_millidegree, 538 570 }; ··· 571 591 { 572 592 .name = "peci_cpu.cputemp.spr", 573 593 .driver_data = (kernel_ulong_t)&cpu_spr, 594 + }, 595 + { 596 + .name = "peci_cpu.cputemp.emr", 597 + .driver_data = (kernel_ulong_t)&cpu_emr, 574 598 }, 575 599 { } 576 600 };
+23 -13
drivers/hwmon/peci/dimmtemp.c
··· 32 32 #define DIMM_IDX_MAX_ON_ICXD 2 33 33 #define CHAN_RANK_MAX_ON_SPR 8 34 34 #define DIMM_IDX_MAX_ON_SPR 2 35 + #define CHAN_RANK_MAX_ON_EMR 8 36 + #define DIMM_IDX_MAX_ON_EMR 2 35 37 36 38 #define CHAN_RANK_MAX CHAN_RANK_MAX_ON_HSX 37 39 #define DIMM_IDX_MAX DIMM_IDX_MAX_ON_HSX ··· 96 94 { 97 95 int dimm_order = dimm_no % priv->gen_info->dimm_idx_max; 98 96 int chan_rank = dimm_no / priv->gen_info->dimm_idx_max; 99 - int ret = 0; 100 97 u32 data; 98 + int ret; 101 99 102 - mutex_lock(&priv->dimm[dimm_no].temp.state.lock); 103 100 if (!peci_sensor_need_update(&priv->dimm[dimm_no].temp.state)) 104 101 goto skip_update; 105 102 106 103 ret = peci_pcs_read(priv->peci_dev, PECI_PCS_DDR_DIMM_TEMP, chan_rank, &data); 107 104 if (ret) 108 - goto unlock; 105 + return ret; 109 106 110 107 priv->dimm[dimm_no].temp.value = __dimm_temp(data, dimm_order) * MILLIDEGREE_PER_DEGREE; 111 108 ··· 112 111 113 112 skip_update: 114 113 *val = priv->dimm[dimm_no].temp.value; 115 - unlock: 116 - mutex_unlock(&priv->dimm[dimm_no].temp.state.lock); 117 - return ret; 114 + return 0; 118 115 } 119 116 120 117 static int update_thresholds(struct peci_dimmtemp *priv, int dimm_no) ··· 142 143 { 143 144 int ret; 144 145 145 - mutex_lock(&priv->dimm[dimm_no].thresholds.state.lock); 146 146 ret = update_thresholds(priv, dimm_no); 147 147 if (ret) 148 - goto unlock; 148 + return ret; 149 149 150 150 switch (type) { 151 151 case temp_max_type: ··· 157 159 ret = -EOPNOTSUPP; 158 160 break; 159 161 } 160 - unlock: 161 - mutex_unlock(&priv->dimm[dimm_no].thresholds.state.lock); 162 - 163 162 return ret; 164 163 } 165 164 ··· 342 347 ret = create_dimm_temp_label(priv, i); 343 348 if (ret) 344 349 return ret; 345 - mutex_init(&priv->dimm[i].thresholds.state.lock); 346 - mutex_init(&priv->dimm[i].temp.state.lock); 347 350 } 348 351 349 352 dev = devm_hwmon_device_register_with_info(priv->dev, priv->name, priv, ··· 564 571 return 0; 565 572 } 566 573 574 + static int read_thresholds_emr(struct peci_dimmtemp *priv, int dimm_order, 575 + int chan_rank, u32 *data) 576 + { 577 + return read_thresholds_spr(priv, dimm_order, chan_rank, data); 578 + } 579 + 567 580 static const struct dimm_info dimm_hsx = { 568 581 .chan_rank_max = CHAN_RANK_MAX_ON_HSX, 569 582 .dimm_idx_max = DIMM_IDX_MAX_ON_HSX, ··· 619 620 .read_thresholds = &read_thresholds_spr, 620 621 }; 621 622 623 + static const struct dimm_info dimm_emr = { 624 + .chan_rank_max = CHAN_RANK_MAX_ON_EMR, 625 + .dimm_idx_max = DIMM_IDX_MAX_ON_EMR, 626 + .min_peci_revision = 0x40, 627 + .read_thresholds = &read_thresholds_emr, 628 + }; 629 + 622 630 static const struct auxiliary_device_id peci_dimmtemp_ids[] = { 623 631 { 624 632 .name = "peci_cpu.dimmtemp.hsx", ··· 654 648 { 655 649 .name = "peci_cpu.dimmtemp.spr", 656 650 .driver_data = (kernel_ulong_t)&dimm_spr, 651 + }, 652 + { 653 + .name = "peci_cpu.dimmtemp.emr", 654 + .driver_data = (kernel_ulong_t)&dimm_emr, 657 655 }, 658 656 { } 659 657 };
+28
drivers/hwmon/pmbus/Kconfig
··· 320 320 This driver can also be built as a module. If so, the module will 321 321 be called max16601. 322 322 323 + config SENSORS_MAX17616 324 + tristate "Analog Devices MAX17616/MAX17616A" 325 + help 326 + If you say yes here you get hardware monitoring support for Analog 327 + Devices MAX17616/MAX17616A. 328 + 329 + This driver can also be built as a module. If so, the module will 330 + be called max17616. 331 + 323 332 config SENSORS_MAX20730 324 333 tristate "Maxim MAX20710, MAX20730, MAX20734, MAX20743" 325 334 help ··· 361 352 help 362 353 If you say yes here you get hardware monitoring support for Maxim 363 354 MAX34440, MAX34441, MAX34446, MAX34451, MAX34460, and MAX34461. 355 + Other compatible are ADPM12160, and ADPM12200. 364 356 365 357 This driver can also be built as a module. If so, the module will 366 358 be called max34440. ··· 410 400 411 401 This driver can also be built as a module. If so, the module will 412 402 be called mp2891. 403 + 404 + config SENSORS_MP2925 405 + tristate "MPS MP2925" 406 + help 407 + If you say yes here you get hardware monitoring support for MPS 408 + MP2925 Dual Loop Digital Multi-Phase Controller. 409 + 410 + This driver can also be built as a module. If so, the module will 411 + be called mp2925. 413 412 414 413 config SENSORS_MP29502 415 414 tristate "MPS MP29502" ··· 489 470 490 471 This driver can also be built as a module. If so, the module will 491 472 be called mp9941. 473 + 474 + config SENSORS_MP9945 475 + tristate "MPS MP9945" 476 + help 477 + If you say yes here you get hardware monitoring support for MPS 478 + MP9945. 479 + 480 + This driver can also be built as a module. If so, the module will 481 + be called mp9945. 492 482 493 483 config SENSORS_MPQ7932_REGULATOR 494 484 bool "Regulator support for MPQ7932"
+3
drivers/hwmon/pmbus/Makefile
··· 31 31 obj-$(CONFIG_SENSORS_MAX15301) += max15301.o 32 32 obj-$(CONFIG_SENSORS_MAX16064) += max16064.o 33 33 obj-$(CONFIG_SENSORS_MAX16601) += max16601.o 34 + obj-$(CONFIG_SENSORS_MAX17616) += max17616.o 34 35 obj-$(CONFIG_SENSORS_MAX20730) += max20730.o 35 36 obj-$(CONFIG_SENSORS_MAX20751) += max20751.o 36 37 obj-$(CONFIG_SENSORS_MAX31785) += max31785.o ··· 41 40 obj-$(CONFIG_SENSORS_MP2869) += mp2869.o 42 41 obj-$(CONFIG_SENSORS_MP2888) += mp2888.o 43 42 obj-$(CONFIG_SENSORS_MP2891) += mp2891.o 43 + obj-$(CONFIG_SENSORS_MP2925) += mp2925.o 44 44 obj-$(CONFIG_SENSORS_MP29502) += mp29502.o 45 45 obj-$(CONFIG_SENSORS_MP2975) += mp2975.o 46 46 obj-$(CONFIG_SENSORS_MP2993) += mp2993.o ··· 49 47 obj-$(CONFIG_SENSORS_MP5920) += mp5920.o 50 48 obj-$(CONFIG_SENSORS_MP5990) += mp5990.o 51 49 obj-$(CONFIG_SENSORS_MP9941) += mp9941.o 50 + obj-$(CONFIG_SENSORS_MP9945) += mp9945.o 52 51 obj-$(CONFIG_SENSORS_MPQ7932) += mpq7932.o 53 52 obj-$(CONFIG_SENSORS_MPQ8785) += mpq8785.o 54 53 obj-$(CONFIG_SENSORS_PLI1209BC) += pli1209bc.o
+14
drivers/hwmon/pmbus/isl68137.c
··· 65 65 raa228246, 66 66 raa229001, 67 67 raa229004, 68 + raa229141, 68 69 raa229621, 69 70 }; 70 71 ··· 74 73 raa_dmpvr2_1rail, 75 74 raa_dmpvr2_2rail, 76 75 raa_dmpvr2_2rail_nontc, 76 + raa_dmpvr2_2rail_pmbus, 77 77 raa_dmpvr2_3rail, 78 78 raa_dmpvr2_hv, 79 79 }; ··· 401 399 info->read_word_data = raa_dmpvr2_read_word_data; 402 400 info->write_word_data = raa_dmpvr2_write_word_data; 403 401 break; 402 + case raa_dmpvr2_2rail_pmbus: 403 + info->format[PSC_VOLTAGE_IN] = linear, 404 + info->format[PSC_VOLTAGE_OUT] = linear, 405 + info->format[PSC_CURRENT_IN] = linear; 406 + info->format[PSC_CURRENT_OUT] = linear; 407 + info->format[PSC_POWER] = linear; 408 + info->format[PSC_TEMPERATURE] = linear; 409 + info->pages = 2; 410 + info->read_word_data = raa_dmpvr2_read_word_data; 411 + info->write_word_data = raa_dmpvr2_write_word_data; 412 + break; 404 413 case raa_dmpvr2_3rail: 405 414 info->read_word_data = raa_dmpvr2_read_word_data; 406 415 info->write_word_data = raa_dmpvr2_write_word_data; ··· 482 469 {"raa228246", raa_dmpvr2_2rail_nontc}, 483 470 {"raa229001", raa_dmpvr2_2rail}, 484 471 {"raa229004", raa_dmpvr2_2rail}, 472 + {"raa229141", raa_dmpvr2_2rail_pmbus}, 485 473 {"raa229621", raa_dmpvr2_2rail}, 486 474 {} 487 475 };
+73
drivers/hwmon/pmbus/max17616.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Hardware monitoring driver for Analog Devices MAX17616/MAX17616A 4 + * 5 + * Copyright (C) 2025 Analog Devices, Inc. 6 + */ 7 + 8 + #include <linux/err.h> 9 + #include <linux/i2c.h> 10 + #include <linux/mod_devicetable.h> 11 + #include <linux/module.h> 12 + 13 + #include "pmbus.h" 14 + 15 + static struct pmbus_driver_info max17616_info = { 16 + .pages = 1, 17 + .format[PSC_VOLTAGE_IN] = direct, 18 + .m[PSC_VOLTAGE_IN] = 512, 19 + .b[PSC_VOLTAGE_IN] = -18, 20 + .R[PSC_VOLTAGE_IN] = -1, 21 + 22 + .format[PSC_VOLTAGE_OUT] = direct, 23 + .m[PSC_VOLTAGE_OUT] = 512, 24 + .b[PSC_VOLTAGE_OUT] = -18, 25 + .R[PSC_VOLTAGE_OUT] = -1, 26 + 27 + .format[PSC_CURRENT_OUT] = direct, 28 + .m[PSC_CURRENT_OUT] = 5845, 29 + .b[PSC_CURRENT_OUT] = 80, 30 + .R[PSC_CURRENT_OUT] = -1, 31 + 32 + .format[PSC_TEMPERATURE] = direct, 33 + .m[PSC_TEMPERATURE] = 71, 34 + .b[PSC_TEMPERATURE] = 19653, 35 + .R[PSC_TEMPERATURE] = -1, 36 + 37 + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | 38 + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_VOUT | 39 + PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT | 40 + PMBUS_HAVE_STATUS_TEMP, 41 + }; 42 + 43 + static int max17616_probe(struct i2c_client *client) 44 + { 45 + return pmbus_do_probe(client, &max17616_info); 46 + } 47 + 48 + static const struct i2c_device_id max17616_id[] = { 49 + { "max17616" }, 50 + { } 51 + }; 52 + MODULE_DEVICE_TABLE(i2c, max17616_id); 53 + 54 + static const struct of_device_id max17616_of_match[] = { 55 + { .compatible = "adi,max17616" }, 56 + { } 57 + }; 58 + MODULE_DEVICE_TABLE(of, max17616_of_match); 59 + 60 + static struct i2c_driver max17616_driver = { 61 + .driver = { 62 + .name = "max17616", 63 + .of_match_table = max17616_of_match, 64 + }, 65 + .probe = max17616_probe, 66 + .id_table = max17616_id, 67 + }; 68 + module_i2c_driver(max17616_driver); 69 + 70 + MODULE_AUTHOR("Kim Seer Paller <kimseer.paller@analog.com>"); 71 + MODULE_DESCRIPTION("PMBus driver for Analog Devices MAX17616/MAX17616A"); 72 + MODULE_LICENSE("GPL"); 73 + MODULE_IMPORT_NS("PMBUS");
+41 -3
drivers/hwmon/pmbus/max34440.c
··· 17 17 18 18 enum chips { 19 19 adpm12160, 20 + adpm12200, 20 21 max34440, 21 22 max34441, 22 23 max34446, ··· 99 98 break; 100 99 case PMBUS_VIRT_READ_IOUT_AVG: 101 100 if (data->id != max34446 && data->id != max34451 && 102 - data->id != adpm12160) 101 + data->id != adpm12160 && data->id != adpm12200) 103 102 return -ENXIO; 104 103 ret = pmbus_read_word_data(client, page, phase, 105 104 MAX34446_MFR_IOUT_AVG); ··· 184 183 ret = pmbus_write_word_data(client, page, 185 184 MAX34440_MFR_IOUT_PEAK, 0); 186 185 if (!ret && (data->id == max34446 || data->id == max34451 || 187 - data->id == adpm12160)) 186 + data->id == adpm12160 || data->id == adpm12200)) 188 187 ret = pmbus_write_word_data(client, page, 189 188 MAX34446_MFR_IOUT_AVG, 0); 190 189 ··· 361 360 .func[8] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT, 362 361 .func[9] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT, 363 362 .func[10] = PMBUS_HAVE_IIN | PMBUS_HAVE_STATUS_INPUT, 363 + .func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, 364 + .read_word_data = max34440_read_word_data, 365 + .write_word_data = max34440_write_word_data, 366 + }, 367 + [adpm12200] = { 368 + .pages = 19, 369 + .format[PSC_VOLTAGE_IN] = direct, 370 + .format[PSC_VOLTAGE_OUT] = direct, 371 + .format[PSC_CURRENT_IN] = direct, 372 + .format[PSC_CURRENT_OUT] = direct, 373 + .format[PSC_TEMPERATURE] = direct, 374 + .m[PSC_VOLTAGE_IN] = 125, 375 + .b[PSC_VOLTAGE_IN] = 0, 376 + .R[PSC_VOLTAGE_IN] = 0, 377 + .m[PSC_VOLTAGE_OUT] = 125, 378 + .b[PSC_VOLTAGE_OUT] = 0, 379 + .R[PSC_VOLTAGE_OUT] = 0, 380 + .m[PSC_CURRENT_IN] = 250, 381 + .b[PSC_CURRENT_IN] = 0, 382 + .R[PSC_CURRENT_IN] = -1, 383 + .m[PSC_CURRENT_OUT] = 250, 384 + .b[PSC_CURRENT_OUT] = 0, 385 + .R[PSC_CURRENT_OUT] = -1, 386 + .m[PSC_TEMPERATURE] = 1, 387 + .b[PSC_TEMPERATURE] = 0, 388 + .R[PSC_TEMPERATURE] = 2, 389 + /* absent func below [18] are not for monitoring */ 390 + .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT, 391 + .func[4] = PMBUS_HAVE_STATUS_IOUT, 392 + .func[5] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT, 393 + .func[6] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT, 394 + .func[7] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT, 395 + .func[8] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT, 396 + .func[9] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT, 397 + .func[10] = PMBUS_HAVE_IIN | PMBUS_HAVE_STATUS_INPUT, 398 + .func[14] = PMBUS_HAVE_IOUT, 364 399 .func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, 365 400 .read_word_data = max34440_read_word_data, 366 401 .write_word_data = max34440_write_word_data, ··· 637 600 rv = max34451_set_supported_funcs(client, data); 638 601 if (rv) 639 602 return rv; 640 - } else if (data->id == adpm12160) { 603 + } else if (data->id == adpm12160 || data->id == adpm12200) { 641 604 data->iout_oc_fault_limit = PMBUS_IOUT_OC_FAULT_LIMIT; 642 605 data->iout_oc_warn_limit = PMBUS_IOUT_OC_WARN_LIMIT; 643 606 } ··· 647 610 648 611 static const struct i2c_device_id max34440_id[] = { 649 612 {"adpm12160", adpm12160}, 613 + {"adpm12200", adpm12200}, 650 614 {"max34440", max34440}, 651 615 {"max34441", max34441}, 652 616 {"max34446", max34446},
+316
drivers/hwmon/pmbus/mp2925.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Hardware monitoring driver for MPS Multi-phase Digital VR Controllers(MP2925) 4 + */ 5 + 6 + #include <linux/bitfield.h> 7 + #include <linux/i2c.h> 8 + #include <linux/module.h> 9 + #include <linux/of_device.h> 10 + #include "pmbus.h" 11 + 12 + /* 13 + * Vender specific register MFR_VR_MULTI_CONFIG(0x08). 14 + * This register is used to obtain vid scale. 15 + */ 16 + #define MFR_VR_MULTI_CONFIG 0x08 17 + 18 + #define MP2925_VOUT_DIV 512 19 + #define MP2925_VOUT_OVUV_UINT 195 20 + #define MP2925_VOUT_OVUV_DIV 100 21 + 22 + #define MP2925_PAGE_NUM 2 23 + 24 + #define MP2925_RAIL1_FUNC (PMBUS_HAVE_VIN | PMBUS_HAVE_PIN | \ 25 + PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | \ 26 + PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP | \ 27 + PMBUS_HAVE_STATUS_VOUT | \ 28 + PMBUS_HAVE_STATUS_IOUT | \ 29 + PMBUS_HAVE_STATUS_TEMP | \ 30 + PMBUS_HAVE_STATUS_INPUT) 31 + 32 + #define MP2925_RAIL2_FUNC (PMBUS_HAVE_PIN | PMBUS_HAVE_VOUT | \ 33 + PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT | \ 34 + PMBUS_HAVE_TEMP | PMBUS_HAVE_IIN | \ 35 + PMBUS_HAVE_STATUS_VOUT | \ 36 + PMBUS_HAVE_STATUS_IOUT | \ 37 + PMBUS_HAVE_STATUS_TEMP | \ 38 + PMBUS_HAVE_STATUS_INPUT) 39 + 40 + struct mp2925_data { 41 + struct pmbus_driver_info info; 42 + int vout_scale[MP2925_PAGE_NUM]; 43 + }; 44 + 45 + #define to_mp2925_data(x) container_of(x, struct mp2925_data, info) 46 + 47 + static u16 mp2925_linear_exp_transfer(u16 word, u16 expect_exponent) 48 + { 49 + s16 exponent, mantissa, target_exponent; 50 + 51 + exponent = ((s16)word) >> 11; 52 + mantissa = ((s16)((word & 0x7ff) << 5)) >> 5; 53 + target_exponent = (s16)((expect_exponent & 0x1f) << 11) >> 11; 54 + 55 + if (exponent > target_exponent) 56 + mantissa = mantissa << (exponent - target_exponent); 57 + else 58 + mantissa = mantissa >> (target_exponent - exponent); 59 + 60 + return (mantissa & 0x7ff) | ((expect_exponent << 11) & 0xf800); 61 + } 62 + 63 + static int mp2925_read_byte_data(struct i2c_client *client, int page, int reg) 64 + { 65 + int ret; 66 + 67 + switch (reg) { 68 + case PMBUS_VOUT_MODE: 69 + /* 70 + * The MP2925 does not follow standard PMBus protocol completely, 71 + * and the calculation of vout in this driver is based on direct 72 + * format. As a result, the format of vout is enforced to direct. 73 + */ 74 + ret = PB_VOUT_MODE_DIRECT; 75 + break; 76 + default: 77 + ret = -ENODATA; 78 + break; 79 + } 80 + 81 + return ret; 82 + } 83 + 84 + static int mp2925_read_word_data(struct i2c_client *client, int page, int phase, 85 + int reg) 86 + { 87 + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 88 + struct mp2925_data *data = to_mp2925_data(info); 89 + int ret; 90 + 91 + switch (reg) { 92 + case PMBUS_READ_VOUT: 93 + ret = pmbus_read_word_data(client, page, phase, reg); 94 + if (ret < 0) 95 + return ret; 96 + 97 + ret = DIV_ROUND_CLOSEST((ret & GENMASK(11, 0)) * data->vout_scale[page], 98 + MP2925_VOUT_DIV); 99 + break; 100 + case PMBUS_VOUT_OV_FAULT_LIMIT: 101 + case PMBUS_VOUT_UV_FAULT_LIMIT: 102 + ret = pmbus_read_word_data(client, page, phase, reg); 103 + if (ret < 0) 104 + return ret; 105 + 106 + ret = DIV_ROUND_CLOSEST((ret & GENMASK(11, 0)) * MP2925_VOUT_OVUV_UINT, 107 + MP2925_VOUT_OVUV_DIV); 108 + break; 109 + case PMBUS_STATUS_WORD: 110 + case PMBUS_READ_VIN: 111 + case PMBUS_READ_IOUT: 112 + case PMBUS_READ_POUT: 113 + case PMBUS_READ_PIN: 114 + case PMBUS_READ_IIN: 115 + case PMBUS_READ_TEMPERATURE_1: 116 + case PMBUS_VIN_OV_FAULT_LIMIT: 117 + case PMBUS_VIN_OV_WARN_LIMIT: 118 + case PMBUS_VIN_UV_WARN_LIMIT: 119 + case PMBUS_VIN_UV_FAULT_LIMIT: 120 + case PMBUS_IOUT_OC_FAULT_LIMIT: 121 + case PMBUS_IOUT_OC_WARN_LIMIT: 122 + case PMBUS_OT_FAULT_LIMIT: 123 + case PMBUS_OT_WARN_LIMIT: 124 + ret = -ENODATA; 125 + break; 126 + default: 127 + ret = -EINVAL; 128 + break; 129 + } 130 + 131 + return ret; 132 + } 133 + 134 + static int mp2925_write_word_data(struct i2c_client *client, int page, int reg, 135 + u16 word) 136 + { 137 + int ret; 138 + 139 + switch (reg) { 140 + case PMBUS_VIN_OV_FAULT_LIMIT: 141 + case PMBUS_VIN_OV_WARN_LIMIT: 142 + case PMBUS_VIN_UV_WARN_LIMIT: 143 + case PMBUS_VIN_UV_FAULT_LIMIT: 144 + /* 145 + * The PMBUS_VIN_OV_FAULT_LIMIT, PMBUS_VIN_OV_WARN_LIMIT, 146 + * PMBUS_VIN_UV_WARN_LIMIT and PMBUS_VIN_UV_FAULT_LIMIT 147 + * of MP2925 is linear11 format, and the exponent is a 148 + * constant value(5'b11100), so the exponent of word 149 + * parameter should be converted to 5'b11100(0x1C). 150 + */ 151 + ret = pmbus_write_word_data(client, page, reg, 152 + mp2925_linear_exp_transfer(word, 0x1C)); 153 + break; 154 + case PMBUS_VOUT_OV_FAULT_LIMIT: 155 + case PMBUS_VOUT_UV_FAULT_LIMIT: 156 + /* 157 + * The bit0-bit11 is the limit value, and bit12-bit15 158 + * should not be changed. 159 + */ 160 + ret = pmbus_read_word_data(client, page, 0xff, reg); 161 + if (ret < 0) 162 + return ret; 163 + 164 + ret = pmbus_write_word_data(client, page, reg, 165 + (ret & ~GENMASK(11, 0)) | 166 + FIELD_PREP(GENMASK(11, 0), 167 + DIV_ROUND_CLOSEST(word * MP2925_VOUT_OVUV_DIV, 168 + MP2925_VOUT_OVUV_UINT))); 169 + break; 170 + case PMBUS_OT_FAULT_LIMIT: 171 + case PMBUS_OT_WARN_LIMIT: 172 + /* 173 + * The PMBUS_OT_FAULT_LIMIT and PMBUS_OT_WARN_LIMIT of 174 + * MP2925 is linear11 format, and the exponent is a 175 + * constant value(5'b00000), so the exponent of word 176 + * parameter should be converted to 5'b00000. 177 + */ 178 + ret = pmbus_write_word_data(client, page, reg, 179 + mp2925_linear_exp_transfer(word, 0x00)); 180 + break; 181 + case PMBUS_IOUT_OC_FAULT_LIMIT: 182 + case PMBUS_IOUT_OC_WARN_LIMIT: 183 + /* 184 + * The PMBUS_IOUT_OC_FAULT_LIMIT and PMBUS_IOUT_OC_WARN_LIMIT 185 + * of MP2925 is linear11 format, and the exponent can not be 186 + * changed. 187 + */ 188 + ret = pmbus_read_word_data(client, page, 0xff, reg); 189 + if (ret < 0) 190 + return ret; 191 + 192 + ret = pmbus_write_word_data(client, page, reg, 193 + mp2925_linear_exp_transfer(word, 194 + FIELD_GET(GENMASK(15, 11), 195 + ret))); 196 + break; 197 + default: 198 + ret = -EINVAL; 199 + break; 200 + } 201 + 202 + return ret; 203 + } 204 + 205 + static int 206 + mp2925_identify_vout_scale(struct i2c_client *client, struct pmbus_driver_info *info, 207 + int page) 208 + { 209 + struct mp2925_data *data = to_mp2925_data(info); 210 + int ret; 211 + 212 + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); 213 + if (ret < 0) 214 + return ret; 215 + 216 + ret = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE); 217 + if (ret < 0) 218 + return ret; 219 + 220 + if (FIELD_GET(GENMASK(5, 5), ret)) { 221 + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 222 + page == 0 ? 3 : 4); 223 + if (ret < 0) 224 + return ret; 225 + 226 + ret = i2c_smbus_read_word_data(client, MFR_VR_MULTI_CONFIG); 227 + if (ret < 0) 228 + return ret; 229 + 230 + if (FIELD_GET(GENMASK(5, 5), ret)) 231 + data->vout_scale[page] = 2560; 232 + else 233 + data->vout_scale[page] = 5120; 234 + } else if (FIELD_GET(GENMASK(4, 4), ret)) { 235 + data->vout_scale[page] = 1; 236 + } else { 237 + data->vout_scale[page] = 512; 238 + } 239 + 240 + return 0; 241 + } 242 + 243 + static int mp2925_identify(struct i2c_client *client, struct pmbus_driver_info *info) 244 + { 245 + int ret; 246 + 247 + ret = mp2925_identify_vout_scale(client, info, 0); 248 + if (ret < 0) 249 + return ret; 250 + 251 + return mp2925_identify_vout_scale(client, info, 1); 252 + } 253 + 254 + static const struct pmbus_driver_info mp2925_info = { 255 + .pages = MP2925_PAGE_NUM, 256 + .format[PSC_VOLTAGE_IN] = linear, 257 + .format[PSC_CURRENT_IN] = linear, 258 + .format[PSC_CURRENT_OUT] = linear, 259 + .format[PSC_POWER] = linear, 260 + .format[PSC_TEMPERATURE] = linear, 261 + .format[PSC_VOLTAGE_OUT] = direct, 262 + 263 + .m[PSC_VOLTAGE_OUT] = 1, 264 + .R[PSC_VOLTAGE_OUT] = 3, 265 + .b[PSC_VOLTAGE_OUT] = 0, 266 + 267 + .func[0] = MP2925_RAIL1_FUNC, 268 + .func[1] = MP2925_RAIL2_FUNC, 269 + .read_word_data = mp2925_read_word_data, 270 + .read_byte_data = mp2925_read_byte_data, 271 + .write_word_data = mp2925_write_word_data, 272 + .identify = mp2925_identify, 273 + }; 274 + 275 + static int mp2925_probe(struct i2c_client *client) 276 + { 277 + struct mp2925_data *data; 278 + 279 + data = devm_kzalloc(&client->dev, sizeof(struct mp2925_data), GFP_KERNEL); 280 + if (!data) 281 + return -ENOMEM; 282 + 283 + memcpy(&data->info, &mp2925_info, sizeof(mp2925_info)); 284 + 285 + return pmbus_do_probe(client, &data->info); 286 + } 287 + 288 + static const struct i2c_device_id mp2925_id[] = { 289 + {"mp2925"}, 290 + {"mp2929"}, 291 + {} 292 + }; 293 + MODULE_DEVICE_TABLE(i2c, mp2925_id); 294 + 295 + static const struct of_device_id __maybe_unused mp2925_of_match[] = { 296 + {.compatible = "mps,mp2925"}, 297 + {.compatible = "mps,mp2929"}, 298 + {} 299 + }; 300 + MODULE_DEVICE_TABLE(of, mp2925_of_match); 301 + 302 + static struct i2c_driver mp2925_driver = { 303 + .driver = { 304 + .name = "mp2925", 305 + .of_match_table = mp2925_of_match, 306 + }, 307 + .probe = mp2925_probe, 308 + .id_table = mp2925_id, 309 + }; 310 + 311 + module_i2c_driver(mp2925_driver); 312 + 313 + MODULE_AUTHOR("Wensheng Wang <wenswang@yeah.net>"); 314 + MODULE_DESCRIPTION("PMBus driver for MPS MP2925"); 315 + MODULE_LICENSE("GPL"); 316 + MODULE_IMPORT_NS("PMBUS");
+243
drivers/hwmon/pmbus/mp9945.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Hardware monitoring driver for MPS Single-phase Digital VR Controllers(MP9945) 4 + */ 5 + 6 + #include <linux/bitfield.h> 7 + #include <linux/i2c.h> 8 + #include <linux/module.h> 9 + #include <linux/of_device.h> 10 + #include "pmbus.h" 11 + 12 + #define MFR_VR_MULTI_CONFIG_R1 0x08 13 + #define MFR_SVID_CFG_R1 0xBD 14 + 15 + /* VOUT_MODE register values */ 16 + #define VOUT_MODE_LINEAR16 0x17 17 + #define VOUT_MODE_VID 0x21 18 + #define VOUT_MODE_DIRECT 0x40 19 + 20 + #define MP9945_PAGE_NUM 1 21 + 22 + #define MP9945_RAIL1_FUNC (PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | \ 23 + PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | \ 24 + PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | \ 25 + PMBUS_HAVE_TEMP | \ 26 + PMBUS_HAVE_STATUS_VOUT | \ 27 + PMBUS_HAVE_STATUS_IOUT | \ 28 + PMBUS_HAVE_STATUS_TEMP | \ 29 + PMBUS_HAVE_STATUS_INPUT) 30 + 31 + enum mp9945_vout_mode { 32 + MP9945_VOUT_MODE_VID, 33 + MP9945_VOUT_MODE_DIRECT, 34 + MP9945_VOUT_MODE_LINEAR16, 35 + }; 36 + 37 + struct mp9945_data { 38 + struct pmbus_driver_info info; 39 + enum mp9945_vout_mode vout_mode; 40 + int vid_resolution; 41 + int vid_offset; 42 + }; 43 + 44 + #define to_mp9945_data(x) container_of(x, struct mp9945_data, info) 45 + 46 + static int mp9945_read_vout(struct i2c_client *client, struct mp9945_data *data) 47 + { 48 + int ret; 49 + 50 + ret = i2c_smbus_read_word_data(client, PMBUS_READ_VOUT); 51 + if (ret < 0) 52 + return ret; 53 + 54 + ret &= GENMASK(11, 0); 55 + 56 + switch (data->vout_mode) { 57 + case MP9945_VOUT_MODE_VID: 58 + if (ret > 0) 59 + ret = (ret + data->vid_offset) * data->vid_resolution; 60 + break; 61 + case MP9945_VOUT_MODE_DIRECT: 62 + break; 63 + case MP9945_VOUT_MODE_LINEAR16: 64 + /* LSB: 1000 * 2^-9 (mV) */ 65 + ret = DIV_ROUND_CLOSEST(ret * 125, 64); 66 + break; 67 + default: 68 + return -ENODEV; 69 + } 70 + 71 + return ret; 72 + } 73 + 74 + static int mp9945_read_byte_data(struct i2c_client *client, int page, int reg) 75 + { 76 + int ret; 77 + 78 + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); 79 + if (ret < 0) 80 + return ret; 81 + 82 + switch (reg) { 83 + case PMBUS_VOUT_MODE: 84 + /* 85 + * Override VOUT_MODE to DIRECT as the driver handles custom 86 + * VOUT format conversions internally. 87 + */ 88 + return PB_VOUT_MODE_DIRECT; 89 + default: 90 + return -ENODATA; 91 + } 92 + } 93 + 94 + static int mp9945_read_word_data(struct i2c_client *client, int page, int phase, 95 + int reg) 96 + { 97 + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 98 + struct mp9945_data *data = to_mp9945_data(info); 99 + int ret; 100 + 101 + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); 102 + if (ret < 0) 103 + return ret; 104 + 105 + switch (reg) { 106 + case PMBUS_READ_VOUT: 107 + ret = mp9945_read_vout(client, data); 108 + break; 109 + case PMBUS_VOUT_OV_FAULT_LIMIT: 110 + case PMBUS_VOUT_UV_FAULT_LIMIT: 111 + ret = i2c_smbus_read_word_data(client, reg); 112 + if (ret < 0) 113 + return ret; 114 + 115 + /* LSB: 1.95 (mV) */ 116 + ret = DIV_ROUND_CLOSEST((ret & GENMASK(11, 0)) * 39, 20); 117 + break; 118 + case PMBUS_VOUT_UV_WARN_LIMIT: 119 + ret = i2c_smbus_read_word_data(client, reg); 120 + if (ret < 0) 121 + return ret; 122 + 123 + ret &= GENMASK(9, 0); 124 + if (ret > 0) 125 + ret = (ret + data->vid_offset) * data->vid_resolution; 126 + break; 127 + default: 128 + ret = -ENODATA; 129 + break; 130 + } 131 + 132 + return ret; 133 + } 134 + 135 + static int mp9945_identify(struct i2c_client *client, 136 + struct pmbus_driver_info *info) 137 + { 138 + struct mp9945_data *data = to_mp9945_data(info); 139 + int ret; 140 + 141 + ret = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE); 142 + if (ret < 0) 143 + return ret; 144 + 145 + switch (ret) { 146 + case VOUT_MODE_LINEAR16: 147 + data->vout_mode = MP9945_VOUT_MODE_LINEAR16; 148 + break; 149 + case VOUT_MODE_VID: 150 + data->vout_mode = MP9945_VOUT_MODE_VID; 151 + break; 152 + case VOUT_MODE_DIRECT: 153 + data->vout_mode = MP9945_VOUT_MODE_DIRECT; 154 + break; 155 + default: 156 + return -ENODEV; 157 + } 158 + 159 + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 3); 160 + if (ret < 0) 161 + return ret; 162 + 163 + ret = i2c_smbus_read_word_data(client, MFR_VR_MULTI_CONFIG_R1); 164 + if (ret < 0) 165 + return ret; 166 + 167 + data->vid_resolution = (FIELD_GET(BIT(2), ret)) ? 5 : 10; 168 + 169 + ret = i2c_smbus_read_word_data(client, MFR_SVID_CFG_R1); 170 + if (ret < 0) 171 + return ret; 172 + 173 + data->vid_offset = (FIELD_GET(BIT(15), ret)) ? 19 : 49; 174 + 175 + return i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); 176 + } 177 + 178 + static struct pmbus_driver_info mp9945_info = { 179 + .pages = MP9945_PAGE_NUM, 180 + .format[PSC_VOLTAGE_IN] = linear, 181 + .format[PSC_VOLTAGE_OUT] = direct, 182 + .format[PSC_CURRENT_IN] = linear, 183 + .format[PSC_CURRENT_OUT] = linear, 184 + .format[PSC_POWER] = linear, 185 + .format[PSC_TEMPERATURE] = linear, 186 + .m[PSC_VOLTAGE_OUT] = 1, 187 + .R[PSC_VOLTAGE_OUT] = 3, 188 + .b[PSC_VOLTAGE_OUT] = 0, 189 + .func[0] = MP9945_RAIL1_FUNC, 190 + .read_word_data = mp9945_read_word_data, 191 + .read_byte_data = mp9945_read_byte_data, 192 + .identify = mp9945_identify, 193 + }; 194 + 195 + static int mp9945_probe(struct i2c_client *client) 196 + { 197 + struct mp9945_data *data; 198 + int ret; 199 + 200 + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); 201 + if (!data) 202 + return -ENOMEM; 203 + 204 + memcpy(&data->info, &mp9945_info, sizeof(mp9945_info)); 205 + 206 + /* 207 + * Set page 0 before probe. The core reads paged registers which are 208 + * only on page 0 for this device. 209 + */ 210 + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); 211 + if (ret < 0) 212 + return ret; 213 + 214 + return pmbus_do_probe(client, &data->info); 215 + } 216 + 217 + static const struct i2c_device_id mp9945_id[] = { 218 + {"mp9945"}, 219 + {} 220 + }; 221 + MODULE_DEVICE_TABLE(i2c, mp9945_id); 222 + 223 + static const struct of_device_id __maybe_unused mp9945_of_match[] = { 224 + {.compatible = "mps,mp9945"}, 225 + {} 226 + }; 227 + MODULE_DEVICE_TABLE(of, mp9945_of_match); 228 + 229 + static struct i2c_driver mp9945_driver = { 230 + .driver = { 231 + .name = "mp9945", 232 + .of_match_table = of_match_ptr(mp9945_of_match), 233 + }, 234 + .probe = mp9945_probe, 235 + .id_table = mp9945_id, 236 + }; 237 + 238 + module_i2c_driver(mp9945_driver); 239 + 240 + MODULE_AUTHOR("Cosmo Chou <chou.cosmo@gmail.com>"); 241 + MODULE_DESCRIPTION("PMBus driver for MPS MP9945"); 242 + MODULE_LICENSE("GPL"); 243 + MODULE_IMPORT_NS("PMBUS");
+4 -13
drivers/hwmon/powr1220.c
··· 16 16 #include <linux/hwmon.h> 17 17 #include <linux/hwmon-sysfs.h> 18 18 #include <linux/err.h> 19 - #include <linux/mutex.h> 20 19 #include <linux/delay.h> 21 20 22 21 #define ADC_STEP_MV 2 ··· 74 75 75 76 struct powr1220_data { 76 77 struct i2c_client *client; 77 - struct mutex update_lock; 78 78 u8 max_channels; 79 79 bool adc_valid[MAX_POWR1220_ADC_VALUES]; 80 80 /* the next value is in jiffies */ ··· 109 111 int result; 110 112 int adc_range = 0; 111 113 112 - mutex_lock(&data->update_lock); 113 - 114 114 if (time_after(jiffies, data->adc_last_updated[ch_num] + HZ) || 115 115 !data->adc_valid[ch_num]) { 116 116 /* ··· 124 128 /* set the attenuator and mux */ 125 129 result = i2c_smbus_write_byte_data(data->client, ADC_MUX, 126 130 adc_range | ch_num); 127 - if (result) 128 - goto exit; 131 + if (result < 0) 132 + return result; 129 133 130 134 /* 131 135 * wait at least Tconvert time (200 us) for the ··· 136 140 /* get the ADC reading */ 137 141 result = i2c_smbus_read_byte_data(data->client, ADC_VALUE_LOW); 138 142 if (result < 0) 139 - goto exit; 143 + return result; 140 144 141 145 reading = result >> 4; 142 146 143 147 /* get the upper half of the reading */ 144 148 result = i2c_smbus_read_byte_data(data->client, ADC_VALUE_HIGH); 145 149 if (result < 0) 146 - goto exit; 150 + return result; 147 151 148 152 reading |= result << 4; 149 153 ··· 159 163 } else { 160 164 result = data->adc_values[ch_num]; 161 165 } 162 - 163 - exit: 164 - mutex_unlock(&data->update_lock); 165 - 166 166 return result; 167 167 } 168 168 ··· 294 302 break; 295 303 } 296 304 297 - mutex_init(&data->update_lock); 298 305 data->client = client; 299 306 300 307 hwmon_dev = devm_hwmon_device_register_with_info(&client->dev,
+2 -15
drivers/hwmon/sbtsi_temp.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/hwmon.h> 14 14 #include <linux/module.h> 15 - #include <linux/mutex.h> 16 15 #include <linux/of.h> 17 16 #include <linux/bitfield.h> 18 17 ··· 51 52 /* Each client has this additional data */ 52 53 struct sbtsi_data { 53 54 struct i2c_client *client; 54 - struct mutex lock; 55 55 bool ext_range_mode; 56 56 bool read_order; 57 57 }; ··· 92 94 93 95 switch (attr) { 94 96 case hwmon_temp_input: 95 - mutex_lock(&data->lock); 96 97 if (data->read_order) { 97 98 temp_dec = i2c_smbus_read_byte_data(data->client, SBTSI_REG_TEMP_DEC); 98 99 temp_int = i2c_smbus_read_byte_data(data->client, SBTSI_REG_TEMP_INT); ··· 99 102 temp_int = i2c_smbus_read_byte_data(data->client, SBTSI_REG_TEMP_INT); 100 103 temp_dec = i2c_smbus_read_byte_data(data->client, SBTSI_REG_TEMP_DEC); 101 104 } 102 - mutex_unlock(&data->lock); 103 105 break; 104 106 case hwmon_temp_max: 105 - mutex_lock(&data->lock); 106 107 temp_int = i2c_smbus_read_byte_data(data->client, SBTSI_REG_TEMP_HIGH_INT); 107 108 temp_dec = i2c_smbus_read_byte_data(data->client, SBTSI_REG_TEMP_HIGH_DEC); 108 - mutex_unlock(&data->lock); 109 109 break; 110 110 case hwmon_temp_min: 111 - mutex_lock(&data->lock); 112 111 temp_int = i2c_smbus_read_byte_data(data->client, SBTSI_REG_TEMP_LOW_INT); 113 112 temp_dec = i2c_smbus_read_byte_data(data->client, SBTSI_REG_TEMP_LOW_DEC); 114 - mutex_unlock(&data->lock); 115 113 break; 116 114 default: 117 115 return -EINVAL; ··· 150 158 val = clamp_val(val, SBTSI_TEMP_MIN, SBTSI_TEMP_MAX); 151 159 sbtsi_mc_to_reg(val, &temp_int, &temp_dec); 152 160 153 - mutex_lock(&data->lock); 154 161 err = i2c_smbus_write_byte_data(data->client, reg_int, temp_int); 155 162 if (err) 156 - goto exit; 163 + return err; 157 164 158 - err = i2c_smbus_write_byte_data(data->client, reg_dec, temp_dec); 159 - exit: 160 - mutex_unlock(&data->lock); 161 - return err; 165 + return i2c_smbus_write_byte_data(data->client, reg_dec, temp_dec); 162 166 } 163 167 164 168 static umode_t sbtsi_is_visible(const void *data, ··· 207 219 return -ENOMEM; 208 220 209 221 data->client = client; 210 - mutex_init(&data->lock); 211 222 212 223 err = i2c_smbus_read_byte_data(data->client, SBTSI_REG_CONFIG); 213 224 if (err < 0)
+9
drivers/hwmon/scmi-hwmon.c
··· 240 240 const struct hwmon_channel_info **ptr_scmi_ci; 241 241 const struct scmi_handle *handle = sdev->handle; 242 242 struct scmi_protocol_handle *ph; 243 + u32 sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK, 244 + SCMI_SENS_CFG_SENSOR_ENABLE); 243 245 244 246 if (!handle) 245 247 return -ENODEV; ··· 340 338 sensor = *(scmi_sensors->info[hwmon_temp] + i); 341 339 if (!sensor) 342 340 continue; 341 + 342 + ret = sensor_ops->config_set(ph, i, sensor_config); 343 + if (ret) { 344 + dev_err(dev, "Error enabling sensor %s. err=%d\n", 345 + sensor->name, ret); 346 + continue; 347 + } 343 348 344 349 /* 345 350 * Warn on any misconfiguration related to thermal zones but
+8 -28
drivers/hwmon/sfctemp.c
··· 10 10 #include <linux/hwmon.h> 11 11 #include <linux/io.h> 12 12 #include <linux/module.h> 13 - #include <linux/mutex.h> 14 13 #include <linux/of.h> 15 14 #include <linux/platform_device.h> 16 15 #include <linux/reset.h> ··· 48 49 #define SFCTEMP_K1000 81100L 49 50 50 51 struct sfctemp { 51 - /* serialize access to hardware register and enabled below */ 52 - struct mutex lock; 53 52 void __iomem *regs; 54 53 struct clk *clk_sense; 55 54 struct clk *clk_bus; ··· 89 92 90 93 static int sfctemp_enable(struct sfctemp *sfctemp) 91 94 { 92 - int ret = 0; 95 + int ret; 93 96 94 - mutex_lock(&sfctemp->lock); 95 97 if (sfctemp->enabled) 96 - goto done; 98 + return 0; 97 99 98 100 ret = clk_prepare_enable(sfctemp->clk_bus); 99 101 if (ret) 100 - goto err; 102 + return ret; 101 103 ret = reset_control_deassert(sfctemp->rst_bus); 102 104 if (ret) 103 105 goto err_disable_bus; ··· 111 115 sfctemp_power_up(sfctemp); 112 116 sfctemp_run(sfctemp); 113 117 sfctemp->enabled = true; 114 - done: 115 - mutex_unlock(&sfctemp->lock); 116 - return ret; 118 + return 0; 117 119 118 120 err_disable_sense: 119 121 clk_disable_unprepare(sfctemp->clk_sense); ··· 119 125 reset_control_assert(sfctemp->rst_bus); 120 126 err_disable_bus: 121 127 clk_disable_unprepare(sfctemp->clk_bus); 122 - err: 123 - mutex_unlock(&sfctemp->lock); 124 128 return ret; 125 129 } 126 130 127 131 static int sfctemp_disable(struct sfctemp *sfctemp) 128 132 { 129 - mutex_lock(&sfctemp->lock); 130 133 if (!sfctemp->enabled) 131 - goto done; 134 + return 0; 132 135 133 136 sfctemp_stop(sfctemp); 134 137 sfctemp_power_down(sfctemp); ··· 134 143 reset_control_assert(sfctemp->rst_bus); 135 144 clk_disable_unprepare(sfctemp->clk_bus); 136 145 sfctemp->enabled = false; 137 - done: 138 - mutex_unlock(&sfctemp->lock); 139 146 return 0; 140 147 } 141 148 ··· 144 155 145 156 static int sfctemp_convert(struct sfctemp *sfctemp, long *val) 146 157 { 147 - int ret; 148 - 149 - mutex_lock(&sfctemp->lock); 150 - if (!sfctemp->enabled) { 151 - ret = -ENODATA; 152 - goto out; 153 - } 158 + if (!sfctemp->enabled) 159 + return -ENODATA; 154 160 155 161 /* calculate temperature in milli Celcius */ 156 162 *val = (long)((readl(sfctemp->regs) & SFCTEMP_DOUT_MSK) >> SFCTEMP_DOUT_POS) 157 163 * SFCTEMP_Y1000 / SFCTEMP_Z - SFCTEMP_K1000; 158 164 159 - ret = 0; 160 - out: 161 - mutex_unlock(&sfctemp->lock); 162 - return ret; 165 + return 0; 163 166 } 164 167 165 168 static umode_t sfctemp_is_visible(const void *data, enum hwmon_sensor_types type, ··· 244 263 return -ENOMEM; 245 264 246 265 dev_set_drvdata(dev, sfctemp); 247 - mutex_init(&sfctemp->lock); 248 266 249 267 sfctemp->regs = devm_platform_ioremap_resource(pdev, 0); 250 268 if (IS_ERR(sfctemp->regs))
+11 -29
drivers/hwmon/sht4x.c
··· 55 55 /** 56 56 * struct sht4x_data - All the data required to operate an SHT4X chip 57 57 * @client: the i2c client associated with the SHT4X 58 - * @lock: a mutex that is used to prevent parallel access to the i2c client 59 58 * @heating_complete: the time that the last heating finished 60 59 * @data_pending: true if and only if there are measurements to retrieve after heating 61 60 * @heater_power: the power at which the heater will be started ··· 67 68 */ 68 69 struct sht4x_data { 69 70 struct i2c_client *client; 70 - struct mutex lock; /* atomic read data updates */ 71 71 unsigned long heating_complete; /* in jiffies */ 72 72 bool data_pending; 73 73 u32 heater_power; /* in milli-watts */ ··· 85 87 */ 86 88 static int sht4x_read_values(struct sht4x_data *data) 87 89 { 88 - int ret = 0; 90 + int ret; 89 91 u16 t_ticks, rh_ticks; 90 92 unsigned long next_update; 91 93 struct i2c_client *client = data->client; ··· 93 95 u8 cmd[SHT4X_CMD_LEN] = {SHT4X_CMD_MEASURE_HPM}; 94 96 u8 raw_data[SHT4X_RESPONSE_LENGTH]; 95 97 unsigned long curr_jiffies; 96 - 97 - mutex_lock(&data->lock); 98 98 99 99 curr_jiffies = jiffies; 100 100 if (time_before(curr_jiffies, data->heating_complete)) ··· 106 110 msecs_to_jiffies(data->update_interval); 107 111 108 112 if (data->valid && time_before_eq(jiffies, next_update)) 109 - goto unlock; 113 + return 0; 110 114 111 115 ret = i2c_master_send(client, cmd, SHT4X_CMD_LEN); 112 116 if (ret < 0) 113 - goto unlock; 117 + return ret; 114 118 115 119 usleep_range(SHT4X_MEAS_DELAY_HPM, SHT4X_MEAS_DELAY_HPM + SHT4X_DELAY_EXTRA); 116 120 } ··· 119 123 if (ret != SHT4X_RESPONSE_LENGTH) { 120 124 if (ret >= 0) 121 125 ret = -ENODATA; 122 - goto unlock; 126 + return ret; 123 127 } 124 128 125 129 t_ticks = raw_data[0] << 8 | raw_data[1]; ··· 128 132 crc = crc8(sht4x_crc8_table, &raw_data[0], SHT4X_WORD_LEN, CRC8_INIT_VALUE); 129 133 if (crc != raw_data[2]) { 130 134 dev_err(&client->dev, "data integrity check failed\n"); 131 - ret = -EIO; 132 - goto unlock; 135 + return -EIO; 133 136 } 134 137 135 138 crc = crc8(sht4x_crc8_table, &raw_data[3], SHT4X_WORD_LEN, CRC8_INIT_VALUE); 136 139 if (crc != raw_data[5]) { 137 140 dev_err(&client->dev, "data integrity check failed\n"); 138 - ret = -EIO; 139 - goto unlock; 141 + return -EIO; 140 142 } 141 143 142 144 data->temperature = ((21875 * (int32_t)t_ticks) >> 13) - 45000; 143 145 data->humidity = ((15625 * (int32_t)rh_ticks) >> 13) - 6000; 144 146 data->last_updated = jiffies; 145 147 data->valid = true; 146 - ret = 0; 147 - 148 - unlock: 149 - mutex_unlock(&data->lock); 150 - return ret; 148 + return 0; 151 149 } 152 150 153 151 static ssize_t sht4x_interval_write(struct sht4x_data *data, long val) ··· 277 287 heating_time_bound = 1100; 278 288 } 279 289 280 - mutex_lock(&data->lock); 281 - 282 - if (time_before(jiffies, data->heating_complete)) { 283 - ret = -EBUSY; 284 - goto unlock; 285 - } 290 + if (time_before(jiffies, data->heating_complete)) 291 + return -EBUSY; 286 292 287 293 ret = i2c_master_send(data->client, &cmd, SHT4X_CMD_LEN); 288 294 if (ret < 0) 289 - goto unlock; 295 + return ret; 290 296 291 297 data->heating_complete = jiffies + msecs_to_jiffies(heating_time_bound); 292 298 data->data_pending = true; 293 - unlock: 294 - mutex_unlock(&data->lock); 295 - return ret; 299 + return 0; 296 300 } 297 301 298 302 static ssize_t heater_power_show(struct device *dev, ··· 405 421 data->heater_power = 200; 406 422 data->heater_time = 1000; 407 423 data->heating_complete = jiffies; 408 - 409 - mutex_init(&data->lock); 410 424 411 425 crc8_populate_msb(sht4x_crc8_table, SHT4X_CRC8_POLYNOMIAL); 412 426
+1 -6
drivers/hwmon/sy7636a-hwmon.c
··· 66 66 static int sy7636a_sensor_probe(struct platform_device *pdev) 67 67 { 68 68 struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL); 69 - struct regulator *regulator; 70 69 struct device *hwmon_dev; 71 70 int err; 72 71 73 72 if (!regmap) 74 73 return -EPROBE_DEFER; 75 74 76 - regulator = devm_regulator_get(&pdev->dev, "vcom"); 77 - if (IS_ERR(regulator)) 78 - return PTR_ERR(regulator); 79 - 80 - err = regulator_enable(regulator); 75 + err = devm_regulator_get_enable(&pdev->dev, "vcom"); 81 76 if (err) 82 77 return err; 83 78
-2
drivers/hwmon/tmp102.c
··· 10 10 #include <linux/slab.h> 11 11 #include <linux/i2c.h> 12 12 #include <linux/hwmon.h> 13 - #include <linux/hwmon-sysfs.h> 14 13 #include <linux/err.h> 15 - #include <linux/mutex.h> 16 14 #include <linux/device.h> 17 15 #include <linux/jiffies.h> 18 16 #include <linux/regmap.h>
-3
drivers/hwmon/tmp103.c
··· 14 14 #include <linux/slab.h> 15 15 #include <linux/i2c.h> 16 16 #include <linux/hwmon.h> 17 - #include <linux/hwmon-sysfs.h> 18 17 #include <linux/err.h> 19 - #include <linux/mutex.h> 20 18 #include <linux/device.h> 21 - #include <linux/jiffies.h> 22 19 #include <linux/regmap.h> 23 20 24 21 #define TMP103_TEMP_REG 0x00
-1
drivers/hwmon/tmp108.c
··· 10 10 #include <linux/hwmon.h> 11 11 #include <linux/mod_devicetable.h> 12 12 #include <linux/module.h> 13 - #include <linux/mutex.h> 14 13 #include <linux/i2c.h> 15 14 #include <linux/i3c/device.h> 16 15 #include <linux/init.h>
-8
drivers/hwmon/tmp401.c
··· 24 24 #include <linux/hwmon.h> 25 25 #include <linux/init.h> 26 26 #include <linux/module.h> 27 - #include <linux/mutex.h> 28 27 #include <linux/regmap.h> 29 28 #include <linux/slab.h> 30 29 ··· 106 107 struct tmp401_data { 107 108 struct i2c_client *client; 108 109 struct regmap *regmap; 109 - struct mutex update_lock; 110 110 enum chips kind; 111 111 112 112 bool extended_range; ··· 355 357 unsigned int regval; 356 358 int reg, ret, temp; 357 359 358 - mutex_lock(&data->update_lock); 359 360 switch (attr) { 360 361 case hwmon_temp_min: 361 362 case hwmon_temp_max: ··· 383 386 ret = -EOPNOTSUPP; 384 387 break; 385 388 } 386 - mutex_unlock(&data->update_lock); 387 389 return ret; 388 390 } 389 391 ··· 432 436 struct regmap *regmap = data->regmap; 433 437 int err; 434 438 435 - mutex_lock(&data->update_lock); 436 439 switch (attr) { 437 440 case hwmon_chip_update_interval: 438 441 err = tmp401_set_convrate(regmap, val); ··· 451 456 err = -EOPNOTSUPP; 452 457 break; 453 458 } 454 - mutex_unlock(&data->update_lock); 455 - 456 459 return err; 457 460 } 458 461 ··· 678 685 return -ENOMEM; 679 686 680 687 data->client = client; 681 - mutex_init(&data->update_lock); 682 688 data->kind = (uintptr_t)i2c_get_match_data(client); 683 689 684 690 data->regmap = devm_regmap_init(dev, NULL, data, &tmp401_regmap_config);
+9 -19
drivers/hwmon/tmp421.c
··· 19 19 #include <linux/hwmon.h> 20 20 #include <linux/hwmon-sysfs.h> 21 21 #include <linux/err.h> 22 - #include <linux/mutex.h> 23 22 #include <linux/of.h> 24 23 #include <linux/sysfs.h> 25 24 ··· 98 99 99 100 struct tmp421_data { 100 101 struct i2c_client *client; 101 - struct mutex update_lock; 102 102 u32 temp_config[MAX_CHANNELS + 1]; 103 103 struct hwmon_channel_info temp_info; 104 104 const struct hwmon_channel_info *info[2]; ··· 128 130 int ret = 0; 129 131 int i; 130 132 131 - mutex_lock(&data->update_lock); 132 - 133 133 if (time_after(jiffies, data->last_updated + (HZ / 2)) || 134 134 !data->valid) { 135 + data->valid = false; 135 136 ret = i2c_smbus_read_byte_data(client, TMP421_CONFIG_REG_1); 136 137 if (ret < 0) 137 - goto exit; 138 + return ret; 138 139 data->config = ret; 139 140 140 141 for (i = 0; i < data->channels; i++) { 141 142 ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_MSB[i]); 142 143 if (ret < 0) 143 - goto exit; 144 + return ret; 144 145 data->channel[i].temp = ret << 8; 145 146 146 147 ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_LSB[i]); 147 148 if (ret < 0) 148 - goto exit; 149 + return ret; 149 150 data->channel[i].temp |= ret; 150 151 } 151 152 data->last_updated = jiffies; 152 153 data->valid = true; 153 154 } 154 - 155 - exit: 156 - mutex_unlock(&data->update_lock); 157 - 158 - if (ret < 0) { 159 - data->valid = false; 160 - return ret; 161 - } 162 - 163 155 return 0; 164 156 } 165 157 ··· 250 262 switch (attr) { 251 263 case hwmon_temp_fault: 252 264 case hwmon_temp_input: 253 - return 0444; 254 265 case hwmon_temp_label: 255 266 return 0444; 256 267 case hwmon_temp_enable: ··· 368 381 return -EINVAL; 369 382 } 370 383 371 - of_property_read_string(child, "label", &data->channel[i].label); 384 + err = of_property_read_string(child, "label", &data->channel[i].label); 385 + if (err == -ENODATA || err == -EILSEQ) { 386 + dev_err(dev, "invalid label property in %pOFn\n", child); 387 + return err; 388 + } 372 389 if (data->channel[i].label) 373 390 data->temp_config[i] |= HWMON_T_LABEL; 374 391 ··· 433 442 if (!data) 434 443 return -ENOMEM; 435 444 436 - mutex_init(&data->update_lock); 437 445 data->channels = (unsigned long)i2c_get_match_data(client); 438 446 data->client = client; 439 447
+1 -12
drivers/hwmon/tmp464.c
··· 13 13 #include <linux/i2c.h> 14 14 #include <linux/init.h> 15 15 #include <linux/module.h> 16 - #include <linux/mutex.h> 17 16 #include <linux/of.h> 18 17 #include <linux/regmap.h> 19 18 #include <linux/slab.h> ··· 91 92 92 93 struct tmp464_data { 93 94 struct regmap *regmap; 94 - struct mutex update_lock; 95 95 int channels; 96 96 s16 config_orig; 97 97 u16 open_reg; ··· 170 172 * complete. That means we have to cache the value internally 171 173 * for one measurement cycle and report the cached value. 172 174 */ 173 - mutex_lock(&data->update_lock); 174 175 if (!data->valid || time_after(jiffies, data->last_updated + 175 176 msecs_to_jiffies(data->update_interval))) { 176 177 err = regmap_read(regmap, TMP464_REMOTE_OPEN_REG, &regval); 177 178 if (err < 0) 178 - goto unlock; 179 + break; 179 180 data->open_reg = regval; 180 181 data->last_updated = jiffies; 181 182 data->valid = true; 182 183 } 183 184 *val = !!(data->open_reg & BIT(channel + 7)); 184 - unlock: 185 - mutex_unlock(&data->update_lock); 186 185 break; 187 186 case hwmon_temp_max_hyst: 188 187 regs[0] = TMP464_THERM_LIMIT[channel]; ··· 340 345 struct tmp464_data *data = dev_get_drvdata(dev); 341 346 int err; 342 347 343 - mutex_lock(&data->update_lock); 344 - 345 348 switch (type) { 346 349 case hwmon_chip: 347 350 err = tmp464_chip_write(data, attr, channel, val); ··· 351 358 err = -EOPNOTSUPP; 352 359 break; 353 360 } 354 - 355 - mutex_unlock(&data->update_lock); 356 361 357 362 return err; 358 363 } ··· 648 657 data = devm_kzalloc(dev, sizeof(struct tmp464_data), GFP_KERNEL); 649 658 if (!data) 650 659 return -ENOMEM; 651 - 652 - mutex_init(&data->update_lock); 653 660 654 661 data->channels = (int)(unsigned long)i2c_get_match_data(client); 655 662
+748
drivers/hwmon/tsc1641.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Driver for ST Microelectronics TSC1641 I2C power monitor 4 + * 5 + * 60 V, 16-bit high-precision power monitor with I2C and MIPI I3C interface 6 + * Datasheet: https://www.st.com/resource/en/datasheet/tsc1641.pdf 7 + * 8 + * Copyright (C) 2025 Igor Reznichenko <igor@reznichenko.net> 9 + */ 10 + 11 + #include <linux/bitfield.h> 12 + #include <linux/bits.h> 13 + #include <linux/device.h> 14 + #include <linux/err.h> 15 + #include <linux/hwmon.h> 16 + #include <linux/i2c.h> 17 + #include <linux/module.h> 18 + #include <linux/regmap.h> 19 + #include <linux/sysfs.h> 20 + #include <linux/util_macros.h> 21 + 22 + /* I2C registers */ 23 + #define TSC1641_CONFIG 0x00 24 + #define TSC1641_SHUNT_VOLTAGE 0x01 25 + #define TSC1641_LOAD_VOLTAGE 0x02 26 + #define TSC1641_POWER 0x03 27 + #define TSC1641_CURRENT 0x04 28 + #define TSC1641_TEMP 0x05 29 + #define TSC1641_MASK 0x06 30 + #define TSC1641_FLAG 0x07 31 + #define TSC1641_RSHUNT 0x08 /* Shunt resistance */ 32 + #define TSC1641_SOL 0x09 33 + #define TSC1641_SUL 0x0A 34 + #define TSC1641_LOL 0x0B 35 + #define TSC1641_LUL 0x0C 36 + #define TSC1641_POL 0x0D 37 + #define TSC1641_TOL 0x0E 38 + #define TSC1641_MANUF_ID 0xFE /* 0x0006 */ 39 + #define TSC1641_DIE_ID 0xFF /* 0x1000 */ 40 + #define TSC1641_MAX_REG 0xFF 41 + 42 + #define TSC1641_RSHUNT_DEFAULT 1000 /* 1mOhm */ 43 + #define TSC1641_CONFIG_DEFAULT 0x003F /* Default mode and temperature sensor */ 44 + #define TSC1641_MASK_DEFAULT 0xFC00 /* Unmask all alerts */ 45 + 46 + /* Bit mask for conversion time in the configuration register */ 47 + #define TSC1641_CONV_TIME_MASK GENMASK(7, 4) 48 + 49 + #define TSC1641_CONV_TIME_DEFAULT 1024 50 + #define TSC1641_MIN_UPDATE_INTERVAL 1024 51 + 52 + /* LSB value of different registers */ 53 + #define TSC1641_VLOAD_LSB_MVOLT 2 54 + #define TSC1641_POWER_LSB_UWATT 25000 55 + #define TSC1641_VSHUNT_LSB_NVOLT 2500 /* Use nanovolts to make it integer */ 56 + #define TSC1641_RSHUNT_LSB_UOHM 10 57 + #define TSC1641_TEMP_LSB_MDEGC 500 58 + 59 + /* Limits based on datasheet */ 60 + #define TSC1641_RSHUNT_MIN_UOHM 100 61 + #define TSC1641_RSHUNT_MAX_UOHM 655350 62 + #define TSC1641_CURR_ABS_MAX_MAMP 819200 /* Max current at 100uOhm*/ 63 + 64 + #define TSC1641_ALERT_POL_MASK BIT(1) 65 + #define TSC1641_ALERT_LATCH_EN_MASK BIT(0) 66 + 67 + /* Flags indicating alerts in TSC1641_FLAG register*/ 68 + #define TSC1641_SAT_FLAG BIT(13) 69 + #define TSC1641_SHUNT_OV_FLAG BIT(6) 70 + #define TSC1641_SHUNT_UV_FLAG BIT(5) 71 + #define TSC1641_LOAD_OV_FLAG BIT(4) 72 + #define TSC1641_LOAD_UV_FLAG BIT(3) 73 + #define TSC1641_POWER_OVER_FLAG BIT(2) 74 + #define TSC1641_TEMP_OVER_FLAG BIT(1) 75 + 76 + static bool tsc1641_writeable_reg(struct device *dev, unsigned int reg) 77 + { 78 + switch (reg) { 79 + case TSC1641_CONFIG: 80 + case TSC1641_MASK: 81 + case TSC1641_RSHUNT: 82 + case TSC1641_SOL: 83 + case TSC1641_SUL: 84 + case TSC1641_LOL: 85 + case TSC1641_LUL: 86 + case TSC1641_POL: 87 + case TSC1641_TOL: 88 + return true; 89 + default: 90 + return false; 91 + } 92 + } 93 + 94 + static bool tsc1641_volatile_reg(struct device *dev, unsigned int reg) 95 + { 96 + switch (reg) { 97 + case TSC1641_SHUNT_VOLTAGE: 98 + case TSC1641_LOAD_VOLTAGE: 99 + case TSC1641_POWER: 100 + case TSC1641_CURRENT: 101 + case TSC1641_TEMP: 102 + case TSC1641_FLAG: 103 + case TSC1641_MANUF_ID: 104 + case TSC1641_DIE_ID: 105 + return true; 106 + default: 107 + return false; 108 + } 109 + } 110 + 111 + static const struct regmap_config tsc1641_regmap_config = { 112 + .reg_bits = 8, 113 + .val_bits = 16, 114 + .use_single_write = true, 115 + .use_single_read = true, 116 + .max_register = TSC1641_MAX_REG, 117 + .cache_type = REGCACHE_MAPLE, 118 + .volatile_reg = tsc1641_volatile_reg, 119 + .writeable_reg = tsc1641_writeable_reg, 120 + }; 121 + 122 + struct tsc1641_data { 123 + long rshunt_uohm; 124 + long current_lsb_ua; 125 + struct regmap *regmap; 126 + }; 127 + 128 + /* 129 + * Upper limit due to chip 16-bit shunt register, lower limit to 130 + * prevent current and power registers overflow 131 + */ 132 + static inline int tsc1641_validate_shunt(u32 val) 133 + { 134 + if (val < TSC1641_RSHUNT_MIN_UOHM || val > TSC1641_RSHUNT_MAX_UOHM) 135 + return -EINVAL; 136 + return 0; 137 + } 138 + 139 + static int tsc1641_set_shunt(struct tsc1641_data *data, u32 val) 140 + { 141 + struct regmap *regmap = data->regmap; 142 + long rshunt_reg; 143 + 144 + /* RSHUNT register LSB is 10uOhm so need to divide further */ 145 + rshunt_reg = DIV_ROUND_CLOSEST(val, TSC1641_RSHUNT_LSB_UOHM); 146 + /* 147 + * Clamp value to the nearest multiple of TSC1641_RSHUNT_LSB_UOHM 148 + * in case shunt value provided was not a multiple 149 + */ 150 + data->rshunt_uohm = rshunt_reg * TSC1641_RSHUNT_LSB_UOHM; 151 + data->current_lsb_ua = DIV_ROUND_CLOSEST(TSC1641_VSHUNT_LSB_NVOLT * 1000, 152 + data->rshunt_uohm); 153 + 154 + return regmap_write(regmap, TSC1641_RSHUNT, rshunt_reg); 155 + } 156 + 157 + /* 158 + * Conversion times in uS, value in CONFIG[CT3:CT0] corresponds to index in this array 159 + * See "Table 14. CT3 to CT0: conversion time" in: 160 + * https://www.st.com/resource/en/datasheet/tsc1641.pdf 161 + */ 162 + static const int tsc1641_conv_times[] = { 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 }; 163 + 164 + static int tsc1641_reg_to_upd_interval(u16 config) 165 + { 166 + int idx = FIELD_GET(TSC1641_CONV_TIME_MASK, config); 167 + 168 + idx = clamp_val(idx, 0, ARRAY_SIZE(tsc1641_conv_times) - 1); 169 + int conv_time = tsc1641_conv_times[idx]; 170 + 171 + /* Don't support sub-millisecond update interval as it's not supported in hwmon */ 172 + conv_time = max(conv_time, TSC1641_MIN_UPDATE_INTERVAL); 173 + /* Return nearest value in milliseconds */ 174 + return DIV_ROUND_CLOSEST(conv_time, 1000); 175 + } 176 + 177 + static u16 tsc1641_upd_interval_to_reg(long interval) 178 + { 179 + /* Supported interval is 1ms - 33ms */ 180 + interval = clamp_val(interval, 1, 33); 181 + 182 + int conv = interval * 1000; 183 + int conv_bits = find_closest(conv, tsc1641_conv_times, 184 + ARRAY_SIZE(tsc1641_conv_times)); 185 + 186 + return FIELD_PREP(TSC1641_CONV_TIME_MASK, conv_bits); 187 + } 188 + 189 + static int tsc1641_chip_write(struct device *dev, u32 attr, long val) 190 + { 191 + struct tsc1641_data *data = dev_get_drvdata(dev); 192 + 193 + switch (attr) { 194 + case hwmon_chip_update_interval: 195 + return regmap_update_bits(data->regmap, TSC1641_CONFIG, 196 + TSC1641_CONV_TIME_MASK, 197 + tsc1641_upd_interval_to_reg(val)); 198 + default: 199 + return -EOPNOTSUPP; 200 + } 201 + } 202 + 203 + static int tsc1641_chip_read(struct device *dev, u32 attr, long *val) 204 + { 205 + struct tsc1641_data *data = dev_get_drvdata(dev); 206 + u32 regval; 207 + int ret; 208 + 209 + switch (attr) { 210 + case hwmon_chip_update_interval: 211 + ret = regmap_read(data->regmap, TSC1641_CONFIG, &regval); 212 + if (ret) 213 + return ret; 214 + 215 + *val = tsc1641_reg_to_upd_interval(regval); 216 + return 0; 217 + default: 218 + return -EOPNOTSUPP; 219 + } 220 + } 221 + 222 + static int tsc1641_flag_read(struct regmap *regmap, u32 flag, long *val) 223 + { 224 + unsigned int regval; 225 + int ret; 226 + 227 + ret = regmap_read_bypassed(regmap, TSC1641_FLAG, &regval); 228 + if (ret) 229 + return ret; 230 + 231 + *val = !!(regval & flag); 232 + return 0; 233 + } 234 + 235 + static int tsc1641_in_read(struct device *dev, u32 attr, long *val) 236 + { 237 + struct tsc1641_data *data = dev_get_drvdata(dev); 238 + struct regmap *regmap = data->regmap; 239 + unsigned int regval; 240 + int ret, reg; 241 + long sat_flag; 242 + 243 + switch (attr) { 244 + case hwmon_in_input: 245 + reg = TSC1641_LOAD_VOLTAGE; 246 + break; 247 + case hwmon_in_min: 248 + reg = TSC1641_LUL; 249 + break; 250 + case hwmon_in_max: 251 + reg = TSC1641_LOL; 252 + break; 253 + case hwmon_in_min_alarm: 254 + return tsc1641_flag_read(regmap, TSC1641_LOAD_UV_FLAG, val); 255 + case hwmon_in_max_alarm: 256 + return tsc1641_flag_read(regmap, TSC1641_LOAD_OV_FLAG, val); 257 + default: 258 + return -EOPNOTSUPP; 259 + } 260 + 261 + ret = regmap_read(regmap, reg, &regval); 262 + if (ret) 263 + return ret; 264 + 265 + /* Check if load voltage is out of range */ 266 + if (reg == TSC1641_LOAD_VOLTAGE) { 267 + /* Register is 15-bit max */ 268 + if (regval & 0x8000) 269 + return -ENODATA; 270 + 271 + ret = tsc1641_flag_read(regmap, TSC1641_SAT_FLAG, &sat_flag); 272 + if (ret) 273 + return ret; 274 + /* Out of range conditions per datasheet */ 275 + if (sat_flag && (regval == 0x7FFF || !regval)) 276 + return -ENODATA; 277 + } 278 + 279 + *val = regval * TSC1641_VLOAD_LSB_MVOLT; 280 + return 0; 281 + } 282 + 283 + /* Chip supports bidirectional (positive or negative) current */ 284 + static int tsc1641_curr_read(struct device *dev, u32 attr, long *val) 285 + { 286 + struct tsc1641_data *data = dev_get_drvdata(dev); 287 + struct regmap *regmap = data->regmap; 288 + int regval; 289 + int ret, reg; 290 + long sat_flag; 291 + 292 + /* Current limits are the shunt under/over voltage limits */ 293 + switch (attr) { 294 + case hwmon_curr_input: 295 + reg = TSC1641_CURRENT; 296 + break; 297 + case hwmon_curr_min: 298 + reg = TSC1641_SUL; 299 + break; 300 + case hwmon_curr_max: 301 + reg = TSC1641_SOL; 302 + break; 303 + case hwmon_curr_min_alarm: 304 + return tsc1641_flag_read(regmap, TSC1641_SHUNT_UV_FLAG, val); 305 + case hwmon_curr_max_alarm: 306 + return tsc1641_flag_read(regmap, TSC1641_SHUNT_OV_FLAG, val); 307 + default: 308 + return -EOPNOTSUPP; 309 + } 310 + /* 311 + * Current uses shunt voltage, so check if it's out of range. 312 + * We report current register in sysfs to stay consistent with internal 313 + * power calculations which use current register values 314 + */ 315 + if (reg == TSC1641_CURRENT) { 316 + ret = regmap_read(regmap, TSC1641_SHUNT_VOLTAGE, &regval); 317 + if (ret) 318 + return ret; 319 + 320 + ret = tsc1641_flag_read(regmap, TSC1641_SAT_FLAG, &sat_flag); 321 + if (ret) 322 + return ret; 323 + 324 + if (sat_flag && (regval == 0x7FFF || regval == 0x8000)) 325 + return -ENODATA; 326 + } 327 + 328 + ret = regmap_read(regmap, reg, &regval); 329 + if (ret) 330 + return ret; 331 + 332 + /* Current in milliamps, signed */ 333 + *val = DIV_ROUND_CLOSEST((s16)regval * data->current_lsb_ua, 1000); 334 + return 0; 335 + } 336 + 337 + static int tsc1641_power_read(struct device *dev, u32 attr, long *val) 338 + { 339 + struct tsc1641_data *data = dev_get_drvdata(dev); 340 + struct regmap *regmap = data->regmap; 341 + unsigned int regval; 342 + int ret, reg; 343 + 344 + switch (attr) { 345 + case hwmon_power_input: 346 + reg = TSC1641_POWER; 347 + break; 348 + case hwmon_power_max: 349 + reg = TSC1641_POL; 350 + break; 351 + case hwmon_power_max_alarm: 352 + return tsc1641_flag_read(regmap, TSC1641_POWER_OVER_FLAG, val); 353 + default: 354 + return -EOPNOTSUPP; 355 + } 356 + 357 + ret = regmap_read(regmap, reg, &regval); 358 + if (ret) 359 + return ret; 360 + 361 + *val = regval * TSC1641_POWER_LSB_UWATT; 362 + return 0; 363 + } 364 + 365 + static int tsc1641_temp_read(struct device *dev, u32 attr, long *val) 366 + { 367 + struct tsc1641_data *data = dev_get_drvdata(dev); 368 + struct regmap *regmap = data->regmap; 369 + unsigned int regval; 370 + int ret, reg; 371 + 372 + switch (attr) { 373 + case hwmon_temp_input: 374 + reg = TSC1641_TEMP; 375 + break; 376 + case hwmon_temp_max: 377 + reg = TSC1641_TOL; 378 + break; 379 + case hwmon_temp_max_alarm: 380 + return tsc1641_flag_read(regmap, TSC1641_TEMP_OVER_FLAG, val); 381 + default: 382 + return -EOPNOTSUPP; 383 + } 384 + 385 + ret = regmap_read(regmap, reg, &regval); 386 + if (ret) 387 + return ret; 388 + 389 + /* 0x8000 means that TEMP measurement not enabled */ 390 + if (reg == TSC1641_TEMP && regval == 0x8000) 391 + return -ENODATA; 392 + 393 + /* Both temperature and limit registers are signed */ 394 + *val = (s16)regval * TSC1641_TEMP_LSB_MDEGC; 395 + return 0; 396 + } 397 + 398 + static int tsc1641_in_write(struct device *dev, u32 attr, long val) 399 + { 400 + struct tsc1641_data *data = dev_get_drvdata(dev); 401 + struct regmap *regmap = data->regmap; 402 + unsigned int regval; 403 + int reg; 404 + 405 + switch (attr) { 406 + case hwmon_in_min: 407 + reg = TSC1641_LUL; 408 + break; 409 + case hwmon_in_max: 410 + reg = TSC1641_LOL; 411 + break; 412 + default: 413 + return -EOPNOTSUPP; 414 + } 415 + /* Clamp to full register range */ 416 + val = clamp_val(val, 0, TSC1641_VLOAD_LSB_MVOLT * USHRT_MAX); 417 + regval = DIV_ROUND_CLOSEST(val, TSC1641_VLOAD_LSB_MVOLT); 418 + 419 + return regmap_write(regmap, reg, regval); 420 + } 421 + 422 + static int tsc1641_curr_write(struct device *dev, u32 attr, long val) 423 + { 424 + struct tsc1641_data *data = dev_get_drvdata(dev); 425 + struct regmap *regmap = data->regmap; 426 + int reg, regval; 427 + 428 + switch (attr) { 429 + case hwmon_curr_min: 430 + reg = TSC1641_SUL; 431 + break; 432 + case hwmon_curr_max: 433 + reg = TSC1641_SOL; 434 + break; 435 + default: 436 + return -EOPNOTSUPP; 437 + } 438 + 439 + /* Clamp to prevent over/underflow below */ 440 + val = clamp_val(val, -TSC1641_CURR_ABS_MAX_MAMP, TSC1641_CURR_ABS_MAX_MAMP); 441 + /* Convert val in milliamps to register */ 442 + regval = DIV_ROUND_CLOSEST(val * 1000, data->current_lsb_ua); 443 + /* 444 + * Prevent signed 16-bit overflow. 445 + * Integer arithmetic and shunt scaling can quantize values near 0x7FFF/0x8000, 446 + * so reading and writing back may not preserve the exact original register value. 447 + */ 448 + regval = clamp_val(regval, SHRT_MIN, SHRT_MAX); 449 + /* SUL and SOL registers are signed */ 450 + return regmap_write(regmap, reg, regval & 0xFFFF); 451 + } 452 + 453 + static int tsc1641_power_write(struct device *dev, u32 attr, long val) 454 + { 455 + struct tsc1641_data *data = dev_get_drvdata(dev); 456 + struct regmap *regmap = data->regmap; 457 + unsigned int regval; 458 + 459 + switch (attr) { 460 + case hwmon_power_max: 461 + /* Clamp to full register range */ 462 + val = clamp_val(val, 0, TSC1641_POWER_LSB_UWATT * USHRT_MAX); 463 + regval = DIV_ROUND_CLOSEST(val, TSC1641_POWER_LSB_UWATT); 464 + return regmap_write(regmap, TSC1641_POL, regval); 465 + default: 466 + return -EOPNOTSUPP; 467 + } 468 + } 469 + 470 + static int tsc1641_temp_write(struct device *dev, u32 attr, long val) 471 + { 472 + struct tsc1641_data *data = dev_get_drvdata(dev); 473 + struct regmap *regmap = data->regmap; 474 + int regval; 475 + 476 + switch (attr) { 477 + case hwmon_temp_max: 478 + /* Clamp to full register range */ 479 + val = clamp_val(val, TSC1641_TEMP_LSB_MDEGC * SHRT_MIN, 480 + TSC1641_TEMP_LSB_MDEGC * SHRT_MAX); 481 + regval = DIV_ROUND_CLOSEST(val, TSC1641_TEMP_LSB_MDEGC); 482 + /* TOL register is signed */ 483 + return regmap_write(regmap, TSC1641_TOL, regval & 0xFFFF); 484 + default: 485 + return -EOPNOTSUPP; 486 + } 487 + } 488 + 489 + static umode_t tsc1641_is_visible(const void *data, enum hwmon_sensor_types type, 490 + u32 attr, int channel) 491 + { 492 + switch (type) { 493 + case hwmon_chip: 494 + switch (attr) { 495 + case hwmon_chip_update_interval: 496 + return 0644; 497 + default: 498 + break; 499 + } 500 + break; 501 + case hwmon_in: 502 + switch (attr) { 503 + case hwmon_in_input: 504 + return 0444; 505 + case hwmon_in_min: 506 + case hwmon_in_max: 507 + return 0644; 508 + case hwmon_in_min_alarm: 509 + case hwmon_in_max_alarm: 510 + return 0444; 511 + default: 512 + break; 513 + } 514 + break; 515 + case hwmon_curr: 516 + switch (attr) { 517 + case hwmon_curr_input: 518 + return 0444; 519 + case hwmon_curr_min: 520 + case hwmon_curr_max: 521 + return 0644; 522 + case hwmon_curr_min_alarm: 523 + case hwmon_curr_max_alarm: 524 + return 0444; 525 + default: 526 + break; 527 + } 528 + break; 529 + case hwmon_power: 530 + switch (attr) { 531 + case hwmon_power_input: 532 + return 0444; 533 + case hwmon_power_max: 534 + return 0644; 535 + case hwmon_power_max_alarm: 536 + return 0444; 537 + default: 538 + break; 539 + } 540 + break; 541 + case hwmon_temp: 542 + switch (attr) { 543 + case hwmon_temp_input: 544 + return 0444; 545 + case hwmon_temp_max: 546 + return 0644; 547 + case hwmon_temp_max_alarm: 548 + return 0444; 549 + default: 550 + break; 551 + } 552 + break; 553 + default: 554 + break; 555 + } 556 + return 0; 557 + } 558 + 559 + static int tsc1641_read(struct device *dev, enum hwmon_sensor_types type, 560 + u32 attr, int channel, long *val) 561 + { 562 + switch (type) { 563 + case hwmon_chip: 564 + return tsc1641_chip_read(dev, attr, val); 565 + case hwmon_in: 566 + return tsc1641_in_read(dev, attr, val); 567 + case hwmon_curr: 568 + return tsc1641_curr_read(dev, attr, val); 569 + case hwmon_power: 570 + return tsc1641_power_read(dev, attr, val); 571 + case hwmon_temp: 572 + return tsc1641_temp_read(dev, attr, val); 573 + default: 574 + return -EOPNOTSUPP; 575 + } 576 + } 577 + 578 + static int tsc1641_write(struct device *dev, enum hwmon_sensor_types type, 579 + u32 attr, int channel, long val) 580 + { 581 + switch (type) { 582 + case hwmon_chip: 583 + return tsc1641_chip_write(dev, attr, val); 584 + case hwmon_in: 585 + return tsc1641_in_write(dev, attr, val); 586 + case hwmon_curr: 587 + return tsc1641_curr_write(dev, attr, val); 588 + case hwmon_power: 589 + return tsc1641_power_write(dev, attr, val); 590 + case hwmon_temp: 591 + return tsc1641_temp_write(dev, attr, val); 592 + default: 593 + return -EOPNOTSUPP; 594 + } 595 + } 596 + 597 + static const struct hwmon_channel_info * const tsc1641_info[] = { 598 + HWMON_CHANNEL_INFO(chip, 599 + HWMON_C_UPDATE_INTERVAL), 600 + HWMON_CHANNEL_INFO(in, 601 + HWMON_I_INPUT | HWMON_I_MAX | HWMON_I_MAX_ALARM | 602 + HWMON_I_MIN | HWMON_I_MIN_ALARM), 603 + HWMON_CHANNEL_INFO(curr, 604 + HWMON_C_INPUT | HWMON_C_MAX | HWMON_C_MAX_ALARM | 605 + HWMON_C_MIN | HWMON_C_MIN_ALARM), 606 + HWMON_CHANNEL_INFO(power, 607 + HWMON_P_INPUT | HWMON_P_MAX | HWMON_P_MAX_ALARM), 608 + HWMON_CHANNEL_INFO(temp, 609 + HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_ALARM), 610 + NULL 611 + }; 612 + 613 + static ssize_t shunt_resistor_show(struct device *dev, 614 + struct device_attribute *da, char *buf) 615 + { 616 + struct tsc1641_data *data = dev_get_drvdata(dev); 617 + 618 + return sysfs_emit(buf, "%li\n", data->rshunt_uohm); 619 + } 620 + 621 + static ssize_t shunt_resistor_store(struct device *dev, 622 + struct device_attribute *da, 623 + const char *buf, size_t count) 624 + { 625 + struct tsc1641_data *data = dev_get_drvdata(dev); 626 + unsigned int val; 627 + int ret; 628 + 629 + ret = kstrtouint(buf, 10, &val); 630 + if (ret < 0) 631 + return ret; 632 + 633 + ret = tsc1641_validate_shunt(val); 634 + if (ret < 0) 635 + return ret; 636 + 637 + ret = tsc1641_set_shunt(data, val); 638 + if (ret < 0) 639 + return ret; 640 + return count; 641 + } 642 + 643 + static const struct hwmon_ops tsc1641_hwmon_ops = { 644 + .is_visible = tsc1641_is_visible, 645 + .read = tsc1641_read, 646 + .write = tsc1641_write, 647 + }; 648 + 649 + static const struct hwmon_chip_info tsc1641_chip_info = { 650 + .ops = &tsc1641_hwmon_ops, 651 + .info = tsc1641_info, 652 + }; 653 + 654 + static DEVICE_ATTR_RW(shunt_resistor); 655 + 656 + /* Shunt resistor value is exposed via sysfs attribute */ 657 + static struct attribute *tsc1641_attrs[] = { 658 + &dev_attr_shunt_resistor.attr, 659 + NULL, 660 + }; 661 + ATTRIBUTE_GROUPS(tsc1641); 662 + 663 + static int tsc1641_init(struct device *dev, struct tsc1641_data *data) 664 + { 665 + struct regmap *regmap = data->regmap; 666 + bool active_high; 667 + u32 shunt; 668 + int ret; 669 + 670 + if (device_property_read_u32(dev, "shunt-resistor-micro-ohms", &shunt) < 0) 671 + shunt = TSC1641_RSHUNT_DEFAULT; 672 + 673 + if (tsc1641_validate_shunt(shunt) < 0) { 674 + dev_err(dev, "invalid shunt resistor value %u\n", shunt); 675 + return -EINVAL; 676 + } 677 + 678 + ret = tsc1641_set_shunt(data, shunt); 679 + if (ret < 0) 680 + return ret; 681 + 682 + ret = regmap_write(regmap, TSC1641_CONFIG, TSC1641_CONFIG_DEFAULT); 683 + if (ret < 0) 684 + return ret; 685 + 686 + active_high = device_property_read_bool(dev, "st,alert-polarity-active-high"); 687 + 688 + return regmap_write(regmap, TSC1641_MASK, TSC1641_MASK_DEFAULT | 689 + FIELD_PREP(TSC1641_ALERT_POL_MASK, active_high)); 690 + } 691 + 692 + static int tsc1641_probe(struct i2c_client *client) 693 + { 694 + struct device *dev = &client->dev; 695 + struct tsc1641_data *data; 696 + struct device *hwmon_dev; 697 + int ret; 698 + 699 + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 700 + if (!data) 701 + return -ENOMEM; 702 + 703 + data->regmap = devm_regmap_init_i2c(client, &tsc1641_regmap_config); 704 + if (IS_ERR(data->regmap)) 705 + return dev_err_probe(dev, PTR_ERR(data->regmap), 706 + "failed to allocate register map\n"); 707 + 708 + ret = tsc1641_init(dev, data); 709 + if (ret < 0) 710 + return dev_err_probe(dev, ret, "failed to configure device\n"); 711 + 712 + hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, 713 + data, &tsc1641_chip_info, tsc1641_groups); 714 + if (IS_ERR(hwmon_dev)) 715 + return PTR_ERR(hwmon_dev); 716 + 717 + dev_info(dev, "power monitor %s (Rshunt = %li uOhm)\n", 718 + client->name, data->rshunt_uohm); 719 + 720 + return 0; 721 + } 722 + 723 + static const struct i2c_device_id tsc1641_id[] = { 724 + { "tsc1641", 0 }, 725 + { } 726 + }; 727 + MODULE_DEVICE_TABLE(i2c, tsc1641_id); 728 + 729 + static const struct of_device_id __maybe_unused tsc1641_of_match[] = { 730 + { .compatible = "st,tsc1641" }, 731 + { }, 732 + }; 733 + MODULE_DEVICE_TABLE(of, tsc1641_of_match); 734 + 735 + static struct i2c_driver tsc1641_driver = { 736 + .driver = { 737 + .name = "tsc1641", 738 + .of_match_table = of_match_ptr(tsc1641_of_match), 739 + }, 740 + .probe = tsc1641_probe, 741 + .id_table = tsc1641_id, 742 + }; 743 + 744 + module_i2c_driver(tsc1641_driver); 745 + 746 + MODULE_AUTHOR("Igor Reznichenko <igor@reznichenko.net>"); 747 + MODULE_DESCRIPTION("tsc1641 driver"); 748 + MODULE_LICENSE("GPL");
+35 -18
drivers/hwmon/vt1211.c
··· 142 142 * in5 (ix = 5) is special. It's the internal 3.3V so it's scaled in the 143 143 * driver according to the VT1211 BIOS porting guide 144 144 */ 145 - #define IN_FROM_REG(ix, reg) ((reg) < 3 ? 0 : (ix) == 5 ? \ 146 - (((reg) - 3) * 15882 + 479) / 958 : \ 147 - (((reg) - 3) * 10000 + 479) / 958) 145 + static int in_from_reg(int ix, int reg) 146 + { 147 + if (reg < 3) 148 + return 0; 149 + if (ix == 5) 150 + return ((reg - 3) * 15882 + 479) / 958; 151 + return ((reg - 3) * 10000 + 479) / 958; 152 + } 153 + 148 154 #define IN_TO_REG(ix, val) (clamp_val((ix) == 5 ? \ 149 155 ((val) * 958 + 7941) / 15882 + 3 : \ 150 156 ((val) * 958 + 5000) / 10000 + 3, 0, 255)) ··· 162 156 * temp3-7 are thermistor based so the driver returns the voltage measured at 163 157 * the pin (range 0V - 2.2V). 164 158 */ 165 - #define TEMP_FROM_REG(ix, reg) ((ix) == 0 ? (reg) * 1000 : \ 166 - (ix) == 1 ? (reg) < 51 ? 0 : \ 167 - ((reg) - 51) * 1000 : \ 168 - ((253 - (reg)) * 2200 + 105) / 210) 159 + static int temp_from_reg(int ix, int reg) 160 + { 161 + if (ix == 0) 162 + return reg * 1000; 163 + if (ix == 1) 164 + return reg < 51 ? 0 : (reg - 51) * 1000; 165 + return ((253 - reg) * 2200 + 105) / 210; 166 + } 167 + 169 168 #define TEMP_TO_REG(ix, val) clamp_val( \ 170 169 ((ix) == 0 ? ((val) + 500) / 1000 : \ 171 170 (ix) == 1 ? ((val) + 500) / 1000 + 51 : \ ··· 178 167 179 168 #define DIV_FROM_REG(reg) (1 << (reg)) 180 169 181 - #define RPM_FROM_REG(reg, div) (((reg) == 0) || ((reg) == 255) ? 0 : \ 182 - 1310720 / (reg) / DIV_FROM_REG(div)) 170 + static int rpm_from_reg(int reg, int div) 171 + { 172 + if (reg == 0 || reg == 255) 173 + return 0; 174 + 175 + return 1310720 / reg / DIV_FROM_REG(div); 176 + } 177 + 183 178 #define RPM_TO_REG(val, div) ((val) == 0 ? 255 : \ 184 179 clamp_val((1310720 / (val) / \ 185 180 DIV_FROM_REG(div)), 1, 254)) ··· 360 343 361 344 switch (fn) { 362 345 case SHOW_IN_INPUT: 363 - res = IN_FROM_REG(ix, data->in[ix]); 346 + res = in_from_reg(ix, data->in[ix]); 364 347 break; 365 348 case SHOW_SET_IN_MIN: 366 - res = IN_FROM_REG(ix, data->in_min[ix]); 349 + res = in_from_reg(ix, data->in_min[ix]); 367 350 break; 368 351 case SHOW_SET_IN_MAX: 369 - res = IN_FROM_REG(ix, data->in_max[ix]); 352 + res = in_from_reg(ix, data->in_max[ix]); 370 353 break; 371 354 case SHOW_IN_ALARM: 372 355 res = (data->alarms >> bitalarmin[ix]) & 1; ··· 434 417 435 418 switch (fn) { 436 419 case SHOW_TEMP_INPUT: 437 - res = TEMP_FROM_REG(ix, data->temp[ix]); 420 + res = temp_from_reg(ix, data->temp[ix]); 438 421 break; 439 422 case SHOW_SET_TEMP_MAX: 440 - res = TEMP_FROM_REG(ix, data->temp_max[ix]); 423 + res = temp_from_reg(ix, data->temp_max[ix]); 441 424 break; 442 425 case SHOW_SET_TEMP_MAX_HYST: 443 - res = TEMP_FROM_REG(ix, data->temp_hyst[ix]); 426 + res = temp_from_reg(ix, data->temp_hyst[ix]); 444 427 break; 445 428 case SHOW_TEMP_ALARM: 446 429 res = (data->alarms >> bitalarmtemp[ix]) & 1; ··· 510 493 511 494 switch (fn) { 512 495 case SHOW_FAN_INPUT: 513 - res = RPM_FROM_REG(data->fan[ix], data->fan_div[ix]); 496 + res = rpm_from_reg(data->fan[ix], data->fan_div[ix]); 514 497 break; 515 498 case SHOW_SET_FAN_MIN: 516 - res = RPM_FROM_REG(data->fan_min[ix], data->fan_div[ix]); 499 + res = rpm_from_reg(data->fan_min[ix], data->fan_div[ix]); 517 500 break; 518 501 case SHOW_SET_FAN_DIV: 519 502 res = DIV_FROM_REG(data->fan_div[ix]); ··· 768 751 int ix = sensor_attr_2->index; 769 752 int ap = sensor_attr_2->nr; 770 753 771 - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->pwm_ctl[ix] & 7, 754 + return sprintf(buf, "%d\n", temp_from_reg(data->pwm_ctl[ix] & 7, 772 755 data->pwm_auto_temp[ap])); 773 756 } 774 757
+12 -6
drivers/hwmon/vt8231.c
··· 138 138 return clamp_val(1310720 / (rpm * div), 1, 255); 139 139 } 140 140 141 - #define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : 1310720 / ((val) * (div))) 141 + static int fan_from_reg(int val, int div) 142 + { 143 + if (val == 0) 144 + return 0; 145 + return 1310720 / (val * div); 146 + } 142 147 143 148 struct vt8231_data { 144 149 unsigned short addr; ··· 566 561 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 567 562 int nr = sensor_attr->index; 568 563 struct vt8231_data *data = vt8231_update_device(dev); 569 - return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], 564 + return sprintf(buf, "%d\n", fan_from_reg(data->fan[nr], 570 565 DIV_FROM_REG(data->fan_div[nr]))); 571 566 } 572 567 ··· 576 571 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 577 572 int nr = sensor_attr->index; 578 573 struct vt8231_data *data = vt8231_update_device(dev); 579 - return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], 574 + return sprintf(buf, "%d\n", fan_from_reg(data->fan_min[nr], 580 575 DIV_FROM_REG(data->fan_div[nr]))); 581 576 } 582 577 ··· 618 613 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 619 614 unsigned long val; 620 615 int nr = sensor_attr->index; 621 - int old = vt8231_read_value(data, VT8231_REG_FANDIV); 622 - long min = FAN_FROM_REG(data->fan_min[nr], 623 - DIV_FROM_REG(data->fan_div[nr])); 616 + int old; 617 + long min; 624 618 int err; 625 619 626 620 err = kstrtoul(buf, 10, &val); ··· 627 623 return err; 628 624 629 625 mutex_lock(&data->update_lock); 626 + old = vt8231_read_value(data, VT8231_REG_FANDIV); 627 + min = fan_from_reg(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])); 630 628 switch (val) { 631 629 case 1: 632 630 data->fan_div[nr] = 0;
+3 -2
drivers/hwmon/w83781d.c
··· 1850 1850 } 1851 1851 } 1852 1852 1853 - #define REALLY_SLOW_IO 1854 1853 /* 1855 1854 * We need the timeouts for at least some W83781D-like 1856 1855 * chips. But only if we read 'undefined' registers. 1856 + * There used to be a "#define REALLY_SLOW_IO" to enforce that, but 1857 + * this has been without any effect since more than a decade, so it 1858 + * has been dropped. 1857 1859 */ 1858 1860 val = inb_p(address + 1); 1859 1861 if (inb_p(address + 2) != val ··· 1864 1862 pr_debug("Detection failed at step %d\n", 1); 1865 1863 goto release; 1866 1864 } 1867 - #undef REALLY_SLOW_IO 1868 1865 1869 1866 /* 1870 1867 * We should be able to change the 7 LSB of the address port. The
+18 -8
drivers/hwmon/w83l786ng.c
··· 76 76 return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254); 77 77 } 78 78 79 - #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : \ 80 - ((val) == 255 ? 0 : \ 81 - 1350000 / ((val) * (div)))) 79 + static int fan_from_reg(int val, int div) 80 + { 81 + if (val == 0) 82 + return -1; 83 + if (val == 255) 84 + return 0; 85 + return 1350000 / (val * div); 86 + } 82 87 83 88 /* for temp */ 84 89 #define TEMP_TO_REG(val) (clamp_val(((val) < 0 ? (val) + 0x100 * 1000 \ 85 90 : (val)) / 1000, 0, 0xff)) 86 - #define TEMP_FROM_REG(val) (((val) & 0x80 ? \ 87 - (val) - 0x100 : (val)) * 1000) 91 + 92 + static int temp_from_reg(int val) 93 + { 94 + if (val & 0x80) 95 + return (val - 0x100) * 1000; 96 + return val * 1000; 97 + } 88 98 89 99 /* 90 100 * The analog voltage inputs have 8mV LSB. Since the sysfs output is ··· 290 280 int nr = to_sensor_dev_attr(attr)->index; \ 291 281 struct w83l786ng_data *data = w83l786ng_update_device(dev); \ 292 282 return sprintf(buf, "%d\n", \ 293 - FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \ 283 + fan_from_reg(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \ 294 284 } 295 285 296 286 show_fan_reg(fan); ··· 357 347 358 348 /* Save fan_min */ 359 349 mutex_lock(&data->update_lock); 360 - min = FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])); 350 + min = fan_from_reg(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])); 361 351 362 352 data->fan_div[nr] = DIV_TO_REG(val); 363 353 ··· 419 409 int nr = sensor_attr->nr; 420 410 int index = sensor_attr->index; 421 411 struct w83l786ng_data *data = w83l786ng_update_device(dev); 422 - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr][index])); 412 + return sprintf(buf, "%d\n", temp_from_reg(data->temp[nr][index])); 423 413 } 424 414 425 415 static ssize_t
+4
drivers/peci/cpu.c
··· 321 321 .x86_vfm = INTEL_SAPPHIRERAPIDS_X, 322 322 .data = "spr", 323 323 }, 324 + { /* Emerald Rapids Xeon */ 325 + .x86_vfm = INTEL_EMERALDRAPIDS_X, 326 + .data = "emr", 327 + }, 324 328 { } 325 329 }; 326 330 MODULE_DEVICE_TABLE(peci, peci_cpu_device_ids);
+1
include/linux/mfd/macsmc.h
··· 41 41 */ 42 42 #define SMC_KEY(s) (smc_key)(_SMC_KEY(#s)) 43 43 #define _SMC_KEY(s) (((s)[0] << 24) | ((s)[1] << 16) | ((s)[2] << 8) | (s)[3]) 44 + #define __SMC_KEY(a, b, c, d) (((u32)(a) << 24) | ((u32)(b) << 16) | ((u32)(c) << 8) | ((u32)(d))) 44 45 45 46 #define APPLE_SMC_READABLE BIT(7) 46 47 #define APPLE_SMC_WRITABLE BIT(6)