xref: /linux/Documentation/devicetree/bindings/sound/simple-card.yaml (revision 7f4f3b14e8079ecde096bd734af10e30d40c27b7)
1# SPDX-License-Identifier: GPL-2.0
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/sound/simple-card.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Simple Audio Card Driver
8
9maintainers:
10  - Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
11
12definitions:
13
14  frame-master:
15    description: Indicates dai-link frame master.
16    $ref: /schemas/types.yaml#/definitions/phandle
17
18  bitclock-master:
19    description: Indicates dai-link bit clock master
20    $ref: /schemas/types.yaml#/definitions/phandle
21
22  frame-inversion:
23    description: dai-link uses frame clock inversion
24    $ref: /schemas/types.yaml#/definitions/flag
25
26  bitclock-inversion:
27    description: dai-link uses bit clock inversion
28    $ref: /schemas/types.yaml#/definitions/flag
29
30  dai-tdm-slot-num:
31    description: see tdm-slot.txt.
32    $ref: /schemas/types.yaml#/definitions/uint32
33
34  dai-tdm-slot-width:
35    description: see tdm-slot.txt.
36    $ref: /schemas/types.yaml#/definitions/uint32
37
38  system-clock-frequency:
39    description: |
40      If a clock is specified and a multiplication factor is given with
41      mclk-fs, the clock will be set to the calculated mclk frequency
42      when the stream starts.
43    $ref: /schemas/types.yaml#/definitions/uint32
44
45  system-clock-direction-out:
46    description: |
47      specifies clock direction as 'out' on initialization.
48      It is useful for some aCPUs with fixed clocks.
49    $ref: /schemas/types.yaml#/definitions/flag
50
51  system-clock-fixed:
52    description: |
53      Specifies that the clock frequency should not be modified.
54      Implied when system-clock-frequency is specified, but can be used when
55      a clock is mapped to the device whose frequency cannot or should not be
56      changed. When mclk-fs is also specified, this restricts the device to a
57      single fixed sampling rate.
58    $ref: /schemas/types.yaml#/definitions/flag
59
60  mclk-fs:
61    description: |
62      Multiplication factor between stream rate and codec mclk.
63      When defined, mclk-fs property defined in dai-link sub nodes are ignored.
64    $ref: /schemas/types.yaml#/definitions/uint32
65
66  aux-devs:
67    description: |
68      List of phandles pointing to auxiliary devices, such
69      as amplifiers, to be added to the sound card.
70    $ref: /schemas/types.yaml#/definitions/phandle-array
71
72  convert-rate:
73    description: CPU to Codec rate convert.
74    $ref: /schemas/types.yaml#/definitions/uint32
75
76  convert-channels:
77    description: CPU to Codec rate channels.
78    $ref: /schemas/types.yaml#/definitions/uint32
79
80  prefix:
81    description: device name prefix
82    $ref: /schemas/types.yaml#/definitions/string
83
84  label:
85    maxItems: 1
86
87  routing:
88    description: |
89      A list of the connections between audio components.
90      Each entry is a pair of strings, the first being the
91      connection's sink, the second being the connection's source.
92    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
93
94  widgets:
95    description: User specified audio sound widgets.
96    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
97
98  pin-switches:
99    description: the widget names for which pin switches must be created.
100    $ref: /schemas/types.yaml#/definitions/string-array
101
102  format:
103    description: audio format.
104    items:
105      enum:
106        - i2s
107        - right_j
108        - left_j
109        - dsp_a
110        - dsp_b
111        - ac97
112        - pdm
113        - msb
114        - lsb
115
116  dai:
117    type: object
118    properties:
119      sound-dai:
120        maxItems: 1
121
122      # common properties
123      mclk-fs:
124        $ref: "#/definitions/mclk-fs"
125      prefix:
126        $ref: "#/definitions/prefix"
127      frame-inversion:
128        $ref: "#/definitions/frame-inversion"
129      bitclock-inversion:
130        $ref: "#/definitions/bitclock-inversion"
131      frame-master:
132        $ref: /schemas/types.yaml#/definitions/flag
133      bitclock-master:
134        $ref: /schemas/types.yaml#/definitions/flag
135
136      dai-tdm-slot-num:
137        $ref: "#/definitions/dai-tdm-slot-num"
138      dai-tdm-slot-width:
139        $ref: "#/definitions/dai-tdm-slot-width"
140      clocks:
141        maxItems: 1
142      system-clock-frequency:
143        $ref: "#/definitions/system-clock-frequency"
144      system-clock-direction-out:
145        $ref: "#/definitions/system-clock-direction-out"
146      system-clock-fixed:
147        $ref: "#/definitions/system-clock-fixed"
148    required:
149      - sound-dai
150
151  additional-devs:
152    type: object
153    description:
154      Additional devices used by the simple audio card.
155    patternProperties:
156      '^iio-aux(-.+)?$':
157        type: object
158        $ref: audio-iio-aux.yaml#
159
160properties:
161  compatible:
162    contains:
163      enum:
164        - simple-audio-card
165        - simple-scu-audio-card
166
167  "#address-cells":
168    const: 1
169  "#size-cells":
170    const: 0
171
172  label:
173    $ref: "#/definitions/label"
174
175  simple-audio-card,name:
176    description: User specified audio sound card name.
177    $ref: /schemas/types.yaml#/definitions/string
178
179  simple-audio-card,widgets:
180    $ref: "#/definitions/widgets"
181  simple-audio-card,routing:
182    $ref: "#/definitions/routing"
183
184  # common properties
185  simple-audio-card,frame-master:
186    $ref: "#/definitions/frame-master"
187  simple-audio-card,bitclock-master:
188    $ref: "#/definitions/bitclock-master"
189  simple-audio-card,frame-inversion:
190    $ref: "#/definitions/frame-inversion"
191  simple-audio-card,bitclock-inversion:
192    $ref: "#/definitions/bitclock-inversion"
193  simple-audio-card,format:
194    $ref: "#/definitions/format"
195  simple-audio-card,mclk-fs:
196    $ref: "#/definitions/mclk-fs"
197  simple-audio-card,aux-devs:
198    $ref: "#/definitions/aux-devs"
199  simple-audio-card,additional-devs:
200    $ref: "#/definitions/additional-devs"
201  simple-audio-card,convert-rate:
202    $ref: "#/definitions/convert-rate"
203  simple-audio-card,convert-channels:
204    $ref: "#/definitions/convert-channels"
205  simple-audio-card,prefix:
206    $ref: "#/definitions/prefix"
207  simple-audio-card,pin-switches:
208    $ref: "#/definitions/pin-switches"
209  simple-audio-card,hp-det-gpio:
210    deprecated: true
211    maxItems: 1
212  simple-audio-card,hp-det-gpios:
213    maxItems: 1
214  simple-audio-card,mic-det-gpio:
215    deprecated: true
216    maxItems: 1
217  simple-audio-card,mic-det-gpios:
218    maxItems: 1
219
220patternProperties:
221  "^simple-audio-card,cpu(@[0-9a-f]+)?$":
222    $ref: "#/definitions/dai"
223  "^simple-audio-card,codec(@[0-9a-f]+)?$":
224    $ref: "#/definitions/dai"
225  "^simple-audio-card,plat(@[0-9a-f]+)?$":
226    $ref: "#/definitions/dai"
227
228  "^simple-audio-card,dai-link(@[0-9a-f]+)?$":
229    description: |
230      Container for dai-link level properties and the CPU and CODEC sub-nodes.
231      This container may be omitted when the card has only one DAI link.
232    type: object
233    properties:
234      reg:
235        maxItems: 1
236
237      "#address-cells":
238        const: 1
239      "#size-cells":
240        const: 0
241      # common properties
242      frame-master:
243        $ref: "#/definitions/frame-master"
244      bitclock-master:
245        $ref: "#/definitions/bitclock-master"
246      frame-inversion:
247        $ref: "#/definitions/frame-inversion"
248      bitclock-inversion:
249        $ref: "#/definitions/bitclock-inversion"
250      format:
251        $ref: "#/definitions/format"
252      mclk-fs:
253        $ref: "#/definitions/mclk-fs"
254      aux-devs:
255        $ref: "#/definitions/aux-devs"
256      convert-rate:
257        $ref: "#/definitions/convert-rate"
258      convert-channels:
259        $ref: "#/definitions/convert-channels"
260      prefix:
261        $ref: "#/definitions/prefix"
262      pin-switches:
263        $ref: "#/definitions/pin-switches"
264      hp-det-gpio:
265        deprecated: true
266        maxItems: 1
267      hp-det-gpios:
268        maxItems: 1
269      mic-det-gpio:
270        deprecated: true
271        maxItems: 1
272      mic-det-gpios:
273        maxItems: 1
274
275    patternProperties:
276      "^cpu(-[0-9]+)?$":
277        $ref: "#/definitions/dai"
278      "^codec(-[0-9]+)?$":
279        $ref: "#/definitions/dai"
280    additionalProperties: false
281
282required:
283  - compatible
284
285additionalProperties: false
286
287examples:
288# --------------------
289# single DAI link
290# --------------------
291  - |
292    sound {
293        compatible = "simple-audio-card";
294        simple-audio-card,name = "VF610-Tower-Sound-Card";
295        simple-audio-card,format = "left_j";
296        simple-audio-card,bitclock-master = <&dailink0_master>;
297        simple-audio-card,frame-master = <&dailink0_master>;
298        simple-audio-card,widgets =
299                "Microphone", "Microphone Jack",
300                "Headphone", "Headphone Jack",
301                "Speaker", "External Speaker";
302        simple-audio-card,routing =
303                "MIC_IN", "Microphone Jack",
304                "Headphone Jack", "HP_OUT",
305                "External Speaker", "LINE_OUT";
306
307        simple-audio-card,cpu {
308            sound-dai = <&sh_fsi2 0>;
309        };
310
311        dailink0_master: simple-audio-card,codec {
312            sound-dai = <&ak4648>;
313            clocks = <&osc>;
314        };
315    };
316
317# --------------------
318# Multi DAI links
319# --------------------
320  - |
321    sound {
322        compatible = "simple-audio-card";
323        simple-audio-card,name = "Cubox Audio";
324
325        #address-cells = <1>;
326        #size-cells = <0>;
327
328        simple-audio-card,dai-link@0 {		/* I2S - HDMI */
329            reg = <0>;
330            format = "i2s";
331            cpu {
332                sound-dai = <&audio0>;
333            };
334            codec {
335                sound-dai = <&tda998x0>;
336            };
337        };
338
339        simple-audio-card,dai-link@1 {		/* S/PDIF - HDMI */
340            reg = <1>;
341            cpu {
342                sound-dai = <&audio1>;
343            };
344            codec {
345                sound-dai = <&tda998x1>;
346            };
347        };
348
349        simple-audio-card,dai-link@2 {		/* S/PDIF - S/PDIF */
350            reg = <2>;
351            cpu {
352                sound-dai = <&audio2>;
353            };
354            codec {
355                sound-dai = <&spdif_codec>;
356            };
357        };
358    };
359
360# --------------------
361# route audio from IMX6 SSI2 through TLV320DAC3100 codec
362# through TPA6130A2 amplifier to headphones:
363# --------------------
364  - |
365    sound {
366        compatible = "simple-audio-card";
367
368        simple-audio-card,widgets =
369            "Headphone", "Headphone Jack";
370        simple-audio-card,routing =
371            "Headphone Jack", "HPLEFT",
372            "Headphone Jack", "HPRIGHT",
373            "LEFTIN", "HPL",
374            "RIGHTIN", "HPR";
375        simple-audio-card,aux-devs = <&amp>;
376        simple-audio-card,cpu {
377            sound-dai = <&ssi2>;
378        };
379        simple-audio-card,codec {
380            sound-dai = <&codec>;
381            clocks = <&clocks>;
382        };
383    };
384
385# --------------------
386# route audio to/from a codec through an amplifier
387# designed with a potentiometer driven by IIO:
388# --------------------
389  - |
390    sound {
391        compatible = "simple-audio-card";
392
393        simple-audio-card,aux-devs = <&amp_in>, <&amp_out>;
394        simple-audio-card,routing =
395            "CODEC LEFTIN", "AMP_IN LEFT OUT",
396            "CODEC RIGHTIN", "AMP_IN RIGHT OUT",
397            "AMP_OUT LEFT IN", "CODEC LEFTOUT",
398            "AMP_OUT RIGHT IN", "CODEC RIGHTOUT";
399
400        simple-audio-card,additional-devs {
401            amp_out: iio-aux-out {
402                compatible = "audio-iio-aux";
403                io-channels = <&pot_out 0>, <&pot_out 1>;
404                io-channel-names = "LEFT", "RIGHT";
405                snd-control-invert-range = <1 1>;
406                sound-name-prefix = "AMP_OUT";
407            };
408
409            amp_in: iio_aux-in {
410                compatible = "audio-iio-aux";
411                io-channels = <&pot_in 0>, <&pot_in 1>;
412                io-channel-names = "LEFT", "RIGHT";
413                sound-name-prefix = "AMP_IN";
414            };
415        };
416
417        simple-audio-card,cpu {
418            sound-dai = <&cpu>;
419        };
420
421        simple-audio-card,codec {
422            sound-dai = <&codec>;
423            clocks = <&clocks>;
424        };
425    };
426
427# --------------------
428# Sampling Rate Conversion
429# --------------------
430  - |
431    sound {
432        compatible = "simple-audio-card";
433
434        simple-audio-card,name = "rsnd-ak4643";
435        simple-audio-card,format = "left_j";
436        simple-audio-card,bitclock-master = <&sndcodec>;
437        simple-audio-card,frame-master = <&sndcodec>;
438
439        simple-audio-card,convert-rate = <48000>;
440
441        simple-audio-card,prefix = "ak4642";
442        simple-audio-card,routing = "ak4642 Playback", "DAI0 Playback",
443                                    "DAI0 Capture", "ak4642 Capture";
444
445        sndcpu: simple-audio-card,cpu {
446            sound-dai = <&rcar_sound>;
447        };
448
449        sndcodec: simple-audio-card,codec {
450            sound-dai = <&ak4643>;
451            system-clock-frequency = <11289600>;
452        };
453    };
454
455# --------------------
456# 2 CPU 1 Codec (Mixing)
457# --------------------
458  - |
459    sound {
460        compatible = "simple-audio-card";
461        #address-cells = <1>;
462        #size-cells = <0>;
463
464        simple-audio-card,name = "rsnd-ak4643";
465        simple-audio-card,format = "left_j";
466        simple-audio-card,bitclock-master = <&dpcmcpu>;
467        simple-audio-card,frame-master = <&dpcmcpu>;
468
469        simple-audio-card,convert-rate = <48000>;
470        simple-audio-card,convert-channels = <2>;
471
472        simple-audio-card,routing = "ak4642 Playback", "DAI0 Playback",
473                                    "ak4642 Playback", "DAI1 Playback";
474
475        dpcmcpu: simple-audio-card,cpu@0 {
476            reg = <0>;
477            sound-dai = <&rcar_sound 0>;
478        };
479
480        simple-audio-card,cpu@1 {
481            reg = <1>;
482            sound-dai = <&rcar_sound 1>;
483        };
484
485        simple-audio-card,codec {
486            prefix = "ak4642";
487            sound-dai = <&ak4643>;
488            clocks = <&audio_clock>;
489        };
490    };
491
492# --------------------
493# Multi DAI links with DPCM:
494#
495# CPU0 ------ ak4613
496# CPU1 ------ PCM3168A-p  /* DPCM 1ch/2ch */
497# CPU2 --/                /* DPCM 3ch/4ch */
498# CPU3 --/                /* DPCM 5ch/6ch */
499# CPU4 --/                /* DPCM 7ch/8ch */
500# CPU5 ------ PCM3168A-c
501# --------------------
502  - |
503    sound {
504        compatible = "simple-audio-card";
505        #address-cells = <1>;
506        #size-cells = <0>;
507
508        simple-audio-card,routing =
509            "pcm3168a Playback", "DAI1 Playback",
510            "pcm3168a Playback", "DAI2 Playback",
511            "pcm3168a Playback", "DAI3 Playback",
512            "pcm3168a Playback", "DAI4 Playback";
513
514        simple-audio-card,dai-link@0 {
515            reg = <0>;
516            format = "left_j";
517            bitclock-master = <&sndcpu0>;
518            frame-master = <&sndcpu0>;
519
520            sndcpu0: cpu {
521                sound-dai = <&rcar_sound 0>;
522            };
523            codec {
524                sound-dai = <&ak4613>;
525            };
526        };
527
528        simple-audio-card,dai-link@1 {
529            reg = <1>;
530            format = "i2s";
531            bitclock-master = <&sndcpu1>;
532            frame-master = <&sndcpu1>;
533
534            convert-channels = <8>; /* TDM Split */
535
536            sndcpu1: cpu-0 {
537                sound-dai = <&rcar_sound 1>;
538            };
539            cpu-1 {
540                sound-dai = <&rcar_sound 2>;
541            };
542            cpu-2 {
543                sound-dai = <&rcar_sound 3>;
544            };
545            cpu-3 {
546                sound-dai = <&rcar_sound 4>;
547            };
548            codec {
549                mclk-fs = <512>;
550                prefix = "pcm3168a";
551                dai-tdm-slot-num = <8>;
552                sound-dai = <&pcm3168a 0>;
553            };
554        };
555
556        simple-audio-card,dai-link@2 {
557            reg = <2>;
558            format = "i2s";
559            bitclock-master = <&sndcpu2>;
560            frame-master = <&sndcpu2>;
561
562            sndcpu2: cpu {
563                sound-dai = <&rcar_sound 5>;
564            };
565            codec {
566                mclk-fs = <512>;
567                prefix = "pcm3168a";
568                sound-dai = <&pcm3168a 1>;
569            };
570        };
571    };
572