diff mbox series

[v2,2/2] hwmon: pmbus: add driver for ltp8800-1a, ltp8800-4a, and ltp8800-2

Message ID 20241106030918.24849-3-cedricjustine.encarnacion@analog.com
State New
Headers show
Series Add driver for LTP8800-1A, LTP8800-2 and LTP8800-4A | expand

Commit Message

Encarnacion, Cedric justine Nov. 6, 2024, 3:09 a.m. UTC
LTP8800-1A 54V, 150A DC/DC µModule Regulator with PMBus Interface
LTP8800-4A 54V, 200A DC/DC µModule Regulator with PMBus Interface
LTP8800-2 54V, 135A DC/DC μModule Regulator with PMBus Interface

The LTP8800 is a family of step-down μModule regulators that provides
microprocessor core voltage from 54V power distribution architecture. It
features telemetry monitoring of input/output voltage, input current,
output power, and temperature over PMBus.

Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
---
 Documentation/hwmon/index.rst   |  1 +
 Documentation/hwmon/ltp8800.rst | 91 +++++++++++++++++++++++++++++++++
 MAINTAINERS                     |  2 +
 drivers/hwmon/pmbus/Kconfig     | 18 +++++++
 drivers/hwmon/pmbus/Makefile    |  1 +
 drivers/hwmon/pmbus/ltp8800.c   | 63 +++++++++++++++++++++++
 6 files changed, 176 insertions(+)
 create mode 100644 Documentation/hwmon/ltp8800.rst
 create mode 100644 drivers/hwmon/pmbus/ltp8800.c

Comments

