Commit Graph

5611 Commits

Author SHA1 Message Date
Stephen Rothwell
6e16033768 Merge branch 'for-mfd-next' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git
# Conflicts:
#	drivers/mfd/cs42l43.c
2024-12-20 13:12:25 +11:00
Stephen Rothwell
e24a64840a Merge branch 'hwmon-next' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 2024-12-20 11:07:37 +11:00
Ninad Palsule
de076198d1 hwmon: (pmbus/crps) Add Intel CRPS185 power supply
Add the driver to monitor Intel common redundant power supply (crps185)
with hwmon over pmbus.

Signed-off-by: Ninad Palsule <ninad@linux.ibm.com>
Link: https://lore.kernel.org/r/20241217173537.192331-3-ninad@linux.ibm.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-18 07:14:58 -08:00
Wolfram Sang
d3506653d0 hwmon: (lm75) Add NXP P3T1755 support
Add this LM75 compatible sensor which needs a separate entry because of
its default sampling time and SMBusAlert handling.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20241218074131.4351-7-wsa+renesas@sang-engineering.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-18 07:06:32 -08:00
Heiko Stuebner
9855caf5d4 hwmon: add driver for the hwmon parts of qnap-mcu devices
The MCU can be found on network-attached-storage devices made by QNAP
and provides access to fan control including reading back its RPM as
well as reading the temperature of the NAS case.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20241107114712.538976-8-heiko@sntech.de
Signed-off-by: Lee Jones <lee@kernel.org>
2024-12-17 13:14:48 +00:00
Murad Masimov
dd471e2577 hwmon: (tmp513) Fix interpretation of values of Temperature Result and Limit Registers
The values returned by the driver after processing the contents of the
Temperature Result and the Temperature Limit Registers do not correspond to
the TMP512/TMP513 specifications. A raw register value is converted to a
signed integer value by a sign extension in accordance with the algorithm
provided in the specification, but due to the off-by-one error in the sign
bit index, the result is incorrect.

According to the TMP512 and TMP513 datasheets, the Temperature Result (08h
to 0Bh) and Limit (11h to 14h) Registers are 13-bit two's complement
integer values, shifted left by 3 bits. The value is scaled by 0.0625
degrees Celsius per bit.  E.g., if regval = 1 1110 0111 0000 000, the
output should be -25 degrees, but the driver will return +487 degrees.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 59dfa75e5d ("hwmon: Add driver for Texas Instruments TMP512/513 sensor chips.")
Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
Link: https://lore.kernel.org/r/20241216173648.526-4-m.masimov@maxima.ru
[groeck: fixed description line length]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-16 15:58:25 -08:00
Murad Masimov
da1d0e6ba2 hwmon: (tmp513) Fix Current Register value interpretation
The value returned by the driver after processing the contents of the
Current Register does not correspond to the TMP512/TMP513 specifications.
A raw register value is converted to a signed integer value by a sign
extension in accordance with the algorithm provided in the specification,
but due to the off-by-one error in the sign bit index, the result is
incorrect. Moreover, negative values will be reported as large positive
due to missing sign extension from u32 to long.

According to the TMP512 and TMP513 datasheets, the Current Register (07h)
is a 16-bit two's complement integer value. E.g., if regval = 1000 0011
0000 0000, then the value must be (-32000 * lsb), but the driver will
return (33536 * lsb).

Fix off-by-one bug, and also cast data->curr_lsb_ua (which is of type u32)
to long to prevent incorrect cast for negative values.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 59dfa75e5d ("hwmon: Add driver for Texas Instruments TMP512/513 sensor chips.")
Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
Link: https://lore.kernel.org/r/20241216173648.526-3-m.masimov@maxima.ru
[groeck: Fixed description line length]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-16 15:58:25 -08:00
Murad Masimov
74d7e038fd hwmon: (tmp513) Fix interpretation of values of Shunt Voltage and Limit Registers
The values returned by the driver after processing the contents of the
Shunt Voltage Register and the Shunt Limit Registers do not correspond to
the TMP512/TMP513 specifications. A raw register value is converted to a
signed integer value by a sign extension in accordance with the algorithm
provided in the specification, but due to the off-by-one error in the sign
bit index, the result is incorrect. Moreover, the PGA shift calculated with
the tmp51x_get_pga_shift function is relevant only to the Shunt Voltage
Register, but is also applied to the Shunt Limit Registers.

