Skip to contentSkip to conversation

Add Richtek RT5120 PMIC support

PATCH Superseded cy_huang 5 participants 17 messages Jun 22, 2022 – Jul 11, 2022

Subsystems (5)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

cy_huang

author
#0 lore raw

v2 cover Add Richtek RT5120 PMIC support

From: ChiYuan Huang <[email protected]>

This patch series is to add Richtek RT5120 PMIC support.
In RT5120, it integrates four channels of buck converter, one channel of LDO, and one external enable channel to control the external power source.

Since v2:
- Add 'unevaluatedProperties: false' for regulator buck1~4/ldo/exten.
- Fix indention and remove status for powerkey.
- Refine powerkey description for more HW details.
- For the regulator property parsing, use of_property_read_u32 instead.
- Not to overwrite regulator constraint.
- Refine regulator desc coding.

ChiYuan Huang (4):
dt-binding: mfd: Add Richtek RT5120 PMIC support
mfd: rt5120: Add Richtek PMIC support
regulator: rt5120: Add PMIC regulator support
input: misc: rt5120: Add power key support

 .../devicetree/bindings/mfd/richtek,rt5120.yaml    | 178 +++++++++
 drivers/input/misc/Kconfig                         |   9 +
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/rt5120-pwrkey.c                 | 115 ++++++
 drivers/mfd/Kconfig                                |  12 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/rt5120.c                               | 125 ++++++
 drivers/regulator/Kconfig                          |  10 +
 drivers/regulator/Makefile                         |   1 +
 drivers/regulator/rt5120-regulator.c               | 420 +++++++++++++++++++++
 10 files changed, 872 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5120.yaml
 create mode 100644 drivers/input/misc/rt5120-pwrkey.c
 create mode 100644 drivers/mfd/rt5120.c
 create mode 100644 drivers/regulator/rt5120-regulator.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/4 dt-binding: mfd: Add Richtek RT5120 PMIC support

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC devicetree document.

---
Since v2:
- Add 'unevaluatedProperties: false' for regulator buck1~4/ldo/exten.
- Fix indention and remove status for powerkey.
- Refine powerkey description for more HW details.

---
 .../devicetree/bindings/mfd/richtek,rt5120.yaml    | 178 +++++++++++++++++++++
 1 file changed, 178 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5120.yaml
Documentation/devicetree/bindings/mfd/richtek,rt5120.yaml new file +178 -0
new file mode 100644
index 00000000..f73b8b2
@@ -0,0 +1,178 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/richtek,rt5120.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT5120 PMIC
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+
+description: |
+  The RT5120 provides four high-efficiency buck converters and one LDO voltage
+  regulator. The device is targeted at providingthe processor voltage, memory,
+  I/O, and peripheral rails in home entertainment devices. The I2C interface is
+  used for dynamic voltage scaling of the processor voltage, power rails on/off
+  sequence control, operation mode selection.
+
+properties:
+  compatible:
+    enum:
+      - richtek,rt5120
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 1
+
+  wakeup-source: true
+
+  richtek,enable-undervolt-hiccup:
+    type: boolean
+    description: |
+      If used, under voltage protection trigger hiccup behavior, else latchup as
+      default
+
+  richtek,enable-overvolt-hiccup:
+    type: boolean
+    description:
+      Like as 'enable-uv-hiccup', it configures over voltage protection to
+      hiccup, else latchup as default
+
+  vin1-supply:
+    description: phandle for buck1 input power source
+
+  vin2-supply:
+    description: phandle for buck2 input power source
+
+  vin3-supply:
+    description: phandle for buck3 input power source
+
+  vin4-supply:
+    description: phandle for buck4 input power source
+
+  vinldo-supply:
+    description: phandle for ldo input power source
+
+  regulators:
+    type: object
+
+    patternProperties:
+      "^buck[1-4]$":
+        type: object
+        $ref: /schemas/regulator/regulator.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          regulator-allowed-modes:
+            description: |
+              Used to specify the allowed buck converter operating mode
+              mode mapping:
+                0: auto mode
+                1: force pwm mode
+            items:
+              enum: [0, 1]
+
+      "^(ldo|exten)$":
+        type: object
+        $ref: /schemas/regulator/regulator.yaml#
+        unevaluatedProperties: false
+
+    additionalProperties: false
+
+  powerkey:
+    type: object
+    description:
+      PON key that connected to RT5120 PMIC.
+
+    properties:
+      compatible:
+        enum:
+          - richtek,rt5120-pwrkey
+
+    required:
+      - compatible
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - '#interrupt-cells'
+  - interrupt-controller
+  - regulators
+  - powerkey
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      pmic@62 {
+        compatible = "richtek,rt5120";
+        reg = <0x62>;
+        interrupts-extended = <&gpio_intc 32 IRQ_TYPE_LEVEL_LOW>;
+        interrupt-controller;
+        #interrupt-cells = <1>;
+        wakeup-source;
+
+        regulators {
+          buck1 {
+            regulator-name = "rt5120-buck1";
+            regulator-min-microvolt = <600000>;
+            regulator-max-microvolt = <1393750>;
+            regulator-allowed-modes = <0 1>;
+            regulator-boot-on;
+          };
+          buck2 {
+            regulator-name = "rt5120-buck2";
+            regulator-min-microvolt = <1100000>;
+            regulator-max-microvolt = <1100000>;
+            regulator-allowed-modes = <0 1>;
+            regulator-always-on;
+          };
+          buck3 {
+            regulator-name = "rt5120-buck3";
+            regulator-min-microvolt = <1800000>;
+            regulator-max-microvolt = <1800000>;
+            regulator-allowed-modes = <0 1>;
+            regulator-always-on;
+          };
+          buck4 {
+            regulator-name = "rt5120-buck4";
+            regulator-min-microvolt = <3300000>;
+            regulator-max-microvolt = <3300000>;
+            regulator-allowed-modes = <0 1>;
+            regulator-always-on;
+          };
+          ldo {
+            regulator-name = "rt5120-ldo";
+            regulator-min-microvolt = <1800000>;
+            regulator-max-microvolt = <1800000>;
+            regulator-always-on;
+          };
+          exten {
+            regulator-name = "rt5120-exten";
+            regulator-min-microvolt = <3000000>;
+            regulator-max-microvolt = <3000000>;
+            regulator-always-on;
+          };
+        };
+        powerkey {
+          compatible = "richtek,rt5120-pwrkey";
+        };
+      };
+    };
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v2 2/4 mfd: rt5120: Add Richtek PMIC support

