# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-wm8994.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: NVIDIA Tegra audio complex with WM8994 CODEC

maintainers:
  - Svyatoslav Ryhel <clamor95@gmail.com>

allOf:
  - $ref: nvidia,tegra-audio-common.yaml#

properties:
  compatible:
    items:
      - pattern: '^[a-z0-9]+,tegra-audio-wm8994(-[a-z0-9]+)+$'
      - const: nvidia,tegra-audio-wm8994

  nvidia,audio-routing:
    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
    description: |
      A list of the connections between audio components.
      Each entry is a pair of strings, the first being the connection's sink,
      the second being the connection's source. Valid names for sources and
      sinks are the pins (documented in the binding document),
      and the jacks on the board.
    minItems: 2
    items:
      enum:
        # Board Connectors
        - Headphone Jack
        - Int Spk
        - Earpiece
        - Line Out
        - Mic Jack
        - Int Mic
        - Internal Mic 1
        - Internal Mic 2
        - FM Radio

        # CODEC Pins
        - SPKOUTLP
        - SPKOUTLN
        - SPKOUTRP
        - SPKOUTRN
        - HPOUT1L
        - HPOUT1R
        - HPOUT2P
        - HPOUT2N
        - LINEOUT1P
        - LINEOUT1N
        - LINEOUT2P
        - LINEOUT2N
        - IN1LN
        - IN1LP
        - IN2LN
        - IN2LP:VXRN
        - IN1RN
        - IN1RP
        - IN2RN
        - IN2RP:VXRP
        - DMIC1DAT
        - DMIC2DAT
        - MICBIAS1
        - MICBIAS2

required:
  - nvidia,i2s-controller

unevaluatedProperties: false

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

    sound {
        compatible = "lg,tegra-audio-wm8994-star",
                     "nvidia,tegra-audio-wm8994";
        nvidia,model = "LG Optimus 2X WM8994";

        nvidia,audio-routing =
                "Headphone Jack", "HPOUT1L",
                "Headphone Jack", "HPOUT1R",
                "Int Spk", "SPKOUTLN",
                "Int Spk", "SPKOUTLP",
                "Earpiece", "HPOUT2N",
                "Earpiece", "HPOUT2P",
                "IN2RN", "MICBIAS2",
                "IN2RN", "Mic Jack",
                "IN1LN", "MICBIAS1",
                "IN1LN", "Internal Mic 1",
                "IN1RN", "MICBIAS1",
                "IN1RN", "Internal Mic 2";

        nvidia,i2s-controller = <&tegra_i2s1>;
        nvidia,audio-codec = <&wm8994>;

        nvidia,hp-det-gpios = <&gpio 51 GPIO_ACTIVE_HIGH>;
        nvidia,mic-det-gpios = <&gpio 27 GPIO_ACTIVE_HIGH>;
        nvidia,ext-mic-en-gpios = <&gpio 57 GPIO_ACTIVE_HIGH>;
        nvidia,coupled-mic-hp-det;

        clocks = <&tegra_car TEGRA20_CLK_PLL_A>,
                 <&tegra_car TEGRA20_CLK_PLL_A_OUT0>,
                 <&tegra_car TEGRA20_CLK_CDEV1>;
        clock-names = "pll_a", "pll_a_out0", "mclk";
    };