1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/sound/renesas,rsnd.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Renesas R-Car Sound Driver Device Tree Bindings
8
9maintainers:
10  - Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
11
12properties:
13
14  compatible:
15    oneOf:
16      # for Gen1 SoC
17      - items:
18          - enum:
19              - renesas,rcar_sound-r8a7778   # R-Car M1A
20              - renesas,rcar_sound-r8a7779   # R-Car H1
21          - enum:
22              - renesas,rcar_sound-gen1
23      # for Gen2 SoC
24      - items:
25          - enum:
26              - renesas,rcar_sound-r8a7742   # RZ/G1H
27              - renesas,rcar_sound-r8a7743   # RZ/G1M
28              - renesas,rcar_sound-r8a7744   # RZ/G1N
29              - renesas,rcar_sound-r8a7745   # RZ/G1E
30              - renesas,rcar_sound-r8a77470  # RZ/G1C
31              - renesas,rcar_sound-r8a7790   # R-Car H2
32              - renesas,rcar_sound-r8a7791   # R-Car M2-W
33              - renesas,rcar_sound-r8a7793   # R-Car M2-N
34              - renesas,rcar_sound-r8a7794   # R-Car E2
35          - enum:
36              - renesas,rcar_sound-gen2
37      # for Gen3 SoC
38      - items:
39          - enum:
40              - renesas,rcar_sound-r8a774a1  # RZ/G2M
41              - renesas,rcar_sound-r8a774b1  # RZ/G2N
42              - renesas,rcar_sound-r8a774c0  # RZ/G2E
43              - renesas,rcar_sound-r8a774e1  # RZ/G2H
44              - renesas,rcar_sound-r8a7795   # R-Car H3
45              - renesas,rcar_sound-r8a7796   # R-Car M3-W
46              - renesas,rcar_sound-r8a77961  # R-Car M3-W+
47              - renesas,rcar_sound-r8a77965  # R-Car M3-N
48              - renesas,rcar_sound-r8a77990  # R-Car E3
49              - renesas,rcar_sound-r8a77995  # R-Car D3
50          - enum:
51              - renesas,rcar_sound-gen3
52      # for Generic
53      - items:
54          - enum:
55              - renesas,rcar_sound-gen1
56              - renesas,rcar_sound-gen2
57              - renesas,rcar_sound-gen3
58
59  reg:
60    minItems: 1
61    maxItems: 5
62
63  reg-names:
64    minItems: 1
65    maxItems: 5
66
67  "#sound-dai-cells":
68    description: |
69      it must be 0 if your system is using single DAI
70      it must be 1 if your system is using multi  DAIs
71    enum: [0, 1]
72
73  "#clock-cells":
74    description: |
75      it must be 0 if your system has audio_clkout
76      it must be 1 if your system has audio_clkout0/1/2/3
77    enum: [0, 1]
78
79  clock-frequency:
80    description: for audio_clkout0/1/2/3
81    $ref: /schemas/types.yaml#/definitions/uint32-array
82
83  clkout-lr-asynchronous:
84    description: audio_clkoutn is asynchronizes with lr-clock.
85    $ref: /schemas/types.yaml#/definitions/flag
86
87  power-domains: true
88
89  resets:
90    maxItems: 11
91
92  reset-names:
93    maxItems: 11
94
95  clocks:
96    description: References to SSI/SRC/MIX/CTU/DVC/AUDIO_CLK clocks.
97    minItems: 1
98    maxItems: 31
99
100  clock-names:
101    description: List of necessary clock names.
102    minItems: 1
103    maxItems: 31
104    items:
105      oneOf:
106        - const: ssi-all
107        - pattern: '^ssi\.[0-9]$'
108        - pattern: '^src\.[0-9]$'
109        - pattern: '^mix\.[0-1]$'
110        - pattern: '^ctu\.[0-1]$'
111        - pattern: '^dvc\.[0-1]$'
112        - pattern: '^clk_(a|b|c|i)$'
113
114  port: true
115
116# use patternProperties to avoid naming "xxx,yyy" issue
117patternProperties:
118  "^rcar_sound,dvc$":
119    description: DVC subnode.
120    type: object
121    patternProperties:
122      "^dvc-[0-1]$":
123        type: object
124        properties:
125          dmas:
126            maxItems: 1
127          dma-names:
128            const: "tx"
129        required:
130          - dmas
131          - dma-names
132    additionalProperties: false
133
134  "^rcar_sound,mix$":
135    description: MIX subnode.
136    type: object
137    patternProperties:
138      "^mix-[0-1]$":
139        type: object
140        # no properties
141    additionalProperties: false
142
143  "^rcar_sound,ctu$":
144    description: CTU subnode.
145    type: object
146    patternProperties:
147      "^ctu-[0-7]$":
148        type: object
149        # no properties
150    additionalProperties: false
151
152  "^rcar_sound,src$":
153    description: SRC subnode.
154    type: object
155    patternProperties:
156      "^src-[0-9]$":
157        type: object
158        properties:
159          interrupts:
160            maxItems: 1
161          dmas:
162            maxItems: 2
163          dma-names:
164            allOf:
165              - items:
166                  enum:
167                    - tx
168                    - rx
169        required:
170          - interrupts
171          - dmas
172          - dma-names
173    additionalProperties: false
174
175  "^rcar_sound,ssiu$":
176    description: SSIU subnode.
177    type: object
178    patternProperties:
179      "^ssiu-[0-9]+$":
180        type: object
181        properties:
182          dmas:
183            maxItems: 2
184          dma-names:
185            allOf:
186              - items:
187                  enum:
188                    - tx
189                    - rx
190        required:
191          - dmas
192          - dma-names
193    additionalProperties: false
194
195  "^rcar_sound,ssi$":
196    description: SSI subnode.
197    type: object
198    patternProperties:
199      "^ssi-[0-9]$":
200        type: object
201        properties:
202          interrupts:
203            maxItems: 1
204          dmas:
205            minItems: 2
206            maxItems: 4
207          dma-names:
208            allOf:
209              - items:
210                  enum:
211                    - tx
212                    - rx
213                    - txu # if no ssiu node
214                    - rxu # if no ssiu node
215
216          shared-pin:
217            description: shared clock pin
218            $ref: /schemas/types.yaml#/definitions/flag
219          pio-transfer:
220            description: PIO transfer mode
221            $ref: /schemas/types.yaml#/definitions/flag
222          no-busif:
223            description: BUSIF is not used when [mem -> SSI] via DMA case
224            $ref: /schemas/types.yaml#/definitions/flag
225        required:
226          - interrupts
227          - dmas
228          - dma-names
229    additionalProperties: false
230
231  # For DAI base
232  "^rcar_sound,dai$":
233    description: DAI subnode.
234    type: object
235    patternProperties:
236      "^dai([0-9]+)?$":
237        type: object
238        properties:
239          playback:
240            $ref: /schemas/types.yaml#/definitions/phandle-array
241          capture:
242            $ref: /schemas/types.yaml#/definitions/phandle-array
243        anyOf:
244          - required:
245              - playback
246          - required:
247              - capture
248    additionalProperties: false
249
250required:
251  - compatible
252  - reg
253  - reg-names
254  - clocks
255  - clock-names
256  - "#sound-dai-cells"
257
258allOf:
259  - $ref: audio-graph.yaml#
260  - $ref: audio-graph-port.yaml#
261  - if:
262      properties:
263        compatible:
264          contains:
265            const: renesas,rcar_sound-gen1
266    then:
267      properties:
268        reg:
269          maxItems: 3
270        reg-names:
271          maxItems: 3
272          items:
273            enum:
274              - scu
275              - ssi
276              - adg
277    else:
278      properties:
279        reg:
280          maxItems: 5
281        reg-names:
282          maxItems: 5
283          items:
284            enum:
285              - scu
286              - adg
287              - ssiu
288              - ssi
289              - audmapp
290
291additionalProperties: false
292
293examples:
294  - |
295    rcar_sound: sound@ec500000 {
296        #sound-dai-cells = <1>;
297        compatible = "renesas,rcar_sound-r8a7790", "renesas,rcar_sound-gen2";
298        reg = <0xec500000 0x1000>, /* SCU  */
299              <0xec5a0000 0x100>,  /* ADG  */
300              <0xec540000 0x1000>, /* SSIU */
301              <0xec541000 0x1280>, /* SSI  */
302              <0xec740000 0x200>;  /* Audio DMAC peri peri*/
303        reg-names = "scu", "adg", "ssiu", "ssi", "audmapp";
304
305        clocks = <&mstp10_clks 1005>,                      /* SSI-ALL    */
306                 <&mstp10_clks 1006>, <&mstp10_clks 1007>, /* SSI9, SSI8 */
307                 <&mstp10_clks 1008>, <&mstp10_clks 1009>, /* SSI7, SSI6 */
308                 <&mstp10_clks 1010>, <&mstp10_clks 1011>, /* SSI5, SSI4 */
309                 <&mstp10_clks 1012>, <&mstp10_clks 1013>, /* SSI3, SSI2 */
310                 <&mstp10_clks 1014>, <&mstp10_clks 1015>, /* SSI1, SSI0 */
311                 <&mstp10_clks 1022>, <&mstp10_clks 1023>, /* SRC9, SRC8 */
312                 <&mstp10_clks 1024>, <&mstp10_clks 1025>, /* SRC7, SRC6 */
313                 <&mstp10_clks 1026>, <&mstp10_clks 1027>, /* SRC5, SRC4 */
314                 <&mstp10_clks 1028>, <&mstp10_clks 1029>, /* SRC3, SRC2 */
315                 <&mstp10_clks 1030>, <&mstp10_clks 1031>, /* SRC1, SRC0 */
316                 <&mstp10_clks 1020>, <&mstp10_clks 1021>, /* MIX1, MIX0 */
317                 <&mstp10_clks 1020>, <&mstp10_clks 1021>, /* CTU1, CTU0 */
318                 <&mstp10_clks 1019>, <&mstp10_clks 1018>, /* DVC0, DVC1 */
319                 <&audio_clk_a>, <&audio_clk_b>,           /* CLKA, CLKB */
320                 <&audio_clk_c>, <&audio_clk_i>;           /* CLKC, CLKI */
321
322        clock-names = "ssi-all",
323                      "ssi.9", "ssi.8",
324                      "ssi.7", "ssi.6",
325                      "ssi.5", "ssi.4",
326                      "ssi.3", "ssi.2",
327                      "ssi.1", "ssi.0",
328                      "src.9", "src.8",
329                      "src.7", "src.6",
330                      "src.5", "src.4",
331                      "src.3", "src.2",
332                      "src.1", "src.0",
333                      "mix.1", "mix.0",
334                      "ctu.1", "ctu.0",
335                      "dvc.0", "dvc.1",
336                      "clk_a", "clk_b",
337                      "clk_c", "clk_i";
338
339        rcar_sound,dvc {
340               dvc0: dvc-0 {
341                    dmas = <&audma0 0xbc>;
342                    dma-names = "tx";
343               };
344               dvc1: dvc-1 {
345                    dmas = <&audma0 0xbe>;
346                    dma-names = "tx";
347               };
348        };
349
350        rcar_sound,mix {
351            mix0: mix-0 { };
352            mix1: mix-1 { };
353        };
354
355        rcar_sound,ctu {
356            ctu00: ctu-0 { };
357            ctu01: ctu-1 { };
358            ctu02: ctu-2 { };
359            ctu03: ctu-3 { };
360            ctu10: ctu-4 { };
361            ctu11: ctu-5 { };
362            ctu12: ctu-6 { };
363            ctu13: ctu-7 { };
364        };
365
366        rcar_sound,src {
367            src0: src-0 {
368                status = "disabled";
369            };
370            src1: src-1 {
371                interrupts = <0 353 0>;
372                dmas = <&audma0 0x87>, <&audma1 0x9c>;
373                dma-names = "rx", "tx";
374            };
375            /* skip after src-2 */
376        };
377
378        rcar_sound,ssiu {
379            ssiu00: ssiu-0 {
380                dmas = <&audma0 0x15>, <&audma1 0x16>;
381                dma-names = "rx", "tx";
382            };
383            ssiu01: ssiu-1 {
384                dmas = <&audma0 0x35>, <&audma1 0x36>;
385                dma-names = "rx", "tx";
386            };
387            /* skip after ssiu-2 */
388        };
389
390        rcar_sound,ssi {
391            ssi0: ssi-0 {
392                interrupts = <0 370 1>;
393                dmas = <&audma0 0x01>, <&audma1 0x02>;
394                dma-names = "rx", "tx";
395            };
396            ssi1: ssi-1 {
397                interrupts = <0 371 1>;
398                dmas = <&audma0 0x03>, <&audma1 0x04>;
399                dma-names = "rx", "tx";
400            };
401            /* skip other ssi-2 */
402        };
403
404        /* DAI base */
405        rcar_sound,dai {
406            dai0 {
407                playback = <&ssi5 &src5>;
408                capture  = <&ssi6>;
409            };
410            dai1 {
411                playback = <&ssi3>;
412            };
413            dai2 {
414                capture  = <&ssi4>;
415            };
416            dai3 {
417                playback = <&ssi7>;
418            };
419            dai4 {
420                capture  = <&ssi8>;
421            };
422        };
423
424        /* assume audio-graph */
425        port {
426            rsnd_endpoint: endpoint {
427                remote-endpoint = <&codec_endpoint>;
428
429                dai-format = "left_j";
430                bitclock-master = <&rsnd_endpoint0>;
431                frame-master = <&rsnd_endpoint0>;
432
433                playback = <&ssi0 &src0 &dvc0>;
434                capture  = <&ssi1 &src1 &dvc1>;
435            };
436        };
437    };
438
439
440    /* assume audio-graph */
441    codec {
442        port {
443            codec_endpoint: endpoint {
444                remote-endpoint = <&rsnd_endpoint>;
445            };
446        };
447    };
448