# SPDX-License-Identifier: GPL-2.0-only
%YAML 1.2
---
$id: http://devicetree.org/schemas/mfd/maxim,max14577.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Maxim MAX14577/MAX77836 MicroUSB and Companion Power Management IC

maintainers:
  - Krzysztof Kozlowski <krzk@kernel.org>

description: |
  This is a part of device tree bindings for Maxim MAX14577/MAX77836 MicroUSB
  Integrated Circuit (MUIC).

  The Maxim MAX14577 is a MicroUSB and Companion Power Management IC which
  includes voltage safeout regulators, charger and MicroUSB management IC.

  The Maxim MAX77836 is a MicroUSB and Companion Power Management IC which
  includes voltage safeout and LDO regulators, charger, fuel-gauge and MicroUSB
  management IC.

properties:
  compatible:
    enum:
      - maxim,max14577
      - maxim,max77836

  interrupts:
    maxItems: 1

  reg:
    maxItems: 1

  wakeup-source: true

  charger:
    $ref: /schemas/power/supply/maxim,max14577.yaml

  extcon:
    type: object
    additionalProperties: false
    properties:
      compatible:
        enum:
          - maxim,max14577-muic
          - maxim,max77836-muic

    required:
      - compatible

  regulators:
    $ref: /schemas/regulator/maxim,max14577.yaml

required:
  - compatible
  - interrupts
  - reg
  - charger

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: maxim,max14577
    then:
      properties:
        charger:
          properties:
            compatible:
              const: maxim,max14577-charger
        extcon:
          properties:
            compatible:
              const: maxim,max14577-muic
        regulator:
          properties:
            compatible:
              const: maxim,max14577-regulator
    else:
      properties:
        charger:
          properties:
            compatible:
              const: maxim,max77836-charger
        extcon:
          properties:
            compatible:
              const: maxim,max77836-muic
        regulator:
          properties:
            compatible:
              const: maxim,max77836-regulator

additionalProperties: false

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

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

        pmic@25 {
            compatible = "maxim,max14577";
            reg = <0x25>;
            interrupt-parent = <&gpx1>;
            interrupts = <5 IRQ_TYPE_LEVEL_LOW>;

            extcon {
                compatible = "maxim,max14577-muic";
            };

            regulators {
                compatible = "maxim,max14577-regulator";

                SAFEOUT {
                    regulator-name = "SAFEOUT";
                };

                CHARGER {
                    regulator-name = "CHARGER";
                    regulator-min-microamp = <90000>;
                    regulator-max-microamp = <950000>;
                    regulator-boot-on;
                };
            };

            charger {
                compatible = "maxim,max14577-charger";

                maxim,constant-uvolt = <4350000>;
                maxim,fast-charge-uamp = <450000>;
                maxim,eoc-uamp = <50000>;
                maxim,ovp-uvolt = <6500000>;
            };
        };
    };

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

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

        pmic@25 {
            compatible = "maxim,max77836";
            interrupt-parent = <&gpx1>;
            interrupts = <5 IRQ_TYPE_NONE>;
            reg = <0x25>;
            wakeup-source;

            extcon {
                compatible = "maxim,max77836-muic";
            };

            regulators {
                compatible = "maxim,max77836-regulator";

                SAFEOUT {
                    regulator-name = "SAFEOUT";
                };

                CHARGER {
                    regulator-name = "CHARGER";
                    regulator-min-microamp = <45000>;
                    regulator-max-microamp = <475000>;
                    regulator-boot-on;
                };

                LDO1 {
                    regulator-name = "MOT_2.7V";
                    regulator-min-microvolt = <1100000>;
                    regulator-max-microvolt = <2700000>;
                };

                LDO2 {
                    regulator-name = "UNUSED_LDO2";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3950000>;
                };
            };

            charger {
                compatible = "maxim,max77836-charger";

                maxim,constant-uvolt = <4350000>;
                maxim,fast-charge-uamp = <225000>;
                maxim,eoc-uamp = <7500>;
                maxim,ovp-uvolt = <6500000>;
            };
        };
    };
