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

title: Qualcomm SPMI Regulators

maintainers:
  - Robert Marko <robimarko@gmail.com>

properties:
  compatible:
    enum:
      - qcom,pm6125-regulators
      - qcom,pm660-regulators
      - qcom,pm660l-regulators
      - qcom,pm8004-regulators
      - qcom,pm8005-regulators
      - qcom,pm8226-regulators
      - qcom,pm8841-regulators
      - qcom,pm8916-regulators
      - qcom,pm8941-regulators
      - qcom,pm8950-regulators
      - qcom,pm8994-regulators
      - qcom,pmi8994-regulators
      - qcom,pmp8074-regulators
      - qcom,pms405-regulators

  qcom,saw-reg:
    description: Reference to syscon node defining the SAW registers
    $ref: /schemas/types.yaml#/definitions/phandle

patternProperties:
  "^(5vs[1-2]|(l|s)[1-9][0-9]?|lvs[1-3])$":
    description: List of regulators and its properties
    type: object
    $ref: regulator.yaml#
    unevaluatedProperties: false

    properties:
      qcom,ocp-max-retries:
        description:
          Maximum number of times to try toggling a voltage switch off and
          back on as a result of consecutive over current events
        $ref: /schemas/types.yaml#/definitions/uint32

      qcom,ocp-retry-delay:
        description:
          Time to delay in milliseconds between each voltage switch toggle
          after an over current event takes place
        $ref: /schemas/types.yaml#/definitions/uint32

      qcom,pin-ctrl-enable:
        description:
          Bit mask specifying which hardware pins should be used to enable the
          regulator, if any.
          Supported bits are
          0 = ignore all hardware enable signals
          BIT(0) = follow HW0_EN signal
          BIT(1) = follow HW1_EN signal
          BIT(2) = follow HW2_EN signal
          BIT(3) = follow HW3_EN signal
        $ref: /schemas/types.yaml#/definitions/uint32
        minimum: 0
        maximum: 15

      qcom,pin-ctrl-hpm:
        description:
          Bit mask specifying which hardware pins should be used to force the
          regulator into high power mode, if any.
          Supported bits are
          0 = ignore all hardware enable signals
          BIT(0) = follow HW0_EN signal
          BIT(1) = follow HW1_EN signal
          BIT(2) = follow HW2_EN signal
          BIT(3) = follow HW3_EN signal
          BIT(4) = follow PMIC awake state
        $ref: /schemas/types.yaml#/definitions/uint32
        minimum: 0
        maximum: 31

      qcom,vs-soft-start-strength:
        description:
          This property sets the soft start strength for voltage switch type
          regulators.
          Supported values are
          0 = 0.05 uA
          1 = 0.25 uA
          2 = 0.55 uA
          3 = 0.75 uA
        $ref: /schemas/types.yaml#/definitions/uint32
        minimum: 0
        maximum: 3

      qcom,saw-slave:
        description: SAW controlled gang slave. Will not be configured.
        type: boolean

      qcom,saw-leader:
        description:
          SAW controlled gang leader. Will be configured as SAW regulator.
        type: boolean

required:
  - compatible

