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