According to the TMP512 and TMP513 datasheets, the Shunt Voltage Register
(04h) is 13 to 16 bit two's complement integer value, depending on the PGA
setting.  The Shunt Positive (0Ch) and Negative (0Dh) Limit Registers are
16-bit two's complement integer values. Below are some examples:

* Shunt Voltage Register
If PGA = 8, and regval = 1000 0011 0000 0000, then the decimal value must
be -32000, but the value calculated by the driver will be 33536.

* Shunt Limit Register
If regval = 1000 0011 0000 0000, then the decimal value must be -32000, but
the value calculated by the driver will be 768, if PGA = 1.

Fix sign bit index, and also correct misleading comment describing the
tmp51x_get_pga_shift function.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 59dfa75e5d ("hwmon: Add driver for Texas Instruments TMP512/513 sensor chips.")
Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
Link: https://lore.kernel.org/r/20241216173648.526-2-m.masimov@maxima.ru
[groeck: Fixed description and multi-line alignments]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-16 15:58:24 -08:00
Ninad Palsule
30062044a1 hwmon: (pmbus/core) Add PMBUS_REVISION in debugfs
Add debugfs file for the PMBUS_REVISION command. This command provides
information about PMBus protocol revision number.

Signed-off-by: Ninad Palsule <ninad@linux.ibm.com>
Link: https://lore.kernel.org/r/20241216175044.4144442-2-ninad@linux.ibm.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-16 10:44:36 -08:00
Thomas Weißschuh
0f049da5b0 hwmon: (occ/p9_sbe) Constify 'struct bin_attribute'
The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241215-sysfs-const-bin_attr-hwmon-v1-1-ea72a6a46c36@weissschuh.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-15 22:02:26 -08:00
Max Ammann
cf85760f6a hwmon: (nct6683) Add customer ID for ASRock B650 Steel Legend WiFi
This value was found on an ASRock B650 Steel Legend WiFi with an
NCT6686D chip.

Signed-off-by: Max Ammann <max@maxammann.org>
Link: https://lore.kernel.org/r/20241214102201.122851-1-max@maxammann.org
[groeck: htmldocs fix]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-15 22:02:25 -08:00
Uwe Kleine-König
a4ea3e41be hwmon: (isl28022) Drop explicit initialization of struct i2c_device_id::driver_data to 0
This driver doesn't use the driver_data member of struct i2c_device_id,
so don't explicitly initialize it.

This prepares putting driver_data in an anonymous union which requires
either no initialization or named designators. But it's also a nice
cleanup on its own.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20241204140857.1691402-2-u.kleine-koenig@baylibre.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Guenter Roeck
27cad221a4 hwmon: (tmp108) Drop of_match_ptr() protection
Limiting the scope of devicetree support to CONFIG_OF prevents use of this
driver with ACPI via PRP0001. Drop the dependency.

While at it,
- Switch of.h for mod_devicetable.h include given the use of struct
  of_device_id which is defined in that header
- Add I2C device ID for p3t1085
- Drop the unnecessary include of hwmon-sysfs.h.

Cc: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20241204141754.4051186-1-linux@roeck-us.net
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Stanislav Jakubek
bddbb9cff4 hwmon: (tmp108) Add basic regulator support
TMP108/P3T1085 are powered by the V+/VCC regulator, add support for it.

Signed-off-by: Stanislav Jakubek <stano.jakubek@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Li XingYang
fd8caceaae hwmon: (asus-ec-sensors) Add TUF GAMING X670E PLUS
Add support for TUF GAMING X670E PLUS.