In reply to cy_huang

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

---
 drivers/mfd/Kconfig  |  12 +++++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/rt5120.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 drivers/mfd/rt5120.c
drivers/mfd/Kconfig +12 -0
index 3b59456..866619c 100644
@@ -1127,6 +1127,18 @@ config MFD_RT5033
 	  sub-devices like charger, fuel gauge, flash LED, current source,
 	  LDO and Buck.
 
+config MFD_RT5120
+	tristate "Richtek RT5120 Power Management IC"
+	depends on I2C
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	help
+	  The enables support for Richtek RT5120 PMIC. It includes four high
+	  efficiency buck converters and one LDO voltage regulator. The device
+	  is targeted at providing the CPU voltage, memory, I/O and peripheral
+	  power rails in home entertainment devices.
+
 config MFD_RC5T583
 	bool "Ricoh RC5T583 Power Management system device"
 	depends on I2C=y
drivers/mfd/Makefile +1 -0
index 858cacf..27e8add 100644
@@ -234,6 +234,7 @@ obj-$(CONFIG_MFD_HI655X_PMIC)   += hi655x-pmic.o
 obj-$(CONFIG_MFD_DLN2)		+= dln2.o
 obj-$(CONFIG_MFD_RT4831)	+= rt4831.o
 obj-$(CONFIG_MFD_RT5033)	+= rt5033.o
+obj-$(CONFIG_MFD_RT5120)	+= rt5120.o
 obj-$(CONFIG_MFD_SKY81452)	+= sky81452.o
 
 intel-soc-pmic-objs		:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
drivers/mfd/rt5120.c new file +125 -0

125 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#12 lore raw

PATCH v2 3/4 regulator: rt5120: Add PMIC regulator support

In reply to cy_huang

From: ChiYuan Huang <[email protected]>

Add RT5120 PMIC regulator support.

It integrates 4 buck convertes, 1 LDO voltage regulator, 1 external enable signal to control the external power source.

---
Since v2:
- Add 'unevaluatedProperties: false' for regulator buck1~4/ldo/exten.
- Fix indention and remove status for powerkey.
- Refine powerkey description for more HW details.

---
 drivers/regulator/Kconfig            |  10 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/rt5120-regulator.c | 420 +++++++++++++++++++++++++++++++++++
 3 files changed, 431 insertions(+)
 create mode 100644 drivers/regulator/rt5120-regulator.c
drivers/regulator/Kconfig +10 -0
index cbe0f96..d777f71 100644
@@ -1047,6 +1047,16 @@ config REGULATOR_RT5033
 	  RT5033 PMIC. The device supports multiple regulators like
 	  current source, LDO and Buck.
 
+config REGULATOR_RT5120
+	tristate "Richtek RT5120 PMIC Regulators"
+	depends on MFD_RT5120
+	help
+	  This adds support for voltage regulator in Richtek RT5120 PMIC.
+	  It integrates 4 channels buck controller, 1 channel LDO, 1 EXTEN
+	  to control external power source. Only BUCK1 is adjustable from
+	  600mV to 1395mV, per step 6.250mV. The others are all fixed voltage
+	  by external hardware circuit.
+
 config REGULATOR_RT5190A
 	tristate "Richtek RT5190A PMIC"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 8d3ee8b6..b74ca8f 100644
@@ -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_RT5120)	+= rt5120-regulator.o
 obj-$(CONFIG_REGULATOR_RT5190A) += rt5190a-regulator.o
 obj-$(CONFIG_REGULATOR_RT5759)	+= rt5759-regulator.o
 obj-$(CONFIG_REGULATOR_RT6160)	+= rt6160-regulator.o
drivers/regulator/rt5120-regulator.c new file +420 -0

420 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#13 lore raw

PATCH v2 4/4 input: misc: rt5120: Add power key support

In reply to cy_huang

From: ChiYuan Huang <[email protected]>

Add RT5120 PMIC power key support.

---
 drivers/input/misc/Kconfig         |   9 +++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/rt5120-pwrkey.c | 115 +++++++++++++++++++++++++++++++++++++
 3 files changed, 125 insertions(+)
 create mode 100644 drivers/input/misc/rt5120-pwrkey.c
drivers/input/misc/Kconfig +9 -0
index a18ab73..0b976f8 100644
@@ -891,6 +891,15 @@ config INPUT_SC27XX_VIBRA
 	  To compile this driver as a module, choose M here. The module will
 	  be called sc27xx_vibra.
 
+config INPUT_RT5120_PWRKEY
+	tristate "RT5120 PMIC power key support"
+	depends on MFD_RT5120
+	help
+	  This enables support for RT5120 PMIC power key driver.
+
+	  To compile this driver as a module, choose M here. the module will
+	  be called rt5120-pwerkey.
+
 config INPUT_STPMIC1_ONKEY
 	tristate "STPMIC1 PMIC Onkey support"
 	depends on MFD_STPMIC1
drivers/input/misc/Makefile +1 -0
index 28dfc44..d1fb00e 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON)	+= rave-sp-pwrbutton.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)	+= rb532_button.o
 obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)	+= regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON)	+= retu-pwrbutton.o
