Commit Graph

504 Commits

Author SHA1 Message Date
Bartosz Golaszewski
d9d87d90cc treewide: rename GPIO set callbacks back to their original names
The conversion of all GPIO drivers to using the .set_rv() and
.set_multiple_rv() callbacks from struct gpio_chip (which - unlike their
predecessors - return an integer and allow the controller drivers to
indicate failures to users) is now complete and the legacy ones have
been removed. Rename the new callbacks back to their original names in
one sweeping change.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-08-07 10:07:06 +02:00
Chiang Brian
75ca1e5875 hwmon: (pmbus/tps53679) Add support for TPS53685
The TPS53685 is a fully AMD SVI3 compliant step down controller with
trans-inductor voltage regulator(TLVR) topology support, dual channels,
built-in non-volatile memory (NVM), PMBus interface, and full compatible
with TI NexFET smart power stages.

Add support for it to the tps53679 driver.

Signed-off-by: Chiang Brian <chiang.brian@inventec.com>
Link: https://lore.kernel.org/r/20250619064223.3165523-3-chiang.brian@inventec.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-07-20 16:38:34 -07:00
Cedric Encarnacion
e09ef2fe4a hwmon: (pmbus/adp1050) Add regulator support for ltp8800
Add regulator support for the single-channel LTP8800-1A/-2/-4A
150A/135A/200A DC/DC µModule Regulator.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
Link: https://lore.kernel.org/r/20250709-adp1051-v5-3-539254692252@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-07-20 16:38:34 -07:00
Cedric Encarnacion
3e5f73a062 hwmon: (pmbus/adp1050) Add support for adp1051, adp1055 and ltp8800
Introduce hardware monitoring support for the following devices:

    ADP1051: 6 PWM for I/O Voltage, I/O Current, Temperature
    ADP1055: 6 PWM for I/O Voltage, I/O Current, Power, Temperature
    LTP8800-1A/-2/-4A: 150A/135A/200A DC/DC µModule Regulator

The ADP1051 and ADP1055 are similar digital controllers for high
efficiency DC-DC power conversion while the LTP8800 is a family of
step-down μModule regulators that provides microprocessor core voltage
from 54V power distribution architecture. All of the above components
features telemetry monitoring of input/output voltage, input current,
output power, and temperature over PMBus.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
Link: https://lore.kernel.org/r/20250709-adp1051-v5-2-539254692252@analog.com
[groeck: Dropped unnecessaary spaces after type casts]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-07-20 16:38:34 -07:00
Chiang Brian
947809f9ee hwmon: (pmbus/isl68137) Add support for RAA229621
The RAA229621 is a digital dual output multiphase (X+Y <= 8) PWM controller
designed to be compliant with AMD SVI3 specifications, targeting VDDCR_CPU
and VDDCR_SOC rails.

Add support for it to the isl68137 driver.

Signed-off-by: Chiang Brian <chiang.brian@inventec.com>
Link: https://lore.kernel.org/r/20250605040134.4012199-3-chiang.brian@inventec.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-07-20 16:38:34 -07:00
Torben Nielsen
ce3cf7c8a1 hwmon: (pmbus/ucd9000) Fix error in ucd9000_gpio_set
The GPIO output functionality does not work as intended.

The ucd9000_gpio_set function should set UCD9000_GPIO_CONFIG_OUT_VALUE
(bit 2) in order to change the output value of the selected GPIO.
Instead UCD9000_GPIO_CONFIG_STATUS (bit 3) is set, but this is a
read-only value. This patch fixes the mistake and provides the intended
functionality of the GPIOs.

See UCD90xxx Sequencer and System Health Controller PMBus Command SLVU352C
section 10.43 for reference.

