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

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

Pull hwmon updates from Guenter Roeck:
"New drivers:

- Driver for MAX31827

- Driver to support HP WMI Sensors

Added support to existing drivers:

- aht10: Support for AHT20

- aquacomputer_d5next: Support for Aquacomputer Leakshield

- asus-ec-sensors: Support for ROG Crosshair X670E Hero

- corsair-psu: Cleanups and support for series 2022 and 2023

- it87: Various improvements and support for IT8732F

- nct6683: Support customer ID of some MSI boards.

- nct6755: Support for NCT6799D

- oxp-sensors: Various cleanups; support for AYANEO 2, Geek, OXP
Mini, and AOKZOE A1 PRO

- pmbus/max16601: Support for new revisions of MAX16508

- pmbus/adm1275: Disable ADC while updating PMON_CONFIG, and fix
problems with temperature monitoring on ADM1272

- sht3x: Various cleanups; support for medium repeatability

Other notable changes:

- Switched regmap drivers to Maple tree support where appropriate

Various other minor fixes and improvements"

* tag 'hwmon-for-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (54 commits)
hwmon: max31827: Switch back to use struct i2c_driver::probe
hwmon: (oxp-sensors) Add support for AOKZOE A1 PRO
hwmon: (corsair-psu) update Series 2022 and 2023 support
hwmon: (corsair-psu) various cleanups
hwmon: (corsair-psu) add support for reading PWM values and mode
hwmon: (pmbus/adm1275) Disable ADC while updating PMON_CONFIG
hwmon: (pmbus/adm1275) Prepare for protected write to PMON_CONFIG
hwmon: (oxp-sensors) Simplify logic of error return
hwmon: (oxp-sensors) Remove unused header
hwmon: (nct6755) Add support for NCT6799D
hwmon: (oxp-sensors) Add tt_toggle attribute on supported boards
hwmon: (sht3x) complement sysfs interface for sts3x
hwmon: (sht3x) Add new non-stardard sysfs attribute
hwmon: (sht3x) add medium repeatability support
hwmon: (sht3x)replace "high-precision" property to "repeatability"
hwmon: (sht3x) remove blocking_io property
hwmon: (sht3x) remove sht3x_platform_data
hwmon: (pmbus/max16601) Add support for new revisions of MAX16508
Documentation/hwmon: Fix description of devm_hwmon_device_unregister()
hwmon: (tmp464) Use maple tree register cache
...

