diff mbox series

[2/2] hwmon: (pmbus/max3440): add support adpm12160

Message ID 20250320-dev_adpm12160-v1-2-8f7b975eac75@analog.com (mailing list archive)
State Changes Requested
Headers show
Series Add support for ADPM12160 a DC/DC Power Module | expand

Commit Message

Torreno, Alexis Czezar March 20, 2025, 3:55 a.m. UTC
ASPM12160 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>
---
 Documentation/hwmon/max34440.rst | 31 +++++++++++++++++--------
 drivers/hwmon/pmbus/Kconfig      |  1 +
 drivers/hwmon/pmbus/max34440.c   | 49 +++++++++++++++++++++++++++++++++++-----
 3 files changed, 66 insertions(+), 15 deletions(-)

Comments

Guenter Roeck March 20, 2025, 4:32 a.m. UTC | #1
On 3/19/25 20:55, Alexis Czezar Torreno wrote:
> ASPM12160 is a quarter brick DC/DC Power Module. It is a high

ASPM12160 or ADPM12160 ?

> 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>

I am not convinced that this chip should be supported as part of this driver.
Unfortunately the datasheet is not public ... or, rather, the chip does not
officially exist. Sorry, this driver will have to wait until I can have
a look into the datasheet.

Guenter
Torreno, Alexis Czezar March 20, 2025, 4:40 a.m. UTC | #2
> [External]
> 
> On 3/19/25 20:55, Alexis Czezar Torreno wrote:
> > ASPM12160 is a quarter brick DC/DC Power Module. It is a high
> 
> ASPM12160 or ADPM12160 ?
> 
> > 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>
> 
> I am not convinced that this chip should be supported as part of this driver.
> Unfortunately the datasheet is not public ... or, rather, the chip does not
> officially exist. Sorry, this driver will have to wait until I can have a look into the
> datasheet.
> 
> Guenter

Apology on the typo, it is ADPM12160.
They wanted to upstream this same time as the chip release.
But it makes sense, this upstream should at least be after it releases.

Will attend to the feedback on the other commit (Patch 1/2) for the meantime.

Thank you,
Alexis
kernel test robot March 20, 2025, 4:12 p.m. UTC | #3
Hi Alexis,

kernel test robot noticed the following build errors:

[auto build test ERROR on c812cc42f92d3d0b17c01b5db9a1dee5793a1491]

url:    https://github.com/intel-lab-lkp/linux/commits/Alexis-Czezar-Torreno/hwmon-pmbus-max34440-Fix-support-for-max34451/20250320-115905
base:   c812cc42f92d3d0b17c01b5db9a1dee5793a1491
patch link:    https://lore.kernel.org/r/20250320-dev_adpm12160-v1-2-8f7b975eac75%40analog.com
patch subject: [PATCH 2/2] hwmon: (pmbus/max3440): add support adpm12160
config: i386-buildonly-randconfig-005-20250320 (https://download.01.org/0day-ci/archive/20250320/202503202311.5PZH0XKm-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250320/202503202311.5PZH0XKm-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503202311.5PZH0XKm-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/hwmon/pmbus/max34440.c: In function 'max34440_read_word_data':
>> drivers/hwmon/pmbus/max34440.c:97:71: error: expected statement before ')' token
      97 |                     data->id != max34451_na6 && data->id != adpm12160))
         |                                                                       ^
   drivers/hwmon/pmbus/max34440.c: At top level:
   drivers/hwmon/pmbus/max34440.c:483:37: error: expected expression before ',' token
     483 |                 MAX34451_COMMON_INFO,
         |                                     ^
   drivers/hwmon/pmbus/max34440.c:486:37: error: expected expression before ',' token
     486 |                 MAX34451_COMMON_INFO,
         |                                     ^
   In file included from include/linux/module.h:22,
                    from drivers/hwmon/pmbus/max34440.c:11:
   drivers/hwmon/pmbus/max34440.c:603:18: error: expected ',' or ';' before 'PMBUS'
     603 | MODULE_IMPORT_NS(PMBUS);
         |                  ^~~~~
   include/linux/moduleparam.h:26:61: note: in definition of macro '__MODULE_INFO'
      26 |                 = __MODULE_INFO_PREFIX __stringify(tag) "=" info
         |                                                             ^~~~
   include/linux/module.h:299:33: note: in expansion of macro 'MODULE_INFO'
     299 | #define MODULE_IMPORT_NS(ns)    MODULE_INFO(import_ns, ns)
         |                                 ^~~~~~~~~~~
   drivers/hwmon/pmbus/max34440.c:603:1: note: in expansion of macro 'MODULE_IMPORT_NS'
     603 | MODULE_IMPORT_NS(PMBUS);
         | ^~~~~~~~~~~~~~~~