Signed-off-by: Torben Nielsen <t8927095@gmail.com>
Link: https://lore.kernel.org/r/20250718093644.356085-2-t8927095@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-07-18 09:50:55 -07:00
Pawel Dembicki
8fcefe7812 hwmon: pmbus: mpq8785: Add support for MPM3695 family
Add support for the Monolithic Power Systems MPM3695 family.
It contains four devices with suffixes: -10, -20, -25 and -100.
The device is PMBus compliant and shares characteristics with the
MPM82504.

MPM3695-25 has different VOLTAGE_SCALE_LOOP register size [11:0]
and therefore needs to have a separate compatible entry.

Tested with device tree based matching (MPM3695-10).

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Link: https://lore.kernel.org/r/20250511035701.2607947-6-paweldembicki@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-05-12 09:45:26 -07:00
Pawel Dembicki
c27291468e hwmon: pmbus: mpq8785: Add support for MPM82504
Add support for the Monolithic Power Systems MPM82504 digital voltage
regulator. MPM82504 uses PMBus direct format for voltage output.

Tested with device tree based matching.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Link: https://lore.kernel.org/r/20250511035701.2607947-5-paweldembicki@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-05-12 09:44:06 -07:00
Pawel Dembicki
dc1a4bab48 hwmon: pmbus: mpq8785: Implement VOUT feedback resistor divider ratio configuration
Implement support for setting the VOUT_SCALE_LOOP PMBus register
based on an optional device tree property
"mps,vout-fb-divider-ratio-permille".

This allows the driver to provide the correct VOUT value depending
on the feedback voltage divider configuration for chips where the
bootloader does not configure the VOUT_SCALE_LOOP register.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Link: https://lore.kernel.org/r/20250511035701.2607947-4-paweldembicki@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-05-12 09:43:17 -07:00
Pawel Dembicki
1bc6020dc4 hwmon: pmbus: mpq8785: Prepare driver for multiple device support
Refactor the driver to support multiple Monolithic Power Systems devices.
Introduce chip ID handling based on device tree matching.

No functional changes intended.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Link: https://lore.kernel.org/r/20250511035701.2607947-3-paweldembicki@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-05-12 09:42:39 -07:00
Cedric Encarnacion
c66c5bda7f hwmon: (pmbus/lt3074) add support for lt3074
Add hardware monitoring and regulator support for LT3074. The LT3074 is an
ultrafast, ultralow noise 3A, 5.5V dropout linear regulator. The PMBus
serial interface allows telemetry for input/output voltage, bias voltage,
output current, and die temperature.

Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
Link: https://lore.kernel.org/r/20250421-upstream-lt3074-v3-2-71636322f9fe@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-04-23 07:18:27 -07:00
William A. Kennington III
ab2f6bffe7 hwmon: (max34451) Work around lost page
When requesting new pages from the max34451 we sometimes see that the
firmware responds with stale or bad data to reads that happen
immediately after a page change. This is due to a lack of clock
stretching after page changing on the device side when it needs more
time to complete the operation.

To remedy this, the manufacturer recommends we wait 50us until
the firmware should be ready with the new page.

Signed-off-by: William A. Kennington III <william@wkennington.com>
Link: https://lore.kernel.org/r/20250408011006.1314622-1-william@wkennington.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-04-23 07:18:27 -07:00
Guenter Roeck
0b3c04c818 hwmon: (pmbus) Do not set regulators_node for single-channel chips
Single-channel regulators do not need and should not have a "regulators"
node. We can not entirely remove it due to existing bindings. To solve the
problem for new drivers, provide additional macros PMBUS_REGULATOR_ONE_NODE
and PMBUS_REGULATOR_STEP_ONE_NODE and convert existing drivers to use those
macros. The exception is the ir38064 driver because its devicetree files
and its description do not require or use the nested regulators node.

Modify PMBUS_REGULATOR_STEP_ONE and PMBUS_REGULATOR_ONE to set the
regulators_node pointer to NULL.

