# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
# Copyright 2022 Analog Devices Inc.
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/adi,max77857.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices MAX77857 Buck-Boost Converter

maintainers:
  - Ibrahim Tilki <Ibrahim.Tilki@analog.com>
  - Okan Sahin <Okan.Sahin@analog.com>

description: Analog Devices MAX77857 Buck-Boost Converter

properties:
  compatible:
    enum:
      - adi,max77831
      - adi,max77857
      - adi,max77859
      - adi,max77859a

  reg:
    description: I2C address of the device
    items:
      - enum: [0x66, 0x67, 0x6E, 0x6F]

  interrupts:
    maxItems: 1

  adi,switch-frequency-hz:
    description: Switching frequency of the Buck-Boost converter in Hz.
    items:
      - enum: [1200000, 1500000, 1800000, 2100000]

  adi,rtop-ohms:
    description: Top feedback resistor value in ohms for external feedback.
    minimum: 150000
    maximum: 330000

  adi,rbot-ohms:
    description: Bottom feedback resistor value in ohms for external feedback.

dependencies:
  adi,rtop-ohms: [ 'adi,rbot-ohms' ]
  adi,rbot-ohms: [ 'adi,rtop-ohms' ]

required:
  - compatible
  - reg

allOf:
  - $ref: regulator.yaml#
  - if:
      properties:
        compatible:
          contains:
            enum:
              - adi,max77831

    then:
      properties:
        adi,switch-frequency-hz:
          items:
            enum: [1200000, 1500000, 1800000]

unevaluatedProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/irq.h>
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        regulator@66 {
            reg = <0x66>;
            compatible = "adi,max77857";
            interrupt-parent = <&gpio>;
            interrupts = <26 IRQ_TYPE_EDGE_FALLING>;

            adi,rtop-ohms = <312000>;
            adi,rbot-ohms = <12000>;
        };
    };