+3910 -443
+54
Documentation/devicetree/bindings/hwmon/adi,max31827.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/adi,max31827.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Analog Devices MAX31827, MAX31828, MAX31829 Low-Power Temperature Switch 8 + 9 + maintainers: 10 + - Daniel Matyas <daniel.matyas@analog.com> 11 + 12 + description: | 13 + Analog Devices MAX31827, MAX31828, MAX31829 Low-Power Temperature Switch with 14 + I2C Interface 15 + https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31827-MAX31829.pdf 16 + 17 + properties: 18 + compatible: 19 + oneOf: 20 + - const: adi,max31827 21 + - items: 22 + - enum: 23 + - adi,max31828 24 + - adi,max31829 25 + - const: adi,max31827 26 + 27 + reg: 28 + maxItems: 1 29 + 30 + vref-supply: 31 + description: 32 + Must have values in the interval (1.6V; 3.6V) in order for the device to 33 + function correctly. 34 + 35 + required: 36 + - compatible 37 + - reg 38 + - vref-supply 39 + 40 + additionalProperties: false 41 + 42 + examples: 43 + - | 44 + i2c { 45 + #address-cells = <1>; 46 + #size-cells = <0>; 47 + 48 + temperature-sensor@42 { 49 + compatible = "adi,max31827"; 50 + reg = <0x42>; 51 + vref-supply = <&reg_vdd>; 52 + }; 53 + }; 54 + ...
+15 -5
Documentation/hwmon/aht10.rst
··· 5 5 6 6 Supported chips: 7 7 8 - * Aosong AHT10 8 + * Aosong AHT10/AHT20 9 9 10 10 Prefix: 'aht10' 11 11 12 12 Addresses scanned: None 13 13 14 - Datasheet: 14 + Datasheet(AHT10): 15 15 16 16 Chinese: http://www.aosong.com/userfiles/files/media/AHT10%E4%BA%A7%E5%93%81%E6%89%8B%E5%86%8C%20A3%2020201210.pdf 17 17 English: https://server4.eca.ir/eshop/AHT10/Aosong_AHT10_en_draft_0c.pdf 18 + 19 + Datasheet(AHT20): 20 + 21 + English: http://www.aosong.com/userfiles/files/media/Data%20Sheet%20AHT20.pdf 18 22 19 23 Author: Johannes Cornelis Draaijer <jcdra1@gmail.com> 20 24 ··· 26 22 Description 27 23 ----------- 28 24 29 - The AHT10 is a Temperature and Humidity sensor 25 + The AHT10/AHT20 is a Temperature and Humidity sensor 30 26 31 27 The address of this i2c device may only be 0x38 28 + 29 + Special Features 30 + ---------------- 31 + 32 + AHT20 has additional CRC8 support which is sent as the last byte of the sensor 33 + values. 32 34 33 35 Usage Notes 34 36 ----------- 35 37 36 - This driver does not probe for AHT10 devices, as there is no reliable 37 - way to determine if an i2c chip is or isn't an AHT10. The device has 38 + This driver does not probe for AHT10/ATH20 devices, as there is no reliable 39 + way to determine if an i2c chip is or isn't an AHT10/AHT20. The device has 38 40 to be instantiated explicitly with the address 0x38. See 39 41 Documentation/i2c/instantiating-devices.rst for details. 40 42
+9
Documentation/hwmon/aquacomputer_d5next.rst
··· 12 12 * Aquacomputer Octo fan controller 13 13 * Aquacomputer Quadro fan controller 14 14 * Aquacomputer High Flow Next sensor 15 + * Aquacomputer Leakshield leak prevention system 15 16 * Aquacomputer Aquastream XT watercooling pump 16 17 * Aquacomputer Aquastream Ultimate watercooling pump 17 18 * Aquacomputer Poweradjust 3 fan controller ··· 58 57 A temperature sensor can be connected to it, in which case it provides its reading 59 58 and an estimation of the dissipated/absorbed power in the liquid cooling loop. 60 59 60 + The Leakshield exposes two temperature sensors and coolant pressure (current, min, max and 61 + target readings). It also exposes the estimated reservoir volume and how much of it is 62 + filled with coolant. Pump RPM and flow can be set to enhance on-device calculations, 63 + but this is not yet implemented here. 64 + 61 65 The Aquastream XT pump exposes temperature readings for the coolant, external sensor 62 66 and fan IC. It also exposes pump and fan speeds (in RPM), voltages, as well as pump 63 67 current. ··· 89 83 temp[1-20]_input Physical/virtual temperature sensors (in millidegrees Celsius) 90 84 temp[1-8]_offset Temperature sensor correction offset (in millidegrees Celsius) 91 85 fan[1-8]_input Pump/fan speed (in RPM) / Flow speed (in dL/h) 86 + fan1_min Minimal fan speed (in RPM) 87 + fan1_max Maximal fan speed (in RPM) 88 + fan1_target Target fan speed (in RPM) 92 89 fan5_pulses Quadro flow sensor pulses 93 90 power[1-8]_input Pump/fan power (in micro Watts) 94 91 in[0-7]_input Pump/fan voltage (in milli Volts)
+1
Documentation/hwmon/asus_ec_sensors.rst
··· 14 14 * ROG CROSSHAIR VIII FORMULA 15 15 * ROG CROSSHAIR VIII HERO 16 16 * ROG CROSSHAIR VIII IMPACT 17 + * ROG CROSSHAIR X670E HERO 17 18 * ROG MAXIMUS XI HERO 18 19 * ROG MAXIMUS XI HERO (WI-FI) 19 20 * ROG STRIX B550-E GAMING
+10 -5
Documentation/hwmon/corsair-psu.rst
··· 15 15 16 16 Corsair HX850i 17 17 18 - Corsair HX1000i (revision 1 and 2) 18 + Corsair HX1000i (Series 2022 and 2023) 19 19 20 20 Corsair HX1200i 21 21 22 - Corsair HX1500i 22 + Corsair HX1500i (Series 2022 and 2023) 23 23 24 24 Corsair RM550i 25 25 ··· 69 69 power2_input Power usage of the 12v psu rail 70 70 power3_input Power usage of the 5v psu rail 71 71 power4_input Power usage of the 3.3v psu rail 72 + pwm1 PWM value, read only 73 + pwm1_enable PWM mode, read only 72 74 temp1_input Temperature of the psu vrm component 73 75 temp1_crit Temperature max cirtical value of the psu vrm component 74 76 temp2_input Temperature of the psu case ··· 80 78 Usage Notes 81 79 ----------- 82 80 83 - It is an USB HID device, so it is auto-detected and supports hot-swapping. 81 + It is an USB HID device, so it is auto-detected, supports hot-swapping and 82 + several devices at once. 84 83 85 84 Flickering values in the rail voltage levels can be an indicator for a failing 86 - PSU. The driver also provides some additional useful values via debugfs, which 87 - do not fit into the hwmon class. 85 + PSU. Accordingly to the default automatic fan speed plan the fan starts at about 86 + 30% of the wattage rating. If this does not happen, a fan failure is likely. The 87 + driver also provides some additional useful values via debugfs, which do not fit 88 + into the hwmon class. 88 89 89 90 Debugfs entries 90 91 ---------------
+140
Documentation/hwmon/hp-wmi-sensors.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0-or-later 2 + 3 + .. include:: <isonum.txt> 4 + 5 + =========================== 6 + Linux HP WMI Sensors Driver 7 + =========================== 8 + 9 + :Copyright: |copy| 2023 James Seo <james@equiv.tech> 10 + 11 + Description 12 + =========== 13 + 14 + Hewlett-Packard (and some HP Compaq) business-class computers report hardware 15 + monitoring information via Windows Management Instrumentation (WMI). 16 + This driver exposes that information to the Linux hwmon subsystem, allowing 17 + userspace utilities like ``sensors`` to gather numeric sensor readings. 18 + 19 + sysfs interface 20 + =============== 21 + 22 + When the driver is loaded, it discovers the sensors available on the 23 + system and creates the following sysfs attributes as necessary within 24 + ``/sys/class/hwmon/hwmon[X]``: 25 + 26 + (``[X]`` is some number that depends on other system components.) 27 + 28 + ======================= ======= =================================== 29 + Name Perm Description 30 + ======================= ======= =================================== 31 + ``curr[X]_input`` RO Current in milliamperes (mA). 32 + ``curr[X]_label`` RO Current sensor label. 33 + ``fan[X]_input`` RO Fan speed in RPM. 34 + ``fan[X]_label`` RO Fan sensor label. 35 + ``fan[X]_fault`` RO Fan sensor fault indicator. 36 + ``fan[X]_alarm`` RO Fan sensor alarm indicator. 37 + ``in[X]_input`` RO Voltage in millivolts (mV). 38 + ``in[X]_label`` RO Voltage sensor label. 39 + ``temp[X]_input`` RO Temperature in millidegrees Celsius 40 + (m\ |deg|\ C). 41 + ``temp[X]_label`` RO Temperature sensor label. 42 + ``temp[X]_fault`` RO Temperature sensor fault indicator. 43 + ``temp[X]_alarm`` RO Temperature sensor alarm indicator. 44 + ``intrusion[X]_alarm`` RW Chassis intrusion alarm indicator. 45 + ======================= ======= =================================== 46 + 47 + ``fault`` attributes 48 + Reading ``1`` instead of ``0`` as the ``fault`` attribute for a sensor 49 + indicates that it has encountered some issue during operation such that 50 + measurements from it should not be trusted. If a sensor with the fault 51 + condition recovers later, reading this attribute will return ``0`` again. 52 + 53 + ``alarm`` attributes 54 + Reading ``1`` instead of ``0`` as the ``alarm`` attribute for a sensor 55 + indicates that one of the following has occurred, depending on its type: 56 + 57 + - ``fan``: The fan has stalled or has been disconnected while running. 58 + - ``temp``: The sensor reading has reached a critical threshold. 59 + The exact threshold is system-dependent. 60 + - ``intrusion``: The system's chassis has been opened. 61 + 62 + After ``1`` is read from an ``alarm`` attribute, the attribute resets itself 63 + and returns ``0`` on subsequent reads. As an exception, an 64 + ``intrusion[X]_alarm`` can only be manually reset by writing ``0`` to it. 65 + 66 + debugfs interface 67 + ================= 68 + 69 + .. warning:: The debugfs interface is subject to change without notice 70 + and is only available when the kernel is compiled with 71 + ``CONFIG_DEBUG_FS`` defined. 72 + 73 + The standard hwmon interface in sysfs exposes sensors of several common types 74 + that are connected as of driver initialization. However, there are usually 75 + other sensors in WMI that do not meet these criteria. In addition, a number of 76 + system-dependent "platform events objects" used for ``alarm`` attributes may 77 + be present. A debugfs interface is therefore provided for read-only access to 78 + all available HP WMI sensors and platform events objects. 79 + 80 + ``/sys/kernel/debug/hp-wmi-sensors-[X]/sensor`` 81 + contains one numbered entry per sensor with the following attributes: 82 + 83 + =============================== ======================================= 84 + Name Example 85 + =============================== ======================================= 86 + ``name`` ``CPU0 Fan`` 87 + ``description`` ``Reports CPU0 fan speed`` 88 + ``sensor_type`` ``12`` 89 + ``other_sensor_type`` (an empty string) 90 + ``operational_status`` ``2`` 91 + ``possible_states`` ``Normal,Caution,Critical,Not Present`` 92 + ``current_state`` ``Normal`` 93 + ``base_units`` ``19`` 94 + ``unit_modifier`` ``0`` 95 + ``current_reading`` ``1008`` 96 + ``rate_units`` ``0`` (only exists on some systems) 97 + =============================== ======================================= 98 + 99 + If platform events objects are available, 100 + ``/sys/kernel/debug/hp-wmi-sensors-[X]/platform_events`` 101 + contains one numbered entry per object with the following attributes: 102 + 103 + =============================== ==================== 104 + Name Example 105 + =============================== ==================== 106 + ``name`` ``CPU0 Fan Stall`` 107 + ``description`` ``CPU0 Fan Speed`` 108 + ``source_namespace`` ``root\wmi`` 109 + ``source_class`` ``HPBIOS_BIOSEvent`` 110 + ``category`` ``3`` 111 + ``possible_severity`` ``25`` 112 + ``possible_status`` ``5`` 113 + =============================== ==================== 114 + 115 + These represent the properties of the underlying ``HPBIOS_BIOSNumericSensor`` 116 + and ``HPBIOS_PlatformEvents`` WMI objects, which vary between systems. 117 + See [#]_ for more details and Managed Object Format (MOF) definitions. 118 + 119 + Known issues and limitations 120 + ============================ 121 + 122 + - If the existing hp-wmi driver for non-business-class HP systems is already 123 + loaded, ``alarm`` attributes will be unavailable even on systems that 124 + support them. This is because the same WMI event GUID used by this driver 125 + for ``alarm`` attributes is used on those systems for e.g. laptop hotkeys. 126 + - Dubious sensor hardware and inconsistent BIOS WMI implementations have been 127 + observed to cause inaccurate readings and peculiar behavior, such as alarms 128 + failing to occur or occurring only once per boot. 129 + - Only temperature, fan speed, and intrusion sensor types have been seen in 130 + the wild so far. Support for voltage and current sensors is therefore 131 + provisional. 132 + - Although HP WMI sensors may claim to be of any type, any oddball sensor 133 + types unknown to hwmon will not be supported. 134 + 135 + References 136 + ========== 137 + 138 + .. [#] Hewlett-Packard Development Company, L.P., 139 + "HP Client Management Interface Technical White Paper", 2005. [Online]. 140 + Available: https://h20331.www2.hp.com/hpsub/downloads/cmi_whitepaper.pdf
+1 -1
Documentation/hwmon/hwmon-kernel-api.rst
··· 66 66 67 67 devm_hwmon_device_unregister does not normally have to be called. It is only 68 68 needed for error handling, and only needed if the driver probe fails after 69 - the call to hwmon_device_register_with_info and if the automatic (device 69 + the call to devm_hwmon_device_register_with_info and if the automatic (device 70 70 managed) removal would be too late. 71 71 72 72 All supported hwmon device registration functions only accept valid device
+3 -1
Documentation/hwmon/index.rst
··· 9 9 10 10 hwmon-kernel-api 11 11 pmbus-core 12 - inspur-ipsps1 13 12 submitting-patches 14 13 sysfs-interface 15 14 userspace-tools ··· 77 78 gl518sm 78 79 gxp-fan-ctrl 79 80 hih6130 81 + hp-wmi-sensors 80 82 ibmaem 81 83 ibm-cffps 82 84 ibmpowernv ··· 85 85 ina2xx 86 86 ina238 87 87 ina3221 88 + inspur-ipsps1 88 89 intel-m10-bmc-hwmon 89 90 ir35221 90 91 ir38064 ··· 141 140 max31760 142 141 max31785 143 142 max31790 143 + max31827 144 144 max34440 145 145 max6620 146 146 max6639
+90
Documentation/hwmon/max31827.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Kernel driver max31827 4 + ====================== 5 + 6 + Supported chips: 7 + 8 + * Maxim MAX31827 9 + 10 + Prefix: 'max31827' 11 + 12 + Addresses scanned: I2C 0x40 - 0x5f 13 + 14 + Datasheet: Publicly available at the Analog Devices website 15 + 16 + * Maxim MAX31828 17 + 18 + Prefix: 'max31828' 19 + 20 + Addresses scanned: I2C 0x40 - 0x5f 21 + 22 + Datasheet: Publicly available at the Analog Devices website 23 + 24 + * Maxim MAX31829 25 + 26 + Prefix: 'max31829' 27 + 28 + Addresses scanned: I2C 0x40 - 0x5f 29 + 30 + Datasheet: Publicly available at the Analog Devices website 31 + 32 + 33 + Authors: 34 + - Daniel Matyas <daniel.matyas@analog.com> 35 + 36 + Description 37 + ----------- 38 + 39 + The chips supported by this driver are quite similar. The only difference 40 + between them is found in the default power-on behaviour of the chips. While the 41 + MAX31827's fault queue is set to 1, the other two chip's fault queue is set to 42 + 4. Besides this, the MAX31829's alarm active state is high, while the other two 43 + chip's alarms are active on low. It is important to note that the chips can be 44 + configured to operate in the same manner with 1 write operation to the 45 + configuration register. From here on, we will refer to all these chips as 46 + MAX31827. 47 + 48 + MAX31827 implements a temperature sensor with a 6 WLP packaging scheme. This 49 + sensor measures the temperature of the chip itself. 50 + 51 + MAX31827 has low and over temperature alarms with an effective value and a 52 + hysteresis value: -40 and -30 degrees for under temperature alarm and +100 and 53 + +90 degrees for over temperature alarm. 54 + 55 + The alarm can be configured in comparator and interrupt mode. Currently only 56 + comparator mode is implemented. In Comparator mode, the OT/UT status bits have a 57 + value of 1 when the temperature rises above the TH value or falls below TL, 58 + which is also subject to the Fault Queue selection. OT status returns to 0 when 59 + the temperature drops below the TH_HYST value or when shutdown mode is entered. 60 + Similarly, UT status returns to 0 when the temperature rises above TL_HYST value 61 + or when shutdown mode is entered. 62 + 63 + Putting the MAX31827 into shutdown mode also resets the OT/UT status bits. Note 64 + that if the mode is changed while OT/UT status bits are set, an OT/UT status 65 + reset may be required before it begins to behave normally. To prevent this, 66 + it is recommended to perform a read of the configuration/status register to 67 + clear the status bits before changing the operating mode. 68 + 69 + The conversions can be manual with the one-shot functionality and automatic with 70 + a set frequency. When powered on, the chip measures temperatures with 1 conv/s. 71 + Enabling the device when it is already enabled has the side effect of setting 72 + the conversion frequency to 1 conv/s. The conversion time varies depending on 73 + the resolution. The conversion time doubles with every bit of increased 74 + resolution. For 10 bit resolution 35ms are needed, while for 12 bit resolution 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. 78 + 79 + The LSB of the temperature values is 0.0625 degrees Celsius, but the values of 80 + the temperatures are displayed in milli-degrees. This means, that some data is 81 + lost. The step between 2 consecutive values is 62 or 63. This effect can be seen 82 + in the writing of alarm values too. For positive numbers the user-input value 83 + will always be rounded down to the nearest possible value, for negative numbers 84 + the user-input will always be rounded up to the nearest possible value. 85 + 86 + Notes 87 + ----- 88 + 89 + Currently fault queue, alarm polarity and resolution cannot be modified. 90 + PEC is not implemented either.
+21
Documentation/hwmon/oxp-sensors.rst
··· 19 19 different. Aya Neo devices preceding the AIR may not be supportable as the EC 20 20 model is different and do not appear to have manual control capabilities. 21 21 22 + Some models have a toggle for changing the behaviour of the "Turbo/Silent" 23 + button of the device. It will change the key event that it triggers with 24 + a flip of the `tt_toggle` attribute. See below for boards that support this 25 + function. 26 + 22 27 Supported devices 23 28 ----------------- 24 29 25 30 Currently the driver supports the following handhelds: 26 31 27 32 - AOK ZOE A1 33 + - AOK ZOE A1 PRO 34 + - Aya Neo 2 28 35 - Aya Neo AIR 29 36 - Aya Neo AIR Pro 37 + - Aya Neo Geek 30 38 - OneXPlayer AMD 31 39 - OneXPlayer mini AMD 40 + - OneXPlayer mini AMD PRO 41 + 42 + "Turbo/Silent" button behaviour toggle is only supported on: 43 + - AOK ZOE A1 44 + - AOK ZOE A1 PRO 45 + - OneXPlayer mini AMD (only with updated alpha BIOS) 32 46 - OneXPlayer mini AMD PRO 33 47 34 48 Sysfs entries ··· 61 47 Read Write. Read this attribute to see current duty cycle in the range [0-255]. 62 48 When pwm1_enable is set to "1" (manual) write any value in the range [0-255] 63 49 to set fan speed. 50 + 51 + tt_toggle 52 + Read Write. Read this attribute to check the status of the turbo/silent 53 + button behaviour function. Write "1" to activate the switch and "0" to 54 + deactivate it. The specific keycodes and behaviour is specific to the device 55 + both with this function on and off. This attribute is attached to the platform 56 + driver and not to the hwmon driver (/sys/devices/platform/oxp-platform/tt_toggle)
+9 -9
Documentation/hwmon/sht3x.rst
··· 28 28 addresses 0x44 or 0x45, depending on the wiring. See 29 29 Documentation/i2c/instantiating-devices.rst for methods to instantiate the device. 30 30 31 - There are two options configurable by means of sht3x_platform_data: 32 - 33 - 1. blocking (pull the I2C clock line down while performing the measurement) or 34 - non-blocking mode. Blocking mode will guarantee the fastest result but 35 - the I2C bus will be busy during that time. By default, non-blocking mode 36 - is used. Make sure clock-stretching works properly on your device if you 37 - want to use blocking mode. 38 - 2. high or low accuracy. High accuracy is used by default and using it is 39 - strongly recommended. 31 + Even if sht3x sensor supports clock-strech(blocking mode) and non-strench 32 + (non-blocking mode) in single-shot mode, this driver only supports the latter. 40 33 41 34 The sht3x sensor supports a single shot mode as well as 5 periodic measure 42 35 modes, which can be controlled with the update_interval sysfs interface. ··· 78 85 update_interval: update interval, 0 for single shot, interval in msec 79 86 for periodic measurement. If the interval is not supported 80 87 by the sensor, the next faster interval is chosen 88 + repeatability: write or read repeatability, higher repeatability means 89 + longer measurement duration, lower noise level and 90 + larger energy consumption: 91 + 92 + - 0: low repeatability 93 + - 1: medium repeatability 94 + - 2: high repeatability 81 95 =================== ============================================================
+16
MAINTAINERS
··· 9473 9473 S: Orphan 9474 9474 F: drivers/platform/x86/hp/tc1100-wmi.c 9475 9475 9476 + HP WMI HARDWARE MONITOR DRIVER 9477 + M: James Seo <james@equiv.tech> 9478 + L: linux-hwmon@vger.kernel.org 9479 + S: Maintained 9480 + F: Documentation/hwmon/hp-wmi-sensors.rst 9481 + F: drivers/hwmon/hp-wmi-sensors.c 9482 + 9476 9483 HPET: High Precision Event Timers driver 9477 9484 M: Clemens Ladisch <clemens@ladisch.de> 9478 9485 S: Maintained ··· 12677 12670 F: Documentation/userspace-api/media/drivers/max2175.rst 12678 12671 F: drivers/media/i2c/max2175* 12679 12672 F: include/uapi/linux/max2175.h 12673 + 12674 + MAX31827 TEMPERATURE SWITCH DRIVER 12675 + M: Daniel Matyas <daniel.matyas@analog.com> 12676 + L: linux-hwmon@vger.kernel.org 12677 + S: Supported 12678 + W: http://ez.analog.com/community/linux-device-drivers 12679 + F: Documentation/devicetree/bindings/hwmon/adi,max31827.yaml 12680 + F: Documentation/hwmon/max31827.rst 12681 + F: drivers/hwmon/max31827.c 12680 12682 12681 12683 MAX6650 HARDWARE MONITOR AND FAN CONTROLLER DRIVER 12682 12684 L: linux-hwmon@vger.kernel.org
+26 -2
drivers/hwmon/Kconfig
··· 255 255 will be called adt7475. 256 256 257 257 config SENSORS_AHT10 258 - tristate "Aosong AHT10" 258 + tristate "Aosong AHT10, AHT20" 259 259 depends on I2C 260 + select CRC8 260 261 help 261 - If you say yes here, you get support for the Aosong AHT10 262 + If you say yes here, you get support for the Aosong AHT10 and AHT20 262 263 temperature and humidity sensors 263 264 264 265 This driver can also be built as a module. If so, the module ··· 1097 1096 1098 1097 This driver can also be built as a module. If so, the module 1099 1098 will be called max31760. 1099 + 1100 + config MAX31827 1101 + tristate "MAX31827 low-power temperature switch and similar devices" 1102 + depends on I2C 1103 + select REGMAP_I2C 1104 + help 1105 + If you say yes here you get support for MAX31827, MAX31828 and 1106 + MAX31829 low-power temperature switches and sensors connected with I2C. 1107 + 1108 + This driver can also be built as a module. If so, the module 1109 + will be called max31827. 1100 1110 1101 1111 config SENSORS_MAX6620 1102 1112 tristate "Maxim MAX6620 fan controller" ··· 2420 2408 2421 2409 This driver can also be built as a module. If so, the module 2422 2410 will be called asus_ec_sensors. 2411 + 2412 + config SENSORS_HP_WMI 2413 + tristate "HP WMI Sensors" 2414 + depends on ACPI_WMI 2415 + help 2416 + If you say yes here you get support for the ACPI hardware monitoring 2417 + interface found in HP (and some HP Compaq) business-class computers. 2418 + Available sensors vary between systems. Temperature and fan speed 2419 + sensors are the most common. 2420 + 2421 + This driver can also be built as a module. If so, the module 2422 + will be called hp_wmi_sensors. 2423 2423 2424 2424 endif # ACPI 2425 2425
+2 -1
drivers/hwmon/Makefile
··· 11 11 obj-$(CONFIG_SENSORS_ATK0110) += asus_atk0110.o 12 12 obj-$(CONFIG_SENSORS_ASUS_EC) += asus-ec-sensors.o 13 13 obj-$(CONFIG_SENSORS_ASUS_WMI) += asus_wmi_sensors.o 14 + obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o 14 15 15 16 # Native drivers 16 17 # asb100, then w83781d go first, as they can override other drivers' addresses. ··· 150 149 obj-$(CONFIG_SENSORS_MAX6650) += max6650.o 151 150 obj-$(CONFIG_SENSORS_MAX6697) += max6697.o 152 151 obj-$(CONFIG_SENSORS_MAX31790) += max31790.o 152 + obj-$(CONFIG_MAX31827) += max31827.o 153 153 obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o 154 154 obj-$(CONFIG_SENSORS_MC34VR500) += mc34vr500.o 155 155 obj-$(CONFIG_SENSORS_MCP3021) += mcp3021.o ··· 226 224 obj-$(CONFIG_PMBUS) += pmbus/ 227 225 228 226 ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG 229 -
+1 -1
drivers/hwmon/ad7414.c
··· 221 221 .name = "ad7414", 222 222 .of_match_table = of_match_ptr(ad7414_of_match), 223 223 }, 224 - .probe_new = ad7414_probe, 224 + .probe = ad7414_probe, 225 225 .id_table = ad7414_id, 226 226 }; 227 227
+1 -1
drivers/hwmon/ad7418.c
··· 306 306 .name = "ad7418", 307 307 .of_match_table = ad7418_dt_ids, 308 308 }, 309 - .probe_new = ad7418_probe, 309 + .probe = ad7418_probe, 310 310 .id_table = ad7418_id, 311 311 }; 312 312
+1 -1
drivers/hwmon/adc128d818.c
··· 521 521 .name = "adc128d818", 522 522 .of_match_table = of_match_ptr(adc128_of_match), 523 523 }, 524 - .probe_new = adc128_probe, 524 + .probe = adc128_probe, 525 525 .remove = adc128_remove, 526 526 .id_table = adc128_id, 527 527 .detect = adc128_detect,
+1 -1
drivers/hwmon/adm1021.c
··· 488 488 .driver = { 489 489 .name = "adm1021", 490 490 }, 491 - .probe_new = adm1021_probe, 491 + .probe = adm1021_probe, 492 492 .id_table = adm1021_id, 493 493 .detect = adm1021_detect, 494 494 .address_list = normal_i2c,
+1 -1
drivers/hwmon/adm1025.c
··· 559 559 .driver = { 560 560 .name = "adm1025", 561 561 }, 562 - .probe_new = adm1025_probe, 562 + .probe = adm1025_probe, 563 563 .id_table = adm1025_id, 564 564 .detect = adm1025_detect, 565 565 .address_list = normal_i2c,
+1 -1
drivers/hwmon/adm1026.c
··· 1859 1859 .driver = { 1860 1860 .name = "adm1026", 1861 1861 }, 1862 - .probe_new = adm1026_probe, 1862 + .probe = adm1026_probe, 1863 1863 .id_table = adm1026_id, 1864 1864 .detect = adm1026_detect, 1865 1865 .address_list = normal_i2c,
+1 -1
drivers/hwmon/adm1029.c
··· 389 389 .driver = { 390 390 .name = "adm1029", 391 391 }, 392 - .probe_new = adm1029_probe, 392 + .probe = adm1029_probe, 393 393 .id_table = adm1029_id, 394 394 .detect = adm1029_detect, 395 395 .address_list = normal_i2c,
+1 -1
drivers/hwmon/adm1031.c
··· 1068 1068 .driver = { 1069 1069 .name = "adm1031", 1070 1070 }, 1071 - .probe_new = adm1031_probe, 1071 + .probe = adm1031_probe, 1072 1072 .id_table = adm1031_id, 1073 1073 .detect = adm1031_detect, 1074 1074 .address_list = normal_i2c,
+1 -1
drivers/hwmon/adm1177.c
··· 255 255 .name = "adm1177", 256 256 .of_match_table = adm1177_dt_ids, 257 257 }, 258 - .probe_new = adm1177_probe, 258 + .probe = adm1177_probe, 259 259 .id_table = adm1177_id, 260 260 }; 261 261 module_i2c_driver(adm1177_driver);
+1 -1
drivers/hwmon/adm9240.c
··· 819 819 .driver = { 820 820 .name = "adm9240", 821 821 }, 822 - .probe_new = adm9240_probe, 822 + .probe = adm9240_probe, 823 823 .id_table = adm9240_id, 824 824 .detect = adm9240_detect, 825 825 .address_list = normal_i2c,
+1 -1
drivers/hwmon/ads7828.c
··· 208 208 }, 209 209 210 210 .id_table = ads7828_device_ids, 211 - .probe_new = ads7828_probe, 211 + .probe = ads7828_probe, 212 212 }; 213 213 214 214 module_i2c_driver(ads7828_driver);
+1 -1
drivers/hwmon/adt7410.c
··· 100 100 .name = "adt7410", 101 101 .pm = pm_sleep_ptr(&adt7x10_dev_pm_ops), 102 102 }, 103 - .probe_new = adt7410_i2c_probe, 103 + .probe = adt7410_i2c_probe, 104 104 .id_table = adt7410_ids, 105 105 .address_list = I2C_ADDRS(0x48, 0x49, 0x4a, 0x4b), 106 106 };
+1 -1
drivers/hwmon/adt7411.c
··· 706 706 .driver = { 707 707 .name = "adt7411", 708 708 }, 709 - .probe_new = adt7411_probe, 709 + .probe = adt7411_probe, 710 710 .id_table = adt7411_id, 711 711 .detect = adt7411_detect, 712 712 .address_list = normal_i2c,
+1 -1
drivers/hwmon/adt7462.c
··· 1819 1819 .driver = { 1820 1820 .name = "adt7462", 1821 1821 }, 1822 - .probe_new = adt7462_probe, 1822 + .probe = adt7462_probe, 1823 1823 .id_table = adt7462_id, 1824 1824 .detect = adt7462_detect, 1825 1825 .address_list = normal_i2c,
+1 -1
drivers/hwmon/adt7470.c
··· 1314 1314 .driver = { 1315 1315 .name = "adt7470", 1316 1316 }, 1317 - .probe_new = adt7470_probe, 1317 + .probe = adt7470_probe, 1318 1318 .remove = adt7470_remove, 1319 1319 .id_table = adt7470_id, 1320 1320 .detect = adt7470_detect,
+5 -5
drivers/hwmon/adt7475.c
··· 1468 1468 u8 config3; 1469 1469 int ret; 1470 1470 1471 - ret = of_property_read_string(client->dev.of_node, propname, &function); 1471 + ret = device_property_read_string(&client->dev, propname, &function); 1472 1472 if (!ret) { 1473 1473 ret = adt7475_read(REG_CONFIG3); 1474 1474 if (ret < 0) ··· 1494 1494 u8 config4; 1495 1495 int ret; 1496 1496 1497 - ret = of_property_read_string(client->dev.of_node, propname, &function); 1497 + ret = device_property_read_string(&client->dev, propname, &function); 1498 1498 if (!ret) { 1499 1499 ret = adt7475_read(REG_CONFIG4); 1500 1500 if (ret < 0) ··· 1556 1556 u8 *config, u8 bit_index) 1557 1557 { 1558 1558 u32 prop_value = 0; 1559 - int ret = of_property_read_u32(client->dev.of_node, property, 1560 - &prop_value); 1559 + int ret = device_property_read_u32(&client->dev, property, 1560 + &prop_value); 1561 1561 1562 1562 if (!ret) { 1563 1563 if (prop_value) ··· 1821 1821 .name = "adt7475", 1822 1822 .of_match_table = of_match_ptr(adt7475_of_match), 1823 1823 }, 1824 - .probe_new = adt7475_probe, 1824 + .probe = adt7475_probe, 1825 1825 .id_table = adt7475_id, 1826 1826 .detect = adt7475_detect, 1827 1827 .address_list = normal_i2c,
+101 -53
drivers/hwmon/aht10.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 3 3 /* 4 - * aht10.c - Linux hwmon driver for AHT10 Temperature and Humidity sensor 4 + * aht10.c - Linux hwmon driver for AHT10/AHT20 Temperature and Humidity sensors 5 5 * Copyright (C) 2020 Johannes Cornelis Draaijer 6 6 */ 7 7 ··· 10 10 #include <linux/i2c.h> 11 11 #include <linux/ktime.h> 12 12 #include <linux/module.h> 13 + #include <linux/crc8.h> 13 14 14 15 #define AHT10_MEAS_SIZE 6 16 + 17 + #define AHT20_MEAS_SIZE 7 18 + #define AHT20_CRC8_POLY 0x31 15 19 16 20 /* 17 21 * Poll intervals (in milliseconds) ··· 48 44 49 45 #define AHT10_MAX_POLL_INTERVAL_LEN 30 50 46 47 + enum aht10_variant { aht10, aht20 }; 48 + 49 + static const struct i2c_device_id aht10_id[] = { 50 + { "aht10", aht10 }, 51 + { "aht20", aht20 }, 52 + { }, 53 + }; 54 + MODULE_DEVICE_TABLE(i2c, aht10_id); 55 + 51 56 /** 52 - * struct aht10_data - All the data required to operate an AHT10 chip 53 - * @client: the i2c client associated with the AHT10 57 + * struct aht10_data - All the data required to operate an AHT10/AHT20 chip 58 + * @client: the i2c client associated with the AHT10/AHT20 54 59 * @lock: a mutex that is used to prevent parallel access to the 55 60 * i2c client 56 61 * @min_poll_interval: the minimum poll interval ··· 69 56 * the chip from warming up due to the heat it generates. 70 57 * If it's unwanted, it can be ignored setting it to 71 58 * it to 0. Default value is 2000 ms 72 - * @previous_poll_time: the previous time that the AHT10 59 + * @previous_poll_time: the previous time that the AHT10/AHT20 73 60 * was polled 74 61 * @temperature: the latest temperature value received from 75 - * the AHT10 62 + * the AHT10/AHT20 76 63 * @humidity: the latest humidity value received from the 77 - * AHT10 64 + * AHT10/AHT20 65 + * @crc8: crc8 support flag 66 + * @meas_size: measurements data size 78 67 */ 79 68 80 69 struct aht10_data { ··· 90 75 ktime_t previous_poll_time; 91 76 int temperature; 92 77 int humidity; 78 + bool crc8; 79 + unsigned int meas_size; 93 80 }; 94 81 95 82 /** 96 - * aht10_init() - Initialize an AHT10 chip 97 - * @data: the data associated with this AHT10 chip 98 - * Return: 0 if succesfull, 1 if not 83 + * aht10_init() - Initialize an AHT10/AHT20 chip 84 + * @data: the data associated with this AHT10/AHT20 chip 85 + * Return: 0 if successful, 1 if not 99 86 */ 100 87 static int aht10_init(struct aht10_data *data) 101 88 { ··· 138 121 return ktime_after(difference, data->min_poll_interval); 139 122 } 140 123 124 + DECLARE_CRC8_TABLE(crc8_table); 125 + 141 126 /** 142 - * aht10_read_values() - read and parse the raw data from the AHT10 127 + * crc8_check() - check crc of the sensor's measurements 128 + * @raw_data: data frame received from sensor(including crc as the last byte) 129 + * @count: size of the data frame 130 + * Return: 0 if successful, 1 if not 131 + */ 132 + static int crc8_check(u8 *raw_data, int count) 133 + { 134 + /* 135 + * crc calculated on the whole frame(including crc byte) should yield 136 + * zero in case of correctly received bytes 137 + */ 138 + return crc8(crc8_table, raw_data, count, CRC8_INIT_VALUE); 139 + } 140 + 141 + /** 142 + * aht10_read_values() - read and parse the raw data from the AHT10/AHT20 143 143 * @data: the struct aht10_data to use for the lock 144 - * Return: 0 if succesfull, 1 if not 144 + * Return: 0 if successful, 1 if not 145 145 */ 146 146 static int aht10_read_values(struct aht10_data *data) 147 147 { 148 148 const u8 cmd_meas[] = {AHT10_CMD_MEAS, 0x33, 0x00}; 149 149 u32 temp, hum; 150 150 int res; 151 - u8 raw_data[AHT10_MEAS_SIZE]; 151 + u8 raw_data[AHT20_MEAS_SIZE]; 152 152 struct i2c_client *client = data->client; 153 153 154 154 mutex_lock(&data->lock); 155 - if (aht10_polltime_expired(data)) { 156 - res = i2c_master_send(client, cmd_meas, sizeof(cmd_meas)); 157 - if (res < 0) { 158 - mutex_unlock(&data->lock); 159 - return res; 160 - } 161 - 162 - usleep_range(AHT10_MEAS_DELAY, 163 - AHT10_MEAS_DELAY + AHT10_DELAY_EXTRA); 164 - 165 - res = i2c_master_recv(client, raw_data, AHT10_MEAS_SIZE); 166 - if (res != AHT10_MEAS_SIZE) { 167 - mutex_unlock(&data->lock); 168 - if (res >= 0) 169 - return -ENODATA; 170 - else 171 - return res; 172 - } 173 - 174 - hum = ((u32)raw_data[1] << 12u) | 175 - ((u32)raw_data[2] << 4u) | 176 - ((raw_data[3] & 0xF0u) >> 4u); 177 - 178 - temp = ((u32)(raw_data[3] & 0x0Fu) << 16u) | 179 - ((u32)raw_data[4] << 8u) | 180 - raw_data[5]; 181 - 182 - temp = ((temp * 625) >> 15u) * 10; 183 - hum = ((hum * 625) >> 16u) * 10; 184 - 185 - data->temperature = (int)temp - 50000; 186 - data->humidity = hum; 187 - data->previous_poll_time = ktime_get_boottime(); 155 + if (!aht10_polltime_expired(data)) { 156 + mutex_unlock(&data->lock); 157 + return 0; 188 158 } 159 + 160 + res = i2c_master_send(client, cmd_meas, sizeof(cmd_meas)); 161 + if (res < 0) { 162 + mutex_unlock(&data->lock); 163 + return res; 164 + } 165 + 166 + usleep_range(AHT10_MEAS_DELAY, AHT10_MEAS_DELAY + AHT10_DELAY_EXTRA); 167 + 168 + res = i2c_master_recv(client, raw_data, data->meas_size); 169 + if (res != data->meas_size) { 170 + mutex_unlock(&data->lock); 171 + if (res >= 0) 172 + return -ENODATA; 173 + return res; 174 + } 175 + 176 + if (data->crc8 && crc8_check(raw_data, data->meas_size)) { 177 + mutex_unlock(&data->lock); 178 + return -EIO; 179 + } 180 + 181 + hum = ((u32)raw_data[1] << 12u) | 182 + ((u32)raw_data[2] << 4u) | 183 + ((raw_data[3] & 0xF0u) >> 4u); 184 + 185 + temp = ((u32)(raw_data[3] & 0x0Fu) << 16u) | 186 + ((u32)raw_data[4] << 8u) | 187 + raw_data[5]; 188 + 189 + temp = ((temp * 625) >> 15u) * 10; 190 + hum = ((hum * 625) >> 16u) * 10; 191 + 192 + data->temperature = (int)temp - 50000; 193 + data->humidity = hum; 194 + data->previous_poll_time = ktime_get_boottime(); 195 + 189 196 mutex_unlock(&data->lock); 190 197 return 0; 191 198 } ··· 331 290 332 291 static int aht10_probe(struct i2c_client *client) 333 292 { 293 + const struct i2c_device_id *id = i2c_match_id(aht10_id, client); 294 + enum aht10_variant variant = id->driver_data; 334 295 struct device *device = &client->dev; 335 296 struct device *hwmon_dev; 336 297 struct aht10_data *data; ··· 347 304 348 305 data->min_poll_interval = ms_to_ktime(AHT10_DEFAULT_MIN_POLL_INTERVAL); 349 306 data->client = client; 307 + 308 + switch (variant) { 309 + case aht20: 310 + data->meas_size = AHT20_MEAS_SIZE; 311 + data->crc8 = true; 312 + crc8_populate_msb(crc8_table, AHT20_CRC8_POLY); 313 + break; 314 + default: 315 + data->meas_size = AHT10_MEAS_SIZE; 316 + break; 317 + } 350 318 351 319 mutex_init(&data->lock); 352 320 ··· 378 324 return PTR_ERR_OR_ZERO(hwmon_dev); 379 325 } 380 326 381 - static const struct i2c_device_id aht10_id[] = { 382 - { "aht10", 0 }, 383 - { }, 384 - }; 385 - MODULE_DEVICE_TABLE(i2c, aht10_id); 386 - 387 327 static struct i2c_driver aht10_driver = { 388 328 .driver = { 389 329 .name = "aht10", 390 330 }, 391 - .probe_new = aht10_probe, 331 + .probe = aht10_probe, 392 332 .id_table = aht10_id, 393 333 }; 394 334 395 335 module_i2c_driver(aht10_driver); 396 336 397 337 MODULE_AUTHOR("Johannes Cornelis Draaijer <jcdra1@gmail.com>"); 398 - MODULE_DESCRIPTION("AHT10 Temperature and Humidity sensor driver"); 338 + MODULE_DESCRIPTION("AHT10/AHT20 Temperature and Humidity sensor driver"); 399 339 MODULE_VERSION("1.0"); 400 340 MODULE_LICENSE("GPL v2");
+1 -1
drivers/hwmon/amc6821.c
··· 939 939 .driver = { 940 940 .name = "amc6821", 941 941 }, 942 - .probe_new = amc6821_probe, 942 + .probe = amc6821_probe, 943 943 .id_table = amc6821_id, 944 944 .detect = amc6821_detect, 945 945 .address_list = normal_i2c,
+109 -8
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) 4 + * Quadro, High Flow Next, Aquaero, Aquastream Ultimate, Leakshield) 5 5 * 6 6 * Aquacomputer devices send HID reports (with ID 0x01) every second to report 7 7 * sensor values, except for devices that communicate through the ··· 29 29 #define USB_PRODUCT_ID_FARBWERK360 0xf010 30 30 #define USB_PRODUCT_ID_OCTO 0xf011 31 31 #define USB_PRODUCT_ID_HIGHFLOWNEXT 0xf012 32 + #define USB_PRODUCT_ID_LEAKSHIELD 0xf014 32 33 #define USB_PRODUCT_ID_AQUASTREAMXT 0xf0b6 33 34 #define USB_PRODUCT_ID_AQUASTREAMULT 0xf00b 34 35 #define USB_PRODUCT_ID_POWERADJUST3 0xf0bd ··· 37 36 enum kinds { 38 37 d5next, farbwerk, farbwerk360, octo, quadro, 39 38 highflownext, aquaero, poweradjust3, aquastreamult, 40 - aquastreamxt 39 + aquastreamxt, leakshield 41 40 }; 42 41 43 42 static const char *const aqc_device_names[] = { ··· 47 46 [octo] = "octo", 48 47 [quadro] = "quadro", 49 48 [highflownext] = "highflownext", 49 + [leakshield] = "leakshield", 50 50 [aquastreamxt] = "aquastreamxt", 51 51 [aquaero] = "aquaero", 52 52 [aquastreamult] = "aquastreamultimate", ··· 95 93 #define AQC_FIRMWARE_VERSION 0xD 96 94 97 95 #define AQC_SENSOR_SIZE 0x02 98 - #define AQC_TEMP_SENSOR_DISCONNECTED 0x7FFF 96 + #define AQC_SENSOR_NA 0x7FFF 99 97 #define AQC_FAN_PERCENT_OFFSET 0x00 100 98 #define AQC_FAN_VOLTAGE_OFFSET 0x02 101 99 #define AQC_FAN_CURRENT_OFFSET 0x04 ··· 237 235 #define HIGHFLOWNEXT_CONDUCTIVITY 95 238 236 #define HIGHFLOWNEXT_5V_VOLTAGE 97 239 237 #define HIGHFLOWNEXT_5V_VOLTAGE_USB 99 238 + 239 + /* Specs of the Leakshield */ 240 + #define LEAKSHIELD_NUM_SENSORS 2 241 + 242 + /* Sensor report offsets for Leakshield */ 243 + #define LEAKSHIELD_PRESSURE_ADJUSTED 285 244 + #define LEAKSHIELD_TEMPERATURE_1 265 245 + #define LEAKSHIELD_TEMPERATURE_2 287 246 + #define LEAKSHIELD_PRESSURE_MIN 291 247 + #define LEAKSHIELD_PRESSURE_TARGET 293 248 + #define LEAKSHIELD_PRESSURE_MAX 295 249 + #define LEAKSHIELD_PUMP_RPM_IN 101 250 + #define LEAKSHIELD_FLOW_IN 111 251 + #define LEAKSHIELD_RESERVOIR_VOLUME 313 252 + #define LEAKSHIELD_RESERVOIR_FILLED 311 240 253 241 254 /* Specs of the Aquastream XT pump */ 242 255 #define AQUASTREAMXT_SERIAL_START 0x3a ··· 428 411 "+5V USB voltage" 429 412 }; 430 413 414 + /* Labels for Leakshield */ 415 + static const char *const label_leakshield_temp_sensors[] = { 416 + "Temperature 1", 417 + "Temperature 2" 418 + }; 419 + 420 + static const char *const label_leakshield_fan_speed[] = { 421 + "Pressure [ubar]", 422 + "User-Provided Pump Speed", 423 + "User-Provided Flow [dL/h]", 424 + "Reservoir Volume [ml]", 425 + "Reservoir Filled [ml]", 426 + }; 427 + 431 428 /* Labels for Aquastream XT */ 432 429 static const char *const label_aquastreamxt_temp_sensors[] = { 433 430 "Fan IC temp", ··· 560 529 561 530 /* Sensor values */ 562 531 s32 temp_input[20]; /* Max 4 physical and 16 virtual or 8 physical and 12 virtual */ 563 - u16 speed_input[8]; 532 + s32 speed_input[8]; 533 + u32 speed_input_min[1]; 534 + u32 speed_input_target[1]; 535 + u32 speed_input_max[1]; 564 536 u32 power_input[8]; 565 537 u16 voltage_input[8]; 566 538 u16 current_input[8]; ··· 781 747 if (channel < 3) 782 748 return 0444; 783 749 break; 750 + case leakshield: 751 + /* Special case for Leakshield sensors */ 752 + if (channel < 5) 753 + return 0444; 754 + break; 784 755 case aquaero: 785 756 case quadro: 786 757 /* Special case to support flow sensors */ ··· 802 763 /* Special case for Quadro flow sensor */ 803 764 if (priv->kind == quadro && channel == priv->num_fans) 804 765 return 0644; 766 + break; 767 + case hwmon_fan_min: 768 + case hwmon_fan_max: 769 + case hwmon_fan_target: 770 + /* Special case for Leakshield pressure sensor */ 771 + if (priv->kind == leakshield && channel == 0) 772 + return 0444; 805 773 break; 806 774 default: 807 775 break; ··· 984 938 case hwmon_fan: 985 939 switch (attr) { 986 940 case hwmon_fan_input: 941 + if (priv->speed_input[channel] == -ENODATA) 942 + return -ENODATA; 943 + 987 944 *val = priv->speed_input[channel]; 945 + break; 946 + case hwmon_fan_min: 947 + *val = priv->speed_input_min[channel]; 948 + break; 949 + case hwmon_fan_max: 950 + *val = priv->speed_input_max[channel]; 951 + break; 952 + case hwmon_fan_target: 953 + *val = priv->speed_input_target[channel]; 988 954 break; 989 955 case hwmon_fan_pulses: 990 956 ret = aqc_get_ctrl_val(priv, priv->flow_pulses_ctrl_offset, ··· 1209 1151 HWMON_T_INPUT | HWMON_T_LABEL, 1210 1152 HWMON_T_INPUT | HWMON_T_LABEL), 1211 1153 HWMON_CHANNEL_INFO(fan, 1212 - HWMON_F_INPUT | HWMON_F_LABEL, 1154 + HWMON_F_INPUT | HWMON_F_LABEL | HWMON_F_MIN | HWMON_F_MAX | 1155 + HWMON_F_TARGET, 1213 1156 HWMON_F_INPUT | HWMON_F_LABEL, 1214 1157 HWMON_F_INPUT | HWMON_F_LABEL, 1215 1158 HWMON_F_INPUT | HWMON_F_LABEL, ··· 1283 1224 sensor_value = get_unaligned_be16(data + 1284 1225 priv->temp_sensor_start_offset + 1285 1226 i * AQC_SENSOR_SIZE); 1286 - if (sensor_value == AQC_TEMP_SENSOR_DISCONNECTED) 1227 + if (sensor_value == AQC_SENSOR_NA) 1287 1228 priv->temp_input[i] = -ENODATA; 1288 1229 else 1289 1230 priv->temp_input[i] = sensor_value * 10; ··· 1294 1235 sensor_value = get_unaligned_be16(data + 1295 1236 priv->virtual_temp_sensor_start_offset + 1296 1237 j * AQC_SENSOR_SIZE); 1297 - if (sensor_value == AQC_TEMP_SENSOR_DISCONNECTED) 1238 + if (sensor_value == AQC_SENSOR_NA) 1298 1239 priv->temp_input[i] = -ENODATA; 1299 1240 else 1300 1241 priv->temp_input[i] = sensor_value * 10; ··· 1336 1277 sensor_value = get_unaligned_be16(data + 1337 1278 priv->calc_virt_temp_sensor_start_offset + 1338 1279 j * AQC_SENSOR_SIZE); 1339 - if (sensor_value == AQC_TEMP_SENSOR_DISCONNECTED) 1280 + if (sensor_value == AQC_SENSOR_NA) 1340 1281 priv->temp_input[i] = -ENODATA; 1341 1282 else 1342 1283 priv->temp_input[i] = sensor_value * 10; ··· 1372 1313 1373 1314 priv->speed_input[1] = get_unaligned_be16(data + HIGHFLOWNEXT_WATER_QUALITY); 1374 1315 priv->speed_input[2] = get_unaligned_be16(data + HIGHFLOWNEXT_CONDUCTIVITY); 1316 + break; 1317 + case leakshield: 1318 + priv->speed_input[0] = 1319 + ((s16)get_unaligned_be16(data + LEAKSHIELD_PRESSURE_ADJUSTED)) * 100; 1320 + priv->speed_input_min[0] = get_unaligned_be16(data + LEAKSHIELD_PRESSURE_MIN) * 100; 1321 + priv->speed_input_target[0] = 1322 + get_unaligned_be16(data + LEAKSHIELD_PRESSURE_TARGET) * 100; 1323 + priv->speed_input_max[0] = get_unaligned_be16(data + LEAKSHIELD_PRESSURE_MAX) * 100; 1324 + 1325 + priv->speed_input[1] = get_unaligned_be16(data + LEAKSHIELD_PUMP_RPM_IN); 1326 + if (priv->speed_input[1] == AQC_SENSOR_NA) 1327 + priv->speed_input[1] = -ENODATA; 1328 + 1329 + priv->speed_input[2] = get_unaligned_be16(data + LEAKSHIELD_FLOW_IN); 1330 + if (priv->speed_input[2] == AQC_SENSOR_NA) 1331 + priv->speed_input[2] = -ENODATA; 1332 + 1333 + priv->speed_input[3] = get_unaligned_be16(data + LEAKSHIELD_RESERVOIR_VOLUME); 1334 + priv->speed_input[4] = get_unaligned_be16(data + LEAKSHIELD_RESERVOIR_FILLED); 1335 + 1336 + /* Second temp sensor is not positioned after the first one, read it here */ 1337 + priv->temp_input[1] = get_unaligned_be16(data + LEAKSHIELD_TEMPERATURE_2) * 10; 1375 1338 break; 1376 1339 default: 1377 1340 break; ··· 1652 1571 priv->power_label = label_highflownext_power; 1653 1572 priv->voltage_label = label_highflownext_voltage; 1654 1573 break; 1574 + case USB_PRODUCT_ID_LEAKSHIELD: 1575 + /* 1576 + * Choose the right Leakshield device, because 1577 + * the other one acts as a keyboard 1578 + */ 1579 + if (hdev->type != 2) { 1580 + ret = -ENODEV; 1581 + goto fail_and_close; 1582 + } 1583 + 1584 + priv->kind = leakshield; 1585 + 1586 + priv->num_fans = 0; 1587 + priv->num_temp_sensors = LEAKSHIELD_NUM_SENSORS; 1588 + priv->temp_sensor_start_offset = LEAKSHIELD_TEMPERATURE_1; 1589 + 1590 + priv->temp_label = label_leakshield_temp_sensors; 1591 + priv->speed_label = label_leakshield_fan_speed; 1592 + break; 1655 1593 case USB_PRODUCT_ID_AQUASTREAMXT: 1656 1594 priv->kind = aquastreamxt; 1657 1595 ··· 1807 1707 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_OCTO) }, 1808 1708 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_QUADRO) }, 1809 1709 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_HIGHFLOWNEXT) }, 1710 + { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_LEAKSHIELD) }, 1810 1711 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_AQUASTREAMXT) }, 1811 1712 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_AQUASTREAMULT) }, 1812 1713 { HID_USB_DEVICE(USB_VENDOR_ID_AQUACOMPUTER, USB_PRODUCT_ID_POWERADJUST3) },
+1 -1
drivers/hwmon/asb100.c
··· 223 223 .driver = { 224 224 .name = "asb100", 225 225 }, 226 - .probe_new = asb100_probe, 226 + .probe = asb100_probe, 227 227 .remove = asb100_remove, 228 228 .id_table = asb100_id, 229 229 .detect = asb100_detect,
+1 -1
drivers/hwmon/asc7621.c
··· 1191 1191 .driver = { 1192 1192 .name = "asc7621", 1193 1193 }, 1194 - .probe_new = asc7621_probe, 1194 + .probe = asc7621_probe, 1195 1195 .remove = asc7621_remove, 1196 1196 .id_table = asc7621_id, 1197 1197 .detect = asc7621_detect,
+30
drivers/hwmon/asus-ec-sensors.c
··· 101 101 ec_sensor_temp_chipset, 102 102 /* CPU temperature [℃] */ 103 103 ec_sensor_temp_cpu, 104 + /* CPU package temperature [℃] */ 105 + ec_sensor_temp_cpu_package, 104 106 /* motherboard temperature [℃] */ 105 107 ec_sensor_temp_mb, 106 108 /* "T_Sensor" temperature sensor reading [℃] */ ··· 141 139 142 140 #define SENSOR_TEMP_CHIPSET BIT(ec_sensor_temp_chipset) 143 141 #define SENSOR_TEMP_CPU BIT(ec_sensor_temp_cpu) 142 + #define SENSOR_TEMP_CPU_PACKAGE BIT(ec_sensor_temp_cpu_package) 144 143 #define SENSOR_TEMP_MB BIT(ec_sensor_temp_mb) 145 144 #define SENSOR_TEMP_T_SENSOR BIT(ec_sensor_temp_t_sensor) 146 145 #define SENSOR_TEMP_VRM BIT(ec_sensor_temp_vrm) ··· 164 161 family_unknown, 165 162 family_amd_400_series, 166 163 family_amd_500_series, 164 + family_amd_600_series, 167 165 family_intel_300_series, 168 166 family_intel_600_series 169 167 }; ··· 235 231 EC_SENSOR("Extra_2", hwmon_temp, 1, 0x01, 0x0b), 236 232 [ec_sensor_temp_sensor_extra_3] = 237 233 EC_SENSOR("Extra_3", hwmon_temp, 1, 0x01, 0x0c), 234 + }; 235 + 236 + static const struct ec_sensor_info sensors_family_amd_600[] = { 237 + [ec_sensor_temp_cpu] = EC_SENSOR("CPU", hwmon_temp, 1, 0x00, 0x30), 238 + [ec_sensor_temp_cpu_package] = EC_SENSOR("CPU Package", hwmon_temp, 1, 0x00, 0x31), 239 + [ec_sensor_temp_mb] = 240 + EC_SENSOR("Motherboard", hwmon_temp, 1, 0x00, 0x32), 241 + [ec_sensor_temp_vrm] = 242 + EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x33), 243 + [ec_sensor_temp_water_in] = 244 + EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00), 245 + [ec_sensor_temp_water_out] = 246 + EC_SENSOR("Water_Out", hwmon_temp, 1, 0x01, 0x01), 238 247 }; 239 248 240 249 static const struct ec_sensor_info sensors_family_intel_300[] = { ··· 334 317 SENSOR_CURR_CPU | SENSOR_IN_CPU_CORE, 335 318 .mutex_path = ASUS_HW_ACCESS_MUTEX_ASMX, 336 319 .family = family_amd_500_series, 320 + }; 321 + 322 + static const struct ec_board_info board_info_crosshair_x670e_hero = { 323 + .sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE | 324 + SENSOR_TEMP_MB | SENSOR_TEMP_VRM | 325 + SENSOR_SET_TEMP_WATER, 326 + .mutex_path = ASUS_HW_ACCESS_MUTEX_RMTW_ASMX, 327 + .family = family_amd_600_series, 337 328 }; 338 329 339 330 static const struct ec_board_info board_info_crosshair_viii_dark_hero = { ··· 488 463 &board_info_crosshair_viii_hero), 489 464 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR VIII HERO (WI-FI)", 490 465 &board_info_crosshair_viii_hero), 466 + DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR X670E HERO", 467 + &board_info_crosshair_x670e_hero), 491 468 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS XI HERO", 492 469 &board_info_maximus_xi_hero), 493 470 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS XI HERO (WI-FI)", ··· 972 945 break; 973 946 case family_amd_500_series: 974 947 ec_data->sensors_info = sensors_family_amd_500; 948 + break; 949 + case family_amd_600_series: 950 + ec_data->sensors_info = sensors_family_amd_600; 975 951 break; 976 952 case family_intel_300_series: 977 953 ec_data->sensors_info = sensors_family_intel_300;
+1 -1
drivers/hwmon/atxp1.c
··· 288 288 .driver = { 289 289 .name = "atxp1", 290 290 }, 291 - .probe_new = atxp1_probe, 291 + .probe = atxp1_probe, 292 292 .id_table = atxp1_id, 293 293 }; 294 294
+76 -14
drivers/hwmon/corsair-psu.c
··· 32 32 * but it is better to not rely on this (it is also hard to parse) 33 33 * - the driver uses raw events to be accessible from userspace (though this is not really 34 34 * supported, it is just there for convenience, may be removed in the future) 35 - * - a reply always start with the length and command in the same order the request used it 35 + * - a reply always starts with the length and command in the same order the request used it 36 36 * - length of the reply data is specific to the command used 37 37 * - some of the commands work on a rail and can be switched to a specific rail (0 = 12v, 38 38 * 1 = 5v, 2 = 3.3v) 39 39 * - the format of the init command 0xFE is swapped length/command bytes 40 40 * - parameter bytes amount and values are specific to the command (rail setting is the only 41 - * for now that uses non-zero values) 42 - * - there are much more commands, especially for configuring the device, but they are not 43 - * supported because a wrong command/length can lockup the micro-controller 41 + * one for now that uses non-zero values) 44 42 * - the driver supports debugfs for values not fitting into the hwmon class 45 - * - not every device class (HXi, RMi or AXi) supports all commands 46 - * - it is a pure sensors reading driver (will not support configuring) 43 + * - not every device class (HXi or RMi) supports all commands 44 + * - if configured wrong the PSU resets or shuts down, often before actually hitting the 45 + * reported critical temperature 46 + * - new models like HX1500i Series 2023 have changes in the reported vendor and product 47 + * strings, both are slightly longer now, report vendor and product in one string and are 48 + * the same now 47 49 */ 48 50 49 51 #define DRIVER_NAME "corsair-psu" 50 52 51 - #define REPLY_SIZE 16 /* max length of a reply to a single command */ 53 + #define REPLY_SIZE 24 /* max length of a reply to a single command */ 52 54 #define CMD_BUFFER_SIZE 64 53 55 #define CMD_TIMEOUT_MS 250 54 56 #define SECONDS_PER_HOUR (60 * 60) ··· 60 58 #define OCP_MULTI_RAIL 0x02 61 59 62 60 #define PSU_CMD_SELECT_RAIL 0x00 /* expects length 2 */ 63 - #define PSU_CMD_RAIL_VOLTS_HCRIT 0x40 /* the rest of the commands expect length 3 */ 61 + #define PSU_CMD_FAN_PWM 0x3B /* the rest of the commands expect length 3 */ 62 + #define PSU_CMD_RAIL_VOLTS_HCRIT 0x40 64 63 #define PSU_CMD_RAIL_VOLTS_LCRIT 0x44 65 64 #define PSU_CMD_RAIL_AMPS_HCRIT 0x46 66 65 #define PSU_CMD_TEMP_HCRIT 0x4F ··· 79 76 #define PSU_CMD_UPTIME 0xD2 80 77 #define PSU_CMD_OCPMODE 0xD8 81 78 #define PSU_CMD_TOTAL_WATTS 0xEE 79 + #define PSU_CMD_FAN_PWM_ENABLE 0xF0 82 80 #define PSU_CMD_INIT 0xFE 83 81 84 82 #define L_IN_VOLTS "v_in" ··· 147 143 const int result = mant * scale; 148 144 149 145 return (exp >= 0) ? (result << exp) : (result >> -exp); 146 + } 147 + 148 + /* the micro-controller uses percentage values to control pwm */ 149 + static int corsairpsu_dutycycle_to_pwm(const long dutycycle) 150 + { 151 + const int result = (256 << 16) / 100; 152 + 153 + return (result * dutycycle) >> 16; 150 154 } 151 155 152 156 static int corsairpsu_usb_cmd(struct corsairpsu_data *priv, u8 p0, u8 p1, u8 p2, void *data) ··· 256 244 /* 257 245 * the biggest value here comes from the uptime command and to exceed MAXINT total uptime 258 246 * needs to be about 68 years, the rest are u16 values and the biggest value coming out of 259 - * the LINEAR11 conversion are the watts values which are about 1200 for the strongest psu 260 - * supported (HX1200i) 247 + * the LINEAR11 conversion are the watts values which are about 1500 for the strongest psu 248 + * supported (HX1500i) 261 249 */ 262 250 tmp = ((long)data[3] << 24) + (data[2] << 16) + (data[1] << 8) + data[0]; 263 251 switch (cmd) { ··· 275 263 break; 276 264 case PSU_CMD_FAN: 277 265 *val = corsairpsu_linear11_to_int(tmp & 0xFFFF, 1); 266 + break; 267 + case PSU_CMD_FAN_PWM_ENABLE: 268 + *val = corsairpsu_linear11_to_int(tmp & 0xFFFF, 1); 269 + /* 270 + * 0 = automatic mode, means the micro-controller controls the fan using a plan 271 + * which can be modified, but changing this plan is not supported by this 272 + * driver, the matching PWM mode is automatic fan speed control = PWM 2 273 + * 1 = fixed mode, fan runs at a fixed speed represented by a percentage 274 + * value 0-100, this matches the PWM manual fan speed control = PWM 1 275 + * technically there is no PWM no fan speed control mode, it would be a combination 276 + * of 1 at 100% 277 + */ 278 + if (*val == 0) 279 + *val = 2; 280 + break; 281 + case PSU_CMD_FAN_PWM: 282 + *val = corsairpsu_linear11_to_int(tmp & 0xFFFF, 1); 283 + *val = corsairpsu_dutycycle_to_pwm(*val); 278 284 break; 279 285 case PSU_CMD_RAIL_WATTS: 280 286 case PSU_CMD_TOTAL_WATTS: ··· 379 349 } 380 350 } 381 351 352 + static umode_t corsairpsu_hwmon_pwm_is_visible(const struct corsairpsu_data *priv, u32 attr, 353 + int channel) 354 + { 355 + switch (attr) { 356 + case hwmon_pwm_input: 357 + case hwmon_pwm_enable: 358 + return 0444; 359 + default: 360 + return 0; 361 + } 362 + } 363 + 382 364 static umode_t corsairpsu_hwmon_power_is_visible(const struct corsairpsu_data *priv, u32 attr, 383 365 int channel) 384 366 { ··· 458 416 return corsairpsu_hwmon_temp_is_visible(priv, attr, channel); 459 417 case hwmon_fan: 460 418 return corsairpsu_hwmon_fan_is_visible(priv, attr, channel); 419 + case hwmon_pwm: 420 + return corsairpsu_hwmon_pwm_is_visible(priv, attr, channel); 461 421 case hwmon_power: 462 422 return corsairpsu_hwmon_power_is_visible(priv, attr, channel); 463 423 case hwmon_in: ··· 489 445 } 490 446 491 447 return err; 448 + } 449 + 450 + static int corsairpsu_hwmon_pwm_read(struct corsairpsu_data *priv, u32 attr, int channel, long *val) 451 + { 452 + switch (attr) { 453 + case hwmon_pwm_input: 454 + return corsairpsu_get_value(priv, PSU_CMD_FAN_PWM, 0, val); 455 + case hwmon_pwm_enable: 456 + return corsairpsu_get_value(priv, PSU_CMD_FAN_PWM_ENABLE, 0, val); 457 + default: 458 + break; 459 + } 460 + 461 + return -EOPNOTSUPP; 492 462 } 493 463 494 464 static int corsairpsu_hwmon_power_read(struct corsairpsu_data *priv, u32 attr, int channel, ··· 589 531 if (attr == hwmon_fan_input) 590 532 return corsairpsu_get_value(priv, PSU_CMD_FAN, 0, val); 591 533 return -EOPNOTSUPP; 534 + case hwmon_pwm: 535 + return corsairpsu_hwmon_pwm_read(priv, attr, channel, val); 592 536 case hwmon_power: 593 537 return corsairpsu_hwmon_power_read(priv, attr, channel, val); 594 538 case hwmon_in: ··· 631 571 .read_string = corsairpsu_hwmon_ops_read_string, 632 572 }; 633 573 634 - static const struct hwmon_channel_info * const corsairpsu_info[] = { 574 + static const struct hwmon_channel_info *const corsairpsu_info[] = { 635 575 HWMON_CHANNEL_INFO(chip, 636 576 HWMON_C_REGISTER_TZ), 637 577 HWMON_CHANNEL_INFO(temp, ··· 639 579 HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT), 640 580 HWMON_CHANNEL_INFO(fan, 641 581 HWMON_F_INPUT | HWMON_F_LABEL), 582 + HWMON_CHANNEL_INFO(pwm, 583 + HWMON_PWM_INPUT | HWMON_PWM_ENABLE), 642 584 HWMON_CHANNEL_INFO(power, 643 585 HWMON_P_INPUT | HWMON_P_LABEL, 644 586 HWMON_P_INPUT | HWMON_P_LABEL, ··· 875 813 { HID_USB_DEVICE(0x1b1c, 0x1c04) }, /* Corsair HX650i */ 876 814 { HID_USB_DEVICE(0x1b1c, 0x1c05) }, /* Corsair HX750i */ 877 815 { HID_USB_DEVICE(0x1b1c, 0x1c06) }, /* Corsair HX850i */ 878 - { HID_USB_DEVICE(0x1b1c, 0x1c07) }, /* Corsair HX1000i revision 1 */ 816 + { HID_USB_DEVICE(0x1b1c, 0x1c07) }, /* Corsair HX1000i Series 2022 */ 879 817 { HID_USB_DEVICE(0x1b1c, 0x1c08) }, /* Corsair HX1200i */ 880 818 { HID_USB_DEVICE(0x1b1c, 0x1c09) }, /* Corsair RM550i */ 881 819 { HID_USB_DEVICE(0x1b1c, 0x1c0a) }, /* Corsair RM650i */ 882 820 { HID_USB_DEVICE(0x1b1c, 0x1c0b) }, /* Corsair RM750i */ 883 821 { HID_USB_DEVICE(0x1b1c, 0x1c0c) }, /* Corsair RM850i */ 884 822 { HID_USB_DEVICE(0x1b1c, 0x1c0d) }, /* Corsair RM1000i */ 885 - { HID_USB_DEVICE(0x1b1c, 0x1c1e) }, /* Corsair HX1000i revision 2 */ 886 - { HID_USB_DEVICE(0x1b1c, 0x1c1f) }, /* Corsair HX1500i */ 823 + { HID_USB_DEVICE(0x1b1c, 0x1c1e) }, /* Corsair HX1000i Series 2023 */ 824 + { HID_USB_DEVICE(0x1b1c, 0x1c1f) }, /* Corsair HX1500i Series 2022 and 2023 */ 887 825 { }, 888 826 }; 889 827 MODULE_DEVICE_TABLE(hid, corsairpsu_idtable);
+1 -1
drivers/hwmon/dme1737.c
··· 2528 2528 .driver = { 2529 2529 .name = "dme1737", 2530 2530 }, 2531 - .probe_new = dme1737_i2c_probe, 2531 + .probe = dme1737_i2c_probe, 2532 2532 .remove = dme1737_i2c_remove, 2533 2533 .id_table = dme1737_id, 2534 2534 .detect = dme1737_i2c_detect,
+1 -1
drivers/hwmon/ds1621.c
··· 384 384 .driver = { 385 385 .name = "ds1621", 386 386 }, 387 - .probe_new = ds1621_probe, 387 + .probe = ds1621_probe, 388 388 .id_table = ds1621_id, 389 389 }; 390 390
+1 -1
drivers/hwmon/ds620.c
··· 245 245 .driver = { 246 246 .name = "ds620", 247 247 }, 248 - .probe_new = ds620_probe, 248 + .probe = ds620_probe, 249 249 .id_table = ds620_id, 250 250 }; 251 251
+1 -1
drivers/hwmon/emc1403.c
··· 454 454 .name = "emc1403", 455 455 }, 456 456 .detect = emc1403_detect, 457 - .probe_new = emc1403_probe, 457 + .probe = emc1403_probe, 458 458 .id_table = emc1403_idtable, 459 459 .address_list = emc1403_address_list, 460 460 };
+1 -1
drivers/hwmon/emc2103.c
··· 653 653 .driver = { 654 654 .name = "emc2103", 655 655 }, 656 - .probe_new = emc2103_probe, 656 + .probe = emc2103_probe, 657 657 .id_table = emc2103_ids, 658 658 .detect = emc2103_detect, 659 659 .address_list = normal_i2c,
+1 -1
drivers/hwmon/emc2305.c
··· 615 615 .driver = { 616 616 .name = "emc2305", 617 617 }, 618 - .probe_new = emc2305_probe, 618 + .probe = emc2305_probe, 619 619 .remove = emc2305_remove, 620 620 .id_table = emc2305_ids, 621 621 .address_list = emc2305_normal_i2c,
+1 -1
drivers/hwmon/emc6w201.c
··· 474 474 .driver = { 475 475 .name = "emc6w201", 476 476 }, 477 - .probe_new = emc6w201_probe, 477 + .probe = emc6w201_probe, 478 478 .id_table = emc6w201_id, 479 479 .detect = emc6w201_detect, 480 480 .address_list = normal_i2c,
+5 -2
drivers/hwmon/f71882fg.c
··· 1096 1096 val = data->pwm[nr]; 1097 1097 else { 1098 1098 /* RPM mode */ 1099 - val = 255 * fan_from_reg(data->fan_target[nr]) 1100 - / fan_from_reg(data->fan_full_speed[nr]); 1099 + if (fan_from_reg(data->fan_full_speed[nr])) 1100 + val = 255 * fan_from_reg(data->fan_target[nr]) 1101 + / fan_from_reg(data->fan_full_speed[nr]); 1102 + else 1103 + val = 0; 1101 1104 } 1102 1105 mutex_unlock(&data->update_lock); 1103 1106 return sprintf(buf, "%d\n", val);
+1 -1
drivers/hwmon/f75375s.c
··· 129 129 .driver = { 130 130 .name = "f75375", 131 131 }, 132 - .probe_new = f75375_probe, 132 + .probe = f75375_probe, 133 133 .remove = f75375_remove, 134 134 .id_table = f75375_id, 135 135 .detect = f75375_detect,
+1 -1
drivers/hwmon/fschmd.c
··· 241 241 .driver = { 242 242 .name = "fschmd", 243 243 }, 244 - .probe_new = fschmd_probe, 244 + .probe = fschmd_probe, 245 245 .remove = fschmd_remove, 246 246 .id_table = fschmd_id, 247 247 .detect = fschmd_detect,
+1 -1
drivers/hwmon/ftsteutates.c
··· 678 678 .name = "ftsteutates", 679 679 }, 680 680 .id_table = fts_id, 681 - .probe_new = fts_probe, 681 + .probe = fts_probe, 682 682 .detect = fts_detect, 683 683 .address_list = normal_i2c, 684 684 };
+1 -1
drivers/hwmon/g760a.c
··· 206 206 .driver = { 207 207 .name = "g760a", 208 208 }, 209 - .probe_new = g760a_probe, 209 + .probe = g760a_probe, 210 210 .id_table = g760a_id, 211 211 }; 212 212
+1 -1
drivers/hwmon/g762.c
··· 1084 1084 .name = DRVNAME, 1085 1085 .of_match_table = of_match_ptr(g762_dt_match), 1086 1086 }, 1087 - .probe_new = g762_probe, 1087 + .probe = g762_probe, 1088 1088 .id_table = g762_id, 1089 1089 }; 1090 1090
+1 -1
drivers/hwmon/gl518sm.c
··· 652 652 .driver = { 653 653 .name = "gl518sm", 654 654 }, 655 - .probe_new = gl518_probe, 655 + .probe = gl518_probe, 656 656 .id_table = gl518_id, 657 657 .detect = gl518_detect, 658 658 .address_list = normal_i2c,
+1 -1
drivers/hwmon/gl520sm.c
··· 895 895 .driver = { 896 896 .name = "gl520sm", 897 897 }, 898 - .probe_new = gl520_probe, 898 + .probe = gl520_probe, 899 899 .id_table = gl520_id, 900 900 .detect = gl520_detect, 901 901 .address_list = normal_i2c,
+3 -3
drivers/hwmon/gsc-hwmon.c
··· 82 82 if (kstrtol(buf, 10, &temp)) 83 83 return -EINVAL; 84 84 85 - temp = clamp_val(temp, 0, 10000); 86 - temp = DIV_ROUND_CLOSEST(temp, 10); 85 + temp = clamp_val(temp, 0, 100000); 86 + temp = DIV_ROUND_CLOSEST(temp, 100); 87 87 88 88 regs[0] = temp & 0xff; 89 89 regs[1] = (temp >> 8) & 0xff; ··· 100 100 { 101 101 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 102 102 103 - return sprintf(buf, "%d\n", 255 * (50 + (attr->index * 10)) / 100); 103 + return sprintf(buf, "%d\n", 255 * (50 + (attr->index * 10))); 104 104 } 105 105 106 106 static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point1_pwm, pwm_auto_point_pwm, 0);
+1 -1
drivers/hwmon/hih6130.c
··· 249 249 .name = "hih6130", 250 250 .of_match_table = of_match_ptr(hih6130_of_match), 251 251 }, 252 - .probe_new = hih6130_probe, 252 + .probe = hih6130_probe, 253 253 .id_table = hih6130_id, 254 254 }; 255 255
+2004
drivers/hwmon/hp-wmi-sensors.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * hwmon driver for HP (and some HP Compaq) business-class computers that 4 + * report numeric sensor data via Windows Management Instrumentation (WMI). 5 + * 6 + * Copyright (C) 2023 James Seo <james@equiv.tech> 7 + * 8 + * References: 9 + * [1] Hewlett-Packard Development Company, L.P., 10 + * "HP Client Management Interface Technical White Paper", 2005. [Online]. 11 + * Available: https://h20331.www2.hp.com/hpsub/downloads/cmi_whitepaper.pdf 12 + * [2] Hewlett-Packard Development Company, L.P., 13 + * "HP Retail Manageability", 2012. [Online]. 14 + * Available: http://h10032.www1.hp.com/ctg/Manual/c03291135.pdf 15 + * [3] Linux Hardware Project, A. Ponomarenko et al., 16 + * "linuxhw/ACPI - Collect ACPI table dumps", 2018. [Online]. 17 + * Available: https://github.com/linuxhw/ACPI 18 + * [4] P. Rohár, "bmfdec - Decompile binary MOF file (BMF) from WMI buffer", 19 + * 2017. [Online]. Available: https://github.com/pali/bmfdec 20 + */ 21 + 22 + #include <linux/acpi.h> 23 + #include <linux/debugfs.h> 24 + #include <linux/hwmon.h> 25 + #include <linux/jiffies.h> 26 + #include <linux/mutex.h> 27 + #include <linux/units.h> 28 + #include <linux/wmi.h> 29 + 30 + #define HP_WMI_EVENT_NAMESPACE "root\\WMI" 31 + #define HP_WMI_EVENT_CLASS "HPBIOS_BIOSEvent" 32 + #define HP_WMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" 33 + #define HP_WMI_NUMERIC_SENSOR_GUID "8F1F6435-9F42-42C8-BADC-0E9424F20C9A" 34 + #define HP_WMI_PLATFORM_EVENTS_GUID "41227C2D-80E1-423F-8B8E-87E32755A0EB" 35 + 36 + /* Patterns for recognizing sensors and matching events to channels. */ 37 + 38 + #define HP_WMI_PATTERN_SYS_TEMP "Chassis Thermal Index" 39 + #define HP_WMI_PATTERN_SYS_TEMP2 "System Ambient Temperature" 40 + #define HP_WMI_PATTERN_CPU_TEMP "CPU Thermal Index" 41 + #define HP_WMI_PATTERN_CPU_TEMP2 "CPU Temperature" 42 + #define HP_WMI_PATTERN_TEMP_SENSOR "Thermal Index" 43 + #define HP_WMI_PATTERN_TEMP_ALARM "Thermal Critical" 44 + #define HP_WMI_PATTERN_INTRUSION_ALARM "Hood Intrusion" 45 + #define HP_WMI_PATTERN_FAN_ALARM "Stall" 46 + #define HP_WMI_PATTERN_TEMP "Temperature" 47 + #define HP_WMI_PATTERN_CPU "CPU" 48 + 49 + /* These limits are arbitrary. The WMI implementation may vary by system. */ 50 + 51 + #define HP_WMI_MAX_STR_SIZE 128U 52 + #define HP_WMI_MAX_PROPERTIES 32U 53 + #define HP_WMI_MAX_INSTANCES 32U 54 + 55 + enum hp_wmi_type { 56 + HP_WMI_TYPE_OTHER = 1, 57 + HP_WMI_TYPE_TEMPERATURE = 2, 58 + HP_WMI_TYPE_VOLTAGE = 3, 59 + HP_WMI_TYPE_CURRENT = 4, 60 + HP_WMI_TYPE_AIR_FLOW = 12, 61 + HP_WMI_TYPE_INTRUSION = 0xabadb01, /* Custom. */ 62 + }; 63 + 64 + enum hp_wmi_category { 65 + HP_WMI_CATEGORY_SENSOR = 3, 66 + }; 67 + 68 + enum hp_wmi_severity { 69 + HP_WMI_SEVERITY_UNKNOWN = 0, 70 + HP_WMI_SEVERITY_OK = 5, 71 + HP_WMI_SEVERITY_DEGRADED_WARNING = 10, 72 + HP_WMI_SEVERITY_MINOR_FAILURE = 15, 73 + HP_WMI_SEVERITY_MAJOR_FAILURE = 20, 74 + HP_WMI_SEVERITY_CRITICAL_FAILURE = 25, 75 + HP_WMI_SEVERITY_NON_RECOVERABLE_ERROR = 30, 76 + }; 77 + 78 + enum hp_wmi_status { 79 + HP_WMI_STATUS_OK = 2, 80 + HP_WMI_STATUS_DEGRADED = 3, 81 + HP_WMI_STATUS_STRESSED = 4, 82 + HP_WMI_STATUS_PREDICTIVE_FAILURE = 5, 83 + HP_WMI_STATUS_ERROR = 6, 84 + HP_WMI_STATUS_NON_RECOVERABLE_ERROR = 7, 85 + HP_WMI_STATUS_NO_CONTACT = 12, 86 + HP_WMI_STATUS_LOST_COMMUNICATION = 13, 87 + HP_WMI_STATUS_ABORTED = 14, 88 + HP_WMI_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16, 89 + 90 + /* Occurs combined with one of "OK", "Degraded", and "Error" [1]. */ 91 + HP_WMI_STATUS_COMPLETED = 17, 92 + }; 93 + 94 + enum hp_wmi_units { 95 + HP_WMI_UNITS_OTHER = 1, 96 + HP_WMI_UNITS_DEGREES_C = 2, 97 + HP_WMI_UNITS_DEGREES_F = 3, 98 + HP_WMI_UNITS_DEGREES_K = 4, 99 + HP_WMI_UNITS_VOLTS = 5, 100 + HP_WMI_UNITS_AMPS = 6, 101 + HP_WMI_UNITS_RPM = 19, 102 + }; 103 + 104 + enum hp_wmi_property { 105 + HP_WMI_PROPERTY_NAME = 0, 106 + HP_WMI_PROPERTY_DESCRIPTION = 1, 107 + HP_WMI_PROPERTY_SENSOR_TYPE = 2, 108 + HP_WMI_PROPERTY_OTHER_SENSOR_TYPE = 3, 109 + HP_WMI_PROPERTY_OPERATIONAL_STATUS = 4, 110 + HP_WMI_PROPERTY_SIZE = 5, 111 + HP_WMI_PROPERTY_POSSIBLE_STATES = 6, 112 + HP_WMI_PROPERTY_CURRENT_STATE = 7, 113 + HP_WMI_PROPERTY_BASE_UNITS = 8, 114 + HP_WMI_PROPERTY_UNIT_MODIFIER = 9, 115 + HP_WMI_PROPERTY_CURRENT_READING = 10, 116 + HP_WMI_PROPERTY_RATE_UNITS = 11, 117 + }; 118 + 119 + static const acpi_object_type hp_wmi_property_map[] = { 120 + [HP_WMI_PROPERTY_NAME] = ACPI_TYPE_STRING, 121 + [HP_WMI_PROPERTY_DESCRIPTION] = ACPI_TYPE_STRING, 122 + [HP_WMI_PROPERTY_SENSOR_TYPE] = ACPI_TYPE_INTEGER, 123 + [HP_WMI_PROPERTY_OTHER_SENSOR_TYPE] = ACPI_TYPE_STRING, 124 + [HP_WMI_PROPERTY_OPERATIONAL_STATUS] = ACPI_TYPE_INTEGER, 125 + [HP_WMI_PROPERTY_SIZE] = ACPI_TYPE_INTEGER, 126 + [HP_WMI_PROPERTY_POSSIBLE_STATES] = ACPI_TYPE_STRING, 127 + [HP_WMI_PROPERTY_CURRENT_STATE] = ACPI_TYPE_STRING, 128 + [HP_WMI_PROPERTY_BASE_UNITS] = ACPI_TYPE_INTEGER, 129 + [HP_WMI_PROPERTY_UNIT_MODIFIER] = ACPI_TYPE_INTEGER, 130 + [HP_WMI_PROPERTY_CURRENT_READING] = ACPI_TYPE_INTEGER, 131 + [HP_WMI_PROPERTY_RATE_UNITS] = ACPI_TYPE_INTEGER, 132 + }; 133 + 134 + enum hp_wmi_platform_events_property { 135 + HP_WMI_PLATFORM_EVENTS_PROPERTY_NAME = 0, 136 + HP_WMI_PLATFORM_EVENTS_PROPERTY_DESCRIPTION = 1, 137 + HP_WMI_PLATFORM_EVENTS_PROPERTY_SOURCE_NAMESPACE = 2, 138 + HP_WMI_PLATFORM_EVENTS_PROPERTY_SOURCE_CLASS = 3, 139 + HP_WMI_PLATFORM_EVENTS_PROPERTY_CATEGORY = 4, 140 + HP_WMI_PLATFORM_EVENTS_PROPERTY_POSSIBLE_SEVERITY = 5, 141 + HP_WMI_PLATFORM_EVENTS_PROPERTY_POSSIBLE_STATUS = 6, 142 + }; 143 + 144 + static const acpi_object_type hp_wmi_platform_events_property_map[] = { 145 + [HP_WMI_PLATFORM_EVENTS_PROPERTY_NAME] = ACPI_TYPE_STRING, 146 + [HP_WMI_PLATFORM_EVENTS_PROPERTY_DESCRIPTION] = ACPI_TYPE_STRING, 147 + [HP_WMI_PLATFORM_EVENTS_PROPERTY_SOURCE_NAMESPACE] = ACPI_TYPE_STRING, 148 + [HP_WMI_PLATFORM_EVENTS_PROPERTY_SOURCE_CLASS] = ACPI_TYPE_STRING, 149 + [HP_WMI_PLATFORM_EVENTS_PROPERTY_CATEGORY] = ACPI_TYPE_INTEGER, 150 + [HP_WMI_PLATFORM_EVENTS_PROPERTY_POSSIBLE_SEVERITY] = ACPI_TYPE_INTEGER, 151 + [HP_WMI_PLATFORM_EVENTS_PROPERTY_POSSIBLE_STATUS] = ACPI_TYPE_INTEGER, 152 + }; 153 + 154 + enum hp_wmi_event_property { 155 + HP_WMI_EVENT_PROPERTY_NAME = 0, 156 + HP_WMI_EVENT_PROPERTY_DESCRIPTION = 1, 157 + HP_WMI_EVENT_PROPERTY_CATEGORY = 2, 158 + HP_WMI_EVENT_PROPERTY_SEVERITY = 3, 159 + HP_WMI_EVENT_PROPERTY_STATUS = 4, 160 + }; 161 + 162 + static const acpi_object_type hp_wmi_event_property_map[] = { 163 + [HP_WMI_EVENT_PROPERTY_NAME] = ACPI_TYPE_STRING, 164 + [HP_WMI_EVENT_PROPERTY_DESCRIPTION] = ACPI_TYPE_STRING, 165 + [HP_WMI_EVENT_PROPERTY_CATEGORY] = ACPI_TYPE_INTEGER, 166 + [HP_WMI_EVENT_PROPERTY_SEVERITY] = ACPI_TYPE_INTEGER, 167 + [HP_WMI_EVENT_PROPERTY_STATUS] = ACPI_TYPE_INTEGER, 168 + }; 169 + 170 + static const enum hwmon_sensor_types hp_wmi_hwmon_type_map[] = { 171 + [HP_WMI_TYPE_TEMPERATURE] = hwmon_temp, 172 + [HP_WMI_TYPE_VOLTAGE] = hwmon_in, 173 + [HP_WMI_TYPE_CURRENT] = hwmon_curr, 174 + [HP_WMI_TYPE_AIR_FLOW] = hwmon_fan, 175 + }; 176 + 177 + static const u32 hp_wmi_hwmon_attributes[hwmon_max] = { 178 + [hwmon_chip] = HWMON_C_REGISTER_TZ, 179 + [hwmon_temp] = HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_FAULT, 180 + [hwmon_in] = HWMON_I_INPUT | HWMON_I_LABEL, 181 + [hwmon_curr] = HWMON_C_INPUT | HWMON_C_LABEL, 182 + [hwmon_fan] = HWMON_F_INPUT | HWMON_F_LABEL | HWMON_F_FAULT, 183 + [hwmon_intrusion] = HWMON_INTRUSION_ALARM, 184 + }; 185 + 186 + /* 187 + * struct hp_wmi_numeric_sensor - a HPBIOS_BIOSNumericSensor instance 188 + * 189 + * Two variants of HPBIOS_BIOSNumericSensor are known. The first is specified 190 + * in [1] and appears to be much more widespread. The second was discovered by 191 + * decoding BMOF blobs [4], seems to be found only in some newer ZBook systems 192 + * [3], and has two new properties and a slightly different property order. 193 + * 194 + * These differences don't matter on Windows, where WMI object properties are 195 + * accessed by name. For us, supporting both variants gets ugly and hacky at 196 + * times. The fun begins now; this struct is defined as per the new variant. 197 + * 198 + * Effective MOF definition: 199 + * 200 + * #pragma namespace("\\\\.\\root\\HP\\InstrumentedBIOS"); 201 + * class HPBIOS_BIOSNumericSensor { 202 + * [read] string Name; 203 + * [read] string Description; 204 + * [read, ValueMap {"0","1","2","3","4","5","6","7","8","9", 205 + * "10","11","12"}, Values {"Unknown","Other","Temperature", 206 + * "Voltage","Current","Tachometer","Counter","Switch","Lock", 207 + * "Humidity","Smoke Detection","Presence","Air Flow"}] 208 + * uint32 SensorType; 209 + * [read] string OtherSensorType; 210 + * [read, ValueMap {"0","1","2","3","4","5","6","7","8","9", 211 + * "10","11","12","13","14","15","16","17","18","..", 212 + * "0x8000.."}, Values {"Unknown","Other","OK","Degraded", 213 + * "Stressed","Predictive Failure","Error", 214 + * "Non-Recoverable Error","Starting","Stopping","Stopped", 215 + * "In Service","No Contact","Lost Communication","Aborted", 216 + * "Dormant","Supporting Entity in Error","Completed", 217 + * "Power Mode","DMTF Reserved","Vendor Reserved"}] 218 + * uint32 OperationalStatus; 219 + * [read] uint32 Size; 220 + * [read] string PossibleStates[]; 221 + * [read] string CurrentState; 222 + * [read, ValueMap {"0","1","2","3","4","5","6","7","8","9", 223 + * "10","11","12","13","14","15","16","17","18","19","20", 224 + * "21","22","23","24","25","26","27","28","29","30","31", 225 + * "32","33","34","35","36","37","38","39","40","41","42", 226 + * "43","44","45","46","47","48","49","50","51","52","53", 227 + * "54","55","56","57","58","59","60","61","62","63","64", 228 + * "65"}, Values {"Unknown","Other","Degrees C","Degrees F", 229 + * "Degrees K","Volts","Amps","Watts","Joules","Coulombs", 230 + * "VA","Nits","Lumens","Lux","Candelas","kPa","PSI", 231 + * "Newtons","CFM","RPM","Hertz","Seconds","Minutes", 232 + * "Hours","Days","Weeks","Mils","Inches","Feet", 233 + * "Cubic Inches","Cubic Feet","Meters","Cubic Centimeters", 234 + * "Cubic Meters","Liters","Fluid Ounces","Radians", 235 + * "Steradians","Revolutions","Cycles","Gravities","Ounces", 236 + * "Pounds","Foot-Pounds","Ounce-Inches","Gauss","Gilberts", 237 + * "Henries","Farads","Ohms","Siemens","Moles","Becquerels", 238 + * "PPM (parts/million)","Decibels","DbA","DbC","Grays", 239 + * "Sieverts","Color Temperature Degrees K","Bits","Bytes", 240 + * "Words (data)","DoubleWords","QuadWords","Percentage"}] 241 + * uint32 BaseUnits; 242 + * [read] sint32 UnitModifier; 243 + * [read] uint32 CurrentReading; 244 + * [read] uint32 RateUnits; 245 + * }; 246 + * 247 + * Effective MOF definition of old variant [1] (sans redundant info): 248 + * 249 + * class HPBIOS_BIOSNumericSensor { 250 + * [read] string Name; 251 + * [read] string Description; 252 + * [read] uint32 SensorType; 253 + * [read] string OtherSensorType; 254 + * [read] uint32 OperationalStatus; 255 + * [read] string CurrentState; 256 + * [read] string PossibleStates[]; 257 + * [read] uint32 BaseUnits; 258 + * [read] sint32 UnitModifier; 259 + * [read] uint32 CurrentReading; 260 + * }; 261 + */ 262 + struct hp_wmi_numeric_sensor { 263 + const char *name; 264 + const char *description; 265 + u32 sensor_type; 266 + const char *other_sensor_type; /* Explains "Other" SensorType. */ 267 + u32 operational_status; 268 + u8 size; /* Count of PossibleStates[]. */ 269 + const char **possible_states; 270 + const char *current_state; 271 + u32 base_units; 272 + s32 unit_modifier; 273 + u32 current_reading; 274 + u32 rate_units; 275 + }; 276 + 277 + /* 278 + * struct hp_wmi_platform_events - a HPBIOS_PlatformEvents instance 279 + * 280 + * Instances of this object reveal the set of possible HPBIOS_BIOSEvent 281 + * instances for the current system, but it may not always be present. 282 + * 283 + * Effective MOF definition: 284 + * 285 + * #pragma namespace("\\\\.\\root\\HP\\InstrumentedBIOS"); 286 + * class HPBIOS_PlatformEvents { 287 + * [read] string Name; 288 + * [read] string Description; 289 + * [read] string SourceNamespace; 290 + * [read] string SourceClass; 291 + * [read, ValueMap {"0","1","2","3","4",".."}, Values { 292 + * "Unknown","Configuration Change","Button Pressed", 293 + * "Sensor","BIOS Settings","Reserved"}] 294 + * uint32 Category; 295 + * [read, ValueMap{"0","5","10","15","20","25","30",".."}, 296 + * Values{"Unknown","OK","Degraded/Warning","Minor Failure", 297 + * "Major Failure","Critical Failure","Non-recoverable Error", 298 + * "DMTF Reserved"}] 299 + * uint32 PossibleSeverity; 300 + * [read, ValueMap {"0","1","2","3","4","5","6","7","8","9", 301 + * "10","11","12","13","14","15","16","17","18","..", 302 + * "0x8000.."}, Values {"Unknown","Other","OK","Degraded", 303 + * "Stressed","Predictive Failure","Error", 304 + * "Non-Recoverable Error","Starting","Stopping","Stopped", 305 + * "In Service","No Contact","Lost Communication","Aborted", 306 + * "Dormant","Supporting Entity in Error","Completed", 307 + * "Power Mode","DMTF Reserved","Vendor Reserved"}] 308 + * uint32 PossibleStatus; 309 + * }; 310 + */ 311 + struct hp_wmi_platform_events { 312 + const char *name; 313 + const char *description; 314 + const char *source_namespace; 315 + const char *source_class; 316 + u32 category; 317 + u32 possible_severity; 318 + u32 possible_status; 319 + }; 320 + 321 + /* 322 + * struct hp_wmi_event - a HPBIOS_BIOSEvent instance 323 + * 324 + * Effective MOF definition [1] (corrected below from original): 325 + * 326 + * #pragma namespace("\\\\.\\root\\WMI"); 327 + * class HPBIOS_BIOSEvent : WMIEvent { 328 + * [read] string Name; 329 + * [read] string Description; 330 + * [read ValueMap {"0","1","2","3","4"}, Values {"Unknown", 331 + * "Configuration Change","Button Pressed","Sensor", 332 + * "BIOS Settings"}] 333 + * uint32 Category; 334 + * [read, ValueMap {"0","5","10","15","20","25","30"}, 335 + * Values {"Unknown","OK","Degraded/Warning", 336 + * "Minor Failure","Major Failure","Critical Failure", 337 + * "Non-recoverable Error"}] 338 + * uint32 Severity; 339 + * [read, ValueMap {"0","1","2","3","4","5","6","7","8", 340 + * "9","10","11","12","13","14","15","16","17","18","..", 341 + * "0x8000.."}, Values {"Unknown","Other","OK","Degraded", 342 + * "Stressed","Predictive Failure","Error", 343 + * "Non-Recoverable Error","Starting","Stopping","Stopped", 344 + * "In Service","No Contact","Lost Communication","Aborted", 345 + * "Dormant","Supporting Entity in Error","Completed", 346 + * "Power Mode","DMTF Reserved","Vendor Reserved"}] 347 + * uint32 Status; 348 + * }; 349 + */ 350 + struct hp_wmi_event { 351 + const char *name; 352 + const char *description; 353 + u32 category; 354 + }; 355 + 356 + /* 357 + * struct hp_wmi_info - sensor info 358 + * @nsensor: numeric sensor properties 359 + * @instance: its WMI instance number 360 + * @state: pointer to driver state 361 + * @has_alarm: whether sensor has an alarm flag 362 + * @alarm: alarm flag 363 + * @type: its hwmon sensor type 364 + * @cached_val: current sensor reading value, scaled for hwmon 365 + * @last_updated: when these readings were last updated 366 + */ 367 + struct hp_wmi_info { 368 + struct hp_wmi_numeric_sensor nsensor; 369 + u8 instance; 370 + void *state; /* void *: Avoid forward declaration. */ 371 + bool has_alarm; 372 + bool alarm; 373 + enum hwmon_sensor_types type; 374 + long cached_val; 375 + unsigned long last_updated; /* In jiffies. */ 376 + 377 + }; 378 + 379 + /* 380 + * struct hp_wmi_sensors - driver state 381 + * @wdev: pointer to the parent WMI device 382 + * @info_map: sensor info structs by hwmon type and channel number 383 + * @channel_count: count of hwmon channels by hwmon type 384 + * @has_intrusion: whether an intrusion sensor is present 385 + * @intrusion: intrusion flag 386 + * @lock: mutex to lock polling WMI and changes to driver state 387 + */ 388 + struct hp_wmi_sensors { 389 + struct wmi_device *wdev; 390 + struct hp_wmi_info **info_map[hwmon_max]; 391 + u8 channel_count[hwmon_max]; 392 + bool has_intrusion; 393 + bool intrusion; 394 + 395 + struct mutex lock; /* Lock polling WMI and driver state changes. */ 396 + }; 397 + 398 + /* hp_wmi_strdup - devm_kstrdup, but length-limited */ 399 + static char *hp_wmi_strdup(struct device *dev, const char *src) 400 + { 401 + char *dst; 402 + size_t len; 403 + 404 + len = strnlen(src, HP_WMI_MAX_STR_SIZE - 1); 405 + 406 + dst = devm_kmalloc(dev, (len + 1) * sizeof(*dst), GFP_KERNEL); 407 + if (!dst) 408 + return NULL; 409 + 410 + strscpy(dst, src, len + 1); 411 + 412 + return dst; 413 + } 414 + 415 + /* 416 + * hp_wmi_get_wobj - poll WMI for a WMI object instance 417 + * @guid: WMI object GUID 418 + * @instance: WMI object instance number 419 + * 420 + * Returns a new WMI object instance on success, or NULL on error. 421 + * Caller must kfree() the result. 422 + */ 423 + static union acpi_object *hp_wmi_get_wobj(const char *guid, u8 instance) 424 + { 425 + struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; 426 + acpi_status err; 427 + 428 + err = wmi_query_block(guid, instance, &out); 429 + if (ACPI_FAILURE(err)) 430 + return NULL; 431 + 432 + return out.pointer; 433 + } 434 + 435 + /* hp_wmi_wobj_instance_count - find count of WMI object instances */ 436 + static u8 hp_wmi_wobj_instance_count(const char *guid) 437 + { 438 + u8 hi = HP_WMI_MAX_INSTANCES; 439 + union acpi_object *wobj; 440 + u8 lo = 0; 441 + u8 mid; 442 + 443 + while (lo < hi) { 444 + mid = (lo + hi) / 2; 445 + 446 + wobj = hp_wmi_get_wobj(guid, mid); 447 + if (!wobj) { 448 + hi = mid; 449 + continue; 450 + } 451 + 452 + lo = mid + 1; 453 + kfree(wobj); 454 + } 455 + 456 + return lo; 457 + } 458 + 459 + static int check_wobj(const union acpi_object *wobj, 460 + const acpi_object_type property_map[], int last_prop) 461 + { 462 + acpi_object_type type = wobj->type; 463 + acpi_object_type valid_type; 464 + union acpi_object *elements; 465 + u32 elem_count; 466 + int prop; 467 + 468 + if (type != ACPI_TYPE_PACKAGE) 469 + return -EINVAL; 470 + 471 + elem_count = wobj->package.count; 472 + if (elem_count != last_prop + 1) 473 + return -EINVAL; 474 + 475 + elements = wobj->package.elements; 476 + for (prop = 0; prop <= last_prop; prop++) { 477 + type = elements[prop].type; 478 + valid_type = property_map[prop]; 479 + if (type != valid_type) 480 + return -EINVAL; 481 + } 482 + 483 + return 0; 484 + } 485 + 486 + static int extract_acpi_value(struct device *dev, 487 + union acpi_object *element, 488 + acpi_object_type type, 489 + u32 *out_value, char **out_string) 490 + { 491 + switch (type) { 492 + case ACPI_TYPE_INTEGER: 493 + *out_value = element->integer.value; 494 + break; 495 + 496 + case ACPI_TYPE_STRING: 497 + *out_string = hp_wmi_strdup(dev, strim(element->string.pointer)); 498 + if (!*out_string) 499 + return -ENOMEM; 500 + break; 501 + 502 + default: 503 + return -EINVAL; 504 + } 505 + 506 + return 0; 507 + } 508 + 509 + /* 510 + * check_numeric_sensor_wobj - validate a HPBIOS_BIOSNumericSensor instance 511 + * @wobj: pointer to WMI object instance to check 512 + * @out_size: out pointer to count of possible states 513 + * @out_is_new: out pointer to whether this is a "new" variant object 514 + * 515 + * Returns 0 on success, or a negative error code on error. 516 + */ 517 + static int check_numeric_sensor_wobj(const union acpi_object *wobj, 518 + u8 *out_size, bool *out_is_new) 519 + { 520 + acpi_object_type type = wobj->type; 521 + int prop = HP_WMI_PROPERTY_NAME; 522 + acpi_object_type valid_type; 523 + union acpi_object *elements; 524 + u32 elem_count; 525 + int last_prop; 526 + bool is_new; 527 + u8 count; 528 + u32 j; 529 + u32 i; 530 + 531 + if (type != ACPI_TYPE_PACKAGE) 532 + return -EINVAL; 533 + 534 + /* 535 + * elements is a variable-length array of ACPI objects, one for 536 + * each property of the WMI object instance, except that the 537 + * strings in PossibleStates[] are flattened into this array 538 + * as if each individual string were a property by itself. 539 + */ 540 + elements = wobj->package.elements; 541 + 542 + elem_count = wobj->package.count; 543 + if (elem_count <= HP_WMI_PROPERTY_SIZE || 544 + elem_count > HP_WMI_MAX_PROPERTIES) 545 + return -EINVAL; 546 + 547 + type = elements[HP_WMI_PROPERTY_SIZE].type; 548 + switch (type) { 549 + case ACPI_TYPE_INTEGER: 550 + is_new = true; 551 + last_prop = HP_WMI_PROPERTY_RATE_UNITS; 552 + break; 553 + 554 + case ACPI_TYPE_STRING: 555 + is_new = false; 556 + last_prop = HP_WMI_PROPERTY_CURRENT_READING; 557 + break; 558 + 559 + default: 560 + return -EINVAL; 561 + } 562 + 563 + /* 564 + * In general, the count of PossibleStates[] must be > 0. 565 + * Also, the old variant lacks the Size property, so we may need to 566 + * reduce the value of last_prop by 1 when doing arithmetic with it. 567 + */ 568 + if (elem_count < last_prop - !is_new + 1) 569 + return -EINVAL; 570 + 571 + count = elem_count - (last_prop - !is_new); 572 + 573 + for (i = 0; i < elem_count && prop <= last_prop; i++, prop++) { 574 + type = elements[i].type; 575 + valid_type = hp_wmi_property_map[prop]; 576 + if (type != valid_type) 577 + return -EINVAL; 578 + 579 + switch (prop) { 580 + case HP_WMI_PROPERTY_OPERATIONAL_STATUS: 581 + /* Old variant: CurrentState follows OperationalStatus. */ 582 + if (!is_new) 583 + prop = HP_WMI_PROPERTY_CURRENT_STATE - 1; 584 + break; 585 + 586 + case HP_WMI_PROPERTY_SIZE: 587 + /* New variant: Size == count of PossibleStates[]. */ 588 + if (count != elements[i].integer.value) 589 + return -EINVAL; 590 + break; 591 + 592 + case HP_WMI_PROPERTY_POSSIBLE_STATES: 593 + /* PossibleStates[0] has already been type-checked. */ 594 + for (j = 0; i + 1 < elem_count && j + 1 < count; j++) { 595 + type = elements[++i].type; 596 + if (type != valid_type) 597 + return -EINVAL; 598 + } 599 + 600 + /* Old variant: BaseUnits follows PossibleStates[]. */ 601 + if (!is_new) 602 + prop = HP_WMI_PROPERTY_BASE_UNITS - 1; 603 + break; 604 + 605 + case HP_WMI_PROPERTY_CURRENT_STATE: 606 + /* Old variant: PossibleStates[] follows CurrentState. */ 607 + if (!is_new) 608 + prop = HP_WMI_PROPERTY_POSSIBLE_STATES - 1; 609 + break; 610 + } 611 + } 612 + 613 + if (prop != last_prop + 1) 614 + return -EINVAL; 615 + 616 + *out_size = count; 617 + *out_is_new = is_new; 618 + 619 + return 0; 620 + } 621 + 622 + static int 623 + numeric_sensor_is_connected(const struct hp_wmi_numeric_sensor *nsensor) 624 + { 625 + u32 operational_status = nsensor->operational_status; 626 + 627 + return operational_status != HP_WMI_STATUS_NO_CONTACT; 628 + } 629 + 630 + static int numeric_sensor_has_fault(const struct hp_wmi_numeric_sensor *nsensor) 631 + { 632 + u32 operational_status = nsensor->operational_status; 633 + 634 + switch (operational_status) { 635 + case HP_WMI_STATUS_DEGRADED: 636 + case HP_WMI_STATUS_STRESSED: /* e.g. Overload, overtemp. */ 637 + case HP_WMI_STATUS_PREDICTIVE_FAILURE: /* e.g. Fan removed. */ 638 + case HP_WMI_STATUS_ERROR: 639 + case HP_WMI_STATUS_NON_RECOVERABLE_ERROR: 640 + case HP_WMI_STATUS_NO_CONTACT: 641 + case HP_WMI_STATUS_LOST_COMMUNICATION: 642 + case HP_WMI_STATUS_ABORTED: 643 + case HP_WMI_STATUS_SUPPORTING_ENTITY_IN_ERROR: 644 + 645 + /* Assume combination by addition; bitwise OR doesn't make sense. */ 646 + case HP_WMI_STATUS_COMPLETED + HP_WMI_STATUS_DEGRADED: 647 + case HP_WMI_STATUS_COMPLETED + HP_WMI_STATUS_ERROR: 648 + return true; 649 + } 650 + 651 + return false; 652 + } 653 + 654 + /* scale_numeric_sensor - scale sensor reading for hwmon */ 655 + static long scale_numeric_sensor(const struct hp_wmi_numeric_sensor *nsensor) 656 + { 657 + u32 current_reading = nsensor->current_reading; 658 + s32 unit_modifier = nsensor->unit_modifier; 659 + u32 sensor_type = nsensor->sensor_type; 660 + u32 base_units = nsensor->base_units; 661 + s32 target_modifier; 662 + long val; 663 + 664 + /* Fan readings are in RPM units; others are in milliunits. */ 665 + target_modifier = sensor_type == HP_WMI_TYPE_AIR_FLOW ? 0 : -3; 666 + 667 + val = current_reading; 668 + 669 + for (; unit_modifier < target_modifier; unit_modifier++) 670 + val = DIV_ROUND_CLOSEST(val, 10); 671 + 672 + for (; unit_modifier > target_modifier; unit_modifier--) { 673 + if (val > LONG_MAX / 10) { 674 + val = LONG_MAX; 675 + break; 676 + } 677 + val *= 10; 678 + } 679 + 680 + if (sensor_type == HP_WMI_TYPE_TEMPERATURE) { 681 + switch (base_units) { 682 + case HP_WMI_UNITS_DEGREES_F: 683 + val -= MILLI * 32; 684 + val = val <= LONG_MAX / 5 ? 685 + DIV_ROUND_CLOSEST(val * 5, 9) : 686 + DIV_ROUND_CLOSEST(val, 9) * 5; 687 + break; 688 + 689 + case HP_WMI_UNITS_DEGREES_K: 690 + val = milli_kelvin_to_millicelsius(val); 691 + break; 692 + } 693 + } 694 + 695 + return val; 696 + } 697 + 698 + /* 699 + * classify_numeric_sensor - classify a numeric sensor 700 + * @nsensor: pointer to numeric sensor struct 701 + * 702 + * Returns an enum hp_wmi_type value on success, 703 + * or a negative value if the sensor type is unsupported. 704 + */ 705 + static int classify_numeric_sensor(const struct hp_wmi_numeric_sensor *nsensor) 706 + { 707 + u32 sensor_type = nsensor->sensor_type; 708 + u32 base_units = nsensor->base_units; 709 + const char *name = nsensor->name; 710 + 711 + switch (sensor_type) { 712 + case HP_WMI_TYPE_TEMPERATURE: 713 + /* 714 + * Some systems have sensors named "X Thermal Index" in "Other" 715 + * units. Tested CPU sensor examples were found to be in °C, 716 + * albeit perhaps "differently" accurate; e.g. readings were 717 + * reliably -6°C vs. coretemp on a HP Compaq Elite 8300, and 718 + * +8°C on an EliteOne G1 800. But this is still within the 719 + * realm of plausibility for cheaply implemented motherboard 720 + * sensors, and chassis readings were about as expected. 721 + */ 722 + if ((base_units == HP_WMI_UNITS_OTHER && 723 + strstr(name, HP_WMI_PATTERN_TEMP_SENSOR)) || 724 + base_units == HP_WMI_UNITS_DEGREES_C || 725 + base_units == HP_WMI_UNITS_DEGREES_F || 726 + base_units == HP_WMI_UNITS_DEGREES_K) 727 + return HP_WMI_TYPE_TEMPERATURE; 728 + break; 729 + 730 + case HP_WMI_TYPE_VOLTAGE: 731 + if (base_units == HP_WMI_UNITS_VOLTS) 732 + return HP_WMI_TYPE_VOLTAGE; 733 + break; 734 + 735 + case HP_WMI_TYPE_CURRENT: 736 + if (base_units == HP_WMI_UNITS_AMPS) 737 + return HP_WMI_TYPE_CURRENT; 738 + break; 739 + 740 + case HP_WMI_TYPE_AIR_FLOW: 741 + /* 742 + * Strangely, HP considers fan RPM sensor type to be 743 + * "Air Flow" instead of the more intuitive "Tachometer". 744 + */ 745 + if (base_units == HP_WMI_UNITS_RPM) 746 + return HP_WMI_TYPE_AIR_FLOW; 747 + break; 748 + } 749 + 750 + return -EINVAL; 751 + } 752 + 753 + static int 754 + populate_numeric_sensor_from_wobj(struct device *dev, 755 + struct hp_wmi_numeric_sensor *nsensor, 756 + union acpi_object *wobj, bool *out_is_new) 757 + { 758 + int last_prop = HP_WMI_PROPERTY_RATE_UNITS; 759 + int prop = HP_WMI_PROPERTY_NAME; 760 + const char **possible_states; 761 + union acpi_object *element; 762 + acpi_object_type type; 763 + char *string; 764 + bool is_new; 765 + u32 value; 766 + u8 size; 767 + int err; 768 + 769 + err = check_numeric_sensor_wobj(wobj, &size, &is_new); 770 + if (err) 771 + return err; 772 + 773 + possible_states = devm_kcalloc(dev, size, sizeof(*possible_states), 774 + GFP_KERNEL); 775 + if (!possible_states) 776 + return -ENOMEM; 777 + 778 + element = wobj->package.elements; 779 + nsensor->possible_states = possible_states; 780 + nsensor->size = size; 781 + 782 + if (!is_new) 783 + last_prop = HP_WMI_PROPERTY_CURRENT_READING; 784 + 785 + for (; prop <= last_prop; prop++) { 786 + type = hp_wmi_property_map[prop]; 787 + 788 + err = extract_acpi_value(dev, element, type, &value, &string); 789 + if (err) 790 + return err; 791 + 792 + element++; 793 + 794 + switch (prop) { 795 + case HP_WMI_PROPERTY_NAME: 796 + nsensor->name = string; 797 + break; 798 + 799 + case HP_WMI_PROPERTY_DESCRIPTION: 800 + nsensor->description = string; 801 + break; 802 + 803 + case HP_WMI_PROPERTY_SENSOR_TYPE: 804 + if (value > HP_WMI_TYPE_AIR_FLOW) 805 + return -EINVAL; 806 + 807 + nsensor->sensor_type = value; 808 + break; 809 + 810 + case HP_WMI_PROPERTY_OTHER_SENSOR_TYPE: 811 + nsensor->other_sensor_type = string; 812 + break; 813 + 814 + case HP_WMI_PROPERTY_OPERATIONAL_STATUS: 815 + nsensor->operational_status = value; 816 + 817 + /* Old variant: CurrentState follows OperationalStatus. */ 818 + if (!is_new) 819 + prop = HP_WMI_PROPERTY_CURRENT_STATE - 1; 820 + break; 821 + 822 + case HP_WMI_PROPERTY_SIZE: 823 + break; /* Already set. */ 824 + 825 + case HP_WMI_PROPERTY_POSSIBLE_STATES: 826 + *possible_states++ = string; 827 + if (--size) 828 + prop--; 829 + 830 + /* Old variant: BaseUnits follows PossibleStates[]. */ 831 + if (!is_new && !size) 832 + prop = HP_WMI_PROPERTY_BASE_UNITS - 1; 833 + break; 834 + 835 + case HP_WMI_PROPERTY_CURRENT_STATE: 836 + nsensor->current_state = string; 837 + 838 + /* Old variant: PossibleStates[] follows CurrentState. */ 839 + if (!is_new) 840 + prop = HP_WMI_PROPERTY_POSSIBLE_STATES - 1; 841 + break; 842 + 843 + case HP_WMI_PROPERTY_BASE_UNITS: 844 + nsensor->base_units = value; 845 + break; 846 + 847 + case HP_WMI_PROPERTY_UNIT_MODIFIER: 848 + /* UnitModifier is signed. */ 849 + nsensor->unit_modifier = (s32)value; 850 + break; 851 + 852 + case HP_WMI_PROPERTY_CURRENT_READING: 853 + nsensor->current_reading = value; 854 + break; 855 + 856 + case HP_WMI_PROPERTY_RATE_UNITS: 857 + nsensor->rate_units = value; 858 + break; 859 + 860 + default: 861 + return -EINVAL; 862 + } 863 + } 864 + 865 + *out_is_new = is_new; 866 + 867 + return 0; 868 + } 869 + 870 + /* update_numeric_sensor_from_wobj - update fungible sensor properties */ 871 + static void 872 + update_numeric_sensor_from_wobj(struct device *dev, 873 + struct hp_wmi_numeric_sensor *nsensor, 874 + const union acpi_object *wobj) 875 + { 876 + const union acpi_object *elements; 877 + const union acpi_object *element; 878 + const char *string; 879 + bool is_new; 880 + int offset; 881 + u8 size; 882 + int err; 883 + 884 + err = check_numeric_sensor_wobj(wobj, &size, &is_new); 885 + if (err) 886 + return; 887 + 888 + elements = wobj->package.elements; 889 + 890 + element = &elements[HP_WMI_PROPERTY_OPERATIONAL_STATUS]; 891 + nsensor->operational_status = element->integer.value; 892 + 893 + /* 894 + * In general, an index offset is needed after PossibleStates[0]. 895 + * On a new variant, CurrentState is after PossibleStates[]. This is 896 + * not the case on an old variant, but we still need to offset the 897 + * read because CurrentState is where Size would be on a new variant. 898 + */ 899 + offset = is_new ? size - 1 : -2; 900 + 901 + element = &elements[HP_WMI_PROPERTY_CURRENT_STATE + offset]; 902 + string = strim(element->string.pointer); 903 + 904 + if (strcmp(string, nsensor->current_state)) { 905 + devm_kfree(dev, nsensor->current_state); 906 + nsensor->current_state = hp_wmi_strdup(dev, string); 907 + } 908 + 909 + /* Old variant: -2 (not -1) because it lacks the Size property. */ 910 + if (!is_new) 911 + offset = (int)size - 2; /* size is > 0, i.e. may be 1. */ 912 + 913 + element = &elements[HP_WMI_PROPERTY_UNIT_MODIFIER + offset]; 914 + nsensor->unit_modifier = (s32)element->integer.value; 915 + 916 + element = &elements[HP_WMI_PROPERTY_CURRENT_READING + offset]; 917 + nsensor->current_reading = element->integer.value; 918 + } 919 + 920 + /* 921 + * check_platform_events_wobj - validate a HPBIOS_PlatformEvents instance 922 + * @wobj: pointer to WMI object instance to check 923 + * 924 + * Returns 0 on success, or a negative error code on error. 925 + */ 926 + static int check_platform_events_wobj(const union acpi_object *wobj) 927 + { 928 + return check_wobj(wobj, hp_wmi_platform_events_property_map, 929 + HP_WMI_PLATFORM_EVENTS_PROPERTY_POSSIBLE_STATUS); 930 + } 931 + 932 + static int 933 + populate_platform_events_from_wobj(struct device *dev, 934 + struct hp_wmi_platform_events *pevents, 935 + union acpi_object *wobj) 936 + { 937 + int last_prop = HP_WMI_PLATFORM_EVENTS_PROPERTY_POSSIBLE_STATUS; 938 + int prop = HP_WMI_PLATFORM_EVENTS_PROPERTY_NAME; 939 + union acpi_object *element; 940 + acpi_object_type type; 941 + char *string; 942 + u32 value; 943 + int err; 944 + 945 + err = check_platform_events_wobj(wobj); 946 + if (err) 947 + return err; 948 + 949 + element = wobj->package.elements; 950 + 951 + for (; prop <= last_prop; prop++, element++) { 952 + type = hp_wmi_platform_events_property_map[prop]; 953 + 954 + err = extract_acpi_value(dev, element, type, &value, &string); 955 + if (err) 956 + return err; 957 + 958 + switch (prop) { 959 + case HP_WMI_PLATFORM_EVENTS_PROPERTY_NAME: 960 + pevents->name = string; 961 + break; 962 + 963 + case HP_WMI_PLATFORM_EVENTS_PROPERTY_DESCRIPTION: 964 + pevents->description = string; 965 + break; 966 + 967 + case HP_WMI_PLATFORM_EVENTS_PROPERTY_SOURCE_NAMESPACE: 968 + if (strcasecmp(HP_WMI_EVENT_NAMESPACE, string)) 969 + return -EINVAL; 970 + 971 + pevents->source_namespace = string; 972 + break; 973 + 974 + case HP_WMI_PLATFORM_EVENTS_PROPERTY_SOURCE_CLASS: 975 + if (strcasecmp(HP_WMI_EVENT_CLASS, string)) 976 + return -EINVAL; 977 + 978 + pevents->source_class = string; 979 + break; 980 + 981 + case HP_WMI_PLATFORM_EVENTS_PROPERTY_CATEGORY: 982 + pevents->category = value; 983 + break; 984 + 985 + case HP_WMI_PLATFORM_EVENTS_PROPERTY_POSSIBLE_SEVERITY: 986 + pevents->possible_severity = value; 987 + break; 988 + 989 + case HP_WMI_PLATFORM_EVENTS_PROPERTY_POSSIBLE_STATUS: 990 + pevents->possible_status = value; 991 + break; 992 + 993 + default: 994 + return -EINVAL; 995 + } 996 + } 997 + 998 + return 0; 999 + } 1000 + 1001 + /* 1002 + * check_event_wobj - validate a HPBIOS_BIOSEvent instance 1003 + * @wobj: pointer to WMI object instance to check 1004 + * 1005 + * Returns 0 on success, or a negative error code on error. 1006 + */ 1007 + static int check_event_wobj(const union acpi_object *wobj) 1008 + { 1009 + return check_wobj(wobj, hp_wmi_event_property_map, 1010 + HP_WMI_EVENT_PROPERTY_STATUS); 1011 + } 1012 + 1013 + static int populate_event_from_wobj(struct hp_wmi_event *event, 1014 + union acpi_object *wobj) 1015 + { 1016 + int prop = HP_WMI_EVENT_PROPERTY_NAME; 1017 + union acpi_object *element; 1018 + int err; 1019 + 1020 + err = check_event_wobj(wobj); 1021 + if (err) 1022 + return err; 1023 + 1024 + element = wobj->package.elements; 1025 + 1026 + /* Extracted strings are NOT device-managed copies. */ 1027 + 1028 + for (; prop <= HP_WMI_EVENT_PROPERTY_CATEGORY; prop++, element++) { 1029 + switch (prop) { 1030 + case HP_WMI_EVENT_PROPERTY_NAME: 1031 + event->name = strim(element->string.pointer); 1032 + break; 1033 + 1034 + case HP_WMI_EVENT_PROPERTY_DESCRIPTION: 1035 + event->description = strim(element->string.pointer); 1036 + break; 1037 + 1038 + case HP_WMI_EVENT_PROPERTY_CATEGORY: 1039 + event->category = element->integer.value; 1040 + break; 1041 + 1042 + default: 1043 + return -EINVAL; 1044 + } 1045 + } 1046 + 1047 + return 0; 1048 + } 1049 + 1050 + /* 1051 + * classify_event - classify an event 1052 + * @name: event name 1053 + * @category: event category 1054 + * 1055 + * Classify instances of both HPBIOS_PlatformEvents and HPBIOS_BIOSEvent from 1056 + * property values. Recognition criteria are based on multiple ACPI dumps [3]. 1057 + * 1058 + * Returns an enum hp_wmi_type value on success, 1059 + * or a negative value if the event type is unsupported. 1060 + */ 1061 + static int classify_event(const char *event_name, u32 category) 1062 + { 1063 + if (category != HP_WMI_CATEGORY_SENSOR) 1064 + return -EINVAL; 1065 + 1066 + /* Fan events have Name "X Stall". */ 1067 + if (strstr(event_name, HP_WMI_PATTERN_FAN_ALARM)) 1068 + return HP_WMI_TYPE_AIR_FLOW; 1069 + 1070 + /* Intrusion events have Name "Hood Intrusion". */ 1071 + if (!strcmp(event_name, HP_WMI_PATTERN_INTRUSION_ALARM)) 1072 + return HP_WMI_TYPE_INTRUSION; 1073 + 1074 + /* 1075 + * Temperature events have Name either "Thermal Caution" or 1076 + * "Thermal Critical". Deal only with "Thermal Critical" events. 1077 + * 1078 + * "Thermal Caution" events have Status "Stressed", informing us that 1079 + * the OperationalStatus of the related sensor has become "Stressed". 1080 + * However, this is already a fault condition that will clear itself 1081 + * when the sensor recovers, so we have no further interest in them. 1082 + */ 1083 + if (!strcmp(event_name, HP_WMI_PATTERN_TEMP_ALARM)) 1084 + return HP_WMI_TYPE_TEMPERATURE; 1085 + 1086 + return -EINVAL; 1087 + } 1088 + 1089 + /* 1090 + * interpret_info - interpret sensor for hwmon 1091 + * @info: pointer to sensor info struct 1092 + * 1093 + * Should be called after the numeric sensor member has been updated. 1094 + */ 1095 + static void interpret_info(struct hp_wmi_info *info) 1096 + { 1097 + const struct hp_wmi_numeric_sensor *nsensor = &info->nsensor; 1098 + 1099 + info->cached_val = scale_numeric_sensor(nsensor); 1100 + info->last_updated = jiffies; 1101 + } 1102 + 1103 + /* 1104 + * hp_wmi_update_info - poll WMI to update sensor info 1105 + * @state: pointer to driver state 1106 + * @info: pointer to sensor info struct 1107 + * 1108 + * Returns 0 on success, or a negative error code on error. 1109 + */ 1110 + static int hp_wmi_update_info(struct hp_wmi_sensors *state, 1111 + struct hp_wmi_info *info) 1112 + { 1113 + struct hp_wmi_numeric_sensor *nsensor = &info->nsensor; 1114 + struct device *dev = &state->wdev->dev; 1115 + const union acpi_object *wobj; 1116 + u8 instance = info->instance; 1117 + int ret = 0; 1118 + 1119 + if (time_after(jiffies, info->last_updated + HZ)) { 1120 + mutex_lock(&state->lock); 1121 + 1122 + wobj = hp_wmi_get_wobj(HP_WMI_NUMERIC_SENSOR_GUID, instance); 1123 + if (!wobj) { 1124 + ret = -EIO; 1125 + goto out_unlock; 1126 + } 1127 + 1128 + update_numeric_sensor_from_wobj(dev, nsensor, wobj); 1129 + 1130 + interpret_info(info); 1131 + 1132 + kfree(wobj); 1133 + 1134 + out_unlock: 1135 + mutex_unlock(&state->lock); 1136 + } 1137 + 1138 + return ret; 1139 + } 1140 + 1141 + static int basic_string_show(struct seq_file *seqf, void *ignored) 1142 + { 1143 + const char *str = seqf->private; 1144 + 1145 + seq_printf(seqf, "%s\n", str); 1146 + 1147 + return 0; 1148 + } 1149 + DEFINE_SHOW_ATTRIBUTE(basic_string); 1150 + 1151 + static int fungible_show(struct seq_file *seqf, enum hp_wmi_property prop) 1152 + { 1153 + struct hp_wmi_numeric_sensor *nsensor; 1154 + struct hp_wmi_sensors *state; 1155 + struct hp_wmi_info *info; 1156 + int err; 1157 + 1158 + info = seqf->private; 1159 + state = info->state; 1160 + nsensor = &info->nsensor; 1161 + 1162 + err = hp_wmi_update_info(state, info); 1163 + if (err) 1164 + return err; 1165 + 1166 + switch (prop) { 1167 + case HP_WMI_PROPERTY_OPERATIONAL_STATUS: 1168 + seq_printf(seqf, "%u\n", nsensor->operational_status); 1169 + break; 1170 + 1171 + case HP_WMI_PROPERTY_CURRENT_STATE: 1172 + seq_printf(seqf, "%s\n", nsensor->current_state); 1173 + break; 1174 + 1175 + case HP_WMI_PROPERTY_UNIT_MODIFIER: 1176 + seq_printf(seqf, "%d\n", nsensor->unit_modifier); 1177 + break; 1178 + 1179 + case HP_WMI_PROPERTY_CURRENT_READING: 1180 + seq_printf(seqf, "%u\n", nsensor->current_reading); 1181 + break; 1182 + 1183 + default: 1184 + return -EOPNOTSUPP; 1185 + } 1186 + 1187 + return 0; 1188 + } 1189 + 1190 + static int operational_status_show(struct seq_file *seqf, void *ignored) 1191 + { 1192 + return fungible_show(seqf, HP_WMI_PROPERTY_OPERATIONAL_STATUS); 1193 + } 1194 + DEFINE_SHOW_ATTRIBUTE(operational_status); 1195 + 1196 + static int current_state_show(struct seq_file *seqf, void *ignored) 1197 + { 1198 + return fungible_show(seqf, HP_WMI_PROPERTY_CURRENT_STATE); 1199 + } 1200 + DEFINE_SHOW_ATTRIBUTE(current_state); 1201 + 1202 + static int possible_states_show(struct seq_file *seqf, void *ignored) 1203 + { 1204 + struct hp_wmi_numeric_sensor *nsensor = seqf->private; 1205 + u8 i; 1206 + 1207 + for (i = 0; i < nsensor->size; i++) 1208 + seq_printf(seqf, "%s%s", i ? "," : "", 1209 + nsensor->possible_states[i]); 1210 + 1211 + seq_puts(seqf, "\n"); 1212 + 1213 + return 0; 1214 + } 1215 + DEFINE_SHOW_ATTRIBUTE(possible_states); 1216 + 1217 + static int unit_modifier_show(struct seq_file *seqf, void *ignored) 1218 + { 1219 + return fungible_show(seqf, HP_WMI_PROPERTY_UNIT_MODIFIER); 1220 + } 1221 + DEFINE_SHOW_ATTRIBUTE(unit_modifier); 1222 + 1223 + static int current_reading_show(struct seq_file *seqf, void *ignored) 1224 + { 1225 + return fungible_show(seqf, HP_WMI_PROPERTY_CURRENT_READING); 1226 + } 1227 + DEFINE_SHOW_ATTRIBUTE(current_reading); 1228 + 1229 + /* hp_wmi_devm_debugfs_remove - devm callback for debugfs cleanup */ 1230 + static void hp_wmi_devm_debugfs_remove(void *res) 1231 + { 1232 + debugfs_remove_recursive(res); 1233 + } 1234 + 1235 + /* hp_wmi_debugfs_init - create and populate debugfs directory tree */ 1236 + static void hp_wmi_debugfs_init(struct device *dev, struct hp_wmi_info *info, 1237 + struct hp_wmi_platform_events *pevents, 1238 + u8 icount, u8 pcount, bool is_new) 1239 + { 1240 + struct hp_wmi_numeric_sensor *nsensor; 1241 + char buf[HP_WMI_MAX_STR_SIZE]; 1242 + struct dentry *debugfs; 1243 + struct dentry *entries; 1244 + struct dentry *dir; 1245 + int err; 1246 + u8 i; 1247 + 1248 + /* dev_name() gives a not-very-friendly GUID for WMI devices. */ 1249 + scnprintf(buf, sizeof(buf), "hp-wmi-sensors-%u", dev->id); 1250 + 1251 + debugfs = debugfs_create_dir(buf, NULL); 1252 + if (IS_ERR(debugfs)) 1253 + return; 1254 + 1255 + err = devm_add_action_or_reset(dev, hp_wmi_devm_debugfs_remove, 1256 + debugfs); 1257 + if (err) 1258 + return; 1259 + 1260 + entries = debugfs_create_dir("sensor", debugfs); 1261 + 1262 + for (i = 0; i < icount; i++, info++) { 1263 + nsensor = &info->nsensor; 1264 + 1265 + scnprintf(buf, sizeof(buf), "%u", i); 1266 + dir = debugfs_create_dir(buf, entries); 1267 + 1268 + debugfs_create_file("name", 0444, dir, 1269 + (void *)nsensor->name, 1270 + &basic_string_fops); 1271 + 1272 + debugfs_create_file("description", 0444, dir, 1273 + (void *)nsensor->description, 1274 + &basic_string_fops); 1275 + 1276 + debugfs_create_u32("sensor_type", 0444, dir, 1277 + &nsensor->sensor_type); 1278 + 1279 + debugfs_create_file("other_sensor_type", 0444, dir, 1280 + (void *)nsensor->other_sensor_type, 1281 + &basic_string_fops); 1282 + 1283 + debugfs_create_file("operational_status", 0444, dir, 1284 + info, &operational_status_fops); 1285 + 1286 + debugfs_create_file("possible_states", 0444, dir, 1287 + nsensor, &possible_states_fops); 1288 + 1289 + debugfs_create_file("current_state", 0444, dir, 1290 + info, &current_state_fops); 1291 + 1292 + debugfs_create_u32("base_units", 0444, dir, 1293 + &nsensor->base_units); 1294 + 1295 + debugfs_create_file("unit_modifier", 0444, dir, 1296 + info, &unit_modifier_fops); 1297 + 1298 + debugfs_create_file("current_reading", 0444, dir, 1299 + info, &current_reading_fops); 1300 + 1301 + if (is_new) 1302 + debugfs_create_u32("rate_units", 0444, dir, 1303 + &nsensor->rate_units); 1304 + } 1305 + 1306 + if (!pcount) 1307 + return; 1308 + 1309 + entries = debugfs_create_dir("platform_events", debugfs); 1310 + 1311 + for (i = 0; i < pcount; i++, pevents++) { 1312 + scnprintf(buf, sizeof(buf), "%u", i); 1313 + dir = debugfs_create_dir(buf, entries); 1314 + 1315 + debugfs_create_file("name", 0444, dir, 1316 + (void *)pevents->name, 1317 + &basic_string_fops); 1318 + 1319 + debugfs_create_file("description", 0444, dir, 1320 + (void *)pevents->description, 1321 + &basic_string_fops); 1322 + 1323 + debugfs_create_file("source_namespace", 0444, dir, 1324 + (void *)pevents->source_namespace, 1325 + &basic_string_fops); 1326 + 1327 + debugfs_create_file("source_class", 0444, dir, 1328 + (void *)pevents->source_class, 1329 + &basic_string_fops); 1330 + 1331 + debugfs_create_u32("category", 0444, dir, 1332 + &pevents->category); 1333 + 1334 + debugfs_create_u32("possible_severity", 0444, dir, 1335 + &pevents->possible_severity); 1336 + 1337 + debugfs_create_u32("possible_status", 0444, dir, 1338 + &pevents->possible_status); 1339 + } 1340 + } 1341 + 1342 + static umode_t hp_wmi_hwmon_is_visible(const void *drvdata, 1343 + enum hwmon_sensor_types type, 1344 + u32 attr, int channel) 1345 + { 1346 + const struct hp_wmi_sensors *state = drvdata; 1347 + const struct hp_wmi_info *info; 1348 + 1349 + if (type == hwmon_intrusion) 1350 + return state->has_intrusion ? 0644 : 0; 1351 + 1352 + if (!state->info_map[type] || !state->info_map[type][channel]) 1353 + return 0; 1354 + 1355 + info = state->info_map[type][channel]; 1356 + 1357 + if ((type == hwmon_temp && attr == hwmon_temp_alarm) || 1358 + (type == hwmon_fan && attr == hwmon_fan_alarm)) 1359 + return info->has_alarm ? 0444 : 0; 1360 + 1361 + return 0444; 1362 + } 1363 + 1364 + static int hp_wmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type, 1365 + u32 attr, int channel, long *out_val) 1366 + { 1367 + struct hp_wmi_sensors *state = dev_get_drvdata(dev); 1368 + const struct hp_wmi_numeric_sensor *nsensor; 1369 + struct hp_wmi_info *info; 1370 + int err; 1371 + 1372 + if (type == hwmon_intrusion) { 1373 + *out_val = state->intrusion ? 1 : 0; 1374 + 1375 + return 0; 1376 + } 1377 + 1378 + info = state->info_map[type][channel]; 1379 + 1380 + if ((type == hwmon_temp && attr == hwmon_temp_alarm) || 1381 + (type == hwmon_fan && attr == hwmon_fan_alarm)) { 1382 + *out_val = info->alarm ? 1 : 0; 1383 + info->alarm = false; 1384 + 1385 + return 0; 1386 + } 1387 + 1388 + nsensor = &info->nsensor; 1389 + 1390 + err = hp_wmi_update_info(state, info); 1391 + if (err) 1392 + return err; 1393 + 1394 + if ((type == hwmon_temp && attr == hwmon_temp_fault) || 1395 + (type == hwmon_fan && attr == hwmon_fan_fault)) 1396 + *out_val = numeric_sensor_has_fault(nsensor); 1397 + else 1398 + *out_val = info->cached_val; 1399 + 1400 + return 0; 1401 + } 1402 + 1403 + static int hp_wmi_hwmon_read_string(struct device *dev, 1404 + enum hwmon_sensor_types type, u32 attr, 1405 + int channel, const char **out_str) 1406 + { 1407 + const struct hp_wmi_sensors *state = dev_get_drvdata(dev); 1408 + const struct hp_wmi_info *info; 1409 + 1410 + info = state->info_map[type][channel]; 1411 + *out_str = info->nsensor.name; 1412 + 1413 + return 0; 1414 + } 1415 + 1416 + static int hp_wmi_hwmon_write(struct device *dev, enum hwmon_sensor_types type, 1417 + u32 attr, int channel, long val) 1418 + { 1419 + struct hp_wmi_sensors *state = dev_get_drvdata(dev); 1420 + 1421 + if (val) 1422 + return -EINVAL; 1423 + 1424 + mutex_lock(&state->lock); 1425 + 1426 + state->intrusion = false; 1427 + 1428 + mutex_unlock(&state->lock); 1429 + 1430 + return 0; 1431 + } 1432 + 1433 + static const struct hwmon_ops hp_wmi_hwmon_ops = { 1434 + .is_visible = hp_wmi_hwmon_is_visible, 1435 + .read = hp_wmi_hwmon_read, 1436 + .read_string = hp_wmi_hwmon_read_string, 1437 + .write = hp_wmi_hwmon_write, 1438 + }; 1439 + 1440 + static struct hwmon_chip_info hp_wmi_chip_info = { 1441 + .ops = &hp_wmi_hwmon_ops, 1442 + .info = NULL, 1443 + }; 1444 + 1445 + static struct hp_wmi_info *match_fan_event(struct hp_wmi_sensors *state, 1446 + const char *event_description) 1447 + { 1448 + struct hp_wmi_info **ptr_info = state->info_map[hwmon_fan]; 1449 + u8 fan_count = state->channel_count[hwmon_fan]; 1450 + struct hp_wmi_info *info; 1451 + const char *name; 1452 + u8 i; 1453 + 1454 + /* Fan event has Description "X Speed". Sensor has Name "X[ Speed]". */ 1455 + 1456 + for (i = 0; i < fan_count; i++, ptr_info++) { 1457 + info = *ptr_info; 1458 + name = info->nsensor.name; 1459 + 1460 + if (strstr(event_description, name)) 1461 + return info; 1462 + } 1463 + 1464 + return NULL; 1465 + } 1466 + 1467 + static u8 match_temp_events(struct hp_wmi_sensors *state, 1468 + const char *event_description, 1469 + struct hp_wmi_info *temp_info[]) 1470 + { 1471 + struct hp_wmi_info **ptr_info = state->info_map[hwmon_temp]; 1472 + u8 temp_count = state->channel_count[hwmon_temp]; 1473 + struct hp_wmi_info *info; 1474 + const char *name; 1475 + u8 count = 0; 1476 + bool is_cpu; 1477 + bool is_sys; 1478 + u8 i; 1479 + 1480 + /* Description is either "CPU Thermal Index" or "Chassis Thermal Index". */ 1481 + 1482 + is_cpu = !strcmp(event_description, HP_WMI_PATTERN_CPU_TEMP); 1483 + is_sys = !strcmp(event_description, HP_WMI_PATTERN_SYS_TEMP); 1484 + if (!is_cpu && !is_sys) 1485 + return 0; 1486 + 1487 + /* 1488 + * CPU event: Match one sensor with Name either "CPU Thermal Index" or 1489 + * "CPU Temperature", or multiple with Name(s) "CPU[#] Temperature". 1490 + * 1491 + * Chassis event: Match one sensor with Name either 1492 + * "Chassis Thermal Index" or "System Ambient Temperature". 1493 + */ 1494 + 1495 + for (i = 0; i < temp_count; i++, ptr_info++) { 1496 + info = *ptr_info; 1497 + name = info->nsensor.name; 1498 + 1499 + if ((is_cpu && (!strcmp(name, HP_WMI_PATTERN_CPU_TEMP) || 1500 + !strcmp(name, HP_WMI_PATTERN_CPU_TEMP2))) || 1501 + (is_sys && (!strcmp(name, HP_WMI_PATTERN_SYS_TEMP) || 1502 + !strcmp(name, HP_WMI_PATTERN_SYS_TEMP2)))) { 1503 + temp_info[0] = info; 1504 + return 1; 1505 + } 1506 + 1507 + if (is_cpu && (strstr(name, HP_WMI_PATTERN_CPU) && 1508 + strstr(name, HP_WMI_PATTERN_TEMP))) 1509 + temp_info[count++] = info; 1510 + } 1511 + 1512 + return count; 1513 + } 1514 + 1515 + /* hp_wmi_devm_debugfs_remove - devm callback for WMI event handler removal */ 1516 + static void hp_wmi_devm_notify_remove(void *ignored) 1517 + { 1518 + wmi_remove_notify_handler(HP_WMI_EVENT_GUID); 1519 + } 1520 + 1521 + /* hp_wmi_notify - WMI event notification handler */ 1522 + static void hp_wmi_notify(u32 value, void *context) 1523 + { 1524 + struct hp_wmi_info *temp_info[HP_WMI_MAX_INSTANCES] = {}; 1525 + struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; 1526 + struct hp_wmi_sensors *state = context; 1527 + struct device *dev = &state->wdev->dev; 1528 + struct hp_wmi_info *fan_info; 1529 + struct hp_wmi_event event; 1530 + union acpi_object *wobj; 1531 + acpi_status err; 1532 + int event_type; 1533 + u8 count; 1534 + 1535 + /* 1536 + * The following warning may occur in the kernel log: 1537 + * 1538 + * ACPI Warning: \_SB.WMID._WED: Return type mismatch - 1539 + * found Package, expected Integer/String/Buffer 1540 + * 1541 + * After using [4] to decode BMOF blobs found in [3], careless copying 1542 + * of BIOS code seems the most likely explanation for this warning. 1543 + * HP_WMI_EVENT_GUID refers to \\.\root\WMI\HPBIOS_BIOSEvent on 1544 + * business-class systems, but it refers to \\.\root\WMI\hpqBEvnt on 1545 + * non-business-class systems. Per the existing hp-wmi driver, it 1546 + * looks like an instance of hpqBEvnt delivered as event data may 1547 + * indeed take the form of a raw ACPI_BUFFER on non-business-class 1548 + * systems ("may" because ASL shows some BIOSes do strange things). 1549 + * 1550 + * In any case, we can ignore this warning, because we always validate 1551 + * the event data to ensure it is an ACPI_PACKAGE containing a 1552 + * HPBIOS_BIOSEvent instance. 1553 + */ 1554 + 1555 + mutex_lock(&state->lock); 1556 + 1557 + err = wmi_get_event_data(value, &out); 1558 + if (ACPI_FAILURE(err)) 1559 + goto out_unlock; 1560 + 1561 + wobj = out.pointer; 1562 + 1563 + err = populate_event_from_wobj(&event, wobj); 1564 + if (err) { 1565 + dev_warn(dev, "Bad event data (ACPI type %d)\n", wobj->type); 1566 + goto out_free_wobj; 1567 + } 1568 + 1569 + event_type = classify_event(event.name, event.category); 1570 + switch (event_type) { 1571 + case HP_WMI_TYPE_AIR_FLOW: 1572 + fan_info = match_fan_event(state, event.description); 1573 + if (fan_info) 1574 + fan_info->alarm = true; 1575 + break; 1576 + 1577 + case HP_WMI_TYPE_INTRUSION: 1578 + state->intrusion = true; 1579 + break; 1580 + 1581 + case HP_WMI_TYPE_TEMPERATURE: 1582 + count = match_temp_events(state, event.description, temp_info); 1583 + while (count) 1584 + temp_info[--count]->alarm = true; 1585 + break; 1586 + 1587 + default: 1588 + break; 1589 + } 1590 + 1591 + out_free_wobj: 1592 + kfree(wobj); 1593 + 1594 + out_unlock: 1595 + mutex_unlock(&state->lock); 1596 + } 1597 + 1598 + static int init_platform_events(struct device *dev, 1599 + struct hp_wmi_platform_events **out_pevents, 1600 + u8 *out_pcount) 1601 + { 1602 + struct hp_wmi_platform_events *pevents_arr; 1603 + struct hp_wmi_platform_events *pevents; 1604 + union acpi_object *wobj; 1605 + u8 count; 1606 + int err; 1607 + u8 i; 1608 + 1609 + count = hp_wmi_wobj_instance_count(HP_WMI_PLATFORM_EVENTS_GUID); 1610 + if (!count) { 1611 + *out_pcount = 0; 1612 + 1613 + dev_dbg(dev, "No platform events\n"); 1614 + 1615 + return 0; 1616 + } 1617 + 1618 + pevents_arr = devm_kcalloc(dev, count, sizeof(*pevents), GFP_KERNEL); 1619 + if (!pevents_arr) 1620 + return -ENOMEM; 1621 + 1622 + for (i = 0, pevents = pevents_arr; i < count; i++, pevents++) { 1623 + wobj = hp_wmi_get_wobj(HP_WMI_PLATFORM_EVENTS_GUID, i); 1624 + if (!wobj) 1625 + return -EIO; 1626 + 1627 + err = populate_platform_events_from_wobj(dev, pevents, wobj); 1628 + 1629 + kfree(wobj); 1630 + 1631 + if (err) 1632 + return err; 1633 + } 1634 + 1635 + *out_pevents = pevents_arr; 1636 + *out_pcount = count; 1637 + 1638 + dev_dbg(dev, "Found %u platform events\n", count); 1639 + 1640 + return 0; 1641 + } 1642 + 1643 + static int init_numeric_sensors(struct hp_wmi_sensors *state, 1644 + struct hp_wmi_info *connected[], 1645 + struct hp_wmi_info **out_info, 1646 + u8 *out_icount, u8 *out_count, 1647 + bool *out_is_new) 1648 + { 1649 + struct hp_wmi_info ***info_map = state->info_map; 1650 + u8 *channel_count = state->channel_count; 1651 + struct device *dev = &state->wdev->dev; 1652 + struct hp_wmi_numeric_sensor *nsensor; 1653 + u8 channel_index[hwmon_max] = {}; 1654 + enum hwmon_sensor_types type; 1655 + struct hp_wmi_info *info_arr; 1656 + struct hp_wmi_info *info; 1657 + union acpi_object *wobj; 1658 + u8 count = 0; 1659 + bool is_new; 1660 + u8 icount; 1661 + int wtype; 1662 + int err; 1663 + u8 c; 1664 + u8 i; 1665 + 1666 + icount = hp_wmi_wobj_instance_count(HP_WMI_NUMERIC_SENSOR_GUID); 1667 + if (!icount) 1668 + return -ENODATA; 1669 + 1670 + info_arr = devm_kcalloc(dev, icount, sizeof(*info), GFP_KERNEL); 1671 + if (!info_arr) 1672 + return -ENOMEM; 1673 + 1674 + for (i = 0, info = info_arr; i < icount; i++, info++) { 1675 + wobj = hp_wmi_get_wobj(HP_WMI_NUMERIC_SENSOR_GUID, i); 1676 + if (!wobj) 1677 + return -EIO; 1678 + 1679 + info->instance = i; 1680 + info->state = state; 1681 + nsensor = &info->nsensor; 1682 + 1683 + err = populate_numeric_sensor_from_wobj(dev, nsensor, wobj, 1684 + &is_new); 1685 + 1686 + kfree(wobj); 1687 + 1688 + if (err) 1689 + return err; 1690 + 1691 + if (!numeric_sensor_is_connected(nsensor)) 1692 + continue; 1693 + 1694 + wtype = classify_numeric_sensor(nsensor); 1695 + if (wtype < 0) 1696 + continue; 1697 + 1698 + type = hp_wmi_hwmon_type_map[wtype]; 1699 + 1700 + channel_count[type]++; 1701 + 1702 + info->type = type; 1703 + 1704 + interpret_info(info); 1705 + 1706 + connected[count++] = info; 1707 + } 1708 + 1709 + dev_dbg(dev, "Found %u sensors (%u connected)\n", i, count); 1710 + 1711 + for (i = 0; i < count; i++) { 1712 + info = connected[i]; 1713 + type = info->type; 1714 + c = channel_index[type]++; 1715 + 1716 + if (!info_map[type]) { 1717 + info_map[type] = devm_kcalloc(dev, channel_count[type], 1718 + sizeof(*info_map), 1719 + GFP_KERNEL); 1720 + if (!info_map[type]) 1721 + return -ENOMEM; 1722 + } 1723 + 1724 + info_map[type][c] = info; 1725 + } 1726 + 1727 + *out_info = info_arr; 1728 + *out_icount = icount; 1729 + *out_count = count; 1730 + *out_is_new = is_new; 1731 + 1732 + return 0; 1733 + } 1734 + 1735 + static bool find_event_attributes(struct hp_wmi_sensors *state, 1736 + struct hp_wmi_platform_events *pevents, 1737 + u8 pevents_count) 1738 + { 1739 + /* 1740 + * The existence of this HPBIOS_PlatformEvents instance: 1741 + * 1742 + * { 1743 + * Name = "Rear Chassis Fan0 Stall"; 1744 + * Description = "Rear Chassis Fan0 Speed"; 1745 + * Category = 3; // "Sensor" 1746 + * PossibleSeverity = 25; // "Critical Failure" 1747 + * PossibleStatus = 5; // "Predictive Failure" 1748 + * [...] 1749 + * } 1750 + * 1751 + * means that this HPBIOS_BIOSEvent instance may occur: 1752 + * 1753 + * { 1754 + * Name = "Rear Chassis Fan0 Stall"; 1755 + * Description = "Rear Chassis Fan0 Speed"; 1756 + * Category = 3; // "Sensor" 1757 + * Severity = 25; // "Critical Failure" 1758 + * Status = 5; // "Predictive Failure" 1759 + * } 1760 + * 1761 + * After the event occurs (e.g. because the fan was unplugged), 1762 + * polling the related HPBIOS_BIOSNumericSensor instance gives: 1763 + * 1764 + * { 1765 + * Name = "Rear Chassis Fan0"; 1766 + * Description = "Reports rear chassis fan0 speed"; 1767 + * OperationalStatus = 5; // "Predictive Failure", was 3 ("OK") 1768 + * CurrentReading = 0; 1769 + * [...] 1770 + * } 1771 + * 1772 + * In this example, the hwmon fan channel for "Rear Chassis Fan0" 1773 + * should support the alarm flag and have it be set if the related 1774 + * HPBIOS_BIOSEvent instance occurs. 1775 + * 1776 + * In addition to fan events, temperature (CPU/chassis) and intrusion 1777 + * events are relevant to hwmon [2]. Note that much information in [2] 1778 + * is unreliable; it is referenced in addition to ACPI dumps [3] merely 1779 + * to support the conclusion that sensor and event names/descriptions 1780 + * are systematic enough to allow this driver to match them. 1781 + * 1782 + * Complications and limitations: 1783 + * 1784 + * - Strings are freeform and may vary, cf. sensor Name "CPU0 Fan" 1785 + * on a Z420 vs. "CPU Fan Speed" on an EliteOne 800 G1. 1786 + * - Leading/trailing whitespace is a rare but real possibility [3]. 1787 + * - The HPBIOS_PlatformEvents object may not exist or its instances 1788 + * may show that the system only has e.g. BIOS setting-related 1789 + * events (cf. the ProBook 4540s and ProBook 470 G0 [3]). 1790 + */ 1791 + 1792 + struct hp_wmi_info *temp_info[HP_WMI_MAX_INSTANCES] = {}; 1793 + const char *event_description; 1794 + struct hp_wmi_info *fan_info; 1795 + bool has_events = false; 1796 + const char *event_name; 1797 + u32 event_category; 1798 + int event_type; 1799 + u8 count; 1800 + u8 i; 1801 + 1802 + for (i = 0; i < pevents_count; i++, pevents++) { 1803 + event_name = pevents->name; 1804 + event_description = pevents->description; 1805 + event_category = pevents->category; 1806 + 1807 + event_type = classify_event(event_name, event_category); 1808 + switch (event_type) { 1809 + case HP_WMI_TYPE_AIR_FLOW: 1810 + fan_info = match_fan_event(state, event_description); 1811 + if (!fan_info) 1812 + break; 1813 + 1814 + fan_info->has_alarm = true; 1815 + has_events = true; 1816 + break; 1817 + 1818 + case HP_WMI_TYPE_INTRUSION: 1819 + state->has_intrusion = true; 1820 + has_events = true; 1821 + break; 1822 + 1823 + case HP_WMI_TYPE_TEMPERATURE: 1824 + count = match_temp_events(state, event_description, 1825 + temp_info); 1826 + if (!count) 1827 + break; 1828 + 1829 + while (count) 1830 + temp_info[--count]->has_alarm = true; 1831 + has_events = true; 1832 + break; 1833 + 1834 + default: 1835 + break; 1836 + } 1837 + } 1838 + 1839 + return has_events; 1840 + } 1841 + 1842 + static int make_chip_info(struct hp_wmi_sensors *state, bool has_events) 1843 + { 1844 + const struct hwmon_channel_info **ptr_channel_info; 1845 + struct hp_wmi_info ***info_map = state->info_map; 1846 + u8 *channel_count = state->channel_count; 1847 + struct hwmon_channel_info *channel_info; 1848 + struct device *dev = &state->wdev->dev; 1849 + enum hwmon_sensor_types type; 1850 + u8 type_count = 0; 1851 + u32 *config; 1852 + u32 attr; 1853 + u8 count; 1854 + u8 i; 1855 + 1856 + if (channel_count[hwmon_temp]) 1857 + channel_count[hwmon_chip] = 1; 1858 + 1859 + if (has_events && state->has_intrusion) 1860 + channel_count[hwmon_intrusion] = 1; 1861 + 1862 + for (type = hwmon_chip; type < hwmon_max; type++) 1863 + if (channel_count[type]) 1864 + type_count++; 1865 + 1866 + channel_info = devm_kcalloc(dev, type_count, 1867 + sizeof(*channel_info), GFP_KERNEL); 1868 + if (!channel_info) 1869 + return -ENOMEM; 1870 + 1871 + ptr_channel_info = devm_kcalloc(dev, type_count + 1, 1872 + sizeof(*ptr_channel_info), GFP_KERNEL); 1873 + if (!ptr_channel_info) 1874 + return -ENOMEM; 1875 + 1876 + hp_wmi_chip_info.info = ptr_channel_info; 1877 + 1878 + for (type = hwmon_chip; type < hwmon_max; type++) { 1879 + count = channel_count[type]; 1880 + if (!count) 1881 + continue; 1882 + 1883 + config = devm_kcalloc(dev, count + 1, 1884 + sizeof(*config), GFP_KERNEL); 1885 + if (!config) 1886 + return -ENOMEM; 1887 + 1888 + attr = hp_wmi_hwmon_attributes[type]; 1889 + channel_info->type = type; 1890 + channel_info->config = config; 1891 + memset32(config, attr, count); 1892 + 1893 + *ptr_channel_info++ = channel_info++; 1894 + 1895 + if (!has_events || (type != hwmon_temp && type != hwmon_fan)) 1896 + continue; 1897 + 1898 + attr = type == hwmon_temp ? HWMON_T_ALARM : HWMON_F_ALARM; 1899 + 1900 + for (i = 0; i < count; i++) 1901 + if (info_map[type][i]->has_alarm) 1902 + config[i] |= attr; 1903 + } 1904 + 1905 + return 0; 1906 + } 1907 + 1908 + static bool add_event_handler(struct hp_wmi_sensors *state) 1909 + { 1910 + struct device *dev = &state->wdev->dev; 1911 + int err; 1912 + 1913 + err = wmi_install_notify_handler(HP_WMI_EVENT_GUID, 1914 + hp_wmi_notify, state); 1915 + if (err) { 1916 + dev_info(dev, "Failed to subscribe to WMI event\n"); 1917 + return false; 1918 + } 1919 + 1920 + err = devm_add_action_or_reset(dev, hp_wmi_devm_notify_remove, NULL); 1921 + if (err) 1922 + return false; 1923 + 1924 + return true; 1925 + } 1926 + 1927 + static int hp_wmi_sensors_init(struct hp_wmi_sensors *state) 1928 + { 1929 + struct hp_wmi_info *connected[HP_WMI_MAX_INSTANCES]; 1930 + struct hp_wmi_platform_events *pevents; 1931 + struct device *dev = &state->wdev->dev; 1932 + struct hp_wmi_info *info; 1933 + struct device *hwdev; 1934 + bool has_events; 1935 + bool is_new; 1936 + u8 icount; 1937 + u8 pcount; 1938 + u8 count; 1939 + int err; 1940 + 1941 + err = init_platform_events(dev, &pevents, &pcount); 1942 + if (err) 1943 + return err; 1944 + 1945 + err = init_numeric_sensors(state, connected, &info, 1946 + &icount, &count, &is_new); 1947 + if (err) 1948 + return err; 1949 + 1950 + if (IS_ENABLED(CONFIG_DEBUG_FS)) 1951 + hp_wmi_debugfs_init(dev, info, pevents, icount, pcount, is_new); 1952 + 1953 + if (!count) 1954 + return 0; /* No connected sensors; debugfs only. */ 1955 + 1956 + has_events = find_event_attributes(state, pevents, pcount); 1957 + 1958 + /* Survive failure to install WMI event handler. */ 1959 + if (has_events && !add_event_handler(state)) 1960 + has_events = false; 1961 + 1962 + err = make_chip_info(state, has_events); 1963 + if (err) 1964 + return err; 1965 + 1966 + hwdev = devm_hwmon_device_register_with_info(dev, "hp_wmi_sensors", 1967 + state, &hp_wmi_chip_info, 1968 + NULL); 1969 + return PTR_ERR_OR_ZERO(hwdev); 1970 + } 1971 + 1972 + static int hp_wmi_sensors_probe(struct wmi_device *wdev, const void *context) 1973 + { 1974 + struct device *dev = &wdev->dev; 1975 + struct hp_wmi_sensors *state; 1976 + 1977 + state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); 1978 + if (!state) 1979 + return -ENOMEM; 1980 + 1981 + state->wdev = wdev; 1982 + 1983 + mutex_init(&state->lock); 1984 + 1985 + dev_set_drvdata(dev, state); 1986 + 1987 + return hp_wmi_sensors_init(state); 1988 + } 1989 + 1990 + static const struct wmi_device_id hp_wmi_sensors_id_table[] = { 1991 + { HP_WMI_NUMERIC_SENSOR_GUID, NULL }, 1992 + {}, 1993 + }; 1994 + 1995 + static struct wmi_driver hp_wmi_sensors_driver = { 1996 + .driver = { .name = "hp-wmi-sensors" }, 1997 + .id_table = hp_wmi_sensors_id_table, 1998 + .probe = hp_wmi_sensors_probe, 1999 + }; 2000 + module_wmi_driver(hp_wmi_sensors_driver); 2001 + 2002 + MODULE_AUTHOR("James Seo <james@equiv.tech>"); 2003 + MODULE_DESCRIPTION("HP WMI Sensors driver"); 2004 + MODULE_LICENSE("GPL");
+8 -3
drivers/hwmon/hwmon.c
··· 456 456 [hwmon_chip_in_samples] = "in_samples", 457 457 [hwmon_chip_power_samples] = "power_samples", 458 458 [hwmon_chip_temp_samples] = "temp_samples", 459 + [hwmon_chip_beep_enable] = "beep_enable", 459 460 }; 460 461 461 462 static const char * const hwmon_temp_attr_templates[] = { ··· 487 486 [hwmon_temp_reset_history] = "temp%d_reset_history", 488 487 [hwmon_temp_rated_min] = "temp%d_rated_min", 489 488 [hwmon_temp_rated_max] = "temp%d_rated_max", 489 + [hwmon_temp_beep] = "temp%d_beep", 490 490 }; 491 491 492 492 static const char * const hwmon_in_attr_templates[] = { ··· 509 507 [hwmon_in_crit_alarm] = "in%d_crit_alarm", 510 508 [hwmon_in_rated_min] = "in%d_rated_min", 511 509 [hwmon_in_rated_max] = "in%d_rated_max", 510 + [hwmon_in_beep] = "in%d_beep", 512 511 }; 513 512 514 513 static const char * const hwmon_curr_attr_templates[] = { ··· 531 528 [hwmon_curr_crit_alarm] = "curr%d_crit_alarm", 532 529 [hwmon_curr_rated_min] = "curr%d_rated_min", 533 530 [hwmon_curr_rated_max] = "curr%d_rated_max", 531 + [hwmon_curr_beep] = "curr%d_beep", 534 532 }; 535 533 536 534 static const char * const hwmon_power_attr_templates[] = { ··· 601 597 [hwmon_fan_min_alarm] = "fan%d_min_alarm", 602 598 [hwmon_fan_max_alarm] = "fan%d_max_alarm", 603 599 [hwmon_fan_fault] = "fan%d_fault", 600 + [hwmon_fan_beep] = "fan%d_beep", 604 601 }; 605 602 606 603 static const char * const hwmon_pwm_attr_templates[] = { ··· 1034 1029 * @name: hwmon name attribute 1035 1030 * @drvdata: driver data to attach to created device 1036 1031 * @chip: pointer to hwmon chip information 1037 - * @groups: pointer to list of driver specific attribute groups 1032 + * @extra_groups: pointer to list of driver specific attribute groups 1038 1033 * 1039 1034 * Returns the pointer to the new device. The new device is automatically 1040 1035 * unregistered with the parent device. ··· 1043 1038 devm_hwmon_device_register_with_info(struct device *dev, const char *name, 1044 1039 void *drvdata, 1045 1040 const struct hwmon_chip_info *chip, 1046 - const struct attribute_group **groups) 1041 + const struct attribute_group **extra_groups) 1047 1042 { 1048 1043 struct device **ptr, *hwdev; 1049 1044 ··· 1055 1050 return ERR_PTR(-ENOMEM); 1056 1051 1057 1052 hwdev = hwmon_device_register_with_info(dev, name, drvdata, chip, 1058 - groups); 1053 + extra_groups); 1059 1054 if (IS_ERR(hwdev)) 1060 1055 goto error; 1061 1056
+1 -1
drivers/hwmon/ina209.c
··· 594 594 .name = "ina209", 595 595 .of_match_table = of_match_ptr(ina209_of_match), 596 596 }, 597 - .probe_new = ina209_probe, 597 + .probe = ina209_probe, 598 598 .remove = ina209_remove, 599 599 .id_table = ina209_id, 600 600 };
+1 -1
drivers/hwmon/ina238.c
··· 633 633 .name = "ina238", 634 634 .of_match_table = of_match_ptr(ina238_of_match), 635 635 }, 636 - .probe_new = ina238_probe, 636 + .probe = ina238_probe, 637 637 .id_table = ina238_id, 638 638 }; 639 639
+1 -1
drivers/hwmon/ina2xx.c
··· 721 721 .name = "ina2xx", 722 722 .of_match_table = of_match_ptr(ina2xx_of_match), 723 723 }, 724 - .probe_new = ina2xx_probe, 724 + .probe = ina2xx_probe, 725 725 .id_table = ina2xx_id, 726 726 }; 727 727
+1 -1
drivers/hwmon/ina3221.c
··· 1010 1010 MODULE_DEVICE_TABLE(i2c, ina3221_ids); 1011 1011 1012 1012 static struct i2c_driver ina3221_i2c_driver = { 1013 - .probe_new = ina3221_probe, 1013 + .probe = ina3221_probe, 1014 1014 .remove = ina3221_remove, 1015 1015 .driver = { 1016 1016 .name = INA3221_DRIVER_NAME,
+93 -41
drivers/hwmon/it87.c
··· 317 317 * chips to avoid the problem. 318 318 */ 319 319 #define FEAT_CONF_NOEXIT BIT(19) /* Chip should not exit conf mode */ 320 + #define FEAT_FOUR_FANS BIT(20) /* Supports four fans */ 321 + #define FEAT_FOUR_PWM BIT(21) /* Supports four fan controls */ 322 + #define FEAT_FOUR_TEMP BIT(22) 323 + #define FEAT_FANCTL_ONOFF BIT(23) /* chip has FAN_CTL ON/OFF */ 320 324 321 325 static const struct it87_devices it87_devices[] = { 322 326 [it87] = { 323 327 .name = "it87", 324 328 .model = "IT87F", 325 - .features = FEAT_OLD_AUTOPWM, /* may need to overwrite */ 329 + .features = FEAT_OLD_AUTOPWM | FEAT_FANCTL_ONOFF, 330 + /* may need to overwrite */ 326 331 }, 327 332 [it8712] = { 328 333 .name = "it8712", 329 334 .model = "IT8712F", 330 - .features = FEAT_OLD_AUTOPWM | FEAT_VID, 331 - /* may need to overwrite */ 335 + .features = FEAT_OLD_AUTOPWM | FEAT_VID | FEAT_FANCTL_ONOFF, 336 + /* may need to overwrite */ 332 337 }, 333 338 [it8716] = { 334 339 .name = "it8716", 335 340 .model = "IT8716F", 336 341 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID 337 - | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS | FEAT_PWM_FREQ2, 342 + | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS | FEAT_PWM_FREQ2 343 + | FEAT_FANCTL_ONOFF, 338 344 }, 339 345 [it8718] = { 340 346 .name = "it8718", 341 347 .model = "IT8718F", 342 348 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID 343 349 | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS 344 - | FEAT_PWM_FREQ2, 350 + | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF, 345 351 .old_peci_mask = 0x4, 346 352 }, 347 353 [it8720] = { ··· 355 349 .model = "IT8720F", 356 350 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET | FEAT_VID 357 351 | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS 358 - | FEAT_PWM_FREQ2, 352 + | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF, 359 353 .old_peci_mask = 0x4, 360 354 }, 361 355 [it8721] = { ··· 364 358 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 365 359 | FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI 366 360 | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS | FEAT_IN7_INTERNAL 367 - | FEAT_PWM_FREQ2, 361 + | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF, 368 362 .peci_mask = 0x05, 369 363 .old_peci_mask = 0x02, /* Actually reports PCH */ 370 364 }, ··· 373 367 .model = "IT8728F", 374 368 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 375 369 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_FIVE_FANS 376 - | FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2, 370 + | FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2 371 + | FEAT_FANCTL_ONOFF, 377 372 .peci_mask = 0x07, 378 373 }, 379 374 [it8732] = { ··· 382 375 .model = "IT8732F", 383 376 .features = FEAT_NEWER_AUTOPWM | FEAT_16BIT_FANS 384 377 | FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI 385 - | FEAT_10_9MV_ADC | FEAT_IN7_INTERNAL, 378 + | FEAT_10_9MV_ADC | FEAT_IN7_INTERNAL | FEAT_FOUR_FANS 379 + | FEAT_FOUR_PWM | FEAT_FANCTL_ONOFF, 386 380 .peci_mask = 0x07, 387 381 .old_peci_mask = 0x02, /* Actually reports PCH */ 388 382 }, ··· 392 384 .model = "IT8771E", 393 385 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 394 386 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL 395 - | FEAT_PWM_FREQ2, 387 + | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF, 396 388 /* PECI: guesswork */ 397 389 /* 12mV ADC (OHM) */ 398 390 /* 16 bit fans (OHM) */ ··· 404 396 .model = "IT8772E", 405 397 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 406 398 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL 407 - | FEAT_PWM_FREQ2, 399 + | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF, 408 400 /* PECI (coreboot) */ 409 401 /* 12mV ADC (HWSensors4, OHM) */ 410 402 /* 16 bit fans (HWSensors4, OHM) */ ··· 415 407 .name = "it8781", 416 408 .model = "IT8781F", 417 409 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET 418 - | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2, 410 + | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2 411 + | FEAT_FANCTL_ONOFF, 419 412 .old_peci_mask = 0x4, 420 413 }, 421 414 [it8782] = { 422 415 .name = "it8782", 423 416 .model = "IT8782F", 424 417 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET 425 - | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2, 418 + | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2 419 + | FEAT_FANCTL_ONOFF, 426 420 .old_peci_mask = 0x4, 427 421 }, 428 422 [it8783] = { 429 423 .name = "it8783", 430 424 .model = "IT8783E/F", 431 425 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET 432 - | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2, 426 + | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_PWM_FREQ2 427 + | FEAT_FANCTL_ONOFF, 433 428 .old_peci_mask = 0x4, 434 429 }, 435 430 [it8786] = { ··· 440 429 .model = "IT8786E", 441 430 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 442 431 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL 443 - | FEAT_PWM_FREQ2, 432 + | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF, 444 433 .peci_mask = 0x07, 445 434 }, 446 435 [it8790] = { ··· 448 437 .model = "IT8790E", 449 438 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 450 439 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_IN7_INTERNAL 451 - | FEAT_PWM_FREQ2 | FEAT_CONF_NOEXIT, 440 + | FEAT_PWM_FREQ2 | FEAT_FANCTL_ONOFF | FEAT_CONF_NOEXIT, 452 441 .peci_mask = 0x07, 453 442 }, 454 443 [it8792] = { ··· 456 445 .model = "IT8792E/IT8795E", 457 446 .features = FEAT_NEWER_AUTOPWM | FEAT_16BIT_FANS 458 447 | FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI 459 - | FEAT_10_9MV_ADC | FEAT_IN7_INTERNAL | FEAT_CONF_NOEXIT, 448 + | FEAT_10_9MV_ADC | FEAT_IN7_INTERNAL | FEAT_FANCTL_ONOFF 449 + | FEAT_CONF_NOEXIT, 460 450 .peci_mask = 0x07, 461 451 .old_peci_mask = 0x02, /* Actually reports PCH */ 462 452 }, ··· 475 463 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 476 464 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_SIX_FANS 477 465 | FEAT_IN7_INTERNAL | FEAT_SIX_PWM | FEAT_PWM_FREQ2 478 - | FEAT_SIX_TEMP | FEAT_VIN3_5V, 466 + | FEAT_SIX_TEMP | FEAT_VIN3_5V | FEAT_FANCTL_ONOFF, 479 467 .peci_mask = 0x07, 480 468 }, 481 469 [it8622] = { ··· 484 472 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 485 473 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_FIVE_FANS 486 474 | FEAT_FIVE_PWM | FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2 487 - | FEAT_AVCC3 | FEAT_VIN3_5V, 475 + | FEAT_AVCC3 | FEAT_VIN3_5V | FEAT_FOUR_TEMP, 488 476 .peci_mask = 0x07, 489 477 .smbus_bitmap = BIT(1) | BIT(2), 490 478 }, ··· 494 482 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 495 483 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_SIX_FANS 496 484 | FEAT_IN7_INTERNAL | FEAT_SIX_PWM | FEAT_PWM_FREQ2 497 - | FEAT_SIX_TEMP | FEAT_VIN3_5V, 485 + | FEAT_SIX_TEMP | FEAT_VIN3_5V | FEAT_FANCTL_ONOFF, 498 486 .peci_mask = 0x07, 499 487 }, 500 488 [it87952] = { ··· 502 490 .model = "IT87952E", 503 491 .features = FEAT_NEWER_AUTOPWM | FEAT_16BIT_FANS 504 492 | FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI 505 - | FEAT_10_9MV_ADC | FEAT_IN7_INTERNAL | FEAT_CONF_NOEXIT, 493 + | FEAT_10_9MV_ADC | FEAT_IN7_INTERNAL | FEAT_FANCTL_ONOFF 494 + | FEAT_CONF_NOEXIT, 506 495 .peci_mask = 0x07, 507 496 .old_peci_mask = 0x02, /* Actually reports PCH */ 508 497 }, ··· 521 508 (((data)->features & FEAT_TEMP_OLD_PECI) && \ 522 509 ((data)->old_peci_mask & BIT(nr))) 523 510 #define has_fan16_config(data) ((data)->features & FEAT_FAN16_CONFIG) 511 + #define has_four_fans(data) ((data)->features & (FEAT_FOUR_FANS | \ 512 + FEAT_FIVE_FANS | \ 513 + FEAT_SIX_FANS)) 524 514 #define has_five_fans(data) ((data)->features & (FEAT_FIVE_FANS | \ 525 515 FEAT_SIX_FANS)) 516 + #define has_six_fans(data) ((data)->features & FEAT_SIX_FANS) 526 517 #define has_vid(data) ((data)->features & FEAT_VID) 527 518 #define has_in7_internal(data) ((data)->features & FEAT_IN7_INTERNAL) 528 - #define has_six_fans(data) ((data)->features & FEAT_SIX_FANS) 529 519 #define has_avcc3(data) ((data)->features & FEAT_AVCC3) 530 - #define has_five_pwm(data) ((data)->features & (FEAT_FIVE_PWM \ 531 - | FEAT_SIX_PWM)) 520 + #define has_four_pwm(data) ((data)->features & (FEAT_FOUR_PWM | \ 521 + FEAT_FIVE_PWM | \ 522 + FEAT_SIX_PWM)) 523 + #define has_five_pwm(data) ((data)->features & (FEAT_FIVE_PWM | \ 524 + FEAT_SIX_PWM)) 532 525 #define has_six_pwm(data) ((data)->features & FEAT_SIX_PWM) 533 526 #define has_pwm_freq2(data) ((data)->features & FEAT_PWM_FREQ2) 527 + #define has_four_temp(data) ((data)->features & FEAT_FOUR_TEMP) 534 528 #define has_six_temp(data) ((data)->features & FEAT_SIX_TEMP) 535 529 #define has_vin3_5v(data) ((data)->features & FEAT_VIN3_5V) 536 530 #define has_conf_noexit(data) ((data)->features & FEAT_CONF_NOEXIT) 537 531 #define has_scaling(data) ((data)->features & (FEAT_12MV_ADC | \ 538 532 FEAT_10_9MV_ADC)) 533 + #define has_fanctl_onoff(data) ((data)->features & FEAT_FANCTL_ONOFF) 539 534 540 535 struct it87_sio_data { 541 536 int sioaddr; ··· 1250 1229 1251 1230 static int pwm_mode(const struct it87_data *data, int nr) 1252 1231 { 1253 - if (data->type != it8603 && nr < 3 && !(data->fan_main_ctrl & BIT(nr))) 1254 - return 0; /* Full speed */ 1232 + if (has_fanctl_onoff(data) && nr < 3 && 1233 + !(data->fan_main_ctrl & BIT(nr))) 1234 + return 0; /* Full speed */ 1255 1235 if (data->pwm_ctrl[nr] & 0x80) 1256 - return 2; /* Automatic mode */ 1257 - if ((data->type == it8603 || nr >= 3) && 1236 + return 2; /* Automatic mode */ 1237 + if ((!has_fanctl_onoff(data) || nr >= 3) && 1258 1238 data->pwm_duty[nr] == pwm_to_reg(data, 0xff)) 1259 1239 return 0; /* Full speed */ 1260 1240 ··· 1492 1470 return err; 1493 1471 1494 1472 if (val == 0) { 1495 - if (nr < 3 && data->type != it8603) { 1473 + if (nr < 3 && has_fanctl_onoff(data)) { 1496 1474 int tmp; 1497 1475 /* make sure the fan is on when in on/off mode */ 1498 1476 tmp = it87_read_value(data, IT87_REG_FAN_CTL); ··· 1532 1510 data->pwm_ctrl[nr] = ctrl; 1533 1511 it87_write_value(data, IT87_REG_PWM[nr], ctrl); 1534 1512 1535 - if (data->type != it8603 && nr < 3) { 1513 + if (has_fanctl_onoff(data) && nr < 3) { 1536 1514 /* set SmartGuardian mode */ 1537 1515 data->fan_main_ctrl |= BIT(nr); 1538 1516 it87_write_value(data, IT87_REG_FAN_MAIN_CTRL, ··· 2752 2730 else 2753 2731 sio_data->skip_in |= BIT(9); 2754 2732 2755 - if (!has_five_pwm(config)) 2733 + if (!has_four_pwm(config)) 2756 2734 sio_data->skip_pwm |= BIT(3) | BIT(4) | BIT(5); 2735 + else if (!has_five_pwm(config)) 2736 + sio_data->skip_pwm |= BIT(4) | BIT(5); 2757 2737 else if (!has_six_pwm(config)) 2758 2738 sio_data->skip_pwm |= BIT(5); 2759 2739 ··· 2945 2921 reg = superio_inb(sioaddr, IT87_SIO_PINX2_REG); 2946 2922 if (!(reg & BIT(0))) 2947 2923 sio_data->skip_in |= BIT(9); 2924 + 2925 + sio_data->beep_pin = superio_inb(sioaddr, 2926 + IT87_SIO_BEEP_PIN_REG) & 0x3f; 2927 + } else if (sio_data->type == it8732) { 2928 + int reg; 2929 + 2930 + superio_select(sioaddr, GPIO); 2931 + 2932 + /* Check for pwm2, fan2 */ 2933 + reg = superio_inb(sioaddr, IT87_SIO_GPIO5_REG); 2934 + if (reg & BIT(1)) 2935 + sio_data->skip_pwm |= BIT(1); 2936 + if (reg & BIT(2)) 2937 + sio_data->skip_fan |= BIT(1); 2938 + 2939 + /* Check for pwm3, fan3, fan4 */ 2940 + reg = superio_inb(sioaddr, IT87_SIO_GPIO3_REG); 2941 + if (reg & BIT(6)) 2942 + sio_data->skip_pwm |= BIT(2); 2943 + if (reg & BIT(7)) 2944 + sio_data->skip_fan |= BIT(2); 2945 + if (reg & BIT(5)) 2946 + sio_data->skip_fan |= BIT(3); 2947 + 2948 + /* Check if AVCC is on VIN3 */ 2949 + reg = superio_inb(sioaddr, IT87_SIO_PINX2_REG); 2950 + if (reg & BIT(0)) 2951 + sio_data->internal |= BIT(0); 2948 2952 2949 2953 sio_data->beep_pin = superio_inb(sioaddr, 2950 2954 IT87_SIO_BEEP_PIN_REG) & 0x3f; ··· 3221 3169 it87_check_tachometers_16bit_mode(pdev); 3222 3170 3223 3171 /* Check for additional fans */ 3224 - if (has_five_fans(data)) { 3225 - tmp = it87_read_value(data, IT87_REG_FAN_16BIT); 3172 + tmp = it87_read_value(data, IT87_REG_FAN_16BIT); 3226 3173 3227 - if (tmp & BIT(4)) 3228 - data->has_fan |= BIT(3); /* fan4 enabled */ 3229 - if (tmp & BIT(5)) 3230 - data->has_fan |= BIT(4); /* fan5 enabled */ 3231 - if (has_six_fans(data) && (tmp & BIT(2))) 3232 - data->has_fan |= BIT(5); /* fan6 enabled */ 3233 - } 3174 + if (has_four_fans(data) && (tmp & BIT(4))) 3175 + data->has_fan |= BIT(3); /* fan4 enabled */ 3176 + if (has_five_fans(data) && (tmp & BIT(5))) 3177 + data->has_fan |= BIT(4); /* fan5 enabled */ 3178 + if (has_six_fans(data) && (tmp & BIT(2))) 3179 + data->has_fan |= BIT(5); /* fan6 enabled */ 3234 3180 3235 3181 /* Fan input pins may be used for alternative functions */ 3236 3182 data->has_fan &= ~sio_data->skip_fan; ··· 3406 3356 data->need_in7_reroute = sio_data->need_in7_reroute; 3407 3357 data->has_in = 0x3ff & ~sio_data->skip_in; 3408 3358 3409 - if (has_six_temp(data)) { 3359 + if (has_four_temp(data)) { 3360 + data->has_temp |= BIT(3); 3361 + } else if (has_six_temp(data)) { 3410 3362 u8 reg = it87_read_value(data, IT87_REG_TEMP456_ENABLE); 3411 3363 3412 3364 /* Check for additional temperature sensors */
+1 -1
drivers/hwmon/jc42.c
··· 629 629 .pm = JC42_DEV_PM_OPS, 630 630 .of_match_table = of_match_ptr(jc42_of_ids), 631 631 }, 632 - .probe_new = jc42_probe, 632 + .probe = jc42_probe, 633 633 .remove = jc42_remove, 634 634 .id_table = jc42_id, 635 635 .detect = jc42_detect,
+1 -1
drivers/hwmon/lineage-pem.c
··· 511 511 .driver = { 512 512 .name = "lineage_pem", 513 513 }, 514 - .probe_new = pem_probe, 514 + .probe = pem_probe, 515 515 .id_table = pem_id, 516 516 }; 517 517
+1 -1
drivers/hwmon/lm63.c
··· 1164 1164 .name = "lm63", 1165 1165 .of_match_table = of_match_ptr(lm63_of_match), 1166 1166 }, 1167 - .probe_new = lm63_probe, 1167 + .probe = lm63_probe, 1168 1168 .id_table = lm63_id, 1169 1169 .detect = lm63_detect, 1170 1170 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm73.c
··· 277 277 .name = "lm73", 278 278 .of_match_table = lm73_of_match, 279 279 }, 280 - .probe_new = lm73_probe, 280 + .probe = lm73_probe, 281 281 .id_table = lm73_ids, 282 282 .detect = lm73_detect, 283 283 .address_list = normal_i2c,
+2 -2
drivers/hwmon/lm75.c
··· 548 548 .writeable_reg = lm75_is_writeable_reg, 549 549 .volatile_reg = lm75_is_volatile_reg, 550 550 .val_format_endian = REGMAP_ENDIAN_BIG, 551 - .cache_type = REGCACHE_RBTREE, 551 + .cache_type = REGCACHE_MAPLE, 552 552 .use_single_read = true, 553 553 .use_single_write = true, 554 554 }; ··· 945 945 .of_match_table = of_match_ptr(lm75_of_match), 946 946 .pm = LM75_DEV_PM_OPS, 947 947 }, 948 - .probe_new = lm75_probe, 948 + .probe = lm75_probe, 949 949 .id_table = lm75_ids, 950 950 .detect = lm75_detect, 951 951 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm77.c
··· 348 348 .driver = { 349 349 .name = "lm77", 350 350 }, 351 - .probe_new = lm77_probe, 351 + .probe = lm77_probe, 352 352 .id_table = lm77_id, 353 353 .detect = lm77_detect, 354 354 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm78.c
··· 662 662 .driver = { 663 663 .name = "lm78", 664 664 }, 665 - .probe_new = lm78_i2c_probe, 665 + .probe = lm78_i2c_probe, 666 666 .id_table = lm78_i2c_id, 667 667 .detect = lm78_i2c_detect, 668 668 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm80.c
··· 633 633 .driver = { 634 634 .name = "lm80", 635 635 }, 636 - .probe_new = lm80_probe, 636 + .probe = lm80_probe, 637 637 .id_table = lm80_id, 638 638 .detect = lm80_detect, 639 639 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm83.c
··· 454 454 .driver = { 455 455 .name = "lm83", 456 456 }, 457 - .probe_new = lm83_probe, 457 + .probe = lm83_probe, 458 458 .id_table = lm83_id, 459 459 .detect = lm83_detect, 460 460 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm85.c
··· 1698 1698 .name = "lm85", 1699 1699 .of_match_table = of_match_ptr(lm85_of_match), 1700 1700 }, 1701 - .probe_new = lm85_probe, 1701 + .probe = lm85_probe, 1702 1702 .id_table = lm85_id, 1703 1703 .detect = lm85_detect, 1704 1704 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm87.c
··· 994 994 .name = "lm87", 995 995 .of_match_table = lm87_of_match, 996 996 }, 997 - .probe_new = lm87_probe, 997 + .probe = lm87_probe, 998 998 .id_table = lm87_id, 999 999 .detect = lm87_detect, 1000 1000 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm90.c
··· 2972 2972 .of_match_table = of_match_ptr(lm90_of_match), 2973 2973 .pm = pm_sleep_ptr(&lm90_pm_ops), 2974 2974 }, 2975 - .probe_new = lm90_probe, 2975 + .probe = lm90_probe, 2976 2976 .alert = lm90_alert, 2977 2977 .id_table = lm90_id, 2978 2978 .detect = lm90_detect,
+1 -1
drivers/hwmon/lm92.c
··· 330 330 .driver = { 331 331 .name = "lm92", 332 332 }, 333 - .probe_new = lm92_probe, 333 + .probe = lm92_probe, 334 334 .id_table = lm92_id, 335 335 .detect = lm92_detect, 336 336 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm93.c
··· 2635 2635 .driver = { 2636 2636 .name = "lm93", 2637 2637 }, 2638 - .probe_new = lm93_probe, 2638 + .probe = lm93_probe, 2639 2639 .id_table = lm93_id, 2640 2640 .detect = lm93_detect, 2641 2641 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm95234.c
··· 720 720 .driver = { 721 721 .name = DRVNAME, 722 722 }, 723 - .probe_new = lm95234_probe, 723 + .probe = lm95234_probe, 724 724 .id_table = lm95234_id, 725 725 .detect = lm95234_detect, 726 726 .address_list = normal_i2c,
+1 -1
drivers/hwmon/lm95241.c
··· 468 468 .driver = { 469 469 .name = DEVNAME, 470 470 }, 471 - .probe_new = lm95241_probe, 471 + .probe = lm95241_probe, 472 472 .id_table = lm95241_id, 473 473 .detect = lm95241_detect, 474 474 .address_list = normal_i2c,
+2 -2
drivers/hwmon/lm95245.c
··· 518 518 .val_bits = 8, 519 519 .writeable_reg = lm95245_is_writeable_reg, 520 520 .volatile_reg = lm95245_is_volatile_reg, 521 - .cache_type = REGCACHE_RBTREE, 521 + .cache_type = REGCACHE_MAPLE, 522 522 .use_single_read = true, 523 523 .use_single_write = true, 524 524 }; ··· 597 597 .name = "lm95245", 598 598 .of_match_table = of_match_ptr(lm95245_of_match), 599 599 }, 600 - .probe_new = lm95245_probe, 600 + .probe = lm95245_probe, 601 601 .id_table = lm95245_id, 602 602 .detect = lm95245_detect, 603 603 .address_list = normal_i2c,
+1 -1
drivers/hwmon/ltc2945.c
··· 519 519 .name = "ltc2945", 520 520 .of_match_table = of_match_ptr(ltc2945_of_match), 521 521 }, 522 - .probe_new = ltc2945_probe, 522 + .probe = ltc2945_probe, 523 523 .id_table = ltc2945_id, 524 524 }; 525 525
+1 -1
drivers/hwmon/ltc2947-i2c.c
··· 38 38 .of_match_table = ltc2947_of_match, 39 39 .pm = pm_sleep_ptr(&ltc2947_pm_ops), 40 40 }, 41 - .probe_new = ltc2947_probe, 41 + .probe = ltc2947_probe, 42 42 .id_table = ltc2947_id, 43 43 }; 44 44 module_i2c_driver(ltc2947_driver);
+1 -1
drivers/hwmon/ltc2990.c
··· 268 268 .driver = { 269 269 .name = "ltc2990", 270 270 }, 271 - .probe_new = ltc2990_i2c_probe, 271 + .probe = ltc2990_i2c_probe, 272 272 .id_table = ltc2990_i2c_id, 273 273 }; 274 274
+1 -1
drivers/hwmon/ltc2992.c
··· 928 928 .name = "ltc2992", 929 929 .of_match_table = ltc2992_of_match, 930 930 }, 931 - .probe_new = ltc2992_i2c_probe, 931 + .probe = ltc2992_i2c_probe, 932 932 .id_table = ltc2992_i2c_id, 933 933 }; 934 934
+1 -1
drivers/hwmon/ltc4151.c
··· 205 205 .name = "ltc4151", 206 206 .of_match_table = of_match_ptr(ltc4151_match), 207 207 }, 208 - .probe_new = ltc4151_probe, 208 + .probe = ltc4151_probe, 209 209 .id_table = ltc4151_id, 210 210 }; 211 211
+1 -1
drivers/hwmon/ltc4215.c
··· 255 255 .driver = { 256 256 .name = "ltc4215", 257 257 }, 258 - .probe_new = ltc4215_probe, 258 + .probe = ltc4215_probe, 259 259 .id_table = ltc4215_id, 260 260 }; 261 261
+1 -1
drivers/hwmon/ltc4222.c
··· 210 210 .driver = { 211 211 .name = "ltc4222", 212 212 }, 213 - .probe_new = ltc4222_probe, 213 + .probe = ltc4222_probe, 214 214 .id_table = ltc4222_id, 215 215 }; 216 216
+1 -1
drivers/hwmon/ltc4245.c
··· 479 479 .driver = { 480 480 .name = "ltc4245", 481 481 }, 482 - .probe_new = ltc4245_probe, 482 + .probe = ltc4245_probe, 483 483 .id_table = ltc4245_id, 484 484 }; 485 485
+1 -1
drivers/hwmon/ltc4260.c
··· 173 173 .driver = { 174 174 .name = "ltc4260", 175 175 }, 176 - .probe_new = ltc4260_probe, 176 + .probe = ltc4260_probe, 177 177 .id_table = ltc4260_id, 178 178 }; 179 179
+1 -1
drivers/hwmon/ltc4261.c
··· 233 233 .driver = { 234 234 .name = "ltc4261", 235 235 }, 236 - .probe_new = ltc4261_probe, 236 + .probe = ltc4261_probe, 237 237 .id_table = ltc4261_id, 238 238 }; 239 239
+1 -1
drivers/hwmon/max127.c
··· 339 339 .driver = { 340 340 .name = "max127", 341 341 }, 342 - .probe_new = max127_probe, 342 + .probe = max127_probe, 343 343 .id_table = max127_id, 344 344 }; 345 345
+1 -1
drivers/hwmon/max16065.c
··· 600 600 .driver = { 601 601 .name = "max16065", 602 602 }, 603 - .probe_new = max16065_probe, 603 + .probe = max16065_probe, 604 604 .id_table = max16065_id, 605 605 }; 606 606
+1 -1
drivers/hwmon/max1619.c
··· 305 305 .name = "max1619", 306 306 .of_match_table = of_match_ptr(max1619_of_match), 307 307 }, 308 - .probe_new = max1619_probe, 308 + .probe = max1619_probe, 309 309 .id_table = max1619_id, 310 310 .detect = max1619_detect, 311 311 .address_list = normal_i2c,
+1 -1
drivers/hwmon/max1668.c
··· 435 435 .driver = { 436 436 .name = "max1668", 437 437 }, 438 - .probe_new = max1668_probe, 438 + .probe = max1668_probe, 439 439 .id_table = max1668_id, 440 440 .detect = max1668_detect, 441 441 .address_list = max1668_addr_list,
+1 -1
drivers/hwmon/max31730.c
··· 427 427 .of_match_table = of_match_ptr(max31730_of_match), 428 428 .pm = pm_sleep_ptr(&max31730_pm_ops), 429 429 }, 430 - .probe_new = max31730_probe, 430 + .probe = max31730_probe, 431 431 .id_table = max31730_ids, 432 432 .detect = max31730_detect, 433 433 .address_list = normal_i2c,
+1 -1
drivers/hwmon/max31760.c
··· 584 584 .of_match_table = max31760_of_match, 585 585 .pm = pm_ptr(&max31760_pm_ops) 586 586 }, 587 - .probe_new = max31760_probe, 587 + .probe = max31760_probe, 588 588 .id_table = max31760_id 589 589 }; 590 590 module_i2c_driver(max31760_driver);
+1 -1
drivers/hwmon/max31790.c
··· 544 544 545 545 static struct i2c_driver max31790_driver = { 546 546 .class = I2C_CLASS_HWMON, 547 - .probe_new = max31790_probe, 547 + .probe = max31790_probe, 548 548 .driver = { 549 549 .name = "max31790", 550 550 },
+466
drivers/hwmon/max31827.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * max31827.c - Support for Maxim Low-Power Switch 4 + * 5 + * Copyright (c) 2023 Daniel Matyas <daniel.matyas@analog.com> 6 + */ 7 + 8 + #include <linux/bitfield.h> 9 + #include <linux/bitops.h> 10 + #include <linux/delay.h> 11 + #include <linux/hwmon.h> 12 + #include <linux/i2c.h> 13 + #include <linux/mutex.h> 14 + #include <linux/regmap.h> 15 + 16 + #define MAX31827_T_REG 0x0 17 + #define MAX31827_CONFIGURATION_REG 0x2 18 + #define MAX31827_TH_REG 0x4 19 + #define MAX31827_TL_REG 0x6 20 + #define MAX31827_TH_HYST_REG 0x8 21 + #define MAX31827_TL_HYST_REG 0xA 22 + 23 + #define MAX31827_CONFIGURATION_1SHOT_MASK BIT(0) 24 + #define MAX31827_CONFIGURATION_CNV_RATE_MASK GENMASK(3, 1) 25 + #define MAX31827_CONFIGURATION_U_TEMP_STAT_MASK BIT(14) 26 + #define MAX31827_CONFIGURATION_O_TEMP_STAT_MASK BIT(15) 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 37 + 38 + #define MAX31827_16_BIT_TO_M_DGR(x) (sign_extend32(x, 15) * 1000 / 16) 39 + #define MAX31827_M_DGR_TO_16_BIT(x) (((x) << 4) / 1000) 40 + #define MAX31827_DEVICE_ENABLE(x) ((x) ? 0xA : 0x0) 41 + 42 + struct max31827_state { 43 + /* 44 + * Prevent simultaneous access to the i2c client. 45 + */ 46 + struct mutex lock; 47 + struct regmap *regmap; 48 + bool enable; 49 + }; 50 + 51 + static const struct regmap_config max31827_regmap = { 52 + .reg_bits = 8, 53 + .val_bits = 16, 54 + .max_register = 0xA, 55 + }; 56 + 57 + static int write_alarm_val(struct max31827_state *st, unsigned int reg, 58 + long val) 59 + { 60 + unsigned int cfg; 61 + unsigned int tmp; 62 + int ret; 63 + 64 + val = MAX31827_M_DGR_TO_16_BIT(val); 65 + 66 + /* 67 + * Before the Temperature Threshold Alarm and Alarm Hysteresis Threshold 68 + * register values are changed over I2C, the part must be in shutdown 69 + * mode. 70 + * 71 + * Mutex is used to ensure, that some other process doesn't change the 72 + * configuration register. 73 + */ 74 + mutex_lock(&st->lock); 75 + 76 + if (!st->enable) { 77 + ret = regmap_write(st->regmap, reg, val); 78 + goto unlock; 79 + } 80 + 81 + ret = regmap_read(st->regmap, MAX31827_CONFIGURATION_REG, &cfg); 82 + if (ret) 83 + goto unlock; 84 + 85 + tmp = cfg & ~(MAX31827_CONFIGURATION_1SHOT_MASK | 86 + MAX31827_CONFIGURATION_CNV_RATE_MASK); 87 + ret = regmap_write(st->regmap, MAX31827_CONFIGURATION_REG, tmp); 88 + if (ret) 89 + goto unlock; 90 + 91 + ret = regmap_write(st->regmap, reg, val); 92 + if (ret) 93 + goto unlock; 94 + 95 + ret = regmap_write(st->regmap, MAX31827_CONFIGURATION_REG, cfg); 96 + 97 + unlock: 98 + mutex_unlock(&st->lock); 99 + return ret; 100 + } 101 + 102 + static umode_t max31827_is_visible(const void *state, 103 + enum hwmon_sensor_types type, u32 attr, 104 + int channel) 105 + { 106 + if (type == hwmon_temp) { 107 + switch (attr) { 108 + case hwmon_temp_enable: 109 + case hwmon_temp_max: 110 + case hwmon_temp_min: 111 + case hwmon_temp_max_hyst: 112 + case hwmon_temp_min_hyst: 113 + return 0644; 114 + case hwmon_temp_input: 115 + case hwmon_temp_min_alarm: 116 + case hwmon_temp_max_alarm: 117 + return 0444; 118 + default: 119 + return 0; 120 + } 121 + } else if (type == hwmon_chip) { 122 + if (attr == hwmon_chip_update_interval) 123 + return 0644; 124 + } 125 + 126 + return 0; 127 + } 128 + 129 + static int max31827_read(struct device *dev, enum hwmon_sensor_types type, 130 + u32 attr, int channel, long *val) 131 + { 132 + struct max31827_state *st = dev_get_drvdata(dev); 133 + unsigned int uval; 134 + int ret = 0; 135 + 136 + switch (type) { 137 + case hwmon_temp: 138 + switch (attr) { 139 + case hwmon_temp_enable: 140 + ret = regmap_read(st->regmap, 141 + MAX31827_CONFIGURATION_REG, &uval); 142 + if (ret) 143 + break; 144 + 145 + uval = FIELD_GET(MAX31827_CONFIGURATION_1SHOT_MASK | 146 + MAX31827_CONFIGURATION_CNV_RATE_MASK, 147 + uval); 148 + *val = !!uval; 149 + 150 + break; 151 + case hwmon_temp_input: 152 + mutex_lock(&st->lock); 153 + 154 + if (!st->enable) { 155 + /* 156 + * This operation requires mutex protection, 157 + * because the chip configuration should not 158 + * be changed during the conversion process. 159 + */ 160 + 161 + ret = regmap_update_bits(st->regmap, 162 + MAX31827_CONFIGURATION_REG, 163 + MAX31827_CONFIGURATION_1SHOT_MASK, 164 + 1); 165 + if (ret) { 166 + mutex_unlock(&st->lock); 167 + return ret; 168 + } 169 + 170 + msleep(MAX31827_12_BIT_CNV_TIME); 171 + } 172 + ret = regmap_read(st->regmap, MAX31827_T_REG, &uval); 173 + 174 + mutex_unlock(&st->lock); 175 + 176 + if (ret) 177 + break; 178 + 179 + *val = MAX31827_16_BIT_TO_M_DGR(uval); 180 + 181 + break; 182 + case hwmon_temp_max: 183 + ret = regmap_read(st->regmap, MAX31827_TH_REG, &uval); 184 + if (ret) 185 + break; 186 + 187 + *val = MAX31827_16_BIT_TO_M_DGR(uval); 188 + break; 189 + case hwmon_temp_max_hyst: 190 + ret = regmap_read(st->regmap, MAX31827_TH_HYST_REG, 191 + &uval); 192 + if (ret) 193 + break; 194 + 195 + *val = MAX31827_16_BIT_TO_M_DGR(uval); 196 + break; 197 + case hwmon_temp_max_alarm: 198 + ret = regmap_read(st->regmap, 199 + MAX31827_CONFIGURATION_REG, &uval); 200 + if (ret) 201 + break; 202 + 203 + *val = FIELD_GET(MAX31827_CONFIGURATION_O_TEMP_STAT_MASK, 204 + uval); 205 + break; 206 + case hwmon_temp_min: 207 + ret = regmap_read(st->regmap, MAX31827_TL_REG, &uval); 208 + if (ret) 209 + break; 210 + 211 + *val = MAX31827_16_BIT_TO_M_DGR(uval); 212 + break; 213 + case hwmon_temp_min_hyst: 214 + ret = regmap_read(st->regmap, MAX31827_TL_HYST_REG, 215 + &uval); 216 + if (ret) 217 + break; 218 + 219 + *val = MAX31827_16_BIT_TO_M_DGR(uval); 220 + break; 221 + case hwmon_temp_min_alarm: 222 + ret = regmap_read(st->regmap, 223 + MAX31827_CONFIGURATION_REG, &uval); 224 + if (ret) 225 + break; 226 + 227 + *val = FIELD_GET(MAX31827_CONFIGURATION_U_TEMP_STAT_MASK, 228 + uval); 229 + break; 230 + default: 231 + ret = -EOPNOTSUPP; 232 + break; 233 + } 234 + 235 + break; 236 + 237 + case hwmon_chip: 238 + if (attr == hwmon_chip_update_interval) { 239 + ret = regmap_read(st->regmap, 240 + MAX31827_CONFIGURATION_REG, &uval); 241 + if (ret) 242 + break; 243 + 244 + uval = FIELD_GET(MAX31827_CONFIGURATION_CNV_RATE_MASK, 245 + uval); 246 + switch (uval) { 247 + case MAX31827_CNV_1_DIV_64_HZ: 248 + *val = 64000; 249 + break; 250 + case MAX31827_CNV_1_DIV_32_HZ: 251 + *val = 32000; 252 + break; 253 + case MAX31827_CNV_1_DIV_16_HZ: 254 + *val = 16000; 255 + break; 256 + case MAX31827_CNV_1_DIV_4_HZ: 257 + *val = 4000; 258 + break; 259 + case MAX31827_CNV_1_HZ: 260 + *val = 1000; 261 + break; 262 + case MAX31827_CNV_4_HZ: 263 + *val = 250; 264 + break; 265 + case MAX31827_CNV_8_HZ: 266 + *val = 125; 267 + break; 268 + default: 269 + *val = 0; 270 + break; 271 + } 272 + } 273 + break; 274 + 275 + default: 276 + ret = -EOPNOTSUPP; 277 + break; 278 + } 279 + 280 + return ret; 281 + } 282 + 283 + static int max31827_write(struct device *dev, enum hwmon_sensor_types type, 284 + u32 attr, int channel, long val) 285 + { 286 + struct max31827_state *st = dev_get_drvdata(dev); 287 + int ret; 288 + 289 + switch (type) { 290 + case hwmon_temp: 291 + switch (attr) { 292 + case hwmon_temp_enable: 293 + if (val >> 1) 294 + return -EINVAL; 295 + 296 + mutex_lock(&st->lock); 297 + /** 298 + * The chip should not be enabled while a conversion is 299 + * performed. Neither should the chip be enabled when 300 + * the alarm values are changed. 301 + */ 302 + 303 + st->enable = val; 304 + 305 + ret = regmap_update_bits(st->regmap, 306 + MAX31827_CONFIGURATION_REG, 307 + MAX31827_CONFIGURATION_1SHOT_MASK | 308 + MAX31827_CONFIGURATION_CNV_RATE_MASK, 309 + MAX31827_DEVICE_ENABLE(val)); 310 + 311 + mutex_unlock(&st->lock); 312 + 313 + return ret; 314 + 315 + case hwmon_temp_max: 316 + return write_alarm_val(st, MAX31827_TH_REG, val); 317 + 318 + case hwmon_temp_max_hyst: 319 + return write_alarm_val(st, MAX31827_TH_HYST_REG, val); 320 + 321 + case hwmon_temp_min: 322 + return write_alarm_val(st, MAX31827_TL_REG, val); 323 + 324 + case hwmon_temp_min_hyst: 325 + return write_alarm_val(st, MAX31827_TL_HYST_REG, val); 326 + 327 + default: 328 + return -EOPNOTSUPP; 329 + } 330 + 331 + case hwmon_chip: 332 + if (attr == hwmon_chip_update_interval) { 333 + if (!st->enable) 334 + return -EINVAL; 335 + 336 + switch (val) { 337 + case 125: 338 + val = MAX31827_CNV_8_HZ; 339 + break; 340 + case 250: 341 + val = MAX31827_CNV_4_HZ; 342 + break; 343 + case 1000: 344 + val = MAX31827_CNV_1_HZ; 345 + break; 346 + case 4000: 347 + val = MAX31827_CNV_1_DIV_4_HZ; 348 + break; 349 + case 16000: 350 + val = MAX31827_CNV_1_DIV_16_HZ; 351 + break; 352 + case 32000: 353 + val = MAX31827_CNV_1_DIV_32_HZ; 354 + break; 355 + case 64000: 356 + val = MAX31827_CNV_1_DIV_64_HZ; 357 + break; 358 + default: 359 + return -EINVAL; 360 + } 361 + 362 + val = FIELD_PREP(MAX31827_CONFIGURATION_CNV_RATE_MASK, 363 + val); 364 + 365 + return regmap_update_bits(st->regmap, 366 + MAX31827_CONFIGURATION_REG, 367 + MAX31827_CONFIGURATION_CNV_RATE_MASK, 368 + val); 369 + } 370 + break; 371 + 372 + default: 373 + return -EOPNOTSUPP; 374 + } 375 + 376 + return -EOPNOTSUPP; 377 + } 378 + 379 + static int max31827_init_client(struct max31827_state *st) 380 + { 381 + st->enable = true; 382 + 383 + return regmap_update_bits(st->regmap, MAX31827_CONFIGURATION_REG, 384 + MAX31827_CONFIGURATION_1SHOT_MASK | 385 + MAX31827_CONFIGURATION_CNV_RATE_MASK, 386 + MAX31827_DEVICE_ENABLE(1)); 387 + } 388 + 389 + static const struct hwmon_channel_info *max31827_info[] = { 390 + HWMON_CHANNEL_INFO(temp, HWMON_T_ENABLE | HWMON_T_INPUT | HWMON_T_MIN | 391 + HWMON_T_MIN_HYST | HWMON_T_MIN_ALARM | 392 + HWMON_T_MAX | HWMON_T_MAX_HYST | 393 + HWMON_T_MAX_ALARM), 394 + HWMON_CHANNEL_INFO(chip, HWMON_C_UPDATE_INTERVAL), 395 + NULL, 396 + }; 397 + 398 + static const struct hwmon_ops max31827_hwmon_ops = { 399 + .is_visible = max31827_is_visible, 400 + .read = max31827_read, 401 + .write = max31827_write, 402 + }; 403 + 404 + static const struct hwmon_chip_info max31827_chip_info = { 405 + .ops = &max31827_hwmon_ops, 406 + .info = max31827_info, 407 + }; 408 + 409 + static int max31827_probe(struct i2c_client *client) 410 + { 411 + struct device *dev = &client->dev; 412 + struct device *hwmon_dev; 413 + struct max31827_state *st; 414 + int err; 415 + 416 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) 417 + return -EOPNOTSUPP; 418 + 419 + st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL); 420 + if (!st) 421 + return -ENOMEM; 422 + 423 + mutex_init(&st->lock); 424 + 425 + st->regmap = devm_regmap_init_i2c(client, &max31827_regmap); 426 + if (IS_ERR(st->regmap)) 427 + return dev_err_probe(dev, PTR_ERR(st->regmap), 428 + "Failed to allocate regmap.\n"); 429 + 430 + err = max31827_init_client(st); 431 + if (err) 432 + return err; 433 + 434 + hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, st, 435 + &max31827_chip_info, 436 + NULL); 437 + 438 + return PTR_ERR_OR_ZERO(hwmon_dev); 439 + } 440 + 441 + static const struct i2c_device_id max31827_i2c_ids[] = { 442 + { "max31827", 0 }, 443 + { } 444 + }; 445 + MODULE_DEVICE_TABLE(i2c, max31827_i2c_ids); 446 + 447 + static const struct of_device_id max31827_of_match[] = { 448 + { .compatible = "adi,max31827" }, 449 + { } 450 + }; 451 + MODULE_DEVICE_TABLE(of, max31827_of_match); 452 + 453 + static struct i2c_driver max31827_driver = { 454 + .class = I2C_CLASS_HWMON, 455 + .driver = { 456 + .name = "max31827", 457 + .of_match_table = max31827_of_match, 458 + }, 459 + .probe = max31827_probe, 460 + .id_table = max31827_i2c_ids, 461 + }; 462 + module_i2c_driver(max31827_driver); 463 + 464 + MODULE_AUTHOR("Daniel Matyas <daniel.matyas@analog.com>"); 465 + MODULE_DESCRIPTION("Maxim MAX31827 low-power temperature switch driver"); 466 + MODULE_LICENSE("GPL");
+1 -1
drivers/hwmon/max6620.c
··· 503 503 .driver = { 504 504 .name = "max6620", 505 505 }, 506 - .probe_new = max6620_probe, 506 + .probe = max6620_probe, 507 507 .id_table = max6620_id, 508 508 }; 509 509
+1 -1
drivers/hwmon/max6621.c
··· 554 554 .name = MAX6621_DRV_NAME, 555 555 .of_match_table = of_match_ptr(max6621_of_match), 556 556 }, 557 - .probe_new = max6621_probe, 557 + .probe = max6621_probe, 558 558 .id_table = max6621_id, 559 559 }; 560 560
+1 -1
drivers/hwmon/max6639.c
··· 624 624 .name = "max6639", 625 625 .pm = pm_sleep_ptr(&max6639_pm_ops), 626 626 }, 627 - .probe_new = max6639_probe, 627 + .probe = max6639_probe, 628 628 .id_table = max6639_id, 629 629 .detect = max6639_detect, 630 630 .address_list = normal_i2c,
+1 -1
drivers/hwmon/max6642.c
··· 301 301 .driver = { 302 302 .name = "max6642", 303 303 }, 304 - .probe_new = max6642_probe, 304 + .probe = max6642_probe, 305 305 .id_table = max6642_id, 306 306 .detect = max6642_detect, 307 307 .address_list = normal_i2c,
+1 -1
drivers/hwmon/max6650.c
··· 819 819 .name = "max6650", 820 820 .of_match_table = of_match_ptr(max6650_dt_match), 821 821 }, 822 - .probe_new = max6650_probe, 822 + .probe = max6650_probe, 823 823 .id_table = max6650_id, 824 824 }; 825 825
+1 -1
drivers/hwmon/max6697.c
··· 786 786 .name = "max6697", 787 787 .of_match_table = of_match_ptr(max6697_of_match), 788 788 }, 789 - .probe_new = max6697_probe, 789 + .probe = max6697_probe, 790 790 .id_table = max6697_id, 791 791 }; 792 792
+1 -1
drivers/hwmon/mc34vr500.c
··· 251 251 .name = "mc34vr500", 252 252 .of_match_table = of_match_ptr(mc34vr500_of_match), 253 253 }, 254 - .probe_new = mc34vr500_probe, 254 + .probe = mc34vr500_probe, 255 255 .id_table = mc34vr500_id, 256 256 }; 257 257
+1 -1
drivers/hwmon/mcp3021.c
··· 198 198 .name = "mcp3021", 199 199 .of_match_table = of_match_ptr(of_mcp3021_match), 200 200 }, 201 - .probe_new = mcp3021_probe, 201 + .probe = mcp3021_probe, 202 202 .id_table = mcp3021_id, 203 203 }; 204 204
+3
drivers/hwmon/nct6683.c
··· 173 173 #define NCT6683_CUSTOMER_ID_INTEL 0x805 174 174 #define NCT6683_CUSTOMER_ID_MITAC 0xa0e 175 175 #define NCT6683_CUSTOMER_ID_MSI 0x201 176 + #define NCT6683_CUSTOMER_ID_MSI2 0x200 176 177 #define NCT6683_CUSTOMER_ID_ASROCK 0xe2c 177 178 #define NCT6683_CUSTOMER_ID_ASROCK2 0xe1b 178 179 ··· 1220 1219 case NCT6683_CUSTOMER_ID_MITAC: 1221 1220 break; 1222 1221 case NCT6683_CUSTOMER_ID_MSI: 1222 + break; 1223 + case NCT6683_CUSTOMER_ID_MSI2: 1223 1224 break; 1224 1225 case NCT6683_CUSTOMER_ID_ASROCK: 1225 1226 break;
+53 -2
drivers/hwmon/nct6775-core.c
··· 33 33 * (0xd451) 34 34 * nct6798d 14 7 7 2+6 0xd428 0xc1 0x5ca3 35 35 * (0xd429) 36 + * nct6799d 14 7 7 2+6 0xd802 0xc1 0x5ca3 36 37 * 37 38 * #temp lists the number of monitored temperature sources (first value) plus 38 39 * the number of directly connectable temperature sensors (second value). ··· 74 73 "nct6796", 75 74 "nct6797", 76 75 "nct6798", 76 + "nct6799", 77 77 }; 78 78 79 79 /* Common and NCT6775 specific data */ ··· 383 381 0x39, 0x155 }; 384 382 385 383 static const u16 NCT6779_REG_TEMP_OFFSET[] = { 386 - 0x454, 0x455, 0x456, 0x44a, 0x44b, 0x44c }; 384 + 0x454, 0x455, 0x456, 0x44a, 0x44b, 0x44c, 0x44d, 0x449 }; 387 385 388 386 static const char *const nct6779_temp_label[] = { 389 387 "", ··· 655 653 656 654 #define NCT6798_TEMP_MASK 0xbfff0ffe 657 655 #define NCT6798_VIRT_TEMP_MASK 0x80000c00 656 + 657 + static const char *const nct6799_temp_label[] = { 658 + "", 659 + "SYSTIN", 660 + "CPUTIN", 661 + "AUXTIN0", 662 + "AUXTIN1", 663 + "AUXTIN2", 664 + "AUXTIN3", 665 + "AUXTIN4", 666 + "SMBUSMASTER 0", 667 + "SMBUSMASTER 1", 668 + "Virtual_TEMP", 669 + "Virtual_TEMP", 670 + "", 671 + "AUXTIN5", 672 + "", 673 + "", 674 + "PECI Agent 0", 675 + "PECI Agent 1", 676 + "PCH_CHIP_CPU_MAX_TEMP", 677 + "PCH_CHIP_TEMP", 678 + "PCH_CPU_TEMP", 679 + "PCH_MCH_TEMP", 680 + "Agent0 Dimm0", 681 + "Agent0 Dimm1", 682 + "Agent1 Dimm0", 683 + "Agent1 Dimm1", 684 + "BYTE_TEMP0", 685 + "BYTE_TEMP1", 686 + "PECI Agent 0 Calibration", /* undocumented */ 687 + "PECI Agent 1 Calibration", /* undocumented */ 688 + "", 689 + "Virtual_TEMP" 690 + }; 691 + 692 + #define NCT6799_TEMP_MASK 0xbfff2ffe 693 + #define NCT6799_VIRT_TEMP_MASK 0x80000c00 658 694 659 695 /* NCT6102D/NCT6106D specific data */ 660 696 ··· 1149 1109 case nct6796: 1150 1110 case nct6797: 1151 1111 case nct6798: 1112 + case nct6799: 1152 1113 return reg == 0x150 || reg == 0x153 || reg == 0x155 || 1153 1114 (reg & 0xfff0) == 0x4c0 || 1154 1115 reg == 0x402 || ··· 1503 1462 case nct6796: 1504 1463 case nct6797: 1505 1464 case nct6798: 1465 + case nct6799: 1506 1466 err = nct6775_read_value(data, data->REG_CRITICAL_PWM_ENABLE[i], &reg); 1507 1467 if (err) 1508 1468 return err; ··· 3151 3109 case nct6796: 3152 3110 case nct6797: 3153 3111 case nct6798: 3112 + case nct6799: 3154 3113 err = nct6775_write_value(data, data->REG_CRITICAL_PWM[nr], val); 3155 3114 if (err) 3156 3115 break; ··· 3850 3807 case nct6796: 3851 3808 case nct6797: 3852 3809 case nct6798: 3810 + case nct6799: 3853 3811 data->in_num = 15; 3854 3812 data->pwm_num = (data->kind == nct6796 || 3855 3813 data->kind == nct6797 || 3856 - data->kind == nct6798) ? 7 : 6; 3814 + data->kind == nct6798 || 3815 + data->kind == nct6799) ? 7 : 6; 3857 3816 data->auto_pwm_num = 4; 3858 3817 data->has_fan_div = false; 3859 3818 data->temp_fixed_num = 6; ··· 3903 3858 data->temp_label = nct6798_temp_label; 3904 3859 data->temp_mask = NCT6798_TEMP_MASK; 3905 3860 data->virt_temp_mask = NCT6798_VIRT_TEMP_MASK; 3861 + break; 3862 + case nct6799: 3863 + data->temp_label = nct6799_temp_label; 3864 + data->temp_mask = NCT6799_TEMP_MASK; 3865 + data->virt_temp_mask = NCT6799_VIRT_TEMP_MASK; 3906 3866 break; 3907 3867 } 3908 3868 ··· 3968 3918 case nct6796: 3969 3919 case nct6797: 3970 3920 case nct6798: 3921 + case nct6799: 3971 3922 data->REG_TSI_TEMP = NCT6796_REG_TSI_TEMP; 3972 3923 num_reg_tsi_temp = ARRAY_SIZE(NCT6796_REG_TSI_TEMP); 3973 3924 break;
+3 -1
drivers/hwmon/nct6775-i2c.c
··· 87 87 { .compatible = "nuvoton,nct6796", .data = (void *)nct6796, }, 88 88 { .compatible = "nuvoton,nct6797", .data = (void *)nct6797, }, 89 89 { .compatible = "nuvoton,nct6798", .data = (void *)nct6798, }, 90 + { .compatible = "nuvoton,nct6799", .data = (void *)nct6799, }, 90 91 { }, 91 92 }; 92 93 MODULE_DEVICE_TABLE(of, nct6775_i2c_of_match); ··· 105 104 { "nct6796", nct6796 }, 106 105 { "nct6797", nct6797 }, 107 106 { "nct6798", nct6798 }, 107 + { "nct6799", nct6799 }, 108 108 { } 109 109 }; 110 110 MODULE_DEVICE_TABLE(i2c, nct6775_i2c_id); ··· 185 183 .name = "nct6775-i2c", 186 184 .of_match_table = of_match_ptr(nct6775_i2c_of_match), 187 185 }, 188 - .probe_new = nct6775_i2c_probe, 186 + .probe = nct6775_i2c_probe, 189 187 .id_table = nct6775_i2c_id, 190 188 }; 191 189
+38 -3
drivers/hwmon/nct6775-platform.c
··· 35 35 "NCT6796D", 36 36 "NCT6797D", 37 37 "NCT6798D", 38 + "NCT6799D", 38 39 }; 39 40 40 41 static unsigned short force_id; ··· 86 85 #define SIO_NCT6796_ID 0xd420 87 86 #define SIO_NCT6797_ID 0xd450 88 87 #define SIO_NCT6798_ID 0xd428 88 + #define SIO_NCT6799_ID 0xd800 89 89 #define SIO_ID_MASK 0xFFF8 90 90 91 91 /* ··· 420 418 if (data->kind == nct6791 || data->kind == nct6792 || 421 419 data->kind == nct6793 || data->kind == nct6795 || 422 420 data->kind == nct6796 || data->kind == nct6797 || 423 - data->kind == nct6798) 421 + data->kind == nct6798 || data->kind == nct6799) 424 422 nct6791_enable_io_mapping(sio_data); 425 423 426 424 sio_data->sio_exit(sio_data); ··· 567 565 } else { 568 566 /* 569 567 * NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D, 570 - * NCT6797D, NCT6798D 568 + * NCT6797D, NCT6798D, NCT6799D 571 569 */ 572 570 int cr1a = sio_data->sio_inb(sio_data, 0x1a); 573 571 int cr1b = sio_data->sio_inb(sio_data, 0x1b); ··· 577 575 int cr2b = sio_data->sio_inb(sio_data, 0x2b); 578 576 int cr2d = sio_data->sio_inb(sio_data, 0x2d); 579 577 int cr2f = sio_data->sio_inb(sio_data, 0x2f); 578 + bool vsb_ctl_en = cr2f & BIT(0); 580 579 bool dsw_en = cr2f & BIT(3); 581 580 bool ddr4_en = cr2f & BIT(4); 581 + bool as_seq1_en = cr2f & BIT(7); 582 582 int cre0; 583 + int cre6; 583 584 int creb; 584 585 int cred; 586 + 587 + cre6 = sio_data->sio_inb(sio_data, 0xe0); 585 588 586 589 sio_data->sio_select(sio_data, NCT6775_LD_12); 587 590 cre0 = sio_data->sio_inb(sio_data, 0xe0); ··· 690 683 pwm7pin = !(cr1d & (BIT(2) | BIT(3))); 691 684 pwm7pin |= cr2d & BIT(7); 692 685 pwm7pin |= creb & BIT(2); 686 + break; 687 + case nct6799: 688 + fan4pin = cr1c & BIT(6); 689 + fan5pin = cr1c & BIT(7); 690 + 691 + fan6pin = !(cr1b & BIT(0)) && (cre0 & BIT(3)); 692 + fan6pin |= cre6 & BIT(5); 693 + fan6pin |= creb & BIT(5); 694 + fan6pin |= !as_seq1_en && (cr2a & BIT(4)); 695 + 696 + fan7pin = cr1b & BIT(5); 697 + fan7pin |= !vsb_ctl_en && !(cr2b & BIT(2)); 698 + fan7pin |= creb & BIT(3); 699 + 700 + pwm6pin = !(cr1b & BIT(0)) && (cre0 & BIT(4)); 701 + pwm6pin |= !as_seq1_en && !(cred & BIT(2)) && (cr2a & BIT(3)); 702 + pwm6pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); 703 + pwm6pin |= cre6 & BIT(3); 704 + 705 + pwm7pin = !vsb_ctl_en && !(cr1d & (BIT(2) | BIT(3))); 706 + pwm7pin |= creb & BIT(2); 707 + pwm7pin |= cr2d & BIT(7); 708 + 693 709 break; 694 710 default: /* NCT6779D */ 695 711 break; ··· 868 838 case nct6796: 869 839 case nct6797: 870 840 case nct6798: 841 + case nct6799: 871 842 break; 872 843 } 873 844 ··· 907 876 case nct6796: 908 877 case nct6797: 909 878 case nct6798: 879 + case nct6799: 910 880 tmp |= 0x7e; 911 881 break; 912 882 } ··· 1037 1005 case SIO_NCT6798_ID: 1038 1006 sio_data->kind = nct6798; 1039 1007 break; 1008 + case SIO_NCT6799_ID: 1009 + sio_data->kind = nct6799; 1010 + break; 1040 1011 default: 1041 1012 if (val != 0xffff) 1042 1013 pr_debug("unsupported chip ID: 0x%04x\n", val); ··· 1068 1033 if (sio_data->kind == nct6791 || sio_data->kind == nct6792 || 1069 1034 sio_data->kind == nct6793 || sio_data->kind == nct6795 || 1070 1035 sio_data->kind == nct6796 || sio_data->kind == nct6797 || 1071 - sio_data->kind == nct6798) 1036 + sio_data->kind == nct6798 || sio_data->kind == nct6799) 1072 1037 nct6791_enable_io_mapping(sio_data); 1073 1038 1074 1039 sio_data->sio_exit(sio_data);
+1 -1
drivers/hwmon/nct6775.h
··· 5 5 #include <linux/types.h> 6 6 7 7 enum kinds { nct6106, nct6116, nct6775, nct6776, nct6779, nct6791, nct6792, 8 - nct6793, nct6795, nct6796, nct6797, nct6798 }; 8 + nct6793, nct6795, nct6796, nct6797, nct6798, nct6799 }; 9 9 enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 }; 10 10 11 11 #define NUM_TEMP 10 /* Max number of temp attribute sets w/ limits*/
+1 -1
drivers/hwmon/nct7802.c
··· 1223 1223 .name = DRVNAME, 1224 1224 }, 1225 1225 .detect = nct7802_detect, 1226 - .probe_new = nct7802_probe, 1226 + .probe = nct7802_probe, 1227 1227 .id_table = nct7802_idtable, 1228 1228 .address_list = nct7802_address_list, 1229 1229 };
+1 -1
drivers/hwmon/nct7904.c
··· 1171 1171 .driver = { 1172 1172 .name = "nct7904", 1173 1173 }, 1174 - .probe_new = nct7904_probe, 1174 + .probe = nct7904_probe, 1175 1175 .id_table = nct7904_id, 1176 1176 .detect = nct7904_detect, 1177 1177 .address_list = normal_i2c,
+1 -1
drivers/hwmon/occ/p8_i2c.c
··· 246 246 .name = "occ-hwmon", 247 247 .of_match_table = p8_i2c_occ_of_match, 248 248 }, 249 - .probe_new = p8_i2c_occ_probe, 249 + .probe = p8_i2c_occ_probe, 250 250 .remove = p8_i2c_occ_remove, 251 251 }; 252 252
+179 -15
drivers/hwmon/oxp-sensors.c
··· 16 16 */ 17 17 18 18 #include <linux/acpi.h> 19 - #include <linux/dev_printk.h> 20 19 #include <linux/dmi.h> 21 20 #include <linux/hwmon.h> 22 21 #include <linux/init.h> ··· 41 42 42 43 enum oxp_board { 43 44 aok_zoe_a1 = 1, 45 + aya_neo_2, 44 46 aya_neo_air, 45 47 aya_neo_air_pro, 48 + aya_neo_geek, 46 49 oxp_mini_amd, 50 + oxp_mini_amd_a07, 47 51 oxp_mini_amd_pro, 48 52 }; 49 53 50 54 static enum oxp_board board; 51 55 56 + /* Fan reading and PWM */ 52 57 #define OXP_SENSOR_FAN_REG 0x76 /* Fan reading is 2 registers long */ 53 58 #define OXP_SENSOR_PWM_ENABLE_REG 0x4A /* PWM enable is 1 register long */ 54 59 #define OXP_SENSOR_PWM_REG 0x4B /* PWM reading is 1 register long */ 60 + 61 + /* Turbo button takeover function 62 + * Older boards have different values and EC registers 63 + * for the same function 64 + */ 65 + #define OXP_OLD_TURBO_SWITCH_REG 0x1E 66 + #define OXP_OLD_TURBO_TAKE_VAL 0x01 67 + #define OXP_OLD_TURBO_RETURN_VAL 0x00 68 + 69 + #define OXP_TURBO_SWITCH_REG 0xF1 70 + #define OXP_TURBO_TAKE_VAL 0x40 71 + #define OXP_TURBO_RETURN_VAL 0x00 55 72 56 73 static const struct dmi_system_id dmi_table[] = { 57 74 { ··· 75 60 DMI_MATCH(DMI_BOARD_VENDOR, "AOKZOE"), 76 61 DMI_EXACT_MATCH(DMI_BOARD_NAME, "AOKZOE A1 AR07"), 77 62 }, 78 - .driver_data = (void *) &(enum oxp_board) {aok_zoe_a1}, 63 + .driver_data = (void *)aok_zoe_a1, 64 + }, 65 + { 66 + .matches = { 67 + DMI_MATCH(DMI_BOARD_VENDOR, "AOKZOE"), 68 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "AOKZOE A1 Pro"), 69 + }, 70 + .driver_data = (void *)aok_zoe_a1, 71 + }, 72 + { 73 + .matches = { 74 + DMI_MATCH(DMI_BOARD_VENDOR, "AYANEO"), 75 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "AYANEO 2"), 76 + }, 77 + .driver_data = (void *)aya_neo_2, 79 78 }, 80 79 { 81 80 .matches = { 82 81 DMI_MATCH(DMI_BOARD_VENDOR, "AYANEO"), 83 82 DMI_EXACT_MATCH(DMI_BOARD_NAME, "AIR"), 84 83 }, 85 - .driver_data = (void *) &(enum oxp_board) {aya_neo_air}, 84 + .driver_data = (void *)aya_neo_air, 86 85 }, 87 86 { 88 87 .matches = { 89 88 DMI_MATCH(DMI_BOARD_VENDOR, "AYANEO"), 90 89 DMI_EXACT_MATCH(DMI_BOARD_NAME, "AIR Pro"), 91 90 }, 92 - .driver_data = (void *) &(enum oxp_board) {aya_neo_air_pro}, 91 + .driver_data = (void *)aya_neo_air_pro, 92 + }, 93 + { 94 + .matches = { 95 + DMI_MATCH(DMI_BOARD_VENDOR, "AYANEO"), 96 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "GEEK"), 97 + }, 98 + .driver_data = (void *)aya_neo_geek, 93 99 }, 94 100 { 95 101 .matches = { 96 102 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), 97 103 DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONE XPLAYER"), 98 104 }, 99 - .driver_data = (void *) &(enum oxp_board) {oxp_mini_amd}, 105 + .driver_data = (void *)oxp_mini_amd, 106 + }, 107 + { 108 + .matches = { 109 + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), 110 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER mini A07"), 111 + }, 112 + .driver_data = (void *)oxp_mini_amd_a07, 100 113 }, 101 114 { 102 115 .matches = { 103 116 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), 104 117 DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER Mini Pro"), 105 118 }, 106 - .driver_data = (void *) &(enum oxp_board) {oxp_mini_amd_pro}, 119 + .driver_data = (void *)oxp_mini_amd_pro, 107 120 }, 108 121 {}, 109 122 }; ··· 161 118 return 0; 162 119 } 163 120 164 - static int write_to_ec(const struct device *dev, u8 reg, u8 value) 121 + static int write_to_ec(u8 reg, u8 value) 165 122 { 166 123 int ret; 167 124 ··· 176 133 return ret; 177 134 } 178 135 179 - static int oxp_pwm_enable(const struct device *dev) 136 + /* Turbo button toggle functions */ 137 + static int tt_toggle_enable(void) 180 138 { 181 - return write_to_ec(dev, OXP_SENSOR_PWM_ENABLE_REG, 0x01); 139 + u8 reg; 140 + u8 val; 141 + 142 + switch (board) { 143 + case oxp_mini_amd_a07: 144 + reg = OXP_OLD_TURBO_SWITCH_REG; 145 + val = OXP_OLD_TURBO_TAKE_VAL; 146 + break; 147 + case oxp_mini_amd_pro: 148 + case aok_zoe_a1: 149 + reg = OXP_TURBO_SWITCH_REG; 150 + val = OXP_TURBO_TAKE_VAL; 151 + break; 152 + default: 153 + return -EINVAL; 154 + } 155 + return write_to_ec(reg, val); 182 156 } 183 157 184 - static int oxp_pwm_disable(const struct device *dev) 158 + static int tt_toggle_disable(void) 185 159 { 186 - return write_to_ec(dev, OXP_SENSOR_PWM_ENABLE_REG, 0x00); 160 + u8 reg; 161 + u8 val; 162 + 163 + switch (board) { 164 + case oxp_mini_amd_a07: 165 + reg = OXP_OLD_TURBO_SWITCH_REG; 166 + val = OXP_OLD_TURBO_RETURN_VAL; 167 + break; 168 + case oxp_mini_amd_pro: 169 + case aok_zoe_a1: 170 + reg = OXP_TURBO_SWITCH_REG; 171 + val = OXP_TURBO_RETURN_VAL; 172 + break; 173 + default: 174 + return -EINVAL; 175 + } 176 + return write_to_ec(reg, val); 177 + } 178 + 179 + /* Callbacks for turbo toggle attribute */ 180 + static ssize_t tt_toggle_store(struct device *dev, 181 + struct device_attribute *attr, const char *buf, 182 + size_t count) 183 + { 184 + int rval; 185 + bool value; 186 + 187 + rval = kstrtobool(buf, &value); 188 + if (rval) 189 + return rval; 190 + 191 + if (value) { 192 + rval = tt_toggle_enable(); 193 + } else { 194 + rval = tt_toggle_disable(); 195 + } 196 + if (rval) 197 + return rval; 198 + 199 + return count; 200 + } 201 + 202 + static ssize_t tt_toggle_show(struct device *dev, 203 + struct device_attribute *attr, char *buf) 204 + { 205 + int retval; 206 + u8 reg; 207 + long val; 208 + 209 + switch (board) { 210 + case oxp_mini_amd_a07: 211 + reg = OXP_OLD_TURBO_SWITCH_REG; 212 + break; 213 + case oxp_mini_amd_pro: 214 + case aok_zoe_a1: 215 + reg = OXP_TURBO_SWITCH_REG; 216 + break; 217 + default: 218 + return -EINVAL; 219 + } 220 + 221 + retval = read_from_ec(reg, 1, &val); 222 + if (retval) 223 + return retval; 224 + 225 + return sysfs_emit(buf, "%d\n", !!val); 226 + } 227 + 228 + static DEVICE_ATTR_RW(tt_toggle); 229 + 230 + /* PWM enable/disable functions */ 231 + static int oxp_pwm_enable(void) 232 + { 233 + return write_to_ec(OXP_SENSOR_PWM_ENABLE_REG, 0x01); 234 + } 235 + 236 + static int oxp_pwm_disable(void) 237 + { 238 + return write_to_ec(OXP_SENSOR_PWM_ENABLE_REG, 0x00); 187 239 } 188 240 189 241 /* Callbacks for hwmon interface */ ··· 316 178 if (ret) 317 179 return ret; 318 180 switch (board) { 181 + case aya_neo_2: 319 182 case aya_neo_air: 320 183 case aya_neo_air_pro: 184 + case aya_neo_geek: 321 185 case oxp_mini_amd: 186 + case oxp_mini_amd_a07: 322 187 *val = (*val * 255) / 100; 323 188 break; 324 189 case oxp_mini_amd_pro: ··· 350 209 switch (attr) { 351 210 case hwmon_pwm_enable: 352 211 if (val == 1) 353 - return oxp_pwm_enable(dev); 212 + return oxp_pwm_enable(); 354 213 else if (val == 0) 355 - return oxp_pwm_disable(dev); 214 + return oxp_pwm_disable(); 356 215 return -EINVAL; 357 216 case hwmon_pwm_input: 358 217 if (val < 0 || val > 255) 359 218 return -EINVAL; 360 219 switch (board) { 220 + case aya_neo_2: 361 221 case aya_neo_air: 362 222 case aya_neo_air_pro: 223 + case aya_neo_geek: 363 224 case oxp_mini_amd: 225 + case oxp_mini_amd_a07: 364 226 val = (val * 100) / 255; 365 227 break; 366 228 case aok_zoe_a1: ··· 371 227 default: 372 228 break; 373 229 } 374 - return write_to_ec(dev, OXP_SENSOR_PWM_REG, val); 230 + return write_to_ec(OXP_SENSOR_PWM_REG, val); 375 231 default: 376 232 break; 377 233 } ··· 391 247 NULL, 392 248 }; 393 249 250 + static struct attribute *oxp_ec_attrs[] = { 251 + &dev_attr_tt_toggle.attr, 252 + NULL 253 + }; 254 + 255 + ATTRIBUTE_GROUPS(oxp_ec); 256 + 394 257 static const struct hwmon_ops oxp_ec_hwmon_ops = { 395 258 .is_visible = oxp_ec_hwmon_is_visible, 396 259 .read = oxp_platform_read, ··· 415 264 const struct dmi_system_id *dmi_entry; 416 265 struct device *dev = &pdev->dev; 417 266 struct device *hwdev; 267 + int ret; 418 268 419 269 /* 420 270 * Have to check for AMD processor here because DMI strings are the ··· 428 276 if (!dmi_entry || boot_cpu_data.x86_vendor != X86_VENDOR_AMD) 429 277 return -ENODEV; 430 278 431 - board = *((enum oxp_board *) dmi_entry->driver_data); 279 + board = (enum oxp_board)(unsigned long)dmi_entry->driver_data; 280 + 281 + switch (board) { 282 + case aok_zoe_a1: 283 + case oxp_mini_amd_a07: 284 + case oxp_mini_amd_pro: 285 + ret = devm_device_add_groups(dev, oxp_ec_groups); 286 + if (ret) 287 + return ret; 288 + break; 289 + default: 290 + break; 291 + } 432 292 433 293 hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL, 434 294 &oxp_ec_chip_info, NULL);
+1 -1
drivers/hwmon/pcf8591.c
··· 294 294 .driver = { 295 295 .name = "pcf8591", 296 296 }, 297 - .probe_new = pcf8591_probe, 297 + .probe = pcf8591_probe, 298 298 .remove = pcf8591_remove, 299 299 .id_table = pcf8591_id, 300 300 };
+1 -1
drivers/hwmon/pmbus/acbel-fsg032.c
··· 73 73 .name = "acbel-fsg032", 74 74 .of_match_table = acbel_fsg032_of_match, 75 75 }, 76 - .probe_new = acbel_fsg032_probe, 76 + .probe = acbel_fsg032_probe, 77 77 .id_table = acbel_fsg032_id, 78 78 }; 79 79
+1 -3
drivers/hwmon/pmbus/adm1266.c
··· 340 340 return; 341 341 342 342 data->debugfs_dir = debugfs_create_dir(data->client->name, root); 343 - if (!data->debugfs_dir) 344 - return; 345 343 346 344 debugfs_create_devm_seqfile(&data->client->dev, "sequencer_state", data->debugfs_dir, 347 345 adm1266_state_read); ··· 500 502 .name = "adm1266", 501 503 .of_match_table = adm1266_of_match, 502 504 }, 503 - .probe_new = adm1266_probe, 505 + .probe = adm1266_probe, 504 506 .id_table = adm1266_id, 505 507 }; 506 508
+70 -48
drivers/hwmon/pmbus/adm1275.c
··· 27 27 #define ADM1275_PEAK_IOUT 0xd0 28 28 #define ADM1275_PEAK_VIN 0xd1 29 29 #define ADM1275_PEAK_VOUT 0xd2 30 + #define ADM1275_PMON_CONTROL 0xd3 30 31 #define ADM1275_PMON_CONFIG 0xd4 32 + 33 + #define ADM1275_CONVERT_EN BIT(0) 31 34 32 35 #define ADM1275_VIN_VOUT_SELECT BIT(6) 33 36 #define ADM1275_VRANGE BIT(5) ··· 40 37 41 38 #define ADM1272_IRANGE BIT(0) 42 39 40 + #define ADM1278_TSFILT BIT(15) 43 41 #define ADM1278_TEMP1_EN BIT(3) 44 42 #define ADM1278_VIN_EN BIT(2) 45 43 #define ADM1278_VOUT_EN BIT(1) 44 + 45 + #define ADM1278_PMON_DEFCONFIG (ADM1278_VOUT_EN | ADM1278_TEMP1_EN | ADM1278_TSFILT) 46 46 47 47 #define ADM1293_IRANGE_25 0 48 48 #define ADM1293_IRANGE_50 BIT(6) ··· 176 170 [18] = { 7658, 0, -3 }, /* power, 21V, irange200 */ 177 171 }; 178 172 179 - static int adm1275_read_pmon_config(const struct adm1275_data *data, 180 - struct i2c_client *client, bool is_power) 173 + static int adm1275_read_samples(const struct adm1275_data *data, 174 + struct i2c_client *client, bool is_power) 181 175 { 182 176 int shift, ret; 183 177 u16 mask; ··· 203 197 } 204 198 205 199 static int adm1275_write_pmon_config(const struct adm1275_data *data, 206 - struct i2c_client *client, 207 - bool is_power, u16 word) 200 + struct i2c_client *client, u16 word) 201 + { 202 + int ret, ret2; 203 + 204 + ret = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONTROL, 0); 205 + if (ret) 206 + return ret; 207 + 208 + if (data->have_power_sampling) 209 + ret = i2c_smbus_write_word_data(client, ADM1275_PMON_CONFIG, 210 + word); 211 + else 212 + ret = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONFIG, 213 + word); 214 + 215 + /* 216 + * We still want to re-enable conversions if writing into 217 + * ADM1275_PMON_CONFIG failed. 218 + */ 219 + ret2 = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONTROL, 220 + ADM1275_CONVERT_EN); 221 + if (!ret) 222 + ret = ret2; 223 + 224 + return ret; 225 + } 226 + 227 + static int adm1275_write_samples(const struct adm1275_data *data, 228 + struct i2c_client *client, 229 + bool is_power, u16 word) 208 230 { 209 231 int shift, ret; 210 232 u16 mask; ··· 250 216 return ret; 251 217 252 218 word = (ret & ~mask) | ((word << shift) & mask); 253 - if (data->have_power_sampling) 254 - ret = i2c_smbus_write_word_data(client, ADM1275_PMON_CONFIG, 255 - word); 256 - else 257 - ret = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONFIG, 258 - word); 259 219 260 - return ret; 220 + return adm1275_write_pmon_config(data, client, word); 261 221 } 262 222 263 223 static int adm1275_read_word_data(struct i2c_client *client, int page, ··· 346 318 case PMBUS_VIRT_POWER_SAMPLES: 347 319 if (!data->have_power_sampling) 348 320 return -ENXIO; 349 - ret = adm1275_read_pmon_config(data, client, true); 321 + ret = adm1275_read_samples(data, client, true); 350 322 if (ret < 0) 351 323 break; 352 324 ret = BIT(ret); 353 325 break; 354 326 case PMBUS_VIRT_IN_SAMPLES: 355 327 case PMBUS_VIRT_CURR_SAMPLES: 356 - ret = adm1275_read_pmon_config(data, client, false); 328 + ret = adm1275_read_samples(data, client, false); 357 329 if (ret < 0) 358 330 break; 359 331 ret = BIT(ret); ··· 406 378 if (!data->have_power_sampling) 407 379 return -ENXIO; 408 380 word = clamp_val(word, 1, ADM1275_SAMPLES_AVG_MAX); 409 - ret = adm1275_write_pmon_config(data, client, true, 410 - ilog2(word)); 381 + ret = adm1275_write_samples(data, client, true, ilog2(word)); 411 382 break; 412 383 case PMBUS_VIRT_IN_SAMPLES: 413 384 case PMBUS_VIRT_CURR_SAMPLES: 414 385 word = clamp_val(word, 1, ADM1275_SAMPLES_AVG_MAX); 415 - ret = adm1275_write_pmon_config(data, client, false, 416 - ilog2(word)); 386 + ret = adm1275_write_samples(data, client, false, ilog2(word)); 417 387 break; 418 388 default: 419 389 ret = -ENODATA; ··· 487 461 { } 488 462 }; 489 463 MODULE_DEVICE_TABLE(i2c, adm1275_id); 464 + 465 + /* Enable VOUT & TEMP1 if not enabled (disabled by default) */ 466 + static int adm1275_enable_vout_temp(struct adm1275_data *data, 467 + struct i2c_client *client, int config) 468 + { 469 + int ret; 470 + 471 + if ((config & ADM1278_PMON_DEFCONFIG) != ADM1278_PMON_DEFCONFIG) { 472 + config |= ADM1278_PMON_DEFCONFIG; 473 + ret = adm1275_write_pmon_config(data, client, config); 474 + if (ret < 0) { 475 + dev_err(&client->dev, "Failed to enable VOUT/TEMP1 monitoring\n"); 476 + return ret; 477 + } 478 + } 479 + return 0; 480 + } 490 481 491 482 static int adm1275_probe(struct i2c_client *client) 492 483 { ··· 658 615 PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | 659 616 PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP; 660 617 661 - /* Enable VOUT & TEMP1 if not enabled (disabled by default) */ 662 - if ((config & (ADM1278_VOUT_EN | ADM1278_TEMP1_EN)) != 663 - (ADM1278_VOUT_EN | ADM1278_TEMP1_EN)) { 664 - config |= ADM1278_VOUT_EN | ADM1278_TEMP1_EN; 665 - ret = i2c_smbus_write_byte_data(client, 666 - ADM1275_PMON_CONFIG, 667 - config); 668 - if (ret < 0) { 669 - dev_err(&client->dev, 670 - "Failed to enable VOUT monitoring\n"); 671 - return -ENODEV; 672 - } 673 - } 618 + ret = adm1275_enable_vout_temp(data, client, config); 619 + if (ret) 620 + return ret; 621 + 674 622 if (config & ADM1278_VIN_EN) 675 623 info->func[0] |= PMBUS_HAVE_VIN; 676 624 break; ··· 718 684 PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | 719 685 PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP; 720 686 721 - /* Enable VOUT & TEMP1 if not enabled (disabled by default) */ 722 - if ((config & (ADM1278_VOUT_EN | ADM1278_TEMP1_EN)) != 723 - (ADM1278_VOUT_EN | ADM1278_TEMP1_EN)) { 724 - config |= ADM1278_VOUT_EN | ADM1278_TEMP1_EN; 725 - ret = i2c_smbus_write_word_data(client, 726 - ADM1275_PMON_CONFIG, 727 - config); 728 - if (ret < 0) { 729 - dev_err(&client->dev, 730 - "Failed to enable VOUT monitoring\n"); 731 - return -ENODEV; 732 - } 733 - } 687 + ret = adm1275_enable_vout_temp(data, client, config); 688 + if (ret) 689 + return ret; 734 690 735 691 if (config & ADM1278_VIN_EN) 736 692 info->func[0] |= PMBUS_HAVE_VIN; ··· 790 766 "Invalid number of power samples"); 791 767 return -EINVAL; 792 768 } 793 - ret = adm1275_write_pmon_config(data, client, true, 794 - ilog2(avg)); 769 + ret = adm1275_write_samples(data, client, true, ilog2(avg)); 795 770 if (ret < 0) { 796 771 dev_err(&client->dev, 797 772 "Setting power sample averaging failed with error %d", ··· 807 784 "Invalid number of voltage/current samples"); 808 785 return -EINVAL; 809 786 } 810 - ret = adm1275_write_pmon_config(data, client, false, 811 - ilog2(avg)); 787 + ret = adm1275_write_samples(data, client, false, ilog2(avg)); 812 788 if (ret < 0) { 813 789 dev_err(&client->dev, 814 790 "Setting voltage and current sample averaging failed with error %d", ··· 854 832 .driver = { 855 833 .name = "adm1275", 856 834 }, 857 - .probe_new = adm1275_probe, 835 + .probe = adm1275_probe, 858 836 .id_table = adm1275_id, 859 837 }; 860 838
+1 -1
drivers/hwmon/pmbus/bel-pfe.c
··· 120 120 .driver = { 121 121 .name = "bel-pfe", 122 122 }, 123 - .probe_new = pfe_pmbus_probe, 123 + .probe = pfe_pmbus_probe, 124 124 .id_table = pfe_device_id, 125 125 }; 126 126
+1 -1
drivers/hwmon/pmbus/bpa-rs600.c
··· 196 196 .name = "bpa-rs600", 197 197 .of_match_table = of_match_ptr(bpa_rs600_of_match), 198 198 }, 199 - .probe_new = bpa_rs600_probe, 199 + .probe = bpa_rs600_probe, 200 200 .id_table = bpa_rs600_id, 201 201 }; 202 202
+1 -1
drivers/hwmon/pmbus/delta-ahe50dc-fan.c
··· 119 119 .name = "ahe50dc_fan", 120 120 .of_match_table = of_match_ptr(ahe50dc_fan_of_match), 121 121 }, 122 - .probe_new = ahe50dc_fan_probe, 122 + .probe = ahe50dc_fan_probe, 123 123 .id_table = ahe50dc_fan_id, 124 124 }; 125 125 module_i2c_driver(ahe50dc_fan_driver);
+1 -1
drivers/hwmon/pmbus/dps920ab.c
··· 195 195 .name = "dps920ab", 196 196 .of_match_table = of_match_ptr(dps920ab_of_match), 197 197 }, 198 - .probe_new = dps920ab_probe, 198 + .probe = dps920ab_probe, 199 199 }; 200 200 201 201 module_i2c_driver(dps920ab_driver);
+1 -1
drivers/hwmon/pmbus/fsp-3y.c
··· 282 282 .driver = { 283 283 .name = "fsp3y", 284 284 }, 285 - .probe_new = fsp3y_probe, 285 + .probe = fsp3y_probe, 286 286 .id_table = fsp3y_id 287 287 }; 288 288
+1 -1
drivers/hwmon/pmbus/ibm-cffps.c
··· 605 605 .name = "ibm-cffps", 606 606 .of_match_table = ibm_cffps_of_match, 607 607 }, 608 - .probe_new = ibm_cffps_probe, 608 + .probe = ibm_cffps_probe, 609 609 .id_table = ibm_cffps_id, 610 610 }; 611 611
+1 -1
drivers/hwmon/pmbus/inspur-ipsps.c
··· 215 215 .name = "inspur-ipsps", 216 216 .of_match_table = of_match_ptr(ipsps_of_match), 217 217 }, 218 - .probe_new = ipsps_probe, 218 + .probe = ipsps_probe, 219 219 .id_table = ipsps_id, 220 220 }; 221 221
+1 -1
drivers/hwmon/pmbus/ir35221.c
··· 136 136 .driver = { 137 137 .name = "ir35221", 138 138 }, 139 - .probe_new = ir35221_probe, 139 + .probe = ir35221_probe, 140 140 .id_table = ir35221_id, 141 141 }; 142 142
+1 -1
drivers/hwmon/pmbus/ir36021.c
··· 68 68 .name = "ir36021", 69 69 .of_match_table = of_match_ptr(ir36021_of_id), 70 70 }, 71 - .probe_new = ir36021_probe, 71 + .probe = ir36021_probe, 72 72 .id_table = ir36021_id, 73 73 }; 74 74
+1 -1
drivers/hwmon/pmbus/ir38064.c
··· 78 78 .name = "ir38064", 79 79 .of_match_table = of_match_ptr(ir38064_of_match), 80 80 }, 81 - .probe_new = ir38064_probe, 81 + .probe = ir38064_probe, 82 82 .id_table = ir38064_id, 83 83 }; 84 84
+1 -1
drivers/hwmon/pmbus/irps5401.c
··· 54 54 .driver = { 55 55 .name = "irps5401", 56 56 }, 57 - .probe_new = irps5401_probe, 57 + .probe = irps5401_probe, 58 58 .id_table = irps5401_id, 59 59 }; 60 60
+1 -1
drivers/hwmon/pmbus/isl68137.c
··· 323 323 .driver = { 324 324 .name = "isl68137", 325 325 }, 326 - .probe_new = isl68137_probe, 326 + .probe = isl68137_probe, 327 327 .id_table = raa_dmpvr_id, 328 328 }; 329 329
+1 -1
drivers/hwmon/pmbus/lm25066.c
··· 568 568 .name = "lm25066", 569 569 .of_match_table = of_match_ptr(lm25066_of_match), 570 570 }, 571 - .probe_new = lm25066_probe, 571 + .probe = lm25066_probe, 572 572 .id_table = lm25066_id, 573 573 }; 574 574
+1 -1
drivers/hwmon/pmbus/lt7182s.c
··· 183 183 .name = "lt7182s", 184 184 .of_match_table = of_match_ptr(lt7182s_of_match), 185 185 }, 186 - .probe_new = lt7182s_probe, 186 + .probe = lt7182s_probe, 187 187 .id_table = lt7182s_id, 188 188 }; 189 189
+1 -1
drivers/hwmon/pmbus/ltc2978.c
··· 927 927 .name = "ltc2978", 928 928 .of_match_table = of_match_ptr(ltc2978_of_match), 929 929 }, 930 - .probe_new = ltc2978_probe, 930 + .probe = ltc2978_probe, 931 931 .id_table = ltc2978_id, 932 932 }; 933 933
+1 -1
drivers/hwmon/pmbus/ltc3815.c
··· 199 199 .driver = { 200 200 .name = "ltc3815", 201 201 }, 202 - .probe_new = ltc3815_probe, 202 + .probe = ltc3815_probe, 203 203 .id_table = ltc3815_id, 204 204 }; 205 205
+1 -1
drivers/hwmon/pmbus/max15301.c
··· 178 178 .driver = { 179 179 .name = "max15301", 180 180 }, 181 - .probe_new = max15301_probe, 181 + .probe = max15301_probe, 182 182 .id_table = max15301_id, 183 183 }; 184 184
+1 -1
drivers/hwmon/pmbus/max16064.c
··· 102 102 .driver = { 103 103 .name = "max16064", 104 104 }, 105 - .probe_new = max16064_probe, 105 + .probe = max16064_probe, 106 106 .id_table = max16064_id, 107 107 }; 108 108
+4 -4
drivers/hwmon/pmbus/max16601.c
··· 283 283 return -ENODEV; 284 284 285 285 /* 286 - * PMBUS_IC_DEVICE_ID is expected to return MAX1660[012]y.xx" or 287 - * "MAX16500y.xx".cdxxcccccccccc 286 + * PMBUS_IC_DEVICE_ID is expected to return MAX1660[012]y.xx", 287 + * "MAX16500y.xx".cdxxcccccccccc, or "MAX16508y.xx". 288 288 */ 289 - if (!strncmp(buf, "MAX16500", 8)) { 289 + if (!strncmp(buf, "MAX16500", 8) || !strncmp(buf, "MAX16508", 8)) { 290 290 id = max16508; 291 291 } else if (!strncmp(buf, "MAX16600", 8)) { 292 292 id = max16600; ··· 357 357 .driver = { 358 358 .name = "max16601", 359 359 }, 360 - .probe_new = max16601_probe, 360 + .probe = max16601_probe, 361 361 .id_table = max16601_id, 362 362 }; 363 363
+1 -1
drivers/hwmon/pmbus/max20730.c
··· 776 776 .name = "max20730", 777 777 .of_match_table = max20730_of_match, 778 778 }, 779 - .probe_new = max20730_probe, 779 + .probe = max20730_probe, 780 780 .id_table = max20730_id, 781 781 }; 782 782
+1 -1
drivers/hwmon/pmbus/max20751.c
··· 42 42 .driver = { 43 43 .name = "max20751", 44 44 }, 45 - .probe_new = max20751_probe, 45 + .probe = max20751_probe, 46 46 .id_table = max20751_id, 47 47 }; 48 48
+1 -1
drivers/hwmon/pmbus/max31785.c
··· 394 394 .name = "max31785", 395 395 .of_match_table = max31785_of_match, 396 396 }, 397 - .probe_new = max31785_probe, 397 + .probe = max31785_probe, 398 398 .id_table = max31785_id, 399 399 }; 400 400
+1 -1
drivers/hwmon/pmbus/max34440.c
··· 520 520 .driver = { 521 521 .name = "max34440", 522 522 }, 523 - .probe_new = max34440_probe, 523 + .probe = max34440_probe, 524 524 .id_table = max34440_id, 525 525 }; 526 526
+1 -1
drivers/hwmon/pmbus/max8688.c
··· 182 182 .driver = { 183 183 .name = "max8688", 184 184 }, 185 - .probe_new = max8688_probe, 185 + .probe = max8688_probe, 186 186 .id_table = max8688_id, 187 187 }; 188 188
+1 -1
drivers/hwmon/pmbus/mp2888.c
··· 395 395 .name = "mp2888", 396 396 .of_match_table = of_match_ptr(mp2888_of_match), 397 397 }, 398 - .probe_new = mp2888_probe, 398 + .probe = mp2888_probe, 399 399 .id_table = mp2888_id, 400 400 }; 401 401
+1 -1
drivers/hwmon/pmbus/mp2975.c
··· 757 757 .name = "mp2975", 758 758 .of_match_table = of_match_ptr(mp2975_of_match), 759 759 }, 760 - .probe_new = mp2975_probe, 760 + .probe = mp2975_probe, 761 761 .id_table = mp2975_id, 762 762 }; 763 763
+1 -1
drivers/hwmon/pmbus/mp5023.c
··· 56 56 .name = "mp5023", 57 57 .of_match_table = of_match_ptr(mp5023_of_match), 58 58 }, 59 - .probe_new = mp5023_probe, 59 + .probe = mp5023_probe, 60 60 }; 61 61 62 62 module_i2c_driver(mp5023_driver);
+1 -1
drivers/hwmon/pmbus/mpq7932.c
··· 145 145 .name = "mpq7932", 146 146 .of_match_table = mpq7932_of_match, 147 147 }, 148 - .probe_new = mpq7932_probe, 148 + .probe = mpq7932_probe, 149 149 .id_table = mpq7932_id, 150 150 }; 151 151 module_i2c_driver(mpq7932_regulator_driver);
+1 -1
drivers/hwmon/pmbus/pim4328.c
··· 221 221 .driver = { 222 222 .name = "pim4328", 223 223 }, 224 - .probe_new = pim4328_probe, 224 + .probe = pim4328_probe, 225 225 .id_table = pim4328_id, 226 226 }; 227 227
+1 -1
drivers/hwmon/pmbus/pli1209bc.c
··· 134 134 .name = "pli1209bc", 135 135 .of_match_table = of_match_ptr(pli1209bc_of_match), 136 136 }, 137 - .probe_new = pli1209bc_probe, 137 + .probe = pli1209bc_probe, 138 138 .id_table = pli1209bc_id, 139 139 }; 140 140
+1 -1
drivers/hwmon/pmbus/pm6764tr.c
··· 64 64 .name = "pm6764tr", 65 65 .of_match_table = of_match_ptr(pm6764tr_of_match), 66 66 }, 67 - .probe_new = pm6764tr_probe, 67 + .probe = pm6764tr_probe, 68 68 .id_table = pm6764tr_id, 69 69 }; 70 70
+1 -1
drivers/hwmon/pmbus/pmbus.c
··· 252 252 .driver = { 253 253 .name = "pmbus", 254 254 }, 255 - .probe_new = pmbus_probe, 255 + .probe = pmbus_probe, 256 256 .id_table = pmbus_id, 257 257 }; 258 258
+1 -1
drivers/hwmon/pmbus/pxe1610.c
··· 139 139 .driver = { 140 140 .name = "pxe1610", 141 141 }, 142 - .probe_new = pxe1610_probe, 142 + .probe = pxe1610_probe, 143 143 .id_table = pxe1610_id, 144 144 }; 145 145
+1 -1
drivers/hwmon/pmbus/q54sj108a2.c
··· 412 412 .name = "q54sj108a2", 413 413 .of_match_table = q54sj108a2_of_match, 414 414 }, 415 - .probe_new = q54sj108a2_probe, 415 + .probe = q54sj108a2_probe, 416 416 .id_table = q54sj108a2_id, 417 417 }; 418 418
+1 -1
drivers/hwmon/pmbus/stpddc60.c
··· 237 237 .driver = { 238 238 .name = "stpddc60", 239 239 }, 240 - .probe_new = stpddc60_probe, 240 + .probe = stpddc60_probe, 241 241 .id_table = stpddc60_id, 242 242 }; 243 243
+1 -1
drivers/hwmon/pmbus/tda38640.c
··· 62 62 .name = "tda38640", 63 63 .of_match_table = of_match_ptr(tda38640_of_match), 64 64 }, 65 - .probe_new = tda38640_probe, 65 + .probe = tda38640_probe, 66 66 .id_table = tda38640_id, 67 67 }; 68 68
+1 -1
drivers/hwmon/pmbus/tps40422.c
··· 42 42 .driver = { 43 43 .name = "tps40422", 44 44 }, 45 - .probe_new = tps40422_probe, 45 + .probe = tps40422_probe, 46 46 .id_table = tps40422_id, 47 47 }; 48 48
+1 -1
drivers/hwmon/pmbus/tps53679.c
··· 299 299 .name = "tps53679", 300 300 .of_match_table = of_match_ptr(tps53679_of_match), 301 301 }, 302 - .probe_new = tps53679_probe, 302 + .probe = tps53679_probe, 303 303 .id_table = tps53679_id, 304 304 }; 305 305
+1 -1
drivers/hwmon/pmbus/tps546d24.c
··· 59 59 .name = "tps546d24", 60 60 .of_match_table = of_match_ptr(tps546d24_of_match), 61 61 }, 62 - .probe_new = tps546d24_probe, 62 + .probe = tps546d24_probe, 63 63 .id_table = tps546d24_id, 64 64 }; 65 65
+1 -3
drivers/hwmon/pmbus/ucd9000.c
··· 512 512 return -ENOENT; 513 513 514 514 data->debugfs = debugfs_create_dir(client->name, debugfs); 515 - if (!data->debugfs) 516 - return -ENOENT; 517 515 518 516 /* 519 517 * Of the chips this driver supports, only the UCD9090, UCD90160, ··· 693 695 .name = "ucd9000", 694 696 .of_match_table = of_match_ptr(ucd9000_of_match), 695 697 }, 696 - .probe_new = ucd9000_probe, 698 + .probe = ucd9000_probe, 697 699 .id_table = ucd9000_id, 698 700 }; 699 701
+1 -1
drivers/hwmon/pmbus/ucd9200.c
··· 200 200 .name = "ucd9200", 201 201 .of_match_table = of_match_ptr(ucd9200_of_match), 202 202 }, 203 - .probe_new = ucd9200_probe, 203 + .probe = ucd9200_probe, 204 204 .id_table = ucd9200_id, 205 205 }; 206 206
+1 -1
drivers/hwmon/pmbus/xdpe12284.c
··· 185 185 .name = "xdpe12284", 186 186 .of_match_table = of_match_ptr(xdpe122_of_match), 187 187 }, 188 - .probe_new = xdpe122_probe, 188 + .probe = xdpe122_probe, 189 189 .id_table = xdpe122_id, 190 190 }; 191 191
+1 -1
drivers/hwmon/pmbus/xdpe152c4.c
··· 63 63 .name = "xdpe152c4", 64 64 .of_match_table = of_match_ptr(xdpe152_of_match), 65 65 }, 66 - .probe_new = xdpe152_probe, 66 + .probe = xdpe152_probe, 67 67 .id_table = xdpe152_id, 68 68 }; 69 69
+1 -1
drivers/hwmon/pmbus/zl6100.c
··· 461 461 .driver = { 462 462 .name = "zl6100", 463 463 }, 464 - .probe_new = zl6100_probe, 464 + .probe = zl6100_probe, 465 465 .id_table = zl6100_id, 466 466 }; 467 467
+1 -1
drivers/hwmon/powr1220.c
··· 327 327 .driver = { 328 328 .name = "powr1220", 329 329 }, 330 - .probe_new = powr1220_probe, 330 + .probe = powr1220_probe, 331 331 .id_table = powr1220_ids, 332 332 }; 333 333
+1 -1
drivers/hwmon/sbrmi.c
··· 347 347 .name = "sbrmi", 348 348 .of_match_table = of_match_ptr(sbrmi_of_match), 349 349 }, 350 - .probe_new = sbrmi_probe, 350 + .probe = sbrmi_probe, 351 351 .id_table = sbrmi_id, 352 352 }; 353 353
+1 -1
drivers/hwmon/sbtsi_temp.c
··· 238 238 .name = "sbtsi", 239 239 .of_match_table = of_match_ptr(sbtsi_of_match), 240 240 }, 241 - .probe_new = sbtsi_probe, 241 + .probe = sbtsi_probe, 242 242 .id_table = sbtsi_id, 243 243 }; 244 244
+1 -1
drivers/hwmon/sht21.c
··· 285 285 286 286 static struct i2c_driver sht21_driver = { 287 287 .driver.name = "sht21", 288 - .probe_new = sht21_probe, 288 + .probe = sht21_probe, 289 289 .id_table = sht21_id, 290 290 }; 291 291
+90 -35
drivers/hwmon/sht3x.c
··· 20 20 #include <linux/module.h> 21 21 #include <linux/slab.h> 22 22 #include <linux/jiffies.h> 23 - #include <linux/platform_data/sht3x.h> 24 23 25 - /* commands (high precision mode) */ 26 - static const unsigned char sht3x_cmd_measure_blocking_hpm[] = { 0x2c, 0x06 }; 27 - static const unsigned char sht3x_cmd_measure_nonblocking_hpm[] = { 0x24, 0x00 }; 24 + /* commands (high repeatability mode) */ 25 + static const unsigned char sht3x_cmd_measure_single_hpm[] = { 0x24, 0x00 }; 28 26 29 - /* commands (low power mode) */ 30 - static const unsigned char sht3x_cmd_measure_blocking_lpm[] = { 0x2c, 0x10 }; 31 - static const unsigned char sht3x_cmd_measure_nonblocking_lpm[] = { 0x24, 0x16 }; 27 + /* commands (medium repeatability mode) */ 28 + static const unsigned char sht3x_cmd_measure_single_mpm[] = { 0x24, 0x0b }; 29 + 30 + /* commands (low repeatability mode) */ 31 + static const unsigned char sht3x_cmd_measure_single_lpm[] = { 0x24, 0x16 }; 32 32 33 33 /* commands for periodic mode */ 34 34 static const unsigned char sht3x_cmd_measure_periodic_mode[] = { 0xe0, 0x00 }; ··· 42 42 static const unsigned char sht3x_cmd_read_status_reg[] = { 0xf3, 0x2d }; 43 43 static const unsigned char sht3x_cmd_clear_status_reg[] = { 0x30, 0x41 }; 44 44 45 - /* delays for non-blocking i2c commands, both in us */ 46 - #define SHT3X_NONBLOCKING_WAIT_TIME_HPM 15000 47 - #define SHT3X_NONBLOCKING_WAIT_TIME_LPM 4000 45 + /* delays for single-shot mode i2c commands, both in us */ 46 + #define SHT3X_SINGLE_WAIT_TIME_HPM 15000 47 + #define SHT3X_SINGLE_WAIT_TIME_MPM 6000 48 + #define SHT3X_SINGLE_WAIT_TIME_LPM 4000 48 49 49 50 #define SHT3X_WORD_LEN 2 50 51 #define SHT3X_CMD_LENGTH 2 ··· 70 69 limit_min_hyst, 71 70 }; 72 71 72 + enum sht3x_repeatability { 73 + low_repeatability, 74 + medium_repeatability, 75 + high_repeatability, 76 + }; 77 + 73 78 DECLARE_CRC8_TABLE(sht3x_crc8_table); 74 79 75 - /* periodic measure commands (high precision mode) */ 80 + /* periodic measure commands (high repeatability mode) */ 76 81 static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] = { 77 82 /* 0.5 measurements per second */ 78 83 {0x20, 0x32}, ··· 92 85 {0x27, 0x37}, 93 86 }; 94 87 95 - /* periodic measure commands (low power mode) */ 88 + /* periodic measure commands (medium repeatability) */ 89 + static const char periodic_measure_commands_mpm[][SHT3X_CMD_LENGTH] = { 90 + /* 0.5 measurements per second */ 91 + {0x20, 0x24}, 92 + /* 1 measurements per second */ 93 + {0x21, 0x26}, 94 + /* 2 measurements per second */ 95 + {0x22, 0x20}, 96 + /* 4 measurements per second */ 97 + {0x23, 0x22}, 98 + /* 10 measurements per second */ 99 + {0x27, 0x21}, 100 + }; 101 + 102 + /* periodic measure commands (low repeatability mode) */ 96 103 static const char periodic_measure_commands_lpm[][SHT3X_CMD_LENGTH] = { 97 104 /* 0.5 measurements per second */ 98 105 {0x20, 0x2f}, ··· 156 135 const unsigned char *command; 157 136 u32 wait_time; /* in us*/ 158 137 unsigned long last_update; /* last update in periodic mode*/ 159 - 160 - struct sht3x_platform_data setup; 138 + enum sht3x_repeatability repeatability; 161 139 162 140 /* 163 141 * cached values for temperature and humidity and limits ··· 453 433 static void sht3x_select_command(struct sht3x_data *data) 454 434 { 455 435 /* 456 - * In blocking mode (clock stretching mode) the I2C bus 457 - * is blocked for other traffic, thus the call to i2c_master_recv() 458 - * will wait until the data is ready. For non blocking mode, we 459 - * have to wait ourselves. 436 + * For single-shot mode, only non blocking mode is support, 437 + * we have to wait ourselves for result. 460 438 */ 461 439 if (data->mode > 0) { 462 440 data->command = sht3x_cmd_measure_periodic_mode; 463 441 data->wait_time = 0; 464 - } else if (data->setup.blocking_io) { 465 - data->command = data->setup.high_precision ? 466 - sht3x_cmd_measure_blocking_hpm : 467 - sht3x_cmd_measure_blocking_lpm; 468 - data->wait_time = 0; 469 442 } else { 470 - if (data->setup.high_precision) { 471 - data->command = sht3x_cmd_measure_nonblocking_hpm; 472 - data->wait_time = SHT3X_NONBLOCKING_WAIT_TIME_HPM; 443 + if (data->repeatability == high_repeatability) { 444 + data->command = sht3x_cmd_measure_single_hpm; 445 + data->wait_time = SHT3X_SINGLE_WAIT_TIME_HPM; 446 + } else if (data->repeatability == medium_repeatability) { 447 + data->command = sht3x_cmd_measure_single_mpm; 448 + data->wait_time = SHT3X_SINGLE_WAIT_TIME_MPM; 473 449 } else { 474 - data->command = sht3x_cmd_measure_nonblocking_lpm; 475 - data->wait_time = SHT3X_NONBLOCKING_WAIT_TIME_LPM; 450 + data->command = sht3x_cmd_measure_single_lpm; 451 + data->wait_time = SHT3X_SINGLE_WAIT_TIME_LPM; 476 452 } 477 453 } 478 454 } ··· 611 595 } 612 596 613 597 if (mode > 0) { 614 - if (data->setup.high_precision) 598 + if (data->repeatability == high_repeatability) 615 599 command = periodic_measure_commands_hpm[mode - 1]; 600 + else if (data->repeatability == medium_repeatability) 601 + command = periodic_measure_commands_mpm[mode - 1]; 616 602 else 617 603 command = periodic_measure_commands_lpm[mode - 1]; 618 604 ··· 637 619 return count; 638 620 } 639 621 622 + static ssize_t repeatability_show(struct device *dev, 623 + struct device_attribute *attr, 624 + char *buf) 625 + { 626 + struct sht3x_data *data = dev_get_drvdata(dev); 627 + 628 + return sysfs_emit(buf, "%d\n", data->repeatability); 629 + } 630 + 631 + static ssize_t repeatability_store(struct device *dev, 632 + struct device_attribute *attr, 633 + const char *buf, 634 + size_t count) 635 + { 636 + int ret; 637 + u8 val; 638 + 639 + struct sht3x_data *data = dev_get_drvdata(dev); 640 + 641 + ret = kstrtou8(buf, 0, &val); 642 + if (ret) 643 + return ret; 644 + 645 + if (val > 2) 646 + return -EINVAL; 647 + 648 + data->repeatability = val; 649 + 650 + return count; 651 + } 652 + 640 653 static SENSOR_DEVICE_ATTR_RO(temp1_input, temp1_input, 0); 641 654 static SENSOR_DEVICE_ATTR_RO(humidity1_input, humidity1_input, 0); 642 655 static SENSOR_DEVICE_ATTR_RW(temp1_max, temp1_limit, limit_max); ··· 684 635 static SENSOR_DEVICE_ATTR_RO(humidity1_alarm, humidity1_alarm, 0); 685 636 static SENSOR_DEVICE_ATTR_RW(heater_enable, heater_enable, 0); 686 637 static SENSOR_DEVICE_ATTR_RW(update_interval, update_interval, 0); 638 + static SENSOR_DEVICE_ATTR_RW(repeatability, repeatability, 0); 687 639 688 640 static struct attribute *sht3x_attrs[] = { 689 641 &sensor_dev_attr_temp1_input.dev_attr.attr, ··· 701 651 &sensor_dev_attr_humidity1_alarm.dev_attr.attr, 702 652 &sensor_dev_attr_heater_enable.dev_attr.attr, 703 653 &sensor_dev_attr_update_interval.dev_attr.attr, 654 + &sensor_dev_attr_repeatability.dev_attr.attr, 704 655 NULL 705 656 }; 706 657 707 658 static struct attribute *sts3x_attrs[] = { 708 659 &sensor_dev_attr_temp1_input.dev_attr.attr, 660 + &sensor_dev_attr_temp1_max.dev_attr.attr, 661 + &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, 662 + &sensor_dev_attr_temp1_min.dev_attr.attr, 663 + &sensor_dev_attr_temp1_min_hyst.dev_attr.attr, 664 + &sensor_dev_attr_temp1_alarm.dev_attr.attr, 665 + &sensor_dev_attr_heater_enable.dev_attr.attr, 666 + &sensor_dev_attr_update_interval.dev_attr.attr, 667 + &sensor_dev_attr_repeatability.dev_attr.attr, 709 668 NULL 710 669 }; 711 670 ··· 749 690 if (!data) 750 691 return -ENOMEM; 751 692 752 - data->setup.blocking_io = false; 753 - data->setup.high_precision = true; 693 + data->repeatability = high_repeatability; 754 694 data->mode = 0; 755 695 data->last_update = jiffies - msecs_to_jiffies(3000); 756 696 data->client = client; 757 697 crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL); 758 - 759 - if (client->dev.platform_data) 760 - data->setup = *(struct sht3x_platform_data *)dev->platform_data; 761 698 762 699 sht3x_select_command(data); 763 700 ··· 798 743 799 744 static struct i2c_driver sht3x_i2c_driver = { 800 745 .driver.name = "sht3x", 801 - .probe_new = sht3x_probe, 746 + .probe = sht3x_probe, 802 747 .id_table = sht3x_ids, 803 748 }; 804 749
+1 -1
drivers/hwmon/sht4x.c
··· 291 291 .name = "sht4x", 292 292 .of_match_table = sht4x_of_match, 293 293 }, 294 - .probe_new = sht4x_probe, 294 + .probe = sht4x_probe, 295 295 .id_table = sht4x_id, 296 296 }; 297 297
+1 -1
drivers/hwmon/shtc1.c
··· 279 279 .name = "shtc1", 280 280 .of_match_table = shtc1_of_match, 281 281 }, 282 - .probe_new = shtc1_probe, 282 + .probe = shtc1_probe, 283 283 .id_table = shtc1_id, 284 284 }; 285 285
+1 -1
drivers/hwmon/smm665.c
··· 694 694 .driver = { 695 695 .name = "smm665", 696 696 }, 697 - .probe_new = smm665_probe, 697 + .probe = smm665_probe, 698 698 .remove = smm665_remove, 699 699 .id_table = smm665_id, 700 700 };
+1 -1
drivers/hwmon/smsc47m192.c
··· 628 628 .driver = { 629 629 .name = "smsc47m192", 630 630 }, 631 - .probe_new = smsc47m192_probe, 631 + .probe = smsc47m192_probe, 632 632 .id_table = smsc47m192_id, 633 633 .detect = smsc47m192_detect, 634 634 .address_list = normal_i2c,
+1 -1
drivers/hwmon/stts751.c
··· 821 821 .name = DEVNAME, 822 822 .of_match_table = of_match_ptr(stts751_of_match), 823 823 }, 824 - .probe_new = stts751_probe, 824 + .probe = stts751_probe, 825 825 .id_table = stts751_id, 826 826 .detect = stts751_detect, 827 827 .alert = stts751_alert,
+1 -1
drivers/hwmon/tc654.c
··· 561 561 .driver = { 562 562 .name = "tc654", 563 563 }, 564 - .probe_new = tc654_probe, 564 + .probe = tc654_probe, 565 565 .id_table = tc654_id, 566 566 }; 567 567
+1 -1
drivers/hwmon/tc74.c
··· 160 160 .driver = { 161 161 .name = "tc74", 162 162 }, 163 - .probe_new = tc74_probe, 163 + .probe = tc74_probe, 164 164 .id_table = tc74_id, 165 165 }; 166 166
+1 -1
drivers/hwmon/thmc50.c
··· 420 420 .driver = { 421 421 .name = "thmc50", 422 422 }, 423 - .probe_new = thmc50_probe, 423 + .probe = thmc50_probe, 424 424 .id_table = thmc50_id, 425 425 .detect = thmc50_detect, 426 426 .address_list = normal_i2c,
+2 -2
drivers/hwmon/tmp102.c
··· 184 184 .writeable_reg = tmp102_is_writeable_reg, 185 185 .volatile_reg = tmp102_is_volatile_reg, 186 186 .val_format_endian = REGMAP_ENDIAN_BIG, 187 - .cache_type = REGCACHE_RBTREE, 187 + .cache_type = REGCACHE_MAPLE, 188 188 .use_single_read = true, 189 189 .use_single_write = true, 190 190 }; ··· 301 301 .driver.name = DRIVER_NAME, 302 302 .driver.of_match_table = of_match_ptr(tmp102_of_match), 303 303 .driver.pm = pm_sleep_ptr(&tmp102_dev_pm_ops), 304 - .probe_new = tmp102_probe, 304 + .probe = tmp102_probe, 305 305 .id_table = tmp102_id, 306 306 }; 307 307
+1 -1
drivers/hwmon/tmp103.c
··· 214 214 .of_match_table = of_match_ptr(tmp103_of_match), 215 215 .pm = pm_sleep_ptr(&tmp103_dev_pm_ops), 216 216 }, 217 - .probe_new = tmp103_probe, 217 + .probe = tmp103_probe, 218 218 .id_table = tmp103_id, 219 219 }; 220 220
+2 -2
drivers/hwmon/tmp108.c
··· 318 318 .writeable_reg = tmp108_is_writeable_reg, 319 319 .volatile_reg = tmp108_is_volatile_reg, 320 320 .val_format_endian = REGMAP_ENDIAN_BIG, 321 - .cache_type = REGCACHE_RBTREE, 321 + .cache_type = REGCACHE_MAPLE, 322 322 .use_single_read = true, 323 323 .use_single_write = true, 324 324 }; ··· 432 432 .pm = pm_sleep_ptr(&tmp108_dev_pm_ops), 433 433 .of_match_table = of_match_ptr(tmp108_of_ids), 434 434 }, 435 - .probe_new = tmp108_probe, 435 + .probe = tmp108_probe, 436 436 .id_table = tmp108_i2c_ids, 437 437 }; 438 438
+1 -1
drivers/hwmon/tmp401.c
··· 766 766 .name = "tmp401", 767 767 .of_match_table = of_match_ptr(tmp4xx_of_match), 768 768 }, 769 - .probe_new = tmp401_probe, 769 + .probe = tmp401_probe, 770 770 .id_table = tmp401_id, 771 771 .detect = tmp401_detect, 772 772 .address_list = normal_i2c,
+1 -1
drivers/hwmon/tmp421.c
··· 487 487 .name = "tmp421", 488 488 .of_match_table = of_match_ptr(tmp421_of_match), 489 489 }, 490 - .probe_new = tmp421_probe, 490 + .probe = tmp421_probe, 491 491 .id_table = tmp421_id, 492 492 .detect = tmp421_detect, 493 493 .address_list = normal_i2c,
+2 -2
drivers/hwmon/tmp464.c
··· 644 644 .max_register = TMP464_DEVICE_ID_REG, 645 645 .volatile_reg = tmp464_is_volatile_reg, 646 646 .val_format_endian = REGMAP_ENDIAN_BIG, 647 - .cache_type = REGCACHE_RBTREE, 647 + .cache_type = REGCACHE_MAPLE, 648 648 .use_single_read = true, 649 649 .use_single_write = true, 650 650 }; ··· 699 699 .name = "tmp464", 700 700 .of_match_table = of_match_ptr(tmp464_of_match), 701 701 }, 702 - .probe_new = tmp464_probe, 702 + .probe = tmp464_probe, 703 703 .id_table = tmp464_id, 704 704 .detect = tmp464_detect, 705 705 .address_list = normal_i2c,
+1 -1
drivers/hwmon/tmp513.c
··· 760 760 .name = "tmp51x", 761 761 .of_match_table = tmp51x_of_match, 762 762 }, 763 - .probe_new = tmp51x_probe, 763 + .probe = tmp51x_probe, 764 764 .id_table = tmp51x_id, 765 765 }; 766 766
+1 -1
drivers/hwmon/tps23861.c
··· 581 581 MODULE_DEVICE_TABLE(of, tps23861_of_match); 582 582 583 583 static struct i2c_driver tps23861_driver = { 584 - .probe_new = tps23861_probe, 584 + .probe = tps23861_probe, 585 585 .remove = tps23861_remove, 586 586 .driver = { 587 587 .name = "tps23861",
+1 -1
drivers/hwmon/w83773g.c
··· 295 295 .name = "w83773g", 296 296 .of_match_table = of_match_ptr(w83773_of_match), 297 297 }, 298 - .probe_new = w83773_probe, 298 + .probe = w83773_probe, 299 299 .id_table = w83773_id, 300 300 }; 301 301
+1 -1
drivers/hwmon/w83781d.c
··· 1585 1585 .name = "w83781d", 1586 1586 .of_match_table = w83781d_of_match, 1587 1587 }, 1588 - .probe_new = w83781d_probe, 1588 + .probe = w83781d_probe, 1589 1589 .remove = w83781d_remove, 1590 1590 .id_table = w83781d_ids, 1591 1591 .detect = w83781d_detect,
+1 -1
drivers/hwmon/w83791d.c
··· 338 338 .driver = { 339 339 .name = "w83791d", 340 340 }, 341 - .probe_new = w83791d_probe, 341 + .probe = w83791d_probe, 342 342 .remove = w83791d_remove, 343 343 .id_table = w83791d_id, 344 344 .detect = w83791d_detect,
+1 -1
drivers/hwmon/w83792d.c
··· 306 306 .driver = { 307 307 .name = "w83792d", 308 308 }, 309 - .probe_new = w83792d_probe, 309 + .probe = w83792d_probe, 310 310 .remove = w83792d_remove, 311 311 .id_table = w83792d_id, 312 312 .detect = w83792d_detect,
+1 -1
drivers/hwmon/w83793.c
··· 301 301 .driver = { 302 302 .name = "w83793", 303 303 }, 304 - .probe_new = w83793_probe, 304 + .probe = w83793_probe, 305 305 .remove = w83793_remove, 306 306 .id_table = w83793_id, 307 307 .detect = w83793_detect,
+1 -1
drivers/hwmon/w83795.c
··· 2255 2255 .driver = { 2256 2256 .name = "w83795", 2257 2257 }, 2258 - .probe_new = w83795_probe, 2258 + .probe = w83795_probe, 2259 2259 .remove = w83795_remove, 2260 2260 .id_table = w83795_id, 2261 2261
+1 -1
drivers/hwmon/w83l785ts.c
··· 84 84 .driver = { 85 85 .name = "w83l785ts", 86 86 }, 87 - .probe_new = w83l785ts_probe, 87 + .probe = w83l785ts_probe, 88 88 .remove = w83l785ts_remove, 89 89 .id_table = w83l785ts_id, 90 90 .detect = w83l785ts_detect,
+1 -1
drivers/hwmon/w83l786ng.c
··· 751 751 .driver = { 752 752 .name = "w83l786ng", 753 753 }, 754 - .probe_new = w83l786ng_probe, 754 + .probe = w83l786ng_probe, 755 755 .id_table = w83l786ng_id, 756 756 .detect = w83l786ng_detect, 757 757 .address_list = normal_i2c,
+10
include/linux/hwmon.h
··· 44 44 hwmon_chip_in_samples, 45 45 hwmon_chip_power_samples, 46 46 hwmon_chip_temp_samples, 47 + hwmon_chip_beep_enable, 47 48 }; 48 49 49 50 #define HWMON_C_TEMP_RESET_HISTORY BIT(hwmon_chip_temp_reset_history) ··· 59 58 #define HWMON_C_IN_SAMPLES BIT(hwmon_chip_in_samples) 60 59 #define HWMON_C_POWER_SAMPLES BIT(hwmon_chip_power_samples) 61 60 #define HWMON_C_TEMP_SAMPLES BIT(hwmon_chip_temp_samples) 61 + #define HWMON_C_BEEP_ENABLE BIT(hwmon_chip_beep_enable) 62 62 63 63 enum hwmon_temp_attributes { 64 64 hwmon_temp_enable, ··· 89 87 hwmon_temp_reset_history, 90 88 hwmon_temp_rated_min, 91 89 hwmon_temp_rated_max, 90 + hwmon_temp_beep, 92 91 }; 93 92 94 93 #define HWMON_T_ENABLE BIT(hwmon_temp_enable) ··· 119 116 #define HWMON_T_RESET_HISTORY BIT(hwmon_temp_reset_history) 120 117 #define HWMON_T_RATED_MIN BIT(hwmon_temp_rated_min) 121 118 #define HWMON_T_RATED_MAX BIT(hwmon_temp_rated_max) 119 + #define HWMON_T_BEEP BIT(hwmon_temp_beep) 122 120 123 121 enum hwmon_in_attributes { 124 122 hwmon_in_enable, ··· 140 136 hwmon_in_crit_alarm, 141 137 hwmon_in_rated_min, 142 138 hwmon_in_rated_max, 139 + hwmon_in_beep, 143 140 }; 144 141 145 142 #define HWMON_I_ENABLE BIT(hwmon_in_enable) ··· 161 156 #define HWMON_I_CRIT_ALARM BIT(hwmon_in_crit_alarm) 162 157 #define HWMON_I_RATED_MIN BIT(hwmon_in_rated_min) 163 158 #define HWMON_I_RATED_MAX BIT(hwmon_in_rated_max) 159 + #define HWMON_I_BEEP BIT(hwmon_in_beep) 164 160 165 161 enum hwmon_curr_attributes { 166 162 hwmon_curr_enable, ··· 182 176 hwmon_curr_crit_alarm, 183 177 hwmon_curr_rated_min, 184 178 hwmon_curr_rated_max, 179 + hwmon_curr_beep, 185 180 }; 186 181 187 182 #define HWMON_C_ENABLE BIT(hwmon_curr_enable) ··· 203 196 #define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm) 204 197 #define HWMON_C_RATED_MIN BIT(hwmon_curr_rated_min) 205 198 #define HWMON_C_RATED_MAX BIT(hwmon_curr_rated_max) 199 + #define HWMON_C_BEEP BIT(hwmon_curr_beep) 206 200 207 201 enum hwmon_power_attributes { 208 202 hwmon_power_enable, ··· 320 312 hwmon_fan_min_alarm, 321 313 hwmon_fan_max_alarm, 322 314 hwmon_fan_fault, 315 + hwmon_fan_beep, 323 316 }; 324 317 325 318 #define HWMON_F_ENABLE BIT(hwmon_fan_enable) ··· 335 326 #define HWMON_F_MIN_ALARM BIT(hwmon_fan_min_alarm) 336 327 #define HWMON_F_MAX_ALARM BIT(hwmon_fan_max_alarm) 337 328 #define HWMON_F_FAULT BIT(hwmon_fan_fault) 329 + #define HWMON_F_BEEP BIT(hwmon_fan_beep) 338 330 339 331 enum hwmon_pwm_attributes { 340 332 hwmon_pwm_input,
-15
include/linux/platform_data/sht3x.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (C) 2016 Sensirion AG, Switzerland 4 - * Author: David Frey <david.frey@sensirion.com> 5 - * Author: Pascal Sachs <pascal.sachs@sensirion.com> 6 - */ 7 - 8 - #ifndef __SHT3X_H_ 9 - #define __SHT3X_H_ 10 - 11 - struct sht3x_platform_data { 12 - bool blocking_io; 13 - bool high_precision; 14 - }; 15 - #endif /* __SHT3X_H_ */