Cc: Cedricjustine.Encarnacion@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20250322142602.560042-1-linux@roeck-us.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-04-23 07:18:27 -07:00
Alexis Czezar Torreno
629cf8f6c2 hwmon: (pmbus/max34440) Add support for ADPM12160
ADPM12160 is a quarter brick DC/DC Power Module. It is a high power
non-isolated converter capable of delivering a fully regulated 12V,
with continuous power level of 1600W with peak power at 2400W for
a limited time. Uses PMBus Configuration.

Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
Link: https://lore.kernel.org/r/20250407-dev_adpm12160-v3-2-9cd3095445c8@analog.com
[groeck: The chip is "ADPM12160"]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-04-23 07:18:27 -07:00
Alexis Czezar Torreno
19932f844f hwmon: (pmbus/max34440) Fix support for max34451
The max344** family has an issue with some PMBUS address being switched.
This includes max34451 however version MAX34451-NA6 and later has this
issue fixed and this commit supports that update.

Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
Link: https://lore.kernel.org/r/20250407-dev_adpm12160-v3-1-9cd3095445c8@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-04-23 07:18:27 -07:00
Bartosz Golaszewski
9c47e45de1 hwmon: (pmbus/ucd9000) Use new GPIO line value setter callbacks
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20250407-gpiochip-set-rv-hwmon-v1-2-1fa38f34dc07@linaro.org
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-04-23 07:18:27 -07:00
William A. Kennington III
73e5b6b51f hwmon: (pmbus) Introduce page_change_delay
We have some buggy pmbus devices that require a delay after performing a
page change operation before trying to issue more commands to the
device.

This allows for a configurable delay after page changes, but not
affecting other read or write operations.

This makes a slight behavioral tweak to the existing delay logic, where
it considers the longest of delays between operations, instead of always
chosing the write delay over the access delay.

Signed-off-by: William A. Kennington III <william@wkennington.com>
Link: https://lore.kernel.org/r/20250407201002.1198092-1-william@wkennington.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-04-23 07:18:27 -07:00
Linus Torvalds
c07666e29b hwmon updates for v6.15
- New drivers
 
   * Driver for HTU31
 
   * Congatec Board Controller monitoring driver
 
   * Driver for TI INA233 Current and Power Monitor
 
 - Support for additional chips or boards in existing drivers
 
   * pmbus/ltc2978: Add support for LT717x and LTM4673
 
   * asus-ec-sensors: Add PRIME X670E-PRO WIFI
 
   * k10temp: Add support for cyan skillfish
 
   * nct6683: Add customer ID for AMD BC-250
 
   * lm90: Add support for NCT7716, NCT7717 and NCT7718
 
 - Other notable improvements in existing drivers
 
   * emc2305: Add devicetree support, and use
     devm_thermal_of_cooling_device_register
 
   * acpi_power_meter: Convert to with_info API
 
   * dell-smm: Increase the number of fans
 
   * pmbus/core: Optimize debugfs support and use i2c_client debugfs
     directory
 
    * hwmon core: Fix the missing of 'average' word in
      hwmon_power_attr_templates
 
    * Various drivers: Use per-client debugfs entry provided by I2C
      subsystem
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmfh5YsACgkQyx8mb86f
 mYG/AA//Z8b43kMxImlQjw4SXFyp3lry2OoLBxJADDZk/gHAbGBtrzYv5FFrHs/c
 0YUNP2yGApQnl7iwnUTgmayCafsq+BO1TXLHrn9VwWsefDHNBUZO8PbdZOlmlJgG
 LIxeIBPgHhuNoLthrZIEzGzDqd2xfNURXnox1J2/uHE6ggor5ceXXcAjxeZtxh45
 WP9rwaypC189qmMyLnHGIqGKsiTjFUkri6miAM0UkaRnrR8ELeTCtGeXWA+54b9+
 uOq7VyLYfIV7CffxwFuPfIMXRs/0kye0Y5GMzRPLPXZuY//A1QcVW6OcN6/+8Rgm
 qxsp0uWfwuUYi8Tek+DaX9+vKPo9IoUOvYjKlQt6J55FdBnkvnL6uW430lXp/9O3
 JQnRGLXV0GEdf8aSEya9lfAF7kPl6K9HRlqYIG/DpSoLDqkvn1ArGiRzkUEGRFHc
 pyTwUalhyqxsL9mELuVscN4g4t+MqXld43o/YEqfU8bDsVGztStjJFtrd+XSroKH
 FcvZldoVz6H99n22U45YHzA5BqDn53vP67uqM180mx4yCKDJIEAAduD48TFNJExV
 l9QgPZPZuxch8saFn7IeFmRNNeF7Y0W/TjQ4rjXHaaZN4+elyAXl4wwKYM61xP9Y
 u2E8qXl8Nk2oyXFKNcc4BBIbCB4aaQ66RaK0pWxzFGQDCiR+IKs=
 =6HFa
 -----END PGP SIGNATURE-----

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

