2019-12-22 20:46:42

by saravanan sekar

[permalink] [raw]
Subject: [PATCH v3 0/4] Add regulator support for mpq7920

Changes in V3:
- fixed review comments in Documentation and dt_bindings_check passed

Changes in V2:
- fixed all the review comments in the driver, avoid ternery operator, inline & constant
- fixed/modifed review comments in Documentation

This patch series add support for PMIC regulator driver for Monolithic
Power System's MPQ7920 chipset. MPQ7920 provides support for 4-BUCK converter,
one fixed voltage RTCLDO and 4-LDO regualtor, accessed over I2C.

Saravanan Sekar (4):
dt-bindings: Add an entry for Monolithic Power System, MPS
dt-bindings: regulator: add document bindings for mpq7920
regulator: mpq7920: add mpq7920 regulator driver
MAINTAINERS: Add entry for mpq7920 PMIC driver

.../bindings/regulator/mpq7920.yaml | 143 +++++++
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
MAINTAINERS | 7 +
drivers/regulator/Kconfig | 10 +
drivers/regulator/Makefile | 1 +
drivers/regulator/mpq7920.c | 396 ++++++++++++++++++
drivers/regulator/mpq7920.h | 72 ++++
7 files changed, 631 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/mpq7920.yaml
create mode 100644 drivers/regulator/mpq7920.c
create mode 100644 drivers/regulator/mpq7920.h

--
2.17.1


2019-12-22 20:46:42

by saravanan sekar

[permalink] [raw]
Subject: [PATCH v3 1/4] dt-bindings: Add an entry for Monolithic Power System, MPS

Add an entry for Monolithic Power System, MPS

Signed-off-by: Saravanan Sekar <[email protected]>
---
Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 6046f4555852..5eac9d08bfa8 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -605,6 +605,8 @@ patternProperties:
description: MiraMEMS Sensing Technology Co., Ltd.
"^mitsubishi,.*":
description: Mitsubishi Electric Corporation
+ "^mps,.*":
+ description: Monolithic Power Systems, Inc.
"^mosaixtech,.*":
description: Mosaix Technologies, Inc.
"^motorola,.*":
--
2.17.1

2019-12-22 20:46:46

by saravanan sekar

[permalink] [raw]
Subject: [PATCH v3 3/4] regulator: mpq7920: add mpq7920 regulator driver

Adding regulator driver for the device mpq7920.
The MPQ7920 PMIC device contains four DC-DC buck converters and
five regulators, is designed for automotive and accessed over I2C.

Signed-off-by: Saravanan Sekar <[email protected]>
---
drivers/regulator/Kconfig | 10 +
drivers/regulator/Makefile | 1 +
drivers/regulator/mpq7920.c | 396 ++++++++++++++++++++++++++++++++++++
drivers/regulator/mpq7920.h | 72 +++++++
4 files changed, 479 insertions(+)
create mode 100644 drivers/regulator/mpq7920.c
create mode 100644 drivers/regulator/mpq7920.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 74eb5af7295f..e10adc2e57da 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -600,6 +600,16 @@ config REGULATOR_MCP16502
through the regulator interface. In addition it enables
suspend-to-ram/standby transition.

