hwmon: (pmbus) Add support for MPS MP2949A
Subsystems (2)
PATCH 1/1 hwmon: (pmbus) Add support for MPS MP2949A
From: "Ainux.Wang" <[email protected]>
Add support for MP2949A device from Monolithic Power Systems, Inc. (MPS) vendor. This is a triple-loop, digital, multi-phase controller. This device:
- Supports up to three power rail.
- Provides 6 pulse-width modulations (PWMs), and can be configured up to 6-phase operation for Rail A , up to 2-phase operation for Rail B and up to 1-phase operation for Rail C.
- The PMBus registers are distributed into three pages: Page 0, Page 1, Page 2. Page 0 contains the registers for Rail A and most of the common settings for all of the rails. Page 1 contains register information for Rail B. Page 2 contains register information for Rail C.
- The MP2949A supports both 5mV VID step and 10mv VID step for IMVP8 and IMVP9 with only one DAC for each rail to generate REF.
--- Documentation/hwmon/mp2949a.rst | 48 ++++++++++++++++++ drivers/hwmon/pmbus/Kconfig | 9 ++++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/mp2949a.c | 83 ++++++++++++++++++++++++++++++++ drivers/hwmon/pmbus/pmbus.h | 6 +++ drivers/hwmon/pmbus/pmbus_core.c | 18 +++++-- 6 files changed, 160 insertions(+), 5 deletions(-) create mode 100644 Documentation/hwmon/mp2949a.rst create mode 100644 drivers/hwmon/pmbus/mp2949a.c
Documentation/hwmon/mp2949a.rst new file +48 -0
@@ -0,0 +1,48 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver mp2949a +==================== + +Supported chips: + + * MPS MP2949A + + Prefix: 'mp2949a' + +Author: + + Ainux Wang <[email protected]> + +Description +----------- + +This driver implements support for Monolithic Power Systems, Inc. (MPS) +vendor triple-loop, digital, multi-phase controller MP2949A. + +This device: + +- Supports up to three power rail. +- Provides 6 pulse-width modulations (PWMs), and can be configured up + to 6-phase operation for Rail A , up to 2-phase operation for Rail B + and up to 1-phase operation for Rail C. +- The PMBus registers are distributed into three pages: Page 0, Page 1, + Page 2. Page 0 contains the registers for Rail A and most of the common + settings for all of the rails. Page 1 contains register information for + Rail B. Page 2 contains register information for Rail C. +- The MP2949A supports both 5mV VID step and 10mv VID step for IMVP8 and + IMVP9 with only one DAC for each rail to generate REF. + +Device supports: + +- SVID interface. +- PMBus interface. + +Device complaint with: + +- PMBus rev 1.2 interface. + +Device supports direct format for reading output power. +Device supports linear format for reading input voltage and output current +and temperature. +Device supports VID for reading output voltage. +The below VID modes are supported: VR12, VR13, IMVP8, IMVP9.
drivers/hwmon/pmbus/Kconfig +9 -0
@@ -248,6 +248,15 @@ config SENSORS_MAX8688 This driver can also be built as a module. If so, the module will be called max8688. +config SENSORS_MP2949A + tristate "MPS MP2949A" + help + If you say yes here you get hardware monitoring support for MPS + MP2949A Triple Loop Digital Multi-Phase Controller. + + This driver can also be built as a module. If so, the module will + be called mp2949a. + config SENSORS_MP2975 tristate "MPS MP2975" help
drivers/hwmon/pmbus/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_SENSORS_MAX20751) += max20751.o obj-$(CONFIG_SENSORS_MAX31785) += max31785.o obj-$(CONFIG_SENSORS_MAX34440) += max34440.o obj-$(CONFIG_SENSORS_MAX8688) += max8688.o +obj-$(CONFIG_SENSORS_MP2949A) += mp2949a.o obj-$(CONFIG_SENSORS_MP2975) += mp2975.o obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o obj-$(CONFIG_SENSORS_PXE1610) += pxe1610.o
drivers/hwmon/pmbus/mp2949a.c new file +83 -0
83 lines not on this page · raw message
drivers/hwmon/pmbus/pmbus.h +6 -0
@@ -454,6 +454,12 @@ struct pmbus_driver_info {/* custom attributes */ const struct attribute_group **groups; + +/* +* Skip identify chip parameters, +* some device do not support the PMBUS_VOUT_MODE. +*/ +bool skip_icp; };/* Regulator ops */
drivers/hwmon/pmbus/pmbus_core.c +13 -5
@@ -2248,13 +2248,21 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,return -ENODEV ; } -for (page =0 ; page < info->pages; page++) { - ret =pmbus_identify_common (client, data, page); -if (ret <0 ) { -dev_err (dev,"Failed to identify chip capabilities\n" ); -return ret; +/* +* Some device do not support the PMBUS_VOUT_MODE, +* and the driver of device has known correct formats, +* so the driver set skip_icp to true. +*/ +if (!data->info->skip_icp) { +for (page =0 ; page < info->pages; page++) { + ret =pmbus_identify_common (client, data, page); +if (ret <0 ) { +dev_err (dev,"Failed to identify chip capabilities\n" ); +return ret; + } } } +return 0 ; }
Signature · 1 line
2.18.1
Guenter Roeck
maintainerQuoted 16 lines · On Thu, Jun 17, 2021 at 05:43:23PM +0800, [email protected] wrote:
From: "Ainux.Wang" <[email protected]>
Add support for MP2949A device from Monolithic Power Systems, Inc. (MPS) vendor. This is a triple-loop, digital, multi-phase controller. This device:
- Supports up to three power rail.
- Provides 6 pulse-width modulations (PWMs), and can be configured up to 6-phase operation for Rail A , up to 2-phase operation for Rail B and up to 1-phase operation for Rail C.
- The PMBus registers are distributed into three pages: Page 0, Page 1, Page 2. Page 0 contains the registers for Rail A and most of the common settings for all of the rails. Page 1 contains register information for Rail B. Page 2 contains register information for Rail C.
- The MP2949A supports both 5mV VID step and 10mv VID step for IMVP8 and IMVP9 with only one DAC for each rail to generate REF.
Quoted 3 lines
Signed-off-by Ainux.Wang <[email protected]>--- Documentation/hwmon/mp2949a.rst | 48 ++++++++++++++++++
Reference needs to be added to Documentation/hwmon/index.rst.
Quoted 5 lines
drivers/hwmon/pmbus/Kconfig | 9 ++++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/mp2949a.c | 83 ++++++++++++++++++++++++++++++++ drivers/hwmon/pmbus/pmbus.h | 6 +++ drivers/hwmon/pmbus/pmbus_core.c | 18 +++++--
Changes to the PMBus core need to be submitted as separate patches.
Quoted 20 lines
6 files changed, 160 insertions(+), 5 deletions(-) create mode 100644 Documentation/hwmon/mp2949a.rst create mode 100644 drivers/hwmon/pmbus/mp2949a.cDocumentation/hwmon/mp2949a.rst new file +10
-0@@ -0,0 +1,48 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver mp2949a +==================== + +Supported chips: + + * MPS MP2949A + + Prefix: 'mp2949a'
Documentation/hwmon/mp2949a.rst line 20
Quoted 10 lines
Documentation/hwmon/mp2949a.rst new file +10
-0+ +Author: + + Ainux Wang <[email protected]> + +Description +----------- + +This driver implements support for Monolithic Power Systems, Inc. (MPS) +vendor triple-loop, digital, multi-phase controller MP2949A.
drop 'vendor'
Quoted 10 lines
Documentation/hwmon/mp2949a.rst new file +10
-0+ +This device: + +- Supports up to three power rail. +- Provides 6 pulse-width modulations (PWMs), and can be configured up + to 6-phase operation for Rail A , up to 2-phase operation for Rail B + and up to 1-phase operation for Rail C. +- The PMBus registers are distributed into three pages: Page 0, Page 1, + Page 2. Page 0 contains the registers for Rail A and most of the common + settings for all of the rails. Page 1 contains register information for
Documentation/hwmon/mp2949a.rst line 40
Quoted 10 lines
Documentation/hwmon/mp2949a.rst new file +10
-0+ Rail B. Page 2 contains register information for Rail C. +- The MP2949A supports both 5mV VID step and 10mv VID step for IMVP8 and + IMVP9 with only one DAC for each rail to generate REF. + +Device supports: + +- SVID interface. +- PMBus interface. + +Device complaint with:
compliant
Quoted 73 lines
Documentation/hwmon/mp2949a.rst new file +8
-0+ +- PMBus rev 1.2 interface. + +Device supports direct format for reading output power. +Device supports linear format for reading input voltage and output current +and temperature. +Device supports VID for reading output voltage. +The below VID modes are supported: VR12, VR13, IMVP8, IMVP9.drivers/hwmon/pmbus/Kconfig +9
-0@@ -248,6 +248,15 @@ config SENSORS_MAX8688 This driver can also be built as a module. If so, the module will be called max8688. +config SENSORS_MP2949A + tristate "MPS MP2949A" + help + If you say yes here you get hardware monitoring support for MPS + MP2949A Triple Loop Digital Multi-Phase Controller. + + This driver can also be built as a module. If so, the module will + be called mp2949a. + config SENSORS_MP2975 tristate "MPS MP2975" helpdrivers/hwmon/pmbus/Makefile +1
-0@@ -28,6 +28,7 @@ obj-$(CONFIG_SENSORS_MAX20751) += max20751.o obj-$(CONFIG_SENSORS_MAX31785) += max31785.o obj-$(CONFIG_SENSORS_MAX34440) += max34440.o obj-$(CONFIG_SENSORS_MAX8688) += max8688.o +obj-$(CONFIG_SENSORS_MP2949A) += mp2949a.o obj-$(CONFIG_SENSORS_MP2975) += mp2975.o obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o obj-$(CONFIG_SENSORS_PXE1610) += pxe1610.odrivers/hwmon/pmbus/mp2949a.c new file +27
-0@@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Hardware monitoring driver for Monolithic Power Systems MP2949A +* +* Copyright (c) 2021 Lemote Technologies. All rights reserved. +* Copyright (c) 2021 Ainux <[email protected]> +*/ + +#include <linux/err.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include "pmbus.h" + +#define MP2949A_PAGE_NUM 3 + +static struct pmbus_driver_info mp2949a_info = { + .pages =MP2949A_PAGE_NUM , + .format[PSC_VOLTAGE_IN ] = linear, + .format[PSC_VOLTAGE_OUT ] = vid, + .format[PSC_CURRENT_OUT ] = linear, + .format[PSC_TEMPERATURE ] = linear, + .format[PSC_POWER ] = direct, + .m[PSC_POWER ] =1 , + .b[PSC_POWER ] =0 , + .R[PSC_POWER ] =0 ,
drivers/hwmon/pmbus/mp2949a.c line 37
Quoted 10 lines
drivers/hwmon/pmbus/mp2949a.c new file +10
-0+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | +PMBUS_HAVE_IOUT |PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_POUT, + .func[1 ] =PMBUS_HAVE_VOUT |PMBUS_HAVE_STATUS_VOUT | +PMBUS_HAVE_IOUT |PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_POUT, + .func[2 ] =PMBUS_HAVE_VOUT |PMBUS_HAVE_STATUS_VOUT | +PMBUS_HAVE_IOUT |PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_POUT, + .skip_icp = true,
We already have a means to specify device specific flags (pmbus_platform_data). Please use it when needed.
Quoted 5 lines
drivers/hwmon/pmbus/mp2949a.c new file +5
-0+}; + +static int mp2949a_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{
drivers/hwmon/pmbus/mp2949a.c line 52
Quoted 10 lines
drivers/hwmon/pmbus/mp2949a.c new file +10
-0+struct pmbus_driver_info *info; +int i; + + info =devm_kmemdup (&client->dev, &mp2949a_info,sizeof (*info), +GFP_KERNEL ); +if (!info) +return -ENOMEM ; + +for (i =0 ; i <MP2949A_PAGE_NUM ; i++) + info->vrm_version[i] = vr12;
The chip supports both 5mv step size (vr12/imvp8) and 10mv step size (imvp9). This suggests that the driver should identify the mode dynamically using the identify callback and set vrm_version based on MFR_VR_CONFIG bit 5.
Quoted 56 lines
drivers/hwmon/pmbus/mp2949a.c new file +31
-0+ +return pmbus_do_probe (client, info); +} + +static const struct i2c_device_id mp2949a_id[] = { + {"mp2949a" ,0 }, + {} +}; + +MODULE_DEVICE_TABLE (i2c, mp2949a_id); + +static const struct of_device_id mp2949a_of_match[] = { + {.compatible ="mps,mp2949a" }, + {} +}; +MODULE_DEVICE_TABLE (of, mp2949a_of_match); + +static struct i2c_driver mp2949a_driver = { + .driver = { + .name ="mp2949a" , + .of_match_table =of_match_ptr (mp2949a_of_match), + }, + .probe = mp2949a_probe, + .id_table = mp2949a_id, +}; + +module_i2c_driver (mp2949a_driver); + +MODULE_AUTHOR ("Ainux <[email protected]>" ); +MODULE_DESCRIPTION ("PMBus driver for Monolithic Power Systems MP2949A" ); +MODULE_LICENSE ("GPL" );drivers/hwmon/pmbus/pmbus.h +6
-0@@ -454,6 +454,12 @@ struct pmbus_driver_info {/* custom attributes */ const struct attribute_group **groups; + +/* +* Skip identify chip parameters, +* some device do not support the PMBUS_VOUT_MODE. +*/ +bool skip_icp; };/* Regulator ops */ drivers/hwmon/pmbus/pmbus_core.c +0
-0@@ -2248,13 +2248,21 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,return -ENODEV ; }
drivers/hwmon/pmbus/pmbus_core.c static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, · line 2255
Quoted 10 lines
drivers/hwmon/pmbus/pmbus_core.c +5
-5-for (page =0 ; page < info->pages; page++) { - ret =pmbus_identify_common (client, data, page); -if (ret <0 ) { -dev_err (dev,"Failed to identify chip capabilities\n" ); -return ret; +/* +* Some device do not support the PMBUS_VOUT_MODE, +* and the driver of device has known correct formats, +* so the driver set skip_icp to true. +*/
The existing code should not affect device behavior. A failure to read PMBUS_VOUT_MODE does not result in an error. As such, there is no reason to add this flag. The only reason to add such a flag would be that the chip returns bad data when reading PMBUS_VOUT_MODE. However, even that could be (and is) handled by implementing a custom read_byte_data function to catch the read and return the expected value(s). This would be a possible alternative to using the identify callback if the chip does not return an error when reading PMBUS_VOUT_MODE.
Guenter