Pull hwmon updates from Guenter Roeck:
 "New drivers:

   - Driver for HTU31

   - Congatec Board Controller monitoring driver

   - Driver for TI INA233 Current and Power Monitor

  Support for additional chips or boards in existing drivers:

   - pmbus/ltc2978: Add support for LT717x and LTM4673

   - asus-ec-sensors: Add PRIME X670E-PRO WIFI

   - k10temp: Add support for cyan skillfish

   - nct6683: Add customer ID for AMD BC-250

   - lm90: Add support for NCT7716, NCT7717 and NCT7718

  Other notable improvements in existing drivers:

   - emc2305: Add devicetree support, and use
     devm_thermal_of_cooling_device_register

   - acpi_power_meter: Convert to with_info API

   - dell-smm: Increase the number of fans

   - pmbus/core: Optimize debugfs support and use i2c_client
     debugfs directory

   - hwmon core: Fix the missing of 'average' word in
     hwmon_power_attr_templates

   - Various drivers: Use per-client debugfs entry provided by
     I2C subsystem"

* tag 'hwmon-for-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (49 commits)
  hwmon: emc2305: Use devm_thermal_of_cooling_device_register
  hwmon: emc2305: Add OF support
  dt-bindings: hwmon: Add Microchip emc2305 support
  dt-bindings: hwmon: Drop stray blank line in the header
  hwmon: (acpi_power_meter) Replace the deprecated hwmon_device_register
  hwmon: add driver for HTU31
  dt-bindings: hwmon: Add description for sensor HTU31
  hwmon: Add driver for TI INA233 Current and Power Monitor
  dt-bindings: hwmon: ti,ina2xx: Add INA233 device
  hwmon: Add Congatec Board Controller monitoring driver
  hwmon: (pmbus/ltc2978) add support for lt717x
  dt-bindings: hwmon: ltc2978: add support for LT717x
  hwmon: (pmbus/ltc2978) Add support for LT717x - docs
  hwmon: (dell-smm) Increment the number of fans
  hwmon: (ntc_thermistor) return error instead of clipping on OOB
  hwmon: (pt5161l) Use per-client debugfs entry
  hwmon: Fix the missing of 'average' word in hwmon_power_attr_templates
  hwmon: (acpi_power_meter) Fix the fake power alarm reporting
  hwmon: (gpio-fan) Add missing mutex locks
  dt-bindings: hwmon: gpio-fan: Add optional regulator support
  ...
2025-03-25 19:55:29 -07:00
Leo Yang
b64b6cb163 hwmon: Add driver for TI INA233 Current and Power Monitor
Driver for Texas Instruments INA233 Current and Power Monitor
With I2C-, SMBus-, and PMBus-Compatible Interface

Signed-off-by: Leo Yang <leo.yang.sy0@gmail.com>
Link: https://lore.kernel.org/r/20250116085939.1235598-3-leo.yang.sy0@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-18 08:03:37 -07:00
Kim Seer Paller
c1d6afdbb8 hwmon: (pmbus/ltc2978) add support for lt717x
Add support for LT7170 and LT7171. The LT7170 and LT7171 are 20 A, 16 V,
Single- or Dual-Phase, Silent Switcher Step-Down Regulators with Digital
Power System Management.

