Skip to contentSkip to conversation

regulator: rt5133: Add RT5133 PMIC regulator Support

PATCH Superseded [email protected] 4 participants 5 messages Jul 21, 2025

Subsystems (2)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 regulator: rt5133: Add RT5133 PMIC regulator Support

From: Jeff Chang <[email protected]>

RT5133 is an intefrated chip. It includes 8 LDOs and 3 GPOs that can be used to drive output high/low purpose. The dependency of the GPO block is internally LDO1 Voltage. If LDO1 voltage output disabled, GPO cannot be used to drive output high. It need to pay more attention on the usage.

---

PATCH v3:
1. Fix typo intefrated -> integrated
2. Remove yaml file
3. Remove soft-start-time-sel property
4. Remove GPL-4.0, using GPL-2.0
5. Using C++ comment
6. Using standard dev_dbg
7. Remove driver version
8. Using dev_dbg for base event occured. And return IRQ_HANDLED 9. Because of CRC8 for IO, we don't use cache for regmap_config 10. Remove tracing logs.
11. Set can_sleep = true for gpio operations.
12. Kconfig add depends on OF

 drivers/regulator/Kconfig            |  13 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/rt5133-regulator.c | 624 +++++++++++++++++++++++++++
 3 files changed, 638 insertions(+)
 create mode 100644 drivers/regulator/rt5133-regulator.c
drivers/regulator/Kconfig +13 -0
index 6d8988387da4..2e0c35449fcb 100644
@@ -1229,6 +1229,19 @@ config REGULATOR_RT5120
 	  600mV to 1395mV, per step 6.250mV. The others are all fixed voltage
 	  by external hardware circuit.
 
+config REGULATOR_RT5133
+	tristate "Richtek RT5133 PMIC Regulators"
+	depends on I2C && GPIOLIB && OF
+	select REGMAP
+	select CRC8
+	select OF_GPIO
+	help
+	  RT5133 is an integrated chip. It includes 8 LDOs and 3 GPOs that
+	  can be used to drive output high/low purpose. The dependency of the
+	  GPO block is internally LDO1 Voltage. If LDO1 voltage output disabled,
+	  GPO cannot be used to drive output high. It need to pay more attention
+	  on the usage.
+
 config REGULATOR_RT5190A
 	tristate "Richtek RT5190A PMIC"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index c0bc7a0f4e67..709384ae0a0c 100644
@@ -145,6 +145,7 @@ obj-$(CONFIG_REGULATOR_RT4803)	+= rt4803.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_RT5133)	+= rt5133-regulator.o
 obj-$(CONFIG_REGULATOR_RT5190A) += rt5190a-regulator.o
 obj-$(CONFIG_REGULATOR_RT5739)	+= rt5739.o
 obj-$(CONFIG_REGULATOR_RT5759)	+= rt5759-regulator.o
drivers/regulator/rt5133-regulator.c new file +624 -0

624 lines not on this page · raw message

Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 2/2 dt-bindings: regulator: Add Richtek RTR5133 DT Binding Documentation

From: Jeff Chang <[email protected]>

---

PATCH v3
1. fix Subject format
2. using correct patches version
3. remove '|'
4. remove allOf: &ref regulator.yaml#
5. remove redundant description
6. move BASE to base property with correct indentation
7. only using lowercase node name
8. make DT_CHECKER_FLAG=-m DT_SCHEMA_FILES=richtek,rt5133.yaml dt_binding_check pass

 .../bindings/regulator/richtek,rt5133.yaml    | 197 ++++++++++++++++++
 1 file changed, 197 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +197 -0
new file mode 100644
index 000000000000..a92e7f775832
@@ -0,0 +1,197 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/richtek,rt5133.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT5133 PMIC Regulator
+
+maintainers:
+  - ShihChia Chang <[email protected]>
+
+description:
+  RT5133 is an integrated chip. It includes 8 LDOs and 3 GPOs that can be
+  used to drive output high/low purpose. The dependency of the GPO block
+  is internally LDO1 Voltage. If LDO1 voltage output disabled, GPO cannot
+  be used to drive output high. It need to pay more attention on the usage.
+
+properties:
+  compatible:
+    enum:
+      - richtek,rt5133
+
+  reg:
+    maxItems: 1
+
+  enable-gpios:
+    maxItems: 1
+
+  wakeup-source: true
+
+  interrupts:
+    maxItems: 1
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  regulators:
+    type: object
+    additionalProperties: false
+
+    properties:
+      base:
+        type: object
+        $ref: regulator.yaml#
+        unevaluatedProperties: false
+        description:
+          Properties for base regulator which for force-off base circuit
+
+        properties:
+          regulator-compatible:
+            description: Compatible string for regulator
+            $ref: /schemas/types.yaml#/definitions/string
+
+          oc-shutdown-all:
+            type: boolean
+            description:
+              Anyone of LDO OC state, shut down all channels.
+
+          pgb-shutdown-all:
+            type: boolean
+            description:
+              Anyone of PGB OC state, shut down all channels.
+
+        required:
+          - regulator-name
+          - regulator-compatible
+
+    patternProperties:
+      "^ldo([1-6])$":
+        type: object
+        $ref: regulator.yaml#
+        unevaluatedProperties: false
+        description:
+          Properties for single LDO regulator
+
+        properties:
+          regulator-compatible:
+            description: Compatible string for regulator
+            $ref: /schemas/types.yaml#/definitions/string
+
+        required:
+          - regulator-name
+          - regulator-compatible
+
+      "^ldo([7-8])$":
+        type: object
+        $ref: regulator.yaml#
+        unevaluatedProperties: false
+        description:
+          Properties for single LDO regulator
+
+        properties:
+          regulator-compatible:
+            description: Compatible string for regulator
+            $ref: /schemas/types.yaml#/definitions/string
+
+          rt5133-ldo1-supply:
+            description: |
+              Only for ldo7 ldo8, pvin7 and pvin8 reference design are RT5133 ldo1.
+              If not connect to ldo1 vout, this property for pvin7 and pvin8 is necessary.
+
+        required:
+          - regulator-name
+          - regulator-compatible
+
+required:
+  - compatible
+  - reg
+  - interrupts-extended
+  - wakeup-source
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      rt5133: rt5133@18 {
+        compatible = "richtek,rt5133";
+        reg = <0x18>;
+        wakeup-source;
+        interrupts-extended = <&pio 187 0x0>;
+        enable-gpios = <&pio 186 0x0>;
+        gpio-controller;
+        #gpio-cells = <2>;
+        regulators {
+          base {
+            regulator-compatible = "BASE";
+            regulator-name = "rt5133,base";
+            oc-shutdown-all;
+            pgb-shutdown-all;
+          };
+          rt5133_ldo1: ldo1 {
+            regulator-compatible = "LDO1";
+            regulator-name = "rt5133-ldo1";
+            regulator-min-microvolt = <1800000>;
+            regulator-max-microvolt = <3199998>;
+            regulator-active-discharge = <1>;
+          };
+          rt5133_ldo2: ldo2 {
+            regulator-compatible = "LDO2";
+            regulator-name = "rt5133-ldo2";
+            regulator-min-microvolt = <1800000>;
+            regulator-max-microvolt = <3200000>;
+            regulator-active-discharge = <1>;
+          };
+          rt5133_ldo3: ldo3 {
+            regulator-compatible = "LDO3";
+            regulator-name = "rt5133-ldo3";
+            regulator-min-microvolt = <1700000>;
+            regulator-max-microvolt = <3000000>;
+            regulator-active-discharge = <1>;
+          };
+          rt5133_ldo4: ldo4 {
+            regulator-compatible = "LDO4";
+            regulator-name = "rt5133-ldo4";
+            regulator-min-microvolt = <1700000>;
+            regulator-max-microvolt = <3000000>;
+            regulator-active-discharge = <1>;
+          };
+          rt5133_ldo5: ldo5 {
+            regulator-compatible = "LDO5";
+            regulator-name = "rt5133-ldo5";
+            regulator-min-microvolt = <1700000>;
+            regulator-max-microvolt = <3000000>;
+            regulator-active-discharge = <1>;
+          };
+          rt5133_ldo6: ldo6 {
+            regulator-compatible = "LDO6";
+            regulator-name = "rt5133-ldo6";
+            regulator-min-microvolt = <1700000>;
+            regulator-max-microvolt = <3000000>;
+            regulator-active-discharge = <1>;
+          };
+          rt5133_ldo7: ldo7 {
+            regulator-compatible = "LDO7";
+            regulator-name = "rt5133-ldo7";
+            regulator-min-microvolt = <900000>;
+            regulator-max-microvolt = <1200000>;
+            regulator-active-discharge = <1>;
+            rt5133-ldo1-supply = <&rt5133_ldo1>;
+          };
+          rt5133_ldo8: ldo8 {
+            regulator-compatible = "LDO8";
+            regulator-name = "rt5133-ldo8";
+            regulator-min-microvolt = <855000>;
+            regulator-max-microvolt = <1200000>;
+            regulator-active-discharge = <1>;
+            rt5133-ldo1-supply = <&rt5133_ldo1>;
+          };
+        };
+      };
+    };
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v3 2/2] dt-bindings: regulator: Add Richtek RTR5133 DT Binding Documentation

Quoted 2 lines · On Mon, Jul 21, 2025 at 02:01:35PM +0800, [email protected] wrote:

From: Jeff Chang <[email protected]>

Missing commit msg.

Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

Please use subject prefixes matching the subsystem. You can get them for example with 'git log --oneline -- DIRECTORY_OR_FILE' on the directory your patch is touching. For bindings, the preferred subjects are explained here:
https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters

I already asked for it. Did you really read what I linked last time?

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

I already asked for it, so you ignored another comment. Why are you not responding or implementing the comments?

Bindings go before users, so please re-order patches (see submitting patches in DT dir).

Quoted 30 lines

---

PATCH v3
1. fix Subject format
2. using correct patches version
3. remove '|'
4. remove allOf: &ref regulator.yaml#
5. remove redundant description
6. move BASE to base property with correct indentation
7. only using lowercase node name
8. make DT_CHECKER_FLAG=-m DT_SCHEMA_FILES=richtek,rt5133.yaml dt_binding_check pass

 .../bindings/regulator/richtek,rt5133.yaml    | 197 ++++++++++++++++++
 1 file changed, 197 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +6 -0
new file mode 100644
index 000000000000..a92e7f775832
@@ -0,0 +1,197 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/richtek,rt5133.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 16

Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +10 -0
+title: Richtek RT5133 PMIC Regulator
+
+maintainers:
+  - ShihChia Chang <[email protected]>
+
+description:
+  RT5133 is an integrated chip. It includes 8 LDOs and 3 GPOs that can be
+  used to drive output high/low purpose. The dependency of the GPO block
+  is internally LDO1 Voltage. If LDO1 voltage output disabled, GPO cannot
+  be used to drive output high. It need to pay more attention on the usage.

Last statement does not feel relevant.

Quoted 23 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +23 -0
+
+properties:
+  compatible:
+    enum:
+      - richtek,rt5133
+
+  reg:
+    maxItems: 1
+
+  enable-gpios:
+    maxItems: 1
+
+  wakeup-source: true
+
+  interrupts:
+    maxItems: 1
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  regulators:

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +10 -0
+    type: object
+    additionalProperties: false
+
+    properties:
+      base:
+        type: object
+        $ref: regulator.yaml#
+        unevaluatedProperties: false
+        description:
+          Properties for base regulator which for force-off base circuit

That's not a regulator supply or you need to provide proper description of hardware.

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 54

Quoted 5 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +5 -0
+
+        properties:
+          regulator-compatible:
+            description: Compatible string for regulator
+            $ref: /schemas/types.yaml#/definitions/string

Drop property.

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 56

Quoted 2 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +2 -0
+
+          oc-shutdown-all:

Missing vendor prefix.

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 59

Quoted 3 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +3 -0
+            type: boolean
+            description:
+              Anyone of LDO OC state, shut down all channels.

I don't understand the description at all.

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 64

Quoted 5 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +5 -0
+
+          pgb-shutdown-all:
+            type: boolean
+            description:
+              Anyone of PGB OC state, shut down all channels.

Same problems here

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 68

Quoted 4 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +4 -0
+
+        required:
+          - regulator-name
+          - regulator-compatible

No, drop compatible. Please read the bindings.

Quoted 33 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +33 -0
+
+    patternProperties:
+      "^ldo([1-6])$":
+        type: object
+        $ref: regulator.yaml#
+        unevaluatedProperties: false
+        description:
+          Properties for single LDO regulator
+
+        properties:
+          regulator-compatible:
+            description: Compatible string for regulator
+            $ref: /schemas/types.yaml#/definitions/string
+
+        required:
+          - regulator-name
+          - regulator-compatible
+
+      "^ldo([7-8])$":
+        type: object
+        $ref: regulator.yaml#
+        unevaluatedProperties: false
+        description:
+          Properties for single LDO regulator
+
+        properties:
+          regulator-compatible:
+            description: Compatible string for regulator
+            $ref: /schemas/types.yaml#/definitions/string
+
+          rt5133-ldo1-supply:
+            description: |
+              Only for ldo7 ldo8, pvin7 and pvin8 reference design are RT5133 ldo1.

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 111

Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +10 -0
+              If not connect to ldo1 vout, this property for pvin7 and pvin8 is necessary.
+
+        required:
+          - regulator-name
+          - regulator-compatible
+
+required:
+  - compatible
+  - reg
+  - interrupts-extended

interrupts instead

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 122

