# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/mfd/richtek,rt5033.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Richtek RT5033 Power Management Integrated Circuit

maintainers:
  - Jakob Hauser <jahau@rocketmail.com>

description:
  RT5033 is a multifunction device which includes battery charger, fuel gauge,
  flash LED current source, LDO and synchronous Buck converter for portable
  applications. It is interfaced to host controller using I2C interface. The
  battery fuel gauge uses a separate I2C bus.

properties:
  compatible:
    const: richtek,rt5033

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  regulators:
    description:
      The regulators of RT5033 have to be instantiated under a sub-node named
      "regulators". For SAFE_LDO voltage there is only one value of 4.9 V. LDO
      voltage ranges from 1.2 V to 3.0 V in 0.1 V steps. BUCK voltage ranges
      from 1.0 V to 3.0 V in 0.1 V steps.
    type: object
    patternProperties:
      "^(SAFE_LDO|LDO|BUCK)$":
        type: object
        $ref: /schemas/regulator/regulator.yaml#
        unevaluatedProperties: false
    additionalProperties: false

  charger:
    type: object
    $ref: /schemas/power/supply/richtek,rt5033-charger.yaml#

required:
  - compatible
  - reg
  - interrupts

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/irq.h>

    battery: battery {
        compatible = "simple-battery";
        precharge-current-microamp = <450000>;
        constant-charge-current-max-microamp = <1000000>;
        charge-term-current-microamp = <150000>;
        precharge-upper-limit-microvolt = <3500000>;
        constant-charge-voltage-max-microvolt = <4350000>;
    };

    extcon {
        usb_con: connector {
            compatible = "usb-b-connector";
            label = "micro-USB";
            type = "micro";
        };
    };

    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        i2c@0 {
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <0>;

            fuel-gauge@35 {
                compatible = "richtek,rt5033-battery";
                reg = <0x35>;

                interrupt-parent = <&msmgpio>;
                interrupts = <121 IRQ_TYPE_EDGE_FALLING>;

                pinctrl-names = "default";
                pinctrl-0 = <&fg_alert_default>;

                power-supplies = <&rt5033_charger>;
            };
        };

        i2c@1 {
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <1>;

            pmic@34 {
                compatible = "richtek,rt5033";
                reg = <0x34>;

                interrupt-parent = <&msmgpio>;
                interrupts = <62 IRQ_TYPE_EDGE_FALLING>;

                pinctrl-names = "default";
                pinctrl-0 = <&pmic_int_default>;

                regulators {
                    safe_ldo_reg: SAFE_LDO {
                        regulator-name = "SAFE_LDO";
                        regulator-min-microvolt = <4900000>;
                        regulator-max-microvolt = <4900000>;
                        regulator-always-on;
                    };
                    ldo_reg: LDO {
                        regulator-name = "LDO";
                        regulator-min-microvolt = <2800000>;
                        regulator-max-microvolt = <2800000>;
                    };
                    buck_reg: BUCK {
                        regulator-name = "BUCK";
                        regulator-min-microvolt = <1200000>;
                        regulator-max-microvolt = <1200000>;
                    };
                };

                rt5033_charger: charger {
                    compatible = "richtek,rt5033-charger";
                    monitored-battery = <&battery>;
                    richtek,usb-connector = <&usb_con>;
                };
            };
        };
    };