The relevant registers in the LT7170 and LT7171 are similar to those in
the LTC3887, but with fewer channels. This adds the chip ID and
identification of ASCII to differentiate between the LT7170 and LT7171.
These devices support polling for status updates and clearing peak
values. The data format for voltage, current, and temperature is set to
IEEE754 for precision and compatibility.

Co-developed-by: Cherrence Sarip <cherrence.sarip@analog.com>
Signed-off-by: Cherrence Sarip <cherrence.sarip@analog.com>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://lore.kernel.org/r/20250317-hwmon-next-v1-3-da0218c38197@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-17 08:05:08 -07:00
Guenter Roeck
c90a00368d hwmon: (pmbus/core) Report content of CAPABILITY register in debugfs
Report the value of the CAPABILITY register in debugfs if supported.
Only check if the register is supported if PMBUS_NO_CAPABILITY
is not set.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:49:10 -08:00
Guenter Roeck
64fbb4c42a hwmon: (pmbus/core) Optimize debugfs status attribute initialization
Define debugfs attributes used to access status registers in a data
structure and loop through it instead of creating debugfs files
one by one. This reduces code size and simplifies adding additional
attributes if needed.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:49:06 -08:00
Guenter Roeck
2a431adc96 hwmon: (pmbus/core) Optimize debugfs block data attribute initialization
Define debugfs attributes which need block data access in a data
structure and loop through it instead of creating debugfs files
one by one. This reduces code size and simplifies adding additional
attributes if needed.

While this is currently only used for manufacturer specific attributes,
the access code is generic and also works for other block attributes,
so rename operation functions from _mfg to _block.

While at it, rename the "revison" file to "pmbus_revision" to make its
meaning more obvious and to create a clear distinction against the
"mfg_revision" file.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:49:01 -08:00
Guenter Roeck
510db88a1c hwmon: (pmbus/core) Declare regulator notification function as void
The regulator notification function never returns an error.
Declare it as void.

While at it, fix its indentation.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:48:59 -08:00
Guenter Roeck
05452a3328 hwmon: (pmbus/core) Make debugfs code unconditional
Drop contitionals around debugfs code to compile it unconditionally.
In practice it will be optimized away by the compiler if CONFIG_DEBUG_FS
is not enabled, so the code size is not affected by this change.

Also silently ignore errors if debugfs initialization fails.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:48:32 -08:00
Guenter Roeck
de438ec92f hwmon: (pmbus/core) Use the new i2c_client debugfs directory
The I2C core now manages a debugfs directory per I2C client. PMBus has
its own debugfs hierarchy. Link the two, so a user will be pointed to
the I2C domain from the PMBus domain.

Suggested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:48:32 -08:00
Guenter Roeck
6625a059e6 hwmon: (pmbus/core) Use local debugfs variable in debugfs initialization
In preparation for the next patch in the series, use a local debugfs
variable during debugfs initialization.

No functional change intended.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:48:32 -08:00
Guenter Roeck
649b419f91 hwmon: (pmbus/core) Fix various coding style issues
Checkpatch reports bad multi-line comments, bad multi-line alignments,
missing blank lines after variable declarations, unnecessary empty lines,
unnecessary spaces, and unnecessary braces. Fix most of the reported
problems except for some multi-line alignment problems.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:48:32 -08:00
Thorsten Blum
69af654bf9 hwmon: (pmbus/core) Replace deprecated strncpy() with strscpy()
strncpy() is deprecated for NUL-terminated destination buffers; use
strscpy() instead.

Compile-tested only.