Quoted 11 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +11 -0
+  - wakeup-source
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      rt5133: rt5133@18 {

Drop unused labels.

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 126

Quoted 4 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +4 -0
+        compatible = "richtek,rt5133";
+        reg = <0x18>;
+        wakeup-source;
+        interrupts-extended = <&pio 187 0x0>;

Use proper defines

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 127

Quoted 1 line
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +1 -0
+        enable-gpios = <&pio 186 0x0>;

Use proper defines.

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 137

Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +10 -0
+        gpio-controller;
+        #gpio-cells = <2>;
+        regulators {
+          base {
+            regulator-compatible = "BASE";
+            regulator-name = "rt5133,base";
+            oc-shutdown-all;
+            pgb-shutdown-all;
+          };
+          rt5133_ldo1: ldo1 {

Drop unused labels.

Best regards,
Krzysztof

maintainer
#3 lore raw

Re: [PATCH v3 2/2] dt-bindings: regulator: Add Richtek RTR5133 DT Binding Documentation

In reply to [email protected]
Quoted 68 lines · On Mon, Jul 21, 2025 at 02:01:35PM +0800, [email protected] wrote:

From: Jeff Chang <[email protected]>

---

PATCH v3
1. fix Subject format
2. using correct patches version
3. remove '|'
4. remove allOf: &ref regulator.yaml#
5. remove redundant description
6. move BASE to base property with correct indentation
7. only using lowercase node name
8. make DT_CHECKER_FLAG=-m DT_SCHEMA_FILES=richtek,rt5133.yaml dt_binding_check pass

 .../bindings/regulator/richtek,rt5133.yaml    | 197 ++++++++++++++++++
 1 file changed, 197 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +42 -0
new file mode 100644
index 000000000000..a92e7f775832
@@ -0,0 +1,197 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/richtek,rt5133.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT5133 PMIC Regulator
+
+maintainers:
+  - ShihChia Chang <[email protected]>
+
+description:
+  RT5133 is an integrated chip. It includes 8 LDOs and 3 GPOs that can be
+  used to drive output high/low purpose. The dependency of the GPO block
+  is internally LDO1 Voltage. If LDO1 voltage output disabled, GPO cannot
+  be used to drive output high. It need to pay more attention on the usage.
+
+properties:
+  compatible:
+    enum:
+      - richtek,rt5133
+
+  reg:
+    maxItems: 1
+
+  enable-gpios:
+    maxItems: 1
+
+  wakeup-source: true
+
+  interrupts:
+    maxItems: 1
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  regulators:
+    type: object
+    additionalProperties: false
+

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 52

Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +10 -0
+    properties:
+      base:
+        type: object
+        $ref: regulator.yaml#
+        unevaluatedProperties: false
+        description:
+          Properties for base regulator which for force-off base circuit
+
+        properties:
+          regulator-compatible:

regulator-compatible was deprecated so long ago we don't even document it now. Why are you bringing it back?

Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml line 64

Quoted 12 lines
Documentation/devicetree/bindings/regulator/richtek,rt5133.yaml new file +12 -0
+            description: Compatible string for regulator
+            $ref: /schemas/types.yaml#/definitions/string
+
+          oc-shutdown-all:
+            type: boolean
+            description:
+              Anyone of LDO OC state, shut down all channels.
+
+          pgb-shutdown-all:
+            type: boolean
+            description:
+              Anyone of PGB OC state, shut down all channels.

Is 'base' an actual regulator or are these just common properties for all regulators? If the latter, then just move them up a level and add a vendor prefix.

Rob

maintainer
#4 lore raw
In reply to [email protected]
Quoted 5 lines · On Mon, Jul 21, 2025 at 02:01:34PM +0800, [email protected] wrote:

RT5133 is an intefrated chip. It includes 8 LDOs and 3 GPOs that can be used to drive output high/low purpose. The dependency of the GPO block is internally LDO1 Voltage. If LDO1 voltage output disabled, GPO cannot be used to drive output high. It need to pay more attention on the usage.

This looks mostly fine, a couple of very small nits below:

Quoted 12 lines
drivers/regulator/rt5133-regulator.c new file +12 -0
+static irqreturn_t rt5133_intr_handler(int irq_number, void *data)
+{
+	struct rt5133_priv *priv = data;
+	u32 intr_evts = 0, handle_evts;
+	int i, ret;
+
+	ret = regmap_bulk_read(priv->regmap, RT5133_REG_BASE_EVT, &intr_evts,
+			       RT5133_INTR_BYTE_NR);
+	if (ret) {
+		dev_err(priv->dev, "%s, read event failed\n", __func__);
+		return IRQ_HANDLED;
+	}

drivers/regulator/rt5133-regulator.c line 370

Quoted 10 lines
drivers/regulator/rt5133-regulator.c new file +9 -0
+
+	handle_evts = intr_evts & RT5133_BASE_EVT_MASK;
 
+
+	ret = regmap_bulk_write(priv->regmap, RT5133_REG_BASE_EVT, &intr_evts,
+				RT5133_INTR_BYTE_NR);
+	if (ret)
+		dev_err(priv->dev, "%s, clear event failed\n", __func__);
+
+	return IRQ_HANDLED;

If there weren't any events flagged that we handled we should return IRQ_NONE here, this supports shared interrupts and lets the error handling in the interrupt core handle errors where the interrupt line gets stuck.

drivers/regulator/rt5133-regulator.c line 490

Quoted 6 lines
drivers/regulator/rt5133-regulator.c new file +6 -0
+// Due to crc, cache is not necessary
+static const struct regmap_config rt5133_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = RT5133_REG_LDO8_CTRL4,
+};

Might be worth enabling a cache?