* [PATCH 0/2] Add Richtek RT5190A PMIC support
@ 2022-03-07 10:08 cy_huang
2022-03-07 10:08 ` [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC cy_huang
2022-03-07 10:08 ` [PATCH 2/2] regulator: rt5190a: Add support " cy_huang
0 siblings, 2 replies; 8+ messages in thread
From: cy_huang @ 2022-03-07 10:08 UTC (permalink / raw)
To: broonie, robh+dt; +Cc: lgirdwood, cy_huang, linux-kernel, devicetree
From: ChiYuan Huang <cy_huang@richtek.com>
This patch series add Richtek RT5190A PMIC support.
ChiYuan Huang (2):
dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC
regulator: rt5190a: Add support for Richtek RT5190A PMIC
.../regulator/richtek,rt5190a-regulator.yaml | 138 ++++++
drivers/regulator/Kconfig | 10 +
drivers/regulator/Makefile | 1 +
drivers/regulator/rt5190a-regulator.c | 461 +++++++++++++++++++++
4 files changed, 610 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
create mode 100644 drivers/regulator/rt5190a-regulator.c
--
2.7.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC
2022-03-07 10:08 [PATCH 0/2] Add Richtek RT5190A PMIC support cy_huang
@ 2022-03-07 10:08 ` cy_huang
2022-03-07 11:14 ` Krzysztof Kozlowski
2022-03-07 10:08 ` [PATCH 2/2] regulator: rt5190a: Add support " cy_huang
1 sibling, 1 reply; 8+ messages in thread
From: cy_huang @ 2022-03-07 10:08 UTC (permalink / raw)
To: broonie, robh+dt; +Cc: lgirdwood, cy_huang, linux-kernel, devicetree
From: ChiYuan Huang <cy_huang@richtek.com>
Add bindings for Richtek RT5190A PMIC.
Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
.../regulator/richtek,rt5190a-regulator.yaml | 138 +++++++++++++++++++++
1 file changed, 138 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
diff --git a/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
new file mode 100644
index 00000000..b9f5836
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
@@ -0,0 +1,138 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/richtek,rt5190a-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT5190A PMIC Regulator
+
+maintainers:
+ - ChiYuan Huang <cy_huang@richtek.com>
+
+description: |
+ The RT5190A integrates 1 channel buck controller, 3 channels high efficiency
+ synchronous buck converters, 1 LDO, I2C control interface and peripherial
+ logical control.
+
+ It also supports mute AC OFF depop sound and quick setting storage while
+ input power is removed.
+
+properties:
+ compatible:
+ enum:
+ - richtek,rt5190a
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ vin2-supply:
+ description: phandle to buck2 input voltage.
+
+ vin3-supply:
+ description: phandle to buck3 input voltage.
+
+ vin4-supply:
+ description: phandle to buck4 input voltage.
+
+ vinldo-supply:
+ description: phandle to ldo input voltage
+
+ richtek,buck1-fixed-microvolt:
+ description: buck1 fixed voltage that depends on the external resistor.
+ $ref: "/schemas/types.yaml#/definitions/uint32"
+
+ richtek,buck4-fixed-microvolt:
+ description: buck4 fixed voltage that depends on the external resistor.
+ $ref: "/schemas/types.yaml#/definitions/uint32"
+
+ richtek,ldo-fixed-microvolt:
+ description: ldo fixed voltage that depends on the external resistor.
+ $ref: "/schemas/types.yaml#/definitions/uint32"
+
+ richtek,mute-enable:
+ description: this can be used to enable mute function.
+ type: boolean
+
+ regulators:
+ type: object
+
+ patternProperties:
+ "^buck[1-4]$|^ldo$":
+ type: object
+ $ref: regulator.yaml#
+ description: |
+ regulator description for buck[1-4] and ldo.
+
+ properties:
+ richtek,latchup-enable:
+ type: boolean
+ description: |
+ If specified, undervolt protection mode changes from the default
+ hiccup to latchup.
+
+ unevaluatedProperties: false
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - richtek,buck1-fixed-microvolt
+ - richtek,buck4-fixed-microvolt
+ - richtek,ldo-fixed-microvolt
+ - regulators
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ rt5190a@64 {
+ compatible = "richtek,rt5190a";
+ reg = <0x64>;
+ interrupts-extended = <&gpio26 0 IRQ_TYPE_LEVEL_LOW>;
+ vin2-supply = <&rt5190_buck1>;
+ vin3-supply = <&rt5190_buck1>;
+ vin4-supply = <&rt5190_buck1>;
+ richtek,buck1-fixed-microvolt = <5090000>;
+ richtek,buck4-fixed-microvolt = <850000>;
+ richtek,ldo-fixed-microvolt = <1200000>;
+
+ regulators {
+ rt5190_buck1: buck1 {
+ regulator-name = "rt5190a-buck1";
+ regulator-allowed-modes = <0 1>;
+ regulator-boot-on;
+ };
+ buck2 {
+ regulator-name = "rt5190a-buck2";
+ regulator-min-microvolt = <600000>;
+ regulator-max-microvolt = <1400000>;
+ regulator-boot-on;
+ };
+ buck3 {
+ regulator-name = "rt5190a-buck3";
+ regulator-min-microvolt = <600000>;
+ regulator-max-microvolt = <1400000>;
+ regulator-boot-on;
+ };
+ buck4 {
+ regulator-name = "rt5190a-buck4";
+ regulator-allowed-modes = <0 1>;
+ regulator-boot-on;
+ };
+ ldo {
+ regulator-name = "rt5190a-ldo";
+ regulator-boot-on;
+ };
+ };
+ };
+ };
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] regulator: rt5190a: Add support for Richtek RT5190A PMIC
2022-03-07 10:08 [PATCH 0/2] Add Richtek RT5190A PMIC support cy_huang
2022-03-07 10:08 ` [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC cy_huang
@ 2022-03-07 10:08 ` cy_huang
1 sibling, 0 replies; 8+ messages in thread
From: cy_huang @ 2022-03-07 10:08 UTC (permalink / raw)
To: broonie, robh+dt; +Cc: lgirdwood, cy_huang, linux-kernel, devicetree
From: ChiYuan Huang <cy_huang@richtek.com>
Add support for Richtek RT5190A PMIC.
Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
drivers/regulator/Kconfig | 10 +
drivers/regulator/Makefile | 1 +
drivers/regulator/rt5190a-regulator.c | 461 ++++++++++++++++++++++++++++++++++
3 files changed, 472 insertions(+)
create mode 100644 drivers/regulator/rt5190a-regulator.c
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 1c35fed2..850e954 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1046,6 +1046,16 @@ config REGULATOR_RT5033
RT5033 PMIC. The device supports multiple regulators like
current source, LDO and Buck.
+config REGULATOR_RT5190A
+ tristate "Richtek RT5190A PMIC"
+ depends on I2C
+ select REGMAP_I2C
+ help
+ This adds support for voltage regulator in Richtek RT5190A PMIC.
+ It integratas 1 channel buck controller, 3 channels high efficiency
+ buck converters, 1 LDO, mute AC OFF depop function, with the general
+ I2C control interface.
+
config REGULATOR_RT6160
tristate "Richtek RT6160 BuckBoost voltage regulator"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 2e1b087..28d816a9 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -126,6 +126,7 @@ obj-$(CONFIG_REGULATOR_ROHM) += rohm-regulator.o
obj-$(CONFIG_REGULATOR_RT4801) += rt4801-regulator.o
obj-$(CONFIG_REGULATOR_RT4831) += rt4831-regulator.o
obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o
+obj-$(CONFIG_REGULATOR_RT5190A) += rt5190a-regulator.o
obj-$(CONFIG_REGULATOR_RT6160) += rt6160-regulator.o
obj-$(CONFIG_REGULATOR_RT6245) += rt6245-regulator.o
obj-$(CONFIG_REGULATOR_RTMV20) += rtmv20-regulator.o
diff --git a/drivers/regulator/rt5190a-regulator.c b/drivers/regulator/rt5190a-regulator.c
new file mode 100644
index 00000000..2ac5e37
--- /dev/null
+++ b/drivers/regulator/rt5190a-regulator.c
@@ -0,0 +1,461 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <linux/bits.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/property.h>
+#include <linux/regmap.h>
+#include <linux/regulator/driver.h>
+
+#define RT5190A_REG_MANUFACTURE 0x00
+#define RT5190A_REG_BUCK2VSEL 0x04
+#define RT5190A_REG_BUCK3VSEL 0x05
+#define RT5190A_REG_DCDCCNTL 0x06
+#define RT5190A_REG_ENABLE 0x07
+#define RT5190A_REG_DISCHARGE 0x09
+#define RT5190A_REG_PROTMODE 0x0A
+#define RT5190A_REG_MUTECNTL 0x0B
+#define RT5190A_REG_PGSTAT 0x0F
+#define RT5190A_REG_OVINT 0x10
+#define RT5190A_REG_HOTDIEMASK 0x17
+
+#define RT5190A_VSEL_MASK GENMASK(6, 0)
+#define RT5190A_RID_BITMASK(rid) BIT(rid + 1)
+#define RT5190A_BUCK1_DISCHG_MASK GENMASK(1, 0)
+#define RT5190A_BUCK1_DISCHG_ONVAL 0x01
+#define RT5190A_OVERVOLT_MASK GENMASK(7, 0)
+#define RT5190A_UNDERVOLT_MASK GENMASK(15, 8)
+#define RT5190A_CH234OT_MASK BIT(29)
+#define RT5190A_CHIPOT_MASK BIT(28)
+
+#define RT5190A_BUCK23_MINUV 600000
+#define RT5190A_BUCK23_MAXUV 1400000
+#define RT5190A_BUCK23_STEPUV 10000
+#define RT5190A_BUCK23_STEPNUM ((1400000 - 600000) / 10000 + 1)
+
+enum {
+ RT5190A_IDX_BUCK1 = 0,
+ RT5190A_IDX_BUCK2,
+ RT5190A_IDX_BUCK3,
+ RT5190A_IDX_BUCK4,
+ RT5190A_IDX_LDO,
+ RT5190A_MAX_IDX
+};
+
+struct rt5190a_priv {
+ struct device *dev;
+ struct regmap *regmap;
+ struct regulator_desc rdesc[RT5190A_MAX_IDX];
+ struct regulator_dev *rdev[RT5190A_MAX_IDX];
+ unsigned int buck1_fixed_uV;
+ unsigned int buck4_fixed_uV;
+ unsigned int ldo_fixed_uV;
+ bool mute_enable;
+};
+
+static int rt5190a_get_error_flags(struct regulator_dev *rdev,
+ unsigned int *flags)
+{
+ struct regmap *regmap = rdev_get_regmap(rdev);
+ int rid = rdev_get_id(rdev);
+ unsigned int pgood_stat;
+ int ret;
+
+ ret = regmap_read(regmap, RT5190A_REG_PGSTAT, &pgood_stat);
+ if (ret)
+ return ret;
+
+ if (!(pgood_stat & RT5190A_RID_BITMASK(rid)))
+ *flags = REGULATOR_ERROR_FAIL;
+ else
+ *flags = 0;
+
+ return 0;
+}
+
+static int rt5190a_fixed_buck_set_mode(struct regulator_dev *rdev,
+ unsigned int mode)
+{
+ struct regmap *regmap = rdev_get_regmap(rdev);
+ int rid = rdev_get_id(rdev);
+ unsigned int mask = RT5190A_RID_BITMASK(rid), val;
+
+ switch (mode) {
+ case REGULATOR_MODE_FAST:
+ val = mask;
+ break;
+ case REGULATOR_MODE_NORMAL:
+ val = 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return regmap_update_bits(regmap, RT5190A_REG_DCDCCNTL, mask, val);
+}
+
+static unsigned int rt5190a_fixed_buck_get_mode(struct regulator_dev *rdev)
+{
+ struct regmap *regmap = rdev_get_regmap(rdev);
+ int rid = rdev_get_id(rdev);
+ unsigned int val;
+ int ret;
+
+ ret = regmap_read(regmap, RT5190A_REG_DCDCCNTL, &val);
+ if (ret) {
+ dev_err(&rdev->dev, "Failed to get mode [%d]\n", ret);
+ return ret;
+ }
+
+ if (val & RT5190A_RID_BITMASK(rid))
+ return REGULATOR_MODE_FAST;
+
+ return REGULATOR_MODE_NORMAL;
+}
+
+static const struct regulator_ops rt5190a_ranged_buck_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+ .get_error_flags = rt5190a_get_error_flags,
+};
+
+static const struct regulator_ops rt5190a_fixed_buck_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+ .set_mode = rt5190a_fixed_buck_set_mode,
+ .get_mode = rt5190a_fixed_buck_get_mode,
+ .get_error_flags = rt5190a_get_error_flags,
+};
+
+static const struct regulator_ops rt5190a_fixed_ldo_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .is_enabled = regulator_is_enabled_regmap,
+ .set_active_discharge = regulator_set_active_discharge_regmap,
+ .get_error_flags = rt5190a_get_error_flags,
+};
+
+static irqreturn_t rt5190a_irq_handler(int irq, void *data)
+{
+ struct rt5190a_priv *priv = data;
+ __le32 raws;
+ unsigned int events, fields;
+ static const struct {
+ unsigned int bitmask;
+ unsigned int report;
+ } event_tbl[] = {
+ { RT5190A_OVERVOLT_MASK, REGULATOR_ERROR_REGULATION_OUT },
+ { RT5190A_UNDERVOLT_MASK, REGULATOR_ERROR_UNDER_VOLTAGE }
+ };
+ int i, j, ret;
+
+ ret = regmap_raw_read(priv->regmap, RT5190A_REG_OVINT, &raws,
+ sizeof(raws));
+ if (ret) {
+ dev_err(priv->dev, "Failed to read events\n");
+ return IRQ_NONE;
+ }
+
+ events = le32_to_cpu(raws);
+
+ /* Handle OV,UV events */
+ for (i = 0; i < ARRAY_SIZE(event_tbl); i++) {
+ fields = events & event_tbl[i].bitmask;
+ fields >>= ffs(event_tbl[i].bitmask) - 1;
+
+ for (j = 0; j < RT5190A_MAX_IDX; j++) {
+ if (!(fields & RT5190A_RID_BITMASK(j)))
+ continue;
+
+ regulator_notifier_call_chain(priv->rdev[j],
+ event_tbl[i].report,
+ NULL);
+ }
+ }
+
+ /* Handle CH234 OT event */
+ if (events & RT5190A_CH234OT_MASK) {
+ for (j = RT5190A_IDX_BUCK2; j < RT5190A_IDX_LDO; j++) {
+ regulator_notifier_call_chain(priv->rdev[j],
+ REGULATOR_ERROR_OVER_TEMP,
+ NULL);
+ }
+ }
+
+ /* Warning if CHIP OT occur */
+ if (events & RT5190A_CHIPOT_MASK)
+ dev_warn(priv->dev, "CHIP overheat\n");
+
+ ret = regmap_raw_write(priv->regmap, RT5190A_REG_OVINT, &raws,
+ sizeof(raws));
+ if (ret)
+ dev_err(priv->dev, "Failed to write-clear events\n");
+
+ return IRQ_HANDLED;
+}
+
+static unsigned int rt5190a_of_map_mode(unsigned int mode)
+{
+ switch (mode) {
+ case 0:
+ return REGULATOR_MODE_NORMAL;
+ case 1:
+ return REGULATOR_MODE_FAST;
+ default:
+ return REGULATOR_MODE_INVALID;
+ }
+}
+
+static int rt5190a_of_parse_cb(struct device_node *np,
+ const struct regulator_desc *desc,
+ struct regulator_config *cfg)
+{
+ bool latchup_enable;
+ unsigned int mask = RT5190A_RID_BITMASK(desc->id), val;
+
+ latchup_enable = of_property_read_bool(np, "richtek,latchup-enable");
+
+ /* latchup: 0, default hiccup: 1 */
+ val = !latchup_enable ? mask : 0;
+
+ return regmap_update_bits(cfg->regmap, RT5190A_REG_PROTMODE, mask, val);
+}
+
+static void rt5190a_fillin_regulator_desc(struct rt5190a_priv *priv, int rid)
+{
+ static const char *regu_name[] = { "buck1", "buck2", "buck3", "buck4",
+ "ldo" };
+ static const char *supply[]= { NULL, "vin2", "vin3", "vin4", "vinldo" };
+ struct regulator_desc *desc = priv->rdesc + rid;
+
+ desc->name = desc->of_match = regu_name[rid];
+ desc->supply_name = supply[rid];
+ desc->regulators_node = "regulators";
+ desc->owner = THIS_MODULE;
+ desc->type = REGULATOR_VOLTAGE;
+ desc->id = rid;
+ desc->enable_reg = RT5190A_REG_ENABLE;
+ desc->enable_mask = RT5190A_RID_BITMASK(rid);
+ desc->active_discharge_reg = RT5190A_REG_DISCHARGE;
+ desc->active_discharge_mask = RT5190A_RID_BITMASK(rid);
+ desc->active_discharge_on = RT5190A_RID_BITMASK(rid);
+ desc->of_parse_cb = rt5190a_of_parse_cb;
+
+ switch (rid) {
+ case RT5190A_IDX_BUCK1:
+ desc->active_discharge_mask = RT5190A_BUCK1_DISCHG_MASK;
+ desc->active_discharge_on = RT5190A_BUCK1_DISCHG_ONVAL;
+ desc->fixed_uV = priv->buck1_fixed_uV;
+ desc->n_voltages = 1;
+ desc->ops = &rt5190a_fixed_buck_ops;
+ desc->of_map_mode = rt5190a_of_map_mode;
+ break;
+ case RT5190A_IDX_BUCK2:
+ desc->vsel_reg = RT5190A_REG_BUCK2VSEL;
+ desc->vsel_mask = RT5190A_VSEL_MASK;
+ desc->min_uV = RT5190A_BUCK23_MINUV;
+ desc->uV_step = RT5190A_BUCK23_STEPUV;
+ desc->n_voltages = RT5190A_BUCK23_STEPNUM;
+ desc->ops = &rt5190a_ranged_buck_ops;
+ break;
+ case RT5190A_IDX_BUCK3:
+ desc->vsel_reg = RT5190A_REG_BUCK3VSEL;
+ desc->vsel_mask = RT5190A_VSEL_MASK;
+ desc->min_uV = RT5190A_BUCK23_MINUV;
+ desc->uV_step = RT5190A_BUCK23_STEPUV;
+ desc->n_voltages = RT5190A_BUCK23_STEPNUM;
+ desc->ops = &rt5190a_ranged_buck_ops;
+ break;
+ case RT5190A_IDX_BUCK4:
+ desc->fixed_uV = priv->buck4_fixed_uV;
+ desc->n_voltages = 1;
+ desc->ops = &rt5190a_fixed_buck_ops;
+ desc->of_map_mode = rt5190a_of_map_mode;
+ break;
+ case RT5190A_IDX_LDO:
+ desc->fixed_uV = priv->ldo_fixed_uV;
+ desc->n_voltages = 1;
+ desc->ops = &rt5190a_fixed_ldo_ops;
+ break;
+ }
+}
+
+static const struct reg_sequence rt5190a_init_patch[] = {
+ { 0x09, 0x3d, },
+ { 0x0a, 0x3e, },
+ { 0x0b, 0x01, },
+ { 0x10, 0xff, },
+ { 0x11, 0xff, },
+ { 0x12, 0xff, },
+ { 0x13, 0xff, },
+ { 0x14, 0, },
+ { 0x15, 0, },
+ { 0x16, 0x3e, },
+ { 0x17, 0, }
+};
+
+static int rt5190a_device_initialize(struct rt5190a_priv *priv)
+{
+ int ret;
+
+ ret = regmap_register_patch(priv->regmap, rt5190a_init_patch,
+ ARRAY_SIZE(rt5190a_init_patch));
+ if (ret) {
+ dev_err(priv->dev, "Failed to do register patch\n");
+ return ret;
+ }
+
+ if (priv->mute_enable) {
+ ret = regmap_write(priv->regmap, RT5190A_REG_MUTECNTL, 0x00);
+ if (ret) {
+ dev_err(priv->dev, "Failed to enable mute function\n");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int rt5190a_parse_device_config(struct rt5190a_priv *priv)
+{
+ struct device *dev = priv->dev;
+ int ret;
+
+ ret = device_property_read_u32(dev, "richtek,buck1-fixed-microvolt",
+ &priv->buck1_fixed_uV);
+ if (ret)
+ return ret;
+
+ ret = device_property_read_u32(dev, "richtek,buck4-fixed-microvolt",
+ &priv->buck4_fixed_uV);
+ if (ret)
+ return ret;
+
+ ret = device_property_read_u32(dev, "richtek,ldo-fixed-microvolt",
+ &priv->ldo_fixed_uV);
+ if (ret)
+ return ret;
+
+ priv->mute_enable = device_property_read_bool(dev,
+ "richtek,mute-enable");
+
+ return 0;
+}
+
+static int rt5190a_device_check(struct rt5190a_priv *priv)
+{
+ u16 devid;
+ int ret;
+
+ ret = regmap_raw_read(priv->regmap, RT5190A_REG_MANUFACTURE, &devid,
+ sizeof(devid));
+ if (ret)
+ return ret;
+
+ if (devid) {
+ dev_err(priv->dev, "Incorrect device id 0x%04x\n", devid);
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static const struct regmap_config rt5190a_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = RT5190A_REG_HOTDIEMASK,
+};
+
+static int rt5190a_probe(struct i2c_client *i2c)
+{
+ struct rt5190a_priv *priv;
+ struct regulator_config cfg = {};
+ int i, ret;
+
+ priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->dev = &i2c->dev;
+
+ priv->regmap = devm_regmap_init_i2c(i2c, &rt5190a_regmap_config);
+ if (IS_ERR(priv->regmap)) {
+ dev_err(&i2c->dev, "Failed to allocate regmap\n");
+ return PTR_ERR(priv->regmap);
+ }
+
+ ret = rt5190a_device_check(priv);
+ if (ret) {
+ dev_err(&i2c->dev, "Failed to check device %d\n", ret);
+ return ret;
+ }
+
+ ret = rt5190a_parse_device_config(priv);
+ if (ret) {
+ dev_err(&i2c->dev, "Failed to parse device config\n");
+ return ret;
+ }
+
+ ret = rt5190a_device_initialize(priv);
+ if (ret) {
+ dev_err(&i2c->dev, "Failed to initialize the device\n");
+ return ret;
+ }
+
+ cfg.dev = &i2c->dev;
+ cfg.regmap = priv->regmap;
+
+ for (i = 0; i < RT5190A_MAX_IDX; i++) {
+ struct regulator_desc *desc = priv->rdesc + i;
+
+ rt5190a_fillin_regulator_desc(priv, i);
+ priv->rdev[i] = devm_regulator_register(&i2c->dev, desc, &cfg);
+ if (IS_ERR(priv->rdev[i])) {
+ dev_err(&i2c->dev, "Failed to register regulator %s\n",
+ desc->name);
+ return PTR_ERR(priv->rdev[i]);
+ }
+ }
+
+ if (i2c->irq) {
+ ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL,
+ rt5190a_irq_handler,
+ IRQF_ONESHOT,
+ dev_name(&i2c->dev), priv);
+ if (ret) {
+ dev_err(&i2c->dev, "Failed to register interrupt\n");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static const struct of_device_id __maybe_unused rt5190a_device_table[] = {
+ { .compatible = "richtek,rt5190a", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, rt5190a_device_table);
+
+static struct i2c_driver rt5190a_driver = {
+ .driver = {
+ .name = "rt5190a",
+ .of_match_table = rt5190a_device_table,
+ },
+ .probe_new = rt5190a_probe,
+};
+module_i2c_driver(rt5190a_driver);
+
+MODULE_AUTHOR("ChiYuan Huang <cy_huang@richtek.com>");
+MODULE_DESCRIPTION("Richtek RT5190A Regulator Driver");
+MODULE_LICENSE("GPL v2");
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC
2022-03-07 10:08 ` [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC cy_huang
@ 2022-03-07 11:14 ` Krzysztof Kozlowski
2022-03-07 13:21 ` ChiYuan Huang
0 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07 11:14 UTC (permalink / raw)
To: cy_huang, broonie, robh+dt; +Cc: lgirdwood, cy_huang, linux-kernel, devicetree
On 07/03/2022 11:08, cy_huang wrote:
> From: ChiYuan Huang <cy_huang@richtek.com>
>
> Add bindings for Richtek RT5190A PMIC.
>
> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
> ---
> .../regulator/richtek,rt5190a-regulator.yaml | 138 +++++++++++++++++++++
> 1 file changed, 138 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
>
> diff --git a/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
> new file mode 100644
> index 00000000..b9f5836
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
> @@ -0,0 +1,138 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/richtek,rt5190a-regulator.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Richtek RT5190A PMIC Regulator
> +
> +maintainers:
> + - ChiYuan Huang <cy_huang@richtek.com>
> +
> +description: |
> + The RT5190A integrates 1 channel buck controller, 3 channels high efficiency
> + synchronous buck converters, 1 LDO, I2C control interface and peripherial
> + logical control.
> +
> + It also supports mute AC OFF depop sound and quick setting storage while
> + input power is removed.
> +
> +properties:
> + compatible:
> + enum:
> + - richtek,rt5190a
> +
> + reg:
> + maxItems: 1
> +
> + interrupts:
> + maxItems: 1
> +
> + vin2-supply:
> + description: phandle to buck2 input voltage.
> +
> + vin3-supply:
> + description: phandle to buck3 input voltage.
> +
> + vin4-supply:
> + description: phandle to buck4 input voltage.
> +
> + vinldo-supply:
> + description: phandle to ldo input voltage
> +
> + richtek,buck1-fixed-microvolt:
> + description: buck1 fixed voltage that depends on the external resistor.
> + $ref: "/schemas/types.yaml#/definitions/uint32"
You should use standard bindings for it.
> +
> + richtek,buck4-fixed-microvolt:
> + description: buck4 fixed voltage that depends on the external resistor.
> + $ref: "/schemas/types.yaml#/definitions/uint32"
> +
> + richtek,ldo-fixed-microvolt:
> + description: ldo fixed voltage that depends on the external resistor.
> + $ref: "/schemas/types.yaml#/definitions/uint32"
> +
> + richtek,mute-enable:
> + description: this can be used to enable mute function.
Please describe what is "mute" function". Your description copied
property name, so it is not useful.
> + type: boolean
> +
> + regulators:
> + type: object
> +
> + patternProperties:
> + "^buck[1-4]$|^ldo$":
> + type: object
> + $ref: regulator.yaml#
> + description: |
> + regulator description for buck[1-4] and ldo.
> +
> + properties:
> + richtek,latchup-enable:
> + type: boolean
> + description: |
> + If specified, undervolt protection mode changes from the default
> + hiccup to latchup.
> +
> + unevaluatedProperties: false
> +
> + additionalProperties: false
> +
> +required:
> + - compatible
> + - reg
> + - richtek,buck1-fixed-microvolt
> + - richtek,buck4-fixed-microvolt
> + - richtek,ldo-fixed-microvolt
> + - regulators
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/interrupt-controller/irq.h>
> +
> + i2c {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + rt5190a@64 {
Generic node name, so "pmic".
> + compatible = "richtek,rt5190a";
> + reg = <0x64>;
> + interrupts-extended = <&gpio26 0 IRQ_TYPE_LEVEL_LOW>;
> + vin2-supply = <&rt5190_buck1>;
> + vin3-supply = <&rt5190_buck1>;
> + vin4-supply = <&rt5190_buck1>;
> + richtek,buck1-fixed-microvolt = <5090000>;
> + richtek,buck4-fixed-microvolt = <850000>;
> + richtek,ldo-fixed-microvolt = <1200000>;
> +
> + regulators {
> + rt5190_buck1: buck1 {
> + regulator-name = "rt5190a-buck1";
> + regulator-allowed-modes = <0 1>;
Please describe these in header file in bindings and mention as one of
regulator properties with description and enum.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC
2022-03-07 11:14 ` Krzysztof Kozlowski
@ 2022-03-07 13:21 ` ChiYuan Huang
2022-03-07 13:27 ` Krzysztof Kozlowski
0 siblings, 1 reply; 8+ messages in thread
From: ChiYuan Huang @ 2022-03-07 13:21 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Mark Brown, Rob Herring, Liam Girdwood, cy_huang, lkml,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 於 2022年3月7日 週一 下午7:14寫道:
>
> On 07/03/2022 11:08, cy_huang wrote:
> > From: ChiYuan Huang <cy_huang@richtek.com>
> >
> > Add bindings for Richtek RT5190A PMIC.
> >
> > Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
> > ---
> > .../regulator/richtek,rt5190a-regulator.yaml | 138 +++++++++++++++++++++
> > 1 file changed, 138 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
> > new file mode 100644
> > index 00000000..b9f5836
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
> > @@ -0,0 +1,138 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/regulator/richtek,rt5190a-regulator.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Richtek RT5190A PMIC Regulator
> > +
> > +maintainers:
> > + - ChiYuan Huang <cy_huang@richtek.com>
> > +
> > +description: |
> > + The RT5190A integrates 1 channel buck controller, 3 channels high efficiency
> > + synchronous buck converters, 1 LDO, I2C control interface and peripherial
> > + logical control.
> > +
> > + It also supports mute AC OFF depop sound and quick setting storage while
> > + input power is removed.
> > +
> > +properties:
> > + compatible:
> > + enum:
> > + - richtek,rt5190a
> > +
> > + reg:
> > + maxItems: 1
> > +
> > + interrupts:
> > + maxItems: 1
> > +
> > + vin2-supply:
> > + description: phandle to buck2 input voltage.
> > +
> > + vin3-supply:
> > + description: phandle to buck3 input voltage.
> > +
> > + vin4-supply:
> > + description: phandle to buck4 input voltage.
> > +
> > + vinldo-supply:
> > + description: phandle to ldo input voltage
> > +
> > + richtek,buck1-fixed-microvolt:
> > + description: buck1 fixed voltage that depends on the external resistor.
> > + $ref: "/schemas/types.yaml#/definitions/uint32"
>
> You should use standard bindings for it.
>
Sorry, I didn't get the point for the meaning 'standard binding'.
Do you mean to change 'richtek,buck1-fixed-microvolt' or 'uint32' definition?
This voltage depends on the external resistor selection. It's 'fixed'
by the application.
> > +
> > + richtek,buck4-fixed-microvolt:
> > + description: buck4 fixed voltage that depends on the external resistor.
> > + $ref: "/schemas/types.yaml#/definitions/uint32"
> > +
> > + richtek,ldo-fixed-microvolt:
> > + description: ldo fixed voltage that depends on the external resistor.
> > + $ref: "/schemas/types.yaml#/definitions/uint32"
> > +
> > + richtek,mute-enable:
> > + description: this can be used to enable mute function.
>
> Please describe what is "mute" function". Your description copied
> property name, so it is not useful.
>
OK, I'll describe more detailed.
> > + type: boolean
> > +
> > + regulators:
> > + type: object
> > +
> > + patternProperties:
> > + "^buck[1-4]$|^ldo$":
> > + type: object
> > + $ref: regulator.yaml#
> > + description: |
> > + regulator description for buck[1-4] and ldo.
> > +
> > + properties:
> > + richtek,latchup-enable:
> > + type: boolean
> > + description: |
> > + If specified, undervolt protection mode changes from the default
> > + hiccup to latchup.
> > +
> > + unevaluatedProperties: false
> > +
> > + additionalProperties: false
> > +
> > +required:
> > + - compatible
> > + - reg
> > + - richtek,buck1-fixed-microvolt
> > + - richtek,buck4-fixed-microvolt
> > + - richtek,ldo-fixed-microvolt
> > + - regulators
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > + - |
> > + #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > + i2c {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + rt5190a@64 {
>
> Generic node name, so "pmic".
>
Ack in next.
> > + compatible = "richtek,rt5190a";
> > + reg = <0x64>;
> > + interrupts-extended = <&gpio26 0 IRQ_TYPE_LEVEL_LOW>;
> > + vin2-supply = <&rt5190_buck1>;
> > + vin3-supply = <&rt5190_buck1>;
> > + vin4-supply = <&rt5190_buck1>;
> > + richtek,buck1-fixed-microvolt = <5090000>;
> > + richtek,buck4-fixed-microvolt = <850000>;
> > + richtek,ldo-fixed-microvolt = <1200000>;
> > +
> > + regulators {
> > + rt5190_buck1: buck1 {
> > + regulator-name = "rt5190a-buck1";
> > + regulator-allowed-modes = <0 1>;
>
> Please describe these in header file in bindings and mention as one of
> regulator properties with description and enum.
>
OK, will add one dt-binding header file for the constant and mentioned
as one regulator property.
Ack in next.
>
>
> Best regards,
> Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC
2022-03-07 13:21 ` ChiYuan Huang
@ 2022-03-07 13:27 ` Krzysztof Kozlowski
2022-03-07 14:21 ` ChiYuan Huang
0 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07 13:27 UTC (permalink / raw)
To: ChiYuan Huang
Cc: Mark Brown, Rob Herring, Liam Girdwood, cy_huang, lkml,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
On 07/03/2022 14:21, ChiYuan Huang wrote:
> Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 於 2022年3月7日 週一 下午7:14寫道:
>>
>> On 07/03/2022 11:08, cy_huang wrote:
>>> From: ChiYuan Huang <cy_huang@richtek.com>
>>>
>>> Add bindings for Richtek RT5190A PMIC.
>>>
>>> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
>>> ---
>>> .../regulator/richtek,rt5190a-regulator.yaml | 138 +++++++++++++++++++++
>>> 1 file changed, 138 insertions(+)
>>> create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
>>>
>>> diff --git a/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
>>> new file mode 100644
>>> index 00000000..b9f5836
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
>>> @@ -0,0 +1,138 @@
>>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/regulator/richtek,rt5190a-regulator.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: Richtek RT5190A PMIC Regulator
>>> +
>>> +maintainers:
>>> + - ChiYuan Huang <cy_huang@richtek.com>
>>> +
>>> +description: |
>>> + The RT5190A integrates 1 channel buck controller, 3 channels high efficiency
>>> + synchronous buck converters, 1 LDO, I2C control interface and peripherial
>>> + logical control.
>>> +
>>> + It also supports mute AC OFF depop sound and quick setting storage while
>>> + input power is removed.
>>> +
>>> +properties:
>>> + compatible:
>>> + enum:
>>> + - richtek,rt5190a
>>> +
>>> + reg:
>>> + maxItems: 1
>>> +
>>> + interrupts:
>>> + maxItems: 1
>>> +
>>> + vin2-supply:
>>> + description: phandle to buck2 input voltage.
>>> +
>>> + vin3-supply:
>>> + description: phandle to buck3 input voltage.
>>> +
>>> + vin4-supply:
>>> + description: phandle to buck4 input voltage.
>>> +
>>> + vinldo-supply:
>>> + description: phandle to ldo input voltage
>>> +
>>> + richtek,buck1-fixed-microvolt:
>>> + description: buck1 fixed voltage that depends on the external resistor.
>>> + $ref: "/schemas/types.yaml#/definitions/uint32"
>>
>> You should use standard bindings for it.
>>
> Sorry, I didn't get the point for the meaning 'standard binding'.
> Do you mean to change 'richtek,buck1-fixed-microvolt' or 'uint32' definition?
> This voltage depends on the external resistor selection. It's 'fixed'
> by the application.
I meant that you should not have dedicated binding to set regulator
voltage, but use regulator-min/max-microvolt instead, within one
regulator node. Just set min/max to same level and handle it in the
driver. See for example:
drivers/regulator/scmi-regulator.c
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC
2022-03-07 13:27 ` Krzysztof Kozlowski
@ 2022-03-07 14:21 ` ChiYuan Huang
2022-03-07 14:26 ` Krzysztof Kozlowski
0 siblings, 1 reply; 8+ messages in thread
From: ChiYuan Huang @ 2022-03-07 14:21 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Mark Brown, Rob Herring, Liam Girdwood, cy_huang, lkml,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
HI, Krzysztof:
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 於 2022年3月7日 週一 下午9:27寫道:
>
> On 07/03/2022 14:21, ChiYuan Huang wrote:
> > Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 於 2022年3月7日 週一 下午7:14寫道:
> >>
> >> On 07/03/2022 11:08, cy_huang wrote:
> >>> From: ChiYuan Huang <cy_huang@richtek.com>
> >>>
> >>> Add bindings for Richtek RT5190A PMIC.
> >>>
> >>> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
> >>> ---
> >>> .../regulator/richtek,rt5190a-regulator.yaml | 138 +++++++++++++++++++++
> >>> 1 file changed, 138 insertions(+)
> >>> create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
> >>>
> >>> diff --git a/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
> >>> new file mode 100644
> >>> index 00000000..b9f5836
> >>> --- /dev/null
> >>> +++ b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
> >>> @@ -0,0 +1,138 @@
> >>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> >>> +%YAML 1.2
> >>> +---
> >>> +$id: http://devicetree.org/schemas/regulator/richtek,rt5190a-regulator.yaml#
> >>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >>> +
> >>> +title: Richtek RT5190A PMIC Regulator
> >>> +
> >>> +maintainers:
> >>> + - ChiYuan Huang <cy_huang@richtek.com>
> >>> +
> >>> +description: |
> >>> + The RT5190A integrates 1 channel buck controller, 3 channels high efficiency
> >>> + synchronous buck converters, 1 LDO, I2C control interface and peripherial
> >>> + logical control.
> >>> +
> >>> + It also supports mute AC OFF depop sound and quick setting storage while
> >>> + input power is removed.
> >>> +
> >>> +properties:
> >>> + compatible:
> >>> + enum:
> >>> + - richtek,rt5190a
> >>> +
> >>> + reg:
> >>> + maxItems: 1
> >>> +
> >>> + interrupts:
> >>> + maxItems: 1
> >>> +
> >>> + vin2-supply:
> >>> + description: phandle to buck2 input voltage.
> >>> +
> >>> + vin3-supply:
> >>> + description: phandle to buck3 input voltage.
> >>> +
> >>> + vin4-supply:
> >>> + description: phandle to buck4 input voltage.
> >>> +
> >>> + vinldo-supply:
> >>> + description: phandle to ldo input voltage
> >>> +
> >>> + richtek,buck1-fixed-microvolt:
> >>> + description: buck1 fixed voltage that depends on the external resistor.
> >>> + $ref: "/schemas/types.yaml#/definitions/uint32"
> >>
> >> You should use standard bindings for it.
> >>
> > Sorry, I didn't get the point for the meaning 'standard binding'.
> > Do you mean to change 'richtek,buck1-fixed-microvolt' or 'uint32' definition?
> > This voltage depends on the external resistor selection. It's 'fixed'
> > by the application.
>
> I meant that you should not have dedicated binding to set regulator
> voltage, but use regulator-min/max-microvolt instead, within one
> regulator node. Just set min/max to same level and handle it in the
> driver. See for example:
> drivers/regulator/scmi-regulator.c
>
As I know, regulator-min/max-microvolt is used as the usage constraint.
But out buck1/buck4/ldo vout is defined by
Vout = VFb * (1 + R1/R2) where R1/R2 is chosen by the circuit design.
It seems not similar with the scmi-regulator.
Do you really suggest to use regulator-min/max-microvolt????
>
> Best regards,
> Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC
2022-03-07 14:21 ` ChiYuan Huang
@ 2022-03-07 14:26 ` Krzysztof Kozlowski
0 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07 14:26 UTC (permalink / raw)
To: ChiYuan Huang
Cc: Mark Brown, Rob Herring, Liam Girdwood, cy_huang, lkml,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
On 07/03/2022 15:21, ChiYuan Huang wrote:
> HI, Krzysztof:
>
> Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 於 2022年3月7日 週一 下午9:27寫道:
>>
>> On 07/03/2022 14:21, ChiYuan Huang wrote:
>>> Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 於 2022年3月7日 週一 下午7:14寫道:
>>>>
>>>> On 07/03/2022 11:08, cy_huang wrote:
>>>>> From: ChiYuan Huang <cy_huang@richtek.com>
>>>>>
>>>>> Add bindings for Richtek RT5190A PMIC.
>>>>>
>>>>> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
>>>>> ---
>>>>> .../regulator/richtek,rt5190a-regulator.yaml | 138 +++++++++++++++++++++
>>>>> 1 file changed, 138 insertions(+)
>>>>> create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
>>>>> new file mode 100644
>>>>> index 00000000..b9f5836
>>>>> --- /dev/null
>>>>> +++ b/Documentation/devicetree/bindings/regulator/richtek,rt5190a-regulator.yaml
>>>>> @@ -0,0 +1,138 @@
>>>>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
>>>>> +%YAML 1.2
>>>>> +---
>>>>> +$id: http://devicetree.org/schemas/regulator/richtek,rt5190a-regulator.yaml#
>>>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>>>> +
>>>>> +title: Richtek RT5190A PMIC Regulator
>>>>> +
>>>>> +maintainers:
>>>>> + - ChiYuan Huang <cy_huang@richtek.com>
>>>>> +
>>>>> +description: |
>>>>> + The RT5190A integrates 1 channel buck controller, 3 channels high efficiency
>>>>> + synchronous buck converters, 1 LDO, I2C control interface and peripherial
>>>>> + logical control.
>>>>> +
>>>>> + It also supports mute AC OFF depop sound and quick setting storage while
>>>>> + input power is removed.
>>>>> +
>>>>> +properties:
>>>>> + compatible:
>>>>> + enum:
>>>>> + - richtek,rt5190a
>>>>> +
>>>>> + reg:
>>>>> + maxItems: 1
>>>>> +
>>>>> + interrupts:
>>>>> + maxItems: 1
>>>>> +
>>>>> + vin2-supply:
>>>>> + description: phandle to buck2 input voltage.
>>>>> +
>>>>> + vin3-supply:
>>>>> + description: phandle to buck3 input voltage.
>>>>> +
>>>>> + vin4-supply:
>>>>> + description: phandle to buck4 input voltage.
>>>>> +
>>>>> + vinldo-supply:
>>>>> + description: phandle to ldo input voltage
>>>>> +
>>>>> + richtek,buck1-fixed-microvolt:
>>>>> + description: buck1 fixed voltage that depends on the external resistor.
>>>>> + $ref: "/schemas/types.yaml#/definitions/uint32"
>>>>
>>>> You should use standard bindings for it.
>>>>
>>> Sorry, I didn't get the point for the meaning 'standard binding'.
>>> Do you mean to change 'richtek,buck1-fixed-microvolt' or 'uint32' definition?
>>> This voltage depends on the external resistor selection. It's 'fixed'
>>> by the application.
>>
>> I meant that you should not have dedicated binding to set regulator
>> voltage, but use regulator-min/max-microvolt instead, within one
>> regulator node. Just set min/max to same level and handle it in the
>> driver. See for example:
>> drivers/regulator/scmi-regulator.c
>>
> As I know, regulator-min/max-microvolt is used as the usage constraint.
True, bindings mention the consumers, but I don't think this is treated
literally.
>
> But out buck1/buck4/ldo vout is defined by
> Vout = VFb * (1 + R1/R2) where R1/R2 is chosen by the circuit design.
>
> It seems not similar with the scmi-regulator.
>
> Do you really suggest to use regulator-min/max-microvolt????
The same as existing fixed-regulator. Why this regulator should be
different than fixed-regulator?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-03-07 14:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 10:08 [PATCH 0/2] Add Richtek RT5190A PMIC support cy_huang
2022-03-07 10:08 ` [PATCH 1/2] dt-bindings: regulator: Add bindings for Richtek RT5190A PMIC cy_huang
2022-03-07 11:14 ` Krzysztof Kozlowski
2022-03-07 13:21 ` ChiYuan Huang
2022-03-07 13:27 ` Krzysztof Kozlowski
2022-03-07 14:21 ` ChiYuan Huang
2022-03-07 14:26 ` Krzysztof Kozlowski
2022-03-07 10:08 ` [PATCH 2/2] regulator: rt5190a: Add support " cy_huang
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).