devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] hwmon: (pmbus) MPS mp5990 hsc controller
@ 2023-11-09  4:48 Peter Yin
  2023-11-09  4:48 ` [PATCH v2 1/2] dt-bindings: hwmon: Add mps mp5990 driver bindings Peter Yin
  2023-11-09  4:48 ` [PATCH v2 2/2] hwmon: (pmbus) Add support for MPS Multi-phase mp5990 Peter Yin
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Yin @ 2023-11-09  4:48 UTC (permalink / raw)
  To: patrick, Jean Delvare, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Corbet, Peter Yin,
	linux-hwmon, devicetree, linux-kernel, linux-doc

Add MPS mp5990 hot-swap controller.

Change log:

v1 -> v2:
  - Corrected dt-bindings description.
  - Added comments for Vout mode command.
  - Removed of_match_ptr()
v1:
  - Add support for MPS Multi-phase mp5990 Hot-Swap controller.

---
Peter Yin (2):
  dt-bindings: hwmon: Add mps mp5990 driver bindings
  hwmon: (pmbus) Add support for MPS Multi-phase mp5990

 .../devicetree/bindings/hwmon/mps,mp5990.yaml | 41 +++++++++
 Documentation/hwmon/index.rst                 |  1 +
 Documentation/hwmon/mp5990.rst                | 84 ++++++++++++++++++
 drivers/hwmon/pmbus/Kconfig                   |  9 ++
 drivers/hwmon/pmbus/Makefile                  |  1 +
 drivers/hwmon/pmbus/mp5990.c                  | 86 +++++++++++++++++++
 6 files changed, 222 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
 create mode 100644 Documentation/hwmon/mp5990.rst
 create mode 100644 drivers/hwmon/pmbus/mp5990.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] dt-bindings: hwmon: Add mps mp5990 driver bindings
  2023-11-09  4:48 [PATCH v2 0/2] hwmon: (pmbus) MPS mp5990 hsc controller Peter Yin
@ 2023-11-09  4:48 ` Peter Yin
  2023-11-09  8:56   ` Krzysztof Kozlowski
  2023-11-09  4:48 ` [PATCH v2 2/2] hwmon: (pmbus) Add support for MPS Multi-phase mp5990 Peter Yin
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Yin @ 2023-11-09  4:48 UTC (permalink / raw)
  To: patrick, Jean Delvare, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Corbet, Peter Yin,
	linux-hwmon, devicetree, linux-kernel, linux-doc

Add a device tree bindings for mp5990 device.

Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com>
---
 .../devicetree/bindings/hwmon/mps,mp5990.yaml | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml

diff --git a/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml b/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
new file mode 100644
index 000000000000..bfd0cf7d3470
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/mps,mp5990.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Monolithic Power Systems Devices MP5990 Hot-Swap Controller
+
+maintainers:
+  - Peter Yin <peteryin.openbmc@gmail.com>
+
+description: |
+  Monolithic Power Systems Devices MP5990 Hot-Swap Controller
+
+  Datasheets:
+  https://www.monolithicpower.com/en/mp5990.html
+
+properties:
+  compatible:
+    const: mps,mp5990
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        power-sensor@20 {
+            reg = <0x20>;
+            compatible = "mps,mp5990";
+        };
+    };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] hwmon: (pmbus) Add support for MPS Multi-phase mp5990
  2023-11-09  4:48 [PATCH v2 0/2] hwmon: (pmbus) MPS mp5990 hsc controller Peter Yin
  2023-11-09  4:48 ` [PATCH v2 1/2] dt-bindings: hwmon: Add mps mp5990 driver bindings Peter Yin
@ 2023-11-09  4:48 ` Peter Yin
  2023-11-10 15:34   ` Guenter Roeck
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Yin @ 2023-11-09  4:48 UTC (permalink / raw)
  To: patrick, Jean Delvare, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Corbet, Peter Yin,
	linux-hwmon, devicetree, linux-kernel, linux-doc

Add support for mp5990 device from Monolithic Power Systems, Inc. (MPS)
vendor. This is a Hot-Swap Controller.

Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com>
---
 Documentation/hwmon/index.rst  |  1 +
 Documentation/hwmon/mp5990.rst | 84 +++++++++++++++++++++++++++++++++
 drivers/hwmon/pmbus/Kconfig    |  9 ++++
 drivers/hwmon/pmbus/Makefile   |  1 +
 drivers/hwmon/pmbus/mp5990.c   | 86 ++++++++++++++++++++++++++++++++++
 5 files changed, 181 insertions(+)
 create mode 100644 Documentation/hwmon/mp5990.rst
 create mode 100644 drivers/hwmon/pmbus/mp5990.c

diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index 042e1cf9501b..8c70e10fc795 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -157,6 +157,7 @@ Hardware Monitoring Kernel Drivers
    mp2888
    mp2975
    mp5023
+   mp5990
    nct6683
    nct6775
    nct7802
diff --git a/Documentation/hwmon/mp5990.rst b/Documentation/hwmon/mp5990.rst
new file mode 100644
index 000000000000..d2da0f767530
--- /dev/null
+++ b/Documentation/hwmon/mp5990.rst
@@ -0,0 +1,84 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver mp5990
+====================
+
+Supported chips:
+
+  * MPS MP5990
+
+    Prefix: 'mp5990'
+
+  * Datasheet
+
+    Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5990.html
+
+Author:
+
+	Peter Yin <peteryin.openbmc@gmail.com>
+
+Description
+-----------
+
+This driver implements support for Monolithic Power Systems, Inc. (MPS)
+MP5990 Hot-Swap Controller.
+
+Device compliant with:
+
+- PMBus rev 1.3 interface.
+
+Device supports direct format for reading input voltage, output voltage,
+output current, input power and temperature.
+
+The driver exports the following attributes via the 'sysfs' files
+for input voltage:
+
+**in1_input**
+
+**in1_label**
+
+**in1_max**
+
+**in1_max_alarm**
+
+**in1_min**
+
+**in1_min_alarm**
+
+The driver provides the following attributes for output voltage:
+
+**in2_input**
+
+**in2_label**
+
+**in2_alarm**
+
+The driver provides the following attributes for output current:
+
+**curr1_input**
+
+**curr1_label**
+
+**curr1_alarm**
+
+**curr1_max**
+
+The driver provides the following attributes for input power:
+
+**power1_input**
+
+**power1_label**
+
+**power1_alarm**
+
+The driver provides the following attributes for temperature:
+
+**temp1_input**
+
+**temp1_max**
+
+**temp1_max_alarm**
+
+**temp1_crit**
+
+**temp1_crit_alarm**
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 270b6336b76d..65a116f7744d 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -326,6 +326,15 @@ config SENSORS_MP5023
 	  This driver can also be built as a module. If so, the module will
 	  be called mp5023.
 
+config SENSORS_MP5990
+	tristate "MPS MP5990"
+	help
+	  If you say yes here you get hardware monitoring support for MPS
+	  MP5990.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called mp5990.
+
 config SENSORS_MPQ7932_REGULATOR
 	bool "Regulator support for MPQ7932"
 	depends on SENSORS_MPQ7932 && REGULATOR
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 84ee960a6c2d..212d9ca0acc9 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_SENSORS_MAX8688)	+= max8688.o
 obj-$(CONFIG_SENSORS_MP2888)	+= mp2888.o
 obj-$(CONFIG_SENSORS_MP2975)	+= mp2975.o
 obj-$(CONFIG_SENSORS_MP5023)	+= mp5023.o
+obj-$(CONFIG_SENSORS_MP5990)	+= mp5990.o
 obj-$(CONFIG_SENSORS_MPQ7932)	+= mpq7932.o
 obj-$(CONFIG_SENSORS_PLI1209BC)	+= pli1209bc.o
 obj-$(CONFIG_SENSORS_PM6764TR)	+= pm6764tr.o