vim +97 drivers/hwmon/pmbus/max34440.c

    62	
    63	static int max34440_read_word_data(struct i2c_client *client, int page,
    64					   int phase, int reg)
    65	{
    66		int ret;
    67		const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
    68		const struct max34440_data *data = to_max34440_data(info);
    69	
    70		switch (reg) {
    71		case PMBUS_IOUT_OC_FAULT_LIMIT:
    72			if (data->id == max34451_na6 || data->id == adpm12160)
    73				ret = pmbus_read_word_data(client, page, phase,
    74							   PMBUS_IOUT_OC_FAULT_LIMIT);
    75			else
    76				ret = pmbus_read_word_data(client, page, phase,
    77							   MAX34440_IOUT_OC_FAULT_LIMIT);
    78			break;
    79		case PMBUS_IOUT_OC_WARN_LIMIT:
    80			if (data->id == max34451_na6 || data->id == adpm12160)
    81				ret = pmbus_read_word_data(client, page, phase,
    82							   PMBUS_IOUT_OC_WARN_LIMIT);
    83			else
    84				ret = pmbus_read_word_data(client, page, phase,
    85							   MAX34440_IOUT_OC_WARN_LIMIT);
    86			break;
    87		case PMBUS_VIRT_READ_VOUT_MIN:
    88			ret = pmbus_read_word_data(client, page, phase,
    89						   MAX34440_MFR_VOUT_MIN);
    90			break;
    91		case PMBUS_VIRT_READ_VOUT_MAX:
    92			ret = pmbus_read_word_data(client, page, phase,
    93						   MAX34440_MFR_VOUT_PEAK);
    94			break;
    95		case PMBUS_VIRT_READ_IOUT_AVG:
    96			if (data->id != max34446 && data->id != max34451 &&
  > 97			    data->id != max34451_na6 && data->id != adpm12160))
    98				return -ENXIO;
    99			ret = pmbus_read_word_data(client, page, phase,
   100						   MAX34446_MFR_IOUT_AVG);
   101			break;
   102		case PMBUS_VIRT_READ_IOUT_MAX:
   103			ret = pmbus_read_word_data(client, page, phase,
   104						   MAX34440_MFR_IOUT_PEAK);
   105			break;
   106		case PMBUS_VIRT_READ_POUT_AVG:
   107			if (data->id != max34446)
   108				return -ENXIO;
   109			ret = pmbus_read_word_data(client, page, phase,
   110						   MAX34446_MFR_POUT_AVG);
   111			break;
   112		case PMBUS_VIRT_READ_POUT_MAX:
   113			if (data->id != max34446)
   114				return -ENXIO;
   115			ret = pmbus_read_word_data(client, page, phase,
   116						   MAX34446_MFR_POUT_PEAK);
   117			break;
   118		case PMBUS_VIRT_READ_TEMP_AVG:
   119			if (data->id != max34446 && data->id != max34460 &&
   120			    data->id != max34461)
   121				return -ENXIO;
   122			ret = pmbus_read_word_data(client, page, phase,
   123						   MAX34446_MFR_TEMPERATURE_AVG);
   124			break;
   125		case PMBUS_VIRT_READ_TEMP_MAX:
   126			ret = pmbus_read_word_data(client, page, phase,
   127						   MAX34440_MFR_TEMPERATURE_PEAK);
   128			break;
   129		case PMBUS_VIRT_RESET_POUT_HISTORY:
   130			if (data->id != max34446)
   131				return -ENXIO;
   132			ret = 0;
   133			break;
   134		case PMBUS_VIRT_RESET_VOUT_HISTORY:
   135		case PMBUS_VIRT_RESET_IOUT_HISTORY:
   136		case PMBUS_VIRT_RESET_TEMP_HISTORY:
   137			ret = 0;
   138			break;
   139		default:
   140			ret = -ENODATA;
   141			break;
   142		}
   143		return ret;
   144	}
   145
diff mbox series

Patch

diff --git a/Documentation/hwmon/max34440.rst b/Documentation/hwmon/max34440.rst
index b1f3f75091bb8e233e766c24913194dd62b0cd90..65522efa57563389fce54b51829964d62f970c27 100644
--- a/Documentation/hwmon/max34440.rst
+++ b/Documentation/hwmon/max34440.rst
@@ -3,6 +3,14 @@  Kernel driver max34440
 
 Supported chips:
 
+  * ADI ADPM12160
+
+    Prefixes: 'adpm12160'
+
+    Addresses scanned: -
+
+    Datasheet: -
+
   * Maxim MAX34440
 
     Prefixes: 'max34440'
@@ -67,13 +75,14 @@  Author: Guenter Roeck <linux@roeck-us.net>
 Description
 -----------
 
-This driver supports hardware monitoring for Maxim MAX34440 PMBus 6-Channel
-Power-Supply Manager, MAX34441 PMBus 5-Channel Power-Supply Manager
-and Intelligent Fan Controller, and MAX34446 PMBus Power-Supply Data Logger.
-It also supports the MAX34451, MAX34460, and MAX34461 PMBus Voltage Monitor &
-Sequencers. The MAX34451 supports monitoring voltage or current of 12 channels
-based on GIN pins. The MAX34460 supports 12 voltage channels, and the MAX34461
-supports 16 voltage channels.
+This driver supports multiple devices: hardware monitoring for Maxim MAX34440
+PMBus 6-Channel Power-Supply Manager, MAX34441 PMBus 5-Channel Power-Supply
+Manager and Intelligent Fan Controller, and MAX34446 PMBus Power-Supply Data
+Logger; PMBus Voltage Monitor and Sequencers for MAX34451, MAX34460, and
+MAX34461; PMBus DC/DC Power Module ADPM12160. The MAX34451 supports monitoring
+voltage or current of 12 channels based on GIN pins. The MAX34460 supports 12
+voltage channels, and the MAX34461 supports 16 voltage channels. The ADPM1260
+also monitors both input and output of voltage and current.
 
 The driver is a client driver to the core PMBus driver. Please see
 Documentation/hwmon/pmbus.rst for details on PMBus client drivers.
@@ -97,7 +106,6 @@  For MAX34451, version MAX34451ETNA6+ and later are denoted with prefix
 'max34451_na6'. The previous versions contains some errors on the PMBUS
 addresses and these are fixed on the later versions.
 
-
 Platform data support
 ---------------------
 
@@ -132,7 +140,10 @@  in[1-6]_highest		Historical maximum voltage.
 in[1-6]_reset_history	Write any value to reset history.
 ======================= =======================================================
 
-.. note:: MAX34446 only supports in[1-4].
+.. note::
+
+    - MAX34446 only supports in[1-4].
+    - ADPM12160 only supports in[1-2]. Label is "vin1" and "vout1" respectively.
 
 Curr
 ~~~~
@@ -154,6 +165,7 @@  curr[1-6]_reset_history	Write any value to reset history.
 
     - in6 and curr6 attributes only exist for MAX34440.
     - MAX34446 only supports curr[1-4].
+    - For ADPM12160, curr[1] is "iin1" and curr[2-6] are "iout[1-5].
 
 Power
 ~~~~~
@@ -189,6 +201,7 @@  temp[1-8]_reset_history	Write any value to reset history.
 .. note::
    - temp7 and temp8 attributes only exist for MAX34440.
    - MAX34446 only supports temp[1-3].
+   - ADPM12160 only supports temp[1].
 
 
 .. note::
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index c9b3c314998234e639db1770c18c6f75fa037d25..b50bb6eceaa1419a928ff5b2153260738978f9a8 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -324,6 +324,7 @@  config SENSORS_MAX34440
 	help
 	  If you say yes here you get hardware monitoring support for Maxim
 	  MAX34440, MAX34441, MAX34446, MAX34451, MAX34460, and MAX34461.