Signed-off-by: Li XingYang <yanhuoguifan@gmail.com>
[groeck: Massaged description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Li XingYang
7582b7ae89 hwmon: (asus-ec-sensors) Add support for fan cpu opt on AMD 600 motherboards
According to the LibreHardwareMonitor project, LibreHardwareMonitorLib/
Hardware/Motherboard/Lpc/EC/EmbeddedController.cs file, fan cpu opt
is supported by the AMD600 EC. Registers are described as follows.

BoardFamily.Amd600, new Dictionary<ECSensor, EmbeddedControllerSource>
{
{ ECSensor.FanCPUOpt,  new EmbeddedControllerSource
("CPU Optional Fan", SensorType.Fan, 0x00b0, 2) },
}

Add FanCPUOpt support for AMD600.

Signed-off-by: Li XingYang <yanhuoguifan@gmail.com>
[groeck: Massaged subject and description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Uwe Kleine-König
2505f87eb3 hwmon: (nct6775): Actually make use of the HWMON_NCT6775 symbol namespace
DEFAULT_SYMBOL_NAMESPACE must already be defined when <linux/export.h>
is included. So move the define above the include block.

Fixes: c3963bc0a0 ("hwmon: (nct6775) Split core and platform driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Jerome Brunet
339bca4ffd hwmon: (pmbus/tps25990) Add initial support
Add initial support for the Texas Instruments TPS25990 eFuse.
This adds the basic PMBUS telemetry support for the device.

From Karol Przybylski:
  The tps25990_read_word_data function contains a block of unreachable code
  caused by the syntactic structure in the PMBUS_VIRT_READ_IIN_MAX case.

  Specifically, the return TPS25990_READ_IIN_PEAK; statement immediately
  exits the function, making the next lines unreachable.

  This patch removes the return statement, leaving the expected handling.
  Discovered in coverity: CID 1602227

Tested-by: Vaishnav Achath <vaishnav.a@ti.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
[groeck: Adjust to MODULE_IMPORT_NS API change]
[karprzy7@gmail.com: Fix unreachable code in tps25990_read_word_data]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Jerome Brunet
83bed3c159 hwmon: (pmbus/core) add wp module param
Add a module parameter to force the write protection mode of pmbus chips.

4 protections modes are provided to start with:
* 0: Remove the write protection
* 1: Disable all writes except to the WRITE_PROTECT, OPERATION,
     PAGE, ON_OFF_CONFIG and VOUT_COMMAND commands
* 2: Disable all writes except to the WRITE_PROTECT, OPERATION and
     PAGE commands
* 3: Disable all writes except to the WRITE_PROTECT command

Of course, if the parameter is not provided, the default write protection
status of the pmbus chips is left untouched.

Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Jerome Brunet
f404525775 hwmon: (pmbus/core) improve handling of write protected regulators
Writing PMBus protected registers does succeed from the smbus perspective,
even if the write is ignored by the device and a communication fault is
raised. This fault will silently be caught and cleared by pmbus irq if one
has been registered.

This means that the regulator call may return succeed although the
operation was ignored.

With this change, the operation which are not supported will be properly
flagged as such and the regulator framework won't even try to execute them.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
[groeck: Adjust to EXPORT_SYMBOL_NS_GPL API change]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Stefan Wahren
c26eef8957 hwmon: (raspberrypi) Add PM suspend/resume support
Add suspend/resume handler in order to stop firmware polling
during s2idle. This was just waking-up the system without a real
benefit.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Thomas Weißschuh
4d2ffc42f7 hwmon: (core) Avoid ifdef CONFIG_THERMAL in C source file
Using an #ifdef in a C source files to have different definitions
of the same symbol makes the code harder to read and understand.
Furthermore it makes it harder to test compilation of the different
branches.

Replace the ifdeffery with IS_ENABLED() which is just a normal
conditional.
The resulting binary is still the same as before as the compiler
optimizes away all the unused code and definitions.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Javier Carrasco
232ba88182 hwmon: (chipcap2) Switch to guard() for mutext handling
Switch to guard() for mutex handling to simplify the code, getting rid
of the 'ret = x, break; return ret;' construct and return the result
of the operation instead.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Wolfram Sang
10208399db hwmon: (isl28022) apply coding style to module init/exit
Function declarations can be in one line. module_init|exit macros should
be tied to the function.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-12-14 08:00:44 -08:00
Masahiro Yamada
ceb8bf2cea module: Convert default symbol namespace to string literal
Commit cdd30ebb1b ("module: Convert symbol namespace to string
literal") only converted MODULE_IMPORT_NS() and EXPORT_SYMBOL_NS(),
leaving DEFAULT_SYMBOL_NAMESPACE as a macro expansion.

This commit converts DEFAULT_SYMBOL_NAMESPACE in the same way to avoid
annoyance for the default namespace as well.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-03 08:22:25 -08:00
Peter Zijlstra
cdd30ebb1b module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498f ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.

Scripted using

  git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
  do
    awk -i inplace '
      /^#define EXPORT_SYMBOL_NS/ {
        gsub(/__stringify\(ns\)/, "ns");
        print;
        next;
      }
      /^#define MODULE_IMPORT_NS/ {
        gsub(/__stringify\(ns\)/, "ns");
        print;
        next;
      }
      /MODULE_IMPORT_NS/ {
        $0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
      }
      /EXPORT_SYMBOL_NS/ {
        if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
  	if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
  	    $0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
  	    $0 !~ /^my/) {
  	  getline line;
  	  gsub(/[[:space:]]*\\$/, "");
  	  gsub(/[[:space:]]/, "", line);
  	  $0 = $0 " " line;
  	}

  	$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
  		    "\\1(\\2, \"\\3\")", "g");
        }
      }
      { print }' $file;
  done

Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 11:34:44 -08:00
Aleksa Savic
998b5a78a9 hwmon: (aquacomputer_d5next) Fix length of speed_input array
Commit 120584c728 ("hwmon: (aquacomputer_d5next) Add support for Octo
flow sensor") added support for reading Octo flow sensor, but didn't
update the priv->speed_input array length. Since Octo has 8 fans, with
the addition of the flow sensor the proper length for speed_input is 9.

Reported by Arne Schwabe on Github [1], who received a UBSAN warning.

Fixes: 120584c728 ("hwmon: (aquacomputer_d5next) Add support for Octo flow sensor")
Closes: https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/issues/100 [1]
Reported-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com>
Message-ID: <20241124152725.7205-1-savicaleksa83@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-24 07:36:47 -08:00
Murad Masimov
de2bf507fa hwmon: (tps23861) Fix reporting of negative temperatures
Negative temperatures are reported as large positive temperatures
due to missing sign extension from unsigned int to long. Cast unsigned
raw register values to signed before performing the calculations
to fix the problem.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: fff7b8ab22 ("hwmon: add Texas Instruments TPS23861 driver")
Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
Message-ID: <20241121173604.2021-1-m.masimov@maxima.ru>
[groeck: Updated subject and description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-23 09:49:03 -08:00
Jarkko Nikula
8281d62790 hwmon: (tmp108) Do not fail in I3C probe when I3C regmap is a module
I3C device probe fails when CONFIG_REGMAP_I3C=m:

	p3t1085_i3c 0-23615290090: error -ENODEV: Failed to register i3c regmap

Fix this by using the IS_ENABLED(CONFIG_REGMAP_I3C) macro in the code.

Fixes: c40655e331 ("hwmon: (tmp108) Add support for I3C device")
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Message-ID: <20241121121819.393104-1-jarkko.nikula@linux.intel.com>
[groeck: Remove #ifdef entirely; it is not needed due to dead code elimination]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-23 09:49:02 -08:00
Linus Torvalds
2b5d5f23d4 hmon updates for v6.13-rc1
* New drivers
 
   - ISL28022 power monitor
 
   - Nuvoton NCT7363Y
 
 * Added support for new chips to existing drivers
 
   - The tmp180 driver now supports NXP p3t1085, including its I3C mode
 
   - The ina2xx driver now supports SY24655 and INA260
 
   - The amc6821 driver now supports tsd,mule
 
 * Other notable improvements
 
   - The sht4x driver now supports the chip heater
 
   - The pmbus/isl68137 driver now supports a voltage divider on Vout
 
   - The cros_ec driver registers with the thermal framework
 
   - The pmbus/ltc2978 driver now supports LTC7841
 
   - The PMBus core now allow drivers to override WRITE_PROTECT
 
 * Various other minor improvements and cleanups
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmc6tlAACgkQyx8mb86f
 mYEmThAAi85J4hUepnrpfKwzqzTgXhU3Y1ih7qWyIK0ErI5tjmYiCR3PHHd7jNb0
 A5STfbpRkomvepQq9H79lv5EiOMFvudYLj2QuxFbSchz0J2XqXtg2RxUi9AK0/SE
 b+KLRjNNNHc2J2tDrLj14ZJJxMbqx35kx2x6TDGI+zoBhQ0XwEWkbtNuXipSpHQ8
 OkTjbtGKlQrjtc7fJ/fWGlTDeVS2LWtCbJhybcL47IkPeIBQH/FIhoEnnKqj9/EV
 KROuVAIoAYK9r+w7ZDfp2iBpR0gOaWZ5I2w2cCufsO9pFEuMIeVDgfFP2XGLBXEi
 NlVlMMyk6X7XqvnHYmun6r9chuPtFc9+Rr7SnJkVaNviY7BmRcuWk1BGxA4GIAIR
 6F3sBxlXdisnjVkYd1ENhCGlso/fXQizKUro3KZka0sXEnjxA+SE0dzIK8d77kip
 P6Mjg3hC6DZlA0eIlnbCWasu0gra4duVTpGTOcbfZQHN+50Fi4va9w2+1UDfIPnn
 f2gIUubtzrWZqKAPnN6ckIE7BQubsPukx7Zef0wgDRpxOgCBrKeQVX8LYtXQfkda
 G+LkSk1N1bUIpTbzGQPg7YLbVCQPQYqaSryFPL2lQtfEY58Tgt+EMCKSROmXMBOV
 tk9uDaN8OjXdYmU90jcHJR7v1WDkLRkRV0fsh6eFUpc8gQDiY+k=
 =BG/M
 -----END PGP SIGNATURE-----

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

Pull hmon updates from Guenter Roeck:
 "New drivers:
   - ISL28022 power monitor
   - Nuvoton NCT7363Y

  Added support for new chips to existing drivers:
   - The tmp180 driver now supports NXP p3t1085, including its I3C mode
   - The ina2xx driver now supports SY24655 and INA260
   - The amc6821 driver now supports tsd,mule

  Other notable improvements:
   - The sht4x driver now supports the chip heater
   - The pmbus/isl68137 driver now supports a voltage divider on Vout
   - The cros_ec driver registers with the thermal framework
   - The pmbus/ltc2978 driver now supports LTC7841
   - The PMBus core now allow drivers to override WRITE_PROTECT

  Various other minor improvements and cleanups"

* tag 'hwmon-for-v6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (51 commits)
  hwmon: (pmbus/isl68137) add support for voltage divider on Vout
  dt-bindings: hwmon: isl68137: add bindings to support voltage dividers
  hwmon: tmp108: fix I3C dependency
  hwmon: (cros_ec) register thermal sensors to thermal framework
  hwmon: (tmp108) Add support for I3C device
  hwmon: (tmp108) Add helper function tmp108_common_probe() to prepare I3C support
  hwmon: (acpi_power_meter) Fix fail to load module on platform without _PMD method
  hwmon: (nct6775-core) Fix overflows seen when writing limit attributes
  hwmon: (pwm-fan) Introduce start from stopped state handling
  dt-bindings: hwmon: pwm-fan: Document start from stopped state properties
  hwmon: (tmp108) Add NXP p3t1085 support
  dt-bindings: hwmon: ti,tmp108: Add nxp,p3t1085 compatible string
  hwmon: (sch5627, max31827) Fix typos in driver documentation
  hwmon: (jc42) Drop of_match_ptr() protection
  hwmon: (f71882fg) Fix grammar in fan speed trip points explanation
  dt-bindings: hwmon: pmbus: add ti tps25990 support
  hwmon: (pmbus/core) clear faults after setting smbalert mask
  hwmon: (pmbus/core) allow drivers to override WRITE_PROTECT
  hwmon: (pmbus) add documentation for existing flags
  hwmon: (ina226) Add support for SY24655
  ...
2024-11-19 11:23:52 -08:00
Grant Peltier
3996187f80 hwmon: (pmbus/isl68137) add support for voltage divider on Vout
Some applications require Vout to be higher than the detectable voltage
range of the Vsense pin for a given rail. In such applications, a voltage
divider may be placed between Vout and the Vsense pin, but this results
in erroneous telemetry being read back from the part. This change adds
support for a voltage divider to be defined in the devicetree for a (or
multiple) specific rail(s) for a supported digital multiphase device and
for the applicable Vout telemetry to be scaled based on the voltage
divider configuration.

This change copies the implementation of the vout-voltage-divider
devicetree property defined in the maxim,max20730 bindings schema since
it is the best fit for the use case of scaling hwmon PMBus telemetry. The
generic voltage-divider property used by many iio drivers was determined
to be a poor fit because that schema is tied directly to iio and the
isl68137 driver is not an iio driver.

Signed-off-by: Grant Peltier <grantpeltier93@gmail.com>
Message-ID: <8c2d048f87282bcf66313afbf5e923d8fc17b4d7.1731439797.git.grantpeltier93@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-13 12:08:07 -08:00
Arnd Bergmann
83b645ee43 hwmon: tmp108: fix I3C dependency
It's possible to build a kernel with tmp108 built-in but i3c support
in a loadable module, but that results in a link failure:

x86_64-linux-ld: drivers/hwmon/tmp108.o: in function `p3t1085_i3c_probe':
tmp108.c:(.text+0x5f9): undefined reference to `i3cdev_to_dev'

Add a Kconfig dependency to ensure only the working configurations
are allowed.

Fixes: c40655e331 ("hwmon: (tmp108) Add support for I3C device")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Message-ID: <20241113175615.2442851-1-arnd@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-13 12:03:54 -08:00
Sung-Chi, Li
c1fff92d80 hwmon: (cros_ec) register thermal sensors to thermal framework
cros_ec hwmon driver probes available thermal sensors when probing the
driver.  Register these thermal sensors to the thermal framework as well
via setting HWMON_C_REGISTER_TZ as a chip info, such that thermal
framework can adopt these sensors as well.

To make cros_ec registrable to thermal framework, the cros_ec dts need
the corresponding changes:

&cros_ec {
	#thermal-sensor-cells = <1>;
};

Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
Message-ID: <20241113024000.3327161-1-lschyi@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 19:03:58 -08:00
Frank Li
c40655e331 hwmon: (tmp108) Add support for I3C device
Add support for I3C device in the tmp108 driver to handle the P3T1085
sensor. Register the I3C device driver to enable I3C functionality for the
sensor.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Message-ID: <20241112-p3t1085-v4-2-a1334314b1e6@nxp.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:55 -08:00
Frank Li
700f325019 hwmon: (tmp108) Add helper function tmp108_common_probe() to prepare I3C support
Add help function tmp108_common_probe() to pave road to support i3c for
P3T1085(NXP) chip.

Use dev_err_probe() to simplify the code.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Message-ID: <20241112-p3t1085-v4-1-a1334314b1e6@nxp.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:55 -08:00
Huisong Li
fabb1f813e hwmon: (acpi_power_meter) Fix fail to load module on platform without _PMD method
According to the ACPI specification, the _PMD method is optional. The
acpi_power_meter driver shouldn't fail to load if the platform has no
_PMD method.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Message-ID: <20241112021228.22914-1-lihuisong@huawei.com>
[groeck: Reworded commit description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:55 -08:00
Pei Xiao
57ee12b6c5 hwmon: (nct6775-core) Fix overflows seen when writing limit attributes
DIV_ROUND_CLOSEST() after kstrtoul() results in an overflow if a large
number such as 18446744073709551615 is provided by the user.
Fix it by reordering clamp_val() and DIV_ROUND_CLOSEST() operations.

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
Fixes: c3963bc0a0 ("hwmon: (nct6775) Split core and platform driver")
Message-ID: <7d5084cea33f7c0fd0578c59adfff71f93de94d9.1731375425.git.xiaopei01@kylinos.cn>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:55 -08:00
Marek Vasut
255ab27a07 hwmon: (pwm-fan) Introduce start from stopped state handling
Delta AFC0612DB-F00 fan has to be set to at least 30% PWM duty cycle
to spin up from a stopped state, and can be afterward throttled down to
lower PWM duty cycle. Introduce support for operating such fans which
need to start at higher PWM duty cycle first and can slow down next.

Introduce two new DT properties, "fan-stop-to-start-percent" and
"fan-stop-to-start-us". The former describes the minimum percent
of fan RPM at which it will surely spin up from stopped state. This
value can be found in the fan datasheet and can be converted to PWM
duty cycle easily. The "fan-stop-to-start-us" describes the minimum
time in microseconds for which the fan has to be set to stopped state
start RPM for the fan to surely spin up.

Adjust the PWM setting code such that if the PWM duty cycle is below
the minimum duty cycle needed by the fan to spin up from stopped state,
then first set the PWM duty cycle to the minimum duty cycle needed
by the fan to spin up from stopped state, then wait the time necessary
for the fan to spin up from stopped state, and finally set the PWM duty
cycle to the one desired by user.

Signed-off-by: Marek Vasut <marex@denx.de>
Message-ID: <20241106185925.223736-2-marex@denx.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:55 -08:00
Frank Li
11d35624d7 hwmon: (tmp108) Add NXP p3t1085 support
Add compatible string 'nxp,p3t1085' since p3t1085's register layout is the
same as tmp108.

The p3t1085 supports I3C interface.

Update document tmp108.rst and Kconfig's help context.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Message-ID: <20241111-p3t1085-v3-2-bff511550aad@nxp.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:55 -08:00
Andy Shevchenko
c412d7af01 hwmon: (jc42) Drop of_match_ptr() protection
This prevents use of this driver with ACPI via PRP0001 and
is an example of an anti pattern I'm trying to remove from
the kernel. Hence drop from this driver.

Also switch of.h for mod_devicetable.h include given use of
struct of_device_id which is defined in that header.

Reported-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Closes: https://lore.kernel.org/r/CACSj6VW7WKv5tiAkLCvSujENJvXq1Mc7_7vtkQsRSz3JGY0i3Q@mail.gmail.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Message-ID: <20241108124348.1392473-1-andriy.shevchenko@linux.intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:55 -08:00
Jerome Brunet
509c3a3626 hwmon: (pmbus/core) clear faults after setting smbalert mask
pmbus_write_smbalert_mask() ignores the errors if the chip can't set
smbalert mask the standard way. It is not necessarily a problem for the irq
support if the chip is otherwise properly setup but it may leave an
uncleared fault behind.

pmbus_core will pick the fault on the next register_check(). The register
check will fails regardless of the actual register support by the chip.

This leads to missing attributes or debugfs entries for chips that should
provide them.

We cannot rely on register_check() as PMBUS_SMBALERT_MASK may be read-only.

Unconditionally clear the page fault after setting PMBUS_SMBALERT_MASK to
avoid the problem.

Suggested-by: Guenter Roeck <linux@roeck-us.net>
Fixes: 221819ca4c ("hwmon: (pmbus/core) Add interrupt support")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Message-ID: <20241105-tps25990-v4-5-0e312ac70b62@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:55 -08:00
Jerome Brunet
7a750b3986 hwmon: (pmbus/core) allow drivers to override WRITE_PROTECT
Use _pmbus_read_byte_data() rather than calling smbus directly to check
the write protection status. This give a chance to device implementing
write protection differently to report back on the actual write protection
status.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Message-ID: <20241105-tps25990-v4-2-0e312ac70b62@baylibre.com>
[groeck: Fix page parameter of _pmbus_read_byte_data()]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-12 13:54:39 -08:00
Wenliang Yan
52172ad87a hwmon: (ina226) Add support for SY24655
SY24655: Support for current and voltage detection as well as
power calculation.

Signed-off-by: Wenliang Yan <wenliang202407@163.com>
Message-ID: <20241106150547.2538-1-wenliang202407@163.com>
[groeck: Changed order of compatible entries;
 dropped spurious extra return statement in is_visible();
 fixed code problems]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:07 -08:00
Mariel Tinaco
9c1716bc51 hwmon: (pmbus/ltc2978) add support for ltc7841
Add support for LTC7841. The LTC7841 is a high performance
PolyPhase® single output synchronous boost converter controller.
Multiphase operation reduces input and output capacitor
requirements and allows the use of smaller inductors than the
single-phase equivalent.

The relevant registers in the LTC7841 are similar to the
LTC7880, only reduced by some amount. So it's just a matter of adding
the chip id. The device also doesn't support polling, on top of the
reduced register set, so a separate case for setting the chip info is
added.

Signed-off-by: Mariel Tinaco <Mariel.Tinaco@analog.com>
Message-ID: <20241029013734.293024-4-Mariel.Tinaco@analog.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:07 -08:00
Ban Feng
46b94c485e hwmon: Add driver for I2C chip Nuvoton NCT7363Y
The NCT7363Y is a fan controller which provides up to 16
independent FAN input monitors. It can report each FAN input count
values. The NCT7363Y also provides up to 16 independent PWM
outputs. Each PWM can output specific PWM signal by manual mode to
control the FAN duty outside.

Signed-off-by: Ban Feng <kcfeng0@nuvoton.com>
Message-ID: <20241022052905.4062682-3-kcfeng0@nuvoton.com>
[groeck: Dropped unnecessary variable initialization, and , after { }]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:07 -08:00
Sarah Maedel
ccae49e5cf hwmon: (nct6775) Add 665-ACE/600M-CL to ASUS WMI monitoring list
Boards such as
* Pro WS 665-ACE
* Pro WS 600M-CL
have got a nct6775 chip, but by default there's no use of it
because of resource conflict with WMI method.

Add affected boards to the WMI monitoring list.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=204807
Co-developed-by: Tommy Giesler <tommy.giesler@hetzner.com>
Signed-off-by: Tommy Giesler <tommy.giesler@hetzner.com>
Signed-off-by: Sarah Maedel <sarah.maedel@hetzner-cloud.de>
Message-ID: <20241018074611.358619-1-sarah.maedel@hetzner-cloud.de>
[groeck: Change commit message to imperative mood]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:07 -08:00
Yikai Tsai
39671a14df hwmon: (isl28022) new driver for ISL28022 power monitor
Driver for Renesas ISL28022 power monitor with I2C interface.
The device monitors voltage, current via shunt resistor
and calculated power.

Signed-off-by: Carsten Spieß <mail@carsten-spiess.de>
Signed-off-by: Yikai Tsai <yikai.tsai.wiwynn@gmail.com>
Message-ID: <20241002081133.13123-3-yikai.tsai.wiwynn@gmail.com>
[groeck: Fixed alignment issues, dropped noise at end of probe]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:07 -08:00
Uwe Kleine-König
6126f7bb60 hwmon: Switch back to struct platform_driver::remove()
After commit 0edb555a65 ("platform: Make platform_driver::remove()
return void") .remove() is (again) the right callback to implement for
platform drivers.

Convert all platform drivers below drivers/hwmonto use .remove(), with
the eventual goal to drop struct platform_driver::remove_new(). As
.remove() and .remove_new() have the same prototypes, conversion is done
by just changing the structure member name in the driver initializer.

While touching these files, make indention of the struct initializer
consistent in several files.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Message-ID: <20241017155900.137357-2-u.kleine-koenig@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:07 -08:00
Antoni Pokusinski
0eed6fc3d2 hwmon: (sht4x): add heater support
Add support for manipulating the internal heater of sht4x devices.
Enabling the heater removes condensed water from the sensor surface
which disturbs the relative humidity measurements.

The heater can operate at three heating levels (20, 110 or 200
milliwatts). Also, two heating durations may be selected (0.1 or 1s).
Once the heating time elapses the heater is automatically switched off.

Changes since v3:
* struct sht4x_data: add heating_complete timestamp
* struct sht4x_data: add data_pending flag
* heater_enable_store: return -EINVAL if input != 1
* heater_enable_store: check for data->heating_complete and update it
* heater_enable_store: set data_pending flag after heating request
* sht4x_read_values: msleep if heating in progress
* sht4x_read_values: dont send measurement request if data_pending
* heater_enable attr: make it RW
* Documentation: update info about heater_enable attr

Changes since v2:
* heater_enable_store: remove unnecessary if
* Documentation: remove incorrect info about turning off the heater
* be more specific in the patch description

Changes since v1:
* explain the use case of the new attributes set
* heater_enable attr: make it write-only
* heater_enable_store: define cmd as u8 instead of u8*
* heater_enable_store: remove unreachable data path
* heater_enable_store: remove unnecessary lock
* heater_enable_store: call i2c_master_send only if status==true
* define attributes as DEVICE_ATTR_* instead of SENSOR_DEVICE_ATTR_*

Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com>
Message-ID: <20240930205346.2147-1-apokusinski01@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:07 -08:00
Heiner Kallweit
83cca55a63 hwmon: (nzxt-kraken2) Simplify specifying static visibility attribute
Use new member visible of struct hwmon_ops to simplify specifying
the static attribute visibility.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Message-ID: <1ac2be2d-df4f-455a-900d-821fc7bd12c4@gmail.com>
Acked-by: Jonas Malaco <jonas@protocubo.io>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:06 -08:00