Guenter Roeck Nov. 6, 2024, 4:31 a.m. UTC | #1
On 11/5/24 19:09, Cedric Encarnacion wrote:
> LTP8800-1A 54V, 150A DC/DC µModule Regulator with PMBus Interface
> LTP8800-4A 54V, 200A DC/DC µModule Regulator with PMBus Interface
> LTP8800-2 54V, 135A DC/DC μModule Regulator with PMBus Interface
> 
> The LTP8800 is a family of step-down μModule regulators that provides
> microprocessor core voltage from 54V power distribution architecture. It
> features telemetry monitoring of input/output voltage, input current,
> output power, and temperature over PMBus.
> 
> Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
> ---
>   Documentation/hwmon/index.rst   |  1 +
>   Documentation/hwmon/ltp8800.rst | 91 +++++++++++++++++++++++++++++++++
>   MAINTAINERS                     |  2 +
>   drivers/hwmon/pmbus/Kconfig     | 18 +++++++
>   drivers/hwmon/pmbus/Makefile    |  1 +
>   drivers/hwmon/pmbus/ltp8800.c   | 63 +++++++++++++++++++++++
>   6 files changed, 176 insertions(+)
>   create mode 100644 Documentation/hwmon/ltp8800.rst
>   create mode 100644 drivers/hwmon/pmbus/ltp8800.c
> 
> diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
> index 55f1111594b2..8e6799824859 100644
> --- a/Documentation/hwmon/index.rst
> +++ b/Documentation/hwmon/index.rst
> @@ -136,6 +136,7 @@ Hardware Monitoring Kernel Drivers
>      ltc4261
>      ltc4282
>      ltc4286
> +   ltp8800
>      max127
>      max15301
>      max16064
> diff --git a/Documentation/hwmon/ltp8800.rst b/Documentation/hwmon/ltp8800.rst
> new file mode 100644
> index 000000000000..bbe1b4a7c827
> --- /dev/null
> +++ b/Documentation/hwmon/ltp8800.rst
> @@ -0,0 +1,91 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +Kernel driver ltp8800
> +=====================
> +
> +Supported chips:
> +
> +  * Analog Devices LTP8800-1A, LTP8800-2, LTP8800-4A
> +
> +    Prefix: 'ltp8800'
> +
> +    Addresses scanned: -
> +
> +    Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ltp8800-1a.pdf
> +
> +         https://www.analog.com/media/en/technical-documentation/data-sheets/ltp8800-2.pdf
> +
> +         https://www.analog.com/media/en/technical-documentation/data-sheets/ltp8800-4a.pdf
> +
> +Authors:
> +    - Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
> +
> +
> +Description
> +-----------
> +
> +The LTP8800 is a family of step-down μModule regulators that provides
> +microprocessor core voltage from 54V power distribution architecture. LTP8800
> +features telemetry monitoring of input/output voltage, input current, output
> +power, and temperature over PMBus.
> +
> +The driver is a client driver to the core PMBus driver. Please see
> +Documentation/hwmon/pmbus.rst for details on PMBus client drivers.
> +
> +Usage Notes
> +-----------
> +
> +This driver does not auto-detect devices. You will have to instantiate the
> +devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for
> +details.
> +
> +Platform data support
> +---------------------
> +
> +The driver supports standard PMBus driver platform data. Please see
> +Documentation/hwmon/pmbus.rst for details.
> +
> +Sysfs Attributes
> +----------------
> +
> +======================= ===========================
> +curr1_label		"iin"
> +curr1_input		Measured input current
> +curr1_crit		Critical maximum current
> +curr1_crit_alarm	Current critical high alarm
> +
> +curr2_label		"iout1"
> +curr2_input		Measured output current
> +curr2_lcrit		Critical minimum current
> +curr2_crit		Critical maximum current
> +curr2_max		Maximum output current
> +curr2_alarm		Current alarm
> +
> +in1_label		"vin"
> +in1_input		Measured input voltage
> +in1_lcrit		Critical minimum input voltage
> +in1_lcrit_alarm		Input voltage critical low alarm
> +in1_crit		Critical maximum input voltage
> +in1_crit_alarm		Input voltage critical high alarm
> +
> +in2_label		"vout1"
> +in2_input		Measured output voltage
> +in2_lcrit		Critical minimum output voltage
> +in2_lcrit_alarm		Output voltage critical low alarm
> +in2_crit		Critical maximum output voltage
> +in2_crit_alarm		Output voltage critical high alarm
> +in2_max			Maximum output voltage
> +in2_max_alarm		Output voltage high alarm
> +in2_min			Minimum output voltage
> +in2_min_alarm		Output voltage low alarm
> +
> +power1_label		"pout1"
> +power1_input		Measured output power
> +power1_crit		Critical maximum output power
> +
> +temp1_input		Measured temperature
> +temp1_lcrit		Critical low temperature
> +temp1_lcrit_alarm		Chip temperature critical low alarm
> +temp1_crit		Critical high temperature
> +temp1_crit_alarm		Chip temperature critical high alarm
> +======================= ===========================
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6ca691500fb7..a5d1bd61fc2c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13559,6 +13559,8 @@ LTP8800 HARDWARE MONITOR DRIVER
>   M:	Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
>   L:	linux-hwmon@vger.kernel.org
>   S:	Supported
> +F:	Documentation/hwmon/ltp8800.rst
> +F:	drivers/hwmon/pmbus/ltp8800.c
>   
>   LYNX 28G SERDES PHY DRIVER
>   M:	Ioana Ciornei <ioana.ciornei@nxp.com>
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index f6d352841953..264c73275d86 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -247,6 +247,24 @@ config SENSORS_LTC4286
>   	  If you say yes here you get hardware monitoring support for Analog
>   	  Devices LTC4286.
>   
> +config SENSORS_LTP8800
> +	tristate "Analog Devices LTP8800 and compatibles"
> +	help
> +	  If you say yes here you get hardware monitoring support for Analog
> +	  Devices LTP8800-1A, LTP8800-4A, and LTP8800-2.
> +
> +	  This driver can also be built as a module. If so, the module will
> +	  be called ltp8800.
> +
> +config SENSORS_LTP8800_REGULATOR
> +	bool "Regulator support for LTP8800 and compatibles"
> +	depends on SENSORS_LTP8800 && REGULATOR
> +	help
> +	  If you say yes here you get regulator support for Analog Devices
> +	  LTP8800-1A, LTP8800-4A, and LTP8800-2. LTP8800 is a family of DC/DC
> +	  µModule regulators that can provide microprocessor power from 54V
> +	  power distribution architecture.
> +
>   config SENSORS_MAX15301
>   	tristate "Maxim MAX15301"
>   	help
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index d00bcc758b97..aa5bbdb4a806 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -26,6 +26,7 @@ obj-$(CONFIG_SENSORS_LT7182S)	+= lt7182s.o
>   obj-$(CONFIG_SENSORS_LTC2978)	+= ltc2978.o
>   obj-$(CONFIG_SENSORS_LTC3815)	+= ltc3815.o
>   obj-$(CONFIG_SENSORS_LTC4286)	+= ltc4286.o
> +obj-$(CONFIG_SENSORS_LTP8800)	+= ltp8800.o
>   obj-$(CONFIG_SENSORS_MAX15301)	+= max15301.o
>   obj-$(CONFIG_SENSORS_MAX16064)	+= max16064.o
>   obj-$(CONFIG_SENSORS_MAX16601)	+= max16601.o
> diff --git a/drivers/hwmon/pmbus/ltp8800.c b/drivers/hwmon/pmbus/ltp8800.c
> new file mode 100644
> index 000000000000..d57f8c058a89
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/ltp8800.c
> @@ -0,0 +1,63 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Hardware monitoring driver for Analog Devices LTP8800
> + *
> + * Copyright (C) 2024 Analog Devices, Inc.
> + */
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include "pmbus.h"
> +
> +static const struct regulator_desc ltp8800_reg_desc[] = {
> +	PMBUS_REGULATOR("vout", 0),

Ah, sorry, I didn't realize this earlier. This needs to use "PMBUS_REGULATOR_ONE("vout")"
since there is only a single regulator (which needs to be named "vout" and not "vout0").

Thanks,
Guenter

> +};
> +
> +static struct pmbus_driver_info ltp8800_info = {
> +	.pages = 1,
> +	.format[PSC_VOLTAGE_IN] = linear,
> +	.format[PSC_VOLTAGE_OUT] = linear,
> +	.format[PSC_CURRENT_IN] = linear,
> +	.format[PSC_TEMPERATURE] = linear,
> +	.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> +		   PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT |
> +		   PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT |
> +		   PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
> +		   PMBUS_HAVE_POUT,
> +#if IS_ENABLED(CONFIG_SENSORS_LTP8800_REGULATOR)
> +	.num_regulators = 1,
> +	.reg_desc = ltp8800_reg_desc,
> +#endif
> +};
> +
> +static int ltp8800_probe(struct i2c_client *client)
> +{
> +	return pmbus_do_probe(client, &ltp8800_info);
> +}
> +
> +static const struct i2c_device_id ltp8800_id[] = {
> +	{"ltp8800", 0},
> +	{}
> +};
> +MODULE_DEVICE_TABLE(i2c, ltp8800_id);
> +
> +static const struct of_device_id ltp8800_of_match[] = {
> +	{ .compatible = "adi,ltp8800"},
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, ltp8800_of_match);
> +
> +static struct i2c_driver ltp8800_driver = {
> +	.driver = {
> +		.name = "ltp8800",
> +		.of_match_table = ltp8800_of_match,
> +	},
> +	.probe = ltp8800_probe,
> +	.id_table = ltp8800_id,
> +};
> +module_i2c_driver(ltp8800_driver);
> +
> +MODULE_AUTHOR("Cedric Encarnacion <cedricjustine.encarnacion@analog.com>");
> +MODULE_DESCRIPTION("Analog Devices LTP8800 HWMON PMBus Driver");
> +MODULE_LICENSE("GPL");
> +MODULE_IMPORT_NS(PMBUS);
kernel test robot Nov. 6, 2024, 6:45 p.m. UTC | #2
Hi Cedric,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 30a984c0c9d8c631cc135280f83c441d50096b6d]

