# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/skyworks,aat1290.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Skyworks Solutions, Inc. AAT1290 Current Regulator for Flash LEDs

maintainers:
  - Jacek Anaszewski <jacek.anaszewski@gmail.com>
  - Krzysztof Kozlowski <krzk@kernel.org>

description: |
  The device is controlled through two pins:: FL_EN and EN_SET. The pins when,
  asserted high, enable flash strobe and movie mode (max 1/2 of flash current)
  respectively. In order to add a capability of selecting the strobe signal
  source (e.g. CPU or camera sensor) there is an additional switch required,
  independent of the flash chip. The switch is controlled with pin control.

properties:
  compatible:
    const: skyworks,aat1290

  enset-gpios:
    maxItems: 1
    description: EN_SET pin

  flen-gpios:
    maxItems: 1
    description: FL_EN pin

  led:
    $ref: common.yaml#
    unevaluatedProperties: false

    properties:
      led-max-microamp: true

      flash-max-microamp:
        description: |
          Maximum flash LED supply current can be calculated using following
          formula:: I = 1A * 162 kOhm / Rset.

      flash-max-timeout-us:
        description: |
          Maximum flash timeout can be calculated using following formula::
            T = 8.82 * 10^9 * Ct.

    required:
      - flash-max-microamp
      - flash-max-timeout-us
      - led-max-microamp

  pinctrl-names:
    items:
      - const: default
      - const: host
      - const: isp

  pinctrl-0: true
  pinctrl-1: true
  pinctrl-2: true

required:
  - compatible
  - enset-gpios
  - flen-gpios
  - led

additionalProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/leds/common.h>

    // Ct = 220 nF, Rset = 160 kOhm
    led-controller {
        compatible = "skyworks,aat1290";
        flen-gpios = <&gpj1 1 GPIO_ACTIVE_HIGH>;
        enset-gpios = <&gpj1 2 GPIO_ACTIVE_HIGH>;

        pinctrl-names = "default", "host", "isp";
        pinctrl-0 = <&camera_flash_host>;
        pinctrl-1 = <&camera_flash_host>;
        pinctrl-2 = <&camera_flash_isp>;

        led {
            function = LED_FUNCTION_FLASH;
            color = <LED_COLOR_ID_WHITE>;
            led-max-microamp = <520833>;
            flash-max-microamp = <1012500>;
            flash-max-timeout-us = <1940000>;
        };
    };