linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Add support for mpq7932 PMIC IC
@ 2022-12-07 17:37 Saravanan Sekar
  2022-12-07 17:37 ` [PATCH v3 1/4] hwmon: pm_bus: core: Add min_uV in pmbus regulator helper macro Saravanan Sekar
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Saravanan Sekar @ 2022-12-07 17:37 UTC (permalink / raw)
  To: jdelvare, linux, robh+dt, krzysztof.kozlowski+dt, marten.lindahl
  Cc: linux-hwmon, devicetree, linux-kernel, Saravanan Sekar

changes in v3:
  - bindings moved from pmbus to regulator directory
  - added second configuraion option SENSORS_MPQ7932_REGULATOR which enables regulator functionality
  - fixed review comments on driver

changes in v2:
  - add new patch to include min_uV in PMBUS_REGULATOR_STEP
  - fix review comments mpq7932 driver, bindings document and Maintiners file

Saravanan Sekar (4):
  hwmon: pm_bus: core: Add min_uV in pmbus regulator helper macro
  dt-bindings: regulator: Add mps,mpq7932 power-management IC
  hwmon: (pmbus/mpq7932) Add a support for mpq7932 Power Management IC
  MAINTAINERS: Update the entry for MPQ7932 PMIC driver

 .../bindings/regulator/mps,mpq7932.yaml       |  68 ++++++++
 MAINTAINERS                                   |   1 +
 drivers/hwmon/pmbus/Kconfig                   |  16 ++
 drivers/hwmon/pmbus/Makefile                  |   1 +
 drivers/hwmon/pmbus/ltc2978.c                 |  16 +-
 drivers/hwmon/pmbus/mpq7932.c                 | 157 ++++++++++++++++++
 drivers/hwmon/pmbus/pmbus.h                   |   5 +-
 7 files changed, 254 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml
 create mode 100644 drivers/hwmon/pmbus/mpq7932.c

-- 
2.34.1


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

* [PATCH v3 1/4] hwmon: pm_bus: core: Add min_uV in pmbus regulator helper macro
  2022-12-07 17:37 [PATCH v3 0/4] Add support for mpq7932 PMIC IC Saravanan Sekar
@ 2022-12-07 17:37 ` Saravanan Sekar
  2022-12-29 14:02   ` Guenter Roeck
  2022-12-07 17:37 ` [PATCH v3 2/4] dt-bindings: regulator: Add mps,mpq7932 power-management IC Saravanan Sekar
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Saravanan Sekar @ 2022-12-07 17:37 UTC (permalink / raw)
  To: jdelvare, linux, robh+dt, krzysztof.kozlowski+dt, marten.lindahl
  Cc: linux-hwmon, devicetree, linux-kernel, Saravanan Sekar

