* [PATCH v3 0/2] Add MPS MP5920 Host-Swap controller
@ 2024-07-01 14:55 Alex Vdovydchenko
2024-07-01 14:56 ` [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920 Alex Vdovydchenko
2024-07-01 14:56 ` [PATCH v3 2/2] hwmon: add MP5920 driver Alex Vdovydchenko
0 siblings, 2 replies; 10+ messages in thread
From: Alex Vdovydchenko @ 2024-07-01 14:55 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sean Anderson,
Guenter Roeck, Jean Delvare, Jonathan Corbet, Delphine CC Chiu
Cc: devicetree, linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
This series of patches adds the MP5920 Host-swap controller, which is used
as a protection and control IC for devices that are being inserted into a live
backplane. MP5920 acts as a voltage regulator (MP5911 etc) supervisor. IC
utilizes pmbus and provides monitoring, statistics and limits to electrical and
thermal characteristics such as:
- input and output voltage
- output current
- output power
- IC temperature
One must take into account the nonlinear character of readings, so there will be
a statistical error in the range 5–10 percents, depending on current passing
through. In order to use the IC, make sure to specify a valid I2C address
(consult to datasheet and dts-bindings)
MP5920 datasheet: https://www.monolithicpower.com/en/mp5920.html
Changes in v2:
- fixed typos
Changes in v3:
- removed unnecessary license blob
- removed unnecessary headers
- edited device tables style
- added chip name checking in probing
- fixed typos in pmbus_driver_info struct initialization
Alex Vdovydchenko (2):
dt-bindings: hwmon: Add MPS mp5920
hwmon: add MP5920 driver
.../devicetree/bindings/trivial-devices.yaml | 2 +
Documentation/hwmon/index.rst | 1 +
Documentation/hwmon/mp5920.rst | 91 ++++++++++++++++++
drivers/hwmon/pmbus/Kconfig | 9 ++
drivers/hwmon/pmbus/Makefile | 1 +
drivers/hwmon/pmbus/mp5920.c | 93 +++++++++++++++++++
6 files changed, 197 insertions(+)
create mode 100644 Documentation/hwmon/mp5920.rst
create mode 100644 drivers/hwmon/pmbus/mp5920.c
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920
2024-07-01 14:55 [PATCH v3 0/2] Add MPS MP5920 Host-Swap controller Alex Vdovydchenko
@ 2024-07-01 14:56 ` Alex Vdovydchenko
2024-07-01 15:47 ` Conor Dooley
2024-07-01 14:56 ` [PATCH v3 2/2] hwmon: add MP5920 driver Alex Vdovydchenko
1 sibling, 1 reply; 10+ messages in thread
From: Alex Vdovydchenko @ 2024-07-01 14:56 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sean Anderson,
Guenter Roeck, Jean Delvare, Jonathan Corbet, Delphine CC Chiu
Cc: devicetree, linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
Add support for MPS mp5920 controller
Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
---
Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
index ff70f0926..cb2fc26d9 100644
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
@@ -296,6 +296,8 @@ properties:
- mps,mp2975
# Monolithic Power Systems Inc. multi-phase controller mp2993
- mps,mp2993
+ # Monolithic Power Systems Inc. multi-phase hot-swap controller mp5920
+ - mps,mp5920
# Monolithic Power Systems Inc. multi-phase hot-swap controller mp5990
- mps,mp5990
# Monolithic Power Systems Inc. digital step-down converter mp9941
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 2/2] hwmon: add MP5920 driver
2024-07-01 14:55 [PATCH v3 0/2] Add MPS MP5920 Host-Swap controller Alex Vdovydchenko
2024-07-01 14:56 ` [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920 Alex Vdovydchenko
@ 2024-07-01 14:56 ` Alex Vdovydchenko
2024-07-01 16:11 ` Guenter Roeck
2024-07-01 20:19 ` Thomas Weißschuh
1 sibling, 2 replies; 10+ messages in thread
From: Alex Vdovydchenko @ 2024-07-01 14:56 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sean Anderson,
Guenter Roeck, Jean Delvare, Jonathan Corbet, Delphine CC Chiu
Cc: devicetree, linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
Add support for MPS Hot-Swap controller mp5920. This driver exposes
telemetry and limit value readings and writings.
Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
---
Documentation/hwmon/index.rst | 1 +
Documentation/hwmon/mp5920.rst | 91 +++++++++++++++++++++++++++++++++
drivers/hwmon/pmbus/Kconfig | 9 ++++
drivers/hwmon/pmbus/Makefile | 1 +
drivers/hwmon/pmbus/mp5920.c | 93 ++++++++++++++++++++++++++++++++++
5 files changed, 195 insertions(+)
create mode 100644 Documentation/hwmon/mp5920.rst
create mode 100644 drivers/hwmon/pmbus/mp5920.c
diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index e92a3d5c7..9eba7e402 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -168,6 +168,7 @@ Hardware Monitoring Kernel Drivers
mp2975
mp2993
mp5023
+ mp5920
mp5990
mp9941
mpq8785
--- /dev/null
+++ b/Documentation/hwmon/mp5920.rst
@@ -0,0 +1,91 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver mp5920
+====================
+
+Supported chips:
+
+ * MPS MP5920
+
+ Prefix: 'mp5920'
+
+ * Datasheet
+
+ Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5920.html
+
+Authors:
+
+ Tony Ao <tony_ao@wiwynn.com>
+ Alex Vdovydchenko <xzeol@yahoo.com>
+
+Description
+-----------
+
+This driver implements support for Monolithic Power Systems, Inc. (MPS)
+MP5920 Hot-Swap Controller.
+
+Device compliant with:
+
+- PMBus rev 1.3 interface.
+
+Device supports direct and linear 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_rated_max**
+
+**in1_rated_min**
+
+**in1_crit**
+
+**in1_alarm**
+
+The driver provides the following attributes for output voltage:
+
+**in2_input**
+
+**in2_label**
+
+**in2_rated_max**
+
+**in2_rated_min**
+
+**in2_alarm**
+
+The driver provides the following attributes for output current:
+
+**curr1_input**
+
+**curr1_label**
+
+**curr1_crit**
+
+**curr1_alarm**
+
+**curr1_rated_max**
+
+The driver provides the following attributes for input power:
+
+**power1_input**
+
+**power1_label**
+
+**power1_max**
+
+**power1_rated_max**
+
+The driver provides the following attributes for temperature:
+
+**temp1_input**
+
+**temp1_max**
+
+**temp1_crit**
+
+**temp1_alarm**
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -371,6 +371,15 @@ config SENSORS_MP5023
This driver can also be built as a module. If so, the module will
be called mp5023.
+config SENSORS_MP5920
+ tristate "MPS MP5920"
+ help
+ If you say yes here you get hardware monitoring support for Monolithic
+ MP5920.
+
+ This driver can also be built as a module. If so, the module will
+ be called mp5920.
+
config SENSORS_MP5990
tristate "MPS MP5990"
help
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_SENSORS_MP2888) += mp2888.o
obj-$(CONFIG_SENSORS_MP2975) += mp2975.o
obj-$(CONFIG_SENSORS_MP2993) += mp2993.o
obj-$(CONFIG_SENSORS_MP5023) += mp5023.o
+obj-$(CONFIG_SENSORS_MP5920) += mp5920.o
obj-$(CONFIG_SENSORS_MP5990) += mp5990.o
obj-$(CONFIG_SENSORS_MP9941) += mp9941.o
obj-$(CONFIG_SENSORS_MPQ7932) += mpq7932.o
--- /dev/null
+++ b/drivers/hwmon/pmbus/mp5920.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include "pmbus.h"
+
+static struct pmbus_driver_info mp5920_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] = 2266,
+ .b[PSC_VOLTAGE_IN] = 0,
+ .R[PSC_VOLTAGE_IN] = -1,
+ .m[PSC_VOLTAGE_OUT] = 2266,
+ .b[PSC_VOLTAGE_OUT] = 0,
+ .R[PSC_VOLTAGE_OUT] = -1,
+ .m[PSC_CURRENT_OUT] = 546,
+ .b[PSC_CURRENT_OUT] = 0,
+ .R[PSC_CURRENT_OUT] = -2,
+ .m[PSC_POWER] = 5840,
+ .b[PSC_POWER] = 0,
+ .R[PSC_POWER] = -3,
+ .m[PSC_TEMPERATURE] = 1067,
+ .b[PSC_TEMPERATURE] = 20500,
+ .R[PSC_TEMPERATURE] = -2,
+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT |
+ PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT |
+ PMBUS_HAVE_TEMP,
+};
+
+static int mp5920_probe(struct i2c_client *client)
+{
+ struct device *dev = &client->dev;
+ int ret;
+ u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
+
+ ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
+ if (ret < 0) {
+ dev_err(dev, "Failed to read PMBUS_MFR_MODEL\n");
+ return ret;
+ }
+ if (ret != 6 || strncmp(buf, "MP5920", 6)) {
+ buf[ret] = '\0';
+ dev_err(dev, "Model '%s' not supported\n", buf);
+ return -ENODEV;
+ }
+
+ return pmbus_do_probe(client, &mp5920_info);
+}
+
+static const struct of_device_id mp5920_of_match[] = {
+ { .compatible = "mps,mp5920" },
+ { }
+};
+
+MODULE_DEVICE_TABLE(of, mp5920_of_match);
+
+static const struct i2c_device_id mp5920_id[] = {
+ { "mp5920" },
+ { }
+};
+
+MODULE_DEVICE_TABLE(i2c, mp5920_id);
+
+static struct i2c_driver mp5920_driver = {
+ .driver = {
+ .name = "mp5920",
+ },
+ .probe = mp5920_probe,
+ .id_table = mp5920_id,
+};
+
+module_i2c_driver(mp5920_driver);
+
+MODULE_AUTHOR("Tony Ao <tony_ao@wiwynn.com>");
+MODULE_AUTHOR("Alex Vdovydchenko <xzeol@yahoo.com>");
+MODULE_DESCRIPTION("PMBus driver for MP5920 HSC");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(PMBUS);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920
2024-07-01 14:56 ` [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920 Alex Vdovydchenko
@ 2024-07-01 15:47 ` Conor Dooley
2024-07-02 13:10 ` Krzysztof Kozlowski
0 siblings, 1 reply; 10+ messages in thread
From: Conor Dooley @ 2024-07-01 15:47 UTC (permalink / raw)
To: Alex Vdovydchenko
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sean Anderson,
Guenter Roeck, Jean Delvare, Jonathan Corbet, Delphine CC Chiu,
devicetree, linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
[-- Attachment #1: Type: text/plain, Size: 1244 bytes --]
On Mon, Jul 01, 2024 at 05:56:00PM +0300, Alex Vdovydchenko wrote:
> Add support for MPS mp5920 controller
>
> Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
Missing an ack from v2:
https://lore.kernel.org/all/20240627-swivel-grower-002af077b654@spud/
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Thanks,
Conor.
> ---
> Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
> index ff70f0926..cb2fc26d9 100644
> --- a/Documentation/devicetree/bindings/trivial-devices.yaml
> +++ b/Documentation/devicetree/bindings/trivial-devices.yaml
> @@ -296,6 +296,8 @@ properties:
> - mps,mp2975
> # Monolithic Power Systems Inc. multi-phase controller mp2993
> - mps,mp2993
> + # Monolithic Power Systems Inc. multi-phase hot-swap controller mp5920
> + - mps,mp5920
> # Monolithic Power Systems Inc. multi-phase hot-swap controller mp5990
> - mps,mp5990
> # Monolithic Power Systems Inc. digital step-down converter mp9941
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 2/2] hwmon: add MP5920 driver
2024-07-01 14:56 ` [PATCH v3 2/2] hwmon: add MP5920 driver Alex Vdovydchenko
@ 2024-07-01 16:11 ` Guenter Roeck
2024-07-01 20:19 ` Thomas Weißschuh
1 sibling, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2024-07-01 16:11 UTC (permalink / raw)
To: Alex Vdovydchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Sean Anderson, Jean Delvare, Jonathan Corbet, Delphine CC Chiu
Cc: devicetree, linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
On 7/1/24 07:56, Alex Vdovydchenko wrote:
> Add support for MPS Hot-Swap controller mp5920. This driver exposes
> telemetry and limit value readings and writings.
>
> Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
checkpatch says:
WARNING: From:/Signed-off-by: email address mismatch: 'From: Alex Vdovydchenko <keromvp@gmail.com>' != 'Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>'
You'll have to decide which address to use, and use it consistently.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 2/2] hwmon: add MP5920 driver
2024-07-01 14:56 ` [PATCH v3 2/2] hwmon: add MP5920 driver Alex Vdovydchenko
2024-07-01 16:11 ` Guenter Roeck
@ 2024-07-01 20:19 ` Thomas Weißschuh
2024-07-01 20:55 ` Guenter Roeck
1 sibling, 1 reply; 10+ messages in thread
From: Thomas Weißschuh @ 2024-07-01 20:19 UTC (permalink / raw)
To: Alex Vdovydchenko
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sean Anderson,
Guenter Roeck, Jean Delvare, Jonathan Corbet, Delphine CC Chiu,
devicetree, linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
On 2024-07-01 17:56:01+0000, Alex Vdovydchenko wrote:
> Add support for MPS Hot-Swap controller mp5920. This driver exposes
> telemetry and limit value readings and writings.
>
> Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
> ---
> Documentation/hwmon/index.rst | 1 +
> Documentation/hwmon/mp5920.rst | 91 +++++++++++++++++++++++++++++++++
> drivers/hwmon/pmbus/Kconfig | 9 ++++
> drivers/hwmon/pmbus/Makefile | 1 +
> drivers/hwmon/pmbus/mp5920.c | 93 ++++++++++++++++++++++++++++++++++
> 5 files changed, 195 insertions(+)
> create mode 100644 Documentation/hwmon/mp5920.rst
> create mode 100644 drivers/hwmon/pmbus/mp5920.c
>
> diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
> index e92a3d5c7..9eba7e402 100644
> --- a/Documentation/hwmon/index.rst
> +++ b/Documentation/hwmon/index.rst
> @@ -168,6 +168,7 @@ Hardware Monitoring Kernel Drivers
> mp2975
> mp2993
> mp5023
> + mp5920
> mp5990
> mp9941
> mpq8785
> --- /dev/null
> +++ b/Documentation/hwmon/mp5920.rst
> @@ -0,0 +1,91 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +Kernel driver mp5920
> +====================
> +
> +Supported chips:
> +
> + * MPS MP5920
> +
> + Prefix: 'mp5920'
> +
> + * Datasheet
> +
> + Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5920.html
> +
> +Authors:
> +
> + Tony Ao <tony_ao@wiwynn.com>
> + Alex Vdovydchenko <xzeol@yahoo.com>
> +
> +Description
> +-----------
> +
> +This driver implements support for Monolithic Power Systems, Inc. (MPS)
> +MP5920 Hot-Swap Controller.
> +
> +Device compliant with:
> +
> +- PMBus rev 1.3 interface.
> +
> +Device supports direct and linear 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_rated_max**
> +
> +**in1_rated_min**
> +
> +**in1_crit**
> +
> +**in1_alarm**
> +
> +The driver provides the following attributes for output voltage:
> +
> +**in2_input**
> +
> +**in2_label**
> +
> +**in2_rated_max**
> +
> +**in2_rated_min**
> +
> +**in2_alarm**
> +
> +The driver provides the following attributes for output current:
> +
> +**curr1_input**
> +
> +**curr1_label**
> +
> +**curr1_crit**
> +
> +**curr1_alarm**
> +
> +**curr1_rated_max**
> +
> +The driver provides the following attributes for input power:
> +
> +**power1_input**
> +
> +**power1_label**
> +
> +**power1_max**
> +
> +**power1_rated_max**
> +
> +The driver provides the following attributes for temperature:
> +
> +**temp1_input**
> +
> +**temp1_max**
> +
> +**temp1_crit**
> +
> +**temp1_alarm**
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -371,6 +371,15 @@ config SENSORS_MP5023
> This driver can also be built as a module. If so, the module will
> be called mp5023.
>
> +config SENSORS_MP5920
> + tristate "MPS MP5920"
> + help
> + If you say yes here you get hardware monitoring support for Monolithic
> + MP5920.
> +
> + This driver can also be built as a module. If so, the module will
> + be called mp5920.
> +
> config SENSORS_MP5990
> tristate "MPS MP5990"
> help
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -39,6 +39,7 @@ obj-$(CONFIG_SENSORS_MP2888) += mp2888.o
> obj-$(CONFIG_SENSORS_MP2975) += mp2975.o
> obj-$(CONFIG_SENSORS_MP2993) += mp2993.o
> obj-$(CONFIG_SENSORS_MP5023) += mp5023.o
> +obj-$(CONFIG_SENSORS_MP5920) += mp5920.o
> obj-$(CONFIG_SENSORS_MP5990) += mp5990.o
> obj-$(CONFIG_SENSORS_MP9941) += mp9941.o
> obj-$(CONFIG_SENSORS_MPQ7932) += mpq7932.o
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/mp5920.c
> @@ -0,0 +1,82 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include "pmbus.h"
> +
> +static struct pmbus_driver_info mp5920_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] = 2266,
> + .b[PSC_VOLTAGE_IN] = 0,
> + .R[PSC_VOLTAGE_IN] = -1,
> + .m[PSC_VOLTAGE_OUT] = 2266,
> + .b[PSC_VOLTAGE_OUT] = 0,
> + .R[PSC_VOLTAGE_OUT] = -1,
> + .m[PSC_CURRENT_OUT] = 546,
> + .b[PSC_CURRENT_OUT] = 0,
> + .R[PSC_CURRENT_OUT] = -2,
> + .m[PSC_POWER] = 5840,
> + .b[PSC_POWER] = 0,
> + .R[PSC_POWER] = -3,
> + .m[PSC_TEMPERATURE] = 1067,
> + .b[PSC_TEMPERATURE] = 20500,
> + .R[PSC_TEMPERATURE] = -2,
> + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT |
> + PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT |
> + PMBUS_HAVE_TEMP,
> +};
> +
> +static int mp5920_probe(struct i2c_client *client)
> +{
> + struct device *dev = &client->dev;
> + int ret;
> + u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
> +
> + ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
If you do keep a custom call to i2c_smbus_read_block_data(),
then you probably should also keep the call to i2c_check_functionality().
> + if (ret < 0) {
> + dev_err(dev, "Failed to read PMBUS_MFR_MODEL\n");
> + return ret;
> + }
If you use dev_err_probe() that would be shorter:
if (ret < 0)
return dev_err_probe(dev, ret, "Failed to read PMBUS_MFR_MODEL\n");
> + if (ret != 6 || strncmp(buf, "MP5920", 6)) {
> + buf[ret] = '\0';
> + dev_err(dev, "Model '%s' not supported\n", buf);
The manual 0-byte termination and the size + 1 can be avoided by using
dev_err_probe(dev, -ENODEV, "Model '%.*s' not supported\n", sizeof(buf), buf);
> + return -ENODEV;
> + }
> +
> + return pmbus_do_probe(client, &mp5920_info);
> +}
> +
> +static const struct of_device_id mp5920_of_match[] = {
> + { .compatible = "mps,mp5920" },
> + { }
> +};
> +
> +MODULE_DEVICE_TABLE(of, mp5920_of_match);
> +
> +static const struct i2c_device_id mp5920_id[] = {
> + { "mp5920" },
> + { }
> +};
> +
> +MODULE_DEVICE_TABLE(i2c, mp5920_id);
> +
> +static struct i2c_driver mp5920_driver = {
> + .driver = {
> + .name = "mp5920",
> + },
Borked indentation.
You can also use the shorter variant:
.driver.name = "mp5920",
Where did the .driver.of_match_table go?
> + .probe = mp5920_probe,
> + .id_table = mp5920_id,
> +};
> +
> +module_i2c_driver(mp5920_driver);
> +
> +MODULE_AUTHOR("Tony Ao <tony_ao@wiwynn.com>");
> +MODULE_AUTHOR("Alex Vdovydchenko <xzeol@yahoo.com>");
> +MODULE_DESCRIPTION("PMBus driver for MP5920 HSC");
> +MODULE_LICENSE("GPL");
> +MODULE_IMPORT_NS(PMBUS);
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 2/2] hwmon: add MP5920 driver
2024-07-01 20:19 ` Thomas Weißschuh
@ 2024-07-01 20:55 ` Guenter Roeck
0 siblings, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2024-07-01 20:55 UTC (permalink / raw)
To: Thomas Weißschuh, Alex Vdovydchenko
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sean Anderson,
Jean Delvare, Jonathan Corbet, Delphine CC Chiu, devicetree,
linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
On 7/1/24 13:19, Thomas Weißschuh wrote:
> On 2024-07-01 17:56:01+0000, Alex Vdovydchenko wrote:
>> Add support for MPS Hot-Swap controller mp5920. This driver exposes
>> telemetry and limit value readings and writings.
>>
>> Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
>> ---
>> Documentation/hwmon/index.rst | 1 +
>> Documentation/hwmon/mp5920.rst | 91 +++++++++++++++++++++++++++++++++
>> drivers/hwmon/pmbus/Kconfig | 9 ++++
>> drivers/hwmon/pmbus/Makefile | 1 +
>> drivers/hwmon/pmbus/mp5920.c | 93 ++++++++++++++++++++++++++++++++++
>> 5 files changed, 195 insertions(+)
>> create mode 100644 Documentation/hwmon/mp5920.rst
>> create mode 100644 drivers/hwmon/pmbus/mp5920.c
>>
>> diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
>> index e92a3d5c7..9eba7e402 100644
>> --- a/Documentation/hwmon/index.rst
>> +++ b/Documentation/hwmon/index.rst
>> @@ -168,6 +168,7 @@ Hardware Monitoring Kernel Drivers
>> mp2975
>> mp2993
>> mp5023
>> + mp5920
>> mp5990
>> mp9941
>> mpq8785
>> --- /dev/null
>> +++ b/Documentation/hwmon/mp5920.rst
>> @@ -0,0 +1,91 @@
>> +.. SPDX-License-Identifier: GPL-2.0
>> +
>> +Kernel driver mp5920
>> +====================
>> +
>> +Supported chips:
>> +
>> + * MPS MP5920
>> +
>> + Prefix: 'mp5920'
>> +
>> + * Datasheet
>> +
>> + Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5920.html
>> +
>> +Authors:
>> +
>> + Tony Ao <tony_ao@wiwynn.com>
>> + Alex Vdovydchenko <xzeol@yahoo.com>
>> +
>> +Description
>> +-----------
>> +
>> +This driver implements support for Monolithic Power Systems, Inc. (MPS)
>> +MP5920 Hot-Swap Controller.
>> +
>> +Device compliant with:
>> +
>> +- PMBus rev 1.3 interface.
>> +
>> +Device supports direct and linear 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_rated_max**
>> +
>> +**in1_rated_min**
>> +
>> +**in1_crit**
>> +
>> +**in1_alarm**
>> +
>> +The driver provides the following attributes for output voltage:
>> +
>> +**in2_input**
>> +
>> +**in2_label**
>> +
>> +**in2_rated_max**
>> +
>> +**in2_rated_min**
>> +
>> +**in2_alarm**
>> +
>> +The driver provides the following attributes for output current:
>> +
>> +**curr1_input**
>> +
>> +**curr1_label**
>> +
>> +**curr1_crit**
>> +
>> +**curr1_alarm**
>> +
>> +**curr1_rated_max**
>> +
>> +The driver provides the following attributes for input power:
>> +
>> +**power1_input**
>> +
>> +**power1_label**
>> +
>> +**power1_max**
>> +
>> +**power1_rated_max**
>> +
>> +The driver provides the following attributes for temperature:
>> +
>> +**temp1_input**
>> +
>> +**temp1_max**
>> +
>> +**temp1_crit**
>> +
>> +**temp1_alarm**
>> --- a/drivers/hwmon/pmbus/Kconfig
>> +++ b/drivers/hwmon/pmbus/Kconfig
>> @@ -371,6 +371,15 @@ config SENSORS_MP5023
>> This driver can also be built as a module. If so, the module will
>> be called mp5023.
>>
>> +config SENSORS_MP5920
>> + tristate "MPS MP5920"
>> + help
>> + If you say yes here you get hardware monitoring support for Monolithic
>> + MP5920.
>> +
>> + This driver can also be built as a module. If so, the module will
>> + be called mp5920.
>> +
>> config SENSORS_MP5990
>> tristate "MPS MP5990"
>> help
>> --- a/drivers/hwmon/pmbus/Makefile
>> +++ b/drivers/hwmon/pmbus/Makefile
>> @@ -39,6 +39,7 @@ obj-$(CONFIG_SENSORS_MP2888) += mp2888.o
>> obj-$(CONFIG_SENSORS_MP2975) += mp2975.o
>> obj-$(CONFIG_SENSORS_MP2993) += mp2993.o
>> obj-$(CONFIG_SENSORS_MP5023) += mp5023.o
>> +obj-$(CONFIG_SENSORS_MP5920) += mp5920.o
>> obj-$(CONFIG_SENSORS_MP5990) += mp5990.o
>> obj-$(CONFIG_SENSORS_MP9941) += mp9941.o
>> obj-$(CONFIG_SENSORS_MPQ7932) += mpq7932.o
>> --- /dev/null
>> +++ b/drivers/hwmon/pmbus/mp5920.c
>> @@ -0,0 +1,82 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +#include <linux/i2c.h>
>> +#include <linux/module.h>
>> +#include <linux/of_device.h>
>> +#include "pmbus.h"
>> +
>> +static struct pmbus_driver_info mp5920_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] = 2266,
>> + .b[PSC_VOLTAGE_IN] = 0,
>> + .R[PSC_VOLTAGE_IN] = -1,
>> + .m[PSC_VOLTAGE_OUT] = 2266,
>> + .b[PSC_VOLTAGE_OUT] = 0,
>> + .R[PSC_VOLTAGE_OUT] = -1,
>> + .m[PSC_CURRENT_OUT] = 546,
>> + .b[PSC_CURRENT_OUT] = 0,
>> + .R[PSC_CURRENT_OUT] = -2,
>> + .m[PSC_POWER] = 5840,
>> + .b[PSC_POWER] = 0,
>> + .R[PSC_POWER] = -3,
>> + .m[PSC_TEMPERATURE] = 1067,
>> + .b[PSC_TEMPERATURE] = 20500,
>> + .R[PSC_TEMPERATURE] = -2,
>> + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT |
>> + PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT |
>> + PMBUS_HAVE_TEMP,
>> +};
>> +
>> +static int mp5920_probe(struct i2c_client *client)
>> +{
>> + struct device *dev = &client->dev;
>> + int ret;
>> + u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
>> +
>> + ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
>
> If you do keep a custom call to i2c_smbus_read_block_data(),
> then you probably should also keep the call to i2c_check_functionality().
>
>> + if (ret < 0) {
>> + dev_err(dev, "Failed to read PMBUS_MFR_MODEL\n");
>> + return ret;
>> + }
>
> If you use dev_err_probe() that would be shorter:
>
> if (ret < 0)
> return dev_err_probe(dev, ret, "Failed to read PMBUS_MFR_MODEL\n");
>
>> + if (ret != 6 || strncmp(buf, "MP5920", 6)) {
>> + buf[ret] = '\0';
>> + dev_err(dev, "Model '%s' not supported\n", buf);
>
> The manual 0-byte termination and the size + 1 can be avoided by using
>
> dev_err_probe(dev, -ENODEV, "Model '%.*s' not supported\n", sizeof(buf), buf);
>
>> + return -ENODEV;
>> + }
>> +
>> + return pmbus_do_probe(client, &mp5920_info);
>> +}
>> +
>> +static const struct of_device_id mp5920_of_match[] = {
>> + { .compatible = "mps,mp5920" },
>> + { }
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, mp5920_of_match);
>> +
>> +static const struct i2c_device_id mp5920_id[] = {
>> + { "mp5920" },
>> + { }
>> +};
>> +
>> +MODULE_DEVICE_TABLE(i2c, mp5920_id);
>> +
>> +static struct i2c_driver mp5920_driver = {
>> + .driver = {
>> + .name = "mp5920",
>> + },
>
> Borked indentation.
> You can also use the shorter variant:
> .driver.name = "mp5920",
>
> Where did the .driver.of_match_table go?
>
I personally prefer the longer version, but, yes,
.driver.of_match_table disappeared. Good catch.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920
2024-07-01 15:47 ` Conor Dooley
@ 2024-07-02 13:10 ` Krzysztof Kozlowski
2024-07-02 15:44 ` Conor Dooley
0 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-02 13:10 UTC (permalink / raw)
To: Conor Dooley, Alex Vdovydchenko
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sean Anderson,
Guenter Roeck, Jean Delvare, Jonathan Corbet, Delphine CC Chiu,
devicetree, linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
On 01/07/2024 17:47, Conor Dooley wrote:
> On Mon, Jul 01, 2024 at 05:56:00PM +0300, Alex Vdovydchenko wrote:
>> Add support for MPS mp5920 controller
>>
>> Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
>
> Missing an ack from v2:
> https://lore.kernel.org/all/20240627-swivel-grower-002af077b654@spud/
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
That's third time you give the same ack. I suggest give up...
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920
2024-07-02 13:10 ` Krzysztof Kozlowski
@ 2024-07-02 15:44 ` Conor Dooley
2024-07-02 16:03 ` Guenter Roeck
0 siblings, 1 reply; 10+ messages in thread
From: Conor Dooley @ 2024-07-02 15:44 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Alex Vdovydchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Sean Anderson, Guenter Roeck, Jean Delvare, Jonathan Corbet,
Delphine CC Chiu, devicetree, linux-kernel, linux-hwmon,
linux-doc, linux-i2c, Alex Vdovydchenko
[-- Attachment #1: Type: text/plain, Size: 644 bytes --]
On Tue, Jul 02, 2024 at 03:10:38PM +0200, Krzysztof Kozlowski wrote:
> On 01/07/2024 17:47, Conor Dooley wrote:
> > On Mon, Jul 01, 2024 at 05:56:00PM +0300, Alex Vdovydchenko wrote:
> >> Add support for MPS mp5920 controller
> >>
> >> Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
> >
> > Missing an ack from v2:
> > https://lore.kernel.org/all/20240627-swivel-grower-002af077b654@spud/
> > Acked-by: Conor Dooley <conor.dooley@microchip.com>
>
> That's third time you give the same ack. I suggest give up...
Yeah, I guess. It's just not really any slower to re-ack than it is to
complain about the ack being missing.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920
2024-07-02 15:44 ` Conor Dooley
@ 2024-07-02 16:03 ` Guenter Roeck
0 siblings, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2024-07-02 16:03 UTC (permalink / raw)
To: Conor Dooley, Krzysztof Kozlowski
Cc: Alex Vdovydchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Sean Anderson, Jean Delvare, Jonathan Corbet, Delphine CC Chiu,
devicetree, linux-kernel, linux-hwmon, linux-doc, linux-i2c,
Alex Vdovydchenko
On 7/2/24 08:44, Conor Dooley wrote:
> On Tue, Jul 02, 2024 at 03:10:38PM +0200, Krzysztof Kozlowski wrote:
>> On 01/07/2024 17:47, Conor Dooley wrote:
>>> On Mon, Jul 01, 2024 at 05:56:00PM +0300, Alex Vdovydchenko wrote:
>>>> Add support for MPS mp5920 controller
>>>>
>>>> Signed-off-by: Alex Vdovydchenko <xzeol@yahoo.com>
>>>
>>> Missing an ack from v2:
>>> https://lore.kernel.org/all/20240627-swivel-grower-002af077b654@spud/
>>> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>>
>> That's third time you give the same ack. I suggest give up...
>
>
> Yeah, I guess. It's just not really any slower to re-ack than it is to
> complain about the ack being missing.
Makes me wonder though why I am still a kernel maintainer :-(.
Guenter
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-07-02 16:03 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-01 14:55 [PATCH v3 0/2] Add MPS MP5920 Host-Swap controller Alex Vdovydchenko
2024-07-01 14:56 ` [PATCH v3 1/2] dt-bindings: hwmon: Add MPS mp5920 Alex Vdovydchenko
2024-07-01 15:47 ` Conor Dooley
2024-07-02 13:10 ` Krzysztof Kozlowski
2024-07-02 15:44 ` Conor Dooley
2024-07-02 16:03 ` Guenter Roeck
2024-07-01 14:56 ` [PATCH v3 2/2] hwmon: add MP5920 driver Alex Vdovydchenko
2024-07-01 16:11 ` Guenter Roeck
2024-07-01 20:19 ` Thomas Weißschuh
2024-07-01 20:55 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox