[alsa-devel] [PATCH v2 2/5] ASoC: dt-bindings: Convert Allwinner A10 codec to a schema

Rob Herring robh+dt at kernel.org
Fri Aug 30 17:36:04 CEST 2019


On Wed, Aug 28, 2019 at 7:52 AM Maxime Ripard <mripard at kernel.org> wrote:
>
> From: Maxime Ripard <maxime.ripard at bootlin.com>
>
> The Allwinner SoCs have an embedded audio codec that is supported in Linux,
> with a matching Device Tree binding.
>
> Now that we have the DT validation in place, let's convert the device tree
> bindings for that controller over to a YAML schemas.
>
> Signed-off-by: Maxime Ripard <maxime.ripard at bootlin.com>
>
> ---
>
> Changes from v1:
>   - Fix subject prefix
> ---
>  .../sound/allwinner,sun4i-a10-codec.yaml      | 162 ++++++++++++++++++
>  .../devicetree/bindings/sound/sun4i-codec.txt |  94 ----------
>  2 files changed, 162 insertions(+), 94 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-codec.yaml
>  delete mode 100644 Documentation/devicetree/bindings/sound/sun4i-codec.txt
>
> diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-codec.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-codec.yaml
> new file mode 100644
> index 000000000000..44feefae0ef0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-codec.yaml
> @@ -0,0 +1,162 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/sound/allwinner,sun4i-a10-codec.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Allwinner A10 Codec Device Tree Bindings
> +
> +maintainers:
> +  - Chen-Yu Tsai <wens at csie.org>
> +  - Maxime Ripard <maxime.ripard at bootlin.com>
> +
> +properties:
> +  "#sound-dai-cells":
> +    const: 0
> +
> +  compatible:
> +    enum:
> +      - allwinner,sun4i-a10-codec
> +      - allwinner,sun6i-a31-codec
> +      - allwinner,sun7i-a20-codec
> +      - allwinner,sun8i-a23-codec
> +      - allwinner,sun8i-h3-codec
> +      - allwinner,sun8i-v3s-codec
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  clocks:
> +    items:
> +      - description: Bus Clock
> +      - description: Module Clock
> +
> +  clock-names:
> +    items:
> +      - const: apb
> +      - const: codec
> +
> +  dmas:
> +    items:
> +      - description: RX DMA Channel
> +      - description: TX DMA Channel
> +
> +  dma-names:
> +    items:
> +      - const: rx
> +      - const: tx
> +
> +  resets:
> +    maxItems: 1
> +
> +  allwinner,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 include
> +
> +        Audio pins on the SoC
> +          HP
> +          HPCOM
> +          LINEIN    (not on sun8i-v3s)
> +          LINEOUT   (not on sun8i-a23 or sun8i-v3s)
> +          MIC1
> +          MIC2      (not on sun8i-v3s)
> +          MIC3      (only on sun6i-a31)
> +
> +        Microphone biases from the SoC
> +          HBIAS
> +          MBIAS     (not on sun8i-v3s)
> +
> +        Board connectors
> +          Headphone
> +          Headset Mic
> +          Line In
> +          Line Out
> +          Mic
> +          Speaker

All these strings should be in an enum. If 'items' is a schema rather
than a list, it applies to all items.

Also, I assume that maxItems can be 18 and minItems is 2?

> +
> +  allwinner,codec-analog-controls:
> +    $ref: /schemas/types.yaml#/definitions/phandle
> +    description: Phandle to the codec analog controls in the PRCM
> +
> +  allwinner,pa-gpios:
> +    description: GPIO to enable the external amplifier
> +
> +required:
> +  - "#sound-dai-cells"
> +  - compatible
> +  - reg
> +  - interrupts
> +  - clocks
> +  - clock-names
> +  - dmas
> +  - dma-names
> +
> +if:
> +  properties:
> +    compatible:
> +      enum:
> +        - allwinner,sun6i-a31-codec
> +        - allwinner,sun8i-a23-codec
> +        - allwinner,sun8i-h3-codec
> +        - allwinner,sun8i-v3s-codec
> +
> +then:
> +  if:
> +    properties:
> +      compatible:
> +        const: allwinner,sun6i-a31-codec
> +
> +  then:
> +    required:
> +      - resets
> +      - allwinner,audio-routing
> +
> +  else:
> +    required:
> +      - resets
> +      - allwinner,audio-routing
> +      - allwinner,codec-analog-controls
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    codec at 1c22c00 {
> +        #sound-dai-cells = <0>;
> +        compatible = "allwinner,sun7i-a20-codec";
> +        reg = <0x01c22c00 0x40>;
> +        interrupts = <0 30 4>;
> +        clocks = <&apb0_gates 0>, <&codec_clk>;
> +        clock-names = "apb", "codec";
> +        dmas = <&dma 0 19>, <&dma 0 19>;
> +        dma-names = "rx", "tx";
> +    };
> +
> +  - |
> +    codec at 1c22c00 {
> +        #sound-dai-cells = <0>;
> +        compatible = "allwinner,sun6i-a31-codec";
> +        reg = <0x01c22c00 0x98>;
> +        interrupts = <0 29 4>;
> +        clocks = <&ccu 61>, <&ccu 135>;
> +        clock-names = "apb", "codec";
> +        resets = <&ccu 42>;
> +        dmas = <&dma 15>, <&dma 15>;
> +        dma-names = "rx", "tx";
> +        allwinner,audio-routing =
> +            "Headphone", "HP",
> +            "Speaker", "LINEOUT",
> +            "LINEIN", "Line In",
> +            "MIC1", "MBIAS",
> +            "MIC1", "Mic",
> +            "MIC2", "HBIAS",
> +            "MIC2", "Headset Mic";
> +    };
> +
> +...


More information about the Alsa-devel mailing list