+config REGULATOR_MPQ7920
+ tristate "Monolithic MPQ7920 PMIC"
+ depends on I2C && OF
+ select REGMAP_I2C
+ help
+ Say y here to support the MPQ7920 PMIC. This will enable supports
+ the software controllable 4 buck and 5 LDO regulators.
+ This driver supports the control of different power rails of device
+ through regulator interface.
+
config REGULATOR_MT6311
tristate "MediaTek MT6311 PMIC"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 2210ba56f9bd..fd11002507e4 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -77,6 +77,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_MCP16502) += mcp16502.o
+obj-$(CONFIG_REGULATOR_MPQ7920) += mpq7920.o
obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o
obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o
obj-$(CONFIG_REGULATOR_MT6358) += mt6358-regulator.o
diff --git a/drivers/regulator/mpq7920.c b/drivers/regulator/mpq7920.c
new file mode 100644
index 000000000000..04ec563661e4
--- /dev/null
+++ b/drivers/regulator/mpq7920.c
@@ -0,0 +1,396 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// mpq7920.c - regulator driver for mps mpq7920
+//
+// Copyright 2019 Monolithic Power Systems, Inc
+//
+// Author: Saravanan Sekar <[email protected]>
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+#include "mpq7920.h"
+
+#define MPQ7920_BUCK_VOLT_RANGE \
+ ((MPQ7920_VOLT_MAX - MPQ7920_BUCK_VOLT_MIN)/MPQ7920_VOLT_STEP + 1)
+#define MPQ7920_LDO_VOLT_RANGE \
+ ((MPQ7920_VOLT_MAX - MPQ7920_LDO_VOLT_MIN)/MPQ7920_VOLT_STEP + 1)
+
+#define MPQ7920BUCK(_name, _id, _ilim) \
+ [MPQ7920_BUCK ## _id] = { \
+ .id = MPQ7920_BUCK ## _id, \
+ .name = _name, \
+ .ops = &mpq7920_buck_ops, \
+ .min_uV = MPQ7920_BUCK_VOLT_MIN, \
+ .uV_step = MPQ7920_VOLT_STEP, \
+ .n_voltages = MPQ7920_BUCK_VOLT_RANGE, \
+ .curr_table = _ilim, \
+ .n_current_limits = ARRAY_SIZE(_ilim), \
+ .csel_reg = MPQ7920_BUCK ##_id## _REG_C, \
+ .csel_mask = MPQ7920_MASK_BUCK_ILIM, \
+ .enable_reg = MPQ7920_REG_REGULATOR_EN, \
+ .enable_mask = BIT(MPQ7920_REGULATOR_EN_OFFSET - \
+ MPQ7920_BUCK ## _id), \
+ .vsel_reg = MPQ7920_BUCK ##_id## _REG_A, \
+ .vsel_mask = MPQ7920_MASK_VREF, \
+ .active_discharge_on = MPQ7920_DISCHARGE_ON, \
+ .active_discharge_reg = MPQ7920_BUCK ##_id## _REG_B, \
+ .active_discharge_mask = MPQ7920_MASK_DISCHARGE, \
+ .soft_start_reg = MPQ7920_BUCK ##_id## _REG_C, \
+ .soft_start_mask = MPQ7920_MASK_SOFTSTART, \
+ .owner = THIS_MODULE, \
+ }
+
+#define MPQ7920LDO(_name, _id, _ops, _ilim, _ilim_sz, _creg, _cmask) \
+ [MPQ7920_LDO ## _id] = { \
+ .id = MPQ7920_LDO ## _id, \
+ .name = _name, \
+ .ops = _ops, \
+ .min_uV = MPQ7920_LDO_VOLT_MIN, \
+ .uV_step = MPQ7920_VOLT_STEP, \
+ .n_voltages = MPQ7920_LDO_VOLT_RANGE, \
+ .vsel_reg = MPQ7920_LDO ##_id## _REG_A, \
+ .vsel_mask = MPQ7920_MASK_VREF, \
+ .curr_table = _ilim, \
+ .n_current_limits = _ilim_sz, \
+ .csel_reg = _creg, \
+ .csel_mask = _cmask, \
+ .enable_reg = (_id == 1) ? 0 : MPQ7920_REG_REGULATOR_EN,\
+ .enable_mask = BIT(MPQ7920_REGULATOR_EN_OFFSET - \
+ MPQ7920_LDO ##_id + 1), \
+ .active_discharge_on = MPQ7920_DISCHARGE_ON, \
+ .active_discharge_mask = MPQ7920_MASK_DISCHARGE, \
+ .active_discharge_reg = MPQ7920_LDO ##_id## _REG_B, \
+ .type = REGULATOR_VOLTAGE, \
+ .owner = THIS_MODULE, \
+ }
+
+enum mpq7920_regulators {
+ MPQ7920_BUCK1,
+ MPQ7920_BUCK2,
+ MPQ7920_BUCK3,
+ MPQ7920_BUCK4,
+ MPQ7920_LDO1, /* LDORTC */
+ MPQ7920_LDO2,
+ MPQ7920_LDO3,
+ MPQ7920_LDO4,
+ MPQ7920_LDO5,
+ MPQ7920_MAX_REGULATORS,
+};
+
+struct mpq7920_regulator_info {
+ struct device *dev;
+ struct regmap *regmap;
+ struct regulator_dev *rdev[MPQ7920_MAX_REGULATORS];
+ struct regulator_desc *rdesc;
+};
+
+static const struct regmap_config mpq7920_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = 0x25,
+};
+
+/* Current limits array (in uA)
+ * ILIM1 & ILIM3
+ */
+static const unsigned int mpq7920_I_limits1[] = {
+ 4600000, 6600000, 7600000, 9300000
+};
+
+/* ILIM2 & ILIM4 */
+static const unsigned int mpq7920_I_limits2[] = {
+ 2700000, 3900000, 5100000, 6100000
+};
+
+/* LDO4 & LDO5 */
+static const unsigned int mpq7920_I_limits3[] = {
+ 300000, 700000
+};
+
+static int mpq7920_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay);
+
+/* RTCLDO not controllable, always ON */
+static const struct regulator_ops mpq7920_ldortc_ops = {
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+};
+
+static const struct regulator_ops mpq7920_ldo_wo_current_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+};
+
+static const struct regulator_ops mpq7920_ldo_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+ .get_current_limit = regulator_get_current_limit_regmap,
+ .set_current_limit = regulator_set_current_limit_regmap,
+};
+
+static const struct regulator_ops mpq7920_buck_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+ .set_soft_start = regulator_set_soft_start_regmap,
+ .set_ramp_delay = mpq7920_set_ramp_delay,
+};
+
+static struct regulator_desc mpq7920_regulators_desc[MPQ7920_MAX_REGULATORS] = {
+ MPQ7920BUCK("buck1", 1, mpq7920_I_limits1),
+ MPQ7920BUCK("buck2", 2, mpq7920_I_limits2),
+ MPQ7920BUCK("buck3", 3, mpq7920_I_limits1),
+ MPQ7920BUCK("buck4", 4, mpq7920_I_limits2),
+ MPQ7920LDO("ldortc", 1, &mpq7920_ldortc_ops, NULL, 0, 0, 0),
+ MPQ7920LDO("ldo2", 2, &mpq7920_ldo_wo_current_ops, NULL, 0, 0, 0),
+ MPQ7920LDO("ldo3", 3, &mpq7920_ldo_wo_current_ops, NULL, 0, 0, 0),
+ MPQ7920LDO("ldo4", 4, &mpq7920_ldo_ops, mpq7920_I_limits3,
+ ARRAY_SIZE(mpq7920_I_limits3), MPQ7920_LDO4_REG_B,
+ MPQ7920_MASK_LDO_ILIM),
+ MPQ7920LDO("ldo5", 5, &mpq7920_ldo_ops, mpq7920_I_limits3,
+ ARRAY_SIZE(mpq7920_I_limits3), MPQ7920_LDO5_REG_B,
+ MPQ7920_MASK_LDO_ILIM),
+};
+
+/*
+ * DVS ramp rate BUCK1 to BUCK4
+ * 00-01: Reserved
+ * 10: 8mV/us
+ * 11: 4mV/us
+ */
+static int mpq7920_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
+{
+ unsigned int ramp_val;
+
+ if (ramp_delay > 8000 || ramp_delay < 0)
+ return -EINVAL;
+
+ if (ramp_delay <= 4000)
+ ramp_val = 3;
+ else
+ ramp_val = 2;
+
+ return regmap_update_bits(rdev->regmap, MPQ7920_REG_CTL0,
+ MPQ7920_MASK_DVS_SLEWRATE, ramp_val << 6);
+}
+
+static void mpq7920_parse_dt(struct device *dev,
+ struct mpq7920_regulator_info *info)
+{
+ int ret, i;
+ struct device_node *np = dev->of_node;
+ uint8_t freq;
+ uint8_t time_slot;
+ uint8_t val[MPQ7920_BUCK4 + 1];
+ uint8_t var_time[MPQ7920_LDO5];
+ bool is_fixed_on_time = 0;
+ bool is_fixed_off_time = 0;
+
+ is_fixed_on_time = of_property_read_bool(np, "mps,fixed-on-time");
+ is_fixed_off_time = of_property_read_bool(np, "mps,fixed-off-time");
+ if (is_fixed_on_time || is_fixed_off_time) {
+ regmap_update_bits(info->regmap, MPQ7920_REG_CTL2,
+ MPQ7920_MASK_FIXED_TIME_SLOT,
+ ~(is_fixed_on_time << 1 | is_fixed_off_time));
+ }
+
+ ret = of_property_read_u8(np, "mps,time-slot", &time_slot);
+ if (!ret) {
+ regmap_update_bits(info->regmap, MPQ7920_REG_CTL2,
+ MPQ7920_MASK_TIME_SLOT,
+ (time_slot & 3) << 2);
+ }
+
+ if (!is_fixed_on_time &&
+ !of_property_read_u8_array(np, "mps,inc-on-time", var_time,
+ ARRAY_SIZE(var_time))) {
+
+ for (i = 0; i < MPQ7920_LDO5; i++) {
+ if (i <= MPQ7920_BUCK4) {
+ regmap_update_bits(info->regmap,
+ MPQ7920_BUCK1_REG_D + (i * 4),
+ MPQ7920_MASK_ON_TIME_SLOT,
+ var_time[i] & 0xF);
+ } else {
+ regmap_update_bits(info->regmap,
+ (MPQ7920_LDO2_REG_C +
+ ((i - MPQ7920_LDO1) * 3)),
+ MPQ7920_MASK_ON_TIME_SLOT,
+ var_time[i] & 0xF);
+ }
+ }
+ }
+
+ if (!is_fixed_off_time &&
+ !of_property_read_u8_array(np, "mps,inc-off-time", var_time,
+ ARRAY_SIZE(var_time))) {
+
+ for (i = 0; i < MPQ7920_LDO5; i++) {
+ if (i <= MPQ7920_BUCK4) {
+ regmap_update_bits(info->regmap,
+ MPQ7920_BUCK1_REG_D + (i * 4),
+ MPQ7920_MASK_OFF_TIME_SLOT,
+ (var_time[i] & 0xF) << 4);
+ } else {
+ regmap_update_bits(info->regmap,
+ (MPQ7920_LDO2_REG_C +
+ ((i - MPQ7920_LDO1) * 3)),
+ MPQ7920_MASK_OFF_TIME_SLOT,
+ (var_time[i] & 0xF) << 4);
+ }
+ }
+ }
+
+ ret = of_property_read_u8_array(np, "mps,buck-softstart", val,
+ ARRAY_SIZE(val));
+ if (!ret) {
+ for (i = 0; i < ARRAY_SIZE(val); i++)
+ info->rdesc[i].soft_start_val_on = (val[i] & 3) << 2;
+ }
+
+ ret = of_property_read_u8_array(np, "mps,buck-ovp", val,
+ ARRAY_SIZE(val));
+ if (!ret) {
+ for (i = 0; i <= MPQ7920_BUCK4; i++) {
+ regmap_update_bits(info->regmap,
+ MPQ7920_BUCK1_REG_B + (i * 4),
+ BIT(6), val[i] << 6);
+ }
+ }
+
+ ret = of_property_read_u8_array(np, "mps,buck-phase-delay", val,
+ ARRAY_SIZE(val));
+ if (!ret) {
+ for (i = 0; i <= MPQ7920_BUCK4; i++) {
+ regmap_update_bits(info->regmap,
+ MPQ7920_BUCK1_REG_C + (i * 4),
+ MPQ7920_MASK_BUCK_PHASE_DEALY,
+ (val[i] & 3) << 4);
+ }
+ }
+
+ ret = of_property_read_u8(np, "mps,switch-freq", &freq);
+ if (!ret) {
+ regmap_update_bits(info->regmap, MPQ7920_REG_CTL0,
+ MPQ7920_MASK_SWITCH_FREQ,
+ (freq & 3) << 4);
+ }
+}
+
+static inline int mpq7920_regulator_register(
+ struct mpq7920_regulator_info *info,
+ struct regulator_config *config)
+{
+ int i;
+ struct regulator_desc *rdesc;
+ struct regulator_ops *ops;
+
+ for (i = 0; i < MPQ7920_MAX_REGULATORS; i++) {
+ rdesc = &info->rdesc[i];
+ ops = rdesc->ops;
+ if (rdesc->curr_table) {
+ ops->get_current_limit =
+ regulator_get_current_limit_regmap;
+ ops->set_current_limit =
+ regulator_set_current_limit_regmap;
+ }
+
+ info->rdev[i] = devm_regulator_register(info->dev, rdesc,
+ config);
+ if (IS_ERR(info->rdev))
+ return PTR_ERR(info->rdev);
+ }
+
+ return 0;
+}
+
+static int mpq7920_i2c_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct device *dev = &client->dev;
+ struct mpq7920_regulator_info *info;
+ struct regulator_config config = { 0 };
+ struct regmap *regmap;
+ int ret;
+
+ info = devm_kzalloc(dev, sizeof(struct mpq7920_regulator_info),
+ GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ info->dev = dev;
+ info->rdesc = mpq7920_regulators_desc;
+ regmap = devm_regmap_init_i2c(client, &mpq7920_regmap_config);
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "Failed to allocate regmap!\n");
+ return PTR_ERR(regmap);
+ }
+
+ i2c_set_clientdata(client, info);
+ info->regmap = regmap;
+ if (client->dev.of_node)
+ mpq7920_parse_dt(&client->dev, info);
+
+ config.dev = info->dev;
+ config.regmap = regmap;
+ config.driver_data = info;
+
+ ret = mpq7920_regulator_register(info, &config);
+ if (ret < 0)
+ dev_err(dev, "Failed to register regulator!\n");
+
+ return ret;
+}
+
+static const struct of_device_id mpq7920_of_match[] = {
+ { .compatible = "mps,mpq7920"},
+ {},
+};
+MODULE_DEVICE_TABLE(of, mpq7920_of_match);
+
+static const struct i2c_device_id mpq7920_id[] = {
+ { "mpq7920", },
+ { },
+};
+MODULE_DEVICE_TABLE(i2c, mpq7920_id);
+
+static struct i2c_driver mpq7920_regulator_driver = {
+ .driver = {
+ .name = "mpq7920",
+ .of_match_table = of_match_ptr(mpq7920_of_match),
+ },
+ .probe = mpq7920_i2c_probe,
+ .id_table = mpq7920_id,
+};
+module_i2c_driver(mpq7920_regulator_driver);
+
+MODULE_AUTHOR("Saravanan Sekar <[email protected]>");
+MODULE_DESCRIPTION("MPQ7920 PMIC regulator driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/mpq7920.h b/drivers/regulator/mpq7920.h
new file mode 100644
index 000000000000..58c64e708f2e
--- /dev/null
+++ b/drivers/regulator/mpq7920.h
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * mpq7920.h - Regulator definitions for mpq7920
+ *
+ * Copyright 2019 Monolithic Power Systems, Inc
+ *
+ */
+
+#ifndef __MPQ7920_H__
+#define __MPQ7920_H__
+
+#define MPQ7920_REG_CTL0 0x00
+#define MPQ7920_REG_CTL1 0x01
+#define MPQ7920_REG_CTL2 0x02
+#define MPQ7920_BUCK1_REG_A 0x03
+#define MPQ7920_BUCK1_REG_B 0x04
+#define MPQ7920_BUCK1_REG_C 0x05
+#define MPQ7920_BUCK1_REG_D 0x06
+#define MPQ7920_BUCK2_REG_A 0x07
+#define MPQ7920_BUCK2_REG_B 0x08
+#define MPQ7920_BUCK2_REG_C 0x09
+#define MPQ7920_BUCK2_REG_D 0x0a
+#define MPQ7920_BUCK3_REG_A 0x0b
+#define MPQ7920_BUCK3_REG_B 0x0c
+#define MPQ7920_BUCK3_REG_C 0x0d
+#define MPQ7920_BUCK3_REG_D 0x0e
+#define MPQ7920_BUCK4_REG_A 0x0f
+#define MPQ7920_BUCK4_REG_B 0x10
+#define MPQ7920_BUCK4_REG_C 0x11
+#define MPQ7920_BUCK4_REG_D 0x12
+#define MPQ7920_LDO1_REG_A 0x13
+#define MPQ7920_LDO1_REG_B 0x0
+#define MPQ7920_LDO2_REG_A 0x14
+#define MPQ7920_LDO2_REG_B 0x15
+#define MPQ7920_LDO2_REG_C 0x16
+#define MPQ7920_LDO3_REG_A 0x17
+#define MPQ7920_LDO3_REG_B 0x18
+#define MPQ7920_LDO3_REG_C 0x19
+#define MPQ7920_LDO4_REG_A 0x1a
+#define MPQ7920_LDO4_REG_B 0x1b
+#define MPQ7920_LDO4_REG_C 0x1c
+#define MPQ7920_LDO5_REG_A 0x1d
+#define MPQ7920_LDO5_REG_B 0x1e
+#define MPQ7920_LDO5_REG_C 0x1f
+#define MPQ7920_REG_MODE 0x20
+#define MPQ7920_REG_REGULATOR_EN1 0x22
+#define MPQ7920_REG_REGULATOR_EN 0x22
+
+#define MPQ7920_MASK_VREF 0x7f
+#define MPQ7920_MASK_BUCK_ILIM 0xd0
+#define MPQ7920_MASK_LDO_ILIM BIT(6)
+#define MPQ7920_MASK_DISCHARGE BIT(5)
+#define MPQ7920_MASK_MODE 0xc0
+#define MPQ7920_MASK_SOFTSTART 0x0c
+#define MPQ7920_MASK_SWITCH_FREQ 0x30
+#define MPQ7920_MASK_BUCK_PHASE_DEALY 0x30
+#define MPQ7920_MASK_DVS_SLEWRATE 0xc0
+#define MPQ7920_MASK_TIME_SLOT 0x06
+#define MPQ7920_MASK_FIXED_TIME_SLOT 0x03
+#define MPQ7920_MASK_ON_TIME_SLOT 0x0F
+#define MPQ7920_MASK_OFF_TIME_SLOT 0xF0
+#define MPQ7920_DISCHARGE_ON 0x1
+
+#define MPQ7920_REGULATOR_EN_OFFSET 7
+
+/* values in mV */
+#define MPQ7920_BUCK_VOLT_MIN 400000
+#define MPQ7920_LDO_VOLT_MIN 650000
+#define MPQ7920_VOLT_MAX 3587500
+#define MPQ7920_VOLT_STEP 12500
+
+#endif /* __MPQ7920_H__ */
--
2.17.1

2019-12-22 20:48:05

by saravanan sekar

[permalink] [raw]
Subject: [PATCH v3 4/4] MAINTAINERS: Add entry for mpq7920 PMIC driver

Add MAINTAINERS entry for Monolithic Power Systems mpq7920 PMIC driver.

Signed-off-by: Saravanan Sekar <[email protected]>
---
MAINTAINERS | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0fd82e674cf4..8a31285b59c6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11128,6 +11128,13 @@ S: Maintained
F: Documentation/driver-api/serial/moxa-smartio.rst
F: drivers/tty/mxser.*

+MONOLITHIC POWER SYSTEM PMIC DRIVER
+M: Saravanan Sekar <[email protected]>
+S: Maintained
+F: Documentation/devicetree/bindings/regulator/mpq7920.yaml
+F: drivers/regulator/mpq7920.c
+F: drivers/regulator/mpq7920.h
+
MR800 AVERMEDIA USB FM RADIO DRIVER
M: Alexey Klimov <[email protected]>
L: [email protected]
--
2.17.1

2019-12-22 20:48:23

by saravanan sekar

[permalink] [raw]
Subject: [PATCH v3 2/4] dt-bindings: regulator: add document bindings for mpq7920

Add device tree binding information for mpq7920 regulator driver.
Example bindings for mpq7920 are added.

Signed-off-by: Saravanan Sekar <[email protected]>
---
.../bindings/regulator/mpq7920.yaml | 143 ++++++++++++++++++
1 file changed, 143 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/mpq7920.yaml

diff --git a/Documentation/devicetree/bindings/regulator/mpq7920.yaml b/Documentation/devicetree/bindings/regulator/mpq7920.yaml
new file mode 100644
index 000000000000..d173ba1fb28d
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/mpq7920.yaml
@@ -0,0 +1,143 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/mpq7920.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Monolithic Power System MPQ7920 PMIC
+
+maintainers:
+ - Saravanan Sekar <[email protected]>
+
+properties:
+ $nodename:
+ pattern: "pmic@[0-9a-f]{1,2}"
+ compatible:
+ enum:
+ - mps,mpq7920
+
+ reg:
+ maxItems: 1
+
+ mps,time-slot:
+ description:
+ each regulator output shall be delayed during power on/off sequence which
+ based on configurable time slot value, must be one of following corresponding
+ value 0.5ms, 2ms, 8ms, 16ms
+ allOf:
+ - $ref: "/schemas/types.yaml#/definitions/uint8"
+ - enum: [ 0, 1, 2, 3 ]
+ - default: 0
+
+ mps,fixed-on-time:
+ description:
+ select power on sequence with fixed time output delay mentioned in
+ time-slot reg for all the regulators.
+ type: boolean
+
+ mps,fixed-off-time:
+ description:
+ select power off sequence with fixed time output delay mentioned in
+ time-slot reg for all the regulators.
+ type: boolean
+
+ mps,inc-off-time:
+ description: |
+ mutually exclusive to mps,fixed-off-time an array of 8, linearly increase
+ output delay during power off sequence based on factor of time slot/interval
+ for each regulator.
+ allOf:
+ - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+ - minimum: 0
+ - maximum: 15
+ - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
+
+ mps,inc-on-time:
+ description: |
+ mutually exclusive to mps,fixed-on-time an array of 8, linearly increase
+ output delay during power on sequence based on factor of time slot/interval
+ for each regulator.
+ allOf:
+ - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+ - minimum: 0
+ - maximum: 15
+ - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
+
+ mps,switch-freq:
+ description: |
+ switching frequency must be one of following corresponding value
+ 1.1MHz, 1.65MHz, 2.2MHz, 2.75MHz
+ allOf:
+ - $ref: "/schemas/types.yaml#/definitions/uint8"
+ - enum: [ 0, 1, 2, 3 ]
+ - default: 2
+
+ mps,buck-softstart:
+ description: |
+ An array of 4 contains soft start time of each buck, must be one of
+ following corresponding values 150us, 300us, 610us, 920us
+ allOf:
+ - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+ - enum: [ 0, 1, 2, 3 ]
+ - default: [ 1, 1, 1, 1 ]
+
+ mps,buck-ovp:
+ description: |
+ An array of 4 contains over voltage protection of each buck, must be
+ one of above values
+ allOf:
+ - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+ - enum: [ 0, 1 ]
+ - default: [ 1, 1, 1, 1 ]
+
+ mps,buck-phase-delay:
+ description: |
+ An array of 4 contains phase delay of each buck must be one of above values
+ corresponding to 0deg, 90deg, 180deg, 270deg
+ allOf:
+ - $ref: "/schemas/types.yaml#/definitions/uint8-array"
+ - enum: [ 0, 1, 2, 3 ]
+ - default: [ 0, 0, 1, 1 ]
+
+ regulators:
+ type: object
+ description:
+ list of regulators provided by this controller, must be named
+ after their hardware counterparts BUCK[1-4], one LDORTC, and LDO[2-5]
+ The valid names for regulators are
+ buck1, buck2, buck3, buck4, ldortc, ldo2, ldo3, ldo4, ldo5
+
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ mpq7920@69 {
+ compatible = "mps,mpq7920";
+ reg = <0x69>;
+
+ mps,switch-freq = <1>;
+ mps,buck-softstart = /bits/ 8 <1 2 1 3>;
+ mps,buck-ovp = /bits/ 8 <1 0 1 1>;
+
+ regulators {
+ buck1 {
+ regulator-name = "buck1";
+ regulator-min-microvolt = <400000>;
+ regulator-max-microvolt = <3587500>;
+ regulator-min-microamp = <460000>;
+ regulator-max-microamp = <7600000>;
+ regulator-boot-on;
+ };
+
+ ldo2 {
+ regulator-name = "ldo2";
+ regulator-min-microvolt = <650000>;
+ regulator-max-microvolt = <3587500>;
+ };
+ };
+ };
+ };
+...
--
2.17.1

