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

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

Pull hwmon updates from Guenter Roeck:
"New drivers:

- Driver for LTC2991

- Driver for POWER-Z

Added chip / system support to existing drivers:

- The ina238 driver now also supports INA237

- The asus-ec-sensors driver now supports ROG Crosshair X670E Gene

- The aquacomputer_d5next now supports Aquacomputer High Flow USB and
MPS Flow

- The pmbus/mpq7932 driver now also supports MPQ2286

- The nct6683 now also supports ASRock X670E Taichi

Various other minor improvements and fixes:

- One patch series to call out is the conversion of hwmon platform
drivers to use the platform remove callback returning void"

* tag 'hwmon-for-v6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (69 commits)
hwmon: (aquacomputer_d5next) Check if temp sensors of legacy devices are connected
hwmon: (aquacomputer_d5next) Add support for Aquacomputer High Flow USB and MPS Flow
dt-bindings: hwmon: npcm: Add npcm845 compatible string
hwmon: Add driver for ltc2991
dt-bindings: hwmon: ltc2991: add bindings
hwmon: (pmbus/max31785) Add delay between bus accesses
hwmon: (ina238) add ina237 support
dt-bindings: hwmon: ti,ina2xx: add ti,ina237
hwmon: (asus-ec-sensors) add ROG Crosshair X670E Gene.
hwmon: (max31827) handle vref regulator
hwmon: (ina3221) Add support for channel summation disable
dt-bindings: hwmon: ina3221: Add ti,summation-disable
dt-bindings: hwmon: ina3221: Convert to json-schema
hwmon: (pmbus/mpq7932) Add a support for mpq2286 Power Management IC
hwmon: (pmbus/core) Add helper macro to define single pmbus regulator
regulator: dt-bindings: Add mps,mpq2286 power-management IC
hwmon: (pmbus/mpq7932) Get page count based on chip info
dt-bindings: hwmon: Add possible new properties to max31827 bindings
hwmon: (max31827) Modify conversion wait time
hwmon: (max31827) Make code cleaner
...