Note(groeck): strscpy() uses sizeof() to determine the length of the
destination buffer if it is not provided as argument.

Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250227173936.7746-2-thorsten.blum@linux.dev
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:30:11 -08:00
Titus Rwantare
6b6e2e8fd0 hwmon: (pmbus) Initialise page count in pmbus_identify()
The `pmbus_identify()` function fails to correctly determine the number
of supported pages on PMBus devices. This occurs because `info->pages`
is implicitly zero-initialised, and `pmbus_set_page()` does not perform
writes to the page register if `info->pages` is not yet initialised.
Without this patch, `info->pages` is always set to the maximum after
scanning.

This patch initialises `info->pages` to `PMBUS_PAGES` before the probing
loop, enabling `pmbus_set_page()` writes to make it out onto the bus
correctly identifying the number of pages. `PMBUS_PAGES` seemed like a
reasonable non-zero number because that's the current result of the
identification process.

Testing was done with a PMBus device in QEMU.

Signed-off-by: Titus Rwantare <titusr@google.com>
Fixes: 442aba7872 ("hwmon: PMBus device driver")
Link: https://lore.kernel.org/r/20250227222455.2583468-1-titusr@google.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-03-02 08:27:22 -08:00
Cedric Encarnacion
68b6f95861 hwmon: (pmbus/ltc2978) add support for ltm4673
Add support for LTM4673. The LTM4673 is a quad output, dual 12A and dual
5A, switching mode DC/DC step-down μModule regulator integrated with
4-channel power system manager.

This adds only the chip id, the checks for the manufacturer special id,
and the relevant attributes for the device's pmbus_driver_info.
The device does not support clear peaks.

Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
Link: https://lore.kernel.org/r/20250124-ltm4673-v1-2-a2c6aa37c903@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-02-02 17:34:06 -08:00
Denis Kirjanov
a76539b293 hwmon: pmbus: dps920ab: Add ability to instantiate through i2c
Add support for instantiating the Delta DPS920AB PSU
through I2C on systems without devicetree support.

Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
Link: https://lore.kernel.org/r/20250113092846.10786-1-kirjanov@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-01-13 08:57:06 -08:00
Nuno Sa
788bd792c7 hwmon: (pmbus/max15301) Add support for MAX15303
The MAX15303 is a full-featured, flexible, efficient, 6A digital
point-of-load (PoL) controller with integrated switching MOSFETs. It
contains advanced power management and telemetry features.

Tested-by: Robin Getz <rgetz503@gmail.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20250108-dev-max15303-v1-1-9154eb2c9d9e@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-01-08 09:17:49 -08:00
John Erasmus Mari Geronimo
adc52dd407 hwmon: (pmbus/adm1275) add adm1273 support
Add support for adm1273 which is similar to adm1275 and other chips
of the series.

Signed-off-by: John Erasmus Mari Geronimo <johnerasmusmari.geronimo@analog.com>
Link: https://lore.kernel.org/r/20250106131740.305988-3-johnerasmusmari.geronimo@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-01-07 09:08:10 -08: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
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
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
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
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
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
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
Shen Lichuan
ff140456b5 hwmon: (pmbus/mpq8785) Convert comma to semicolon
To ensure code clarity and prevent potential errors, use ';' instead of
',' as a statement separator in the function mpq8785_identify.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
Message-ID: <20240919064939.3282-1-shenlichuan@vivo.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:06 -08:00
Uwe Kleine-König
a7e03f9679 hwmon: Drop explicit initialization of struct i2c_device_id::driver_data to 0
These drivers don't use the driver_data member of struct i2c_device_id,
so don't explicitly initialize this member.

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.

