# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/mfd/hisilicon,hi6421-spmi-pmic.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: HiSilicon 6421v600 SPMI PMIC

maintainers:
  - Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

description: |
  HiSilicon 6421v600 should be connected inside a MIPI System Power Management
  (SPMI) bus. It provides interrupts and power supply.

  The GPIO and interrupt settings are represented as part of the top-level PMIC
  node.

  The SPMI controller part is provided by
  drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml.

properties:
  $nodename:
    pattern: "pmic@[0-9a-f]"

  compatible:
    const: hisilicon,hi6421v600-spmi

  reg:
    maxItems: 1

  '#interrupt-cells':
    const: 2

  interrupt-controller:
    description:
      Identify that the PMIC is capable of behaving as an interrupt controller.

  gpios:
    maxItems: 1

  regulators:
    type: object

    properties:
      '#address-cells':
        const: 1

      '#size-cells':
        const: 0

    patternProperties:
      '^ldo[0-9]+@[0-9a-f]$':
        type: object

        $ref: "/schemas/regulator/regulator.yaml#"

        properties:
          reg:
            description: Enable register.

          '#address-cells':
            const: 1

          '#size-cells':
            const: 0

          vsel-reg:
            description: Voltage selector register.

          enable-mask:
            description: Bitmask used to enable the regulator.

          voltage-table:
            description: Table with the selector items for the voltage regulator.
            minItems: 2
            maxItems: 16

          off-on-delay-us:
            description: Time required for changing state to enabled in microseconds.

          startup-delay-us:
            description: Startup time in microseconds.

          idle-mode-mask:
            description: Bitmask used to put the regulator on idle mode.

          eco-microamp:
            description: Maximum current while on idle mode.

        required:
          - reg
          - vsel-reg
          - enable-mask
          - voltage-table
          - off-on-delay-us
          - startup-delay-us

required:
  - compatible
  - reg
  - regulators

examples:
  - |
    /* pmic properties */

    pmic: pmic@0 {
      compatible = "hisilicon,hi6421-spmi";
      reg = <0 0>;

      #interrupt-cells = <2>;
      interrupt-controller;
      gpios = <&gpio28 0 0>;

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

        ldo3: ldo3@16 {
          reg = <0x16>;
          vsel-reg = <0x51>;

          regulator-name = "ldo3";
          regulator-min-microvolt = <1500000>;
          regulator-max-microvolt = <2000000>;
          regulator-boot-on;

          enable-mask = <0x01>;

          voltage-table = <1500000>, <1550000>, <1600000>, <1650000>,
                          <1700000>, <1725000>, <1750000>, <1775000>,
                          <1800000>, <1825000>, <1850000>, <1875000>,
                          <1900000>, <1925000>, <1950000>, <2000000>;
          off-on-delay-us = <20000>;
          startup-delay-us = <120>;
        };

        ldo4: ldo4@17 { /* 40 PIN */
          reg = <0x17>;
          vsel-reg = <0x52>;

          regulator-name = "ldo4";
          regulator-min-microvolt = <1725000>;
          regulator-max-microvolt = <1900000>;
          regulator-boot-on;

          enable-mask = <0x01>;
          idle-mode-mask = <0x10>;
          eco-microamp = <10000>;

          hi6421-vsel = <0x52 0x07>;
          voltage-table = <1725000>, <1750000>, <1775000>, <1800000>,
                          <1825000>, <1850000>, <1875000>, <1900000>;
          off-on-delay-us = <20000>;
          startup-delay-us = <120>;
        };
      };
    };