2019-12-23 10:50:07

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH v3 2/4] dt-bindings: regulator: add document bindings for mpq7920

On Sun, Dec 22, 2019 at 09:45:05PM +0100, Saravanan Sekar wrote:
> Add device tree binding information for mpq7920 regulator driver.
> Example bindings for mpq7920 are added.
>
> Signed-off-by: Saravanan Sekar <[email protected]>
> ---
> .../bindings/regulator/mpq7920.yaml | 143 ++++++++++++++++++
> 1 file changed, 143 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/regulator/mpq7920.yaml
>
> diff --git a/Documentation/devicetree/bindings/regulator/mpq7920.yaml b/Documentation/devicetree/bindings/regulator/mpq7920.yaml
> new file mode 100644
> index 000000000000..d173ba1fb28d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/mpq7920.yaml
> @@ -0,0 +1,143 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/mpq7920.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Monolithic Power System MPQ7920 PMIC
> +
> +maintainers:
> + - Saravanan Sekar <[email protected]>
> +
> +properties:
> + $nodename:
> + pattern: "pmic@[0-9a-f]{1,2}"
> + compatible:
> + enum:
> + - mps,mpq7920
> +
> + reg:
> + maxItems: 1
> +
> + mps,time-slot:
> + description:
> + each regulator output shall be delayed during power on/off sequence which
> + based on configurable time slot value, must be one of following corresponding
> + value 0.5ms, 2ms, 8ms, 16ms
> + allOf:
> + - $ref: "/schemas/types.yaml#/definitions/uint8"
> + - enum: [ 0, 1, 2, 3 ]
> + - default: 0
> +
> + mps,fixed-on-time:
> + description:
> + select power on sequence with fixed time output delay mentioned in
> + time-slot reg for all the regulators.
> + type: boolean
> +
> + mps,fixed-off-time:
> + description:
> + select power off sequence with fixed time output delay mentioned in
> + time-slot reg for all the regulators.
> + type: boolean