+2292 -456
+128
Documentation/devicetree/bindings/hwmon/adi,ltc2991.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + 5 + $id: http://devicetree.org/schemas/hwmon/adi,ltc2991.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 + 8 + title: Analog Devices LTC2991 Octal I2C Voltage, Current and Temperature Monitor 9 + 10 + maintainers: 11 + - Antoniu Miclaus <antoniu.miclaus@analog.com> 12 + 13 + description: | 14 + The LTC2991 is used to monitor system temperatures, voltages and currents. 15 + Through the I2C serial interface, the eight monitors can individually measure 16 + supply voltages and can be paired for differential measurements of current 17 + sense resistors or temperature sensing transistors. 18 + 19 + Datasheet: 20 + https://www.analog.com/en/products/ltc2991.html 21 + 22 + properties: 23 + compatible: 24 + const: adi,ltc2991 25 + 26 + reg: 27 + maxItems: 1 28 + 29 + '#address-cells': 30 + const: 1 31 + 32 + '#size-cells': 33 + const: 0 34 + 35 + vcc-supply: true 36 + 37 + patternProperties: 38 + "^channel@[0-3]$": 39 + type: object 40 + description: 41 + Represents the differential/temperature channels. 42 + 43 + properties: 44 + reg: 45 + description: 46 + The channel number. LTC2991 can monitor 4 currents/temperatures. 47 + items: 48 + minimum: 0 49 + maximum: 3 50 + 51 + shunt-resistor-micro-ohms: 52 + description: 53 + The value of curent sense resistor in micro ohms. Pin configuration is 54 + set for differential input pair. 55 + 56 + adi,temperature-enable: 57 + description: 58 + Enables temperature readings. Pin configuration is set for remote 59 + diode temperature measurement. 60 + type: boolean 61 + 62 + required: 63 + - reg 64 + 65 + allOf: 66 + - if: 67 + required: 68 + - shunt-resistor-micro-ohms 69 + then: 70 + properties: 71 + adi,temperature-enable: false 72 + 73 + additionalProperties: false 74 + 75 + required: 76 + - compatible 77 + - reg 78 + - vcc-supply 79 + 80 + additionalProperties: false 81 + 82 + examples: 83 + - | 84 + i2c { 85 + #address-cells = <1>; 86 + #size-cells = <0>; 87 + 88 + hwmon@48 { 89 + compatible = "adi,ltc2991"; 90 + reg = <0x48>; 91 + vcc-supply = <&vcc>; 92 + }; 93 + }; 94 + - | 95 + i2c { 96 + #address-cells = <1>; 97 + #size-cells = <0>; 98 + 99 + hwmon@48 { 100 + #address-cells = <1>; 101 + #size-cells = <0>; 102 + 103 + compatible = "adi,ltc2991"; 104 + reg = <0x48>; 105 + vcc-supply = <&vcc>; 106 + 107 + channel@0 { 108 + reg = <0x0>; 109 + shunt-resistor-micro-ohms = <100000>; 110 + }; 111 + 112 + channel@1 { 113 + reg = <0x1>; 114 + shunt-resistor-micro-ohms = <100000>; 115 + }; 116 + 117 + channel@2 { 118 + reg = <0x2>; 119 + adi,temperature-enable; 120 + }; 121 + 122 + channel@3 { 123 + reg = <0x3>; 124 + adi,temperature-enable; 125 + }; 126 + }; 127 + }; 128 + ...
+66
Documentation/devicetree/bindings/hwmon/adi,max31827.yaml
··· 32 32 Must have values in the interval (1.6V; 3.6V) in order for the device to 33 33 function correctly. 34 34 35 + adi,comp-int: 36 + description: 37 + If present interrupt mode is used. If not present comparator mode is used 38 + (default). 39 + type: boolean 40 + 41 + adi,alarm-pol: 42 + description: 43 + Sets the alarms active state. 44 + - 0 = active low 45 + - 1 = active high 46 + $ref: /schemas/types.yaml#/definitions/uint32 47 + enum: [0, 1] 48 + 49 + adi,fault-q: 50 + description: 51 + Select how many consecutive temperature faults must occur before 52 + overtemperature or undertemperature faults are indicated in the 53 + corresponding status bits. 54 + $ref: /schemas/types.yaml#/definitions/uint32 55 + enum: [1, 2, 4, 8] 56 + 57 + adi,timeout-enable: 58 + description: 59 + Enables timeout. Bus timeout resets the I2C-compatible interface when SCL 60 + is low for more than 30ms (nominal). 61 + type: boolean 62 + 63 + allOf: 64 + - if: 65 + properties: 66 + compatible: 67 + contains: 68 + const: adi,max31829 69 + 70 + then: 71 + properties: 72 + adi,alarm-pol: 73 + default: 1 74 + 75 + else: 76 + properties: 77 + adi,alarm-pol: 78 + default: 0 79 + 80 + - if: 81 + properties: 82 + compatible: 83 + contains: 84 + const: adi,max31827 85 + 86 + then: 87 + properties: 88 + adi,fault-q: 89 + default: 1 90 + 91 + else: 92 + properties: 93 + adi,fault-q: 94 + default: 4 95 + 96 + 35 97 required: 36 98 - compatible 37 99 - reg ··· 111 49 compatible = "adi,max31827"; 112 50 reg = <0x42>; 113 51 vref-supply = <&reg_vdd>; 52 + adi,comp-int; 53 + adi,alarm-pol = <0>; 54 + adi,fault-q = <1>; 55 + adi,timeout-enable; 114 56 }; 115 57 }; 116 58 ...
-54
Documentation/devicetree/bindings/hwmon/ina3221.txt
··· 1 - Texas Instruments INA3221 Device Tree Bindings 2 - 3 - 1) ina3221 node 4 - Required properties: 5 - - compatible: Must be "ti,ina3221" 6 - - reg: I2C address 7 - 8 - Optional properties: 9 - - ti,single-shot: This chip has two power modes: single-shot (chip takes one 10 - measurement and then shuts itself down) and continuous ( 11 - chip takes continuous measurements). The continuous mode is 12 - more reliable and suitable for hardware monitor type device, 13 - but the single-shot mode is more power-friendly and useful 14 - for battery-powered device which cares power consumptions 15 - while still needs some measurements occasionally. 16 - If this property is present, the single-shot mode will be 17 - used, instead of the default continuous one for monitoring. 18 - 19 - = The node contains optional child nodes for three channels = 20 - = Each child node describes the information of input source = 21 - 22 - - #address-cells: Required only if a child node is present. Must be 1. 23 - - #size-cells: Required only if a child node is present. Must be 0. 24 - 25 - 2) child nodes 26 - Required properties: 27 - - reg: Must be 0, 1 or 2, corresponding to IN1, IN2 or IN3 port of INA3221 28 - 29 - Optional properties: 30 - - label: Name of the input source 31 - - shunt-resistor-micro-ohms: Shunt resistor value in micro-Ohm 32 - 33 - Example: 34 - 35 - ina3221@40 { 36 - compatible = "ti,ina3221"; 37 - reg = <0x40>; 38 - #address-cells = <1>; 39 - #size-cells = <0>; 40 - 41 - input@0 { 42 - reg = <0x0>; 43 - status = "disabled"; 44 - }; 45 - input@1 { 46 - reg = <0x1>; 47 - shunt-resistor-micro-ohms = <5000>; 48 - }; 49 - input@2 { 50 - reg = <0x2>; 51 - label = "VDD_5V"; 52 - shunt-resistor-micro-ohms = <5000>; 53 - }; 54 - };
+5 -1
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
··· 1 - Nuvoton NPCM7xx PWM and Fan Tacho controller device 1 + Nuvoton NPCM PWM and Fan Tacho controller device 2 2 3 3 The Nuvoton BMC NPCM7XX supports 8 Pulse-width modulation (PWM) 4 + controller outputs and 16 Fan tachometer controller inputs. 5 + 6 + The Nuvoton BMC NPCM8XX supports 12 Pulse-width modulation (PWM) 4 7 controller outputs and 16 Fan tachometer controller inputs. 5 8 6 9 Required properties for pwm-fan node 7 10 - #address-cells : should be 1. 8 11 - #size-cells : should be 0. 9 12 - compatible : "nuvoton,npcm750-pwm-fan" for Poleg NPCM7XX. 13 + : "nuvoton,npcm845-pwm-fan" for Arbel NPCM8XX. 10 14 - reg : specifies physical base address and size of the registers. 11 15 - reg-names : must contain: 12 16 * "pwm" for the PWM registers.
+49
Documentation/devicetree/bindings/hwmon/pmbus/infineon,tda38640.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + 5 + $id: http://devicetree.org/schemas/hwmon/pmbus/infineon,tda38640.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 + 8 + title: Infineon TDA38640 Synchronous Buck Regulator with SVID and I2C 9 + 10 + maintainers: 11 + - Naresh Solanki <naresh.solanki@9elements.com> 12 + 13 + description: | 14 + The Infineon TDA38640 is a 40A Single-voltage Synchronous Buck 15 + Regulator with SVID and I2C designed for Industrial use. 16 + 17 + Datasheet: https://www.infineon.com/dgdl/Infineon-TDA38640-0000-DataSheet-v02_04-EN.pdf?fileId=8ac78c8c80027ecd018042f2337f00c9 18 + 19 + properties: 20 + compatible: 21 + enum: 22 + - infineon,tda38640 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + infineon,en-pin-fixed-level: 28 + description: 29 + Indicates that the chip EN pin is at fixed level or left 30 + unconnected(has internal pull-down). 31 + type: boolean 32 + 33 + required: 34 + - compatible 35 + - reg 36 + 37 + additionalProperties: false 38 + 39 + examples: 40 + - | 41 + i2c { 42 + #address-cells = <1>; 43 + #size-cells = <0>; 44 + 45 + tda38640@40 { 46 + compatible = "infineon,tda38640"; 47 + reg = <0x40>; 48 + }; 49 + };
+1
Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml
··· 26 26 - ti,ina226 27 27 - ti,ina230 28 28 - ti,ina231 29 + - ti,ina237 29 30 - ti,ina238 30 31 31 32 reg:
+121
Documentation/devicetree/bindings/hwmon/ti,ina3221.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/ti,ina3221.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Texas Instruments INA3221 Current and Voltage Monitor 8 + 9 + maintainers: 10 + - Jean Delvare <jdelvare@suse.com> 11 + - Guenter Roeck <linux@roeck-us.net> 12 + 13 + properties: 14 + compatible: 15 + const: ti,ina3221 16 + 17 + reg: 18 + maxItems: 1 19 + 20 + ti,single-shot: 21 + description: | 22 + This chip has two power modes: single-shot (chip takes one measurement 23 + and then shuts itself down) and continuous (chip takes continuous 24 + measurements). The continuous mode is more reliable and suitable for 25 + hardware monitor type device, but the single-shot mode is more power- 26 + friendly and useful for battery-powered device which cares power 27 + consumptions while still needs some measurements occasionally. 28 + 29 + If this property is present, the single-shot mode will be used, instead 30 + of the default continuous one for monitoring. 31 + $ref: /schemas/types.yaml#/definitions/flag 32 + 33 + "#address-cells": 34 + description: Required only if a child node is present. 35 + const: 1 36 + 37 + "#size-cells": 38 + description: Required only if a child node is present. 39 + const: 0 40 + 41 + patternProperties: 42 + "^input@[0-2]$": 43 + description: The node contains optional child nodes for three channels. 44 + Each child node describes the information of input source. Input channels 45 + default to enabled in the chip. Unless channels are explicitly disabled 46 + in device-tree, input channels will be enabled. 47 + type: object 48 + additionalProperties: false 49 + properties: 50 + reg: 51 + description: Must be 0, 1 and 2, corresponding to the IN1, IN2 or IN3 52 + ports of the INA3221, respectively. 53 + enum: [ 0, 1, 2 ] 54 + 55 + label: 56 + description: name of the input source 57 + 58 + shunt-resistor-micro-ohms: 59 + description: shunt resistor value in micro-Ohm 60 + 61 + ti,summation-disable: 62 + description: | 63 + The INA3221 has a critical alert pin that can be controlled by the 64 + summation control function. This function adds the single 65 + shunt-voltage conversions for the desired channels in order to 66 + compare the combined sum to the programmed limit. The Shunt-Voltage 67 + Sum Limit register contains the programmed value that is compared 68 + to the value in the Shunt-Voltage Sum register in order to 69 + determine if the total summed limit is exceeded. If the 70 + shunt-voltage sum limit value is exceeded, the critical alert pin 71 + is asserted. 72 + 73 + For the summation limit to have a meaningful value, it is necessary 74 + to use the same shunt-resistor value on all enabled channels. If 75 + this is not the case or if a channel should not be used for 76 + triggering the critical alert pin, then this property can be used 77 + exclude specific channels from the summation control function. 78 + type: boolean 79 + 80 + required: 81 + - reg 82 + 83 + required: 84 + - compatible 85 + - reg 86 + 87 + additionalProperties: false 88 + 89 + examples: 90 + - | 91 + i2c { 92 + #address-cells = <1>; 93 + #size-cells = <0>; 94 + 95 + power-sensor@40 { 96 + compatible = "ti,ina3221"; 97 + reg = <0x40>; 98 + #address-cells = <1>; 99 + #size-cells = <0>; 100 + 101 + input@0 { 102 + reg = <0x0>; 103 + /* 104 + * Input channels are enabled by default in the device and so 105 + * to disable, must be explicitly disabled in device-tree. 106 + */ 107 + status = "disabled"; 108 + }; 109 + 110 + input@1 { 111 + reg = <0x1>; 112 + shunt-resistor-micro-ohms = <5000>; 113 + }; 114 + 115 + input@2 { 116 + reg = <0x2>; 117 + label = "VDD_5V"; 118 + shunt-resistor-micro-ohms = <5000>; 119 + }; 120 + }; 121 + };
+59
Documentation/devicetree/bindings/regulator/mps,mpq2286.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/regulator/mps,mpq2286.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Monolithic Power System MPQ2286 PMIC 8 + 9 + maintainers: 10 + - Saravanan Sekar <saravanan@linumiz.com> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - mps,mpq2286 16 + 17 + reg: 18 + maxItems: 1 19 + 20 + regulators: 21 + type: object 22 + 23 + properties: 24 + buck: 25 + type: object 26 + $ref: regulator.yaml# 27 + 28 + unevaluatedProperties: false 29 + 30 + additionalProperties: false 31 + 32 + required: 33 + - compatible 34 + - reg 35 + - regulators 36 + 37 + additionalProperties: false 38 + 39 + examples: 40 + - | 41 + i2c { 42 + #address-cells = <1>; 43 + #size-cells = <0>; 44 + 45 + pmic@3 { 46 + compatible = "mps,mpq2286"; 47 + reg = <0x3>; 48 + 49 + regulators { 50 + buck { 51 + regulator-name = "buck"; 52 + regulator-min-microvolt = <1600000>; 53 + regulator-max-microvolt = <1800000>; 54 + regulator-boot-on; 55 + }; 56 + }; 57 + }; 58 + }; 59 + ...
-2
Documentation/devicetree/bindings/trivial-devices.yaml
··· 151 151 - infineon,slb9645tt 152 152 # Infineon SLB9673 I2C TPM 2.0 153 153 - infineon,slb9673 154 - # Infineon TDA38640 Voltage Regulator 155 - - infineon,tda38640 156 154 # Infineon TLV493D-A1B6 I2C 3D Magnetic Sensor 157 155 - infineon,tlv493d-a1b6 158 156 # Infineon Multi-phase Digital VR Controller xdpe11280
+2 -1
Documentation/hwmon/adt7475.rst
··· 90 90 91 91 ADT7490: 92 92 * 6 voltage inputs 93 - * 1 Imon input (not implemented) 93 + * 1 Imon input 94 94 * PECI support (not implemented) 95 95 * 2 GPIO pins (not implemented) 96 96 * system acoustics optimizations (not implemented) ··· 107 107 in3 5VIN (20) 5VIN (20) 108 108 in4 12VIN (21) 12VIN (21) 109 109 in5 VTT (8) 110 + in6 Imon (19) 110 111 ==== =========== =========== ========= ========== 111 112 112 113 Special Features
+7
Documentation/hwmon/aquacomputer_d5next.rst
··· 16 16 * Aquacomputer Aquastream XT watercooling pump 17 17 * Aquacomputer Aquastream Ultimate watercooling pump 18 18 * Aquacomputer Poweradjust 3 fan controller 19 + * Aquacomputer High Flow USB flow meter 20 + * Aquacomputer MPS Flow devices 19 21 20 22 Author: Aleksa Savic 21 23 ··· 74 72 It also exposes pressure and flow speed readings. 75 73 76 74 The Poweradjust 3 controller exposes a single external temperature sensor. 75 + 76 + The High Flow USB exposes an internal and external temperature sensor, and a flow meter. 77 + 78 + The MPS Flow devices expose the same entries as the High Flow USB because they have 79 + the same USB product ID and report sensors equivalently. 77 80 78 81 Depending on the device, not all sysfs and debugfs entries will be available. 79 82 Writing to virtual temperature sensors is not currently supported.
+1
Documentation/hwmon/asus_ec_sensors.rst
··· 15 15 * ROG CROSSHAIR VIII HERO 16 16 * ROG CROSSHAIR VIII IMPACT 17 17 * ROG CROSSHAIR X670E HERO 18 + * ROG CROSSHAIR X670E GENE 18 19 * ROG MAXIMUS XI HERO 19 20 * ROG MAXIMUS XI HERO (WI-FI) 20 21 * ROG STRIX B550-E GAMING
+2
Documentation/hwmon/index.rst
··· 121 121 ltc2947 122 122 ltc2978 123 123 ltc2990 124 + ltc2991 124 125 ltc3815 125 126 ltc4151 126 127 ltc4215 ··· 179 178 peci-cputemp 180 179 peci-dimmtemp 181 180 pmbus 181 + powerz 182 182 powr1220 183 183 pxe1610 184 184 pwm-fan
+43
Documentation/hwmon/ltc2991.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Kernel driver ltc2991 4 + ===================== 5 + 6 + Supported chips: 7 + 8 + * Analog Devices LTC2991 9 + 10 + Prefix: 'ltc2991' 11 + 12 + Addresses scanned: I2C 0x48 - 0x4f 13 + 14 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/2991ff.pdf 15 + 16 + Authors: 17 + 18 + - Antoniu Miclaus <antoniu.miclaus@analog.com> 19 + 20 + 21 + Description 22 + ----------- 23 + 24 + This driver supports hardware monitoring for Analog Devices LTC2991 Octal I2C 25 + Voltage, Current and Temperature Monitor. 26 + 27 + The LTC2991 is used to monitor system temperatures, voltages and currents. 28 + Through the I2C serial interface, the eight monitors can individually measure 29 + supply voltages and can be paired for differential measurements of current sense 30 + resistors or temperature sensing transistors. Additional measurements include 31 + internal temperatureand internal VCC. 32 + 33 + 34 + sysfs-Interface 35 + --------------- 36 + 37 + The following attributes are supported. Limits are read-only. 38 + 39 + =============== ================= 40 + inX_input: voltage input 41 + currX_input: current input 42 + tempX_input: temperature input 43 + =============== =================
+2 -2
Documentation/hwmon/max31827.rst
··· 73 73 the resolution. The conversion time doubles with every bit of increased 74 74 resolution. For 10 bit resolution 35ms are needed, while for 12 bit resolution 75 75 (default) 140ms. When chip is in shutdown mode and a read operation is 76 - requested, one-shot is triggered, the device waits for 140 (conversion time) + 1 77 - (error) ms, and only after that is the temperature value register read. 76 + requested, one-shot is triggered, the device waits for 140 (conversion time) ms, 77 + and only after that is the temperature value register read. 78 78 79 79 The LSB of the temperature values is 0.0625 degrees Celsius, but the values of 80 80 the temperatures are displayed in milli-degrees. This means, that some data is
+1
Documentation/hwmon/nct6683.rst
··· 62 62 Intel DH87MC NCT6683D EC firmware version 1.0 build 04/03/13 63 63 Intel DB85FL NCT6683D EC firmware version 1.0 build 04/03/13 64 64 ASRock X570 NCT6683D EC firmware version 1.0 build 06/28/19 65 + ASRock X670E NCT6686D EC firmware version 1.0 build 05/19/22 65 66 MSI B550 NCT6687D EC firmware version 1.0 build 05/07/20 66 67 =============== ===============================================
+30
Documentation/hwmon/powerz.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0-or-later 2 + 3 + Kernel driver POWERZ 4 + ==================== 5 + 6 + Supported chips: 7 + 8 + * ChargerLAB POWER-Z KM003C 9 + 10 + Prefix: 'powerz' 11 + 12 + Addresses scanned: - 13 + 14 + Author: 15 + 16 + - Thomas Weißschuh <linux@weissschuh.net> 17 + 18 + Description 19 + ----------- 20 + 21 + This driver implements support for the ChargerLAB POWER-Z USB-C power testing 22 + family. 23 + 24 + The device communicates with the custom protocol over USB. 25 + 26 + The channel labels exposed via hwmon match the labels used by the on-device 27 + display and the official POWER-Z PC software. 28 + 29 + As current can flow in both directions through the tester the sign of the 30 + channel "curr1_input" (label "IBUS") indicates the direction.
+10
Documentation/hwmon/sch5627.rst
··· 33 33 through an embedded microcontroller. An application note describing the 34 34 protocol for communicating with the microcontroller is available upon 35 35 request. Please mail me if you want a copy. 36 + 37 + 38 + Controlling fan speed 39 + --------------------- 40 + 41 + The SCH5627 allows for partially controlling the fan speed. If a temperature 42 + channel excedes tempX_max, all fans are forced to maximum speed. The same is not 43 + true for tempX_crit, presumably some other measures to cool down the system are 44 + take in this case. 45 + In which way the value of fanX_min affects the fan speed is currently unknown.
+16
MAINTAINERS
··· 4828 4828 X: drivers/char/random.c 4829 4829 X: drivers/char/tpm/ 4830 4830 4831 + CHARGERLAB POWER-Z HARDWARE MONITOR DRIVER 4832 + M: Thomas Weißschuh <linux@weissschuh.net> 4833 + L: linux-hwmon@vger.kernel.org 4834 + S: Maintained 4835 + F: Documentation/hwmon/powerz.rst 4836 + F: drivers/hwmon/powerz.c 4837 + 4831 4838 CHECKPATCH 4832 4839 M: Andy Whitcroft <apw@canonical.com> 4833 4840 M: Joe Perches <joe@perches.com> ··· 12498 12491 F: drivers/hwmon/ltc2947-spi.c 12499 12492 F: drivers/hwmon/ltc2947.h 12500 12493 12494 + LTC2991 HARDWARE MONITOR DRIVER 12495 + M: Antoniu Miclaus <antoniu.miclaus@analog.com> 12496 + L: linux-hwmon@vger.kernel.org 12497 + S: Supported 12498 + W: https://ez.analog.com/linux-software-drivers 12499 + F: Documentation/devicetree/bindings/hwmon/adi,ltc2991.yaml 12500 + F: drivers/hwmon/ltc2991.c 12501 + 12501 12502 LTC2983 IIO TEMPERATURE DRIVER 12502 12503 M: Nuno Sá <nuno.sa@analog.com> 12503 12504 L: linux-iio@vger.kernel.org ··· 19456 19441 19457 19442 SFCTEMP HWMON DRIVER 19458 19443 M: Emil Renner Berthing <kernel@esmil.dk> 19444 + M: Hal Feng <hal.feng@starfivetech.com> 19459 19445 L: linux-hwmon@vger.kernel.org 19460 19446 S: Maintained 19461 19447 F: Documentation/devicetree/bindings/hwmon/starfive,jh71x0-temp.yaml
+24 -2
drivers/hwmon/Kconfig
··· 40 40 41 41 config SENSORS_ABITUGURU 42 42 tristate "Abit uGuru (rev 1 & 2)" 43 - depends on X86 && DMI 43 + depends on (X86 && DMI) || COMPILE_TEST 44 44 help 45 45 If you say yes here you get support for the sensor part of the first 46 46 and second revision of the Abit uGuru chip. The voltage and frequency ··· 55 55 56 56 config SENSORS_ABITUGURU3 57 57 tristate "Abit uGuru (rev 3)" 58 - depends on X86 && DMI 58 + depends on (X86 && DMI) || COMPILE_TEST 59 59 help 60 60 If you say yes here you get support for the sensor part of the 61 61 third revision of the Abit uGuru chip. Only reading the sensors ··· 839 839 This driver can also be built as a module. If so, the module 840 840 will be called jc42. 841 841 842 + config SENSORS_POWERZ 843 + tristate "ChargerLAB POWER-Z USB-C tester" 844 + depends on USB 845 + help 846 + If you say yes here you get support for ChargerLAB POWER-Z series of 847 + USB-C charging testers. 848 + 849 + This driver can also be built as a module. If so, the module 850 + will be called powerz. 851 + 842 852 config SENSORS_POWR1220 843 853 tristate "Lattice POWR1220 Power Monitoring" 844 854 depends on I2C ··· 941 931 942 932 This driver can also be built as a module. If so, the module will 943 933 be called ltc2990. 934 + 935 + config SENSORS_LTC2991 936 + tristate "Analog Devices LTC2991" 937 + depends on I2C 938 + help 939 + If you say yes here you get support for Analog Devices LTC2991 940 + Octal I2C Voltage, Current, and Temperature Monitor. The LTC2991 941 + supports a combination of voltage, current and temperature monitoring. 942 + 943 + This driver can also be built as a module. If so, the module will 944 + be called ltc2991. 944 945 945 946 config SENSORS_LTC2992 946 947 tristate "Linear Technology LTC2992" ··· 1930 1909 1931 1910 config SENSORS_SCH56XX_COMMON 1932 1911 tristate 1912 + select REGMAP 1933 1913 1934 1914 config SENSORS_SCH5627 1935 1915 tristate "SMSC SCH5627"
+2
drivers/hwmon/Makefile
··· 127 127 obj-$(CONFIG_SENSORS_LTC2947_I2C) += ltc2947-i2c.o 128 128 obj-$(CONFIG_SENSORS_LTC2947_SPI) += ltc2947-spi.o 129 129 obj-$(CONFIG_SENSORS_LTC2990) += ltc2990.o 130 + obj-$(CONFIG_SENSORS_LTC2991) += ltc2991.o 130 131 obj-$(CONFIG_SENSORS_LTC2992) += ltc2992.o 131 132 obj-$(CONFIG_SENSORS_LTC4151) += ltc4151.o 132 133 obj-$(CONFIG_SENSORS_LTC4215) += ltc4215.o ··· 177 176 obj-$(CONFIG_SENSORS_PC87360) += pc87360.o 178 177 obj-$(CONFIG_SENSORS_PC87427) += pc87427.o 179 178 obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 179 + obj-$(CONFIG_SENSORS_POWERZ) += powerz.o 180 180 obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o 181 181 obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o 182 182 obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o
+2 -4
drivers/hwmon/abituguru.c
··· 1428 1428 return res; 1429 1429 } 1430 1430 1431 - static int abituguru_remove(struct platform_device *pdev) 1431 + static void abituguru_remove(struct platform_device *pdev) 1432 1432 { 1433 1433 int i; 1434 1434 struct abituguru_data *data = platform_get_drvdata(pdev); ··· 1439 1439 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) 1440 1440 device_remove_file(&pdev->dev, 1441 1441 &abituguru_sysfs_attr[i].dev_attr); 1442 - 1443 - return 0; 1444 1442 } 1445 1443 1446 1444 static struct abituguru_data *abituguru_update_device(struct device *dev) ··· 1531 1533 .pm = pm_sleep_ptr(&abituguru_pm), 1532 1534 }, 1533 1535 .probe = abituguru_probe, 1534 - .remove = abituguru_remove, 1536 + .remove_new = abituguru_remove, 1535 1537 }; 1536 1538 1537 1539 static int __init abituguru_detect(void)
+2 -3
drivers/hwmon/abituguru3.c
··· 1061 1061 return res; 1062 1062 } 1063 1063 1064 - static int abituguru3_remove(struct platform_device *pdev) 1064 + static void abituguru3_remove(struct platform_device *pdev) 1065 1065 { 1066 1066 int i; 1067 1067 struct abituguru3_data *data = platform_get_drvdata(pdev); ··· 1072 1072 for (i = 0; i < ARRAY_SIZE(abituguru3_sysfs_attr); i++) 1073 1073 device_remove_file(&pdev->dev, 1074 1074 &abituguru3_sysfs_attr[i].dev_attr); 1075 - return 0; 1076 1075 } 1077 1076 1078 1077 static struct abituguru3_data *abituguru3_update_device(struct device *dev) ··· 1152 1153 .pm = pm_sleep_ptr(&abituguru3_pm), 1153 1154 }, 1154 1155 .probe = abituguru3_probe, 1155 - .remove = abituguru3_remove, 1156 + .remove_new = abituguru3_remove, 1156 1157 }; 1157 1158 1158 1159 static int __init abituguru3_dmi_detect(void)
+62 -6
drivers/hwmon/adt7475.c
··· 43 43 /* 7475 Common Registers */ 44 44 45 45 #define REG_DEVREV2 0x12 /* ADT7490 only */ 46 + #define REG_IMON 0x1D /* ADT7490 only */ 46 47 47 48 #define REG_VTT 0x1E /* ADT7490 only */ 48 49 #define REG_EXTEND3 0x1F /* ADT7490 only */ ··· 104 103 #define REG_VTT_MIN 0x84 /* ADT7490 only */ 105 104 #define REG_VTT_MAX 0x86 /* ADT7490 only */ 106 105 106 + #define REG_IMON_MIN 0x85 /* ADT7490 only */ 107 + #define REG_IMON_MAX 0x87 /* ADT7490 only */ 108 + 107 109 #define VID_VIDSEL 0x80 /* ADT7476 only */ 108 110 109 111 #define CONFIG2_ATTN 0x20 ··· 127 123 128 124 /* ADT7475 Settings */ 129 125 130 - #define ADT7475_VOLTAGE_COUNT 5 /* Not counting Vtt */ 126 + #define ADT7475_VOLTAGE_COUNT 5 /* Not counting Vtt or Imon */ 131 127 #define ADT7475_TEMP_COUNT 3 132 128 #define ADT7475_TACH_COUNT 4 133 129 #define ADT7475_PWM_COUNT 3 ··· 208 204 u8 has_fan4:1; 209 205 u8 has_vid:1; 210 206 u32 alarms; 211 - u16 voltage[3][6]; 207 + u16 voltage[3][7]; 212 208 u16 temp[7][3]; 213 209 u16 tach[2][4]; 214 210 u8 pwm[4][3]; ··· 219 215 220 216 u8 vid; 221 217 u8 vrm; 222 - const struct attribute_group *groups[9]; 218 + const struct attribute_group *groups[10]; 223 219 }; 224 220 225 221 static struct i2c_driver adt7475_driver; ··· 277 273 } 278 274 279 275 /* Scaling factors for voltage inputs, taken from the ADT7490 datasheet */ 280 - static const int adt7473_in_scaling[ADT7475_VOLTAGE_COUNT + 1][2] = { 276 + static const int adt7473_in_scaling[ADT7475_VOLTAGE_COUNT + 2][2] = { 281 277 { 45, 94 }, /* +2.5V */ 282 278 { 175, 525 }, /* Vccp */ 283 279 { 68, 71 }, /* Vcc */ 284 280 { 93, 47 }, /* +5V */ 285 281 { 120, 20 }, /* +12V */ 286 282 { 45, 45 }, /* Vtt */ 283 + { 45, 45 }, /* Imon */ 287 284 }; 288 285 289 286 static inline int reg2volt(int channel, u16 reg, u8 bypass_attn) ··· 374 369 reg = VOLTAGE_MIN_REG(sattr->index); 375 370 else 376 371 reg = VOLTAGE_MAX_REG(sattr->index); 377 - } else { 372 + } else if (sattr->index == 5) { 378 373 if (sattr->nr == MIN) 379 374 reg = REG_VTT_MIN; 380 375 else 381 376 reg = REG_VTT_MAX; 377 + } else { 378 + if (sattr->nr == MIN) 379 + reg = REG_IMON_MIN; 380 + else 381 + reg = REG_IMON_MAX; 382 382 } 383 383 384 384 i2c_smbus_write_byte_data(client, reg, ··· 1114 1104 static SENSOR_DEVICE_ATTR_2_RW(in5_max, voltage, MAX, 5); 1115 1105 static SENSOR_DEVICE_ATTR_2_RW(in5_min, voltage, MIN, 5); 1116 1106 static SENSOR_DEVICE_ATTR_2_RO(in5_alarm, voltage, ALARM, 31); 1107 + static SENSOR_DEVICE_ATTR_2_RO(in6_input, voltage, INPUT, 6); 1108 + static SENSOR_DEVICE_ATTR_2_RW(in6_max, voltage, MAX, 6); 1109 + static SENSOR_DEVICE_ATTR_2_RW(in6_min, voltage, MIN, 6); 1110 + static SENSOR_DEVICE_ATTR_2_RO(in6_alarm, voltage, ALARM, 30); 1117 1111 static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, INPUT, 0); 1118 1112 static SENSOR_DEVICE_ATTR_2_RO(temp1_alarm, temp, ALARM, 0); 1119 1113 static SENSOR_DEVICE_ATTR_2_RO(temp1_fault, temp, FAULT, 0); ··· 1308 1294 NULL 1309 1295 }; 1310 1296 1297 + static struct attribute *in6_attrs[] = { 1298 + &sensor_dev_attr_in6_input.dev_attr.attr, 1299 + &sensor_dev_attr_in6_max.dev_attr.attr, 1300 + &sensor_dev_attr_in6_min.dev_attr.attr, 1301 + &sensor_dev_attr_in6_alarm.dev_attr.attr, 1302 + NULL 1303 + }; 1304 + 1311 1305 static struct attribute *vid_attrs[] = { 1312 1306 &dev_attr_cpu0_vid.attr, 1313 1307 &dev_attr_vrm.attr, ··· 1329 1307 static const struct attribute_group in3_attr_group = { .attrs = in3_attrs }; 1330 1308 static const struct attribute_group in4_attr_group = { .attrs = in4_attrs }; 1331 1309 static const struct attribute_group in5_attr_group = { .attrs = in5_attrs }; 1310 + static const struct attribute_group in6_attr_group = { .attrs = in6_attrs }; 1332 1311 static const struct attribute_group vid_attr_group = { .attrs = vid_attrs }; 1333 1312 1334 1313 static int adt7475_detect(struct i2c_client *client, ··· 1410 1387 if (ret < 0) 1411 1388 return ret; 1412 1389 data->voltage[MAX][5] = ret << 2; 1390 + } 1391 + 1392 + if (data->has_voltage & (1 << 6)) { 1393 + ret = adt7475_read(REG_IMON_MIN); 1394 + if (ret < 0) 1395 + return ret; 1396 + data->voltage[MIN][6] = ret << 2; 1397 + 1398 + ret = adt7475_read(REG_IMON_MAX); 1399 + if (ret < 0) 1400 + return ret; 1401 + data->voltage[MAX][6] = ret << 2; 1413 1402 } 1414 1403 1415 1404 for (i = 0; i < ADT7475_TEMP_COUNT; i++) { ··· 1698 1663 revision = adt7475_read(REG_DEVID2) & 0x07; 1699 1664 break; 1700 1665 case adt7490: 1701 - data->has_voltage = 0x3e; /* in1 to in5 */ 1666 + data->has_voltage = 0x7e; /* in1 to in6 */ 1702 1667 revision = adt7475_read(REG_DEVID2) & 0x03; 1703 1668 if (revision == 0x03) 1704 1669 revision += adt7475_read(REG_DEVREV2); ··· 1809 1774 } 1810 1775 if (data->has_voltage & (1 << 5)) { 1811 1776 data->groups[group_num++] = &in5_attr_group; 1777 + } 1778 + if (data->has_voltage & (1 << 6)) { 1779 + data->groups[group_num++] = &in6_attr_group; 1812 1780 } 1813 1781 if (data->has_vid) { 1814 1782 data->vrm = vid_which_vrm(); ··· 1996 1958 return ret; 1997 1959 data->voltage[INPUT][5] = ret << 2 | 1998 1960 ((ext >> 4) & 3); 1961 + } 1962 + 1963 + if (data->has_voltage & (1 << 6)) { 1964 + ret = adt7475_read(REG_STATUS4); 1965 + if (ret < 0) 1966 + return ret; 1967 + data->alarms |= ret << 24; 1968 + 1969 + ret = adt7475_read(REG_EXTEND3); 1970 + if (ret < 0) 1971 + return ret; 1972 + ext = ret; 1973 + 1974 + ret = adt7475_read(REG_IMON); 1975 + if (ret < 0) 1976 + return ret; 1977 + data->voltage[INPUT][6] = ret << 2 | 1978 + ((ext >> 6) & 3); 1999 1979 } 2000 1980 2001 1981 for (i = 0; i < ADT7475_TACH_COUNT; i++) {
+67 -5
drivers/hwmon/aquacomputer_d5next.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 3 * hwmon driver for Aquacomputer devices (D5 Next, Farbwerk, Farbwerk 360, Octo, 4 - * Quadro, High Flow Next, Aquaero, Aquastream Ultimate, Leakshield) 4 + * Quadro, High Flow Next, Aquaero, Aquastream Ultimate, Leakshield, 5 + * High Flow USB/MPS Flow family) 5 6 * 6 7 * Aquacomputer devices send HID reports (with ID 0x01) every second to report 7 8 * sensor values, except for devices that communicate through the 8 - * legacy way (currently, Poweradjust 3). 9 + * legacy way (currently, Poweradjust 3 and High Flow USB/MPS Flow family). 9 10 * 10 11 * Copyright 2021 Aleksa Savic <savicaleksa83@gmail.com> 11 12 * Copyright 2022 Jack Doan <me@jackdoan.com> ··· 36 35 #define USB_PRODUCT_ID_AQUASTREAMXT 0xf0b6 37 36 #define USB_PRODUCT_ID_AQUASTREAMULT 0xf00b 38 37 #define USB_PRODUCT_ID_POWERADJUST3 0xf0bd 38 + #define USB_PRODUCT_ID_HIGHFLOW 0xf003 39 39 40 40 enum kinds { 41 41 d5next, farbwerk, farbwerk360, octo, quadro, 42 42 highflownext, aquaero, poweradjust3, aquastreamult, 43 - aquastreamxt, leakshield 43 + aquastreamxt, leakshield, highflow 44 44 }; 45 45 46 46 static const char *const aqc_device_names[] = { ··· 55 53 [aquastreamxt] = "aquastreamxt", 56 54 [aquaero] = "aquaero", 57 55 [aquastreamult] = "aquastreamultimate", 58 - [poweradjust3] = "poweradjust3" 56 + [poweradjust3] = "poweradjust3", 57 + [highflow] = "highflow" /* Covers MPS Flow devices */ 59 58 }; 60 59 61 60 #define DRIVER_NAME "aquacomputer_d5next" ··· 92 89 #define AQUASTREAMXT_STATUS_REPORT_ID 0x04 93 90 94 91 #define POWERADJUST3_STATUS_REPORT_ID 0x03 92 + 93 + #define HIGHFLOW_STATUS_REPORT_ID 0x02 95 94 96 95 /* Data types for reading and writing control reports */ 97 96 #define AQC_8 0 ··· 286 281 287 282 /* Sensor report offsets for the Poweradjust 3 */ 288 283 #define POWERADJUST3_SENSOR_START 0x03 284 + 285 + /* Specs of the High Flow USB */ 286 + #define HIGHFLOW_NUM_SENSORS 2 287 + #define HIGHFLOW_NUM_FLOW_SENSORS 1 288 + #define HIGHFLOW_SENSOR_REPORT_SIZE 0x76 289 + 290 + /* Sensor report offsets for the High Flow USB */ 291 + #define HIGHFLOW_FIRMWARE_VERSION 0x3 292 + #define HIGHFLOW_SERIAL_START 0x9 293 + #define HIGHFLOW_FLOW_SENSOR_OFFSET 0x23 294 + #define HIGHFLOW_SENSOR_START 0x2b 289 295 290 296 /* Labels for D5 Next */ 291 297 static const char *const label_d5next_temp[] = { ··· 500 484 /* Labels for Poweradjust 3 */ 501 485 static const char *const label_poweradjust3_temp_sensors[] = { 502 486 "External sensor" 487 + }; 488 + 489 + /* Labels for Highflow */ 490 + static const char *const label_highflow_temp[] = { 491 + "External temp", 492 + "Internal temp" 493 + }; 494 + 495 + static const char *const label_highflow_speeds[] = { 496 + "Flow speed [dL/h]" 503 497 }; 504 498 505 499 struct aqc_fan_structure_offsets { ··· 845 819 break; 846 820 case aquaero: 847 821 case quadro: 822 + case highflow: 848 823 /* Special case to support flow sensors */ 849 824 if (channel < priv->num_fans + priv->num_flow_sensors) 850 825 return 0444; ··· 953 926 for (i = 0; i < priv->num_temp_sensors; i++) { 954 927 sensor_value = get_unaligned_le16(priv->buffer + priv->temp_sensor_start_offset + 955 928 i * AQC_SENSOR_SIZE); 956 - priv->temp_input[i] = sensor_value * 10; 929 + if (sensor_value == AQC_SENSOR_NA) 930 + priv->temp_input[i] = -ENODATA; 931 + else 932 + priv->temp_input[i] = sensor_value * 10; 957 933 } 958 934 959 935 /* Special-case sensor readings */ ··· 991 961 992 962 sensor_value = get_unaligned_le16(priv->buffer + AQUASTREAMXT_FAN_VOLTAGE_OFFSET); 993 963 priv->voltage_input[1] = DIV_ROUND_CLOSEST(sensor_value * 1000, 63); 964 + break; 965 + case highflow: 966 + /* Info provided with every report */ 967 + priv->serial_number[0] = get_unaligned_le16(priv->buffer + 968 + priv->serial_number_start_offset); 969 + priv->firmware_version = 970 + get_unaligned_le16(priv->buffer + priv->firmware_version_offset); 971 + 972 + /* Read flow speed */ 973 + priv->speed_input[0] = get_unaligned_le16(priv->buffer + 974 + priv->flow_sensors_start_offset); 994 975 break; 995 976 default: 996 977 break; ··· 1788 1747 1789 1748 priv->temp_label = label_poweradjust3_temp_sensors; 1790 1749 break; 1750 + case USB_PRODUCT_ID_HIGHFLOW: 1751 + priv->kind = highflow; 1752 + 1753 + priv->num_fans = 0; 1754 + 1755 + priv->num_temp_sensors = HIGHFLOW_NUM_SENSORS; 1756 + priv->temp_sensor_start_offset = HIGHFLOW_SENSOR_START; 1757 + priv->num_flow_sensors = HIGHFLOW_NUM_FLOW_SENSORS; 1758 + priv->flow_sensors_start_offset = HIGHFLOW_FLOW_SENSOR_OFFSET; 1759 + priv->buffer_size = HIGHFLOW_SENSOR_REPORT_SIZE; 1760 + 1761 + priv->temp_label = label_highflow_temp; 1762 + priv->speed_label = label_highflow_speeds; 1763 + break; 1791 1764 default: 1792 1765 break; 1793 1766 } ··· 1826 1771 priv->firmware_version_offset = AQUASTREAMXT_FIRMWARE_VERSION; 1827 1772 1828 1773 priv->status_report_id = AQUASTREAMXT_STATUS_REPORT_ID; 1774 + break; 1775 + case highflow: 1776 + priv->serial_number_start_offset = HIGHFLOW_SERIAL_START; 1777 + priv->firmware_version_offset = HIGHFLOW_FIRMWARE_VERSION; 1778 + 1779 + priv->status_report_id = HIGHFLOW_STATUS_REPORT_ID; 1829 1780 break; 1830 1781 default: 1831 1782 priv->serial_number_start_offset = AQC_SERIAL_START; ··· 1907 1846 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_AQUASTREAMXT) }, 1908 1847 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_AQUASTREAMULT) }, 1909 1848 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_POWERADJUST3) }, 1849 + { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_HIGHFLOW) }, 1910 1850 { } 1911 1851 }; 1912 1852
+12
drivers/hwmon/asus-ec-sensors.c
··· 244 244 EC_SENSOR("Motherboard", hwmon_temp, 1, 0x00, 0x32), 245 245 [ec_sensor_temp_vrm] = 246 246 EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x33), 247 + [ec_sensor_temp_t_sensor] = 248 + EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x36), 247 249 [ec_sensor_temp_water_in] = 248 250 EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00), 249 251 [ec_sensor_temp_water_out] = ··· 342 340 .sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE | 343 341 SENSOR_TEMP_MB | SENSOR_TEMP_VRM | 344 342 SENSOR_SET_TEMP_WATER, 343 + .mutex_path = ACPI_GLOBAL_LOCK_PSEUDO_PATH, 344 + .family = family_amd_600_series, 345 + }; 346 + 347 + static const struct ec_board_info board_info_crosshair_x670e_gene = { 348 + .sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE | 349 + SENSOR_TEMP_T_SENSOR | 350 + SENSOR_TEMP_MB | SENSOR_TEMP_VRM, 345 351 .mutex_path = ACPI_GLOBAL_LOCK_PSEUDO_PATH, 346 352 .family = family_amd_600_series, 347 353 }; ··· 500 490 &board_info_crosshair_viii_hero), 501 491 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR X670E HERO", 502 492 &board_info_crosshair_x670e_hero), 493 + DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR X670E GENE", 494 + &board_info_crosshair_x670e_gene), 503 495 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS XI HERO", 504 496 &board_info_maximus_xi_hero), 505 497 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS XI HERO (WI-FI)",
+16 -13
drivers/hwmon/axi-fan-control.c
··· 496 496 return -ENODEV; 497 497 } 498 498 499 + ret = axi_fan_control_init(ctl, pdev->dev.of_node); 500 + if (ret) { 501 + dev_err(&pdev->dev, "Failed to initialize device\n"); 502 + return ret; 503 + } 504 + 505 + ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev, 506 + name, 507 + ctl, 508 + &axi_chip_info, 509 + axi_fan_control_groups); 510 + 511 + if (IS_ERR(ctl->hdev)) 512 + return PTR_ERR(ctl->hdev); 513 + 499 514 ctl->irq = platform_get_irq(pdev, 0); 500 515 if (ctl->irq < 0) 501 516 return ctl->irq; ··· 524 509 return ret; 525 510 } 526 511 527 - ret = axi_fan_control_init(ctl, pdev->dev.of_node); 528 - if (ret) { 529 - dev_err(&pdev->dev, "Failed to initialize device\n"); 530 - return ret; 531 - } 532 - 533 - ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev, 534 - name, 535 - ctl, 536 - &axi_chip_info, 537 - axi_fan_control_groups); 538 - 539 - return PTR_ERR_OR_ZERO(ctl->hdev); 512 + return 0; 540 513 } 541 514 542 515 static struct platform_driver axi_fan_control_driver = {
+1 -1
drivers/hwmon/coretemp.c
··· 42 42 #define PKG_SYSFS_ATTR_NO 1 /* Sysfs attribute for package temp */ 43 43 #define BASE_SYSFS_ATTR_NO 2 /* Sysfs Base attr no for coretemp */ 44 44 #define NUM_REAL_CORES 128 /* Number of Real cores per cpu */ 45 - #define CORETEMP_NAME_LENGTH 19 /* String Length of attrs */ 45 + #define CORETEMP_NAME_LENGTH 28 /* String Length of attrs */ 46 46 #define MAX_CORE_ATTRS 4 /* Maximum no of basic attrs */ 47 47 #define TOTAL_ATTRS (MAX_CORE_ATTRS + 1) 48 48 #define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO)
+2 -4
drivers/hwmon/da9052-hwmon.c
··· 479 479 return err; 480 480 } 481 481 482 - static int da9052_hwmon_remove(struct platform_device *pdev) 482 + static void da9052_hwmon_remove(struct platform_device *pdev) 483 483 { 484 484 struct da9052_hwmon *hwmon = platform_get_drvdata(pdev); 485 485 ··· 487 487 da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon); 488 488 regulator_disable(hwmon->tsiref); 489 489 } 490 - 491 - return 0; 492 490 } 493 491 494 492 static struct platform_driver da9052_hwmon_driver = { 495 493 .probe = da9052_hwmon_probe, 496 - .remove = da9052_hwmon_remove, 494 + .remove_new = da9052_hwmon_remove, 497 495 .driver = { 498 496 .name = "da9052-hwmon", 499 497 },
+2 -4
drivers/hwmon/dme1737.c
··· 2710 2710 return err; 2711 2711 } 2712 2712 2713 - static int dme1737_isa_remove(struct platform_device *pdev) 2713 + static void dme1737_isa_remove(struct platform_device *pdev) 2714 2714 { 2715 2715 struct dme1737_data *data = platform_get_drvdata(pdev); 2716 2716 2717 2717 hwmon_device_unregister(data->hwmon_dev); 2718 2718 dme1737_remove_files(&pdev->dev); 2719 - 2720 - return 0; 2721 2719 } 2722 2720 2723 2721 static struct platform_driver dme1737_isa_driver = { ··· 2723 2725 .name = "dme1737", 2724 2726 }, 2725 2727 .probe = dme1737_isa_probe, 2726 - .remove = dme1737_isa_remove, 2728 + .remove_new = dme1737_isa_remove, 2727 2729 }; 2728 2730 2729 2731 /* ---------------------------------------------------------------------
+2 -4
drivers/hwmon/f71805f.c
··· 1480 1480 return err; 1481 1481 } 1482 1482 1483 - static int f71805f_remove(struct platform_device *pdev) 1483 + static void f71805f_remove(struct platform_device *pdev) 1484 1484 { 1485 1485 struct f71805f_data *data = platform_get_drvdata(pdev); 1486 1486 int i; ··· 1490 1490 for (i = 0; i < 4; i++) 1491 1491 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); 1492 1492 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); 1493 - 1494 - return 0; 1495 1493 } 1496 1494 1497 1495 static struct platform_driver f71805f_driver = { ··· 1497 1499 .name = DRVNAME, 1498 1500 }, 1499 1501 .probe = f71805f_probe, 1500 - .remove = f71805f_remove, 1502 + .remove_new = f71805f_remove, 1501 1503 }; 1502 1504 1503 1505 static int __init f71805f_device_add(unsigned short address,
+2 -3
drivers/hwmon/f71882fg.c
··· 2223 2223 return err; 2224 2224 } 2225 2225 2226 - static int f71882fg_remove(struct platform_device *pdev) 2226 + static void f71882fg_remove(struct platform_device *pdev) 2227 2227 { 2228 2228 struct f71882fg_data *data = platform_get_drvdata(pdev); 2229 2229 int nr_fans = f71882fg_nr_fans[data->type]; ··· 2333 2333 ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans); 2334 2334 } 2335 2335 } 2336 - return 0; 2337 2336 } 2338 2337 2339 2338 static int f71882fg_probe(struct platform_device *pdev) ··· 2658 2659 .name = DRVNAME, 2659 2660 }, 2660 2661 .probe = f71882fg_probe, 2661 - .remove = f71882fg_remove, 2662 + .remove_new = f71882fg_remove, 2662 2663 }; 2663 2664 2664 2665 static int __init f71882fg_init(void)
+1 -1
drivers/hwmon/hs3001.c
··· 62 62 { 63 63 u32 hum = (raw & HS3001_MASK_HUMIDITY_0X3FFF) * HS3001_FIXPOINT_ARITH * 100; 64 64 65 - return hum /= (1 << 14) - 1; 65 + return hum / (1 << 14) - 1; 66 66 } 67 67 68 68 static int hs3001_data_fetch_command(struct i2c_client *client,
+2 -3
drivers/hwmon/i5k_amb.c
··· 555 555 return res; 556 556 } 557 557 558 - static int i5k_amb_remove(struct platform_device *pdev) 558 + static void i5k_amb_remove(struct platform_device *pdev) 559 559 { 560 560 int i; 561 561 struct i5k_amb_data *data = platform_get_drvdata(pdev); ··· 568 568 iounmap(data->amb_mmio); 569 569 release_mem_region(data->amb_base, data->amb_len); 570 570 kfree(data); 571 - return 0; 572 571 } 573 572 574 573 static struct platform_driver i5k_amb_driver = { ··· 575 576 .name = DRVNAME, 576 577 }, 577 578 .probe = i5k_amb_probe, 578 - .remove = i5k_amb_remove, 579 + .remove_new = i5k_amb_remove, 579 580 }; 580 581 581 582 static int __init i5k_amb_init(void)
+2 -1
drivers/hwmon/ina238.c
··· 33 33 #define INA238_BUS_UNDER_VOLTAGE 0xf 34 34 #define INA238_TEMP_LIMIT 0x10 35 35 #define INA238_POWER_LIMIT 0x11 36 - #define INA238_DEVICE_ID 0x3f 36 + #define INA238_DEVICE_ID 0x3f /* not available on INA237 */ 37 37 38 38 #define INA238_CONFIG_ADCRANGE BIT(4) 39 39 ··· 622 622 MODULE_DEVICE_TABLE(i2c, ina238_id); 623 623 624 624 static const struct of_device_id __maybe_unused ina238_of_match[] = { 625 + { .compatible = "ti,ina237" }, 625 626 { .compatible = "ti,ina238" }, 626 627 { }, 627 628 };
+30 -3
drivers/hwmon/ina3221.c
··· 6 6 * Andrew F. Davis <afd@ti.com> 7 7 */ 8 8 9 + #include <linux/debugfs.h> 9 10 #include <linux/hwmon.h> 10 11 #include <linux/hwmon-sysfs.h> 11 12 #include <linux/i2c.h> ··· 100 99 * @label: label of channel input source 101 100 * @shunt_resistor: shunt resistor value of channel input source 102 101 * @disconnected: connection status of channel input source 102 + * @summation_disable: channel summation status of input source 103 103 */ 104 104 struct ina3221_input { 105 105 const char *label; 106 106 int shunt_resistor; 107 107 bool disconnected; 108 + bool summation_disable; 108 109 }; 109 110 110 111 /** ··· 116 113 * @fields: Register fields of the device 117 114 * @inputs: Array of channel input source specific structures 118 115 * @lock: mutex lock to serialize sysfs attribute accesses 116 + * @debugfs: Pointer to debugfs entry for device 119 117 * @reg_config: Register value of INA3221_CONFIG 120 118 * @summation_shunt_resistor: equivalent shunt resistor value for summation 119 + * @summation_channel_control: Value written to SCC field in INA3221_MASK_ENABLE 121 120 * @single_shot: running in single-shot operating mode 122 121 */ 123 122 struct ina3221_data { ··· 128 123 struct regmap_field *fields[F_MAX_FIELDS]; 129 124 struct ina3221_input inputs[INA3221_NUM_CHANNELS]; 130 125 struct mutex lock; 126 + struct dentry *debugfs; 131 127 u32 reg_config; 132 128 int summation_shunt_resistor; 129 + u32 summation_channel_control; 133 130 134 131 bool single_shot; 135 132 }; ··· 161 154 int i, shunt_resistor = 0; 162 155 163 156 for (i = 0; i < INA3221_NUM_CHANNELS; i++) { 164 - if (input[i].disconnected || !input[i].shunt_resistor) 157 + if (input[i].disconnected || !input[i].shunt_resistor || 158 + input[i].summation_disable) 165 159 continue; 166 160 if (!shunt_resistor) { 167 161 /* Found the reference shunt resistor value */ ··· 794 786 /* Save the connected input label if available */ 795 787 of_property_read_string(child, "label", &input->label); 796 788 789 + /* summation channel control */ 790 + input->summation_disable = of_property_read_bool(child, "ti,summation-disable"); 791 + 797 792 /* Overwrite default shunt resistor value optionally */ 798 793 if (!of_property_read_u32(child, "shunt-resistor-micro-ohms", &val)) { 799 794 if (val < 1 || val > INT_MAX) { ··· 838 827 struct device *dev = &client->dev; 839 828 struct ina3221_data *ina; 840 829 struct device *hwmon_dev; 830 + char name[32]; 841 831 int i, ret; 842 832 843 833 ina = devm_kzalloc(dev, sizeof(*ina), GFP_KERNEL); ··· 885 873 886 874 /* Initialize summation_shunt_resistor for summation channel control */ 887 875 ina->summation_shunt_resistor = ina3221_summation_shunt_resistor(ina); 876 + for (i = 0; i < INA3221_NUM_CHANNELS; i++) { 877 + if (!ina->inputs[i].summation_disable) 878 + ina->summation_channel_control |= BIT(14 - i); 879 + } 888 880 889 881 ina->pm_dev = dev; 890 882 mutex_init(&ina->lock); ··· 916 900 goto fail; 917 901 } 918 902 903 + scnprintf(name, sizeof(name), "%s-%s", INA3221_DRIVER_NAME, dev_name(dev)); 904 + ina->debugfs = debugfs_create_dir(name, NULL); 905 + 906 + for (i = 0; i < INA3221_NUM_CHANNELS; i++) { 907 + scnprintf(name, sizeof(name), "in%d_summation_disable", i); 908 + debugfs_create_bool(name, 0400, ina->debugfs, 909 + &ina->inputs[i].summation_disable); 910 + } 911 + 919 912 return 0; 920 913 921 914 fail: ··· 942 917 { 943 918 struct ina3221_data *ina = dev_get_drvdata(&client->dev); 944 919 int i; 920 + 921 + debugfs_remove_recursive(ina->debugfs); 945 922 946 923 pm_runtime_disable(ina->pm_dev); 947 924 pm_runtime_set_suspended(ina->pm_dev); ··· 1005 978 /* Initialize summation channel control */ 1006 979 if (ina->summation_shunt_resistor) { 1007 980 /* 1008 - * Take all three channels into summation by default 981 + * Sum only channels that are not disabled for summation. 1009 982 * Shunt measurements of disconnected channels should 1010 983 * be 0, so it does not matter for summation. 1011 984 */ 1012 985 ret = regmap_update_bits(ina->regmap, INA3221_MASK_ENABLE, 1013 986 INA3221_MASK_ENABLE_SCC_MASK, 1014 - INA3221_MASK_ENABLE_SCC_MASK); 987 + ina->summation_channel_control); 1015 988 if (ret) { 1016 989 dev_err(dev, "Unable to control summation channel\n"); 1017 990 return ret;
+437
drivers/hwmon/ltc2991.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2023 Analog Devices, Inc. 4 + * Author: Antoniu Miclaus <antoniu.miclaus@analog.com> 5 + */ 6 + 7 + #include <linux/bitops.h> 8 + #include <linux/err.h> 9 + #include <linux/hwmon.h> 10 + #include <linux/i2c.h> 11 + #include <linux/kernel.h> 12 + #include <linux/module.h> 13 + #include <linux/property.h> 14 + #include <linux/regmap.h> 15 + #include <linux/regulator/consumer.h> 16 + 17 + #define LTC2991_STATUS_LOW 0x00 18 + #define LTC2991_CH_EN_TRIGGER 0x01 19 + #define LTC2991_V1_V4_CTRL 0x06 20 + #define LTC2991_V5_V8_CTRL 0x07 21 + #define LTC2991_PWM_TH_LSB_T_INT 0x08 22 + #define LTC2991_PWM_TH_MSB 0x09 23 + #define LTC2991_CHANNEL_V_MSB(x) (0x0A + ((x) * 2)) 24 + #define LTC2991_CHANNEL_T_MSB(x) (0x0A + ((x) * 4)) 25 + #define LTC2991_CHANNEL_C_MSB(x) (0x0C + ((x) * 4)) 26 + #define LTC2991_T_INT_MSB 0x1A 27 + #define LTC2991_VCC_MSB 0x1C 28 + 29 + #define LTC2991_V7_V8_EN BIT(7) 30 + #define LTC2991_V5_V6_EN BIT(6) 31 + #define LTC2991_V3_V4_EN BIT(5) 32 + #define LTC2991_V1_V2_EN BIT(4) 33 + #define LTC2991_T_INT_VCC_EN BIT(3) 34 + 35 + #define LTC2991_V3_V4_FILT_EN BIT(7) 36 + #define LTC2991_V3_V4_TEMP_EN BIT(5) 37 + #define LTC2991_V3_V4_DIFF_EN BIT(4) 38 + #define LTC2991_V1_V2_FILT_EN BIT(3) 39 + #define LTC2991_V1_V2_TEMP_EN BIT(1) 40 + #define LTC2991_V1_V2_DIFF_EN BIT(0) 41 + 42 + #define LTC2991_V7_V8_FILT_EN BIT(7) 43 + #define LTC2991_V7_V8_TEMP_EN BIT(5) 44 + #define LTC2991_V7_V8_DIFF_EN BIT(4) 45 + #define LTC2991_V5_V6_FILT_EN BIT(7) 46 + #define LTC2991_V5_V6_TEMP_EN BIT(5) 47 + #define LTC2991_V5_V6_DIFF_EN BIT(4) 48 + 49 + #define LTC2991_REPEAT_ACQ_EN BIT(4) 50 + #define LTC2991_T_INT_FILT_EN BIT(3) 51 + 52 + #define LTC2991_MAX_CHANNEL 4 53 + #define LTC2991_T_INT_CH_NR 4 54 + #define LTC2991_VCC_CH_NR 0 55 + 56 + struct ltc2991_state { 57 + struct device *dev; 58 + struct regmap *regmap; 59 + u32 r_sense_uohm[LTC2991_MAX_CHANNEL]; 60 + bool temp_en[LTC2991_MAX_CHANNEL]; 61 + }; 62 + 63 + static int ltc2991_read_reg(struct ltc2991_state *st, u8 addr, u8 reg_len, 64 + int *val) 65 + { 66 + __be16 regvals; 67 + int ret; 68 + 69 + if (reg_len < 2) 70 + return regmap_read(st->regmap, addr, val); 71 + 72 + ret = regmap_bulk_read(st->regmap, addr, &regvals, reg_len); 73 + if (ret) 74 + return ret; 75 + 76 + *val = be16_to_cpu(regvals); 77 + 78 + return 0; 79 + } 80 + 81 + static int ltc2991_get_voltage(struct ltc2991_state *st, u32 reg, long *val) 82 + { 83 + int reg_val, ret, offset = 0; 84 + 85 + ret = ltc2991_read_reg(st, reg, 2, &reg_val); 86 + if (ret) 87 + return ret; 88 + 89 + if (reg == LTC2991_VCC_MSB) 90 + /* Vcc 2.5V offset */ 91 + offset = 2500; 92 + 93 + /* Vx, 305.18uV/LSB */ 94 + *val = DIV_ROUND_CLOSEST(sign_extend32(reg_val, 14) * 30518, 95 + 1000 * 100) + offset; 96 + 97 + return 0; 98 + } 99 + 100 + static int ltc2991_read_in(struct device *dev, u32 attr, int channel, long *val) 101 + { 102 + struct ltc2991_state *st = dev_get_drvdata(dev); 103 + u32 reg; 104 + 105 + switch (attr) { 106 + case hwmon_in_input: 107 + if (channel == LTC2991_VCC_CH_NR) 108 + reg = LTC2991_VCC_MSB; 109 + else 110 + reg = LTC2991_CHANNEL_V_MSB(channel - 1); 111 + 112 + return ltc2991_get_voltage(st, reg, val); 113 + default: 114 + return -EOPNOTSUPP; 115 + } 116 + } 117 + 118 + static int ltc2991_get_curr(struct ltc2991_state *st, u32 reg, int channel, 119 + long *val) 120 + { 121 + int reg_val, ret; 122 + 123 + ret = ltc2991_read_reg(st, reg, 2, &reg_val); 124 + if (ret) 125 + return ret; 126 + 127 + /* Vx-Vy, 19.075uV/LSB */ 128 + *val = DIV_ROUND_CLOSEST(sign_extend32(reg_val, 14) * 19075, 129 + st->r_sense_uohm[channel]); 130 + 131 + return 0; 132 + } 133 + 134 + static int ltc2991_read_curr(struct device *dev, u32 attr, int channel, 135 + long *val) 136 + { 137 + struct ltc2991_state *st = dev_get_drvdata(dev); 138 + u32 reg; 139 + 140 + switch (attr) { 141 + case hwmon_curr_input: 142 + reg = LTC2991_CHANNEL_C_MSB(channel); 143 + return ltc2991_get_curr(st, reg, channel, val); 144 + default: 145 + return -EOPNOTSUPP; 146 + } 147 + } 148 + 149 + static int ltc2991_get_temp(struct ltc2991_state *st, u32 reg, int channel, 150 + long *val) 151 + { 152 + int reg_val, ret; 153 + 154 + ret = ltc2991_read_reg(st, reg, 2, &reg_val); 155 + if (ret) 156 + return ret; 157 + 158 + /* Temp LSB = 0.0625 Degrees */ 159 + *val = DIV_ROUND_CLOSEST(sign_extend32(reg_val, 12) * 1000, 16); 160 + 161 + return 0; 162 + } 163 + 164 + static int ltc2991_read_temp(struct device *dev, u32 attr, int channel, 165 + long *val) 166 + { 167 + struct ltc2991_state *st = dev_get_drvdata(dev); 168 + u32 reg; 169 + 170 + switch (attr) { 171 + case hwmon_temp_input: 172 + if (channel == LTC2991_T_INT_CH_NR) 173 + reg = LTC2991_T_INT_MSB; 174 + else 175 + reg = LTC2991_CHANNEL_T_MSB(channel); 176 + 177 + return ltc2991_get_temp(st, reg, channel, val); 178 + default: 179 + return -EOPNOTSUPP; 180 + } 181 + } 182 + 183 + static int ltc2991_read(struct device *dev, enum hwmon_sensor_types type, 184 + u32 attr, int channel, long *val) 185 + { 186 + switch (type) { 187 + case hwmon_in: 188 + return ltc2991_read_in(dev, attr, channel, val); 189 + case hwmon_curr: 190 + return ltc2991_read_curr(dev, attr, channel, val); 191 + case hwmon_temp: 192 + return ltc2991_read_temp(dev, attr, channel, val); 193 + default: 194 + return -EOPNOTSUPP; 195 + } 196 + } 197 + 198 + static umode_t ltc2991_is_visible(const void *data, 199 + enum hwmon_sensor_types type, u32 attr, 200 + int channel) 201 + { 202 + const struct ltc2991_state *st = data; 203 + 204 + switch (type) { 205 + case hwmon_in: 206 + switch (attr) { 207 + case hwmon_in_input: 208 + if (channel == LTC2991_VCC_CH_NR) 209 + return 0444; 210 + if (st->temp_en[(channel - 1) / 2]) 211 + break; 212 + if (channel % 2) 213 + return 0444; 214 + if (!st->r_sense_uohm[(channel - 1) / 2]) 215 + return 0444; 216 + } 217 + break; 218 + case hwmon_curr: 219 + switch (attr) { 220 + case hwmon_curr_input: 221 + if (st->r_sense_uohm[channel]) 222 + return 0444; 223 + break; 224 + } 225 + break; 226 + case hwmon_temp: 227 + switch (attr) { 228 + case hwmon_temp_input: 229 + if (st->temp_en[channel] || 230 + channel == LTC2991_T_INT_CH_NR) 231 + return 0444; 232 + break; 233 + } 234 + break; 235 + default: 236 + break; 237 + } 238 + 239 + return 0; 240 + } 241 + 242 + static const struct hwmon_ops ltc2991_hwmon_ops = { 243 + .is_visible = ltc2991_is_visible, 244 + .read = ltc2991_read, 245 + }; 246 + 247 + static const struct hwmon_channel_info *ltc2991_info[] = { 248 + HWMON_CHANNEL_INFO(temp, 249 + HWMON_T_INPUT, 250 + HWMON_T_INPUT, 251 + HWMON_T_INPUT, 252 + HWMON_T_INPUT, 253 + HWMON_T_INPUT 254 + ), 255 + HWMON_CHANNEL_INFO(curr, 256 + HWMON_C_INPUT, 257 + HWMON_C_INPUT, 258 + HWMON_C_INPUT, 259 + HWMON_C_INPUT 260 + ), 261 + HWMON_CHANNEL_INFO(in, 262 + HWMON_I_INPUT, 263 + HWMON_I_INPUT, 264 + HWMON_I_INPUT, 265 + HWMON_I_INPUT, 266 + HWMON_I_INPUT, 267 + HWMON_I_INPUT, 268 + HWMON_I_INPUT, 269 + HWMON_I_INPUT, 270 + HWMON_I_INPUT 271 + ), 272 + NULL 273 + }; 274 + 275 + static const struct hwmon_chip_info ltc2991_chip_info = { 276 + .ops = &ltc2991_hwmon_ops, 277 + .info = ltc2991_info, 278 + }; 279 + 280 + static const struct regmap_config ltc2991_regmap_config = { 281 + .reg_bits = 8, 282 + .val_bits = 8, 283 + .max_register = 0x1D, 284 + }; 285 + 286 + static int ltc2991_init(struct ltc2991_state *st) 287 + { 288 + struct fwnode_handle *child; 289 + int ret; 290 + u32 val, addr; 291 + u8 v5_v8_reg_data = 0, v1_v4_reg_data = 0; 292 + 293 + ret = devm_regulator_get_enable(st->dev, "vcc"); 294 + if (ret) 295 + return dev_err_probe(st->dev, ret, 296 + "failed to enable regulator\n"); 297 + 298 + device_for_each_child_node(st->dev, child) { 299 + ret = fwnode_property_read_u32(child, "reg", &addr); 300 + if (ret < 0) { 301 + fwnode_handle_put(child); 302 + return ret; 303 + } 304 + 305 + if (addr > 3) { 306 + fwnode_handle_put(child); 307 + return -EINVAL; 308 + } 309 + 310 + ret = fwnode_property_read_u32(child, 311 + "shunt-resistor-micro-ohms", 312 + &val); 313 + if (!ret) { 314 + if (!val) 315 + return dev_err_probe(st->dev, -EINVAL, 316 + "shunt resistor value cannot be zero\n"); 317 + 318 + st->r_sense_uohm[addr] = val; 319 + 320 + switch (addr) { 321 + case 0: 322 + v1_v4_reg_data |= LTC2991_V1_V2_DIFF_EN; 323 + break; 324 + case 1: 325 + v1_v4_reg_data |= LTC2991_V3_V4_DIFF_EN; 326 + break; 327 + case 2: 328 + v5_v8_reg_data |= LTC2991_V5_V6_DIFF_EN; 329 + break; 330 + case 3: 331 + v5_v8_reg_data |= LTC2991_V7_V8_DIFF_EN; 332 + break; 333 + default: 334 + break; 335 + } 336 + } 337 + 338 + ret = fwnode_property_read_bool(child, 339 + "adi,temperature-enable"); 340 + if (ret) { 341 + st->temp_en[addr] = ret; 342 + 343 + switch (addr) { 344 + case 0: 345 + v1_v4_reg_data |= LTC2991_V1_V2_TEMP_EN; 346 + break; 347 + case 1: 348 + v1_v4_reg_data |= LTC2991_V3_V4_TEMP_EN; 349 + break; 350 + case 2: 351 + v5_v8_reg_data |= LTC2991_V5_V6_TEMP_EN; 352 + break; 353 + case 3: 354 + v5_v8_reg_data |= LTC2991_V7_V8_TEMP_EN; 355 + break; 356 + default: 357 + break; 358 + } 359 + } 360 + } 361 + 362 + ret = regmap_write(st->regmap, LTC2991_V5_V8_CTRL, v5_v8_reg_data); 363 + if (ret) 364 + return dev_err_probe(st->dev, ret, 365 + "Error: Failed to set V5-V8 CTRL reg.\n"); 366 + 367 + ret = regmap_write(st->regmap, LTC2991_V1_V4_CTRL, v1_v4_reg_data); 368 + if (ret) 369 + return dev_err_probe(st->dev, ret, 370 + "Error: Failed to set V1-V4 CTRL reg.\n"); 371 + 372 + ret = regmap_write(st->regmap, LTC2991_PWM_TH_LSB_T_INT, 373 + LTC2991_REPEAT_ACQ_EN); 374 + if (ret) 375 + return dev_err_probe(st->dev, ret, 376 + "Error: Failed to set contiuous mode.\n"); 377 + 378 + /* Enable all channels and trigger conversions */ 379 + return regmap_write(st->regmap, LTC2991_CH_EN_TRIGGER, 380 + LTC2991_V7_V8_EN | LTC2991_V5_V6_EN | 381 + LTC2991_V3_V4_EN | LTC2991_V1_V2_EN | 382 + LTC2991_T_INT_VCC_EN); 383 + } 384 + 385 + static int ltc2991_i2c_probe(struct i2c_client *client) 386 + { 387 + int ret; 388 + struct device *hwmon_dev; 389 + struct ltc2991_state *st; 390 + 391 + st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL); 392 + if (!st) 393 + return -ENOMEM; 394 + 395 + st->dev = &client->dev; 396 + st->regmap = devm_regmap_init_i2c(client, &ltc2991_regmap_config); 397 + if (IS_ERR(st->regmap)) 398 + return PTR_ERR(st->regmap); 399 + 400 + ret = ltc2991_init(st); 401 + if (ret) 402 + return ret; 403 + 404 + hwmon_dev = devm_hwmon_device_register_with_info(&client->dev, 405 + client->name, st, 406 + &ltc2991_chip_info, 407 + NULL); 408 + 409 + return PTR_ERR_OR_ZERO(hwmon_dev); 410 + } 411 + 412 + static const struct of_device_id ltc2991_of_match[] = { 413 + { .compatible = "adi,ltc2991" }, 414 + { } 415 + }; 416 + MODULE_DEVICE_TABLE(of, ltc2991_of_match); 417 + 418 + static const struct i2c_device_id ltc2991_i2c_id[] = { 419 + { "ltc2991", 0 }, 420 + {} 421 + }; 422 + MODULE_DEVICE_TABLE(i2c, ltc2991_i2c_id); 423 + 424 + static struct i2c_driver ltc2991_i2c_driver = { 425 + .driver = { 426 + .name = "ltc2991", 427 + .of_match_table = ltc2991_of_match, 428 + }, 429 + .probe = ltc2991_i2c_probe, 430 + .id_table = ltc2991_i2c_id, 431 + }; 432 + 433 + module_i2c_driver(ltc2991_i2c_driver); 434 + 435 + MODULE_AUTHOR("Antoniu Miclaus <antoniu.miclaus@analog.com>"); 436 + MODULE_DESCRIPTION("Analog Devices LTC2991 HWMON Driver"); 437 + MODULE_LICENSE("GPL");
+5 -1
drivers/hwmon/ltc2992.c
··· 875 875 } 876 876 877 877 ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val); 878 - if (!ret) 878 + if (!ret) { 879 + if (!val) 880 + return dev_err_probe(&st->client->dev, -EINVAL, 881 + "shunt resistor value cannot be zero\n"); 879 882 st->r_sense_uohm[addr] = val; 883 + } 880 884 } 881 885 882 886 return 0;
+2 -4
drivers/hwmon/max197.c
··· 312 312 return ret; 313 313 } 314 314 315 - static int max197_remove(struct platform_device *pdev) 315 + static void max197_remove(struct platform_device *pdev) 316 316 { 317 317 struct max197_data *data = platform_get_drvdata(pdev); 318 318 319 319 hwmon_device_unregister(data->hwmon_dev); 320 320 sysfs_remove_group(&pdev->dev.kobj, &max197_sysfs_group); 321 - 322 - return 0; 323 321 } 324 322 325 323 static const struct platform_device_id max197_device_ids[] = { ··· 332 334 .name = "max197", 333 335 }, 334 336 .probe = max197_probe, 335 - .remove = max197_remove, 337 + .remove_new = max197_remove, 336 338 .id_table = max197_device_ids, 337 339 }; 338 340 module_platform_driver(max197_driver);
+60 -71
drivers/hwmon/max31827.c
··· 25 25 #define MAX31827_CONFIGURATION_U_TEMP_STAT_MASK BIT(14) 26 26 #define MAX31827_CONFIGURATION_O_TEMP_STAT_MASK BIT(15) 27 27 28 - #define MAX31827_12_BIT_CNV_TIME 141 29 - 30 - #define MAX31827_CNV_1_DIV_64_HZ 0x1 31 - #define MAX31827_CNV_1_DIV_32_HZ 0x2 32 - #define MAX31827_CNV_1_DIV_16_HZ 0x3 33 - #define MAX31827_CNV_1_DIV_4_HZ 0x4 34 - #define MAX31827_CNV_1_HZ 0x5 35 - #define MAX31827_CNV_4_HZ 0x6 36 - #define MAX31827_CNV_8_HZ 0x7 28 + #define MAX31827_12_BIT_CNV_TIME 140 37 29 38 30 #define MAX31827_16_BIT_TO_M_DGR(x) (sign_extend32(x, 15) * 1000 / 16) 39 31 #define MAX31827_M_DGR_TO_16_BIT(x) (((x) << 4) / 1000) 40 32 #define MAX31827_DEVICE_ENABLE(x) ((x) ? 0xA : 0x0) 33 + 34 + enum max31827_cnv { 35 + MAX31827_CNV_1_DIV_64_HZ = 1, 36 + MAX31827_CNV_1_DIV_32_HZ, 37 + MAX31827_CNV_1_DIV_16_HZ, 38 + MAX31827_CNV_1_DIV_4_HZ, 39 + MAX31827_CNV_1_HZ, 40 + MAX31827_CNV_4_HZ, 41 + MAX31827_CNV_8_HZ, 42 + }; 43 + 44 + static const u16 max31827_conversions[] = { 45 + [MAX31827_CNV_1_DIV_64_HZ] = 64000, 46 + [MAX31827_CNV_1_DIV_32_HZ] = 32000, 47 + [MAX31827_CNV_1_DIV_16_HZ] = 16000, 48 + [MAX31827_CNV_1_DIV_4_HZ] = 4000, 49 + [MAX31827_CNV_1_HZ] = 1000, 50 + [MAX31827_CNV_4_HZ] = 250, 51 + [MAX31827_CNV_8_HZ] = 125, 52 + }; 41 53 42 54 struct max31827_state { 43 55 /* ··· 66 54 .max_register = 0xA, 67 55 }; 68 56 69 - static int write_alarm_val(struct max31827_state *st, unsigned int reg, 70 - long val) 57 + static int shutdown_write(struct max31827_state *st, unsigned int reg, 58 + unsigned int val) 71 59 { 72 60 unsigned int cfg; 73 - unsigned int tmp; 61 + unsigned int cnv_rate; 74 62 int ret; 75 - 76 - val = MAX31827_M_DGR_TO_16_BIT(val); 77 63 78 64 /* 79 65 * Before the Temperature Threshold Alarm and Alarm Hysteresis Threshold ··· 92 82 if (ret) 93 83 goto unlock; 94 84 95 - tmp = cfg & ~(MAX31827_CONFIGURATION_1SHOT_MASK | 85 + cnv_rate = MAX31827_CONFIGURATION_CNV_RATE_MASK & cfg; 86 + cfg = cfg & ~(MAX31827_CONFIGURATION_1SHOT_MASK | 96 87 MAX31827_CONFIGURATION_CNV_RATE_MASK); 97 - ret = regmap_write(st->regmap, MAX31827_CONFIGURATION_REG, tmp); 88 + ret = regmap_write(st->regmap, MAX31827_CONFIGURATION_REG, cfg); 98 89 if (ret) 99 90 goto unlock; 100 91 ··· 103 92 if (ret) 104 93 goto unlock; 105 94 106 - ret = regmap_write(st->regmap, MAX31827_CONFIGURATION_REG, cfg); 95 + ret = regmap_update_bits(st->regmap, MAX31827_CONFIGURATION_REG, 96 + MAX31827_CONFIGURATION_CNV_RATE_MASK, 97 + cnv_rate); 107 98 108 99 unlock: 109 100 mutex_unlock(&st->lock); 110 101 return ret; 102 + } 103 + 104 + static int write_alarm_val(struct max31827_state *st, unsigned int reg, 105 + long val) 106 + { 107 + val = MAX31827_M_DGR_TO_16_BIT(val); 108 + 109 + return shutdown_write(st, reg, val); 111 110 } 112 111 113 112 static umode_t max31827_is_visible(const void *state, ··· 264 243 265 244 uval = FIELD_GET(MAX31827_CONFIGURATION_CNV_RATE_MASK, 266 245 uval); 267 - switch (uval) { 268 - case MAX31827_CNV_1_DIV_64_HZ: 269 - *val = 64000; 270 - break; 271 - case MAX31827_CNV_1_DIV_32_HZ: 272 - *val = 32000; 273 - break; 274 - case MAX31827_CNV_1_DIV_16_HZ: 275 - *val = 16000; 276 - break; 277 - case MAX31827_CNV_1_DIV_4_HZ: 278 - *val = 4000; 279 - break; 280 - case MAX31827_CNV_1_HZ: 281 - *val = 1000; 282 - break; 283 - case MAX31827_CNV_4_HZ: 284 - *val = 250; 285 - break; 286 - case MAX31827_CNV_8_HZ: 287 - *val = 125; 288 - break; 289 - default: 290 - *val = 0; 291 - break; 292 - } 246 + *val = max31827_conversions[uval]; 293 247 } 294 248 break; 295 249 ··· 280 284 u32 attr, int channel, long val) 281 285 { 282 286 struct max31827_state *st = dev_get_drvdata(dev); 287 + int res = 1; 283 288 int ret; 284 289 285 290 switch (type) { ··· 330 333 if (!st->enable) 331 334 return -EINVAL; 332 335 333 - switch (val) { 334 - case 125: 335 - val = MAX31827_CNV_8_HZ; 336 - break; 337 - case 250: 338 - val = MAX31827_CNV_4_HZ; 339 - break; 340 - case 1000: 341 - val = MAX31827_CNV_1_HZ; 342 - break; 343 - case 4000: 344 - val = MAX31827_CNV_1_DIV_4_HZ; 345 - break; 346 - case 16000: 347 - val = MAX31827_CNV_1_DIV_16_HZ; 348 - break; 349 - case 32000: 350 - val = MAX31827_CNV_1_DIV_32_HZ; 351 - break; 352 - case 64000: 353 - val = MAX31827_CNV_1_DIV_64_HZ; 354 - break; 355 - default: 356 - return -EINVAL; 357 - } 336 + /* 337 + * Convert the desired conversion rate into register 338 + * bits. res is already initialized with 1. 339 + * 340 + * This was inspired by lm73 driver. 341 + */ 342 + while (res < ARRAY_SIZE(max31827_conversions) && 343 + val < max31827_conversions[res]) 344 + res++; 358 345 359 - val = FIELD_PREP(MAX31827_CONFIGURATION_CNV_RATE_MASK, 360 - val); 346 + if (res == ARRAY_SIZE(max31827_conversions) || 347 + val != max31827_conversions[res]) 348 + return -EINVAL; 349 + 350 + res = FIELD_PREP(MAX31827_CONFIGURATION_CNV_RATE_MASK, 351 + res); 361 352 362 353 return regmap_update_bits(st->regmap, 363 354 MAX31827_CONFIGURATION_REG, 364 355 MAX31827_CONFIGURATION_CNV_RATE_MASK, 365 - val); 356 + res); 366 357 } 367 358 break; 368 359 ··· 411 426 if (IS_ERR(st->regmap)) 412 427 return dev_err_probe(dev, PTR_ERR(st->regmap), 413 428 "Failed to allocate regmap.\n"); 429 + 430 + err = devm_regulator_get_enable(dev, "vref"); 431 + if (err) 432 + return dev_err_probe(dev, err, "failed to enable regulator\n"); 414 433 415 434 err = max31827_init_client(st); 416 435 if (err)
+2 -4
drivers/hwmon/mc13783-adc.c
··· 285 285 return ret; 286 286 } 287 287 288 - static int mc13783_adc_remove(struct platform_device *pdev) 288 + static void mc13783_adc_remove(struct platform_device *pdev) 289 289 { 290 290 struct mc13783_adc_priv *priv = platform_get_drvdata(pdev); 291 291 kernel_ulong_t driver_data = platform_get_device_id(pdev)->driver_data; ··· 299 299 sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_16chans); 300 300 301 301 sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_base); 302 - 303 - return 0; 304 302 } 305 303 306 304 static const struct platform_device_id mc13783_adc_idtable[] = { ··· 315 317 MODULE_DEVICE_TABLE(platform, mc13783_adc_idtable); 316 318 317 319 static struct platform_driver mc13783_adc_driver = { 318 - .remove = mc13783_adc_remove, 320 + .remove_new = mc13783_adc_remove, 319 321 .driver = { 320 322 .name = DRIVER_NAME, 321 323 },
+3
drivers/hwmon/nct6683.c
··· 176 176 #define NCT6683_CUSTOMER_ID_MSI2 0x200 177 177 #define NCT6683_CUSTOMER_ID_ASROCK 0xe2c 178 178 #define NCT6683_CUSTOMER_ID_ASROCK2 0xe1b 179 + #define NCT6683_CUSTOMER_ID_ASROCK3 0x1631 179 180 180 181 #define NCT6683_REG_BUILD_YEAR 0x604 181 182 #define NCT6683_REG_BUILD_MONTH 0x605 ··· 1227 1226 case NCT6683_CUSTOMER_ID_ASROCK: 1228 1227 break; 1229 1228 case NCT6683_CUSTOMER_ID_ASROCK2: 1229 + break; 1230 + case NCT6683_CUSTOMER_ID_ASROCK3: 1230 1231 break; 1231 1232 default: 1232 1233 if (!force)
+8 -4
drivers/hwmon/nct6775-core.c
··· 1614 1614 data->fan_div[i]); 1615 1615 1616 1616 if (data->has_fan_min & BIT(i)) { 1617 - err = nct6775_read_value(data, data->REG_FAN_MIN[i], &reg); 1617 + u16 tmp; 1618 + 1619 + err = nct6775_read_value(data, data->REG_FAN_MIN[i], &tmp); 1618 1620 if (err) 1619 1621 goto out; 1620 - data->fan_min[i] = reg; 1622 + data->fan_min[i] = tmp; 1621 1623 } 1622 1624 1623 1625 if (data->REG_FAN_PULSES[i]) { 1624 - err = nct6775_read_value(data, data->REG_FAN_PULSES[i], &reg); 1626 + u16 tmp; 1627 + 1628 + err = nct6775_read_value(data, data->REG_FAN_PULSES[i], &tmp); 1625 1629 if (err) 1626 1630 goto out; 1627 - data->fan_pulses[i] = (reg >> data->FAN_PULSE_SHIFT[i]) & 0x03; 1631 + data->fan_pulses[i] = (tmp >> data->FAN_PULSE_SHIFT[i]) & 0x03; 1628 1632 } 1629 1633 1630 1634 err = nct6775_select_fan_div(dev, data, i, reg);
+1 -3
drivers/hwmon/nct6775-platform.c
··· 1465 1465 static int nct6775_asuswmi_device_match(struct device *dev, void *data) 1466 1466 { 1467 1467 struct acpi_device *adev = to_acpi_device(dev); 1468 - const char *uid = acpi_device_uid(adev); 1469 - const char *hid = acpi_device_hid(adev); 1470 1468 1471 - if (hid && !strcmp(hid, ASUSWMI_DEVICE_HID) && uid && !strcmp(uid, data)) { 1469 + if (acpi_dev_hid_uid_match(adev, ASUSWMI_DEVICE_HID, data)) { 1472 1470 asus_acpi_dev = adev; 1473 1471 return 1; 1474 1472 }
+2
drivers/hwmon/npcm750-pwm-fan.c
··· 875 875 data->pwm_present[pwm_port] = true; 876 876 ret = npcm7xx_pwm_config_set(data, pwm_port, 877 877 NPCM7XX_PWM_CMR_DEFAULT_NUM); 878 + if (ret) 879 + return ret; 878 880 879 881 ret = of_property_count_u8_elems(child, "cooling-levels"); 880 882 if (ret > 0) {
+2 -4
drivers/hwmon/occ/p9_sbe.c
··· 167 167 return rc; 168 168 } 169 169 170 - static int p9_sbe_occ_remove(struct platform_device *pdev) 170 + static void p9_sbe_occ_remove(struct platform_device *pdev) 171 171 { 172 172 struct occ *occ = platform_get_drvdata(pdev); 173 173 struct p9_sbe_occ *ctx = to_p9_sbe_occ(occ); ··· 178 178 occ_shutdown(occ); 179 179 180 180 kvfree(ctx->ffdc); 181 - 182 - return 0; 183 181 } 184 182 185 183 static const struct of_device_id p9_sbe_occ_of_match[] = { ··· 193 195 .of_match_table = p9_sbe_occ_of_match, 194 196 }, 195 197 .probe = p9_sbe_occ_probe, 196 - .remove = p9_sbe_occ_remove, 198 + .remove_new = p9_sbe_occ_remove, 197 199 }; 198 200 199 201 module_platform_driver(p9_sbe_occ_driver);
+2 -4
drivers/hwmon/pc87360.c
··· 1586 1586 return err; 1587 1587 } 1588 1588 1589 - static int pc87360_remove(struct platform_device *pdev) 1589 + static void pc87360_remove(struct platform_device *pdev) 1590 1590 { 1591 1591 struct pc87360_data *data = platform_get_drvdata(pdev); 1592 1592 1593 1593 hwmon_device_unregister(data->hwmon_dev); 1594 1594 pc87360_remove_files(&pdev->dev); 1595 - 1596 - return 0; 1597 1595 } 1598 1596 1599 1597 /* ··· 1602 1604 .name = DRIVER_NAME, 1603 1605 }, 1604 1606 .probe = pc87360_probe, 1605 - .remove = pc87360_remove, 1607 + .remove_new = pc87360_remove, 1606 1608 }; 1607 1609 1608 1610 /*
+2 -4
drivers/hwmon/pc87427.c
··· 1115 1115 return err; 1116 1116 } 1117 1117 1118 - static int pc87427_remove(struct platform_device *pdev) 1118 + static void pc87427_remove(struct platform_device *pdev) 1119 1119 { 1120 1120 struct pc87427_data *data = platform_get_drvdata(pdev); 1121 1121 1122 1122 hwmon_device_unregister(data->hwmon_dev); 1123 1123 pc87427_remove_files(&pdev->dev); 1124 - 1125 - return 0; 1126 1124 } 1127 1125 1128 1126 ··· 1129 1131 .name = DRVNAME, 1130 1132 }, 1131 1133 .probe = pc87427_probe, 1132 - .remove = pc87427_remove, 1134 + .remove_new = pc87427_remove, 1133 1135 }; 1134 1136 1135 1137 static int __init pc87427_device_add(const struct pc87427_sio_data *sio_data)
+167 -21
drivers/hwmon/pmbus/max31785.c
··· 3 3 * Copyright (C) 2017 IBM Corp. 4 4 */ 5 5 6 + #include <linux/delay.h> 6 7 #include <linux/kernel.h> 7 8 #include <linux/module.h> 8 9 #include <linux/init.h> ··· 24 23 25 24 #define MAX31785_NR_PAGES 23 26 25 #define MAX31785_NR_FAN_PAGES 6 26 + #define MAX31785_WAIT_DELAY_US 250 27 27 28 - static int max31785_read_byte_data(struct i2c_client *client, int page, 29 - int reg) 28 + struct max31785_data { 29 + ktime_t access; /* Chip access time */ 30 + struct pmbus_driver_info info; 31 + }; 32 + 33 + #define to_max31785_data(x) container_of(x, struct max31785_data, info) 34 + 35 + /* 36 + * MAX31785 Driver Workaround 37 + * 38 + * The MAX31785 fan controller occasionally exhibits communication issues. 39 + * These issues are not indicated by the device itself, except for occasional 40 + * NACK responses during master transactions. No error bits are set in STATUS_BYTE. 41 + * 42 + * To address this, we introduce a delay of 250us between consecutive accesses 43 + * to the fan controller. This delay helps mitigate communication problems by 44 + * allowing sufficient time between accesses. 45 + */ 46 + static inline void max31785_wait(const struct max31785_data *data) 30 47 { 31 - if (page < MAX31785_NR_PAGES) 32 - return -ENODATA; 48 + s64 delta = ktime_us_delta(ktime_get(), data->access); 49 + 50 + if (delta < MAX31785_WAIT_DELAY_US) 51 + usleep_range(MAX31785_WAIT_DELAY_US - delta, 52 + MAX31785_WAIT_DELAY_US); 53 + } 54 + 55 + static int max31785_i2c_write_byte_data(struct i2c_client *client, 56 + struct max31785_data *driver_data, 57 + int command, u16 data) 58 + { 59 + int rc; 60 + 61 + max31785_wait(driver_data); 62 + rc = i2c_smbus_write_byte_data(client, command, data); 63 + driver_data->access = ktime_get(); 64 + return rc; 65 + } 66 + 67 + static int max31785_i2c_read_word_data(struct i2c_client *client, 68 + struct max31785_data *driver_data, 69 + int command) 70 + { 71 + int rc; 72 + 73 + max31785_wait(driver_data); 74 + rc = i2c_smbus_read_word_data(client, command); 75 + driver_data->access = ktime_get(); 76 + return rc; 77 + } 78 + 79 + static int _max31785_read_byte_data(struct i2c_client *client, 80 + struct max31785_data *driver_data, 81 + int page, int command) 82 + { 83 + int rc; 84 + 85 + max31785_wait(driver_data); 86 + rc = pmbus_read_byte_data(client, page, command); 87 + driver_data->access = ktime_get(); 88 + return rc; 89 + } 90 + 91 + static int _max31785_write_byte_data(struct i2c_client *client, 92 + struct max31785_data *driver_data, 93 + int page, int command, u16 data) 94 + { 95 + int rc; 96 + 97 + max31785_wait(driver_data); 98 + rc = pmbus_write_byte_data(client, page, command, data); 99 + driver_data->access = ktime_get(); 100 + return rc; 101 + } 102 + 103 + static int _max31785_read_word_data(struct i2c_client *client, 104 + struct max31785_data *driver_data, 105 + int page, int phase, int command) 106 + { 107 + int rc; 108 + 109 + max31785_wait(driver_data); 110 + rc = pmbus_read_word_data(client, page, phase, command); 111 + driver_data->access = ktime_get(); 112 + return rc; 113 + } 114 + 115 + static int _max31785_write_word_data(struct i2c_client *client, 116 + struct max31785_data *driver_data, 117 + int page, int command, u16 data) 118 + { 119 + int rc; 120 + 121 + max31785_wait(driver_data); 122 + rc = pmbus_write_word_data(client, page, command, data); 123 + driver_data->access = ktime_get(); 124 + return rc; 125 + } 126 + 127 + static int max31785_read_byte_data(struct i2c_client *client, int page, int reg) 128 + { 129 + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 130 + struct max31785_data *driver_data = to_max31785_data(info); 33 131 34 132 switch (reg) { 35 133 case PMBUS_VOUT_MODE: 36 134 return -ENOTSUPP; 37 135 case PMBUS_FAN_CONFIG_12: 38 - return pmbus_read_byte_data(client, page - MAX31785_NR_PAGES, 39 - reg); 136 + return _max31785_read_byte_data(client, driver_data, 137 + page - MAX31785_NR_PAGES, 138 + reg); 40 139 } 41 140 42 141 return -ENODATA; ··· 203 102 return rv; 204 103 } 205 104 206 - static int max31785_get_pwm_mode(struct i2c_client *client, int page) 105 + static int max31785_get_pwm_mode(struct i2c_client *client, 106 + struct max31785_data *driver_data, int page) 207 107 { 208 108 int config; 209 109 int command; 210 110 211 - config = pmbus_read_byte_data(client, page, PMBUS_FAN_CONFIG_12); 111 + config = _max31785_read_byte_data(client, driver_data, page, 112 + PMBUS_FAN_CONFIG_12); 212 113 if (config < 0) 213 114 return config; 214 115 215 - command = pmbus_read_word_data(client, page, 0xff, PMBUS_FAN_COMMAND_1); 116 + command = _max31785_read_word_data(client, driver_data, page, 0xff, 117 + PMBUS_FAN_COMMAND_1); 216 118 if (command < 0) 217 119 return command; 218 120 ··· 233 129 static int max31785_read_word_data(struct i2c_client *client, int page, 234 130 int phase, int reg) 235 131 { 132 + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 133 + struct max31785_data *driver_data = to_max31785_data(info); 236 134 u32 val; 237 135 int rv; 238 136 ··· 263 157 rv = max31785_get_pwm(client, page); 264 158 break; 265 159 case PMBUS_VIRT_PWM_ENABLE_1: 266 - rv = max31785_get_pwm_mode(client, page); 160 + rv = max31785_get_pwm_mode(client, driver_data, page); 267 161 break; 268 162 default: 269 163 rv = -ENODATA; ··· 294 188 return (sensor_val * 100) / 255; 295 189 } 296 190 297 - static int max31785_pwm_enable(struct i2c_client *client, int page, 298 - u16 word) 191 + static int max31785_update_fan(struct i2c_client *client, 192 + struct max31785_data *driver_data, int page, 193 + u8 config, u8 mask, u16 command) 194 + { 195 + int from, rv; 196 + u8 to; 197 + 198 + from = _max31785_read_byte_data(client, driver_data, page, 199 + PMBUS_FAN_CONFIG_12); 200 + if (from < 0) 201 + return from; 202 + 203 + to = (from & ~mask) | (config & mask); 204 + 205 + if (to != from) { 206 + rv = _max31785_write_byte_data(client, driver_data, page, 207 + PMBUS_FAN_CONFIG_12, to); 208 + if (rv < 0) 209 + return rv; 210 + } 211 + 212 + rv = _max31785_write_word_data(client, driver_data, page, 213 + PMBUS_FAN_COMMAND_1, command); 214 + 215 + return rv; 216 + } 217 + 218 + static int max31785_pwm_enable(struct i2c_client *client, 219 + struct max31785_data *driver_data, int page, 220 + u16 word) 299 221 { 300 222 int config = 0; 301 223 int rate; ··· 351 217 return -EINVAL; 352 218 } 353 219 354 - return pmbus_update_fan(client, page, 0, config, PB_FAN_1_RPM, rate); 220 + return max31785_update_fan(client, driver_data, page, config, 221 + PB_FAN_1_RPM, rate); 355 222 } 356 223 357 224 static int max31785_write_word_data(struct i2c_client *client, int page, 358 225 int reg, u16 word) 359 226 { 227 + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 228 + struct max31785_data *driver_data = to_max31785_data(info); 229 + 360 230 switch (reg) { 361 231 case PMBUS_VIRT_PWM_1: 362 - return pmbus_update_fan(client, page, 0, 0, PB_FAN_1_RPM, 363 - max31785_scale_pwm(word)); 232 + return max31785_update_fan(client, driver_data, page, 0, 233 + PB_FAN_1_RPM, 234 + max31785_scale_pwm(word)); 364 235 case PMBUS_VIRT_PWM_ENABLE_1: 365 - return max31785_pwm_enable(client, page, word); 236 + return max31785_pwm_enable(client, driver_data, page, word); 366 237 default: 367 238 break; 368 239 } ··· 442 303 { 443 304 int ret; 444 305 int i; 306 + struct max31785_data *driver_data = to_max31785_data(info); 445 307 446 308 for (i = 0; i < MAX31785_NR_FAN_PAGES; i++) { 447 - ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i); 309 + ret = max31785_i2c_write_byte_data(client, driver_data, 310 + PMBUS_PAGE, i); 448 311 if (ret < 0) 449 312 return ret; 450 313 451 - ret = i2c_smbus_read_word_data(client, MFR_FAN_CONFIG); 314 + ret = max31785_i2c_read_word_data(client, driver_data, 315 + MFR_FAN_CONFIG); 452 316 if (ret < 0) 453 317 return ret; 454 318 ··· 471 329 { 472 330 struct device *dev = &client->dev; 473 331 struct pmbus_driver_info *info; 332 + struct max31785_data *driver_data; 474 333 bool dual_tach = false; 475 334 int ret; 476 335 ··· 480 337 I2C_FUNC_SMBUS_WORD_DATA)) 481 338 return -ENODEV; 482 339 483 - info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL); 484 - if (!info) 340 + driver_data = devm_kzalloc(dev, sizeof(struct max31785_data), GFP_KERNEL); 341 + if (!driver_data) 485 342 return -ENOMEM; 486 343 344 + info = &driver_data->info; 345 + driver_data->access = ktime_get(); 487 346 *info = max31785_info; 488 347 489 - ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 255); 348 + ret = max31785_i2c_write_byte_data(client, driver_data, 349 + PMBUS_PAGE, 255); 490 350 if (ret < 0) 491 351 return ret; 492 352
+5 -5
drivers/hwmon/pmbus/mp2975.c
··· 297 297 int ret; 298 298 299 299 switch (reg) { 300 + case PMBUS_STATUS_WORD: 301 + /* MP2973 & MP2971 return PGOOD instead of PB_STATUS_POWER_GOOD_N. */ 302 + ret = pmbus_read_word_data(client, page, phase, reg); 303 + ret ^= PB_STATUS_POWER_GOOD_N; 304 + break; 300 305 case PMBUS_OT_FAULT_LIMIT: 301 306 ret = mp2975_read_word_helper(client, page, phase, reg, 302 307 GENMASK(7, 0)); ··· 385 380 int ret; 386 381 387 382 switch (reg) { 388 - case PMBUS_STATUS_WORD: 389 - /* MP2973 & MP2971 return PGOOD instead of PB_STATUS_POWER_GOOD_N. */ 390 - ret = pmbus_read_word_data(client, page, phase, reg); 391 - ret ^= PB_STATUS_POWER_GOOD_N; 392 - break; 393 383 case PMBUS_OT_FAULT_LIMIT: 394 384 ret = mp2975_read_word_helper(client, page, phase, reg, 395 385 GENMASK(7, 0));
+15 -4
drivers/hwmon/pmbus/mpq7932.c
··· 21 21 #define MPQ7932_N_VOLTAGES 256 22 22 #define MPQ7932_VOUT_MAX 0xFF 23 23 #define MPQ7932_NUM_PAGES 6 24 + #define MPQ2286_NUM_PAGES 1 24 25 25 26 #define MPQ7932_TON_DELAY 0x60 26 27 #define MPQ7932_VOUT_STARTUP_SLEW 0xA3 ··· 48 47 MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN), 49 48 PMBUS_REGULATOR_STEP("buck", 5, MPQ7932_N_VOLTAGES, 50 49 MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN), 50 + }; 51 + 52 + static const struct regulator_desc mpq7932_regulators_desc_one[] = { 53 + PMBUS_REGULATOR_STEP_ONE("buck", MPQ7932_N_VOLTAGES, 54 + MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN), 51 55 }; 52 56 #endif 53 57 ··· 111 105 return -ENOMEM; 112 106 113 107 info = &data->info; 114 - info->pages = MPQ7932_NUM_PAGES; 108 + info->pages = (int)(unsigned long)device_get_match_data(&client->dev); 115 109 info->format[PSC_VOLTAGE_OUT] = direct; 116 110 info->m[PSC_VOLTAGE_OUT] = 160; 117 111 info->b[PSC_VOLTAGE_OUT] = -33; ··· 121 115 } 122 116 123 117 #if IS_ENABLED(CONFIG_SENSORS_MPQ7932_REGULATOR) 124 - info->num_regulators = ARRAY_SIZE(mpq7932_regulators_desc); 125 - info->reg_desc = mpq7932_regulators_desc; 118 + info->num_regulators = info->pages; 119 + if (info->num_regulators == 1) 120 + info->reg_desc = mpq7932_regulators_desc_one; 121 + else 122 + info->reg_desc = mpq7932_regulators_desc; 126 123 #endif 127 124 128 125 info->read_word_data = mpq7932_read_word_data; ··· 138 129 } 139 130 140 131 static const struct of_device_id mpq7932_of_match[] = { 141 - { .compatible = "mps,mpq7932"}, 132 + { .compatible = "mps,mpq2286", .data = (void *)MPQ2286_NUM_PAGES }, 133 + { .compatible = "mps,mpq7932", .data = (void *)MPQ7932_NUM_PAGES }, 142 134 {}, 143 135 }; 144 136 MODULE_DEVICE_TABLE(of, mpq7932_of_match); 145 137 146 138 static const struct i2c_device_id mpq7932_id[] = { 139 + { "mpq2286", }, 147 140 { "mpq7932", }, 148 141 { }, 149 142 };
+24
drivers/hwmon/pmbus/pmbus.h
··· 244 244 #define PB_OPERATION_CONTROL_ON BIT(7) 245 245 246 246 /* 247 + * ON_OFF_CONFIG 248 + */ 249 + #define PB_ON_OFF_CONFIG_POWERUP_CONTROL BIT(4) 250 + #define PB_ON_OFF_CONFIG_OPERATION_REQ BIT(3) 251 + #define PB_ON_OFF_CONFIG_EN_PIN_REQ BIT(2) 252 + #define PB_ON_OFF_CONFIG_POLARITY_HIGH BIT(1) 253 + #define PB_ON_OFF_CONFIG_TURN_OFF_FAST BIT(0) 254 + 255 + /* 247 256 * WRITE_PROTECT 248 257 */ 249 258 #define PB_WP_ALL BIT(7) /* all but WRITE_PROTECT */ ··· 488 479 } 489 480 490 481 #define PMBUS_REGULATOR(_name, _id) PMBUS_REGULATOR_STEP(_name, _id, 0, 0, 0) 482 + 483 + #define PMBUS_REGULATOR_STEP_ONE(_name, _voltages, _step, _min_uV) \ 484 + { \ 485 + .name = (_name), \ 486 + .of_match = of_match_ptr(_name), \ 487 + .regulators_node = of_match_ptr("regulators"), \ 488 + .ops = &pmbus_regulator_ops, \ 489 + .type = REGULATOR_VOLTAGE, \ 490 + .owner = THIS_MODULE, \ 491 + .n_voltages = _voltages, \ 492 + .uV_step = _step, \ 493 + .min_uV = _min_uV, \ 494 + } 495 + 496 + #define PMBUS_REGULATOR_ONE(_name) PMBUS_REGULATOR_STEP_ONE(_name, 0, 0, 0) 491 497 492 498 /* Function declarations */ 493 499
+152 -2
drivers/hwmon/pmbus/tda38640.c
··· 18 18 PMBUS_REGULATOR("vout", 0), 19 19 }; 20 20 21 + struct tda38640_data { 22 + struct pmbus_driver_info info; 23 + u32 en_pin_lvl; 24 + }; 25 + 26 + #define to_tda38640_data(x) container_of(x, struct tda38640_data, info) 27 + 28 + /* 29 + * Map PB_ON_OFF_CONFIG_POLARITY_HIGH to PB_OPERATION_CONTROL_ON. 30 + */ 31 + static int tda38640_read_byte_data(struct i2c_client *client, int page, int reg) 32 + { 33 + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 34 + struct tda38640_data *data = to_tda38640_data(info); 35 + int ret, on_off_config, enabled; 36 + 37 + if (reg != PMBUS_OPERATION) 38 + return -ENODATA; 39 + 40 + ret = pmbus_read_byte_data(client, page, reg); 41 + if (ret < 0) 42 + return ret; 43 + 44 + on_off_config = pmbus_read_byte_data(client, page, 45 + PMBUS_ON_OFF_CONFIG); 46 + if (on_off_config < 0) 47 + return on_off_config; 48 + 49 + enabled = !!(on_off_config & PB_ON_OFF_CONFIG_POLARITY_HIGH); 50 + 51 + enabled ^= data->en_pin_lvl; 52 + if (enabled) 53 + ret &= ~PB_OPERATION_CONTROL_ON; 54 + else 55 + ret |= PB_OPERATION_CONTROL_ON; 56 + 57 + return ret; 58 + } 59 + 60 + /* 61 + * Map PB_OPERATION_CONTROL_ON to PB_ON_OFF_CONFIG_POLARITY_HIGH. 62 + */ 63 + static int tda38640_write_byte_data(struct i2c_client *client, int page, 64 + int reg, u8 byte) 65 + { 66 + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 67 + struct tda38640_data *data = to_tda38640_data(info); 68 + int enable, ret; 69 + 70 + if (reg != PMBUS_OPERATION) 71 + return -ENODATA; 72 + 73 + enable = !!(byte & PB_OPERATION_CONTROL_ON); 74 + 75 + byte &= ~PB_OPERATION_CONTROL_ON; 76 + ret = pmbus_write_byte_data(client, page, reg, byte); 77 + if (ret < 0) 78 + return ret; 79 + 80 + enable ^= data->en_pin_lvl; 81 + 82 + return pmbus_update_byte_data(client, page, PMBUS_ON_OFF_CONFIG, 83 + PB_ON_OFF_CONFIG_POLARITY_HIGH, 84 + enable ? 0 : PB_ON_OFF_CONFIG_POLARITY_HIGH); 85 + } 86 + 87 + static int svid_mode(struct i2c_client *client, struct tda38640_data *data) 88 + { 89 + /* PMBUS_MFR_READ(0xD0) + MTP Address offset */ 90 + u8 write_buf[] = {0xd0, 0x44, 0x00}; 91 + u8 read_buf[2]; 92 + int ret, svid; 93 + bool off, reg_en_pin_pol; 94 + 95 + struct i2c_msg msgs[2] = { 96 + { 97 + .addr = client->addr, 98 + .flags = 0, 99 + .buf = write_buf, 100 + .len = sizeof(write_buf), 101 + }, 102 + { 103 + .addr = client->addr, 104 + .flags = I2C_M_RD, 105 + .buf = read_buf, 106 + .len = sizeof(read_buf), 107 + } 108 + }; 109 + 110 + ret = i2c_transfer(client->adapter, msgs, 2); 111 + if (ret < 0) { 112 + dev_err(&client->dev, "i2c_transfer failed. %d", ret); 113 + return ret; 114 + } 115 + 116 + /* 117 + * 0x44[15] determines PMBus Operating Mode 118 + * If bit is set then it is SVID mode. 119 + */ 120 + svid = !!(read_buf[1] & BIT(7)); 121 + 122 + /* 123 + * Determine EN pin level for use in SVID mode. 124 + * This is done with help of STATUS_BYTE bit 6(OFF) & ON_OFF_CONFIG bit 2(EN pin polarity). 125 + */ 126 + if (svid) { 127 + ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE); 128 + if (ret < 0) 129 + return ret; 130 + off = !!(ret & PB_STATUS_OFF); 131 + 132 + ret = i2c_smbus_read_byte_data(client, PMBUS_ON_OFF_CONFIG); 133 + if (ret < 0) 134 + return ret; 135 + reg_en_pin_pol = !!(ret & PB_ON_OFF_CONFIG_POLARITY_HIGH); 136 + data->en_pin_lvl = off ^ reg_en_pin_pol; 137 + } 138 + 139 + return svid; 140 + } 141 + 21 142 static struct pmbus_driver_info tda38640_info = { 22 143 .pages = 1, 23 144 .format[PSC_VOLTAGE_IN] = linear, ··· 147 26 .format[PSC_CURRENT_IN] = linear, 148 27 .format[PSC_POWER] = linear, 149 28 .format[PSC_TEMPERATURE] = linear, 150 - 151 29 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT 152 30 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP 153 31 | PMBUS_HAVE_IIN ··· 161 41 162 42 static int tda38640_probe(struct i2c_client *client) 163 43 { 164 - return pmbus_do_probe(client, &tda38640_info); 44 + struct tda38640_data *data; 45 + int svid; 46 + 47 + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); 48 + if (!data) 49 + return -ENOMEM; 50 + memcpy(&data->info, &tda38640_info, sizeof(tda38640_info)); 51 + 52 + if (IS_ENABLED(CONFIG_SENSORS_TDA38640_REGULATOR) && 53 + of_property_read_bool(client->dev.of_node, "infineon,en-pin-fixed-level")) { 54 + svid = svid_mode(client, data); 55 + if (svid < 0) { 56 + dev_err_probe(&client->dev, svid, "Could not determine operating mode."); 57 + return svid; 58 + } 59 + 60 + /* 61 + * Apply ON_OFF_CONFIG workaround as enabling the regulator using the 62 + * OPERATION register doesn't work in SVID mode. 63 + * 64 + * One should configure PMBUS_ON_OFF_CONFIG here, but 65 + * PB_ON_OFF_CONFIG_POWERUP_CONTROL and PB_ON_OFF_CONFIG_EN_PIN_REQ 66 + * are ignored by the device. 67 + * Only PB_ON_OFF_CONFIG_POLARITY_HIGH has an effect. 68 + */ 69 + if (svid) { 70 + data->info.read_byte_data = tda38640_read_byte_data; 71 + data->info.write_byte_data = tda38640_write_byte_data; 72 + } 73 + } 74 + return pmbus_do_probe(client, &data->info); 165 75 } 166 76 167 77 static const struct i2c_device_id tda38640_id[] = {
+275
drivers/hwmon/powerz.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (C) 2023 Thomas Weißschuh <linux@weissschuh.net> 4 + */ 5 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 6 + 7 + #include <linux/completion.h> 8 + #include <linux/device.h> 9 + #include <linux/hwmon.h> 10 + #include <linux/module.h> 11 + #include <linux/mutex.h> 12 + #include <linux/types.h> 13 + #include <linux/usb.h> 14 + 15 + #define DRIVER_NAME "powerz" 16 + #define POWERZ_EP_CMD_OUT 0x01 17 + #define POWERZ_EP_DATA_IN 0x81 18 + 19 + struct powerz_sensor_data { 20 + u8 _unknown_1[8]; 21 + __le32 V_bus; 22 + __le32 I_bus; 23 + __le32 V_bus_avg; 24 + __le32 I_bus_avg; 25 + u8 _unknown_2[8]; 26 + u8 temp[2]; 27 + __le16 V_cc1; 28 + __le16 V_cc2; 29 + __le16 V_dp; 30 + __le16 V_dm; 31 + __le16 V_dd; 32 + u8 _unknown_3[4]; 33 + } __packed; 34 + 35 + struct powerz_priv { 36 + char transfer_buffer[64]; /* first member to satisfy DMA alignment */ 37 + struct mutex mutex; 38 + struct completion completion; 39 + struct urb *urb; 40 + int status; 41 + }; 42 + 43 + static const struct hwmon_channel_info *const powerz_info[] = { 44 + HWMON_CHANNEL_INFO(in, 45 + HWMON_I_INPUT | HWMON_I_LABEL | HWMON_I_AVERAGE, 46 + HWMON_I_INPUT | HWMON_I_LABEL, 47 + HWMON_I_INPUT | HWMON_I_LABEL, 48 + HWMON_I_INPUT | HWMON_I_LABEL, 49 + HWMON_I_INPUT | HWMON_I_LABEL, 50 + HWMON_I_INPUT | HWMON_I_LABEL), 51 + HWMON_CHANNEL_INFO(curr, 52 + HWMON_C_INPUT | HWMON_C_LABEL | HWMON_C_AVERAGE), 53 + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL), 54 + NULL 55 + }; 56 + 57 + static umode_t powerz_is_visible(const void *data, enum hwmon_sensor_types type, 58 + u32 attr, int channel) 59 + { 60 + return 0444; 61 + } 62 + 63 + static int powerz_read_string(struct device *dev, enum hwmon_sensor_types type, 64 + u32 attr, int channel, const char **str) 65 + { 66 + if (type == hwmon_curr && attr == hwmon_curr_label) { 67 + *str = "IBUS"; 68 + } else if (type == hwmon_in && attr == hwmon_in_label) { 69 + if (channel == 0) 70 + *str = "VBUS"; 71 + else if (channel == 1) 72 + *str = "VCC1"; 73 + else if (channel == 2) 74 + *str = "VCC2"; 75 + else if (channel == 3) 76 + *str = "VDP"; 77 + else if (channel == 4) 78 + *str = "VDM"; 79 + else if (channel == 5) 80 + *str = "VDD"; 81 + else 82 + return -EOPNOTSUPP; 83 + } else if (type == hwmon_temp && attr == hwmon_temp_label) { 84 + *str = "TEMP"; 85 + } else { 86 + return -EOPNOTSUPP; 87 + } 88 + 89 + return 0; 90 + } 91 + 92 + static void powerz_usb_data_complete(struct urb *urb) 93 + { 94 + struct powerz_priv *priv = urb->context; 95 + 96 + complete(&priv->completion); 97 + } 98 + 99 + static void powerz_usb_cmd_complete(struct urb *urb) 100 + { 101 + struct powerz_priv *priv = urb->context; 102 + 103 + usb_fill_bulk_urb(urb, urb->dev, 104 + usb_rcvbulkpipe(urb->dev, POWERZ_EP_DATA_IN), 105 + priv->transfer_buffer, sizeof(priv->transfer_buffer), 106 + powerz_usb_data_complete, priv); 107 + 108 + priv->status = usb_submit_urb(urb, GFP_ATOMIC); 109 + if (priv->status) 110 + complete(&priv->completion); 111 + } 112 + 113 + static int powerz_read_data(struct usb_device *udev, struct powerz_priv *priv) 114 + { 115 + int ret; 116 + 117 + priv->status = -ETIMEDOUT; 118 + reinit_completion(&priv->completion); 119 + 120 + priv->transfer_buffer[0] = 0x0c; 121 + priv->transfer_buffer[1] = 0x00; 122 + priv->transfer_buffer[2] = 0x02; 123 + priv->transfer_buffer[3] = 0x00; 124 + 125 + usb_fill_bulk_urb(priv->urb, udev, 126 + usb_sndbulkpipe(udev, POWERZ_EP_CMD_OUT), 127 + priv->transfer_buffer, 4, powerz_usb_cmd_complete, 128 + priv); 129 + ret = usb_submit_urb(priv->urb, GFP_KERNEL); 130 + if (ret) 131 + return ret; 132 + 133 + if (!wait_for_completion_interruptible_timeout 134 + (&priv->completion, msecs_to_jiffies(5))) { 135 + usb_kill_urb(priv->urb); 136 + return -EIO; 137 + } 138 + 139 + if (priv->urb->actual_length < sizeof(struct powerz_sensor_data)) 140 + return -EIO; 141 + 142 + return priv->status; 143 + } 144 + 145 + static int powerz_read(struct device *dev, enum hwmon_sensor_types type, 146 + u32 attr, int channel, long *val) 147 + { 148 + struct usb_interface *intf = to_usb_interface(dev->parent); 149 + struct usb_device *udev = interface_to_usbdev(intf); 150 + struct powerz_priv *priv = usb_get_intfdata(intf); 151 + struct powerz_sensor_data *data; 152 + int ret; 153 + 154 + if (!priv) 155 + return -EIO; /* disconnected */ 156 + 157 + mutex_lock(&priv->mutex); 158 + ret = powerz_read_data(udev, priv); 159 + if (ret) 160 + goto out; 161 + 162 + data = (struct powerz_sensor_data *)priv->transfer_buffer; 163 + 164 + if (type == hwmon_curr) { 165 + if (attr == hwmon_curr_input) 166 + *val = ((s32)le32_to_cpu(data->I_bus)) / 1000; 167 + else if (attr == hwmon_curr_average) 168 + *val = ((s32)le32_to_cpu(data->I_bus_avg)) / 1000; 169 + else 170 + ret = -EOPNOTSUPP; 171 + } else if (type == hwmon_in) { 172 + if (attr == hwmon_in_input) { 173 + if (channel == 0) 174 + *val = le32_to_cpu(data->V_bus) / 1000; 175 + else if (channel == 1) 176 + *val = le16_to_cpu(data->V_cc1) / 10; 177 + else if (channel == 2) 178 + *val = le16_to_cpu(data->V_cc2) / 10; 179 + else if (channel == 3) 180 + *val = le16_to_cpu(data->V_dp) / 10; 181 + else if (channel == 4) 182 + *val = le16_to_cpu(data->V_dm) / 10; 183 + else if (channel == 5) 184 + *val = le16_to_cpu(data->V_dd) / 10; 185 + else 186 + ret = -EOPNOTSUPP; 187 + } else if (attr == hwmon_in_average && channel == 0) { 188 + *val = le32_to_cpu(data->V_bus_avg) / 1000; 189 + } else { 190 + ret = -EOPNOTSUPP; 191 + } 192 + } else if (type == hwmon_temp && attr == hwmon_temp_input) { 193 + *val = data->temp[1] * 2000 + data->temp[0] * 1000 / 128; 194 + } else { 195 + ret = -EOPNOTSUPP; 196 + } 197 + 198 + out: 199 + mutex_unlock(&priv->mutex); 200 + return ret; 201 + } 202 + 203 + static const struct hwmon_ops powerz_hwmon_ops = { 204 + .is_visible = powerz_is_visible, 205 + .read = powerz_read, 206 + .read_string = powerz_read_string, 207 + }; 208 + 209 + static const struct hwmon_chip_info powerz_chip_info = { 210 + .ops = &powerz_hwmon_ops, 211 + .info = powerz_info, 212 + }; 213 + 214 + static int powerz_probe(struct usb_interface *intf, 215 + const struct usb_device_id *id) 216 + { 217 + struct powerz_priv *priv; 218 + struct device *hwmon_dev; 219 + struct device *parent; 220 + 221 + parent = &intf->dev; 222 + 223 + priv = devm_kzalloc(parent, sizeof(*priv), GFP_KERNEL); 224 + if (!priv) 225 + return -ENOMEM; 226 + 227 + priv->urb = usb_alloc_urb(0, GFP_KERNEL); 228 + if (!priv->urb) 229 + return -ENOMEM; 230 + mutex_init(&priv->mutex); 231 + init_completion(&priv->completion); 232 + 233 + hwmon_dev = 234 + devm_hwmon_device_register_with_info(parent, DRIVER_NAME, priv, 235 + &powerz_chip_info, NULL); 236 + if (IS_ERR(hwmon_dev)) { 237 + usb_free_urb(priv->urb); 238 + return PTR_ERR(hwmon_dev); 239 + } 240 + 241 + usb_set_intfdata(intf, priv); 242 + 243 + return 0; 244 + } 245 + 246 + static void powerz_disconnect(struct usb_interface *intf) 247 + { 248 + struct powerz_priv *priv = usb_get_intfdata(intf); 249 + 250 + mutex_lock(&priv->mutex); 251 + usb_kill_urb(priv->urb); 252 + usb_free_urb(priv->urb); 253 + mutex_unlock(&priv->mutex); 254 + } 255 + 256 + static const struct usb_device_id powerz_id_table[] = { 257 + { USB_DEVICE_INTERFACE_NUMBER(0x5FC9, 0x0061, 0x00) }, /* ChargerLAB POWER-Z KM002C */ 258 + { USB_DEVICE_INTERFACE_NUMBER(0x5FC9, 0x0063, 0x00) }, /* ChargerLAB POWER-Z KM003C */ 259 + { } 260 + }; 261 + 262 + MODULE_DEVICE_TABLE(usb, powerz_id_table); 263 + 264 + static struct usb_driver powerz_driver = { 265 + .name = DRIVER_NAME, 266 + .id_table = powerz_id_table, 267 + .probe = powerz_probe, 268 + .disconnect = powerz_disconnect, 269 + }; 270 + 271 + module_usb_driver(powerz_driver); 272 + 273 + MODULE_LICENSE("GPL"); 274 + MODULE_AUTHOR("Thomas Weißschuh <linux@weissschuh.net>"); 275 + MODULE_DESCRIPTION("ChargerLAB POWER-Z USB-C tester");
+194 -73
drivers/hwmon/sch5627.c
··· 6 6 7 7 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 8 9 + #include <linux/bits.h> 10 + #include <linux/minmax.h> 9 11 #include <linux/module.h> 10 12 #include <linux/mod_devicetable.h> 13 + #include <linux/pm.h> 11 14 #include <linux/init.h> 15 + #include <linux/regmap.h> 12 16 #include <linux/slab.h> 13 17 #include <linux/jiffies.h> 14 18 #include <linux/platform_device.h> ··· 35 31 #define SCH5627_REG_COMPANY_ID 0x3e 36 32 #define SCH5627_REG_PRIMARY_ID 0x3f 37 33 #define SCH5627_REG_CTRL 0x40 34 + 35 + #define SCH5627_CTRL_START BIT(0) 36 + #define SCH5627_CTRL_LOCK BIT(1) 37 + #define SCH5627_CTRL_VBAT BIT(4) 38 38 39 39 #define SCH5627_NO_TEMPS 8 40 40 #define SCH5627_NO_FANS 4 ··· 75 67 "VCC", "VTT", "VBAT", "VTR", "V_IN" }; 76 68 77 69 struct sch5627_data { 70 + struct regmap *regmap; 78 71 unsigned short addr; 79 72 u8 control; 80 - u8 temp_max[SCH5627_NO_TEMPS]; 81 - u8 temp_crit[SCH5627_NO_TEMPS]; 82 - u16 fan_min[SCH5627_NO_FANS]; 83 73 84 74 struct mutex update_lock; 85 75 unsigned long last_battery; /* In jiffies */ ··· 90 84 u16 temp[SCH5627_NO_TEMPS]; 91 85 u16 fan[SCH5627_NO_FANS]; 92 86 u16 in[SCH5627_NO_IN]; 87 + }; 88 + 89 + static const struct regmap_range sch5627_tunables_ranges[] = { 90 + regmap_reg_range(0x57, 0x57), 91 + regmap_reg_range(0x59, 0x59), 92 + regmap_reg_range(0x5B, 0x5B), 93 + regmap_reg_range(0x5D, 0x5D), 94 + regmap_reg_range(0x5F, 0x5F), 95 + regmap_reg_range(0x61, 0x69), 96 + regmap_reg_range(0x96, 0x9B), 97 + regmap_reg_range(0xA0, 0xA3), 98 + regmap_reg_range(0x184, 0x184), 99 + regmap_reg_range(0x186, 0x186), 100 + regmap_reg_range(0x1A8, 0x1A9), 101 + }; 102 + 103 + static const struct regmap_access_table sch5627_tunables_table = { 104 + .yes_ranges = sch5627_tunables_ranges, 105 + .n_yes_ranges = ARRAY_SIZE(sch5627_tunables_ranges), 106 + }; 107 + 108 + static const struct regmap_config sch5627_regmap_config = { 109 + .reg_bits = 16, 110 + .val_bits = 8, 111 + .wr_table = &sch5627_tunables_table, 112 + .rd_table = &sch5627_tunables_table, 113 + .cache_type = REGCACHE_RBTREE, 114 + .use_single_read = true, 115 + .use_single_write = true, 116 + .can_sleep = true, 93 117 }; 94 118 95 119 static int sch5627_update_temp(struct sch5627_data *data) ··· 183 147 184 148 /* Trigger a Vbat voltage measurement every 5 minutes */ 185 149 if (time_after(jiffies, data->last_battery + 300 * HZ)) { 186 - sch56xx_write_virtual_reg(data->addr, SCH5627_REG_CTRL, data->control | 0x10); 150 + sch56xx_write_virtual_reg(data->addr, SCH5627_REG_CTRL, 151 + data->control | SCH5627_CTRL_VBAT); 187 152 data->last_battery = jiffies; 188 153 } 189 154 ··· 208 171 return ret; 209 172 } 210 173 211 - static int sch5627_read_limits(struct sch5627_data *data) 212 - { 213 - int i, val; 214 - 215 - for (i = 0; i < SCH5627_NO_TEMPS; i++) { 216 - /* 217 - * Note what SMSC calls ABS, is what lm_sensors calls max 218 - * (aka high), and HIGH is what lm_sensors calls crit. 219 - */ 220 - val = sch56xx_read_virtual_reg(data->addr, 221 - SCH5627_REG_TEMP_ABS[i]); 222 - if (val < 0) 223 - return val; 224 - data->temp_max[i] = val; 225 - 226 - val = sch56xx_read_virtual_reg(data->addr, 227 - SCH5627_REG_TEMP_HIGH[i]); 228 - if (val < 0) 229 - return val; 230 - data->temp_crit[i] = val; 231 - } 232 - for (i = 0; i < SCH5627_NO_FANS; i++) { 233 - val = sch56xx_read_virtual_reg16(data->addr, 234 - SCH5627_REG_FAN_MIN[i]); 235 - if (val < 0) 236 - return val; 237 - data->fan_min[i] = val; 238 - } 239 - 240 - return 0; 241 - } 242 - 243 174 static int reg_to_temp(u16 reg) 244 175 { 245 176 return (reg * 625) / 10 - 64000; ··· 228 223 return 5400540 / reg; 229 224 } 230 225 226 + static u8 sch5627_temp_limit_to_reg(long value) 227 + { 228 + long limit = (value / 1000) + 64; 229 + 230 + return clamp_val(limit, 0, U8_MAX); 231 + } 232 + 233 + static u16 sch5627_rpm_to_reg(long value) 234 + { 235 + long pulses; 236 + 237 + if (value <= 0) 238 + return U16_MAX - 1; 239 + 240 + pulses = 5400540 / value; 241 + 242 + return clamp_val(pulses, 1, U16_MAX - 1); 243 + } 244 + 231 245 static umode_t sch5627_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, 232 246 int channel) 233 247 { 234 - if (type == hwmon_pwm && attr == hwmon_pwm_auto_channels_temp) 235 - return 0644; 248 + const struct sch5627_data *data = drvdata; 249 + 250 + /* Once the lock bit is set, the virtual registers become read-only 251 + * until the next power cycle. 252 + */ 253 + if (data->control & SCH5627_CTRL_LOCK) 254 + return 0444; 255 + 256 + switch (type) { 257 + case hwmon_temp: 258 + switch (attr) { 259 + case hwmon_temp_max: 260 + case hwmon_temp_crit: 261 + return 0644; 262 + default: 263 + break; 264 + } 265 + break; 266 + case hwmon_fan: 267 + switch (attr) { 268 + case hwmon_fan_min: 269 + return 0644; 270 + default: 271 + break; 272 + } 273 + break; 274 + case hwmon_pwm: 275 + switch (attr) { 276 + case hwmon_pwm_auto_channels_temp: 277 + return 0644; 278 + default: 279 + break; 280 + } 281 + break; 282 + default: 283 + break; 284 + } 236 285 237 286 return 0444; 238 287 } ··· 295 236 long *val) 296 237 { 297 238 struct sch5627_data *data = dev_get_drvdata(dev); 298 - int ret; 239 + int ret, value; 299 240 300 241 switch (type) { 301 242 case hwmon_temp: 302 - ret = sch5627_update_temp(data); 303 - if (ret < 0) 304 - return ret; 305 243 switch (attr) { 306 244 case hwmon_temp_input: 245 + ret = sch5627_update_temp(data); 246 + if (ret < 0) 247 + return ret; 248 + 307 249 *val = reg_to_temp(data->temp[channel]); 308 250 return 0; 309 251 case hwmon_temp_max: 310 - *val = reg_to_temp_limit(data->temp_max[channel]); 252 + ret = regmap_read(data->regmap, SCH5627_REG_TEMP_ABS[channel], &value); 253 + if (ret < 0) 254 + return ret; 255 + 256 + *val = reg_to_temp_limit((u8)value); 311 257 return 0; 312 258 case hwmon_temp_crit: 313 - *val = reg_to_temp_limit(data->temp_crit[channel]); 259 + ret = regmap_read(data->regmap, SCH5627_REG_TEMP_HIGH[channel], &value); 260 + if (ret < 0) 261 + return ret; 262 + 263 + *val = reg_to_temp_limit((u8)value); 314 264 return 0; 315 265 case hwmon_temp_fault: 266 + ret = sch5627_update_temp(data); 267 + if (ret < 0) 268 + return ret; 269 + 316 270 *val = (data->temp[channel] == 0); 317 271 return 0; 318 272 default: ··· 333 261 } 334 262 break; 335 263 case hwmon_fan: 336 - ret = sch5627_update_fan(data); 337 - if (ret < 0) 338 - return ret; 339 264 switch (attr) { 340 265 case hwmon_fan_input: 266 + ret = sch5627_update_fan(data); 267 + if (ret < 0) 268 + return ret; 269 + 341 270 ret = reg_to_rpm(data->fan[channel]); 342 271 if (ret < 0) 343 272 return ret; 273 + 344 274 *val = ret; 345 275 return 0; 346 276 case hwmon_fan_min: 347 - ret = reg_to_rpm(data->fan_min[channel]); 277 + ret = sch56xx_regmap_read16(data->regmap, SCH5627_REG_FAN_MIN[channel], 278 + &value); 348 279 if (ret < 0) 349 280 return ret; 281 + 282 + ret = reg_to_rpm((u16)value); 283 + if (ret < 0) 284 + return ret; 285 + 350 286 *val = ret; 351 287 return 0; 352 288 case hwmon_fan_fault: 289 + ret = sch5627_update_fan(data); 290 + if (ret < 0) 291 + return ret; 292 + 353 293 *val = (data->fan[channel] == 0xffff); 354 294 return 0; 355 295 default: ··· 371 287 case hwmon_pwm: 372 288 switch (attr) { 373 289 case hwmon_pwm_auto_channels_temp: 374 - mutex_lock(&data->update_lock); 375 - ret = sch56xx_read_virtual_reg(data->addr, SCH5627_REG_PWM_MAP[channel]); 376 - mutex_unlock(&data->update_lock); 377 - 290 + ret = regmap_read(data->regmap, SCH5627_REG_PWM_MAP[channel], &value); 378 291 if (ret < 0) 379 292 return ret; 380 293 381 - *val = ret; 382 - 294 + *val = value; 383 295 return 0; 384 296 default: 385 297 break; ··· 425 345 long val) 426 346 { 427 347 struct sch5627_data *data = dev_get_drvdata(dev); 428 - int ret; 348 + u16 fan; 349 + u8 temp; 429 350 430 351 switch (type) { 352 + case hwmon_temp: 353 + temp = sch5627_temp_limit_to_reg(val); 354 + 355 + switch (attr) { 356 + case hwmon_temp_max: 357 + return regmap_write(data->regmap, SCH5627_REG_TEMP_ABS[channel], temp); 358 + case hwmon_temp_crit: 359 + return regmap_write(data->regmap, SCH5627_REG_TEMP_HIGH[channel], temp); 360 + default: 361 + break; 362 + } 363 + break; 364 + case hwmon_fan: 365 + switch (attr) { 366 + case hwmon_fan_min: 367 + fan = sch5627_rpm_to_reg(val); 368 + 369 + return sch56xx_regmap_write16(data->regmap, SCH5627_REG_FAN_MIN[channel], 370 + fan); 371 + default: 372 + break; 373 + } 374 + break; 431 375 case hwmon_pwm: 432 376 switch (attr) { 433 377 case hwmon_pwm_auto_channels_temp: ··· 459 355 if (val > U8_MAX || val < 0) 460 356 return -EINVAL; 461 357 462 - mutex_lock(&data->update_lock); 463 - ret = sch56xx_write_virtual_reg(data->addr, SCH5627_REG_PWM_MAP[channel], 464 - val); 465 - mutex_unlock(&data->update_lock); 466 - 467 - return ret; 358 + return regmap_write(data->regmap, SCH5627_REG_PWM_MAP[channel], val); 468 359 default: 469 360 break; 470 361 } ··· 521 422 { 522 423 struct sch5627_data *data; 523 424 struct device *hwmon_dev; 524 - int err, build_code, build_id, hwmon_rev, val; 425 + int build_code, build_id, hwmon_rev, val; 525 426 526 427 data = devm_kzalloc(&pdev->dev, sizeof(struct sch5627_data), 527 428 GFP_KERNEL); ··· 582 483 return val; 583 484 584 485 data->control = val; 585 - if (!(data->control & 0x01)) { 486 + if (!(data->control & SCH5627_CTRL_START)) { 586 487 pr_err("hardware monitoring not enabled\n"); 587 488 return -ENODEV; 588 489 } 490 + 491 + data->regmap = devm_regmap_init_sch56xx(&pdev->dev, &data->update_lock, data->addr, 492 + &sch5627_regmap_config); 493 + if (IS_ERR(data->regmap)) 494 + return PTR_ERR(data->regmap); 495 + 589 496 /* Trigger a Vbat voltage measurement, so that we get a valid reading 590 497 the first time we read Vbat */ 591 - sch56xx_write_virtual_reg(data->addr, SCH5627_REG_CTRL, 592 - data->control | 0x10); 498 + sch56xx_write_virtual_reg(data->addr, SCH5627_REG_CTRL, data->control | SCH5627_CTRL_VBAT); 593 499 data->last_battery = jiffies; 594 - 595 - /* 596 - * Read limits, we do this only once as reading a register on 597 - * the sch5627 is quite expensive (and they don't change). 598 - */ 599 - err = sch5627_read_limits(data); 600 - if (err) 601 - return err; 602 500 603 501 pr_info("found %s chip at %#hx\n", DEVNAME, data->addr); 604 502 pr_info("firmware build: code 0x%02X, id 0x%04X, hwmon: rev 0x%02X\n", ··· 614 518 return 0; 615 519 } 616 520 521 + static int sch5627_suspend(struct device *dev) 522 + { 523 + struct sch5627_data *data = dev_get_drvdata(dev); 524 + 525 + regcache_cache_only(data->regmap, true); 526 + regcache_mark_dirty(data->regmap); 527 + 528 + return 0; 529 + } 530 + 531 + static int sch5627_resume(struct device *dev) 532 + { 533 + struct sch5627_data *data = dev_get_drvdata(dev); 534 + 535 + regcache_cache_only(data->regmap, false); 536 + /* We must not access the virtual registers when the lock bit is set */ 537 + if (data->control & SCH5627_CTRL_LOCK) 538 + return regcache_drop_region(data->regmap, 0, U16_MAX); 539 + 540 + return regcache_sync(data->regmap); 541 + } 542 + 543 + static DEFINE_SIMPLE_DEV_PM_OPS(sch5627_dev_pm_ops, sch5627_suspend, sch5627_resume); 544 + 617 545 static const struct platform_device_id sch5627_device_id[] = { 618 546 { 619 547 .name = "sch5627", ··· 649 529 static struct platform_driver sch5627_driver = { 650 530 .driver = { 651 531 .name = DRVNAME, 532 + .pm = pm_sleep_ptr(&sch5627_dev_pm_ops), 652 533 }, 653 534 .probe = sch5627_probe, 654 535 .id_table = sch5627_device_id,
+2 -4
drivers/hwmon/sch5636.c
··· 367 367 SENSOR_ATTR_RO(fan8_alarm, fan_alarm, 7), 368 368 }; 369 369 370 - static int sch5636_remove(struct platform_device *pdev) 370 + static void sch5636_remove(struct platform_device *pdev) 371 371 { 372 372 struct sch5636_data *data = platform_get_drvdata(pdev); 373 373 int i; ··· 385 385 for (i = 0; i < SCH5636_NO_FANS * 3; i++) 386 386 device_remove_file(&pdev->dev, 387 387 &sch5636_fan_attr[i].dev_attr); 388 - 389 - return 0; 390 388 } 391 389 392 390 static int sch5636_probe(struct platform_device *pdev) ··· 513 515 .name = DRVNAME, 514 516 }, 515 517 .probe = sch5636_probe, 516 - .remove = sch5636_remove, 518 + .remove_new = sch5636_remove, 517 519 .id_table = sch5636_device_id, 518 520 }; 519 521
+109 -62
drivers/hwmon/sch56xx-common.c
··· 7 7 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 8 9 9 #include <linux/module.h> 10 - #include <linux/mod_devicetable.h> 11 10 #include <linux/init.h> 12 11 #include <linux/platform_device.h> 13 - #include <linux/dmi.h> 12 + #include <linux/regmap.h> 14 13 #include <linux/err.h> 15 14 #include <linux/io.h> 16 15 #include <linux/acpi.h> ··· 20 21 #include <linux/slab.h> 21 22 #include "sch56xx-common.h" 22 23 23 - static bool ignore_dmi; 24 - module_param(ignore_dmi, bool, 0); 25 - MODULE_PARM_DESC(ignore_dmi, "Omit DMI check for supported devices (default=0)"); 26 - 24 + /* Insmod parameters */ 27 25 static bool nowayout = WATCHDOG_NOWAYOUT; 28 26 module_param(nowayout, bool, 0); 29 27 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" ··· 58 62 u8 watchdog_preset; 59 63 u8 watchdog_control; 60 64 u8 watchdog_output_enable; 65 + }; 66 + 67 + struct sch56xx_bus_context { 68 + struct mutex *lock; /* Used to serialize access to the mailbox registers */ 69 + u16 addr; 61 70 }; 62 71 63 72 static struct platform_device *sch56xx_pdev; ··· 243 242 return (msb << 4) | (lsn & 0x0f); 244 243 } 245 244 EXPORT_SYMBOL(sch56xx_read_virtual_reg12); 245 + 246 + /* 247 + * Regmap support 248 + */ 249 + 250 + int sch56xx_regmap_read16(struct regmap *map, unsigned int reg, unsigned int *val) 251 + { 252 + int lsb, msb, ret; 253 + 254 + /* See sch56xx_read_virtual_reg16() */ 255 + ret = regmap_read(map, reg, &lsb); 256 + if (ret < 0) 257 + return ret; 258 + 259 + ret = regmap_read(map, reg + 1, &msb); 260 + if (ret < 0) 261 + return ret; 262 + 263 + *val = lsb | (msb << 8); 264 + 265 + return 0; 266 + } 267 + EXPORT_SYMBOL(sch56xx_regmap_read16); 268 + 269 + int sch56xx_regmap_write16(struct regmap *map, unsigned int reg, unsigned int val) 270 + { 271 + int ret; 272 + 273 + ret = regmap_write(map, reg, val & 0xff); 274 + if (ret < 0) 275 + return ret; 276 + 277 + return regmap_write(map, reg + 1, (val >> 8) & 0xff); 278 + } 279 + EXPORT_SYMBOL(sch56xx_regmap_write16); 280 + 281 + static int sch56xx_reg_write(void *context, unsigned int reg, unsigned int val) 282 + { 283 + struct sch56xx_bus_context *bus = context; 284 + int ret; 285 + 286 + mutex_lock(bus->lock); 287 + ret = sch56xx_write_virtual_reg(bus->addr, (u16)reg, (u8)val); 288 + mutex_unlock(bus->lock); 289 + 290 + return ret; 291 + } 292 + 293 + static int sch56xx_reg_read(void *context, unsigned int reg, unsigned int *val) 294 + { 295 + struct sch56xx_bus_context *bus = context; 296 + int ret; 297 + 298 + mutex_lock(bus->lock); 299 + ret = sch56xx_read_virtual_reg(bus->addr, (u16)reg); 300 + mutex_unlock(bus->lock); 301 + 302 + if (ret < 0) 303 + return ret; 304 + 305 + *val = ret; 306 + 307 + return 0; 308 + } 309 + 310 + static void sch56xx_free_context(void *context) 311 + { 312 + kfree(context); 313 + } 314 + 315 + static const struct regmap_bus sch56xx_bus = { 316 + .reg_write = sch56xx_reg_write, 317 + .reg_read = sch56xx_reg_read, 318 + .free_context = sch56xx_free_context, 319 + .reg_format_endian_default = REGMAP_ENDIAN_LITTLE, 320 + .val_format_endian_default = REGMAP_ENDIAN_LITTLE, 321 + }; 322 + 323 + struct regmap *devm_regmap_init_sch56xx(struct device *dev, struct mutex *lock, u16 addr, 324 + const struct regmap_config *config) 325 + { 326 + struct sch56xx_bus_context *context; 327 + struct regmap *map; 328 + 329 + if (config->reg_bits != 16 && config->val_bits != 8) 330 + return ERR_PTR(-EOPNOTSUPP); 331 + 332 + context = kzalloc(sizeof(*context), GFP_KERNEL); 333 + if (!context) 334 + return ERR_PTR(-ENOMEM); 335 + 336 + context->lock = lock; 337 + context->addr = addr; 338 + 339 + map = devm_regmap_init(dev, &sch56xx_bus, context, config); 340 + if (IS_ERR(map)) 341 + kfree(context); 342 + 343 + return map; 344 + } 345 + EXPORT_SYMBOL(devm_regmap_init_sch56xx); 246 346 247 347 /* 248 348 * Watchdog routines ··· 625 523 return PTR_ERR_OR_ZERO(sch56xx_pdev); 626 524 } 627 525 628 - static const struct dmi_system_id sch56xx_dmi_override_table[] __initconst = { 629 - { 630 - .matches = { 631 - DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), 632 - DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS W380"), 633 - }, 634 - }, 635 - { 636 - .matches = { 637 - DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), 638 - DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO P710"), 639 - }, 640 - }, 641 - { 642 - .matches = { 643 - DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), 644 - DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO E9900"), 645 - }, 646 - }, 647 - { } 648 - }; 649 - 650 - /* For autoloading only */ 651 - static const struct dmi_system_id sch56xx_dmi_table[] __initconst = { 652 - { 653 - .matches = { 654 - DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), 655 - }, 656 - }, 657 - { } 658 - }; 659 - MODULE_DEVICE_TABLE(dmi, sch56xx_dmi_table); 660 - 661 526 static int __init sch56xx_init(void) 662 527 { 663 - const char *name = NULL; 664 528 int address; 529 + const char *name = NULL; 665 530 666 - if (!ignore_dmi) { 667 - if (!dmi_check_system(sch56xx_dmi_table)) 668 - return -ENODEV; 669 - 670 - if (!dmi_check_system(sch56xx_dmi_override_table)) { 671 - /* 672 - * Some machines like the Esprimo P720 and Esprimo C700 have 673 - * onboard devices named " Antiope"/" Theseus" instead of 674 - * "Antiope"/"Theseus", so we need to check for both. 675 - */ 676 - if (!dmi_find_device(DMI_DEV_TYPE_OTHER, "Antiope", NULL) && 677 - !dmi_find_device(DMI_DEV_TYPE_OTHER, " Antiope", NULL) && 678 - !dmi_find_device(DMI_DEV_TYPE_OTHER, "Theseus", NULL) && 679 - !dmi_find_device(DMI_DEV_TYPE_OTHER, " Theseus", NULL)) 680 - return -ENODEV; 681 - } 682 - } 683 - 684 - /* 685 - * Some devices like the Esprimo C700 have both onboard devices, 686 - * so we still have to check manually 687 - */ 688 531 address = sch56xx_find(0x4e, &name); 689 532 if (address < 0) 690 533 address = sch56xx_find(0x2e, &name);
+6
drivers/hwmon/sch56xx-common.h
··· 5 5 ***************************************************************************/ 6 6 7 7 #include <linux/mutex.h> 8 + #include <linux/regmap.h> 8 9 9 10 struct sch56xx_watchdog_data; 11 + 12 + struct regmap *devm_regmap_init_sch56xx(struct device *dev, struct mutex *lock, u16 addr, 13 + const struct regmap_config *config); 14 + int sch56xx_regmap_read16(struct regmap *map, unsigned int reg, unsigned int *val); 15 + int sch56xx_regmap_write16(struct regmap *map, unsigned int reg, unsigned int val); 10 16 11 17 int sch56xx_read_virtual_reg(u16 addr, u16 reg); 12 18 int sch56xx_write_virtual_reg(u16 addr, u16 reg, u8 val);
+2 -4
drivers/hwmon/sht15.c
··· 1017 1017 return ret; 1018 1018 } 1019 1019 1020 - static int sht15_remove(struct platform_device *pdev) 1020 + static void sht15_remove(struct platform_device *pdev) 1021 1021 { 1022 1022 struct sht15_data *data = platform_get_drvdata(pdev); 1023 1023 int ret; ··· 1033 1033 regulator_unregister_notifier(data->reg, &data->nb); 1034 1034 regulator_disable(data->reg); 1035 1035 } 1036 - 1037 - return 0; 1038 1036 } 1039 1037 1040 1038 static const struct platform_device_id sht15_device_ids[] = { ··· 1051 1053 .of_match_table = of_match_ptr(sht15_dt_match), 1052 1054 }, 1053 1055 .probe = sht15_probe, 1054 - .remove = sht15_remove, 1056 + .remove_new = sht15_remove, 1055 1057 .id_table = sht15_device_ids, 1056 1058 }; 1057 1059 module_platform_driver(sht15_driver);
+2 -4
drivers/hwmon/sis5595.c
··· 709 709 return err; 710 710 } 711 711 712 - static int sis5595_remove(struct platform_device *pdev) 712 + static void sis5595_remove(struct platform_device *pdev) 713 713 { 714 714 struct sis5595_data *data = platform_get_drvdata(pdev); 715 715 ··· 717 717 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group); 718 718 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4); 719 719 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1); 720 - 721 - return 0; 722 720 } 723 721 724 722 static const struct pci_device_id sis5595_pci_ids[] = { ··· 788 790 .name = DRIVER_NAME, 789 791 }, 790 792 .probe = sis5595_probe, 791 - .remove = sis5595_remove, 793 + .remove_new = sis5595_remove, 792 794 }; 793 795 794 796 static int sis5595_pci_probe(struct pci_dev *dev,
+23 -29
drivers/hwmon/tmp513.c
··· 73 73 #define TMP51X_PGA_DEFAULT 8 74 74 #define TMP51X_MAX_REGISTER_ADDR 0xFF 75 75 76 - #define TMP512_TEMP_CONFIG_DEFAULT 0xBF80 77 - #define TMP513_TEMP_CONFIG_DEFAULT 0xFF80 78 - 79 76 // Mask and shift 80 77 #define CURRENT_SENSE_VOLTAGE_320_MASK 0x1800 81 78 #define CURRENT_SENSE_VOLTAGE_160_MASK 0x1000 ··· 109 112 #define MIN_TEMP_LIMIT -40000 110 113 111 114 #define MAX_TEMP_HYST 127500 115 + 116 + #define TMP512_MAX_CHANNELS 3 117 + #define TMP513_MAX_CHANNELS 4 118 + 119 + #define TMP51X_TEMP_CONFIG_CONV_RATE GENMASK(9, 7) 120 + #define TMP51X_TEMP_CONFIG_RC BIT(10) 121 + #define TMP51X_TEMP_CHANNEL_MASK(n) (GENMASK((n) - 1, 0) << 11) 122 + #define TMP51X_TEMP_CONFIG_CONT BIT(15) 123 + #define TMP51X_TEMP_CONFIG_DEFAULT(n) \ 124 + (TMP51X_TEMP_CHANNEL_MASK(n) | TMP51X_TEMP_CONFIG_CONT | \ 125 + TMP51X_TEMP_CONFIG_CONV_RATE | TMP51X_TEMP_CONFIG_RC) 112 126 113 127 static const u8 TMP51X_TEMP_INPUT[4] = { 114 128 TMP51X_LOCAL_TEMP_RESULT, ··· 160 152 .max_register = TMP51X_MAX_REGISTER_ADDR, 161 153 }; 162 154 163 - enum tmp51x_ids { 164 - tmp512, tmp513 165 - }; 166 - 167 155 struct tmp51x_data { 168 156 u16 shunt_config; 169 157 u16 pga_gain; ··· 173 169 u32 curr_lsb_ua; 174 170 u32 pwr_lsb_uw; 175 171 176 - enum tmp51x_ids id; 172 + u8 max_channels; 177 173 struct regmap *regmap; 178 174 }; 179 175 ··· 438 434 439 435 switch (type) { 440 436 case hwmon_temp: 441 - if (data->id == tmp512 && channel == 3) 437 + if (channel >= data->max_channels) 442 438 return 0; 443 439 switch (attr) { 444 440 case hwmon_temp_input: ··· 589 585 if (ret < 0) 590 586 return ret; 591 587 592 - if (data->id == tmp513) { 588 + if (data->max_channels == TMP513_MAX_CHANNELS) { 593 589 ret = regmap_write(data->regmap, TMP513_N_FACTOR_3, 594 590 data->nfactor[2] << 8); 595 591 if (ret < 0) ··· 605 601 } 606 602 607 603 static const struct i2c_device_id tmp51x_id[] = { 608 - { "tmp512", tmp512 }, 609 - { "tmp513", tmp513 }, 604 + { "tmp512", TMP512_MAX_CHANNELS }, 605 + { "tmp513", TMP513_MAX_CHANNELS }, 610 606 { } 611 607 }; 612 608 MODULE_DEVICE_TABLE(i2c, tmp51x_id); 613 609 614 610 static const struct of_device_id tmp51x_of_match[] = { 615 - { 616 - .compatible = "ti,tmp512", 617 - .data = (void *)tmp512 618 - }, 619 - { 620 - .compatible = "ti,tmp513", 621 - .data = (void *)tmp513 622 - }, 623 - { }, 611 + { .compatible = "ti,tmp512", .data = (void *)TMP512_MAX_CHANNELS }, 612 + { .compatible = "ti,tmp513", .data = (void *)TMP513_MAX_CHANNELS }, 613 + { } 624 614 }; 625 615 MODULE_DEVICE_TABLE(of, tmp51x_of_match); 626 616 ··· 653 655 static int tmp51x_read_properties(struct device *dev, struct tmp51x_data *data) 654 656 { 655 657 int ret; 656 - u32 nfactor[3]; 657 658 u32 val; 658 659 659 660 ret = device_property_read_u32(dev, "shunt-resistor-micro-ohms", &val); ··· 670 673 if (ret < 0) 671 674 return ret; 672 675 673 - ret = device_property_read_u32_array(dev, "ti,nfactor", nfactor, 674 - (data->id == tmp513) ? 3 : 2); 675 - if (ret >= 0) 676 - memcpy(data->nfactor, nfactor, (data->id == tmp513) ? 3 : 2); 676 + device_property_read_u32_array(dev, "ti,nfactor", data->nfactor, 677 + data->max_channels - 1); 677 678 678 679 // Check if shunt value is compatible with pga-gain 679 680 if (data->shunt_uohms > data->pga_gain * 40 * 1000 * 1000) { ··· 693 698 static int tmp51x_configure(struct device *dev, struct tmp51x_data *data) 694 699 { 695 700 data->shunt_config = TMP51X_SHUNT_CONFIG_DEFAULT; 696 - data->temp_config = (data->id == tmp513) ? 697 - TMP513_TEMP_CONFIG_DEFAULT : TMP512_TEMP_CONFIG_DEFAULT; 701 + data->temp_config = TMP51X_TEMP_CONFIG_DEFAULT(data->max_channels); 698 702 699 703 if (dev->of_node) 700 704 return tmp51x_read_properties(dev, data); ··· 714 720 if (!data) 715 721 return -ENOMEM; 716 722 717 - data->id = (uintptr_t)i2c_get_match_data(client); 723 + data->max_channels = (uintptr_t)i2c_get_match_data(client); 718 724 719 725 ret = tmp51x_configure(dev, data); 720 726 if (ret < 0) {
+2 -4
drivers/hwmon/ultra45_env.c
··· 291 291 goto out; 292 292 } 293 293 294 - static int env_remove(struct platform_device *op) 294 + static void env_remove(struct platform_device *op) 295 295 { 296 296 struct env *p = platform_get_drvdata(op); 297 297 ··· 300 300 hwmon_device_unregister(p->hwmon_dev); 301 301 of_iounmap(&op->resource[0], p->regs, REG_SIZE); 302 302 } 303 - 304 - return 0; 305 303 } 306 304 307 305 static const struct of_device_id env_match[] = { ··· 317 319 .of_match_table = env_match, 318 320 }, 319 321 .probe = env_probe, 320 - .remove = env_remove, 322 + .remove_new = env_remove, 321 323 }; 322 324 323 325 module_platform_driver(env_driver);
+2 -3
drivers/hwmon/via-cputemp.c
··· 182 182 return err; 183 183 } 184 184 185 - static int via_cputemp_remove(struct platform_device *pdev) 185 + static void via_cputemp_remove(struct platform_device *pdev) 186 186 { 187 187 struct via_cputemp_data *data = platform_get_drvdata(pdev); 188 188 ··· 190 190 if (data->vrm) 191 191 device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); 192 192 sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); 193 - return 0; 194 193 } 195 194 196 195 static struct platform_driver via_cputemp_driver = { ··· 197 198 .name = DRVNAME, 198 199 }, 199 200 .probe = via_cputemp_probe, 200 - .remove = via_cputemp_remove, 201 + .remove_new = via_cputemp_remove, 201 202 }; 202 203 203 204 struct pdev_entry {
+2 -4
drivers/hwmon/via686a.c
··· 786 786 return err; 787 787 } 788 788 789 - static int via686a_remove(struct platform_device *pdev) 789 + static void via686a_remove(struct platform_device *pdev) 790 790 { 791 791 struct via686a_data *data = platform_get_drvdata(pdev); 792 792 793 793 hwmon_device_unregister(data->hwmon_dev); 794 794 sysfs_remove_group(&pdev->dev.kobj, &via686a_group); 795 - 796 - return 0; 797 795 } 798 796 799 797 static struct platform_driver via686a_driver = { ··· 799 801 .name = DRIVER_NAME, 800 802 }, 801 803 .probe = via686a_probe, 802 - .remove = via686a_remove, 804 + .remove_new = via686a_remove, 803 805 }; 804 806 805 807 static const struct pci_device_id via686a_pci_ids[] = {
+2 -4
drivers/hwmon/vt1211.c
··· 1208 1208 return err; 1209 1209 } 1210 1210 1211 - static int vt1211_remove(struct platform_device *pdev) 1211 + static void vt1211_remove(struct platform_device *pdev) 1212 1212 { 1213 1213 struct vt1211_data *data = platform_get_drvdata(pdev); 1214 1214 1215 1215 hwmon_device_unregister(data->hwmon_dev); 1216 1216 vt1211_remove_sysfs(pdev); 1217 - 1218 - return 0; 1219 1217 } 1220 1218 1221 1219 static struct platform_driver vt1211_driver = { ··· 1221 1223 .name = DRVNAME, 1222 1224 }, 1223 1225 .probe = vt1211_probe, 1224 - .remove = vt1211_remove, 1226 + .remove_new = vt1211_remove, 1225 1227 }; 1226 1228 1227 1229 static int __init vt1211_device_add(unsigned short address)
+2 -4
drivers/hwmon/vt8231.c
··· 892 892 return err; 893 893 } 894 894 895 - static int vt8231_remove(struct platform_device *pdev) 895 + static void vt8231_remove(struct platform_device *pdev) 896 896 { 897 897 struct vt8231_data *data = platform_get_drvdata(pdev); 898 898 int i; ··· 906 906 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group_temps[i]); 907 907 908 908 sysfs_remove_group(&pdev->dev.kobj, &vt8231_group); 909 - 910 - return 0; 911 909 } 912 910 913 911 ··· 914 916 .name = DRIVER_NAME, 915 917 }, 916 918 .probe = vt8231_probe, 917 - .remove = vt8231_remove, 919 + .remove_new = vt8231_remove, 918 920 }; 919 921 920 922 static const struct pci_device_id vt8231_pci_ids[] = {
+2 -4
drivers/hwmon/w83627hf.c
··· 1828 1828 return err; 1829 1829 } 1830 1830 1831 - static int w83627hf_remove(struct platform_device *pdev) 1831 + static void w83627hf_remove(struct platform_device *pdev) 1832 1832 { 1833 1833 struct w83627hf_data *data = platform_get_drvdata(pdev); 1834 1834 ··· 1836 1836 1837 1837 sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group); 1838 1838 sysfs_remove_group(&pdev->dev.kobj, &w83627hf_group_opt); 1839 - 1840 - return 0; 1841 1839 } 1842 1840 1843 1841 static struct platform_driver w83627hf_driver = { ··· 1844 1846 .pm = W83627HF_DEV_PM_OPS, 1845 1847 }, 1846 1848 .probe = w83627hf_probe, 1847 - .remove = w83627hf_remove, 1849 + .remove_new = w83627hf_remove, 1848 1850 }; 1849 1851 1850 1852 static int __init w83627hf_find(int sioaddr, unsigned short *addr,
+2 -5
drivers/hwmon/w83781d.c
··· 1816 1816 return err; 1817 1817 } 1818 1818 1819 - static int 1820 - w83781d_isa_remove(struct platform_device *pdev) 1819 + static void w83781d_isa_remove(struct platform_device *pdev) 1821 1820 { 1822 1821 struct w83781d_data *data = platform_get_drvdata(pdev); 1823 1822 1824 1823 hwmon_device_unregister(data->hwmon_dev); 1825 1824 w83781d_remove_files(&pdev->dev); 1826 1825 device_remove_file(&pdev->dev, &dev_attr_name); 1827 - 1828 - return 0; 1829 1826 } 1830 1827 1831 1828 static struct platform_driver w83781d_isa_driver = { ··· 1830 1833 .name = "w83781d", 1831 1834 }, 1832 1835 .probe = w83781d_isa_probe, 1833 - .remove = w83781d_isa_remove, 1836 + .remove_new = w83781d_isa_remove, 1834 1837 }; 1835 1838 1836 1839 /* return 1 if a supported chip is found, 0 otherwise */
+2 -4
drivers/hwmon/xgene-hwmon.c
··· 751 751 return rc; 752 752 } 753 753 754 - static int xgene_hwmon_remove(struct platform_device *pdev) 754 + static void xgene_hwmon_remove(struct platform_device *pdev) 755 755 { 756 756 struct xgene_hwmon_dev *ctx = platform_get_drvdata(pdev); 757 757 ··· 762 762 mbox_free_channel(ctx->mbox_chan); 763 763 else 764 764 pcc_mbox_free_channel(ctx->pcc_chan); 765 - 766 - return 0; 767 765 } 768 766 769 767 static const struct of_device_id xgene_hwmon_of_match[] = { ··· 772 774 773 775 static struct platform_driver xgene_hwmon_driver = { 774 776 .probe = xgene_hwmon_probe, 775 - .remove = xgene_hwmon_remove, 777 + .remove_new = xgene_hwmon_remove, 776 778 .driver = { 777 779 .name = "xgene-slimpro-hwmon", 778 780 .of_match_table = xgene_hwmon_of_match,