Some regulator operates in a range of voltage which should not allow
below the lower threshold.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
---
 drivers/hwmon/pmbus/ltc2978.c | 16 ++++++++--------
 drivers/hwmon/pmbus/pmbus.h   |  5 +++--
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index 6d2592731ba3..406a36885ef3 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -569,14 +569,14 @@ MODULE_DEVICE_TABLE(i2c, ltc2978_id);
 #define LTC2978_N_VOLTAGES	((LTC2978_MAX_UV / LTC2978_UV_STEP) + 1)
 
 static const struct regulator_desc ltc2978_reg_desc[] = {
-	PMBUS_REGULATOR_STEP("vout", 0, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
-	PMBUS_REGULATOR_STEP("vout", 1, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
-	PMBUS_REGULATOR_STEP("vout", 2, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
-	PMBUS_REGULATOR_STEP("vout", 3, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
-	PMBUS_REGULATOR_STEP("vout", 4, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
-	PMBUS_REGULATOR_STEP("vout", 5, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
-	PMBUS_REGULATOR_STEP("vout", 6, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
-	PMBUS_REGULATOR_STEP("vout", 7, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
+	PMBUS_REGULATOR_STEP("vout", 0, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
+	PMBUS_REGULATOR_STEP("vout", 1, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
+	PMBUS_REGULATOR_STEP("vout", 2, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
+	PMBUS_REGULATOR_STEP("vout", 3, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
+	PMBUS_REGULATOR_STEP("vout", 4, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
+	PMBUS_REGULATOR_STEP("vout", 5, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
+	PMBUS_REGULATOR_STEP("vout", 6, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
+	PMBUS_REGULATOR_STEP("vout", 7, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
 };
 
 static const struct regulator_desc ltc2978_reg_desc_default[] = {
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index 10fb17879f8e..713ea7915425 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -464,7 +464,7 @@ struct pmbus_driver_info {
 extern const struct regulator_ops pmbus_regulator_ops;
 
 /* Macros for filling in array of struct regulator_desc */
-#define PMBUS_REGULATOR_STEP(_name, _id, _voltages, _step)  \
+#define PMBUS_REGULATOR_STEP(_name, _id, _voltages, _step, _min_uV)  \
 	[_id] = {						\
 		.name = (_name # _id),				\
 		.id = (_id),					\
@@ -475,9 +475,10 @@ extern const struct regulator_ops pmbus_regulator_ops;
 		.owner = THIS_MODULE,				\
 		.n_voltages = _voltages,			\
 		.uV_step = _step,				\
+		.min_uV = _min_uV,				\
 	}
 
-#define PMBUS_REGULATOR(_name, _id)	PMBUS_REGULATOR_STEP(_name, _id, 0, 0)
+#define PMBUS_REGULATOR(_name, _id)   PMBUS_REGULATOR_STEP(_name, _id, 0, 0, 0)
 
 /* Function declarations */
 
-- 
2.34.1


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

* [PATCH v3 2/4] dt-bindings: regulator: Add mps,mpq7932 power-management IC
  2022-12-07 17:37 [PATCH v3 0/4] Add support for mpq7932 PMIC IC Saravanan Sekar
  2022-12-07 17:37 ` [PATCH v3 1/4] hwmon: pm_bus: core: Add min_uV in pmbus regulator helper macro Saravanan Sekar
@ 2022-12-07 17:37 ` Saravanan Sekar
  2022-12-07 17:59   ` Krzysztof Kozlowski
  2022-12-29 14:08   ` Guenter Roeck
  2022-12-07 17:37 ` [PATCH v3 3/4] hwmon: (pmbus/mpq7932) Add a support for mpq7932 Power Management IC Saravanan Sekar
  2022-12-07 17:37 ` [PATCH v3 4/4] MAINTAINERS: Update the entry for MPQ7932 PMIC driver Saravanan Sekar
  3 siblings, 2 replies; 10+ messages in thread
From: Saravanan Sekar @ 2022-12-07 17:37 UTC (permalink / raw)
  To: jdelvare, linux, robh+dt, krzysztof.kozlowski+dt, marten.lindahl
  Cc: linux-hwmon, devicetree, linux-kernel, Saravanan Sekar

Document mpq7932 power-management IC

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
---
 .../bindings/regulator/mps,mpq7932.yaml       | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml

diff --git a/Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml b/Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml
new file mode 100644
index 000000000000..2185cd011c46
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/mps,mpq7932.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Monolithic Power System MPQ7932 PMIC
+
+maintainers:
+  - Saravanan Sekar <saravanan@linumiz.com>
+
+properties:
+  compatible:
+    enum:
+      - mps,mpq7932
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    type: object
+    description: |
+      list of regulators provided by this controller, must be named
+      after their hardware counterparts BUCK[1-6]
+
+    patternProperties:
+      "^buck[1-6]$":
+        type: object
+        $ref: regulator.yaml#
+        unevaluatedProperties: false
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - regulators
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic@3 {
+            compatible = "mps,mpq7932";
+            reg = <0x3>;
+
+            regulators {
+                buck1 {
+                    regulator-name = "buck1";
+                    regulator-min-microvolt = <1600000>;
+                    regulator-max-microvolt = <1800000>;
+                    regulator-boot-on;
+                };
+
+                buck2 {
+                    regulator-name = "buck2";
+                    regulator-min-microvolt = <1700000>;
+                    regulator-max-microvolt = <1800000>;
+                    regulator-boot-on;
+                };
+            };
+        };
+    };
+...
-- 
2.34.1


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

* [PATCH v3 3/4] hwmon: (pmbus/mpq7932) Add a support for mpq7932 Power Management IC
  2022-12-07 17:37 [PATCH v3 0/4] Add support for mpq7932 PMIC IC Saravanan Sekar
  2022-12-07 17:37 ` [PATCH v3 1/4] hwmon: pm_bus: core: Add min_uV in pmbus regulator helper macro Saravanan Sekar
  2022-12-07 17:37 ` [PATCH v3 2/4] dt-bindings: regulator: Add mps,mpq7932 power-management IC Saravanan Sekar
@ 2022-12-07 17:37 ` Saravanan Sekar
  2022-12-29 14:01   ` Guenter Roeck
  2022-12-07 17:37 ` [PATCH v3 4/4] MAINTAINERS: Update the entry for MPQ7932 PMIC driver Saravanan Sekar
  3 siblings, 1 reply; 10+ messages in thread
From: Saravanan Sekar @ 2022-12-07 17:37 UTC (permalink / raw)
  To: jdelvare, linux, robh+dt, krzysztof.kozlowski+dt, marten.lindahl
  Cc: linux-hwmon, devicetree, linux-kernel, Saravanan Sekar

The MPQ7932 is a power management IC designed to operate from 5V buses to
power a variety of Advanced driver-assistance system SOCs. Six integrated
buck converters with hardware monitoring capability powers a variety of
target rails configurable over PMBus interface.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
---
 drivers/hwmon/pmbus/Kconfig   |  16 ++++
 drivers/hwmon/pmbus/Makefile  |   1 +
 drivers/hwmon/pmbus/mpq7932.c | 153 ++++++++++++++++++++++++++++++++++
 3 files changed, 170 insertions(+)
 create mode 100644 drivers/hwmon/pmbus/mpq7932.c

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 89668af67206..30448e049486 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -317,6 +317,22 @@ config SENSORS_MP5023
 	  This driver can also be built as a module. If so, the module will
 	  be called mp5023.
 
+config SENSORS_MPQ7932_REGULATOR
+	bool "Regulator support for MPQ7932"
+	depends on SENSORS_MPQ7932 && REGULATOR
+	help
+	  If you say yes here you get six integrated buck converter regulator
+	  support for power management IC MPS MPQ7932.
+
+config SENSORS_MPQ7932
+	tristate "MPS MPQ7932"
+	help
+	  If you say yes here you get hardware monitoring functionality support
+	  for power management IC MPS MPQ7932.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called mpq7932.
+
 config SENSORS_PIM4328
 	tristate "Flex PIM4328 and compatibles"
 	help
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 0002dbe22d52..d9d2fa4bd6f7 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -34,6 +34,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_MPQ7932)	+= mpq7932.o
 obj-$(CONFIG_SENSORS_PLI1209BC)	+= pli1209bc.o
 obj-$(CONFIG_SENSORS_PM6764TR)	+= pm6764tr.o
 obj-$(CONFIG_SENSORS_PXE1610)	+= pxe1610.o
diff --git a/drivers/hwmon/pmbus/mpq7932.c b/drivers/hwmon/pmbus/mpq7932.c
new file mode 100644
index 000000000000..1dc1ab71957b
--- /dev/null
+++ b/drivers/hwmon/pmbus/mpq7932.c
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * mpq7932.c - hwmon with optional regulator driver for mps mpq7932
+ * Copyright 2022 Monolithic Power Systems, Inc
+ *
+ * Author: Saravanan Sekar <saravanan@linumiz.com>
+ */
+
+#include <linux/bits.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/pmbus.h>
+#include "pmbus.h"
+
+#define MPQ7932_BUCK_UV_MIN		206250
+#define MPQ7932_UV_STEP			6250
+#define MPQ7932_N_VOLTAGES		256
+#define MPQ7932_VOUT_MAX		0xFF
+#define MPQ7932_NUM_PAGES		6
+
+#define MPQ7932_TON_DELAY		0x60
+#define MPQ7932_VOUT_STARTUP_SLEW	0xA3
+#define MPQ7932_VOUT_SHUTDOWN_SLEW	0xA5
+#define MPQ7932_VOUT_SLEW_MASK		GENMASK(1, 0)
+#define MPQ7932_TON_DELAY_MASK		GENMASK(4, 0)
+
+struct mpq7932_data {
+	struct pmbus_driver_info info;
+	struct pmbus_platform_data pdata;
+};
+
+#if IS_ENABLED(CONFIG_SENSORS_MPQ7932_REGULATOR)
+static struct regulator_desc mpq7932_regulators_desc[] = {
+	PMBUS_REGULATOR_STEP("buck", 0, MPQ7932_N_VOLTAGES,
+			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
+	PMBUS_REGULATOR_STEP("buck", 1, MPQ7932_N_VOLTAGES,
+			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
+	PMBUS_REGULATOR_STEP("buck", 2, MPQ7932_N_VOLTAGES,
+			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
+	PMBUS_REGULATOR_STEP("buck", 3, MPQ7932_N_VOLTAGES,
+			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
+	PMBUS_REGULATOR_STEP("buck", 4, MPQ7932_N_VOLTAGES,
+			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
+	PMBUS_REGULATOR_STEP("buck", 5, MPQ7932_N_VOLTAGES,
+			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
+};
+#endif
+
+static int mpq7932_write_word_data(struct i2c_client *client, int page, int reg,
+				   u16 word)
+{
+	switch (reg) {
+	/* chip support only byte access for VOUT_COMMAND otherwise
+	 * results -EREMOTEIO
+	 */
+	case PMBUS_VOUT_COMMAND:
+		return pmbus_write_byte_data(client, page, reg, word & 0xFF);
+
+	default:
+		return -ENODATA;
+	}
+}
+
+static int mpq7932_read_word_data(struct i2c_client *client, int page,
+				  int phase, int reg)
+{
+	switch (reg) {
+	/* chip support neither (PMBUS_VOUT_MARGIN_HIGH, PMBUS_VOUT_MARGIN_LOW)
+	 * nor (PMBUS_MFR_VOUT_MIN, PMBUS_MFR_VOUT_MAX). As a result set voltage
+	 * fails due to error in pmbus_regulator_get_low_margin, so faked.
+	 */
+	case PMBUS_MFR_VOUT_MIN:
+		return 0;
+
+	case PMBUS_MFR_VOUT_MAX:
+		return MPQ7932_VOUT_MAX;
+
+	/* chip support only byte access for VOUT_COMMAND otherwise
+	 * results -EREMOTEIO
+	 */
+	case PMBUS_READ_VOUT:
+		return pmbus_read_byte_data(client, page, PMBUS_VOUT_COMMAND);
+
+	default:
+		return -ENODATA;
+	}
+}
+
+static int mpq7932_probe(struct i2c_client *client)
+{
+	struct mpq7932_data *data;
+	struct pmbus_driver_info *info;
+	struct device *dev = &client->dev;
+	int i;
+
+	data = devm_kzalloc(dev, sizeof(struct mpq7932_data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	info = &data->info;
+	info->pages = MPQ7932_NUM_PAGES;
+	info->format[PSC_VOLTAGE_OUT] = direct;
+	info->m[PSC_VOLTAGE_OUT] = 160;
+	info->b[PSC_VOLTAGE_OUT] = -33;
+	for (i = 0; i < info->pages; i++) {
+		info->func[i] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+				| PMBUS_HAVE_STATUS_TEMP;
+	}
+
+#if IS_ENABLED(CONFIG_SENSORS_MPQ7932_REGULATOR)
+	info->num_regulators = ARRAY_SIZE(mpq7932_regulators_desc);
+	info->reg_desc = mpq7932_regulators_desc;
+#endif
+
+	info->read_word_data = mpq7932_read_word_data;
+	info->write_word_data = mpq7932_write_word_data;
+
+	data->pdata.flags = PMBUS_NO_CAPABILITY;
+	dev->platform_data = &data->pdata;
+
+	return pmbus_do_probe(client, info);
+}
+
+static const struct of_device_id mpq7932_of_match[] = {
+	{ .compatible = "mps,mpq7932"},
+	{},
+};
+MODULE_DEVICE_TABLE(of, mpq7932_of_match);
+
+static const struct i2c_device_id mpq7932_id[] = {
+	{ "mpq7932", },
+	{ },
+};
+MODULE_DEVICE_TABLE(i2c, mpq7932_id);
+
+static struct i2c_driver mpq7932_regulator_driver = {
+	.driver = {
+		.name = "mpq7932",
+		.of_match_table = mpq7932_of_match,
+	},
+	.probe_new = mpq7932_probe,
+	.id_table = mpq7932_id,
+};
+module_i2c_driver(mpq7932_regulator_driver);
+
+MODULE_AUTHOR("Saravanan Sekar <saravanan@linumiz.com>");
+MODULE_DESCRIPTION("MPQ7932 PMIC regulator driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(PMBUS);
-- 
2.34.1


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

* [PATCH v3 4/4] MAINTAINERS: Update the entry for MPQ7932 PMIC driver
  2022-12-07 17:37 [PATCH v3 0/4] Add support for mpq7932 PMIC IC Saravanan Sekar
                   ` (2 preceding siblings ...)
  2022-12-07 17:37 ` [PATCH v3 3/4] hwmon: (pmbus/mpq7932) Add a support for mpq7932 Power Management IC Saravanan Sekar
@ 2022-12-07 17:37 ` Saravanan Sekar
  2022-12-29 14:09   ` Guenter Roeck
  3 siblings, 1 reply; 10+ messages in thread
From: Saravanan Sekar @ 2022-12-07 17:37 UTC (permalink / raw)
  To: jdelvare, linux, robh+dt, krzysztof.kozlowski+dt, marten.lindahl
  Cc: linux-hwmon, devicetree, linux-kernel, Saravanan Sekar

Update the MAINTAINERS file to include the path for the MPQ7932

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 1daadaa4d48b..469ff520c479 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13932,6 +13932,7 @@ M:	Saravanan Sekar <sravanhome@gmail.com>
 S:	Maintained
 F:	Documentation/devicetree/bindings/mfd/mps,mp2629.yaml
 F:	Documentation/devicetree/bindings/regulator/mps,mp*.yaml
+F:	drivers/hwmon/pmbus/mpq7932.c
 F:	drivers/iio/adc/mp2629_adc.c
 F:	drivers/mfd/mp2629.c
 F:	drivers/power/supply/mp2629_charger.c
-- 
2.34.1


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

* Re: [PATCH v3 2/4] dt-bindings: regulator: Add mps,mpq7932 power-management IC
  2022-12-07 17:37 ` [PATCH v3 2/4] dt-bindings: regulator: Add mps,mpq7932 power-management IC Saravanan Sekar
@ 2022-12-07 17:59   ` Krzysztof Kozlowski
  2022-12-29 14:08   ` Guenter Roeck
  1 sibling, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2022-12-07 17:59 UTC (permalink / raw)
  To: Saravanan Sekar, jdelvare, linux, robh+dt,
	krzysztof.kozlowski+dt, marten.lindahl
  Cc: linux-hwmon, devicetree, linux-kernel

On 07/12/2022 18:37, Saravanan Sekar wrote:
> Document mpq7932 power-management IC
> 
> Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
> ---
>  .../bindings/regulator/mps,mpq7932.yaml       | 68 +++++++++++++++++++
>  1 file changed, 68 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml
> 


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

Best regards,
Krzysztof


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

* Re: [PATCH v3 3/4] hwmon: (pmbus/mpq7932) Add a support for mpq7932 Power Management IC
  2022-12-07 17:37 ` [PATCH v3 3/4] hwmon: (pmbus/mpq7932) Add a support for mpq7932 Power Management IC Saravanan Sekar
@ 2022-12-29 14:01   ` Guenter Roeck
  0 siblings, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2022-12-29 14:01 UTC (permalink / raw)
  To: Saravanan Sekar
  Cc: jdelvare, robh+dt, krzysztof.kozlowski+dt, marten.lindahl,
	linux-hwmon, devicetree, linux-kernel

On Wed, Dec 07, 2022 at 06:37:15PM +0100, Saravanan Sekar wrote:
> The MPQ7932 is a power management IC designed to operate from 5V buses to
> power a variety of Advanced driver-assistance system SOCs. Six integrated
> buck converters with hardware monitoring capability powers a variety of
> target rails configurable over PMBus interface.
> 
> Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>

Applied to hwmon-next, after changing multi-line comments.

Guenter

> ---
>  drivers/hwmon/pmbus/Kconfig   |  16 ++++
>  drivers/hwmon/pmbus/Makefile  |   1 +
>  drivers/hwmon/pmbus/mpq7932.c | 153 ++++++++++++++++++++++++++++++++++
>  3 files changed, 170 insertions(+)
>  create mode 100644 drivers/hwmon/pmbus/mpq7932.c
> 
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index 89668af67206..30448e049486 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -317,6 +317,22 @@ config SENSORS_MP5023
>  	  This driver can also be built as a module. If so, the module will
>  	  be called mp5023.
>  
> +config SENSORS_MPQ7932_REGULATOR
> +	bool "Regulator support for MPQ7932"
> +	depends on SENSORS_MPQ7932 && REGULATOR
> +	help
> +	  If you say yes here you get six integrated buck converter regulator
> +	  support for power management IC MPS MPQ7932.
> +
> +config SENSORS_MPQ7932
> +	tristate "MPS MPQ7932"
> +	help
> +	  If you say yes here you get hardware monitoring functionality support
> +	  for power management IC MPS MPQ7932.
> +
> +	  This driver can also be built as a module. If so, the module will
> +	  be called mpq7932.
> +
>  config SENSORS_PIM4328
>  	tristate "Flex PIM4328 and compatibles"
>  	help
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index 0002dbe22d52..d9d2fa4bd6f7 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -34,6 +34,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_MPQ7932)	+= mpq7932.o
>  obj-$(CONFIG_SENSORS_PLI1209BC)	+= pli1209bc.o
>  obj-$(CONFIG_SENSORS_PM6764TR)	+= pm6764tr.o
>  obj-$(CONFIG_SENSORS_PXE1610)	+= pxe1610.o
> diff --git a/drivers/hwmon/pmbus/mpq7932.c b/drivers/hwmon/pmbus/mpq7932.c
> new file mode 100644
> index 000000000000..1dc1ab71957b
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/mpq7932.c
> @@ -0,0 +1,153 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * mpq7932.c - hwmon with optional regulator driver for mps mpq7932
> + * Copyright 2022 Monolithic Power Systems, Inc
> + *
> + * Author: Saravanan Sekar <saravanan@linumiz.com>
> + */
> +
> +#include <linux/bits.h>
> +#include <linux/err.h>
> +#include <linux/i2c.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/pmbus.h>
> +#include "pmbus.h"
> +
> +#define MPQ7932_BUCK_UV_MIN		206250
> +#define MPQ7932_UV_STEP			6250
> +#define MPQ7932_N_VOLTAGES		256
> +#define MPQ7932_VOUT_MAX		0xFF
> +#define MPQ7932_NUM_PAGES		6
> +
> +#define MPQ7932_TON_DELAY		0x60
> +#define MPQ7932_VOUT_STARTUP_SLEW	0xA3
> +#define MPQ7932_VOUT_SHUTDOWN_SLEW	0xA5
> +#define MPQ7932_VOUT_SLEW_MASK		GENMASK(1, 0)
> +#define MPQ7932_TON_DELAY_MASK		GENMASK(4, 0)
> +
> +struct mpq7932_data {
> +	struct pmbus_driver_info info;
> +	struct pmbus_platform_data pdata;
> +};
> +
> +#if IS_ENABLED(CONFIG_SENSORS_MPQ7932_REGULATOR)
> +static struct regulator_desc mpq7932_regulators_desc[] = {
> +	PMBUS_REGULATOR_STEP("buck", 0, MPQ7932_N_VOLTAGES,
> +			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
> +	PMBUS_REGULATOR_STEP("buck", 1, MPQ7932_N_VOLTAGES,
> +			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
> +	PMBUS_REGULATOR_STEP("buck", 2, MPQ7932_N_VOLTAGES,
> +			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
> +	PMBUS_REGULATOR_STEP("buck", 3, MPQ7932_N_VOLTAGES,
> +			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
> +	PMBUS_REGULATOR_STEP("buck", 4, MPQ7932_N_VOLTAGES,
> +			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
> +	PMBUS_REGULATOR_STEP("buck", 5, MPQ7932_N_VOLTAGES,
> +			     MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
> +};
> +#endif
> +
> +static int mpq7932_write_word_data(struct i2c_client *client, int page, int reg,
> +				   u16 word)
> +{
> +	switch (reg) {
> +	/* chip support only byte access for VOUT_COMMAND otherwise
> +	 * results -EREMOTEIO
> +	 */

/*
 * We do not use or accept networking-style multi-line comments in the hwmon
 * subsystem.
 */

> +	case PMBUS_VOUT_COMMAND:
> +		return pmbus_write_byte_data(client, page, reg, word & 0xFF);
> +
> +	default:
> +		return -ENODATA;
> +	}
> +}
> +
> +static int mpq7932_read_word_data(struct i2c_client *client, int page,
> +				  int phase, int reg)
> +{
> +	switch (reg) {
> +	/* chip support neither (PMBUS_VOUT_MARGIN_HIGH, PMBUS_VOUT_MARGIN_LOW)
> +	 * nor (PMBUS_MFR_VOUT_MIN, PMBUS_MFR_VOUT_MAX). As a result set voltage
> +	 * fails due to error in pmbus_regulator_get_low_margin, so faked.
> +	 */
> +	case PMBUS_MFR_VOUT_MIN:
> +		return 0;
> +
> +	case PMBUS_MFR_VOUT_MAX:
> +		return MPQ7932_VOUT_MAX;
> +
> +	/* chip support only byte access for VOUT_COMMAND otherwise
> +	 * results -EREMOTEIO
> +	 */
> +	case PMBUS_READ_VOUT:
> +		return pmbus_read_byte_data(client, page, PMBUS_VOUT_COMMAND);
> +
> +	default:
> +		return -ENODATA;
> +	}
> +}
> +
> +static int mpq7932_probe(struct i2c_client *client)
> +{
> +	struct mpq7932_data *data;
> +	struct pmbus_driver_info *info;
> +	struct device *dev = &client->dev;
> +	int i;
> +
> +	data = devm_kzalloc(dev, sizeof(struct mpq7932_data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	info = &data->info;
> +	info->pages = MPQ7932_NUM_PAGES;
> +	info->format[PSC_VOLTAGE_OUT] = direct;
> +	info->m[PSC_VOLTAGE_OUT] = 160;
> +	info->b[PSC_VOLTAGE_OUT] = -33;
> +	for (i = 0; i < info->pages; i++) {
> +		info->func[i] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
> +				| PMBUS_HAVE_STATUS_TEMP;
> +	}
> +
> +#if IS_ENABLED(CONFIG_SENSORS_MPQ7932_REGULATOR)
> +	info->num_regulators = ARRAY_SIZE(mpq7932_regulators_desc);
> +	info->reg_desc = mpq7932_regulators_desc;
> +#endif
> +
> +	info->read_word_data = mpq7932_read_word_data;
> +	info->write_word_data = mpq7932_write_word_data;
> +
> +	data->pdata.flags = PMBUS_NO_CAPABILITY;
> +	dev->platform_data = &data->pdata;
> +
> +	return pmbus_do_probe(client, info);
> +}
> +
> +static const struct of_device_id mpq7932_of_match[] = {
> +	{ .compatible = "mps,mpq7932"},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, mpq7932_of_match);
> +
> +static const struct i2c_device_id mpq7932_id[] = {
> +	{ "mpq7932", },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(i2c, mpq7932_id);
> +
> +static struct i2c_driver mpq7932_regulator_driver = {
> +	.driver = {
> +		.name = "mpq7932",
> +		.of_match_table = mpq7932_of_match,
> +	},
> +	.probe_new = mpq7932_probe,
> +	.id_table = mpq7932_id,
> +};
> +module_i2c_driver(mpq7932_regulator_driver);
> +
> +MODULE_AUTHOR("Saravanan Sekar <saravanan@linumiz.com>");
> +MODULE_DESCRIPTION("MPQ7932 PMIC regulator driver");
> +MODULE_LICENSE("GPL");
> +MODULE_IMPORT_NS(PMBUS);

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

* Re: [PATCH v3 1/4] hwmon: pm_bus: core: Add min_uV in pmbus regulator helper macro
  2022-12-07 17:37 ` [PATCH v3 1/4] hwmon: pm_bus: core: Add min_uV in pmbus regulator helper macro Saravanan Sekar
@ 2022-12-29 14:02   ` Guenter Roeck
  0 siblings, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2022-12-29 14:02 UTC (permalink / raw)
  To: Saravanan Sekar
  Cc: jdelvare, robh+dt, krzysztof.kozlowski+dt, marten.lindahl,
	linux-hwmon, devicetree, linux-kernel

On Wed, Dec 07, 2022 at 06:37:13PM +0100, Saravanan Sekar wrote:
> Some regulator operates in a range of voltage which should not allow
> below the lower threshold.
> 
> Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>

Applied to hwmon-next.

> ---
>  drivers/hwmon/pmbus/ltc2978.c | 16 ++++++++--------
>  drivers/hwmon/pmbus/pmbus.h   |  5 +++--
>  2 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
> index 6d2592731ba3..406a36885ef3 100644
> --- a/drivers/hwmon/pmbus/ltc2978.c
> +++ b/drivers/hwmon/pmbus/ltc2978.c
> @@ -569,14 +569,14 @@ MODULE_DEVICE_TABLE(i2c, ltc2978_id);
>  #define LTC2978_N_VOLTAGES	((LTC2978_MAX_UV / LTC2978_UV_STEP) + 1)
>  
>  static const struct regulator_desc ltc2978_reg_desc[] = {
> -	PMBUS_REGULATOR_STEP("vout", 0, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
> -	PMBUS_REGULATOR_STEP("vout", 1, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
> -	PMBUS_REGULATOR_STEP("vout", 2, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
> -	PMBUS_REGULATOR_STEP("vout", 3, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
> -	PMBUS_REGULATOR_STEP("vout", 4, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
> -	PMBUS_REGULATOR_STEP("vout", 5, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
> -	PMBUS_REGULATOR_STEP("vout", 6, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
> -	PMBUS_REGULATOR_STEP("vout", 7, LTC2978_N_VOLTAGES, LTC2978_UV_STEP),
> +	PMBUS_REGULATOR_STEP("vout", 0, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
> +	PMBUS_REGULATOR_STEP("vout", 1, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
> +	PMBUS_REGULATOR_STEP("vout", 2, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
> +	PMBUS_REGULATOR_STEP("vout", 3, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
> +	PMBUS_REGULATOR_STEP("vout", 4, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
> +	PMBUS_REGULATOR_STEP("vout", 5, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
> +	PMBUS_REGULATOR_STEP("vout", 6, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
> +	PMBUS_REGULATOR_STEP("vout", 7, LTC2978_N_VOLTAGES, LTC2978_UV_STEP, 0),
>  };
>  
>  static const struct regulator_desc ltc2978_reg_desc_default[] = {
> diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
> index 10fb17879f8e..713ea7915425 100644
> --- a/drivers/hwmon/pmbus/pmbus.h
> +++ b/drivers/hwmon/pmbus/pmbus.h
> @@ -464,7 +464,7 @@ struct pmbus_driver_info {
>  extern const struct regulator_ops pmbus_regulator_ops;
>  
>  /* Macros for filling in array of struct regulator_desc */
> -#define PMBUS_REGULATOR_STEP(_name, _id, _voltages, _step)  \
> +#define PMBUS_REGULATOR_STEP(_name, _id, _voltages, _step, _min_uV)  \
>  	[_id] = {						\
>  		.name = (_name # _id),				\
>  		.id = (_id),					\
> @@ -475,9 +475,10 @@ extern const struct regulator_ops pmbus_regulator_ops;
>  		.owner = THIS_MODULE,				\
>  		.n_voltages = _voltages,			\
>  		.uV_step = _step,				\
> +		.min_uV = _min_uV,				\
>  	}
>  
> -#define PMBUS_REGULATOR(_name, _id)	PMBUS_REGULATOR_STEP(_name, _id, 0, 0)
> +#define PMBUS_REGULATOR(_name, _id)   PMBUS_REGULATOR_STEP(_name, _id, 0, 0, 0)
>  
>  /* Function declarations */
>  

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

* Re: [PATCH v3 2/4] dt-bindings: regulator: Add mps,mpq7932 power-management IC
  2022-12-07 17:37 ` [PATCH v3 2/4] dt-bindings: regulator: Add mps,mpq7932 power-management IC Saravanan Sekar
  2022-12-07 17:59   ` Krzysztof Kozlowski
@ 2022-12-29 14:08   ` Guenter Roeck
  1 sibling, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2022-12-29 14:08 UTC (permalink / raw)
  To: Saravanan Sekar
  Cc: jdelvare, robh+dt, krzysztof.kozlowski+dt, marten.lindahl,
	linux-hwmon, devicetree, linux-kernel

On Wed, Dec 07, 2022 at 06:37:14PM +0100, Saravanan Sekar wrote:
> Document mpq7932 power-management IC
> 
> Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Since this is in the regulator subsystem domain, I can not apply the
patch through hwmon without Acked-by: or Reviewed-by: from a regulator
maintainer.

Acked-by: Guenter Roeck <linux@roeck-us.net>

assuming that it will be applied through the regulator subsystem.

Turns out you did not actually copy a a regulator subsystem maintainer
or the regulator mailing list, so you'll have to re-send this patch for
inclusion there.

Guenter

> ---
>  .../bindings/regulator/mps,mpq7932.yaml       | 68 +++++++++++++++++++
>  1 file changed, 68 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml
> 
> diff --git a/Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml b/Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml
> new file mode 100644
> index 000000000000..2185cd011c46
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/mps,mpq7932.yaml
> @@ -0,0 +1,68 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/mps,mpq7932.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Monolithic Power System MPQ7932 PMIC
> +
> +maintainers:
> +  - Saravanan Sekar <saravanan@linumiz.com>
> +
> +properties:
> +  compatible:
> +    enum:
> +      - mps,mpq7932
> +
> +  reg:
> +    maxItems: 1
> +
> +  regulators:
> +    type: object
> +    description: |
> +      list of regulators provided by this controller, must be named
> +      after their hardware counterparts BUCK[1-6]
> +
> +    patternProperties:
> +      "^buck[1-6]$":
> +        type: object
> +        $ref: regulator.yaml#
> +        unevaluatedProperties: false
> +
> +    additionalProperties: false
> +
> +required:
> +  - compatible
> +  - reg
> +  - regulators
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        pmic@3 {
> +            compatible = "mps,mpq7932";
> +            reg = <0x3>;
> +
> +            regulators {
> +                buck1 {
> +                    regulator-name = "buck1";
> +                    regulator-min-microvolt = <1600000>;
> +                    regulator-max-microvolt = <1800000>;
> +                    regulator-boot-on;
> +                };
> +
> +                buck2 {
> +                    regulator-name = "buck2";
> +                    regulator-min-microvolt = <1700000>;
> +                    regulator-max-microvolt = <1800000>;
> +                    regulator-boot-on;
> +                };
> +            };
> +        };
> +    };
> +...

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

* Re: [PATCH v3 4/4] MAINTAINERS: Update the entry for MPQ7932 PMIC driver
  2022-12-07 17:37 ` [PATCH v3 4/4] MAINTAINERS: Update the entry for MPQ7932 PMIC driver Saravanan Sekar
@ 2022-12-29 14:09   ` Guenter Roeck
  0 siblings, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2022-12-29 14:09 UTC (permalink / raw)
  To: Saravanan Sekar
  Cc: jdelvare, robh+dt, krzysztof.kozlowski+dt, marten.lindahl,
	linux-hwmon, devicetree, linux-kernel

On Wed, Dec 07, 2022 at 06:37:16PM +0100, Saravanan Sekar wrote:
> Update the MAINTAINERS file to include the path for the MPQ7932
> 
> Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1daadaa4d48b..469ff520c479 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13932,6 +13932,7 @@ M:	Saravanan Sekar <sravanhome@gmail.com>
>  S:	Maintained
>  F:	Documentation/devicetree/bindings/mfd/mps,mp2629.yaml
>  F:	Documentation/devicetree/bindings/regulator/mps,mp*.yaml
> +F:	drivers/hwmon/pmbus/mpq7932.c
>  F:	drivers/iio/adc/mp2629_adc.c
>  F:	drivers/mfd/mp2629.c
>  F:	drivers/power/supply/mp2629_charger.c

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

end of thread, other threads:[~2022-12-29 14:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 17:37 [PATCH v3 0/4] Add support for mpq7932 PMIC IC Saravanan Sekar
2022-12-07 17:37 ` [PATCH v3 1/4] hwmon: pm_bus: core: Add min_uV in pmbus regulator helper macro Saravanan Sekar
2022-12-29 14:02   ` Guenter Roeck
2022-12-07 17:37 ` [PATCH v3 2/4] dt-bindings: regulator: Add mps,mpq7932 power-management IC Saravanan Sekar
2022-12-07 17:59   ` Krzysztof Kozlowski
2022-12-29 14:08   ` Guenter Roeck
2022-12-07 17:37 ` [PATCH v3 3/4] hwmon: (pmbus/mpq7932) Add a support for mpq7932 Power Management IC Saravanan Sekar
2022-12-29 14:01   ` Guenter Roeck
2022-12-07 17:37 ` [PATCH v3 4/4] MAINTAINERS: Update the entry for MPQ7932 PMIC driver Saravanan Sekar
2022-12-29 14:09   ` 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).