+	  Other compatible includes ADPM12160.
 
 	  This driver can also be built as a module. If so, the module will
 	  be called max34440.
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index d483c01f256c96f048c9da5981f10f52402d981c..48e459252391048c90f373b3b73de6871392880c 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -15,6 +15,7 @@ 
 #include "pmbus.h"
 
 enum chips {
+	adpm12160,
 	max34440,
 	max34441,
 	max34446,
@@ -68,7 +69,7 @@  static int max34440_read_word_data(struct i2c_client *client, int page,
 
 	switch (reg) {
 	case PMBUS_IOUT_OC_FAULT_LIMIT:
-		if (data->id == max34451_na6)
+		if (data->id == max34451_na6 || data->id == adpm12160)
 			ret = pmbus_read_word_data(client, page, phase,
 						   PMBUS_IOUT_OC_FAULT_LIMIT);
 		else
@@ -76,7 +77,7 @@  static int max34440_read_word_data(struct i2c_client *client, int page,
 						   MAX34440_IOUT_OC_FAULT_LIMIT);
 		break;
 	case PMBUS_IOUT_OC_WARN_LIMIT:
-		if (data->id == max34451_na6)
+		if (data->id == max34451_na6 || data->id == adpm12160)
 			ret = pmbus_read_word_data(client, page, phase,
 						   PMBUS_IOUT_OC_WARN_LIMIT);
 		else
@@ -93,7 +94,7 @@  static int max34440_read_word_data(struct i2c_client *client, int page,
 		break;
 	case PMBUS_VIRT_READ_IOUT_AVG:
 		if (data->id != max34446 && data->id != max34451 &&
-		    data->id != max34451_na6)
+		    data->id != max34451_na6 && data->id != adpm12160))
 			return -ENXIO;
 		ret = pmbus_read_word_data(client, page, phase,
 					   MAX34446_MFR_IOUT_AVG);
@@ -151,7 +152,7 @@  static int max34440_write_word_data(struct i2c_client *client, int page,
 
 	switch (reg) {
 	case PMBUS_IOUT_OC_FAULT_LIMIT:
-		if (data->id == max34451_na6)
+		if (data->id == max34451_na6 || data->id == adpm12160)
 			ret = pmbus_write_word_data(client, page, PMBUS_IOUT_OC_FAULT_LIMIT,
 						    word);
 		else
@@ -159,7 +160,7 @@  static int max34440_write_word_data(struct i2c_client *client, int page,
 						    word);
 		break;
 	case PMBUS_IOUT_OC_WARN_LIMIT:
-		if (data->id == max34451_na6)
+		if (data->id == max34451_na6 || data->id == adpm12160)
 			ret = pmbus_write_word_data(client, page, PMBUS_IOUT_OC_WARN_LIMIT,
 						    word);
 		else
@@ -186,7 +187,7 @@  static int max34440_write_word_data(struct i2c_client *client, int page,
 		ret = pmbus_write_word_data(client, page,
 					    MAX34440_MFR_IOUT_PEAK, 0);
 		if (!ret && (data->id == max34446 || data->id == max34451 ||
-			     data->id == max34451_na6))
+			     data->id == max34451_na6 || data->id == adpm12160))
 			ret = pmbus_write_word_data(client, page,
 					MAX34446_MFR_IOUT_AVG, 0);
 
@@ -321,6 +322,41 @@  static int max34451_set_supported_funcs(struct i2c_client *client,
 	.write_word_data = max34440_write_word_data,
 
 static struct pmbus_driver_info max34440_info[] = {
+	[adpm12160] = {
+		.pages = 19,
+		.format[PSC_VOLTAGE_IN] = direct,
+		.format[PSC_VOLTAGE_OUT] = direct,
+		.format[PSC_CURRENT_IN] = direct,
+		.format[PSC_CURRENT_OUT] = direct,
+		.format[PSC_TEMPERATURE] = direct,
+		.m[PSC_VOLTAGE_IN] = 1,
+		.b[PSC_VOLTAGE_IN] = 0,
+		.R[PSC_VOLTAGE_IN] = 0,
+		.m[PSC_VOLTAGE_OUT] = 1,
+		.b[PSC_VOLTAGE_OUT] = 0,
+		.R[PSC_VOLTAGE_OUT] = 0,
+		.m[PSC_CURRENT_IN] = 1,
+		.b[PSC_CURRENT_IN] = 0,
+		.R[PSC_CURRENT_IN] = 2,
+		.m[PSC_CURRENT_OUT] = 1,
+		.b[PSC_CURRENT_OUT] = 0,
+		.R[PSC_CURRENT_OUT] = 2,
+		.m[PSC_TEMPERATURE] = 1,
+		.b[PSC_TEMPERATURE] = 0,
+		.R[PSC_TEMPERATURE] = 2,
+		/* absent func below [18] are not for monitoring */
+		.func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
+		.func[4] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
+		.func[5] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
+		.func[6] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
+		.func[7] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
+		.func[8] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
+		.func[9] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT,
+		.func[10] = PMBUS_HAVE_IIN | PMBUS_HAVE_STATUS_INPUT,
+		.func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
+		.read_word_data = max34440_read_word_data,
+		.write_word_data = max34440_write_word_data,
+	},
 	[max34440] = {
 		.pages = 14,
 		.format[PSC_VOLTAGE_IN] = direct,
@@ -538,6 +574,7 @@  static int max34440_probe(struct i2c_client *client)
 }
 
 static const struct i2c_device_id max34440_id[] = {
+	{"adpm12160", adpm12160},
 	{"max34440", max34440},
 	{"max34441", max34441},
 	{"max34446", max34446},