allOf:
  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm6125-regulators
    then:
      properties:
        vdd_l1_l7_l17_l18-supply: true
        vdd_l2_l3_l4-supply: true
        vdd_l5_l15_l19_l20_l21_l22-supply: true
        vdd_l6_l8-supply: true
        vdd_l9_l11-supply: true
        vdd_l10_l13_l14-supply: true
        vdd_l12_l16-supply: true
        vdd_l23_l24-supply: true
      patternProperties:
        "^vdd_s[1-8]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm660-regulators
    then:
      properties:
        vdd_l15_l16_l17_l18_l19-supply: true
        vdd_l1_l6_l7-supply: true
        vdd_l2_l3-supply: true
        vdd_l5-supply: true
        vdd_l8_l9_l10_l11_l12_l13_l14-supply: true
      patternProperties:
        "^vdd_s[1-6]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm660l-regulators
    then:
      properties:
        vdd_l1_l9_l10-supply: true
        vdd_l2-supply: true
        vdd_l3_l5_l7_l8-supply: true
        vdd_l4_l6-supply: true
      patternProperties:
        "^vdd_s[1-5]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm8004-regulators
    then:
      patternProperties:
        "^vdd_s[25]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm8005-regulators
    then:
      patternProperties:
        "^vdd_s[1-4]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm8226-regulators
    then:
      properties:
        vdd_l10_l11_l13-supply: true
        vdd_l12_l14-supply: true
        vdd_l15_l16_l17_l18-supply: true
        vdd_l19_l20_l21_l22_l23_l28-supply: true
        vdd_l1_l2_l4_l5-supply: true
        vdd_l25-supply: true
        vdd_l3_l24_l26-supply: true
        vdd_l6_l7_l8_l9_l27-supply: true
        vdd_lvs1-supply: true
      patternProperties:
        "^vdd_s[1-5]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm8841-regulators
    then:
      patternProperties:
        "^vdd_s[1-8]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm8916-regulators
    then:
      properties:
        vdd_l1_l3-supply: true
        vdd_l4_l5_l6-supply: true
        vdd_l8_l11_l14_l15_l16-supply: true
        vdd_l9_l10_l12_l13_l17_l18-supply: true
      patternProperties:
        "^vdd_l[27]-supply$": true
        "^vdd_s[1-4]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm8941-regulators
    then:
      properties:
        interrupts:
          items:
            - description: Over-current protection interrupt for 5V S1
            - description: Over-current protection interrupt for 5V S2
        interrupt-names:
          items:
            - const: ocp-5vs1
            - const: ocp-5vs2
        vdd_l13_l20_l23_l24-supply: true
        vdd_l1_l3-supply: true
        vdd_l21-supply: true
        vdd_l2_lvs_1_2_3-supply: true
        vdd_l4_l11-supply: true
        vdd_l5_l7-supply: true
        vdd_l6_l12_l14_l15-supply: true
        vdd_l8_l16_l18_19-supply: true
        vdd_l9_l10_l17_l22-supply: true
        vin_5vs-supply: true
      patternProperties:
        "^vdd_s[1-3]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm8950-regulators
    then:
      properties:
        vdd_l1_l19-supply: true
        vdd_l20-supply: true
        vdd_l21-supply: true
        vdd_l2_l23-supply: true
        vdd_l3-supply: true
        vdd_l4_l5_l6_l7_l16-supply: true
        vdd_l8_l11_l12_l17_l22-supply: true
        vdd_l9_l10_l13_l14_l15_l18-supply: true
      patternProperties:
        "^vdd_s[1-6]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pm8994-regulators
    then:
      properties:
        vdd_l1-supply: true
        vdd_l13_l19_l23_l24-supply: true
        vdd_l14_l15-supply: true
        vdd_l17_l29-supply: true
        vdd_l20_l21-supply: true
        vdd_l25-supply: true
        vdd_l2_l26_l28-supply: true
        vdd_l3_l11-supply: true
        vdd_l4_l27_l31-supply: true
        vdd_l5_l7-supply: true
        vdd_l6_l12_l32-supply: true
        vdd_l8_l16_l30-supply: true
        vdd_l9_l10_l18_l22-supply: true
        vdd_lvs_1_2-supply: true
      patternProperties:
        "^vdd_s[1-9][0-2]?-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pmi8994-regulators
    then:
      properties:
        vdd_l1-supply: true
      patternProperties:
        "^vdd_s[1-3]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pmp8074-regulators
    then:
      properties:
        vdd_l10_l11_l12_l13-supply: true
        vdd_l1_l2-supply: true
        vdd_l3_l8-supply: true
        vdd_l5_l6_l15-supply: true
      patternProperties:
        "^vdd_l[479]-supply$": true
        "^vdd_s[1-5]-supply$": true

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,pms405-regulators
    then:
      properties:
        vdd_s3-supply: true

unevaluatedProperties: false

examples:
  - |
    regulators {
      compatible = "qcom,pm8941-regulators";
      vdd_l1_l3-supply = <&s1>;

      s1: s1 {
        regulator-min-microvolt = <1300000>;
        regulator-max-microvolt = <1400000>;
      };

      l1: l1 {
        regulator-min-microvolt = <1225000>;
        regulator-max-microvolt = <1300000>;
      };
    };
...