I'm not sure what this fixed-on-time and fixed-off-time property is
supposed to be doing. Why not just get rid of the time slot property,
and set the power on / power off time in fixed-on-time /
fixed-off-time property?

> + mps,inc-off-time:
> + description: |
> + mutually exclusive to mps,fixed-off-time an array of 8, linearly increase
> + output delay during power off sequence based on factor of time slot/interval
> + for each regulator.
> + allOf:
> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
> + - minimum: 0
> + - maximum: 15
> + - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]

You should check the size of the array too, but if it's a property of
the regulators, why not have it in the regulators node?

> + mps,inc-on-time:
> + description: |
> + mutually exclusive to mps,fixed-on-time an array of 8, linearly increase
> + output delay during power on sequence based on factor of time slot/interval
> + for each regulator.
> + allOf:
> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
> + - minimum: 0
> + - maximum: 15
> + - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
> +
> + mps,switch-freq:
> + description: |
> + switching frequency must be one of following corresponding value
> + 1.1MHz, 1.65MHz, 2.2MHz, 2.75MHz
> + allOf:
> + - $ref: "/schemas/types.yaml#/definitions/uint8"
> + - enum: [ 0, 1, 2, 3 ]
> + - default: 2
> +
> + mps,buck-softstart:
> + description: |
> + An array of 4 contains soft start time of each buck, must be one of
> + following corresponding values 150us, 300us, 610us, 920us
> + allOf:
> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
> + - enum: [ 0, 1, 2, 3 ]
> + - default: [ 1, 1, 1, 1 ]
> +
> + mps,buck-ovp:
> + description: |
> + An array of 4 contains over voltage protection of each buck, must be
> + one of above values
> + allOf:
> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
> + - enum: [ 0, 1 ]
> + - default: [ 1, 1, 1, 1 ]
> +
> + mps,buck-phase-delay:
> + description: |
> + An array of 4 contains phase delay of each buck must be one of above values
> + corresponding to 0deg, 90deg, 180deg, 270deg
> + allOf:
> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
> + - enum: [ 0, 1, 2, 3 ]
> + - default: [ 0, 0, 1, 1 ]
> +
> + regulators:
> + type: object
> + description:
> + list of regulators provided by this controller, must be named
> + after their hardware counterparts BUCK[1-4], one LDORTC, and LDO[2-5]
> + The valid names for regulators are
> + buck1, buck2, buck3, buck4, ldortc, ldo2, ldo3, ldo4, ldo5