While touching these structs, also remove commas after the sentinel
entries and use a consistent indention style.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Message-ID: <20240918123150.1540161-7-u.kleine-koenig@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-11-10 14:48:05 -08:00
Linus Torvalds
c27ea952c6 hwmon updates for v6.12
* New drivers
 
   - Driver for Sophgo SG2042 external hardware monitor
 
   - Thermal sensor driver for Surface Aggregator Module
 
 * Added support to existing drivers
 
   - oxp-sensors: Support for multiple new devices.
 
   - nct6775: Added G15CF to ASUS WMI monitoring list
 
 * Modernizations
 
   - ina2xx: Driver cleanup and update to use with_info API
 
   - lm92: Driver cleanup and update to use regmap and with_info API
 
   - lm95234: Driver cleanup and update to use regmap and with_info API
 
   - max1619: Driver cleanup and update to use regmap and with_info API
 
   - max1668: Driver cleanup and update to use regmap and with_info API
 
   - max6697: Driver cleanup and update to use regmap and with_info API
 
 * API updates
 
   - Removed unused devm_hwmon_device_unregister() API function
 
 * Other notable changes
 
   - Implement and use generic bus access delay for pmbus drivers
 
   - Use with scoped for each OF child loop in several drivers
 
   - Module unloading fixes for gsc-hwmon and ntc_thermistor drivers
 
   - Converted various drivers to use multi-byte regmap operations
 
   - adt7475: Improved devicetree based configuration
 
   - ltc2947: Move to firmware agnostic API
 
   - ltc2978: Converted devicetree description to yaml
 
   - max16065: Addressed overflows when writing limit attributes
 
 * Various other minor cleanups, fixes and improvements
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmboX+AACgkQyx8mb86f
 mYHRGA/7BVlHa3sxDTNLPvL3VMZ1/SgmQqC0xUx57bAOcpkLX0taXD/t+Nm93HaW
 vCKGYPe0jII9tVz1YvZ1VSNwJXZo4X+jfdL3t6RpdKpn/op6vASzhKhh0sGeiyw1
 aQNXzrm4dthFDRfmscZM1+CBQv4aTf6ApyTbRFH2dnViXu9idMZYcxoxz87uody5
 AxUAgNDPb/mQww3x6r+rVv3VQaJZ+yrJxbYvaxgzbm8TqIFCpHgNtRJTVBhGjbOi
 o9rushlUpOjBQE2/jKOajtfV9fWX/kpJu9dUfSbVMCvZgEPU985UX6dpg9Oc0t0o
 oUhID2dHLUVNmn4dTQCtvzuLTEBDi87TcML6VDlMIn3dFi5QG3tJZkaWtbPymHz9
 4Qf3TJ2TV0E/jIh8UueFd2SlRlkCE3HooM04Kbes7H8ftSbddMM3fTah8yzdOJJE
 Dwv6eO3T9REHPaBauFq0Y9hzkx46rqF6Mli0tFUumh7oM1b68ILZ+oJxfpapatzO
 Pa6UPFfaHU63VFmDCzNWc0IiI1beF7i5fzzWwj37HgIdaw1+cS6kNtvbv/6t5/41
 5TVitpP1SLzDtjK6f+VDjroE/Qg4OeodamBOEopMPjYM/nipyWxPoOK1VEtbo1P5
 vAJBmgPn45M02miB7l3ERCCkRVQdeL69ZM5vcRmLB8NQRKML830=
 =z6jf
 -----END PGP SIGNATURE-----

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

Pull hwmon updates from Guenter Roeck:
 "New drivers:
   - driver for Sophgo SG2042 external hardware monitor
   - thermal sensor driver for Surface Aggregator Module

  Added support to existing drivers:
   - oxp-sensors: Support for multiple new devices.
   - nct6775: Added G15CF to ASUS WMI monitoring list

  Modernizations:
   - driver cleanup and update to use with_info API: ina2xx, lm92,
     lm95234, max1619, max1668, and max6697.

  API updates:
   - removed unused devm_hwmon_device_unregister() API function

  Other notable changes
   - implement and use generic bus access delay for pmbus drivers
   - use with scoped for each OF child loop in several drivers
   - module unloading fixes for gsc-hwmon and ntc_thermistor drivers
   - converted various drivers to use multi-byte regmap operations
   - adt7475: Improved devicetree based configuration
   - ltc2947: Move to firmware agnostic API
   - ltc2978: Converted devicetree description to yaml
   - max16065: Addressed overflows when writing limit attributes

  Various other minor cleanups, fixes and improvements"

