# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/onnn,ar0521.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: ON Semiconductor AR0521 MIPI CSI-2 sensor

maintainers:
  - Krzysztof Hałasa <khalasa@piap.pl>

description: |-
  The AR0521 is a raw CMOS image sensor with MIPI CSI-2 and
  I2C-compatible control interface.

properties:
  compatible:
    const: onnn,ar0521

  reg:
    maxItems: 1

  clocks:
    maxItems: 1

  clock-names:
    const: extclk

  vaa-supply:
    description:
      Definition of the regulator used as analog (2.7 V) voltage supply.

  vdd-supply:
    description:
      Definition of the regulator used as digital core (1.2 V) voltage supply.

  vdd_io-supply:
    description:
      Definition of the regulator used as digital I/O (1.8 V) voltage supply.

  reset-gpios:
    description: reset GPIO, usually active low
    maxItems: 1

  port:
    $ref: /schemas/graph.yaml#/$defs/port-base
    unevaluatedProperties: false
    description: |
      Video output port.

    properties:
      endpoint:
        $ref: /schemas/media/video-interfaces.yaml#
        unevaluatedProperties: false

        properties:
          bus-type:
            const: 4
          data-lanes:
            anyOf:
              - items:
                  - const: 1
              - items:
                  - const: 1
                  - const: 2
              - items:
                  - const: 1
                  - const: 2
                  - const: 3
                  - const: 4

required:
  - compatible
  - reg
  - clocks
  - clock-names
  - vaa-supply
  - vdd-supply
  - vdd_io-supply
  - port

additionalProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/clock/imx6qdl-clock.h>

    i2c {
            #address-cells = <1>;
            #size-cells = <0>;

            ar0521: camera-sensor@36 {
                    compatible = "onnn,ar0521";
                    reg = <0x36>;
                    pinctrl-names = "default";
                    pinctrl-0 = <&pinctrl_mipi_camera>;
                    clocks = <&clks IMX6QDL_CLK_CKO>;
                    clock-names = "extclk";
                    reset-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
                    vaa-supply = <&reg_2p7v>;
                    vdd-supply = <&reg_1p2v>;
                    vdd_io-supply = <&reg_1p8v>;

                    port {
                           mipi_camera_to_mipi_csi2: endpoint {
                                    remote-endpoint = <&mipi_csi2_in>;
                                    data-lanes = <1 2 3 4>;
                            };
                    };
            };
    };