diff --git a/drivers/hwmon/pmbus/mp5990.c b/drivers/hwmon/pmbus/mp5990.c
new file mode 100644
index 000000000000..fb3ac9c5d44e
--- /dev/null
+++ b/drivers/hwmon/pmbus/mp5990.c
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Driver for MPS MP5990 Hot-Swap Controller
+ */
+
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/pmbus.h>
+#include "pmbus.h"
+
+static int mp5990_read_byte_data(struct i2c_client *client, int page, int reg)
+{
+	switch (reg) {
+	case PMBUS_VOUT_MODE:
+		/* The datasheet does not support the VOUT command,
+		 * but the device responds with a default value of 0x17.
+		 * In the standard, 0x17 represents linear mode. However,
+		 * for the MP5990, the VOUT linear mode is linear11, not linear16.
+		 * Therefore, we should enforce the VOUT in the direct format.
+		 */
+		return PB_VOUT_MODE_DIRECT;
+	default:
+		return -ENODATA;
+	}
+}
+
+static struct pmbus_driver_info mp5990_info = {
+	.pages = 1,
+	.format[PSC_VOLTAGE_IN] = direct,
+	.format[PSC_VOLTAGE_OUT] = direct,
+	.format[PSC_CURRENT_OUT] = direct,
+	.format[PSC_POWER] = direct,
+	.format[PSC_TEMPERATURE] = direct,
+	.m[PSC_VOLTAGE_IN] = 32,
+	.b[PSC_VOLTAGE_IN] = 0,
+	.R[PSC_VOLTAGE_IN] = 0,
+	.m[PSC_VOLTAGE_OUT] = 32,
+	.b[PSC_VOLTAGE_OUT] = 0,
+	.R[PSC_VOLTAGE_OUT] = 0,
+	.m[PSC_CURRENT_OUT] = 16,
+	.b[PSC_CURRENT_OUT] = 0,
+	.R[PSC_CURRENT_OUT] = 0,
+	.m[PSC_POWER] = 1,
+	.b[PSC_POWER] = 0,
+	.R[PSC_POWER] = 0,
+	.m[PSC_TEMPERATURE] = 1,
+	.b[PSC_TEMPERATURE] = 0,
+	.R[PSC_TEMPERATURE] = 0,
+	.func[0] =
+		PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_PIN |
+		PMBUS_HAVE_TEMP | PMBUS_HAVE_IOUT |
+		PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP,
+	.read_byte_data = mp5990_read_byte_data,
+};
+
+static int mp5990_probe(struct i2c_client *client)
+{
+	return pmbus_do_probe(client, &mp5990_info);
+}
+
+static const struct of_device_id mp5990_of_match[] = {
+	{ .compatible = "mps,mp5990" },
+	{}
+};
+
+static const struct i2c_device_id mp5990_id[] = {
+	{"mp5990", 0},
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, mp5990_id);
+
+static struct i2c_driver mp5990_driver = {
+	.driver = {
+		   .name = "mp5990",
+		   .of_match_table = mp5990_of_match,
+	},
+	.probe = mp5990_probe,
+	.id_table = mp5990_id,
+};
+module_i2c_driver(mp5990_driver);
+
+MODULE_AUTHOR("Peter Yin <peter.yin@quantatw.com>");
+MODULE_DESCRIPTION("PMBus driver for MP5990 HSC");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(PMBUS);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: hwmon: Add mps mp5990 driver bindings
  2023-11-09  4:48 ` [PATCH v2 1/2] dt-bindings: hwmon: Add mps mp5990 driver bindings Peter Yin
@ 2023-11-09  8:56   ` Krzysztof Kozlowski
  2023-11-10  9:41     ` PeterYin
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2023-11-09  8:56 UTC (permalink / raw)
  To: Peter Yin, patrick, Jean Delvare, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Corbet, linux-hwmon,
	devicetree, linux-kernel, linux-doc

On 09/11/2023 05:48, Peter Yin wrote:
> Add a device tree bindings for mp5990 device.
> 
> Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com>
> ---
>  .../devicetree/bindings/hwmon/mps,mp5990.yaml | 41 +++++++++++++++++++
>  1 file changed, 41 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml b/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
> new file mode 100644
> index 000000000000..bfd0cf7d3470
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
> @@ -0,0 +1,41 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/hwmon/mps,mp5990.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Monolithic Power Systems Devices MP5990 Hot-Swap Controller
> +
> +maintainers:
> +  - Peter Yin <peteryin.openbmc@gmail.com>
> +
> +description: |
> +  Monolithic Power Systems Devices MP5990 Hot-Swap Controller
> +
> +  Datasheets:
> +  https://www.monolithicpower.com/en/mp5990.html
> +
> +properties:
> +  compatible:
> +    const: mps,mp5990
> +
> +  reg:
> +    maxItems: 1

This is missing some properties... or is a candidate for
trivial-devices.yaml.

I guess it is fine as initial submission:

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: hwmon: Add mps mp5990 driver bindings
  2023-11-09  8:56   ` Krzysztof Kozlowski
