# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/mfd/rohm,bd71815-pmic.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: ROHM BD71815 Power Management Integrated Circuit

maintainers:
  - Matti Vaittinen <mazziesaccount@gmail.com>

description: |
  BD71815AGW is a single-chip power management ICs for battery-powered
  portable devices. It integrates 5 buck converters, 8 LDOs, a boost driver
  for LED and a 500 mA single-cell linear charger. Also included is a Coulomb
  counter, a real-time clock (RTC), and a 32.768 kHz clock gate and two GPOs.

properties:
  compatible:
    const: rohm,bd71815

  reg:
    description:
      I2C slave address.
    maxItems: 1

  interrupts:
    maxItems: 1

  gpio-controller: true

  "#gpio-cells":
    const: 2
    description: |
      The first cell is the pin number and the second cell is used to specify
      flags. See ../gpio/gpio.txt for more information.

  clocks:
    maxItems: 1

  "#clock-cells":
    const: 0

  clock-output-names:
    const: bd71815-32k-out

  rohm,clkout-open-drain:
    description: clk32kout mode. Set to 1 for "open-drain" or 0 for "cmos".
    $ref: /schemas/types.yaml#/definitions/uint32
    minimum: 0
    maximum: 1

  rohm,charger-sense-resistor-ohms:
    minimum: 10000000
    maximum: 50000000
    description: |
      BD71827 and BD71828 have SAR ADC for measuring charging currents.
      External sense resistor (RSENSE in data sheet) should be used. If
      something other but 30MOhm resistor is used the resistance value
      should be given here in Ohms.
    default: 30000000

  regulators:
    $ref: ../regulator/rohm,bd71815-regulator.yaml
    description:
      List of child nodes that specify the regulators.

  gpio-reserved-ranges:
    description: |
      Usage of BD71828 GPIO pins can be changed via OTP. This property can be
      used to mark the pins which should not be configured for GPIO. Please see
      the ../gpio/gpio.txt for more information.

  rohm,enable-hidden-gpo:
    description: |
      The BD71815 has undocumented GPO at pin E5. Pin is marked as GND at the
      data-sheet as its location in the middle of GND pins makes it hard to
      use on PCB. If your board has managed to use this pin you can enable the
      second GPO by defining this property. Dont enable this if you are unsure
      about how the E5 pin is connected on your board.
    type: boolean

required:
  - compatible
  - reg
  - interrupts
  - clocks
  - "#clock-cells"
  - regulators
  - gpio-controller
  - "#gpio-cells"

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/irq.h>
    #include <dt-bindings/leds/common.h>
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;
        pmic: pmic@4b {
            compatible = "rohm,bd71815";
            reg = <0x4b>;

            interrupt-parent = <&gpio1>;
            interrupts = <29 IRQ_TYPE_LEVEL_LOW>;

            clocks = <&osc 0>;
            #clock-cells = <0>;
            clock-output-names = "bd71815-32k-out";

            gpio-controller;
            #gpio-cells = <2>;

            rohm,charger-sense-resistor-ohms = <10000000>;

            regulators {
                buck1: buck1 {
                    regulator-name = "buck1";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <2000000>;
                    regulator-always-on;
                    regulator-ramp-delay = <1250>;
                    rohm,dvs-run-voltage = <1150000>;
                    rohm,dvs-suspend-voltage = <950000>;
                };
                buck2: buck2 {
                    regulator-name = "buck2";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <2000000>;
                    regulator-always-on;
                    regulator-ramp-delay = <1250>;
                    rohm,dvs-run-voltage = <1150000>;
                    rohm,dvs-suspend-voltage = <950000>;
                };
                buck3: buck3 {
                    regulator-name = "buck3";
                    regulator-min-microvolt = <1200000>;
                    regulator-max-microvolt = <2700000>;
                    regulator-always-on;
                };
                buck4: buck4 {
                    regulator-name = "buck4";
                    regulator-min-microvolt = <1100000>;
                    regulator-max-microvolt = <1850000>;
                    regulator-always-on;
                };
                buck5: buck5 {
                    regulator-name = "buck5";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-always-on;
                };
                ldo1: ldo1 {
                    regulator-name = "ldo1";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-always-on;
                };
                ldo2: ldo2 {
                    regulator-name = "ldo2";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-always-on;
                };
                ldo3: ldo3 {
                    regulator-name = "ldo3";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-always-on;
                };
                ldo4: ldo4 {
                    regulator-name = "ldo4";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-always-on;
                };
                ldo5: ldo5 {
                    regulator-name = "ldo5";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-always-on;
                };
                ldo6: ldodvref {
                    regulator-name = "ldodvref";
                    regulator-always-on;
                };
                ldo7: ldolpsr {
                    regulator-name = "ldolpsr";
                    regulator-always-on;
                };

                boost: wled {
                    regulator-name = "wled";
                    regulator-min-microamp = <10>;
                    regulator-max-microamp = <25000>;
                };
            };
        };
    };