For the third times now, the names should be validated using
propertyNames.

Maxime
>


Attachments:
(No filename) (4.87 kB)
signature.asc (235.00 B)
Download all attachments

2019-12-25 22:01:32

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] regulator: mpq7920: add mpq7920 regulator driver

Hi Saravanan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on regulator/for-next]
[also build test WARNING on robh/for-next linus/master v5.5-rc3 next-20191220]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Saravanan-Sekar/Add-regulator-support-for-mpq7920/20191225-005026
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-129-g341daf20-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email protected]>


sparse warnings: (new ones prefixed by >>)

>> drivers/regulator/mpq7920.c:339:44: sparse: sparse: Using plain integer as NULL pointer
>> drivers/regulator/mpq7920.c:317:21: sparse: sparse: incorrect type in assignment (different modifiers)
>> drivers/regulator/mpq7920.c:317:21: sparse: expected struct regulator_ops *ops
>> drivers/regulator/mpq7920.c:317:21: sparse: got struct regulator_ops const *ops

vim +339 drivers/regulator/mpq7920.c

306
307 static inline int mpq7920_regulator_register(
308 struct mpq7920_regulator_info *info,
309 struct regulator_config *config)
310 {
311 int i;
312 struct regulator_desc *rdesc;
313 struct regulator_ops *ops;
314
315 for (i = 0; i < MPQ7920_MAX_REGULATORS; i++) {
316 rdesc = &info->rdesc[i];
> 317 ops = rdesc->ops;
318 if (rdesc->curr_table) {
319 ops->get_current_limit =
320 regulator_get_current_limit_regmap;
321 ops->set_current_limit =
322 regulator_set_current_limit_regmap;
323 }
324
325 info->rdev[i] = devm_regulator_register(info->dev, rdesc,
326 config);
327 if (IS_ERR(info->rdev))
328 return PTR_ERR(info->rdev);
329 }
330
331 return 0;
332 }
333
334 static int mpq7920_i2c_probe(struct i2c_client *client,
335 const struct i2c_device_id *id)
336 {
337 struct device *dev = &client->dev;
338 struct mpq7920_regulator_info *info;
> 339 struct regulator_config config = { 0 };
340 struct regmap *regmap;
341 int ret;
342
343 info = devm_kzalloc(dev, sizeof(struct mpq7920_regulator_info),
344 GFP_KERNEL);
345 if (!info)
346 return -ENOMEM;
347
348 info->dev = dev;
349 info->rdesc = mpq7920_regulators_desc;
350 regmap = devm_regmap_init_i2c(client, &mpq7920_regmap_config);
351 if (IS_ERR(regmap)) {
352 dev_err(dev, "Failed to allocate regmap!\n");
353 return PTR_ERR(regmap);
354 }
355
356 i2c_set_clientdata(client, info);
357 info->regmap = regmap;
358 if (client->dev.of_node)
359 mpq7920_parse_dt(&client->dev, info);
360
361 config.dev = info->dev;
362 config.regmap = regmap;
363 config.driver_data = info;
364
365 ret = mpq7920_regulator_register(info, &config);
366 if (ret < 0)
367 dev_err(dev, "Failed to register regulator!\n");
368
369 return ret;
370 }
371

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation

2019-12-26 22:25:43

by saravanan sekar

[permalink] [raw]
Subject: Re: [PATCH v3 2/4] dt-bindings: regulator: add document bindings for mpq7920

On 23/12/19 11:50 am, Maxime Ripard wrote:

> On Sun, Dec 22, 2019 at 09:45:05PM +0100, Saravanan Sekar wrote:
>> Add device tree binding information for mpq7920 regulator driver.
>> Example bindings for mpq7920 are added.
>>
>> Signed-off-by: Saravanan Sekar <[email protected]>
>> ---
>> .../bindings/regulator/mpq7920.yaml | 143 ++++++++++++++++++
>> 1 file changed, 143 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/regulator/mpq7920.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/regulator/mpq7920.yaml b/Documentation/devicetree/bindings/regulator/mpq7920.yaml
>> new file mode 100644
>> index 000000000000..d173ba1fb28d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/regulator/mpq7920.yaml
>> @@ -0,0 +1,143 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/regulator/mpq7920.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Monolithic Power System MPQ7920 PMIC
>> +
>> +maintainers:
>> + - Saravanan Sekar <[email protected]>
>> +
>> +properties:
>> + $nodename:
>> + pattern: "pmic@[0-9a-f]{1,2}"
>> + compatible:
>> + enum:
>> + - mps,mpq7920
>> +
>> + reg:
>> + maxItems: 1
>> +
>> + mps,time-slot:
>> + description:
>> + each regulator output shall be delayed during power on/off sequence which
>> + based on configurable time slot value, must be one of following corresponding
>> + value 0.5ms, 2ms, 8ms, 16ms
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8"
>> + - enum: [ 0, 1, 2, 3 ]
>> + - default: 0
>> +
>> + mps,fixed-on-time:
>> + description:
>> + select power on sequence with fixed time output delay mentioned in
>> + time-slot reg for all the regulators.
>> + type: boolean
>> +
>> + mps,fixed-off-time:
>> + description:
>> + select power off sequence with fixed time output delay mentioned in
>> + time-slot reg for all the regulators.
>> + type: boolean
> I'm not sure what this fixed-on-time and fixed-off-time property is