@ 2023-11-10  9:41     ` PeterYin
  0 siblings, 0 replies; 6+ messages in thread
From: PeterYin @ 2023-11-10  9:41 UTC (permalink / raw)
  To: Krzysztof Kozlowski, patrick, Jean Delvare, Guenter Roeck,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Corbet,
	linux-hwmon, devicetree, linux-kernel, linux-doc



Krzysztof Kozlowski 於 11/9/23 16:56 寫道:
> On 09/11/2023 05:48, Peter Yin wrote:
>> Add a device tree bindings for mp5990 device.
>>
>> Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com>
>> ---
>>   .../devicetree/bindings/hwmon/mps,mp5990.yaml | 41 +++++++++++++++++++
>>   1 file changed, 41 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml b/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
>> new file mode 100644
>> index 000000000000..bfd0cf7d3470
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml
>> @@ -0,0 +1,41 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/hwmon/mps,mp5990.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Monolithic Power Systems Devices MP5990 Hot-Swap Controller
>> +
>> +maintainers:
>> +  - Peter Yin <peteryin.openbmc@gmail.com>
>> +
>> +description: |
>> +  Monolithic Power Systems Devices MP5990 Hot-Swap Controller
>> +
>> +  Datasheets:
>> +  https://www.monolithicpower.com/en/mp5990.html
>> +
>> +properties:
>> +  compatible:
>> +    const: mps,mp5990
>> +
>> +  reg:
>> +    maxItems: 1
> 
> This is missing some properties... or is a candidate for
> trivial-devices.yaml.
> 
> I guess it is fine as initial submission:
> 
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> Best regards,
> Krzysztof
> 
OK, I will move to trivial-devices, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] hwmon: (pmbus) Add support for MPS Multi-phase mp5990
  2023-11-09  4:48 ` [PATCH v2 2/2] hwmon: (pmbus) Add support for MPS Multi-phase mp5990 Peter Yin
@ 2023-11-10 15:34   ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2023-11-10 15:34 UTC (permalink / raw)
  To: Peter Yin, patrick, Jean Delvare, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Corbet, linux-hwmon,
	devicetree, linux-kernel, linux-doc

On 11/8/23 20:48, Peter Yin wrote:
> Add support for mp5990 device from Monolithic Power Systems, Inc. (MPS)
> vendor. This is a Hot-Swap Controller.
> 
> Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com>
> ---
>   Documentation/hwmon/index.rst  |  1 +
>   Documentation/hwmon/mp5990.rst | 84 +++++++++++++++++++++++++++++++++
>   drivers/hwmon/pmbus/Kconfig    |  9 ++++
>   drivers/hwmon/pmbus/Makefile   |  1 +
>   drivers/hwmon/pmbus/mp5990.c   | 86 ++++++++++++++++++++++++++++++++++
>   5 files changed, 181 insertions(+)
>   create mode 100644 Documentation/hwmon/mp5990.rst
>   create mode 100644 drivers/hwmon/pmbus/mp5990.c
> 
> diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
> index 042e1cf9501b..8c70e10fc795 100644
> --- a/Documentation/hwmon/index.rst
> +++ b/Documentation/hwmon/index.rst
> @@ -157,6 +157,7 @@ Hardware Monitoring Kernel Drivers
>      mp2888
>      mp2975
>      mp5023
> +   mp5990
>      nct6683
>      nct6775
>      nct7802
> diff --git a/Documentation/hwmon/mp5990.rst b/Documentation/hwmon/mp5990.rst
> new file mode 100644
> index 000000000000..d2da0f767530
> --- /dev/null
> +++ b/Documentation/hwmon/mp5990.rst
> @@ -0,0 +1,84 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +Kernel driver mp5990
> +====================
> +
> +Supported chips:
> +
> +  * MPS MP5990
> +
> +    Prefix: 'mp5990'
> +
> +  * Datasheet
> +
> +    Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5990.html
> +
> +Author:
> +
> +	Peter Yin <peteryin.openbmc@gmail.com>
> +
> +Description
> +-----------
> +
> +This driver implements support for Monolithic Power Systems, Inc. (MPS)
> +MP5990 Hot-Swap Controller.
> +
> +Device compliant with:
> +
> +- PMBus rev 1.3 interface.
> +
> +Device supports direct format for reading input voltage, output voltage,
> +output current, input power and temperature.
> +

The device also supports linear mode according to its datasheet.

