# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021 Sebastian Reichel
%YAML 1.2
---
$id: http://devicetree.org/schemas/power/supply/stericsson,ab8500-charger.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: AB8500 Charger

maintainers:
  - Sebastian Reichel <sre@kernel.org>

allOf:
  - $ref: power-supply.yaml#

properties:
  compatible:
    const: stericsson,ab8500-charger

  monitored-battery:
    $ref: /schemas/types.yaml#/definitions/phandle
    description: phandle to battery node

  battery:
    $ref: /schemas/types.yaml#/definitions/phandle
    deprecated: true

  vddadc-supply:
    description: Supply for USB and Main charger

  autopower_cfg:
    type: boolean
    description: automatic poweron after powerloss

  interrupts:
    maxItems: 14

  interrupt-names:
    items:
      - const: MAIN_CH_UNPLUG_DET
      - const: MAIN_CHARGE_PLUG_DET
      - const: MAIN_EXT_CH_NOT_OK
      - const: MAIN_CH_TH_PROT_R
      - const: MAIN_CH_TH_PROT_F
      - const: VBUS_DET_F
      - const: VBUS_DET_R
      - const: USB_LINK_STATUS
      - const: USB_CH_TH_PROT_R
      - const: USB_CH_TH_PROT_F
      - const: USB_CHARGER_NOT_OKR
      - const: VBUS_OVV
      - const: CH_WD_EXP
      - const: VBUS_CH_DROP_END

  io-channels:
    minItems: 2
    maxItems: 4

  io-channel-names:
    oneOf:
      - items:
          - const: main_charger_v
          - const: main_charger_c
          - const: vbus_v
          - const: usb_charger_c
      - items:
          - const: vbus_v
          - const: usb_charger_c


required:
  - compatible
  - monitored-battery
  - vddadc-supply
  - interrupts
  - interrupt-names
  - io-channels
  - io-channel-names

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/irq.h>
    pmic {
      charger {
        compatible = "stericsson,ab8500-charger";
        monitored-battery = <&battery>;
        vddadc-supply = <&ab8500_ldo_tvout_reg>;
        interrupts = <10 IRQ_TYPE_LEVEL_HIGH>,
                     <11 IRQ_TYPE_LEVEL_HIGH>,
                     <0 IRQ_TYPE_LEVEL_HIGH>,
                     <107 IRQ_TYPE_LEVEL_HIGH>,
                     <106 IRQ_TYPE_LEVEL_HIGH>,
                     <14 IRQ_TYPE_LEVEL_HIGH>,
                     <15 IRQ_TYPE_LEVEL_HIGH>,
                     <79 IRQ_TYPE_LEVEL_HIGH>,
                     <105 IRQ_TYPE_LEVEL_HIGH>,
                     <104 IRQ_TYPE_LEVEL_HIGH>,
                     <89 IRQ_TYPE_LEVEL_HIGH>,
                     <22 IRQ_TYPE_LEVEL_HIGH>,
                     <21 IRQ_TYPE_LEVEL_HIGH>,
                     <16 IRQ_TYPE_LEVEL_HIGH>;
        interrupt-names = "MAIN_CH_UNPLUG_DET",
                          "MAIN_CHARGE_PLUG_DET",
                          "MAIN_EXT_CH_NOT_OK",
                          "MAIN_CH_TH_PROT_R",
                          "MAIN_CH_TH_PROT_F",
                          "VBUS_DET_F",
                          "VBUS_DET_R",
                          "USB_LINK_STATUS",
                          "USB_CH_TH_PROT_R",
                          "USB_CH_TH_PROT_F",
                          "USB_CHARGER_NOT_OKR",
                          "VBUS_OVV",
                          "CH_WD_EXP",
                          "VBUS_CH_DROP_END";
        io-channels = <&gpadc 0x03>,
                      <&gpadc 0x0a>,
                      <&gpadc 0x09>,
                      <&gpadc 0x0b>;
        io-channel-names = "main_charger_v",
                           "main_charger_c",
                           "vbus_v",
                           "usb_charger_c";
      };
    };