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

title: Qualcomm Technologies Inc. Plug-N-Play v2 Flash LED

maintainers:
  - Rakesh Kota <quic_kotarake@quicinc.com>
  - Subbaraman Narayanamurthy <subbaram@quicinc.com>
  - Kamal Wadhwa <quic_kamalw@quicinc.com>

description: |
  QPNP (Qualcomm Technologies Inc. Plug N Play) Flash LED (Light
  Emitting Diode) driver v2 is used to provide illumination to
  camera sensor when background light is dim to capture good
  picture. It can also be used for flashlight/torch application.
  It is part of PMIC on Qualcomm Technologies Inc. reference platforms.

properties:
  compatible:
    enum:
      - qcom,pm6150l-flash-led-v2
      - qcom,pmi632-flash-led-v2

  reg:
    description: |
      Base address and size for flash LED modules
    maxItems: 1

  interrupts:
    description: |
      Specifies the interrupts associated with this device.

  interrupt-names:
    description: |
      Specify the interrupt names associated with interrupts.
    items:
      - const: led-fault-irq
      - const: mitigation-irq
      - const: flash-timer-exp-irq
      - const: all-ramp-down-done-irq
      - const: all-ramp-up-done-irq
      - const: led3-ramp-up-done-irq
      - const: led2-ramp-up-done-irq
      - const: led1-ramp-up-done-irq

  qcom,hdrm-auto-mode:
    description: |
      Boolean type to select headroom auto mode enabled or not
    type: boolean

  qcom,isc-delay-us:
    description: |
      Integer type to specify short circuit delay. Valid values are 32, 64,
      128, 192. Unit is uS.
    maxItems: 1

patternProperties:
  '^switch[0-9]-supply$':
    description: |
      phandle of the regulator that needs to be used
      as a supply for flash switch_X device.

  '^qcom,flash_[0-9]$':
    type: object
    properties:
      label:
        $ref: /schemas/types.yaml#/definitions/string-array
        description: |
          Specifies type of LED that will be used.
        const: flash

      qcom,led-name:
        description: |
          Name of the LED.
        $ref: /schemas/types.yaml#/definitions/string

      qcom,id:
        description: |
          Specifies the LED channel number for flash device.
          It depends on hardware and starts with an index 0.
        $ref: /schemas/types.yaml#/definitions/uint32
        enum: [ 0, 1, 2 ]

      qcom,default-led-trigger:
        description: |
          Trigger for camera flash device.
        $ref: /schemas/types.yaml#/definitions/string

      qcom,max-current:
        description: |
          Maximum current allowed on this LED. Valid values should be
          integer from 0 to 1500 inclusive. Flash 2 should have maximum current of
          750 per hardware requirement. Unit is mA.
        $ref: /schemas/types.yaml#/definitions/uint32
        minimum: 0
        maximum: 1500

      qcom,duration-ms:
        description: |
          Default time duration for flash LED device. Unit is ms.
        minimum: 10
        maximum: 1280

      qcom,ires-ua:
        description: |
          Current resolution for flash LED device. Unit is uA.
        $ref: /schemas/types.yaml#/definitions/uint32
        enum: [ 5000, 12500 ]

    required:
      - label
      - qcom,led-name
      - qcom,default-led-trigger
      - qcom,id
      - qcom,max-current
      - qcom,duration-ms

  '^qcom,torch_[0-9]$':
    type: object
    properties:
      label:
        description: |
          Specifies type of LED that will be used.
        $ref: /schemas/types.yaml#/definitions/string-array
        const: torch

      qcom,led-name:
        description: |
          Name of the LED.
        $ref: /schemas/types.yaml#/definitions/string

      qcom,id:
        description: |
          Specifies the LED channel number for torch device.
          It depends on hardware and starts with an index 0.
        $ref: /schemas/types.yaml#/definitions/uint32
        enum: [ 0, 1, 2, 3 ]

      qcom,default-led-trigger:
        description: |
          Trigger for torch device.
        $ref: /schemas/types.yaml#/definitions/string

      qcom,max-current:
        description: |
          Maximum current allowed for torch device. Unit is mA.
        $ref: /schemas/types.yaml#/definitions/uint32
        minimum: 0
        maximum: 500
        default: 500

      qcom,ires-ua:
        description: |
          Current resolution for torch device. Unit is uA.
        $ref: /schemas/types.yaml#/definitions/uint32
        enum: [ 5000, 12500 ]

    required:
      - label
      - qcom,led-name
      - qcom,default-led-trigger
      - qcom,id
      - qcom,max-current

  '^qcom,switch_[0-9]$':
    type: object
    properties:
      label:
        description: |
          Specifies type of LED that will be used.
        $ref: /schemas/types.yaml#/definitions/string-array
        const: switch

      qcom,led-name:
        description: |
          Name of the LED.
        $ref: /schemas/types.yaml#/definitions/string

      qcom,default-led-trigger:
        description: |
          Trigger for switch device.
        $ref: /schemas/types.yaml#/definitions/string

      qcom,led-mask:
        description: |
          Required property for switch nodes. Bitmask to indicate which leds are
          controlled by this switch node. Accepted values are in the range 1 to 7,
          inclusive. Example qcom,led-mask = <4>;
        $ref: /schemas/types.yaml#/definitions/uint32

      qcom,symmetry-en:
        description: |
          Boolean property to specify if the flash LEDs under a
          switch node are controlled symmetrically. This needs
          to be specified if a group of flash LED channels are
          connected to a single LED.
        type: boolean

    required:
      - label
      - qcom,led-name
      - qcom,default-led-trigger
      - qcom,led-mask