> +The driver exports the following attributes via the 'sysfs' files
> +for input voltage:
> +
> +**in1_input**
> +
> +**in1_label**
> +
> +**in1_max**
> +
> +**in1_max_alarm**
> +
> +**in1_min**
> +
> +**in1_min_alarm**
> +
> +The driver provides the following attributes for output voltage:
> +
> +**in2_input**
> +
> +**in2_label**
> +
> +**in2_alarm**
> +
> +The driver provides the following attributes for output current:
> +
> +**curr1_input**
> +
> +**curr1_label**
> +
> +**curr1_alarm**
> +
> +**curr1_max**
> +
> +The driver provides the following attributes for input power:
> +
> +**power1_input**
> +
> +**power1_label**
> +
> +**power1_alarm**
> +
> +The driver provides the following attributes for temperature:
> +
> +**temp1_input**
> +
> +**temp1_max**
> +
> +**temp1_max_alarm**
> +
> +**temp1_crit**
> +
> +**temp1_crit_alarm**
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index 270b6336b76d..65a116f7744d 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -326,6 +326,15 @@ config SENSORS_MP5023
>   	  This driver can also be built as a module. If so, the module will
>   	  be called mp5023.
>   
> +config SENSORS_MP5990
> +	tristate "MPS MP5990"
> +	help
> +	  If you say yes here you get hardware monitoring support for MPS
> +	  MP5990.
> +
> +	  This driver can also be built as a module. If so, the module will
> +	  be called mp5990.
> +
>   config SENSORS_MPQ7932_REGULATOR
>   	bool "Regulator support for MPQ7932"
>   	depends on SENSORS_MPQ7932 && REGULATOR
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index 84ee960a6c2d..212d9ca0acc9 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -35,6 +35,7 @@ obj-$(CONFIG_SENSORS_MAX8688)	+= max8688.o
>   obj-$(CONFIG_SENSORS_MP2888)	+= mp2888.o
>   obj-$(CONFIG_SENSORS_MP2975)	+= mp2975.o
>   obj-$(CONFIG_SENSORS_MP5023)	+= mp5023.o
> +obj-$(CONFIG_SENSORS_MP5990)	+= mp5990.o
>   obj-$(CONFIG_SENSORS_MPQ7932)	+= mpq7932.o
>   obj-$(CONFIG_SENSORS_PLI1209BC)	+= pli1209bc.o
>   obj-$(CONFIG_SENSORS_PM6764TR)	+= pm6764tr.o
> diff --git a/drivers/hwmon/pmbus/mp5990.c b/drivers/hwmon/pmbus/mp5990.c
> new file mode 100644
> index 000000000000..fb3ac9c5d44e
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/mp5990.c
> @@ -0,0 +1,86 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Driver for MPS MP5990 Hot-Swap Controller
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/pmbus.h>

Not used in this driver.

> +#include "pmbus.h"
> +
> +static int mp5990_read_byte_data(struct i2c_client *client, int page, int reg)
> +{
> +	switch (reg) {
> +	case PMBUS_VOUT_MODE:
> +		/* The datasheet does not support the VOUT command,

Standard multi-line comments, please. This is not the networking subsystem.

> +		 * but the device responds with a default value of 0x17.
> +		 * In the standard, 0x17 represents linear mode. However,
> +		 * for the MP5990, the VOUT linear mode is linear11, not linear16.
> +		 * Therefore, we should enforce the VOUT in the direct format.
> +		 */
> +		return PB_VOUT_MODE_DIRECT;

This doesn't take into account that the reporting mode is set in
EFUSE_CFG bit 9 (RPT_FORMAT). If the chip is configured to report its data
in linear mode, all readings will be wrong if the exponent is != 0 and
for negative values.

The driver could enforce direct mode by explicitly configuring EFUSE_CFG,
but that is not guaranteed to work because the chip could be write
protected. It would be necessary to disable write protection first,
making this a bit complicated. Alternatively, the reading of VOUT could
be adjusted in linear mode to linear16 if the chip is configured to
report data in linear mode. I would personally prefer this solution.
Either case, this needs to be handled.

Guenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-10 15:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-09  4:48 [PATCH v2 0/2] hwmon: (pmbus) MPS mp5990 hsc controller Peter Yin
2023-11-09  4:48 ` [PATCH v2 1/2] dt-bindings: hwmon: Add mps mp5990 driver bindings Peter Yin
2023-11-09  8:56   ` Krzysztof Kozlowski
2023-11-10  9:41     ` PeterYin
2023-11-09  4:48 ` [PATCH v2 2/2] hwmon: (pmbus) Add support for MPS Multi-phase mp5990 Peter Yin
2023-11-10 15:34   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).