+obj-$(CONFIG_INPUT_RT5120_PWRKEY)	+= rt5120-pwrkey.o
 obj-$(CONFIG_INPUT_AXP20X_PEK)		+= axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)	+= rotary_encoder.o
 obj-$(CONFIG_INPUT_RK805_PWRKEY)	+= rk805-pwrkey.o
drivers/input/misc/rt5120-pwrkey.c new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#16 lore raw

Re: (subset) [PATCH v2 0/4] Add Richtek RT5120 PMIC support

In reply to cy_huang
Quoted 14 lines · cy_huang

From: ChiYuan Huang <[email protected]>

This patch series is to add Richtek RT5120 PMIC support.
In RT5120, it integrates four channels of buck converter, one channel of LDO, and one external enable channel to control the external power source.

Since v2:
- Add 'unevaluatedProperties: false' for regulator buck1~4/ldo/exten.
- Fix indention and remove status for powerkey.
- Refine powerkey description for more HW details.
- For the regulator property parsing, use of_property_read_u32 instead.
- Not to overwrite regulator constraint.
- Refine regulator desc coding.

Quoted 1 line

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[3/4] regulator: rt5120: Add PMIC regulator support

      commit: c0216c0e68f736d20ac02bbaaaf4a216c10e53af

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

#4 lore raw

Re: [PATCH v2 2/4] mfd: rt5120: Add Richtek PMIC support

In reply to cy_huang
Quoted 3 lines · cy_huang

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

Why a whole new driver?

How different is this to rt5033?

Looks like this could easily be woven into this existing support?

Quoted 174 lines
---
 drivers/mfd/Kconfig  |  12 +++++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/rt5120.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 drivers/mfd/rt5120.c
drivers/mfd/Kconfig +12 -0
index 3b59456..866619c 100644
@@ -1127,6 +1127,18 @@ config MFD_RT5033
 	  sub-devices like charger, fuel gauge, flash LED, current source,
 	  LDO and Buck.
 
+config MFD_RT5120
+	tristate "Richtek RT5120 Power Management IC"
+	depends on I2C
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	help
+	  The enables support for Richtek RT5120 PMIC. It includes four high
+	  efficiency buck converters and one LDO voltage regulator. The device
+	  is targeted at providing the CPU voltage, memory, I/O and peripheral
+	  power rails in home entertainment devices.
+
 config MFD_RC5T583
 	bool "Ricoh RC5T583 Power Management system device"
 	depends on I2C=y
drivers/mfd/Makefile +1 -0
index 858cacf..27e8add 100644
@@ -234,6 +234,7 @@ obj-$(CONFIG_MFD_HI655X_PMIC)   += hi655x-pmic.o
 obj-$(CONFIG_MFD_DLN2)		+= dln2.o
 obj-$(CONFIG_MFD_RT4831)	+= rt4831.o
 obj-$(CONFIG_MFD_RT5033)	+= rt5033.o
+obj-$(CONFIG_MFD_RT5120)	+= rt5120.o
 obj-$(CONFIG_MFD_SKY81452)	+= sky81452.o
 
 intel-soc-pmic-objs		:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
