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    maxItems: 1
211  simple-audio-card,mic-det-gpio:
212    maxItems: 1
213
214patternProperties:
215  "^simple-audio-card,cpu(@[0-9a-f]+)?$":
216    $ref: "#/definitions/dai"
217  "^simple-audio-card,codec(@[0-9a-f]+)?$":
218    $ref: "#/definitions/dai"
219  "^simple-audio-card,plat(@[0-9a-f]+)?$":
220    $ref: "#/definitions/dai"
221
222  "^simple-audio-card,dai-link(@[0-9a-f]+)?$":
223    description: |
224      Container for dai-link level properties and the CPU and CODEC sub-nodes.
225      This container may be omitted when the card has only one DAI link.
226    type: object
227    properties:
228      reg:
229        maxItems: 1
230
231      "#address-cells":
232        const: 1
233      "#size-cells":
234        const: 0
235      # common properties
236      frame-master:
237        $ref: "#/definitions/frame-master"
238      bitclock-master:
239        $ref: "#/definitions/bitclock-master"
240      frame-inversion:
241        $ref: "#/definitions/frame-inversion"
242      bitclock-inversion:
243        $ref: "#/definitions/bitclock-inversion"
244      format:
245        $ref: "#/definitions/format"
246      mclk-fs:
247        $ref: "#/definitions/mclk-fs"
248      aux-devs:
249        $ref: "#/definitions/aux-devs"
250      convert-rate:
251        $ref: "#/definitions/convert-rate"
252      convert-channels:
253        $ref: "#/definitions/convert-channels"
254      prefix:
255        $ref: "#/definitions/prefix"
256      pin-switches:
257        $ref: "#/definitions/pin-switches"
258      hp-det-gpio:
259        maxItems: 1
260      mic-det-gpio:
261        maxItems: 1
262
263    patternProperties:
264      "^cpu(-[0-9]+)?$":
265        $ref: "#/definitions/dai"
266      "^codec(-[0-9]+)?$":
267        $ref: "#/definitions/dai"
268    additionalProperties: false
269
270required:
271  - compatible
272
273additionalProperties: false
274
275examples:
276# --------------------
277# single DAI link
278# --------------------
279  - |
280    sound {
281        compatible = "simple-audio-card";
282        simple-audio-card,name = "VF610-Tower-Sound-Card";
283        simple-audio-card,format = "left_j";
284        simple-audio-card,bitclock-master = <&dailink0_master>;
285        simple-audio-card,frame-master = <&dailink0_master>;
286        simple-audio-card,widgets =
287                "Microphone", "Microphone Jack",
288                "Headphone", "Headphone Jack",
289                "Speaker", "External Speaker";
290        simple-audio-card,routing =
291                "MIC_IN", "Microphone Jack",
292                "Headphone Jack", "HP_OUT",
293                "External Speaker", "LINE_OUT";
294
295        simple-audio-card,cpu {
296            sound-dai = <&sh_fsi2 0>;
297        };
298
299        dailink0_master: simple-audio-card,codec {
300            sound-dai = <&ak4648>;
301            clocks = <&osc>;
302        };
303    };
304
305# --------------------
306# Multi DAI links
307# --------------------
308  - |
309    sound {
310        compatible = "simple-audio-card";
311        simple-audio-card,name = "Cubox Audio";
312
313        #address-cells = <1>;
314        #size-cells = <0>;
315
316        simple-audio-card,dai-link@0 {		/* I2S - HDMI */
317            reg = <0>;
318            format = "i2s";
319            cpu {
320                sound-dai = <&audio0>;
321            };
322            codec {
323                sound-dai = <&tda998x0>;
324            };
325        };
326
327        simple-audio-card,dai-link@1 {		/* S/PDIF - HDMI */
328            reg = <1>;
329            cpu {
330                sound-dai = <&audio1>;
331            };
332            codec {
333                sound-dai = <&tda998x1>;
334            };
335        };
336
337        simple-audio-card,dai-link@2 {		/* S/PDIF - S/PDIF */
338            reg = <2>;
339            cpu {
340                sound-dai = <&audio2>;
341            };
342            codec {
343                sound-dai = <&spdif_codec>;
344            };
345        };
346    };
347
348# --------------------
349# route audio from IMX6 SSI2 through TLV320DAC3100 codec
350# through TPA6130A2 amplifier to headphones:
351# --------------------
352  - |
353    sound {
354        compatible = "simple-audio-card";
355
356        simple-audio-card,widgets =
357            "Headphone", "Headphone Jack";
358        simple-audio-card,routing =
359            "Headphone Jack", "HPLEFT",
360            "Headphone Jack", "HPRIGHT",
361            "LEFTIN", "HPL",
362            "RIGHTIN", "HPR";
363        simple-audio-card,aux-devs = <&amp>;
364        simple-audio-card,cpu {
365            sound-dai = <&ssi2>;
366        };
367        simple-audio-card,codec {
368            sound-dai = <&codec>;
369            clocks = <&clocks>;
370        };
371    };
372
373# --------------------
374# route audio to/from a codec through an amplifier
375# designed with a potentiometer driven by IIO:
376# --------------------
377  - |
378    sound {
379        compatible = "simple-audio-card";
380
381        simple-audio-card,aux-devs = <&amp_in>, <&amp_out>;
382        simple-audio-card,routing =
383            "CODEC LEFTIN", "AMP_IN LEFT OUT",
384            "CODEC RIGHTIN", "AMP_IN RIGHT OUT",
385            "AMP_OUT LEFT IN", "CODEC LEFTOUT",
386            "AMP_OUT RIGHT IN", "CODEC RIGHTOUT";
387
388        simple-audio-card,additional-devs {
389            amp_out: iio-aux-out {
390                compatible = "audio-iio-aux";
391                io-channels = <&pot_out 0>, <&pot_out 1>;
392                io-channel-names = "LEFT", "RIGHT";
393                snd-control-invert-range = <1 1>;
394                sound-name-prefix = "AMP_OUT";
395            };
396
397            amp_in: iio_aux-in {
398                compatible = "audio-iio-aux";
399                io-channels = <&pot_in 0>, <&pot_in 1>;
400                io-channel-names = "LEFT", "RIGHT";
401                sound-name-prefix = "AMP_IN";
402            };
403        };
404
405        simple-audio-card,cpu {
406            sound-dai = <&cpu>;
407        };
408
409        simple-audio-card,codec {
410            sound-dai = <&codec>;
411            clocks = <&clocks>;
412        };
413    };
414
415# --------------------
416# Sampling Rate Conversion
417# --------------------
418  - |
419    sound {
420        compatible = "simple-audio-card";
421
422        simple-audio-card,name = "rsnd-ak4643";
423        simple-audio-card,format = "left_j";
424        simple-audio-card,bitclock-master = <&sndcodec>;
425        simple-audio-card,frame-master = <&sndcodec>;
426
427        simple-audio-card,convert-rate = <48000>;
428
429        simple-audio-card,prefix = "ak4642";
430        simple-audio-card,routing = "ak4642 Playback", "DAI0 Playback",
431                                    "DAI0 Capture", "ak4642 Capture";
432
433        sndcpu: simple-audio-card,cpu {
434            sound-dai = <&rcar_sound>;
435        };
436
437        sndcodec: simple-audio-card,codec {
438            sound-dai = <&ak4643>;
439            system-clock-frequency = <11289600>;
440        };
441    };
442
443# --------------------
444# 2 CPU 1 Codec (Mixing)
445# --------------------
446  - |
447    sound {
448        compatible = "simple-audio-card";
449        #address-cells = <1>;
450        #size-cells = <0>;
451
452        simple-audio-card,name = "rsnd-ak4643";
453        simple-audio-card,format = "left_j";
454        simple-audio-card,bitclock-master = <&dpcmcpu>;
455        simple-audio-card,frame-master = <&dpcmcpu>;
456
457        simple-audio-card,convert-rate = <48000>;
458        simple-audio-card,convert-channels = <2>;
459
460        simple-audio-card,routing = "ak4642 Playback", "DAI0 Playback",
461                                    "ak4642 Playback", "DAI1 Playback";
462
463        dpcmcpu: simple-audio-card,cpu@0 {
464            reg = <0>;
465            sound-dai = <&rcar_sound 0>;
466        };
467
468        simple-audio-card,cpu@1 {
469            reg = <1>;
470            sound-dai = <&rcar_sound 1>;
471        };
472
473        simple-audio-card,codec {
474            prefix = "ak4642";
475            sound-dai = <&ak4643>;
476            clocks = <&audio_clock>;
477        };
478    };
479
480# --------------------
481# Multi DAI links with DPCM:
482#
483# CPU0 ------ ak4613
484# CPU1 ------ PCM3168A-p  /* DPCM 1ch/2ch */
485# CPU2 --/                /* DPCM 3ch/4ch */
486# CPU3 --/                /* DPCM 5ch/6ch */
487# CPU4 --/                /* DPCM 7ch/8ch */
488# CPU5 ------ PCM3168A-c
489# --------------------
490  - |
491    sound {
492        compatible = "simple-audio-card";
493        #address-cells = <1>;
494        #size-cells = <0>;
495
496        simple-audio-card,routing =
497            "pcm3168a Playback", "DAI1 Playback",
498            "pcm3168a Playback", "DAI2 Playback",
499            "pcm3168a Playback", "DAI3 Playback",
500            "pcm3168a Playback", "DAI4 Playback";
501
502        simple-audio-card,dai-link@0 {
503            reg = <0>;
504            format = "left_j";
505            bitclock-master = <&sndcpu0>;
506            frame-master = <&sndcpu0>;
507
508            sndcpu0: cpu {
509                sound-dai = <&rcar_sound 0>;
510            };
511            codec {
512                sound-dai = <&ak4613>;
513            };
514        };
515
516        simple-audio-card,dai-link@1 {
517            reg = <1>;
518            format = "i2s";
519            bitclock-master = <&sndcpu1>;
520            frame-master = <&sndcpu1>;
521
522            convert-channels = <8>; /* TDM Split */
523
524            sndcpu1: cpu-0 {
525                sound-dai = <&rcar_sound 1>;
526            };
527            cpu-1 {
528                sound-dai = <&rcar_sound 2>;
529            };
530            cpu-2 {
531                sound-dai = <&rcar_sound 3>;
532            };
533            cpu-3 {
534                sound-dai = <&rcar_sound 4>;
535            };
536            codec {
537                mclk-fs = <512>;
538                prefix = "pcm3168a";
539                dai-tdm-slot-num = <8>;
540                sound-dai = <&pcm3168a 0>;
541            };
542        };
543
544        simple-audio-card,dai-link@2 {
545            reg = <2>;
546            format = "i2s";
547            bitclock-master = <&sndcpu2>;
548            frame-master = <&sndcpu2>;
549
550            sndcpu2: cpu {
551                sound-dai = <&rcar_sound 5>;
552            };
553            codec {
554                mclk-fs = <512>;
555                prefix = "pcm3168a";
556                sound-dai = <&pcm3168a 1>;
557            };
558        };
559    };
560