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

title: NXP PCA9450A/B/C Power Management Integrated Circuit regulators

maintainers:
  - Robin Gong <yibin.gong@nxp.com>

description: |
  Regulator nodes should be named to BUCK_<number> and LDO_<number>. The
  definition for each of these nodes is defined using the standard
  binding for regulators at
  Documentation/devicetree/bindings/regulator/regulator.txt.
  Datasheet is available at
  https://www.nxp.com/docs/en/data-sheet/PCA9450DS.pdf

  Support PF9453, Datasheet is available at
  https://www.nxp.com/docs/en/data-sheet/PF9453_SDS.pdf

# The valid names for PCA9450 regulator nodes are:
# BUCK1, BUCK2, BUCK3, BUCK4, BUCK5, BUCK6,
# LDO1, LDO2, LDO3, LDO4, LDO5
# Note: Buck3 removed on PCA9450B and connect with Buck1 on PCA9450C.

properties:
  compatible:
    enum:
      - nxp,pca9450a
      - nxp,pca9450b
      - nxp,pca9450c
      - nxp,pca9451a
      - nxp,pca9452
      - nxp,pf9453

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  inl1-supply:
    description: Regulator supply for the INL1 pin group, powering LDOx

  inb13-supply:
    description:
      Regulator supply for the INB13 pin group, powering BUCK1 and BUCK3.

  inb26-supply:
    description:
      Regulator supply for the INB26 pin group, powering BUCK2 and BUCK6.

  inb45-supply:
    description:
      Regulator supply for the INB45 pin group, powering BUCK4 and BUCK5.

  regulators:
    type: object
    description: |
      list of regulators provided by this controller

    properties:
      LDO5:
        type: object
        $ref: regulator.yaml#
        description:
          Properties for single LDO5 regulator.

        properties:
          nxp,sd-vsel-fixed-low:
            type: boolean
            description:
              Let the driver know that SD_VSEL is hardwired to low level and
              there is no GPIO to get the actual value from.

          sd-vsel-gpios:
            description:
              GPIO that can be used to read the current status of the SD_VSEL
              signal in order for the driver to know if LDO5CTRL_L or LDO5CTRL_H
              is used by the hardware.

        unevaluatedProperties: false

    patternProperties:
      "^LDO([1-4]|-SNVS)$":
        type: object
        $ref: regulator.yaml#
        description:
          Properties for single LDO regulator.

        unevaluatedProperties: false

      "^BUCK[1-6]$":
        type: object
        $ref: regulator.yaml#
        description:
          Properties for single BUCK regulator.

        properties:
          nxp,dvs-run-voltage:
            $ref: /schemas/types.yaml#/definitions/uint32
            minimum: 600000
            maximum: 2187500
            description:
              PMIC default "RUN" state voltage in uV. Only Buck1~3 have such
              dvs(dynamic voltage scaling) property.

          nxp,dvs-standby-voltage:
            $ref: /schemas/types.yaml#/definitions/uint32
            minimum: 600000
            maximum: 2187500
            description:
              PMIC default "STANDBY" state voltage in uV. Only Buck1~3 have such
              dvs(dynamic voltage scaling) property.

          regulator-allowed-modes:
            description: |
              Buck regulator operating modes allowed. Valid values below.
              Users should use the macros from dt-bindings/regulator/nxp,pca9450-regulator.h
                0 (PCA9450_BUCK_MODE_AUTO): Auto PFM/PWM mode
                1 (PCA9450_BUCK_MODE_FORCE_PWM): Forced PWM mode
            items:
              enum: [ 0, 1 ]

        unevaluatedProperties: false

    additionalProperties: false

  nxp,i2c-lt-enable:
    type: boolean
    description:
      Indicates that the I2C Level Translator is used.

  nxp,wdog_b-warm-reset:
    type: boolean
    description:
      When WDOG_B signal is asserted a warm reset will be done instead of cold
      reset.

  nxp,pmic-on-req-on-debounce-us:
    enum: [ 120, 20000, 100000, 750000 ]
    description: Debounce time for PMIC_ON_REQ high.

  nxp,pmic-on-req-off-debounce-us:
    enum: [ 120, 2000 ]
    description: Debounce time for PMIC_ON_REQ is asserted low

  nxp,power-on-step-ms:
    enum: [ 1, 2, 4, 8]
    description: Time step configuration during power on sequence

  nxp,power-down-step-ms:
    enum: [ 2, 4, 8, 16 ]
    description: Time step configuration during power down sequence

  nxp,restart-ms:
    enum: [ 250, 500 ]
    description: Time to stay off regulators during Cold reset

  npx,pmic-rst-b-debounce-ms:
    enum: [ 10, 50, 100, 500, 1000, 2000, 4000, 8000 ]
    description: PMIC_RST_B debounce time

required:
  - compatible
  - reg
  - regulators

additionalProperties: false

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: nxp,pf9453
    then:
      properties:
        regulators:
          patternProperties:
            "^LDO[3-4]$": false
            "^BUCK[5-6]$": false
    else:
      properties:
        regulators:
          properties:
            LDO-SNVS: false

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

    i2c {
        #address-cells = <1>;
        #size-cells = <0>;
        pmic: pmic@25 {
            compatible = "nxp,pca9450b";
            reg = <0x25>;
            pinctrl-0 = <&pinctrl_pmic>;
            interrupt-parent = <&gpio1>;
            interrupts = <3 IRQ_TYPE_LEVEL_LOW>;

            regulators {
                buck1: BUCK1 {
                    regulator-name = "BUCK1";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <2187500>;
                    regulator-boot-on;
                    regulator-always-on;
                    regulator-ramp-delay = <3125>;
                };
                buck2: BUCK2 {
                    regulator-name = "BUCK2";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <2187500>;
                    regulator-boot-on;
                    regulator-always-on;
                    regulator-ramp-delay = <3125>;
                    nxp,dvs-run-voltage = <950000>;
                    nxp,dvs-standby-voltage = <850000>;
                };
                buck4: BUCK4 {
                    regulator-name = "BUCK4";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <3400000>;
                    regulator-boot-on;
                    regulator-always-on;
                    regulator-initial-mode = <PCA9450_BUCK_MODE_FORCE_PWM>;
                    regulator-allowed-modes = <PCA9450_BUCK_MODE_FORCE_PWM>;
                };
                buck5: BUCK5 {
                    regulator-name = "BUCK5";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <3400000>;
                    regulator-boot-on;
                    regulator-always-on;
                    regulator-allowed-modes = <PCA9450_BUCK_MODE_AUTO
                                               PCA9450_BUCK_MODE_FORCE_PWM>;
                };
                buck6: BUCK6 {
                    regulator-name = "BUCK6";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <3400000>;
                    regulator-boot-on;
                    regulator-always-on;
                };

                ldo1: LDO1 {
                    regulator-name = "LDO1";
                    regulator-min-microvolt = <1600000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                ldo2: LDO2 {
                    regulator-name = "LDO2";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <1150000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                ldo3: LDO3 {
                    regulator-name = "LDO3";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                ldo4: LDO4 {
                    regulator-name = "LDO4";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                ldo5: LDO5 {
                    regulator-name = "LDO5";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
            };
        };
    };