drivers/mfd/rt5120.c new file +125 -0
new file mode 100644
index 00000000..e7c5f3c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <linux/i2c.h>
+#include <linux/kernel.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/regmap.h>
+
+#define RT5120_REG_INTENABLE	0x1D
+#define RT5120_REG_INTSTAT	0x1E
+#define RT5120_REG_FZCMODE	0x44
+
+#define RT5120_INT_HOTDIE	0
+#define RT5120_INT_PWRKEY_REL	5
+#define RT5120_INT_PWRKEY_PRESS	6
+
+static const struct regmap_range rt5120_rd_yes_ranges[] = {
+	regmap_reg_range(0x03, 0x13),
+	regmap_reg_range(0x1c, 0x20),
+	regmap_reg_range(0x44, 0x44)
+};
+
+static const struct regmap_range rt5120_wr_yes_ranges[] = {
+	regmap_reg_range(0x06, 0x13),
+	regmap_reg_range(0x1c, 0x20),
+	regmap_reg_range(0x44, 0x44)
+};
+
+static const struct regmap_access_table rt5120_rd_table = {
+	.yes_ranges = rt5120_rd_yes_ranges,
+	.n_yes_ranges = ARRAY_SIZE(rt5120_rd_yes_ranges),
+};
+
+static const struct regmap_access_table rt5120_wr_table = {
+	.yes_ranges = rt5120_wr_yes_ranges,
+	.n_yes_ranges = ARRAY_SIZE(rt5120_wr_yes_ranges),
+};
+
+static const struct regmap_config rt5120_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = RT5120_REG_FZCMODE,
+
+	.wr_table = &rt5120_wr_table,
+	.rd_table = &rt5120_rd_table,
+};
+
+static const struct regmap_irq rt5120_irqs[] = {
+	REGMAP_IRQ_REG_LINE(RT5120_INT_HOTDIE, 8),
+	REGMAP_IRQ_REG_LINE(RT5120_INT_PWRKEY_REL, 8),
+	REGMAP_IRQ_REG_LINE(RT5120_INT_PWRKEY_PRESS, 8)
+};
+
+static const struct regmap_irq_chip rt5120_irq_chip = {
+	.name = "rt5120-pmic",
+	.status_base = RT5120_REG_INTSTAT,
+	.mask_base = RT5120_REG_INTENABLE,
+	.ack_base = RT5120_REG_INTSTAT,
+	.mask_invert = true,
+	.use_ack = true,
+	.num_regs = 1,
+	.irqs = rt5120_irqs,
+	.num_irqs = ARRAY_SIZE(rt5120_irqs),
+};
+
+static const struct resource rt5120_regulator_resources[] = {
+	DEFINE_RES_IRQ(RT5120_INT_HOTDIE)
+};
+
+static const struct resource rt5120_pwrkey_resources[] = {
+	DEFINE_RES_IRQ_NAMED(RT5120_INT_PWRKEY_PRESS, "pwrkey-press"),
+	DEFINE_RES_IRQ_NAMED(RT5120_INT_PWRKEY_REL, "pwrkey-release")
+};
+
+static const struct mfd_cell rt5120_devs[] = {
+	MFD_CELL_RES("rt5120-regulator", rt5120_regulator_resources),
+	MFD_CELL_OF("rt5120-pwrkey", rt5120_pwrkey_resources, NULL, 0, 0,
+		    "richtek,rt5120-pwrkey")
+};
+
+static int rt5120_probe(struct i2c_client *i2c)
+{
+	struct regmap *regmap;
+	struct regmap_irq_chip_data *irq_data;
+	int ret;
+
+	regmap = devm_regmap_init_i2c(i2c, &rt5120_regmap_config);
+	if (IS_ERR(regmap)) {
+		ret = PTR_ERR(regmap);
+		dev_err(&i2c->dev, "Failed to init regmap (%d)\n", ret);
+		return ret;
+	}
+
+	ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq,
+				       IRQF_ONESHOT, 0, &rt5120_irq_chip,
+				       &irq_data);
+	if (ret) {
+		dev_err(&i2c->dev, "Failed to add irq chip (%d)\n", ret);
+		return ret;
+	}
+
+	return devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, rt5120_devs,
+				    ARRAY_SIZE(rt5120_devs), NULL, 0,
+				    regmap_irq_get_domain(irq_data));
+}
+
+static const struct of_device_id rt5120_device_match_table[] = {
+	{ .compatible = "richtek,rt5120", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, rt5120_device_match_table);
+
+static struct i2c_driver rt5120_driver = {
+	.driver = {
+		.name = "rt5120",
+		.of_match_table = rt5120_device_match_table,
+	},
+	.probe_new = rt5120_probe,
+};
+module_i2c_driver(rt5120_driver);
+
+MODULE_AUTHOR("ChiYuan Huang <[email protected]>");
+MODULE_DESCRIPTION("Richtek RT5120 I2C driver");
+MODULE_LICENSE("GPL v2");
Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw

Re: [PATCH v2 2/4] mfd: rt5120: Add Richtek PMIC support

Lee Jones <[email protected]> 於 2022年6月27日 週一 晚上10:22寫道:

Quoted 13 lines · cy_huang
Quoted 4 lines

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

Why a whole new driver?

How different is this to rt5033?

Looks like this could easily be woven into this existing support?

It's different with the function domain.
RT5033 is most like as the SubPMIC that includes PMU (battery charger/gauge/led/few buck and ldo)
RT5120 is a main PMIC with default-on power that follows the boot on sequence. RT5120 only integrates regulator and power key report module.

Quoted 180 lines
Quoted 164 lines
---
 drivers/mfd/Kconfig  |  12 +++++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/rt5120.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 drivers/mfd/rt5120.c
drivers/mfd/Kconfig +12 -0
index 3b59456..866619c 100644
@@ -1127,6 +1127,18 @@ config MFD_RT5033
        sub-devices like charger, fuel gauge, flash LED, current source,
        LDO and Buck.
 
+config MFD_RT5120
+     tristate "Richtek RT5120 Power Management IC"
+     depends on I2C
+     select MFD_CORE
+     select REGMAP_I2C
+     select REGMAP_IRQ
+     help
+       The enables support for Richtek RT5120 PMIC. It includes four high
+       efficiency buck converters and one LDO voltage regulator. The device
+       is targeted at providing the CPU voltage, memory, I/O and peripheral
+       power rails in home entertainment devices.
+
 config MFD_RC5T583
      bool "Ricoh RC5T583 Power Management system device"
      depends on I2C=y
drivers/mfd/Makefile +1 -0
index 858cacf..27e8add 100644
@@ -234,6 +234,7 @@ obj-$(CONFIG_MFD_HI655X_PMIC)   += hi655x-pmic.o
 obj-$(CONFIG_MFD_DLN2)               += dln2.o
 obj-$(CONFIG_MFD_RT4831)     += rt4831.o
 obj-$(CONFIG_MFD_RT5033)     += rt5033.o
+obj-$(CONFIG_MFD_RT5120)     += rt5120.o
 obj-$(CONFIG_MFD_SKY81452)   += sky81452.o
 
 intel-soc-pmic-objs          := intel_soc_pmic_core.o intel_soc_pmic_crc.o
drivers/mfd/rt5120.c new file +115 -0
new file mode 100644
index 00000000..e7c5f3c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <linux/i2c.h>
+#include <linux/kernel.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/regmap.h>
+
+#define RT5120_REG_INTENABLE 0x1D
+#define RT5120_REG_INTSTAT   0x1E
+#define RT5120_REG_FZCMODE   0x44
+
+#define RT5120_INT_HOTDIE    0
+#define RT5120_INT_PWRKEY_REL        5
+#define RT5120_INT_PWRKEY_PRESS      6
+
+static const struct regmap_range rt5120_rd_yes_ranges[] = {
+     regmap_reg_range(0x03, 0x13),
+     regmap_reg_range(0x1c, 0x20),
+     regmap_reg_range(0x44, 0x44)
+};
+
+static const struct regmap_range rt5120_wr_yes_ranges[] = {
+     regmap_reg_range(0x06, 0x13),
+     regmap_reg_range(0x1c, 0x20),
+     regmap_reg_range(0x44, 0x44)
+};
+
+static const struct regmap_access_table rt5120_rd_table = {
+     .yes_ranges = rt5120_rd_yes_ranges,
+     .n_yes_ranges = ARRAY_SIZE(rt5120_rd_yes_ranges),
+};
+
+static const struct regmap_access_table rt5120_wr_table = {
+     .yes_ranges = rt5120_wr_yes_ranges,
+     .n_yes_ranges = ARRAY_SIZE(rt5120_wr_yes_ranges),
+};
+
+static const struct regmap_config rt5120_regmap_config = {
+     .reg_bits = 8,
+     .val_bits = 8,
+     .max_register = RT5120_REG_FZCMODE,
+
+     .wr_table = &rt5120_wr_table,
+     .rd_table = &rt5120_rd_table,
+};
+
+static const struct regmap_irq rt5120_irqs[] = {
+     REGMAP_IRQ_REG_LINE(RT5120_INT_HOTDIE, 8),
+     REGMAP_IRQ_REG_LINE(RT5120_INT_PWRKEY_REL, 8),
+     REGMAP_IRQ_REG_LINE(RT5120_INT_PWRKEY_PRESS, 8)
+};
+
+static const struct regmap_irq_chip rt5120_irq_chip = {
+     .name = "rt5120-pmic",
+     .status_base = RT5120_REG_INTSTAT,
+     .mask_base = RT5120_REG_INTENABLE,
+     .ack_base = RT5120_REG_INTSTAT,
+     .mask_invert = true,
+     .use_ack = true,
+     .num_regs = 1,
+     .irqs = rt5120_irqs,
+     .num_irqs = ARRAY_SIZE(rt5120_irqs),
+};
+
+static const struct resource rt5120_regulator_resources[] = {
+     DEFINE_RES_IRQ(RT5120_INT_HOTDIE)
+};
+
+static const struct resource rt5120_pwrkey_resources[] = {
+     DEFINE_RES_IRQ_NAMED(RT5120_INT_PWRKEY_PRESS, "pwrkey-press"),
+     DEFINE_RES_IRQ_NAMED(RT5120_INT_PWRKEY_REL, "pwrkey-release")
+};
+
+static const struct mfd_cell rt5120_devs[] = {
+     MFD_CELL_RES("rt5120-regulator", rt5120_regulator_resources),
+     MFD_CELL_OF("rt5120-pwrkey", rt5120_pwrkey_resources, NULL, 0, 0,
+                 "richtek,rt5120-pwrkey")
+};
+
+static int rt5120_probe(struct i2c_client *i2c)
+{
+     struct regmap *regmap;
+     struct regmap_irq_chip_data *irq_data;
+     int ret;
+
+     regmap = devm_regmap_init_i2c(i2c, &rt5120_regmap_config);
+     if (IS_ERR(regmap)) {
+             ret = PTR_ERR(regmap);
+             dev_err(&i2c->dev, "Failed to init regmap (%d)\n", ret);
+             return ret;
+     }
+
+     ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq,
+                                    IRQF_ONESHOT, 0, &rt5120_irq_chip,
+                                    &irq_data);
+     if (ret) {
+             dev_err(&i2c->dev, "Failed to add irq chip (%d)\n", ret);
+             return ret;
+     }
+
+     return devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, rt5120_devs,
+                                 ARRAY_SIZE(rt5120_devs), NULL, 0,
+                                 regmap_irq_get_domain(irq_data));
+}
+
+static const struct of_device_id rt5120_device_match_table[] = {
+     { .compatible = "richtek,rt5120", },
+     {}
+};
+MODULE_DEVICE_TABLE(of, rt5120_device_match_table);
+
+static struct i2c_driver rt5120_driver = {
+     .driver = {

drivers/mfd/rt5120.c line 125

Quoted 10 lines
drivers/mfd/rt5120.c new file +10 -0
+             .name = "rt5120",
+             .of_match_table = rt5120_device_match_table,
+     },
+     .probe_new = rt5120_probe,
+};
+module_i2c_driver(rt5120_driver);
+
+MODULE_AUTHOR("ChiYuan Huang <[email protected]>");
+MODULE_DESCRIPTION("Richtek RT5120 I2C driver");
+MODULE_LICENSE("GPL v2");