the time slot register holds the time interval of Vout when enable the
each regulator.
fixed-on-time property is to specify each regulator shares same time
interval mention in time slot register.
variable on-time defines the factor or multiples of value in time slot
register.


> supposed to be doing. Why not just get rid of the time slot property,
> and set the power on / power off time in fixed-on-time /
> fixed-off-time property?

1. if fixed-on-time is needed with default time slot register settings,
then time slot property is not needed
2. if variable time is needed with modified time slot, then both
variable time factor & time slot property is needed,
Hope above explanations answers the necessary of all the above property

>
>> + mps,inc-off-time:
>> + description: |
>> + mutually exclusive to mps,fixed-off-time an array of 8, linearly increase
>> + output delay during power off sequence based on factor of time slot/interval
>> + for each regulator.
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - minimum: 0
>> + - maximum: 15
>> + - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
> You should check the size of the array too, but if it's a property of
> the regulators, why not have it in the regulators node?

the node regulators & sub-node of regulators are parsed (initdata) by
regulator framework during regulator registration,
so it would be redundant parsing all the node if mentioned under each
regulator node and this is optional. If you still not
convinced I will change.

>> + mps,inc-on-time:
>> + description: |
>> + mutually exclusive to mps,fixed-on-time an array of 8, linearly increase
>> + output delay during power on sequence based on factor of time slot/interval
>> + for each regulator.
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - minimum: 0
>> + - maximum: 15
>> + - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
>> +
>> + mps,switch-freq:
>> + description: |
>> + switching frequency must be one of following corresponding value
>> + 1.1MHz, 1.65MHz, 2.2MHz, 2.75MHz
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8"
>> + - enum: [ 0, 1, 2, 3 ]
>> + - default: 2
>> +
>> + mps,buck-softstart:
>> + description: |
>> + An array of 4 contains soft start time of each buck, must be one of
>> + following corresponding values 150us, 300us, 610us, 920us
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - enum: [ 0, 1, 2, 3 ]
>> + - default: [ 1, 1, 1, 1 ]
>> +
>> + mps,buck-ovp:
>> + description: |
>> + An array of 4 contains over voltage protection of each buck, must be
>> + one of above values
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - enum: [ 0, 1 ]
>> + - default: [ 1, 1, 1, 1 ]
>> +
>> + mps,buck-phase-delay:
>> + description: |
>> + An array of 4 contains phase delay of each buck must be one of above values
>> + corresponding to 0deg, 90deg, 180deg, 270deg
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - enum: [ 0, 1, 2, 3 ]
>> + - default: [ 0, 0, 1, 1 ]
>> +
>> + regulators:
>> + type: object
>> + description:
>> + list of regulators provided by this controller, must be named
>> + after their hardware counterparts BUCK[1-4], one LDORTC, and LDO[2-5]
>> + The valid names for regulators are
>> + buck1, buck2, buck3, buck4, ldortc, ldo2, ldo3, ldo4, ldo5
> For the third times now, the names should be validated using
> propertyNames.

Not sure did I understand your question correctly.
all the node name under regulators node are parsed by regulator
framework & validated against
name in regulator descriptors.

>
> Maxime


Thanks,

Saravanan