url:    https://github.com/intel-lab-lkp/linux/commits/Cedric-Encarnacion/dt-bindings-trivial-devices-add-ltp8800/20241106-111734
base:   30a984c0c9d8c631cc135280f83c441d50096b6d
patch link:    https://lore.kernel.org/r/20241106030918.24849-3-cedricjustine.encarnacion%40analog.com
patch subject: [PATCH v2 2/2] hwmon: pmbus: add driver for ltp8800-1a, ltp8800-4a, and ltp8800-2
config: x86_64-buildonly-randconfig-004-20241107 (https://download.01.org/0day-ci/archive/20241107/202411070232.xrxV7tVx-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241107/202411070232.xrxV7tVx-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/202411070232.xrxV7tVx-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/hwmon/pmbus/ltp8800.c:7:
   In file included from include/linux/i2c.h:19:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:21:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> drivers/hwmon/pmbus/ltp8800.c:12:36: warning: unused variable 'ltp8800_reg_desc' [-Wunused-const-variable]
      12 | static const struct regulator_desc ltp8800_reg_desc[] = {
         |                                    ^~~~~~~~~~~~~~~~
   2 warnings generated.


vim +/ltp8800_reg_desc +12 drivers/hwmon/pmbus/ltp8800.c

    11	
  > 12	static const struct regulator_desc ltp8800_reg_desc[] = {
    13		PMBUS_REGULATOR("vout", 0),
    14	};
    15
kernel test robot Nov. 6, 2024, 7:17 p.m. UTC | #3
Hi Cedric,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 30a984c0c9d8c631cc135280f83c441d50096b6d]

url:    https://github.com/intel-lab-lkp/linux/commits/Cedric-Encarnacion/dt-bindings-trivial-devices-add-ltp8800/20241106-111734
base:   30a984c0c9d8c631cc135280f83c441d50096b6d
patch link:    https://lore.kernel.org/r/20241106030918.24849-3-cedricjustine.encarnacion%40analog.com
patch subject: [PATCH v2 2/2] hwmon: pmbus: add driver for ltp8800-1a, ltp8800-4a, and ltp8800-2
config: x86_64-buildonly-randconfig-002-20241107 (https://download.01.org/0day-ci/archive/20241107/202411070253.p3aIhGGg-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/20241107/202411070253.p3aIhGGg-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/202411070253.p3aIhGGg-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/hwmon/pmbus/ltp8800.c:12:36: warning: 'ltp8800_reg_desc' defined but not used [-Wunused-const-variable=]
      12 | static const struct regulator_desc ltp8800_reg_desc[] = {
         |                                    ^~~~~~~~~~~~~~~~


vim +/ltp8800_reg_desc +12 drivers/hwmon/pmbus/ltp8800.c

    11	
  > 12	static const struct regulator_desc ltp8800_reg_desc[] = {
    13		PMBUS_REGULATOR("vout", 0),
    14	};
    15
Guenter Roeck Nov. 7, 2024, 1:45 a.m. UTC | #4
On 11/5/24 19:09, Cedric Encarnacion wrote:
> LTP8800-1A 54V, 150A DC/DC µModule Regulator with PMBus Interface
> LTP8800-4A 54V, 200A DC/DC µModule Regulator with PMBus Interface
> LTP8800-2 54V, 135A DC/DC μModule Regulator with PMBus Interface
> 
> The LTP8800 is a family of step-down μModule regulators that provides
> microprocessor core voltage from 54V power distribution architecture. It
> features telemetry monitoring of input/output voltage, input current,
> output power, and temperature over PMBus.
> 
> Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>

Looking closer into the datasheets, I found that the PMBus commands are identical
to those of ADP1055, and an extension of the ADP1050 driver to support ADP1055
has been submitted.

With this in mind, please explain why this series warrants a new driver instead
of just extending the existing driver to support LTP8800.

Thanks,
Guenter
Encarnacion, Cedric justine Nov. 8, 2024, 7:44 a.m. UTC | #5
> -----Original Message-----
> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
> Sent: Thursday, November 7, 2024 9:45 AM
> To: Encarnacion, Cedric justine <Cedricjustine.Encarnacion@analog.com>;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
> i2c@vger.kernel.org; linux-doc@vger.kernel.org; linux-
> hwmon@vger.kernel.org
> Cc: Jean Delvare <jdelvare@suse.com>; Jonathan Corbet <corbet@lwn.net>;
> Delphine CC Chiu <Delphine_CC_Chiu@Wiwynn.com>; Rob Herring
> <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley
> <conor+dt@kernel.org>; Peter Yin <peteryin.openbmc@gmail.com>; Noah
> Wang <noahwang.wang@outlook.com>; Marek Vasut <marex@denx.de>;
> Lukas Wunner <lukas@wunner.de>
> Subject: Re: [PATCH v2 2/2] hwmon: pmbus: add driver for ltp8800-1a,
> ltp8800-4a, and ltp8800-2
> 
> [External]
> 
> On 11/5/24 19:09, Cedric Encarnacion wrote:
> > LTP8800-1A 54V, 150A DC/DC µModule Regulator with PMBus Interface
> > LTP8800-4A 54V, 200A DC/DC µModule Regulator with PMBus Interface
> > LTP8800-2 54V, 135A DC/DC μModule Regulator with PMBus Interface
> >
> > The LTP8800 is a family of step-down μModule regulators that provides
> > microprocessor core voltage from 54V power distribution architecture. It
> > features telemetry monitoring of input/output voltage, input current,
> > output power, and temperature over PMBus.
> >
> > Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
> 
> Looking closer into the datasheets, I found that the PMBus commands are
> identical
> to those of ADP1055, and an extension of the ADP1050 driver to support
> ADP1055
> has been submitted.
> 
> With this in mind, please explain why this series warrants a new driver instead
> of just extending the existing driver to support LTP8800.

It also appears that the LTP8800-1A regulator makes use of
factory-programmed ADP1055 but this is not explicitly stated for other
variants. Initially, I thought a new client driver would be reasonable
since this device is intended as a regulator while ADP1050/ADP1055 is a
more customizable digital controller, and both have their own multiple
variants. Indeed, it may be more reasonable to extend existing driver since
they are exposing the same feature. In this case, can this be done in
succeeding version/s of this series?

Thank you, 
Cedric

> 
> Thanks,
> Guenter
Guenter Roeck Nov. 8, 2024, 2:31 p.m. UTC | #6
On 11/7/24 23:44, Encarnacion, Cedric justine wrote:
>> -----Original Message-----
>> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
>> Sent: Thursday, November 7, 2024 9:45 AM
>> To: Encarnacion, Cedric justine <Cedricjustine.Encarnacion@analog.com>;
>> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
>> i2c@vger.kernel.org; linux-doc@vger.kernel.org; linux-
>> hwmon@vger.kernel.org
>> Cc: Jean Delvare <jdelvare@suse.com>; Jonathan Corbet <corbet@lwn.net>;
>> Delphine CC Chiu <Delphine_CC_Chiu@Wiwynn.com>; Rob Herring
>> <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley
>> <conor+dt@kernel.org>; Peter Yin <peteryin.openbmc@gmail.com>; Noah
>> Wang <noahwang.wang@outlook.com>; Marek Vasut <marex@denx.de>;
>> Lukas Wunner <lukas@wunner.de>
>> Subject: Re: [PATCH v2 2/2] hwmon: pmbus: add driver for ltp8800-1a,
>> ltp8800-4a, and ltp8800-2
>>
>> [External]
>>
>> On 11/5/24 19:09, Cedric Encarnacion wrote:
>>> LTP8800-1A 54V, 150A DC/DC µModule Regulator with PMBus Interface
>>> LTP8800-4A 54V, 200A DC/DC µModule Regulator with PMBus Interface
>>> LTP8800-2 54V, 135A DC/DC μModule Regulator with PMBus Interface
>>>
>>> The LTP8800 is a family of step-down μModule regulators that provides
>>> microprocessor core voltage from 54V power distribution architecture. It
>>> features telemetry monitoring of input/output voltage, input current,
>>> output power, and temperature over PMBus.
>>>
>>> Signed-off-by: Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
>>
>> Looking closer into the datasheets, I found that the PMBus commands are
>> identical
>> to those of ADP1055, and an extension of the ADP1050 driver to support
>> ADP1055
>> has been submitted.
>>
>> With this in mind, please explain why this series warrants a new driver instead
>> of just extending the existing driver to support LTP8800.
> 
> It also appears that the LTP8800-1A regulator makes use of
> factory-programmed ADP1055 but this is not explicitly stated for other
> variants. Initially, I thought a new client driver would be reasonable
> since this device is intended as a regulator while ADP1050/ADP1055 is a
> more customizable digital controller, and both have their own multiple

We use the same driver for many variants of ltc2978. We should do the same here.

> variants. Indeed, it may be more reasonable to extend existing driver since
> they are exposing the same feature. In this case, can this be done in
> succeeding version/s of this series?
> 

Succeeding version, but please synchronize with the engineer adding support
for adp1055 to the adp1050 driver. Another option would be to make adding support
for adp1051/adp1055 and adding support for ltp880X chips a patch series. The
introductory patch could then reference the original patch series.

Thanks,
Guenter
Encarnacion, Cedric justine Nov. 13, 2024, 5:45 a.m. UTC | #7
> -----Original Message-----
> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
> Sent: Friday, November 8, 2024 10:31 PM
> To: Encarnacion, Cedric justine <Cedricjustine.Encarnacion@analog.com>;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
> i2c@vger.kernel.org; linux-doc@vger.kernel.org; linux-hwmon@vger.kernel.org
> Cc: Jean Delvare <jdelvare@suse.com>; Jonathan Corbet <corbet@lwn.net>;
> Delphine CC Chiu <Delphine_CC_Chiu@Wiwynn.com>; Rob Herring
> <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley
> <conor+dt@kernel.org>; Peter Yin <peteryin.openbmc@gmail.com>; Noah
> Wang <noahwang.wang@outlook.com>; Marek Vasut <marex@denx.de>; Lukas
> Wunner <lukas@wunner.de>
> Subject: Re: [PATCH v2 2/2] hwmon: pmbus: add driver for ltp8800-1a, ltp8800-
> 4a, and ltp8800-2
> 
> [External]
> 
> On 11/7/24 23:44, Encarnacion, Cedric justine wrote:
> >> -----Original Message-----
> >> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
> >> Sent: Thursday, November 7, 2024 9:45 AM
> >> To: Encarnacion, Cedric justine <Cedricjustine.Encarnacion@analog.com>;
> >> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
> >> i2c@vger.kernel.org; linux-doc@vger.kernel.org; linux-
> >> hwmon@vger.kernel.org
> >> Cc: Jean Delvare <jdelvare@suse.com>; Jonathan Corbet <corbet@lwn.net>;
> >> Delphine CC Chiu <Delphine_CC_Chiu@Wiwynn.com>; Rob Herring
> >> <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor
> Dooley
> >> <conor+dt@kernel.org>; Peter Yin <peteryin.openbmc@gmail.com>; Noah
> >> Wang <noahwang.wang@outlook.com>; Marek Vasut <marex@denx.de>;
> >> Lukas Wunner <lukas@wunner.de>
> >> Subject: Re: [PATCH v2 2/2] hwmon: pmbus: add driver for ltp8800-1a,
> >> ltp8800-4a, and ltp8800-2
> >>
> >> [External]
> >>
> >> On 11/5/24 19:09, Cedric Encarnacion wrote:
> >>> LTP8800-1A 54V, 150A DC/DC µModule Regulator with PMBus Interface
> >>> LTP8800-4A 54V, 200A DC/DC µModule Regulator with PMBus Interface
> >>> LTP8800-2 54V, 135A DC/DC μModule Regulator with PMBus Interface
> >>>
> >>> The LTP8800 is a family of step-down μModule regulators that provides
> >>> microprocessor core voltage from 54V power distribution architecture. It
> >>> features telemetry monitoring of input/output voltage, input current,
> >>> output power, and temperature over PMBus.
> >>>
> >>> Signed-off-by: Cedric Encarnacion
> <cedricjustine.encarnacion@analog.com>
> >>
> >> Looking closer into the datasheets, I found that the PMBus commands are
> >> identical
> >> to those of ADP1055, and an extension of the ADP1050 driver to support
> >> ADP1055
> >> has been submitted.
> >>
> >> With this in mind, please explain why this series warrants a new driver instead
> >> of just extending the existing driver to support LTP8800.
> >
> > It also appears that the LTP8800-1A regulator makes use of
> > factory-programmed ADP1055 but this is not explicitly stated for other
> > variants. Initially, I thought a new client driver would be reasonable
> > since this device is intended as a regulator while ADP1050/ADP1055 is a
> > more customizable digital controller, and both have their own multiple
> 
> We use the same driver for many variants of ltc2978. We should do the same
> here.
> 
> > variants. Indeed, it may be more reasonable to extend existing driver since
> > they are exposing the same feature. In this case, can this be done in
> > succeeding version/s of this series?
> >
> 
> Succeeding version, but please synchronize with the engineer adding support
> for adp1055 to the adp1050 driver. Another option would be to make adding
> support
> for adp1051/adp1055 and adding support for ltp880X chips a patch series. The
> introductory patch could then reference the original patch series.
> 
> Thanks,
> Guenter

I coordinated with the engineer adding support for ADP1051/ADP1055. We will
be submitting a new patch series adding support for ADP1051, ADP1055 and
LTP8800-XX with reference to the original patch series.

Regards,
Cedric
diff mbox series

Patch

diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index 55f1111594b2..8e6799824859 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -136,6 +136,7 @@  Hardware Monitoring Kernel Drivers
    ltc4261
    ltc4282
    ltc4286
+   ltp8800
    max127
    max15301
    max16064
diff --git a/Documentation/hwmon/ltp8800.rst b/Documentation/hwmon/ltp8800.rst
new file mode 100644
index 000000000000..bbe1b4a7c827
--- /dev/null
+++ b/Documentation/hwmon/ltp8800.rst
@@ -0,0 +1,91 @@ 
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver ltp8800
+=====================
+
+Supported chips:
+
+  * Analog Devices LTP8800-1A, LTP8800-2, LTP8800-4A
+
+    Prefix: 'ltp8800'
+
+    Addresses scanned: -
+
+    Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ltp8800-1a.pdf
+
+         https://www.analog.com/media/en/technical-documentation/data-sheets/ltp8800-2.pdf
+
+         https://www.analog.com/media/en/technical-documentation/data-sheets/ltp8800-4a.pdf
+
+Authors:
+    - Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
+
+
+Description
+-----------
+
+The LTP8800 is a family of step-down μModule regulators that provides
+microprocessor core voltage from 54V power distribution architecture. LTP8800
+features telemetry monitoring of input/output voltage, input current, output
+power, and temperature over PMBus.
+
+The driver is a client driver to the core PMBus driver. Please see
+Documentation/hwmon/pmbus.rst for details on PMBus client drivers.
+
+Usage Notes
+-----------
+
+This driver does not auto-detect devices. You will have to instantiate the
+devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for
+details.
+
+Platform data support
+---------------------
+
+The driver supports standard PMBus driver platform data. Please see
+Documentation/hwmon/pmbus.rst for details.
+
+Sysfs Attributes
+----------------
+
+======================= ===========================
+curr1_label		"iin"
+curr1_input		Measured input current
+curr1_crit		Critical maximum current
+curr1_crit_alarm	Current critical high alarm
+
+curr2_label		"iout1"
+curr2_input		Measured output current
+curr2_lcrit		Critical minimum current
+curr2_crit		Critical maximum current
+curr2_max		Maximum output current
+curr2_alarm		Current alarm
+
+in1_label		"vin"
+in1_input		Measured input voltage
+in1_lcrit		Critical minimum input voltage
+in1_lcrit_alarm		Input voltage critical low alarm
+in1_crit		Critical maximum input voltage
+in1_crit_alarm		Input voltage critical high alarm
+
+in2_label		"vout1"
+in2_input		Measured output voltage
+in2_lcrit		Critical minimum output voltage
+in2_lcrit_alarm		Output voltage critical low alarm
+in2_crit		Critical maximum output voltage
+in2_crit_alarm		Output voltage critical high alarm
+in2_max			Maximum output voltage
+in2_max_alarm		Output voltage high alarm
+in2_min			Minimum output voltage
+in2_min_alarm		Output voltage low alarm
+
+power1_label		"pout1"
+power1_input		Measured output power
+power1_crit		Critical maximum output power
+
+temp1_input		Measured temperature
+temp1_lcrit		Critical low temperature
+temp1_lcrit_alarm		Chip temperature critical low alarm
+temp1_crit		Critical high temperature
+temp1_crit_alarm		Chip temperature critical high alarm
+======================= ===========================
diff --git a/MAINTAINERS b/MAINTAINERS
index 6ca691500fb7..a5d1bd61fc2c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13559,6 +13559,8 @@  LTP8800 HARDWARE MONITOR DRIVER
 M:	Cedric Encarnacion <cedricjustine.encarnacion@analog.com>
 L:	linux-hwmon@vger.kernel.org
 S:	Supported
+F:	Documentation/hwmon/ltp8800.rst
+F:	drivers/hwmon/pmbus/ltp8800.c
 
 LYNX 28G SERDES PHY DRIVER
 M:	Ioana Ciornei <ioana.ciornei@nxp.com>
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index f6d352841953..264c73275d86 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -247,6 +247,24 @@  config SENSORS_LTC4286
 	  If you say yes here you get hardware monitoring support for Analog
 	  Devices LTC4286.
 
+config SENSORS_LTP8800
+	tristate "Analog Devices LTP8800 and compatibles"
+	help
+	  If you say yes here you get hardware monitoring support for Analog
+	  Devices LTP8800-1A, LTP8800-4A, and LTP8800-2.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called ltp8800.
+
+config SENSORS_LTP8800_REGULATOR
+	bool "Regulator support for LTP8800 and compatibles"
+	depends on SENSORS_LTP8800 && REGULATOR
+	help
+	  If you say yes here you get regulator support for Analog Devices
+	  LTP8800-1A, LTP8800-4A, and LTP8800-2. LTP8800 is a family of DC/DC
+	  µModule regulators that can provide microprocessor power from 54V
+	  power distribution architecture.
+
 config SENSORS_MAX15301
 	tristate "Maxim MAX15301"
 	help
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index d00bcc758b97..aa5bbdb4a806 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -26,6 +26,7 @@  obj-$(CONFIG_SENSORS_LT7182S)	+= lt7182s.o
 obj-$(CONFIG_SENSORS_LTC2978)	+= ltc2978.o
 obj-$(CONFIG_SENSORS_LTC3815)	+= ltc3815.o
 obj-$(CONFIG_SENSORS_LTC4286)	+= ltc4286.o
+obj-$(CONFIG_SENSORS_LTP8800)	+= ltp8800.o
 obj-$(CONFIG_SENSORS_MAX15301)	+= max15301.o
 obj-$(CONFIG_SENSORS_MAX16064)	+= max16064.o
 obj-$(CONFIG_SENSORS_MAX16601)	+= max16601.o
diff --git a/drivers/hwmon/pmbus/ltp8800.c b/drivers/hwmon/pmbus/ltp8800.c
new file mode 100644
index 000000000000..d57f8c058a89
--- /dev/null
+++ b/drivers/hwmon/pmbus/ltp8800.c
@@ -0,0 +1,63 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Hardware monitoring driver for Analog Devices LTP8800
+ *
+ * Copyright (C) 2024 Analog Devices, Inc.
+ */
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include "pmbus.h"
+
+static const struct regulator_desc ltp8800_reg_desc[] = {
+	PMBUS_REGULATOR("vout", 0),
+};
+
+static struct pmbus_driver_info ltp8800_info = {
+	.pages = 1,
+	.format[PSC_VOLTAGE_IN] = linear,
+	.format[PSC_VOLTAGE_OUT] = linear,
+	.format[PSC_CURRENT_IN] = linear,
+	.format[PSC_TEMPERATURE] = linear,
+	.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
+		   PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT |
+		   PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT |
+		   PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
+		   PMBUS_HAVE_POUT,
+#if IS_ENABLED(CONFIG_SENSORS_LTP8800_REGULATOR)
+	.num_regulators = 1,
+	.reg_desc = ltp8800_reg_desc,
+#endif
+};
+
+static int ltp8800_probe(struct i2c_client *client)
+{
+	return pmbus_do_probe(client, &ltp8800_info);
+}
+
+static const struct i2c_device_id ltp8800_id[] = {
+	{"ltp8800", 0},
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, ltp8800_id);
+
+static const struct of_device_id ltp8800_of_match[] = {
+	{ .compatible = "adi,ltp8800"},
+	{}
+};
+MODULE_DEVICE_TABLE(of, ltp8800_of_match);
+
+static struct i2c_driver ltp8800_driver = {
+	.driver = {
+		.name = "ltp8800",
+		.of_match_table = ltp8800_of_match,
+	},
+	.probe = ltp8800_probe,
+	.id_table = ltp8800_id,
+};
+module_i2c_driver(ltp8800_driver);
+
+MODULE_AUTHOR("Cedric Encarnacion <cedricjustine.encarnacion@analog.com>");
+MODULE_DESCRIPTION("Analog Devices LTP8800 HWMON PMBus Driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(PMBUS);