--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services

Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw

Re: [PATCH v2 2/4] mfd: rt5120: Add Richtek PMIC support

HI, Lee:

ChiYuan Huang <[email protected]> 於 2022年6月27日 週一 晚上10:56寫道:

Quoted 13 lines

Lee Jones <[email protected]> 於 2022年6月27日 週一 晚上10:22寫道:

Quoted 11 lines · cy_huang
Quoted 4 lines

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

Why a whole new driver?

How different is this to rt5033?

Quoted 8 lines
Quoted 2 lines

Looks like this could easily be woven into this existing support?

It's different with the function domain.
RT5033 is most like as the SubPMIC that includes PMU (battery charger/gauge/led/few buck and ldo)
RT5120 is a main PMIC with default-on power that follows the boot on sequence. RT5120 only integrates regulator and power key report module.

Since I have explained the chip difference, do you still think it's better to merge this code into rt5033 mfd?

Quoted 180 lines
Quoted 180 lines
Quoted 164 lines
---
 drivers/mfd/Kconfig  |  12 +++++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/rt5120.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 drivers/mfd/rt5120.c
drivers/mfd/Kconfig +12 -0
index 3b59456..866619c 100644
@@ -1127,6 +1127,18 @@ config MFD_RT5033
        sub-devices like charger, fuel gauge, flash LED, current source,
        LDO and Buck.
 
+config MFD_RT5120
+     tristate "Richtek RT5120 Power Management IC"
+     depends on I2C
+     select MFD_CORE
+     select REGMAP_I2C
+     select REGMAP_IRQ
+     help
+       The enables support for Richtek RT5120 PMIC. It includes four high
+       efficiency buck converters and one LDO voltage regulator. The device
+       is targeted at providing the CPU voltage, memory, I/O and peripheral
+       power rails in home entertainment devices.
+
 config MFD_RC5T583
      bool "Ricoh RC5T583 Power Management system device"
      depends on I2C=y
drivers/mfd/Makefile +1 -0
index 858cacf..27e8add 100644
@@ -234,6 +234,7 @@ obj-$(CONFIG_MFD_HI655X_PMIC)   += hi655x-pmic.o
 obj-$(CONFIG_MFD_DLN2)               += dln2.o
 obj-$(CONFIG_MFD_RT4831)     += rt4831.o
 obj-$(CONFIG_MFD_RT5033)     += rt5033.o
+obj-$(CONFIG_MFD_RT5120)     += rt5120.o
 obj-$(CONFIG_MFD_SKY81452)   += sky81452.o
 
 intel-soc-pmic-objs          := intel_soc_pmic_core.o intel_soc_pmic_crc.o
drivers/mfd/rt5120.c new file +115 -0
new file mode 100644
index 00000000..e7c5f3c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <linux/i2c.h>
+#include <linux/kernel.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/regmap.h>
+
+#define RT5120_REG_INTENABLE 0x1D
+#define RT5120_REG_INTSTAT   0x1E
+#define RT5120_REG_FZCMODE   0x44
+
+#define RT5120_INT_HOTDIE    0
+#define RT5120_INT_PWRKEY_REL        5
+#define RT5120_INT_PWRKEY_PRESS      6
+
+static const struct regmap_range rt5120_rd_yes_ranges[] = {
+     regmap_reg_range(0x03, 0x13),
+     regmap_reg_range(0x1c, 0x20),
+     regmap_reg_range(0x44, 0x44)
+};
+
+static const struct regmap_range rt5120_wr_yes_ranges[] = {
+     regmap_reg_range(0x06, 0x13),
+     regmap_reg_range(0x1c, 0x20),
+     regmap_reg_range(0x44, 0x44)
+};
+
+static const struct regmap_access_table rt5120_rd_table = {
+     .yes_ranges = rt5120_rd_yes_ranges,
+     .n_yes_ranges = ARRAY_SIZE(rt5120_rd_yes_ranges),
+};
+
+static const struct regmap_access_table rt5120_wr_table = {
+     .yes_ranges = rt5120_wr_yes_ranges,
+     .n_yes_ranges = ARRAY_SIZE(rt5120_wr_yes_ranges),
+};
+
+static const struct regmap_config rt5120_regmap_config = {
+     .reg_bits = 8,
+     .val_bits = 8,
+     .max_register = RT5120_REG_FZCMODE,
+
+     .wr_table = &rt5120_wr_table,
+     .rd_table = &rt5120_rd_table,
+};
+
+static const struct regmap_irq rt5120_irqs[] = {
+     REGMAP_IRQ_REG_LINE(RT5120_INT_HOTDIE, 8),
+     REGMAP_IRQ_REG_LINE(RT5120_INT_PWRKEY_REL, 8),
+     REGMAP_IRQ_REG_LINE(RT5120_INT_PWRKEY_PRESS, 8)
+};
+
+static const struct regmap_irq_chip rt5120_irq_chip = {
+     .name = "rt5120-pmic",
+     .status_base = RT5120_REG_INTSTAT,
+     .mask_base = RT5120_REG_INTENABLE,
+     .ack_base = RT5120_REG_INTSTAT,
+     .mask_invert = true,
+     .use_ack = true,
+     .num_regs = 1,
+     .irqs = rt5120_irqs,
+     .num_irqs = ARRAY_SIZE(rt5120_irqs),
+};
+
+static const struct resource rt5120_regulator_resources[] = {
+     DEFINE_RES_IRQ(RT5120_INT_HOTDIE)
+};
+
+static const struct resource rt5120_pwrkey_resources[] = {
+     DEFINE_RES_IRQ_NAMED(RT5120_INT_PWRKEY_PRESS, "pwrkey-press"),
+     DEFINE_RES_IRQ_NAMED(RT5120_INT_PWRKEY_REL, "pwrkey-release")
+};
+
+static const struct mfd_cell rt5120_devs[] = {
+     MFD_CELL_RES("rt5120-regulator", rt5120_regulator_resources),
+     MFD_CELL_OF("rt5120-pwrkey", rt5120_pwrkey_resources, NULL, 0, 0,
+                 "richtek,rt5120-pwrkey")
+};
+
+static int rt5120_probe(struct i2c_client *i2c)
+{
+     struct regmap *regmap;
+     struct regmap_irq_chip_data *irq_data;
+     int ret;
+
+     regmap = devm_regmap_init_i2c(i2c, &rt5120_regmap_config);
+     if (IS_ERR(regmap)) {
+             ret = PTR_ERR(regmap);
+             dev_err(&i2c->dev, "Failed to init regmap (%d)\n", ret);
+             return ret;
+     }
+
+     ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq,
+                                    IRQF_ONESHOT, 0, &rt5120_irq_chip,
+                                    &irq_data);
+     if (ret) {
+             dev_err(&i2c->dev, "Failed to add irq chip (%d)\n", ret);
+             return ret;
+     }
+
+     return devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, rt5120_devs,
+                                 ARRAY_SIZE(rt5120_devs), NULL, 0,
+                                 regmap_irq_get_domain(irq_data));
+}
+
+static const struct of_device_id rt5120_device_match_table[] = {
+     { .compatible = "richtek,rt5120", },
+     {}
+};
+MODULE_DEVICE_TABLE(of, rt5120_device_match_table);
+
+static struct i2c_driver rt5120_driver = {
+     .driver = {

drivers/mfd/rt5120.c line 125

Quoted 10 lines
drivers/mfd/rt5120.c new file +10 -0
+             .name = "rt5120",
+             .of_match_table = rt5120_device_match_table,
+     },
+     .probe_new = rt5120_probe,
+};
+module_i2c_driver(rt5120_driver);
+
+MODULE_AUTHOR("ChiYuan Huang <[email protected]>");
+MODULE_DESCRIPTION("Richtek RT5120 I2C driver");
+MODULE_LICENSE("GPL v2");

--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services

Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#7 lore raw

Re: [PATCH v2 2/4] mfd: rt5120: Add Richtek PMIC support

Quoted 18 lines · ChiYuan Huang

HI, Lee:

ChiYuan Huang <[email protected]> 於 2022年6月27日 週一 晚上10:56寫道:

