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
151properties:
152  compatible:
153    contains:
154      enum:
155        - simple-audio-card
156        - simple-scu-audio-card
157
158  "#address-cells":
159    const: 1
160  "#size-cells":
161    const: 0
162
163  label:
164    $ref: "#/definitions/label"
165
166  simple-audio-card,name:
167    description: User specified audio sound card name.
168    $ref: /schemas/types.yaml#/definitions/string
169
170  simple-audio-card,widgets:
171    $ref: "#/definitions/widgets"
172  simple-audio-card,routing:
173    $ref: "#/definitions/routing"
174
175  # common properties
176  simple-audio-card,frame-master:
177    $ref: "#/definitions/frame-master"
178  simple-audio-card,bitclock-master:
179    $ref: "#/definitions/bitclock-master"
180  simple-audio-card,frame-inversion:
181    $ref: "#/definitions/frame-inversion"
182  simple-audio-card,bitclock-inversion:
183    $ref: "#/definitions/bitclock-inversion"
184  simple-audio-card,format:
185    $ref: "#/definitions/format"
186  simple-audio-card,mclk-fs:
187    $ref: "#/definitions/mclk-fs"
188  simple-audio-card,aux-devs:
189    $ref: "#/definitions/aux-devs"
190  simple-audio-card,convert-rate:
191    $ref: "#/definitions/convert-rate"
192  simple-audio-card,convert-channels:
193    $ref: "#/definitions/convert-channels"
194  simple-audio-card,prefix:
195    $ref: "#/definitions/prefix"
196  simple-audio-card,pin-switches:
197    $ref: "#/definitions/pin-switches"
198  simple-audio-card,hp-det-gpio:
199    maxItems: 1
200  simple-audio-card,mic-det-gpio:
201    maxItems: 1
202
203patternProperties:
204  "^simple-audio-card,cpu(@[0-9a-f]+)?$":
205    $ref: "#/definitions/dai"
206  "^simple-audio-card,codec(@[0-9a-f]+)?$":
207    $ref: "#/definitions/dai"
208  "^simple-audio-card,plat(@[0-9a-f]+)?$":
209    $ref: "#/definitions/dai"
210
211  "^simple-audio-card,dai-link(@[0-9a-f]+)?$":
212    description: |
213      Container for dai-link level properties and the CPU and CODEC sub-nodes.
214      This container may be omitted when the card has only one DAI link.
215    type: object
216    properties:
217      reg:
218        maxItems: 1
219
220      "#address-cells":
221        const: 1
222      "#size-cells":
223        const: 0
224      # common properties
225      frame-master:
226        $ref: "#/definitions/frame-master"
227      bitclock-master:
228        $ref: "#/definitions/bitclock-master"
229      frame-inversion:
230        $ref: "#/definitions/frame-inversion"
231      bitclock-inversion:
232        $ref: "#/definitions/bitclock-inversion"
233      format:
234        $ref: "#/definitions/format"
235      mclk-fs:
236        $ref: "#/definitions/mclk-fs"
237      aux-devs:
238        $ref: "#/definitions/aux-devs"
239      convert-rate:
240        $ref: "#/definitions/convert-rate"
241      convert-channels:
242        $ref: "#/definitions/convert-channels"
243      prefix:
244        $ref: "#/definitions/prefix"
245      pin-switches:
246        $ref: "#/definitions/pin-switches"
247      hp-det-gpio:
248        maxItems: 1
249      mic-det-gpio:
250        maxItems: 1
251
252    patternProperties:
253      "^cpu(-[0-9]+)?$":
254        $ref: "#/definitions/dai"
255      "^codec(-[0-9]+)?$":
256        $ref: "#/definitions/dai"
257    additionalProperties: false
258
259required:
260  - compatible
261
262additionalProperties: false
263
264examples:
265# --------------------
266# single DAI link
267# --------------------
268  - |
269    sound {
270        compatible = "simple-audio-card";
271        simple-audio-card,name = "VF610-Tower-Sound-Card";
272        simple-audio-card,format = "left_j";
273        simple-audio-card,bitclock-master = <&dailink0_master>;
274        simple-audio-card,frame-master = <&dailink0_master>;
275        simple-audio-card,widgets =
276                "Microphone", "Microphone Jack",
277                "Headphone", "Headphone Jack",
278                "Speaker", "External Speaker";
279        simple-audio-card,routing =
280                "MIC_IN", "Microphone Jack",
281                "Headphone Jack", "HP_OUT",
282                "External Speaker", "LINE_OUT";
283
284        simple-audio-card,cpu {
285            sound-dai = <&sh_fsi2 0>;
286        };
287
288        dailink0_master: simple-audio-card,codec {
289            sound-dai = <&ak4648>;
290            clocks = <&osc>;
291        };
292    };
293
294# --------------------
295# Multi DAI links
296# --------------------
297  - |
298    sound {
299        compatible = "simple-audio-card";
300        simple-audio-card,name = "Cubox Audio";
301
302        #address-cells = <1>;
303        #size-cells = <0>;
304
305        simple-audio-card,dai-link@0 {		/* I2S - HDMI */
306            reg = <0>;
307            format = "i2s";
308            cpu {
309                sound-dai = <&audio0>;
310            };
311            codec {
312                sound-dai = <&tda998x0>;
313            };
314        };
315
316        simple-audio-card,dai-link@1 {		/* S/PDIF - HDMI */
317            reg = <1>;
318            cpu {
319                sound-dai = <&audio1>;
320            };
321            codec {
322                sound-dai = <&tda998x1>;
323            };
324        };
325
326        simple-audio-card,dai-link@2 {		/* S/PDIF - S/PDIF */
327            reg = <2>;
328            cpu {
329                sound-dai = <&audio2>;
330            };
331            codec {
332                sound-dai = <&spdif_codec>;
333            };
334        };
335    };
336
337# --------------------
338# route audio from IMX6 SSI2 through TLV320DAC3100 codec
339# through TPA6130A2 amplifier to headphones:
340# --------------------
341  - |
342    sound {
343        compatible = "simple-audio-card";
344
345        simple-audio-card,widgets =
346            "Headphone", "Headphone Jack";
347        simple-audio-card,routing =
348            "Headphone Jack", "HPLEFT",
349            "Headphone Jack", "HPRIGHT",
350            "LEFTIN", "HPL",
351            "RIGHTIN", "HPR";
352        simple-audio-card,aux-devs = <&amp>;
353        simple-audio-card,cpu {
354            sound-dai = <&ssi2>;
355        };
356        simple-audio-card,codec {
357            sound-dai = <&codec>;
358            clocks = <&clocks>;
359        };
360    };
361
362# --------------------
363# Sampling Rate Conversion
364# --------------------
365  - |
366    sound {
367        compatible = "simple-audio-card";
368
369        simple-audio-card,name = "rsnd-ak4643";
370        simple-audio-card,format = "left_j";
371        simple-audio-card,bitclock-master = <&sndcodec>;
372        simple-audio-card,frame-master = <&sndcodec>;
373
374        simple-audio-card,convert-rate = <48000>;
375
376        simple-audio-card,prefix = "ak4642";
377        simple-audio-card,routing = "ak4642 Playback", "DAI0 Playback",
378                                    "DAI0 Capture", "ak4642 Capture";
379
380        sndcpu: simple-audio-card,cpu {
381            sound-dai = <&rcar_sound>;
382        };
383
384        sndcodec: simple-audio-card,codec {
385            sound-dai = <&ak4643>;
386            system-clock-frequency = <11289600>;
387        };
388    };
389
390# --------------------
391# 2 CPU 1 Codec (Mixing)
392# --------------------
393  - |
394    sound {
395        compatible = "simple-audio-card";
396        #address-cells = <1>;
397        #size-cells = <0>;
398
399        simple-audio-card,name = "rsnd-ak4643";
400        simple-audio-card,format = "left_j";
401        simple-audio-card,bitclock-master = <&dpcmcpu>;
402        simple-audio-card,frame-master = <&dpcmcpu>;
403
404        simple-audio-card,convert-rate = <48000>;
405        simple-audio-card,convert-channels = <2>;
406
407        simple-audio-card,routing = "ak4642 Playback", "DAI0 Playback",
408                                    "ak4642 Playback", "DAI1 Playback";
409
410        dpcmcpu: simple-audio-card,cpu@0 {
411            reg = <0>;
412            sound-dai = <&rcar_sound 0>;
413        };
414
415        simple-audio-card,cpu@1 {
416            reg = <1>;
417            sound-dai = <&rcar_sound 1>;
418        };
419
420        simple-audio-card,codec {
421            prefix = "ak4642";
422            sound-dai = <&ak4643>;
423            clocks = <&audio_clock>;
424        };
425    };
426
427# --------------------
428# Multi DAI links with DPCM:
429#
430# CPU0 ------ ak4613
431# CPU1 ------ PCM3168A-p  /* DPCM 1ch/2ch */
432# CPU2 --/                /* DPCM 3ch/4ch */
433# CPU3 --/                /* DPCM 5ch/6ch */
434# CPU4 --/                /* DPCM 7ch/8ch */
435# CPU5 ------ PCM3168A-c
436# --------------------
437  - |
438    sound {
439        compatible = "simple-audio-card";
440        #address-cells = <1>;
441        #size-cells = <0>;
442
443        simple-audio-card,routing =
444            "pcm3168a Playback", "DAI1 Playback",
445            "pcm3168a Playback", "DAI2 Playback",
446            "pcm3168a Playback", "DAI3 Playback",
447            "pcm3168a Playback", "DAI4 Playback";
448
449        simple-audio-card,dai-link@0 {
450            reg = <0>;
451            format = "left_j";
452            bitclock-master = <&sndcpu0>;
453            frame-master = <&sndcpu0>;
454
455            sndcpu0: cpu {
456                sound-dai = <&rcar_sound 0>;
457            };
458            codec {
459                sound-dai = <&ak4613>;
460            };
461        };
462
463        simple-audio-card,dai-link@1 {
464            reg = <1>;
465            format = "i2s";
466            bitclock-master = <&sndcpu1>;
467            frame-master = <&sndcpu1>;
468
469            convert-channels = <8>; /* TDM Split */
470
471            sndcpu1: cpu-0 {
472                sound-dai = <&rcar_sound 1>;
473            };
474            cpu-1 {
475                sound-dai = <&rcar_sound 2>;
476            };
477            cpu-2 {
478                sound-dai = <&rcar_sound 3>;
479            };
480            cpu-3 {
481                sound-dai = <&rcar_sound 4>;
482            };
483            codec {
484                mclk-fs = <512>;
485                prefix = "pcm3168a";
486                dai-tdm-slot-num = <8>;
487                sound-dai = <&pcm3168a 0>;
488            };
489        };
490
491        simple-audio-card,dai-link@2 {
492            reg = <2>;
493            format = "i2s";
494            bitclock-master = <&sndcpu2>;
495            frame-master = <&sndcpu2>;
496
497            sndcpu2: cpu {
498                sound-dai = <&rcar_sound 5>;
499            };
500            codec {
501                mclk-fs = <512>;
502                prefix = "pcm3168a";
503                sound-dai = <&pcm3168a 1>;
504            };
505        };
506    };
507