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

title: Loongson 7axxx/2kxxx ASoC audio sound card driver

maintainers:
  - Yingkun Meng <mengyingkun@loongson.cn>
  - Binbin Zhou <zhoubinbin@loongson.cn>

description:
  The binding describes the sound card present in loongson
  7axxx/2kxxx platform. The sound card is an ASoC component
  which uses Loongson I2S controller to transfer the audio data.

allOf:
  - $ref: sound-card-common.yaml#

properties:
  compatible:
    enum:
      - loongson,ls-audio-card  # Loongson-2K1000/Loongson-2K2000/LS7A
      - loongson,ls2k0300-forever-pi-audio-card # CTCISZ Forever Pi
      - loongson,ls2k0300-dl2k0300b-audio-card # ATK-DL2K0300B

  mclk-fs:
    $ref: simple-card.yaml#/definitions/mclk-fs

  cpu:
    description: Holds subnode which indicates cpu dai.
    type: object
    additionalProperties: false
    properties:
      sound-dai:
        maxItems: 1
    required:
      - sound-dai

  codec:
    description: Holds subnode which indicates codec dai.
    type: object
    additionalProperties: false
    properties:
      sound-dai:
        maxItems: 1
    required:
      - sound-dai

  spkr-en-gpios:
    maxItems: 1
    description: The GPIO that enables the speakers

  hp-ctl-gpios:
    maxItems: 1
    description: The GPIO that control the headphones

  hp-det-gpios:
    maxItems: 1
    description: The GPIO that detect headphones are plugged in

required:
  - compatible
  - mclk-fs
  - cpu
  - codec

unevaluatedProperties: false

examples:
  - |
    sound {
        compatible = "loongson,ls-audio-card";
        model = "loongson-audio";
        mclk-fs = <512>;

        cpu {
            sound-dai = <&i2s>;
        };
        codec {
            sound-dai = <&es8323>;
        };
    };

  - |
    #include <dt-bindings/gpio/gpio.h>

    sound {
        compatible = "loongson,ls2k0300-dl2k0300b-audio-card";
        model = "loongson-audio";
        mclk-fs = <512>;
        hp-det-gpios = <&gpio 81 GPIO_ACTIVE_HIGH>;
        spkr-en-gpios = <&gpio 86 GPIO_ACTIVE_HIGH>;
        hp-ctl-gpios = <&gpio 87 GPIO_ACTIVE_HIGH>;
        audio-routing =
                      "Headphone", "LOUT1",
                      "Headphone", "ROUT1",
                      "Speaker", "LOUT2",
                      "Speaker", "ROUT2";

        cpu {
            sound-dai = <&i2s>;
        };

        codec {
            sound-dai = <&es8388>;
        };
    };