Quoted 15 lines

Lee Jones <[email protected]> 於 2022年6月27日 週一 晚上10:22寫道:

Quoted 13 lines · cy_huang
Quoted 4 lines

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

Why a whole new driver?

How different is this to rt5033?

Looks like this could easily be woven into this existing support?

Quoted 8 lines
Quoted 6 lines

It's different with the function domain.
RT5033 is most like as the SubPMIC that includes PMU (battery charger/gauge/led/few buck and ldo)
RT5120 is a main PMIC with default-on power that follows the boot on sequence. RT5120 only integrates regulator and power key report module.

Since I have explained the chip difference, do you still think it's better to merge this code into rt5033 mfd?

I think it's okay to group devices which are similar but not exactly the same, if they can be. The integration of this device into the other looks trivial to my naive eyes.

A PMIC is a PMIC, main or sub.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
 drivers/mfd/Kconfig  |  12 +++++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/rt5120.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 drivers/mfd/rt5120.c
Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#8 lore raw

Re: [PATCH v2 2/4] mfd: rt5120: Add Richtek PMIC support

Lee Jones <[email protected]> 於 2022年7月1日 週五 下午3:38寫道:

Quoted 27 lines · ChiYuan Huang
Quoted 25 lines

HI, Lee:

ChiYuan Huang <[email protected]> 於 2022年6月27日 週一 晚上10:56寫道:

Quoted 21 lines

Lee Jones <[email protected]> 於 2022年6月27日 週一 晚上10:22寫道:

Quoted 13 lines · cy_huang
Quoted 4 lines

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

Why a whole new driver?

How different is this to rt5033?

Looks like this could easily be woven into this existing support?

It's different with the function domain.
RT5033 is most like as the SubPMIC that includes PMU (battery charger/gauge/led/few buck and ldo)
RT5120 is a main PMIC with default-on power that follows the boot on sequence. RT5120 only integrates regulator and power key report module.

Quoted 9 lines
Quoted 2 lines

Since I have explained the chip difference, do you still think it's better to merge this code into rt5033 mfd?

I think it's okay to group devices which are similar but not exactly the same, if they can be. The integration of this device into the other looks trivial to my naive eyes.

A PMIC is a PMIC, main or sub.

M.. ok. I will try to group all chip changes like as devices list/regmap_irq/regmap_config ..., etc.
Treat it as one set of chip config and use 'of_device_get_match_data' to get the chip config data.

Quoted 13 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
 drivers/mfd/Kconfig  |  12 +++++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/rt5120.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 drivers/mfd/rt5120.c

--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services

Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#9 lore raw

Re: [PATCH v2 2/4] mfd: rt5120: Add Richtek PMIC support

Hi, Lee:

ChiYuan Huang <[email protected]> 於 2022年7月1日 週五 下午5:56寫道:

Quoted 36 lines

Lee Jones <[email protected]> 於 2022年7月1日 週五 下午3:38寫道:

Quoted 34 lines · ChiYuan Huang
Quoted 19 lines

HI, Lee:

ChiYuan Huang <[email protected]> 於 2022年6月27日 週一 晚上10:56寫道:

Quoted 15 lines

Lee Jones <[email protected]> 於 2022年6月27日 週一 晚上10:22寫道:

Quoted 13 lines · cy_huang
Quoted 4 lines

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

Why a whole new driver?

How different is this to rt5033?

Looks like this could easily be woven into this existing support?

Quoted 8 lines
Quoted 6 lines

It's different with the function domain.
RT5033 is most like as the SubPMIC that includes PMU (battery charger/gauge/led/few buck and ldo)
RT5120 is a main PMIC with default-on power that follows the boot on sequence. RT5120 only integrates regulator and power key report module.

Since I have explained the chip difference, do you still think it's better to merge this code into rt5033 mfd?

I think it's okay to group devices which are similar but not exactly the same, if they can be. The integration of this device into the other looks trivial to my naive eyes.

Quoted 7 lines
Quoted 2 lines

A PMIC is a PMIC, main or sub.

M.. ok. I will try to group all chip changes like as devices list/regmap_irq/regmap_config ..., etc.
Treat it as one set of chip config and use 'of_device_get_match_data' to get the chip config data.

There's a question.
As I know, it's not the same chip series. The rt5033 is submitted from Samsung at 2015. The driver data is also defined in header file.

Do you still suggest to do the merge?
Even in our internal, it's difficult to find a rt5033 EVB for testing.

And one more question is the binding. If yes, for the binding, I need to add rt5033 related.....

Actually, it's a tough work.

Quoted 13 lines
Quoted 13 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
 drivers/mfd/Kconfig  |  12 +++++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/rt5120.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 drivers/mfd/rt5120.c

--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services

Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#10 lore raw

Re: [PATCH v2 2/4] mfd: rt5120: Add Richtek PMIC support

Quoted 51 lines · ChiYuan Huang

Hi, Lee:

ChiYuan Huang <[email protected]> 於 2022年7月1日 週五 下午5:56寫道:

Quoted 36 lines

Lee Jones <[email protected]> 於 2022年7月1日 週五 下午3:38寫道:

Quoted 34 lines · ChiYuan Huang
Quoted 19 lines

HI, Lee:

ChiYuan Huang <[email protected]> 於 2022年6月27日 週一 晚上10:56寫道:

Quoted 15 lines

Lee Jones <[email protected]> 於 2022年6月27日 週一 晚上10:22寫道:

Quoted 13 lines · cy_huang
Quoted 4 lines

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

Why a whole new driver?

How different is this to rt5033?

Looks like this could easily be woven into this existing support?

Quoted 8 lines
Quoted 6 lines

It's different with the function domain.
RT5033 is most like as the SubPMIC that includes PMU (battery charger/gauge/led/few buck and ldo)
RT5120 is a main PMIC with default-on power that follows the boot on sequence. RT5120 only integrates regulator and power key report module.

