# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/mfd/x-powers,ac200.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: X-Powers AC200 mixed-signal IC

maintainers:
  - James Hilliard <james.hilliard1@gmail.com>
  - Jernej Skrabec <jernej.skrabec@gmail.com>

description:
  The AC200 is a mixed-signal companion IC containing audio, video, RTC and
  Fast Ethernet PHY functions. Its control registers are accessed over I2C.
  The audio codec and TV encoder are described by properties of this node.
  The Ethernet PHY is described separately on its MDIO bus.

allOf:
  - $ref: /schemas/sound/dai-common.yaml#

properties:
  compatible:
    const: x-powers,ac200

  reg:
    maxItems: 1

  clocks:
    maxItems: 1
    description:
      AC200 input clock. When using the Ethernet PHY, its configured rate must
      be 24 or 27 MHz, matching the rates encoded by the documented EPHY clock
      selector.

  interrupts:
    maxItems: 1
    description:
      The shared, level-triggered, open-drain INTB output for the TV encoder,
      Ethernet PHY and RTC interrupts. Omit when INTB is not connected. TV
      encoder cable detection status can also be read over I2C without an
      interrupt.

  '#sound-dai-cells':
    const: 0

  ac-ldoin-supply:
    description:
      The 3.3 V supply connected to the AC_LDOIN pin for the audio codec LDO
      input. This may be the same regulator as tv-vcc-supply.

  tv-vcc-supply:
    description:
      The 3.3 V supply connected to the TV_VCC pin for the composite-video
      DAC. This may be the same regulator as ac-ldoin-supply.

  nvmem-cells:
    maxItems: 1
    description: TV encoder bandgap calibration.

  nvmem-cell-names:
    items:
      - const: bandgap

  ports:
    $ref: /schemas/graph.yaml#/properties/ports

    properties:
      port@0:
        $ref: /schemas/graph.yaml#/properties/port
        description: Input to the TV encoder, carrying CCIR656.

      port@1:
        $ref: /schemas/graph.yaml#/properties/port
        description: Output to the composite-video connector.

    required:
      - port@0
      - port@1

required:
  - compatible
  - reg
  - clocks

dependencies:
  '#sound-dai-cells': [ ac-ldoin-supply ]
  ports: [ tv-vcc-supply ]
  nvmem-cells: [ nvmem-cell-names ]
  nvmem-cell-names: [ nvmem-cells ]

unevaluatedProperties: false

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

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

        mixed-signal@10 {
            compatible = "x-powers,ac200";
            reg = <0x10>;
            clocks = <&pwm 5>;
            interrupt-parent = <&pio>;
            interrupts = <1 20 IRQ_TYPE_LEVEL_LOW>;
            #sound-dai-cells = <0>;
            ac-ldoin-supply = <&reg_aldo2>;
            tv-vcc-supply = <&reg_aldo2>;

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

                port@0 {
                    reg = <0>;

                    tve_in: endpoint {
                        remote-endpoint = <&tcon_out_tve>;
                    };
                };

                port@1 {
                    reg = <1>;

                    tve_out: endpoint {
                        remote-endpoint = <&composite_in>;
                    };
                };
            };
        };
    };
  - |
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        mixed-signal@10 {
            compatible = "x-powers,ac200";
            reg = <0x10>;
            clocks = <&pwm 5>;
            /* INTB is not connected. */
            tv-vcc-supply = <&reg_aldo2>;

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

                port@0 {
                    reg = <0>;

                    endpoint {
                        remote-endpoint = <&tcon_out_tve>;
                    };
                };

                port@1 {
                    reg = <1>;

                    endpoint {
                        remote-endpoint = <&composite_in>;
                    };
                };
            };
        };
    };
...