required:
  - compatible
  - reg

additionalProperties: false

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

    qcom,leds@d300 {
        compatible = "qcom,pm6150l-flash-led-v2";
        status = "okay";
        reg = <0xd300 0x100>;
        interrupts = <0x3 0xd3 0x0 IRQ_TYPE_EDGE_BOTH>,
                     <0x3 0xd3 0x1 IRQ_TYPE_EDGE_BOTH>,
                     <0x3 0xd3 0x2 IRQ_TYPE_EDGE_BOTH>,
                     <0x3 0xd3 0x3 IRQ_TYPE_EDGE_BOTH>,
                     <0x3 0xd3 0x4 IRQ_TYPE_EDGE_BOTH>,
                     <0x3 0xd3 0x5 IRQ_TYPE_EDGE_BOTH>,
                     <0x3 0xd3 0x6 IRQ_TYPE_EDGE_BOTH>,
                     <0x3 0xd3 0x7 IRQ_TYPE_EDGE_BOTH>;
        interrupt-names = "led-fault-irq",
                        "mitigation-irq",
                        "flash-timer-exp-irq",
                        "all-ramp-down-done-irq",
                        "all-ramp-up-done-irq",
                        "led3-ramp-up-done-irq",
                        "led2-ramp-up-done-irq",
                        "led1-ramp-up-done-irq";
        qcom,hdrm-auto-mode;
        qcom,isc-delay-us = <192>;
        switch0-supply = <&pmi8998_bob>;

        qcom,flash_0 {
            label = "flash";
            qcom,led-name = "led:flash_0";
            qcom,max-current = <1500>;
            qcom,default-led-trigger = "flash0_trigger";
            qcom,id = <0>;
            qcom,current = <1000>;
            qcom,duration-ms = <1280>;
            qcom,ires-ua = <12500>;
            qcom,hdrm-voltage-mv = <325>;
            qcom,hdrm-vol-hi-lo-win-mv = <100>;
        };

        qcom,flash_1 {
            label = "flash";
            qcom,led-name = "led:flash_1";
            qcom,max-current = <1500>;
            qcom,default-led-trigger = "flash1_trigger";
            qcom,id = <1>;
            qcom,current = <1000>;
            qcom,duration-ms = <1280>;
            qcom,ires-ua = <12500>;
            qcom,hdrm-voltage-mv = <325>;
            qcom,hdrm-vol-hi-lo-win-mv = <100>;
        };

        qcom,flash_2 {
            label = "flash";
            qcom,led-name = "led:flash_2";
            qcom,max-current = <750>;
            qcom,default-led-trigger = "flash2_trigger";
            qcom,id = <2>;
            qcom,current = <500>;
            qcom,duration-ms = <1280>;
            qcom,ires-ua = <12500>;
            qcom,hdrm-voltage-mv = <325>;
            qcom,hdrm-vol-hi-lo-win-mv = <100>;
            pinctrl-names = "led_enable","led_disable";
            pinctrl-0 = <&led_enable>;
            pinctrl-1 = <&led_disable>;
        };

        qcom,torch_0 {
            label = "torch";
            qcom,led-name = "led:torch_0";
            qcom,max-current = <500>;
            qcom,default-led-trigger = "torch0_trigger";
            qcom,id = <0>;
            qcom,current = <300>;
            qcom,ires-ua = <12500>;
            qcom,hdrm-voltage-mv = <325>;
            qcom,hdrm-vol-hi-lo-win-mv = <100>;
        };

        qcom,torch_1 {
            label = "torch";
            qcom,led-name = "led:torch_1";
            qcom,max-current = <500>;
            qcom,default-led-trigger = "torch1_trigger";
            qcom,id = <1>;
            qcom,current = <300>;
            qcom,ires-ua = <12500>;
            qcom,hdrm-voltage-mv = <325>;
            qcom,hdrm-vol-hi-lo-win-mv = <100>;
        };

        qcom,torch_2 {
            label = "torch";
            qcom,led-name = "led:torch_2";
            qcom,max-current = <500>;
            qcom,default-led-trigger = "torch2_trigger";
            qcom,id = <2>;
            qcom,current = <300>;
            qcom,ires-ua = <12500>;
            qcom,hdrm-voltage-mv = <325>;
            qcom,hdrm-vol-hi-lo-win-mv = <100>;
            pinctrl-names = "led_enable","led_disable";
            pinctrl-0 = <&led_enable>;
            pinctrl-1 = <&led_disable>;
        };

        qcom,switch_0 {
            label = "switch";
            qcom,led-name = "led:switch_0";
            qcom,led-mask = <3>;
            qcom,default-led-trigger = "switch0_trigger";
            qcom,symmetry-en;
        };

        qcom,switch_1 {
            label = "switch";
            qcom,led-name = "led:switch_1";
            qcom,led-mask = <4>;
            qcom,default-led-trigger = "switch1_trigger";
        };
    };
...