Since I have explained the chip difference, do you still think it's better to merge this code into rt5033 mfd?

I think it's okay to group devices which are similar but not exactly the same, if they can be. The integration of this device into the other looks trivial to my naive eyes.

Quoted 7 lines
Quoted 2 lines

A PMIC is a PMIC, main or sub.

M.. ok. I will try to group all chip changes like as devices list/regmap_irq/regmap_config ..., etc.
Treat it as one set of chip config and use 'of_device_get_match_data' to get the chip config data.

There's a question.
As I know, it's not the same chip series. The rt5033 is submitted from Samsung at 2015. The driver data is also defined in header file.

Quoted 7 lines

Do you still suggest to do the merge?
Even in our internal, it's difficult to find a rt5033 EVB for testing.

And one more question is the binding. If yes, for the binding, I need to add rt5033 related.....

Actually, it's a tough work.

If it's genuinely difficult to integrate, you can keep them separate.

Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#11 lore raw

Re: [PATCH v2 2/4] mfd: rt5120: Add Richtek PMIC support

Lee Jones <[email protected]> 於 2022年7月4日 週一 下午5:54寫道:

Quoted 57 lines · ChiYuan Huang
Quoted 55 lines

Hi, Lee:

ChiYuan Huang <[email protected]> 於 2022年7月1日 週五 下午5:56寫道:

Quoted 36 lines

Lee Jones <[email protected]> 於 2022年7月1日 週五 下午3:38寫道:

Quoted 34 lines · ChiYuan Huang
Quoted 19 lines

HI, Lee:

ChiYuan Huang <[email protected]> 於 2022年6月27日 週一 晚上10:56寫道:

Quoted 15 lines

Lee Jones <[email protected]> 於 2022年6月27日 週一 晚上10:22寫道:

Quoted 13 lines · cy_huang
Quoted 4 lines

From: ChiYuan Huang <[email protected]>

Add Richtek RT5120 PMIC I2C driver.

Why a whole new driver?

How different is this to rt5033?

Looks like this could easily be woven into this existing support?

Quoted 8 lines
Quoted 6 lines

It's different with the function domain.
RT5033 is most like as the SubPMIC that includes PMU (battery charger/gauge/led/few buck and ldo)
RT5120 is a main PMIC with default-on power that follows the boot on sequence. RT5120 only integrates regulator and power key report module.

Since I have explained the chip difference, do you still think it's better to merge this code into rt5033 mfd?

I think it's okay to group devices which are similar but not exactly the same, if they can be. The integration of this device into the other looks trivial to my naive eyes.

Quoted 7 lines
Quoted 2 lines

A PMIC is a PMIC, main or sub.

M.. ok. I will try to group all chip changes like as devices list/regmap_irq/regmap_config ..., etc.
Treat it as one set of chip config and use 'of_device_get_match_data' to get the chip config data.

There's a question.
As I know, it's not the same chip series. The rt5033 is submitted from Samsung at 2015. The driver data is also defined in header file.

Do you still suggest to do the merge?
Even in our internal, it's difficult to find a rt5033 EVB for testing.

Quoted 7 lines
Quoted 4 lines

And one more question is the binding. If yes, for the binding, I need to add rt5033 related.....

Actually, it's a tough work.

If it's genuinely difficult to integrate, you can keep them separate.

Keep it in this patch series and wait for your reviewing. Hope that I'm not misunderstanding.

Quoted 5 lines

--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services

Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
maintainer
#14 lore raw

Re: [PATCH v2 4/4] input: misc: rt5120: Add power key support

In reply to cy_huang

Hi ChiYuan,

drivers/input/misc/rt5120-pwrkey.c line 40

Quoted 9 lines · cy_huang
drivers/input/misc/rt5120-pwrkey.c new file +9 -0
+
+	is_pressed = !(stat & RT5120_PWRKEYSTAT_MASK);
+
+	if ((is_pressed && irq == priv->press_irq) ||
+	    (!is_pressed  && irq == priv->release_irq)) {
+		input_report_key(priv->input, KEY_POWER, is_pressed);
+		input_sync(priv->input);
+	}
+

What is the reason for checking both the status and interrupt? Can we simply say:

	input_report_key(priv->input, KEY_POWER,
			 !(stat & RT5120_PWRKEYSTAT_MASK));
	input_sync(priv->input);

?

Thanks.

Signature · 1 line
Dmitry
#15 lore raw

Re: [PATCH v2 4/4] input: misc: rt5120: Add power key support

Dmitry Torokhov <[email protected]> 於 2022年7月9日 週六 中午12:53寫道:

Quoted 4 lines

Hi ChiYuan,

On Wed, Jun 22, 2022 at 06:01:44PM +0800, cy_huang wrote:

Quoted 13 lines

drivers/input/misc/rt5120-pwrkey.c line 40

Quoted 9 lines
drivers/input/misc/rt5120-pwrkey.c new file +9 -0
+
+     is_pressed = !(stat & RT5120_PWRKEYSTAT_MASK);
+
+     if ((is_pressed && irq == priv->press_irq) ||
+         (!is_pressed  && irq == priv->release_irq)) {
+             input_report_key(priv->input, KEY_POWER, is_pressed);
+             input_sync(priv->input);
+     }
+

What is the reason for checking both the status and interrupt? Can we simply say:

Just to make sure 'press/release' to matche the current state. In the IC design, it already guarantee press/release interrupt with 50 millisecond debounce time.
But if irq is delayed handling, press and release irq will all be checked. Although irq is one by one, but in that case, pwrkey button up will be reported twice.
I'm not sure whether this case exists or not.

Quoted 7 lines
        input_report_key(priv->input, KEY_POWER,
                         !(stat & RT5120_PWRKEYSTAT_MASK));
        input_sync(priv->input);

?

Yes, but how about the above comment? Is that case 'don't care'?

Quoted 4 lines

Thanks.

--
Dmitry