Add support for MPS Multi-phase mp2888 controller
Subsystems (3)
v6 cover Add support for MPS Multi-phase mp2888 controller
Add driver and documentation for mp2888 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a digital, multi-phase, pulse-width modulation controller.
Patch set includes:
Patch #1 - increases maximum number of phases. Patch #2 - provides mp2888 driver and documentation. Patch #3 - providesy binding documentation.
Vadim Pasternak (3):
hwmon: (pmbus) Increase maximum number of phases per page
hwmon: (pmbus) Add support for MPS Multi-phase mp2888 controller
dt-bindings: Add MP2888 voltage regulator device
.../devicetree/bindings/trivial-devices.yaml | 2 + Documentation/hwmon/mp2888.rst | 113 ++++++ drivers/hwmon/pmbus/Kconfig | 9 + drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/mp2888.c | 411 +++++++++++++++++++++ drivers/hwmon/pmbus/pmbus.h | 2 +- 6 files changed, 537 insertions(+), 1 deletion(-) create mode 100644 Documentation/hwmon/mp2888.rst create mode 100644 drivers/hwmon/pmbus/mp2888.c
Signature · 1 line
2.11.0
PATCH v6 1/3 hwmon: (pmbus) Increase maximum number of phases per page
Increase maximum number of phases from 8 to 10 to support multi-phase devices allowing up to 10 phases.
--- drivers/hwmon/pmbus/pmbus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/pmbus.h +1 -1
@@ -375,7 +375,7 @@ enum pmbus_sensor_classes { };#define PMBUS_PAGES 32/* Per PMBus specification */ -#define PMBUS_PHASES 8/* Maximum number of phases per page */ +#define PMBUS_PHASES 10/* Maximum number of phases per page */ /* Functionality bit mask */ #define PMBUS_HAVE_VIN BIT(0)
Signature · 1 line
2.11.0
PATCH v6 2/3 hwmon: (pmbus) Add support for MPS Multi-phase mp2888 controller
In reply to Vadim PasternakAdd support for mp2888 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a digital, multi-phase, pulse-width modulation controller.
This device supports:
- One power rail.
- Programmable Multi-Phase up to 10 Phases.
- PWM-VID Interface
- One pages 0 for telemetry.
- Programmable pins for PMBus Address.
- Built-In EEPROM to Store Custom Configurations.
- Can configured VOUT readout in direct or VID format and allows setting of different formats on rails 1 and 2. For VID the following protocols are available: VR13 mode with 5-mV DAC; VR13 mode with 10-mV DAC, IMVP9 mode with 5-mV DAC.
---v5->v6
Comments pointed out by Guenter:
- Fix comments for limits in mp2888_read_word_data().
- Remove unnecessary typecasts from mp2888_write_word_data().
v4->v5
Comments pointed out by Guenter:
- Fix calculation of PMBUS_READ_VIN.
- Add mp2888_write_word_data() for limits setting.
- Treat PMBUS_POUT_OP_WARN_LIMIT in separate case.
- Drop tuning of "m[PSC_POWER]" and "m[PSC_CURRENT_OUT]" from probing routine.
Fixes from Vadim:
- Treat PMBUS_IOUT_OC_WARN_LIMIT in separate case.
v3->v4
Comments pointed out by Guenter:
- Fix PMBUS_READ_VIN and limits calculations.
- Add comment for PMBUS_OT_WARN_LIMIT scaling.
- Fix PMBUS_READ_IOUT, PMBUS_READ_POUT, PMBUS_READ_PIN calculations.
- Enable PMBUS_IOUT_OC_WARN_LIMIT and PMBUS_POUT_OP_WARN_LIMIT.
Fixes from Vadim:
- Disable PMBUS_POUT_MAX. Device uses this register for different purpose.
- Disable PMBUS_MFR_VOU_MIN. Device doe not implement this register.
- Update documentation file.
v2->v3
Comments pointed out by Guenter:
- Fix precision for PMBUS_READ_VIN (it requires adding scale for PMBUS_VIN_OV_FAULT_LIMIT and PMBUS_VIN_UV_WARN_LIMIT.
- Fix precision for PMBUS_READ_TEMPERATURE_1 (it requires adding scale for PMBUS_OT_WARN_LIMIT).
- Use DIV_ROUND_CLOSEST_ULL for scaling PMBUS_READ_POUT, PMBUS_READ_PIN readouts.
Notes and fixes from Vadim:
- READ_IOUT in linear11 does not give write calculation (tested with external load), while in direct format readouts are correct.
- Disable non-configured phases in mp2888_identify_multiphase().
v1->v2:
Comments pointed out by Guenter:
- Use standard access for getting PMBUS_OT_WARN_LIMIT, PMBUS_VIN_OV_FAULT_LIMIT, PMBUS_VIN_UV_WARN_LIMIT.
- Use linear11 conversion for PMBUS_READ_VIN, PMBUS_READ_POUT, PMBUS_READ_PIN, PMBUS_READ_TEMPERATURE_1 and adjust coefficients.
- Add reading phases current from the dedicated registers.
- Add comment for not implemented or implemented not according to the spec registers, for which "ENXIO" code is returned.
- Set PMBUS_HAVE_IOUT" statically.
Notes from Vadim:
- READ_IOUT uses direct format, so I did not adjust it like the below registers.
--- Documentation/hwmon/mp2888.rst | 113 +++++++++++ drivers/hwmon/pmbus/Kconfig | 9 + drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/mp2888.c | 411 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 534 insertions(+) create mode 100644 Documentation/hwmon/mp2888.rst create mode 100644 drivers/hwmon/pmbus/mp2888.c
Documentation/hwmon/mp2888.rst new file +113 -0
@@ -0,0 +1,113 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver mp2888 +==================== + +Supported chips: + + * MPS MP12254 + + Prefix: 'mp2888' + +Author: + + Vadim Pasternak <[email protected]> + +Description +----------- + +This driver implements support for Monolithic Power Systems, Inc. (MPS) +vendor dual-loop, digital, multi-phase controller MP2888. + +This device: supports: + +- One power rail. +- Programmable Multi-Phase up to 10 Phases. +- PWM-VID Interface +- One pages 0 for telemetry. +- Programmable pins for PMBus Address. +- Built-In EEPROM to Store Custom Configurations. + +Device complaint with: + +- PMBus rev 1.3 interface. + +Device supports direct format for reading output current, output voltage, +input and output power and temperature. +Device supports linear format for reading input voltage and input power. + +The driver provides the next attributes for the current: + +- for current out input and maximum alarm; +- for phase current: input and label. + +The driver exports the following attributes via the 'sysfs' files, where: + +- 'n' is number of configured phases (from 1 to 10); +- index 1 for "iout"; +- indexes 2 ... 1 + n for phases. + +**curr[1-{1+n}]_input** + +**curr[1-{1+n}]_label** + +**curr1_max** + +**curr1_max_alarm** + +The driver provides the next attributes for the voltage: + +- for voltage in: input, low and high critical thresholds, low and high + critical alarms; +- for voltage out: input and high alarm; + +The driver exports the following attributes via the 'sysfs' files, where + +**in1_crit** + +**in1_crit_alarm** + +**in1_input** + +**in1_label** + +**in1_min** + +**in1_min_alarm** + +**in2_alarm** + +**in2_input** + +**in2_label** + +The driver provides the next attributes for the power: + +- for power in alarm and input. +- for power out: cap, cap alarm an input. + +The driver exports the following attributes via the 'sysfs' files, where +- indexes 1 for "pin"; +- indexes 2 for "pout"; + +**power1_alarm** + +**power1_input** + +**power1_label** + +**power2_input** + +**power2_label** + +**power2_max** + +**power2_max_alarm** + +The driver provides the next attributes for the temperature: + +**temp1_input** + +**temp1_max** + +**temp1_max_alarm**
drivers/hwmon/pmbus/Kconfig +9 -0
@@ -211,6 +211,15 @@ config SENSORS_MAX8688 This driver can also be built as a module. If so, the module will be called max8688. +config SENSORS_MP2888 + tristate "MPS MP2888" + help + If you say yes here you get hardware monitoring support for MPS + MP2888 Digital, Multi-Phase, Pulse-Width Modulation Controller. + + This driver can also be built as a module. If so, the module will + be called mp2888. + config SENSORS_MP2975 tristate "MPS MP2975" help
drivers/hwmon/pmbus/Makefile +1 -0
@@ -24,6 +24,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_MP2888) += mp2888.o obj-$(CONFIG_SENSORS_MP2975) += mp2975.o obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o obj-$(CONFIG_SENSORS_PXE1610) += pxe1610.o
drivers/hwmon/pmbus/mp2888.c new file +411 -0
411 lines not on this page · raw message
Signature · 1 line
2.11.0
Guenter Roeck
maintainerRe: [PATCH hwmon-next v6 2/3] hwmon: (pmbus) Add support for MPS Multi-phase mp2888 controller
Quoted 72 lines · Vadim Pasternak
Add support for mp2888 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a digital, multi-phase, pulse-width modulation controller.
This device supports:
- One power rail.
- Programmable Multi-Phase up to 10 Phases.
- PWM-VID Interface
- One pages 0 for telemetry.
- Programmable pins for PMBus Address.
- Built-In EEPROM to Store Custom Configurations.
- Can configured VOUT readout in direct or VID format and allows setting of different formats on rails 1 and 2. For VID the following protocols are available: VR13 mode with 5-mV DAC; VR13 mode with 10-mV DAC, IMVP9 mode with 5-mV DAC.Signed-off-by Vadim Pasternak <[email protected]>---
v5->v6
Comments pointed out by Guenter:
- Fix comments for limits inmp2888_read_word_data().
- Remove unnecessary typecasts frommp2888_write_word_data().
v4->v5
Comments pointed out by Guenter:
- Fix calculation ofPMBUS_READ_VIN.
- Addmp2888_write_word_data()for limits setting.
- TreatPMBUS_POUT_OP_WARN_LIMITin separate case.
- Drop tuning of "m[PSC_POWER]" and "m[PSC_CURRENT_OUT]" from probing routine.
Fixes from Vadim:
- TreatPMBUS_IOUT_OC_WARN_LIMITin separate case.
v3->v4
Comments pointed out by Guenter:
- FixPMBUS_READ_VINand limits calculations.
- Add comment forPMBUS_OT_WARN_LIMITscaling.
- FixPMBUS_READ_IOUT,PMBUS_READ_POUT,PMBUS_READ_PINcalculations.
- EnablePMBUS_IOUT_OC_WARN_LIMITandPMBUS_POUT_OP_WARN_LIMIT.
Fixes from Vadim:
- DisablePMBUS_POUT_MAX. Device uses this register for different purpose.
- DisablePMBUS_MFR_VOU_MIN. Device doe not implement this register.
- Update documentation file.
v2->v3
Comments pointed out by Guenter:
- Fix precision forPMBUS_READ_VIN(it requires adding scale forPMBUS_VIN_OV_FAULT_LIMITandPMBUS_VIN_UV_WARN_LIMIT.
- Fix precision forPMBUS_READ_TEMPERATURE_1(it requires adding scale forPMBUS_OT_WARN_LIMIT).
- UseDIV_ROUND_CLOSEST_ULLfor scalingPMBUS_READ_POUT,PMBUS_READ_PINreadouts.
Notes and fixes from Vadim:
-READ_IOUTin linear11 does not give write calculation (tested with external load), while in direct format readouts are correct.
- Disable non-configured phases inmp2888_identify_multiphase().
v1->v2:
Comments pointed out by Guenter:
- Use standard access for gettingPMBUS_OT_WARN_LIMIT,PMBUS_VIN_OV_FAULT_LIMIT,PMBUS_VIN_UV_WARN_LIMIT.
- Use linear11 conversion forPMBUS_READ_VIN,PMBUS_READ_POUT,PMBUS_READ_PIN,PMBUS_READ_TEMPERATURE_1and adjust coefficients.
- Add reading phases current from the dedicated registers.
- Add comment for not implemented or implemented not according to the spec registers, for which "ENXIO" code is returned.
- SetPMBUS_HAVE_IOUT" statically.
Notes from Vadim:
-READ_IOUTuses direct format, so I did not adjust it like the below registers.
---
[ ... ]
drivers/hwmon/pmbus/mp2888.c line 271
Quoted 9 lines
drivers/hwmon/pmbus/mp2888.c new file +9
-0+ +static int mp2888_write_word_data (struct i2c_client *client,int page,int reg,u16 word) +{ +const struct pmbus_driver_info *info =pmbus_get_driver_info (client); +struct mp2888_data *data =to_mp2888_data (info); + +switch (reg) { +case PMBUS_OT_WARN_LIMIT : + word =DIV_ROUND_CLOSEST ((int )word,MP2888_TEMP_UNIT );
Sorry if I am missing something, but why those typecasts here and below ?
Quoted 40 lines
drivers/hwmon/pmbus/mp2888.c new file +40
-0+/* Drop unused bits 15:8. */ + word =clamp_val (word,0 ,GENMASK (7 ,0 )); +break ; +case PMBUS_IOUT_OC_WARN_LIMIT : +/* Fix limit according to total curent resolution. */ + word = data->total_curr_resolution ?DIV_ROUND_CLOSEST ((int )word,8 ) : +DIV_ROUND_CLOSEST ((int )word,4 ); +/* Drop unused bits 15:10. */ + word =clamp_val (word,0 ,GENMASK (9 ,0 )); +break ; +case PMBUS_POUT_OP_WARN_LIMIT : +/* Fix limit according to total curent resolution. */ + word = data->total_curr_resolution ?DIV_ROUND_CLOSEST ((int )word,4 ) : +DIV_ROUND_CLOSEST ((int )word,2 ); +/* Drop unused bits 15:10. */ + word =clamp_val (word,0 ,GENMASK (9 ,0 )); +break ; +default : +return -ENODATA ; + } +return pmbus_write_word_data (client, page, reg, word); +} + +static int +mp2888_identify_multiphase (struct i2c_client *client,struct mp2888_data *data, +struct pmbus_driver_info *info) +{ +int i, ret; + + ret =i2c_smbus_write_byte_data (client,PMBUS_PAGE ,0 ); +if (ret <0 ) +return ret; + +/* Identify multiphase number - could be from 1 to 10. */ + ret =i2c_smbus_read_word_data (client,MP2888_MFR_VR_CONFIG1 ); +if (ret <=0 ) +return ret; + + info->phases[0 ] = ret &GENMASK (3 ,0 ); +
drivers/hwmon/pmbus/mp2888.c line 321
Quoted 10 lines
drivers/hwmon/pmbus/mp2888.c new file +10
-0+/* +* The device provides a total of 10 PWM pins, and can be configured to different phase +* count applications for rail. +*/ +if (info->phases[0 ] >MP2888_MAX_PHASE ) +return -EINVAL ; + +/* Disable non-configured phases. */ +for (i = info->phases[0 ]; i <MP2888_MAX_PHASE ; i++) + info->pfunc[i] =0 ;
Not that it matters much, but this is unnecessary since the pmbus core won't look at phase data beyond info->phases[].
Guenter
RE: [PATCH hwmon-next v6 2/3] hwmon: (pmbus) Add support for MPS Multi-phase mp2888 controller
Quoted 97 lines
-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Monday, May 10, 2021 7:48 PM
To: Vadim Pasternak <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH hwmon-next v6 2/3] hwmon: (pmbus) Add support for MPS Multi-phase mp2888 controllerQuoted 23 lines · Vadim Pasternak
Add support for mp2888 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a digital, multi-phase, pulse-width modulation controller.
This device supports:
- One power rail.
- Programmable Multi-Phase up to 10 Phases.
- PWM-VID Interface
- One pages 0 for telemetry.
- Programmable pins for PMBus Address.
- Built-In EEPROM to Store Custom Configurations.
- Can configured VOUT readout in direct or VID format and allows setting of different formats on rails 1 and 2. For VID the following protocols are available: VR13 mode with 5-mV DAC; VR13 mode with 10-mV DAC, IMVP9 mode with 5-mV DAC.Signed-off-by Vadim Pasternak <[email protected]>---
v5->v6
Comments pointed out by Guenter:
- Fix comments for limits inmp2888_read_word_data().
- Remove unnecessary typecasts frommp2888_write_word_data().Quoted 6 lines
v4->v5
Comments pointed out by Guenter:
- Fix calculation ofPMBUS_READ_VIN.
- Addmp2888_write_word_data()for limits setting.
- TreatPMBUS_POUT_OP_WARN_LIMITin separate case.
- Drop tuning of "m[PSC_POWER]" and "m[PSC_CURRENT_OUT]" fromprobing
Quoted 9 lines
routine.
Fixes from Vadim:
- TreatPMBUS_IOUT_OC_WARN_LIMITin separate case.
v3->v4
Comments pointed out by Guenter:
- FixPMBUS_READ_VINand limits calculations.
- Add comment forPMBUS_OT_WARN_LIMITscaling.
- FixPMBUS_READ_IOUT,PMBUS_READ_POUT,PMBUS_READ_PINcalculations.
Quoted 1 line
- Enable
PMBUS_IOUT_OC_WARN_LIMITand
PMBUS_POUT_OP_WARN_LIMIT.Quoted 4 lines
Fixes from Vadim:
- DisablePMBUS_POUT_MAX. Device uses this register for different purpose.
- DisablePMBUS_MFR_VOU_MIN. Device doe not implement thisregister.
Quoted 15 lines
- Update documentation file.
v2->v3
Comments pointed out by Guenter:
- Fix precision forPMBUS_READ_VIN(it requires adding scale forPMBUS_VIN_OV_FAULT_LIMITandPMBUS_VIN_UV_WARN_LIMIT.
- Fix precision forPMBUS_READ_TEMPERATURE_1(it requires adding scale forPMBUS_OT_WARN_LIMIT).
- UseDIV_ROUND_CLOSEST_ULLfor scalingPMBUS_READ_POUT,PMBUS_READ_PINreadouts.
Notes and fixes from Vadim:
-READ_IOUTin linear11 does not give write calculation (tested with external load), while in direct format readouts are correct.
- Disable non-configured phases inmp2888_identify_multiphase().Quoted 6 lines
v1->v2:
Comments pointed out by Guenter:
- Use standard access for gettingPMBUS_OT_WARN_LIMIT,PMBUS_VIN_OV_FAULT_LIMIT,PMBUS_VIN_UV_WARN_LIMIT.
- Use linear11 conversion forPMBUS_READ_VIN,PMBUS_READ_POUT,PMBUS_READ_PIN,PMBUS_READ_TEMPERATURE_1and adjustcoefficients.
Quoted 8 lines
- Add reading phases current from the dedicated registers.
- Add comment for not implemented or implemented not according to the spec registers, for which "ENXIO" code is returned.
- SetPMBUS_HAVE_IOUT" statically.
Notes from Vadim:
-READ_IOUTuses direct format, so I did not adjust it like the below registers.
---[ ... ]
Review
Quoted 4 lines
(quoted diff) +4
-0+ +static int mp2888_write_word_data(struct i2c_client *client, int +page, int reg, u16 word) { + const struct pmbus_driver_info *info =
pmbus_get_driver_info(client);
Quoted 8 lines
drivers/hwmon/pmbus/mp2888.c
Quoted 5 lines
drivers/hwmon/pmbus/mp2888.c new file +5
-0+struct mp2888_data *data =to_mp2888_data (info); + +switch (reg) { +case PMBUS_OT_WARN_LIMIT : + word = DIV_ROUND_CLOSEST((int)word,
MP2888_TEMP_UNIT);Sorry if I am missing something, but why those typecasts here and below ?
I forgot to remove it. Sorry.
Quoted 46 lines
drivers/hwmon/pmbus/mp2888.c
Quoted 7 lines
drivers/hwmon/pmbus/mp2888.c new file +6
-0+/* Drop unused bits 15:8. */ + word =clamp_val (word,0 ,GENMASK (7 ,0 )); +break ; +case PMBUS_IOUT_OC_WARN_LIMIT : +/* Fix limit according to total curent resolution. */ + word = data->total_curr_resolution ?
DIV_ROUND_CLOSEST((int)word, 8):drivers/hwmon/pmbus/mp2888.c
Quoted 7 lines
drivers/hwmon/pmbus/mp2888.c new file +7
-0+DIV_ROUND_CLOSEST ((int )word,4 ); +/* Drop unused bits 15:10. */ + word =clamp_val (word,0 ,GENMASK (9 ,0 )); +break ; +case PMBUS_POUT_OP_WARN_LIMIT : +/* Fix limit according to total curent resolution. */ + word = data->total_curr_resolution ?
DIV_ROUND_CLOSEST((int)word, 4):drivers/hwmon/pmbus/mp2888.c
Quoted 11 lines
drivers/hwmon/pmbus/mp2888.c new file +11
-0+DIV_ROUND_CLOSEST ((int )word,2 ); +/* Drop unused bits 15:10. */ + word =clamp_val (word,0 ,GENMASK (9 ,0 )); +break ; +default : +return -ENODATA ; + } +return pmbus_write_word_data (client, page, reg, word); } + +static int +mp2888_identify_multiphase(struct i2c_client *client, struct mp2888_data*data,
drivers/hwmon/pmbus/mp2888.c
Quoted 9 lines
drivers/hwmon/pmbus/mp2888.c new file +9
-0+ struct pmbus_driver_info *info) { +int i, ret; + + ret =i2c_smbus_write_byte_data (client,PMBUS_PAGE ,0 ); +if (ret <0 ) +return ret; + +/* Identify multiphase number - could be from 1 to 10. */ + ret = i2c_smbus_read_word_data(client,
MP2888_MFR_VR_CONFIG1);drivers/hwmon/pmbus/mp2888.c
Quoted 7 lines
drivers/hwmon/pmbus/mp2888.c new file +7
-0+if (ret <=0 ) +return ret; + + info->phases[0 ] = ret &GENMASK (3 ,0 ); + +/* +* The device provides a total of 10 PWM pins, and can be configured to different phase
Quoted 11 lines
drivers/hwmon/pmbus/mp2888.c line 321
Quoted 8 lines
drivers/hwmon/pmbus/mp2888.c new file +8
-0+* count applications for rail. +*/ +if (info->phases[0 ] >MP2888_MAX_PHASE ) +return -EINVAL ; + +/* Disable non-configured phases. */ +for (i = info->phases[0 ]; i <MP2888_MAX_PHASE ; i++) + info->pfunc[i] =0 ;Not that it matters much, but this is unnecessary since the pmbus core won't look at phase data beyond info->phases[].
I see. So I'll drop these two lines.
Quoted 2 lines
Guenter
PATCH v6 3/3 dt-bindings: Add MP2888 voltage regulator device
In reply to Vadim PasternakMonolithic Power Systems, Inc. (MPS) dual-loop, digital, multi-phase controller.
--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/trivial-devices.yaml +2 -0
@@ -98,6 +98,8 @@ properties: - fsl,mpl3115 # MPR121: Proximity Capacitive Touch Sensor Controller - fsl,mpr121 + # Monolithic Power Systems Inc. multi-phase controller mp2888 + - mps,mp2888 # Monolithic Power Systems Inc. multi-phase controller mp2975 - mps,mp2975 # G751: Digital Temperature Sensor and Thermal Watchdog with Two-Wire Interface
Signature · 1 line
2.11.0