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

title: Qualcomm Technologies, Inc. schgm_flash driver

maintainers:
  - Rakesh Kota <quic_kotarake@quicinc.com>

description: |
  Add support for SCHGM_FLASH module under charger.
  SCHGM_FLASH module handles flash failure, de-rating and
  allows configuration for different flash features.

properties:
  compatible:
    const: qcom,schgm-flash

  reg:
    description: |
      Address and size of the peripheral's register block.

  interrupts:
    description: |
      Peripheral interrupt specifier.

  interrupt-names:
    description: |
      Interrupt names.  This list must match up 1-to-1 with the
      interrupts specified in the 'interrupts' property.

  qcom,flash-derating-soc:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: |
      SOC threshold in percentage below which hardware will start
      derating flash. This is only applicable to certain PMICs like
      PMI632 which has SCHGM_FLASH peripheral.

  qcom,flash-disable-soc:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: |
      SOC threshold in percentage below which hardware will disable
      flash. This is only applicable to certain PMICs like PMI632
      which has SCHGM_FLASH peripheral.

  qcom,headroom-mode:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: |
      Specifies flash hardware headroom management policy.
      possible values are
      0 - Fixed mode, constant 5V at flash input.
      1 - Adaptive mode allows charger output voltage to be
          dynamically controlled by the flash module based on the
          required flash headroom.
      This is only applicable to certain PMICs like PMI632 which
      has SCHGM_FLASH peripheral.

required:
  - compatible
  - reg
  - interrupts
  - interrupt-names

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

additionalProperties: false

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

    qcom,schgm-flash@a600 {
            compatible = "qcom,schgm-flash";
            reg = <0xa600 0x100>;
            interrupts = <0x2 0xa6 0x0 IRQ_TYPE_NONE>,
                         <0x2 0xa6 0x1 IRQ_TYPE_NONE>,
                         <0x2 0xa6 0x2 IRQ_TYPE_NONE>,
                         <0x2 0xa6 0x3 IRQ_TYPE_NONE>,
                         <0x2 0xa6 0x4 IRQ_TYPE_NONE>,
                         <0x2 0xa6 0x5 IRQ_TYPE_NONE>,
                         <0x2 0xa6 0x6 IRQ_TYPE_NONE>,
                         <0x2 0xa6 0x7 IRQ_TYPE_NONE>;

            interrupt-names =	"flash-en",
                                "torch-req",
                                "flash-state-change",
                                "vout-up",
                                "vout-down",
                                "ilim1-s1",
                                "ilim2-s2",
                                "vreg-ok";
    };
...