* tag 'hwmon-for-v6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (96 commits)
  hwmon: Remove devm_hwmon_device_unregister() API function
  hwmon: (sch5636) Print unknown ID in error string via %*pE
  hwmon: (sht21) Use %*ph to print small buffer
  hwmon: (pmbus/mpq7932) Constify struct regulator_desc
  hwmon: pmbus: pli12096bc: Add write delay
  hwmon: pmbus: zl6100: Use generic code
  hwmon: pmbus: ucd9000: Use generic code
  hwmon: pmbus: max15301: Use generic code
  hwmon: pmbus: Implement generic bus access delay
  hwmon: (ina2xx) Use shunt voltage to calculate current
  hwmon: (ina2xx) Add support for current limits
  hwmon: (ina2xx) Pass register to alert limit write functions
  hwmon: (ina2xx) Convert to use with_info hwmon API
  hwmon: (ina2xx) Move ina2xx_get_value()
  hwmon: (ina2xx) Set alert latch
  hwmon: (ina2xx) Consolidate chip initialization code
  hwmon: (ina2xx) Fix various overflow issues
  hwmon: (ina2xx) Re-initialize chip using regmap functions
  hwmon: (ina2xx) Use local regmap pointer if used more than once
  hwmon: (ina2xx) Mark regmap_config as const
  ...
2024-09-18 12:40:48 +02:00
Patryk Biel
20471071f1 hwmon: (pmbus) Conditionally clear individual status bits for pmbus rev >= 1.2
The current implementation of pmbus_show_boolean assumes that all devices
support write-back operation of status register to clear pending warnings
or faults. Since clearing individual bits in the status registers was only
introduced in PMBus specification 1.2, this operation may not be supported
by some older devices. This can result in an error while reading boolean
attributes such as temp1_max_alarm.

Fetch PMBus revision supported by the device and modify pmbus_show_boolean
so that it only tries to clear individual status bits if the device is
compliant with PMBus specs >= 1.2. Otherwise clear all fault indicators
on the current page after a fault status was reported.

Fixes: 35f165f089 ("hwmon: (pmbus) Clear pmbus fault/warning bits after read")
Signed-off-by: Patryk Biel <pbiel7@gmail.com>
Message-ID: <20240909-pmbus-status-reg-clearing-v1-1-f1c0d68c6408@gmail.com>
[groeck:
 Rewrote description
 Moved revision detection code ahead of clear faults command
 Assigned revision if return value from PMBUS_REVISION command is 0
 Improved return value check from calling _pmbus_write_byte_data()]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-09-09 10:58:09 -07:00
Christophe JAILLET
d22bd451d5 hwmon: (pmbus/mpq7932) Constify struct regulator_desc
'struct regulator_desc' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

This also makes mpq7932_regulators_desc consistent with
mpq7932_regulators_desc_one which is already a "static const struct
regulator_desc".

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   3516	   2264	      0	   5780	   1694	drivers/hwmon/pmbus/mpq7932.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   5396	    384	      0	   5780	   1694	drivers/hwmon/pmbus/mpq7932.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Message-ID: <c0585a07547ec58d99a5bff5e02b398114bbe312.1725784343.git.christophe.jaillet@wanadoo.fr>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-09-08 16:37:51 -07:00
Patrick Rudolph
3cd1ef26b0 hwmon: pmbus: pli12096bc: Add write delay
Tests on PLI12096bc showed that sometimes a small delay is necessary
after a write operation before a new operation can be processed.
If not respected the device will probably NACK the data phase of
the SMBus transaction. Tests showed that the probability to observe
transaction errors can be raised by either reading sensor data or
toggling the regulator enable.

Further tests showed that 250 microseconds, as used previously for
the CLEAR_FAULTS workaround, is sufficient.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Message-ID: <20240902075319.585656-5-patrick.rudolph@9elements.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-09-02 07:34:03 -07:00