On 23/12/19 11:50 am, Maxime Ripard wrote:
> On Sun, Dec 22, 2019 at 09:45:05PM +0100, Saravanan Sekar wrote:
>> Add device tree binding information for mpq7920 regulator driver.
>> Example bindings for mpq7920 are added.
>>
>> Signed-off-by: Saravanan Sekar <[email protected]>
>> ---
>> .../bindings/regulator/mpq7920.yaml | 143 ++++++++++++++++++
>> 1 file changed, 143 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/regulator/mpq7920.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/regulator/mpq7920.yaml b/Documentation/devicetree/bindings/regulator/mpq7920.yaml
>> new file mode 100644
>> index 000000000000..d173ba1fb28d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/regulator/mpq7920.yaml
>> @@ -0,0 +1,143 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/regulator/mpq7920.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Monolithic Power System MPQ7920 PMIC
>> +
>> +maintainers:
>> + - Saravanan Sekar <[email protected]>
>> +
>> +properties:
>> + $nodename:
>> + pattern: "pmic@[0-9a-f]{1,2}"
>> + compatible:
>> + enum:
>> + - mps,mpq7920
>> +
>> + reg:
>> + maxItems: 1
>> +
>> + mps,time-slot:
>> + description:
>> + each regulator output shall be delayed during power on/off sequence which
>> + based on configurable time slot value, must be one of following corresponding
>> + value 0.5ms, 2ms, 8ms, 16ms
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8"
>> + - enum: [ 0, 1, 2, 3 ]
>> + - default: 0
>> +
>> + mps,fixed-on-time:
>> + description:
>> + select power on sequence with fixed time output delay mentioned in
>> + time-slot reg for all the regulators.
>> + type: boolean
>> +
>> + mps,fixed-off-time:
>> + description:
>> + select power off sequence with fixed time output delay mentioned in
>> + time-slot reg for all the regulators.
>> + type: boolean
> I'm not sure what this fixed-on-time and fixed-off-time property is
> supposed to be doing. Why not just get rid of the time slot property,
> and set the power on / power off time in fixed-on-time /
> fixed-off-time property?
>
>> + mps,inc-off-time:
>> + description: |
>> + mutually exclusive to mps,fixed-off-time an array of 8, linearly increase
>> + output delay during power off sequence based on factor of time slot/interval
>> + for each regulator.
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - minimum: 0
>> + - maximum: 15
>> + - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
> You should check the size of the array too, but if it's a property of
> the regulators, why not have it in the regulators node?
>
>> + mps,inc-on-time:
>> + description: |
>> + mutually exclusive to mps,fixed-on-time an array of 8, linearly increase
>> + output delay during power on sequence based on factor of time slot/interval
>> + for each regulator.
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - minimum: 0
>> + - maximum: 15
>> + - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
>> +
>> + mps,switch-freq:
>> + description: |
>> + switching frequency must be one of following corresponding value
>> + 1.1MHz, 1.65MHz, 2.2MHz, 2.75MHz
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8"
>> + - enum: [ 0, 1, 2, 3 ]
>> + - default: 2
>> +
>> + mps,buck-softstart:
>> + description: |
>> + An array of 4 contains soft start time of each buck, must be one of
>> + following corresponding values 150us, 300us, 610us, 920us
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - enum: [ 0, 1, 2, 3 ]
>> + - default: [ 1, 1, 1, 1 ]
>> +
>> + mps,buck-ovp:
>> + description: |
>> + An array of 4 contains over voltage protection of each buck, must be
>> + one of above values
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - enum: [ 0, 1 ]
>> + - default: [ 1, 1, 1, 1 ]
>> +
>> + mps,buck-phase-delay:
>> + description: |
>> + An array of 4 contains phase delay of each buck must be one of above values
>> + corresponding to 0deg, 90deg, 180deg, 270deg
>> + allOf:
>> + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
>> + - enum: [ 0, 1, 2, 3 ]
>> + - default: [ 0, 0, 1, 1 ]
>> +
>> + regulators:
>> + type: object
>> + description:
>> + list of regulators provided by this controller, must be named
>> + after their hardware counterparts BUCK[1-4], one LDORTC, and LDO[2-5]
>> + The valid names for regulators are
>> + buck1, buck2, buck3, buck4, ldortc, ldo2, ldo3, ldo4, ldo5
> For the third times now, the names should be validated using
> propertyNames.
>
> Maxime

2019-12-27 00:21:27

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v3 2/4] dt-bindings: regulator: add document bindings for mpq7920

On Thu, Dec 26, 2019 at 11:23:36PM +0100, saravanan sekar wrote:
> On 23/12/19 11:50 am, Maxime Ripard wrote:
> > On Sun, Dec 22, 2019 at 09:45:05PM +0100, Saravanan Sekar wrote:

> > > + mps,fixed-off-time:
> > > + description:
> > > + select power off sequence with fixed time output delay mentioned in
> > > + time-slot reg for all the regulators.
> > > + type: boolean

> > I'm not sure what this fixed-on-time and fixed-off-time property is

> the time slot register holds the time interval of Vout when enable the
> each regulator.
> fixed-on-time property is to specify each regulator shares same time
> interval mention in time slot register.
> variable on-time defines the factor or multiples of value in time slot
> register.

This really isn't very clear from the bindings document. You
need an explanation like the above in there.

> > supposed to be doing. Why not just get rid of the time slot property,
> > and set the power on / power off time in fixed-on-time /
> > fixed-off-time property?

> 1. if fixed-on-time is needed with default time slot register settings,
> then time slot property is not needed
> 2. if variable time is needed with modified time slot, then both
> variable time factor & time slot property is needed,
> Hope above explanations answers the necessary of all the above property

Same here, though I'm still a bit unclear about what "needed with
modified time slot" means.

> > > + regulators:
> > > + type: object
> > > + description:
> > > + list of regulators provided by this controller, must be named
> > > + after their hardware counterparts BUCK[1-4], one LDORTC, and LDO[2-5]
> > > + The valid names for regulators are
> > > + buck1, buck2, buck3, buck4, ldortc, ldo2, ldo3, ldo4, ldo5

> > For the third times now, the names should be validated using
> > propertyNames.

> Not sure did I understand your question correctly.
> all the node name under regulators node are parsed by regulator
> framework & validated against
> name in regulator descriptors.

That validates at kernel runtime but doesn't let bindings
validation at the time the DTS is built verify things, Maxime is
asking you to spell things out in the DT binding document so the
DT can be validated independently of the kernel.


Attachments:
(No filename) (2.29 kB)
signature.asc (499.00 B)
Download all attachments

2019-12-31 08:02:39

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH v3 2/4] dt-bindings: regulator: add document bindings for mpq7920

On Thu, Dec 26, 2019 at 11:23:36PM +0100, saravanan sekar wrote:
> > > + mps,inc-off-time:
> > > + description: |
> > > + mutually exclusive to mps,fixed-off-time an array of 8, linearly increase
> > > + output delay during power off sequence based on factor of time slot/interval
> > > + for each regulator.
> > > + allOf:
> > > + - $ref: "/schemas/types.yaml#/definitions/uint8-array"
> > > + - minimum: 0
> > > + - maximum: 15
> > > + - default: [ 0, 6, 0, 6, 7, 7, 7, 9 ]
> > You should check the size of the array too, but if it's a property of
> > the regulators, why not have it in the regulators node?
>
> the node regulators & sub-node of regulators are parsed (initdata) by
> regulator framework during regulator registration,
> so it would be redundant parsing all the node if mentioned under each
> regulator node and this is optional. If you still not
> convinced I will change.

It's not really redundant, since the regulator framework will ignore
whatever custom property you would put there, and your driver would
ignore any generic property in those nodes.

> > > + regulators:
> > > + type: object
> > > + description:
> > > + list of regulators provided by this controller, must be named
> > > + after their hardware counterparts BUCK[1-4], one LDORTC, and LDO[2-5]
> > > + The valid names for regulators are
> > > + buck1, buck2, buck3, buck4, ldortc, ldo2, ldo3, ldo4, ldo5
> > For the third times now, the names should be validated using
> > propertyNames.
>
> Not sure did I understand your question correctly.
> all the node name under regulators node are parsed by regulator
> framework & validated against
> name in regulator descriptors.

Yes, and the point of the bindings in YAML is to make sure all the
constraints we might have can be catched at compilation / validation
time.

The names of the nodes are a constraint, and propertyNames allows you
to express it.

Maxime