3 =============================================
5 =============================================
7 Renesas R-Car sound is constructed from below modules
10 SCU : Sampling Rate Converter Unit
11 - SRC : Sampling Rate Converter
13 - CTU : Channel Transfer Unit
15 - DVC : Digital Volume and Mute Function
16 SSIU : Serial Sound Interface Unit
17 SSI : Serial Sound Interface
19 See detail of each module's channels, connection, limitation on datasheet
21 =============================================
23 =============================================
25 Multi channel is supported by Multi-SSI, or TDM-SSI.
27 Multi-SSI : 6ch case, you can use stereo x 3 SSI
28 TDM-SSI : 6ch case, you can use TDM
30 =============================================
31 * Enable/Disable each modules
32 =============================================
34 See datasheet to check SRC/CTU/MIX/DVC connect-limitation.
35 DT controls enabling/disabling module.
36 ${LINUX}/arch/arm/boot/dts/r8a7790-lager.dts can be good example.
39 Playback: [MEM] -> [SRC2] -> [DVC0] -> [SSIU0/SSI0] -> [codec]
40 Capture: [MEM] <- [DVC1] <- [SRC3] <- [SSIU1/SSI1] <- [codec]
46 playback = <&ssi0 &src2 &dvc0>;
47 capture = <&ssi1 &src3 &dvc1>;
53 ${LINUX}/arch/arm/boot/dts/r8a7790.dts can be good example.
55 &src0 &ctu00 &mix0 &dvc0 &ssi0
56 &src1 &ctu01 &mix1 &dvc1 &ssi1
66 =============================================
67 * SRC (Sampling Rate Converter)
68 =============================================
73 SRC can convert [xx]Hz to [yy]Hz. Then, it has below 2 modes
75 Asynchronous mode: input data / output data are based on different clocks.
76 you can use this mode on Playback / Capture
77 Synchronous mode: input data / output data are based on same clocks.
78 This mode will be used if system doesn't have its input clock,
79 for example digital TV case.
80 you can use this mode on Playback
86 You need to use "renesas,rsrc-card" sound card for it.
90 compatible = "renesas,rsrc-card";
93 * SRC Asynchronous mode setting
95 * All input data will be converted to 48kHz
97 * Inputed 48kHz data will be converted to
100 convert-rate = <48000>;
103 sound-dai = <&rcar_sound>;
114 > amixer set "SRC Out Rate" on
116 > amixer set "SRC Out Rate" 48000
117 > amixer set "SRC Out Rate" 44100
119 =============================================
120 * CTU (Channel Transfer Unit)
121 =============================================
124 ------> [CTU] -------->
126 CTU can convert [xx]ch to [yy]ch, or exchange outputed channel.
127 CTU conversion needs matrix settings.
128 For more detail information, see below
130 Renesas R-Car datasheet
131 - Sampling Rate Converter Unit (SCU)
134 - Functional Blocks in CMD
136 Renesas R-Car datasheet
137 - Sampling Rate Converter Unit (SCU)
138 - Register Description
139 - CTUn Scale Value exx Register (CTUn_SVxxR)
141 ${LINUX}/sound/soc/sh/rcar/ctu.c
144 You need to use "renesas,rsrc-card" sound card for it.
148 compatible = "renesas,rsrc-card";
152 * All input data will be converted to 2ch
155 convert-channels = <2>;
158 sound-dai = <&rcar_sound>;
165 Ex) Exchange output channel
170 example of using matrix
171 output 0ch = (input 0ch x 0) + (input 1ch x 1)
172 output 1ch = (input 0ch x 1) + (input 1ch x 0)
174 amixer set "CTU Reset" on
175 amixer set "CTU Pass" 9,10
176 amixer set "CTU SV0" 0,4194304
177 amixer set "CTU SV1" 4194304,0
179 example of changing connection
180 amixer set "CTU Reset" on
181 amixer set "CTU Pass" 2,1
183 =============================================
185 =============================================
187 MIX merges 2 sounds path. You can see 2 sound interface on system,
188 and these sounds will be merged by MIX.
190 aplay -D plughw:0,0 xxxx.wav &
191 aplay -D plughw:0,1 yyyy.wav
193 You need to use "renesas,rsrc-card" sound card for it.
195 [MEM] -> [SRC1] -> [CTU02] -+-> [MIX0] -> [DVC0] -> [SSI0]
197 [MEM] -> [SRC2] -> [CTU03] -+
200 compatible = "renesas,rsrc-card";
203 sound-dai = <&rcar_sound 0>;
206 sound-dai = <&rcar_sound 1>;
217 playback = <&src1 &ctu02 &mix0 &dvc0 &ssi0>;
220 playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>;
225 =============================================
226 * DVC (Digital Volume and Mute Function)
227 =============================================
229 DVC controls Playback/Capture volume.
232 amixer set "DVC Out" 100%
235 amixer set "DVC In" 100%
238 amixer set "DVC Out Mute" on
241 amixer set "DVC In Mute" on
244 amixer set "DVC Out Ramp Up Rate" "0.125 dB/64 steps"
245 amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
246 amixer set "DVC Out Ramp" on
248 amixer set "DVC Out" 80% // Volume Down
249 amixer set "DVC Out" 100% // Volume Up
251 =============================================
252 * SSIU (Serial Sound Interface Unit)
253 =============================================
255 There is no DT settings for SSIU, because SSIU will be automatically
257 SSIU can avoid some under/over run error, because it has some buffer.
258 But you can't use it if SSI was PIO mode.
259 In DMA mode, you can select not to use SSIU by using "no-busif" on DT.
265 =============================================
266 * SSI (Serial Sound Interface)
267 =============================================
271 You can use PIO mode which is for connection check by using.
272 Note: The system will drop non-SSI modules in PIO mode
273 even though if DT is selecting other modules.
279 ** DMA mode without SSIU
281 You can use DMA without SSIU.
282 Note: under/over run, or noise are likely to occur
290 Each SSI can share WS pin. It is based on platform.
291 This is example if SSI1 want to share WS pin with SSI0
299 You can use Multi-SSI.
300 This is example of SSI0/SSI1/SSI2 (= for 6ch)
306 playback = <&ssi0 &ssi1 &ssi2 &src0 &dvc0>;
313 You can use TDM with SSI.
314 This is example of TDM 6ch.
315 Driver can automatically switches TDM <-> stereo mode in this case.
318 compatible = "simple-audio-card";
320 simple-audio-card,cpu {
321 /* system can use TDM 6ch */
322 dai-tdm-slot-num = <6>;
323 sound-dai = <&rcar_sound>;
325 simple-audio-card,codec {
331 =============================================
333 =============================================
335 - compatible : "renesas,rcar_sound-<soctype>", fallbacks
336 "renesas,rcar_sound-gen1" if generation1, and
337 "renesas,rcar_sound-gen2" if generation2
338 "renesas,rcar_sound-gen3" if generation3
339 Examples with soctypes are:
340 - "renesas,rcar_sound-r8a7778" (R-Car M1A)
341 - "renesas,rcar_sound-r8a7779" (R-Car H1)
342 - "renesas,rcar_sound-r8a7790" (R-Car H2)
343 - "renesas,rcar_sound-r8a7791" (R-Car M2-W)
344 - "renesas,rcar_sound-r8a7793" (R-Car M2-N)
345 - "renesas,rcar_sound-r8a7794" (R-Car E2)
346 - "renesas,rcar_sound-r8a7795" (R-Car H3)
347 - reg : Should contain the register physical address.
349 SRU/ADG/SSI if generation1
350 SRU/ADG/SSIU/SSI if generation2
351 - rcar_sound,ssi : Should contain SSI feature.
352 The number of SSI subnode should be same as HW.
353 see below for detail.
354 - rcar_sound,src : Should contain SRC feature.
355 The number of SRC subnode should be same as HW.
356 see below for detail.
357 - rcar_sound,ctu : Should contain CTU feature.
358 The number of CTU subnode should be same as HW.
359 see below for detail.
360 - rcar_sound,mix : Should contain MIX feature.
361 The number of MIX subnode should be same as HW.
362 see below for detail.
363 - rcar_sound,dvc : Should contain DVC feature.
364 The number of DVC subnode should be same as HW.
365 see below for detail.
366 - rcar_sound,dai : DAI contents.
367 The number of DAI subnode should be same as HW.
368 see below for detail.
369 - #sound-dai-cells : it must be 0 if your system is using single DAI
370 it must be 1 if your system is using multi DAI
373 - #clock-cells : it must be 0 if your system has audio_clkout
374 it must be 1 if your system has audio_clkout0/1/2/3
375 - clock-frequency : for all audio_clkout0/1/2/3
377 SSI subnode properties:
378 - interrupts : Should contain SSI interrupt for PIO transfer
379 - shared-pin : if shared clock pin
380 - pio-transfer : use PIO transfer mode
381 - no-busif : BUSIF is not ussed when [mem -> SSI] via DMA case
382 - dma : Should contain Audio DMAC entry
383 - dma-names : SSI case "rx" (=playback), "tx" (=capture)
384 SSIU case "rxu" (=playback), "txu" (=capture)
386 SRC subnode properties:
387 - dma : Should contain Audio DMAC entry
388 - dma-names : "rx" (=playback), "tx" (=capture)
390 DVC subnode properties:
391 - dma : Should contain Audio DMAC entry
392 - dma-names : "tx" (=playback/capture)
394 DAI subnode properties:
395 - playback : list of playback modules
396 - capture : list of capture modules
399 =============================================
401 =============================================
403 rcar_sound: sound@ec500000 {
404 #sound-dai-cells = <1>;
405 compatible = "renesas,rcar_sound-r8a7791", "renesas,rcar_sound-gen2";
406 reg = <0 0xec500000 0 0x1000>, /* SCU */
407 <0 0xec5a0000 0 0x100>, /* ADG */
408 <0 0xec540000 0 0x1000>, /* SSIU */
409 <0 0xec541000 0 0x1280>, /* SSI */
410 <0 0xec740000 0 0x200>; /* Audio DMAC peri peri*/
411 reg-names = "scu", "adg", "ssiu", "ssi", "audmapp";
413 clocks = <&mstp10_clks R8A7790_CLK_SSI_ALL>,
414 <&mstp10_clks R8A7790_CLK_SSI9>, <&mstp10_clks R8A7790_CLK_SSI8>,
415 <&mstp10_clks R8A7790_CLK_SSI7>, <&mstp10_clks R8A7790_CLK_SSI6>,
416 <&mstp10_clks R8A7790_CLK_SSI5>, <&mstp10_clks R8A7790_CLK_SSI4>,
417 <&mstp10_clks R8A7790_CLK_SSI3>, <&mstp10_clks R8A7790_CLK_SSI2>,
418 <&mstp10_clks R8A7790_CLK_SSI1>, <&mstp10_clks R8A7790_CLK_SSI0>,
419 <&mstp10_clks R8A7790_CLK_SCU_SRC9>, <&mstp10_clks R8A7790_CLK_SCU_SRC8>,
420 <&mstp10_clks R8A7790_CLK_SCU_SRC7>, <&mstp10_clks R8A7790_CLK_SCU_SRC6>,
421 <&mstp10_clks R8A7790_CLK_SCU_SRC5>, <&mstp10_clks R8A7790_CLK_SCU_SRC4>,
422 <&mstp10_clks R8A7790_CLK_SCU_SRC3>, <&mstp10_clks R8A7790_CLK_SCU_SRC2>,
423 <&mstp10_clks R8A7790_CLK_SCU_SRC1>, <&mstp10_clks R8A7790_CLK_SCU_SRC0>,
424 <&mstp10_clks R8A7790_CLK_SCU_DVC0>, <&mstp10_clks R8A7790_CLK_SCU_DVC1>,
425 <&audio_clk_a>, <&audio_clk_b>, <&audio_clk_c>, <&m2_clk>;
426 clock-names = "ssi-all",
427 "ssi.9", "ssi.8", "ssi.7", "ssi.6", "ssi.5",
428 "ssi.4", "ssi.3", "ssi.2", "ssi.1", "ssi.0",
429 "src.9", "src.8", "src.7", "src.6", "src.5",
430 "src.4", "src.3", "src.2", "src.1", "src.0",
432 "clk_a", "clk_b", "clk_c", "clk_i";
436 dmas = <&audma0 0xbc>;
440 dmas = <&audma0 0xbe>;
463 interrupts = <0 352 IRQ_TYPE_LEVEL_HIGH>;
464 dmas = <&audma0 0x85>, <&audma1 0x9a>;
465 dma-names = "rx", "tx";
468 interrupts = <0 353 IRQ_TYPE_LEVEL_HIGH>;
469 dmas = <&audma0 0x87>, <&audma1 0x9c>;
470 dma-names = "rx", "tx";
473 interrupts = <0 354 IRQ_TYPE_LEVEL_HIGH>;
474 dmas = <&audma0 0x89>, <&audma1 0x9e>;
475 dma-names = "rx", "tx";
478 interrupts = <0 355 IRQ_TYPE_LEVEL_HIGH>;
479 dmas = <&audma0 0x8b>, <&audma1 0xa0>;
480 dma-names = "rx", "tx";
483 interrupts = <0 356 IRQ_TYPE_LEVEL_HIGH>;
484 dmas = <&audma0 0x8d>, <&audma1 0xb0>;
485 dma-names = "rx", "tx";
488 interrupts = <0 357 IRQ_TYPE_LEVEL_HIGH>;
489 dmas = <&audma0 0x8f>, <&audma1 0xb2>;
490 dma-names = "rx", "tx";
493 interrupts = <0 358 IRQ_TYPE_LEVEL_HIGH>;
494 dmas = <&audma0 0x91>, <&audma1 0xb4>;
495 dma-names = "rx", "tx";
498 interrupts = <0 359 IRQ_TYPE_LEVEL_HIGH>;
499 dmas = <&audma0 0x93>, <&audma1 0xb6>;
500 dma-names = "rx", "tx";
503 interrupts = <0 360 IRQ_TYPE_LEVEL_HIGH>;
504 dmas = <&audma0 0x95>, <&audma1 0xb8>;
505 dma-names = "rx", "tx";
508 interrupts = <0 361 IRQ_TYPE_LEVEL_HIGH>;
509 dmas = <&audma0 0x97>, <&audma1 0xba>;
510 dma-names = "rx", "tx";
516 interrupts = <0 370 IRQ_TYPE_LEVEL_HIGH>;
517 dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
518 dma-names = "rx", "tx", "rxu", "txu";
521 interrupts = <0 371 IRQ_TYPE_LEVEL_HIGH>;
522 dmas = <&audma0 0x03>, <&audma1 0x04>, <&audma0 0x49>, <&audma1 0x4a>;
523 dma-names = "rx", "tx", "rxu", "txu";
526 interrupts = <0 372 IRQ_TYPE_LEVEL_HIGH>;
527 dmas = <&audma0 0x05>, <&audma1 0x06>, <&audma0 0x63>, <&audma1 0x64>;
528 dma-names = "rx", "tx", "rxu", "txu";
531 interrupts = <0 373 IRQ_TYPE_LEVEL_HIGH>;
532 dmas = <&audma0 0x07>, <&audma1 0x08>, <&audma0 0x6f>, <&audma1 0x70>;
533 dma-names = "rx", "tx", "rxu", "txu";
536 interrupts = <0 374 IRQ_TYPE_LEVEL_HIGH>;
537 dmas = <&audma0 0x09>, <&audma1 0x0a>, <&audma0 0x71>, <&audma1 0x72>;
538 dma-names = "rx", "tx", "rxu", "txu";
541 interrupts = <0 375 IRQ_TYPE_LEVEL_HIGH>;
542 dmas = <&audma0 0x0b>, <&audma1 0x0c>, <&audma0 0x73>, <&audma1 0x74>;
543 dma-names = "rx", "tx", "rxu", "txu";
546 interrupts = <0 376 IRQ_TYPE_LEVEL_HIGH>;
547 dmas = <&audma0 0x0d>, <&audma1 0x0e>, <&audma0 0x75>, <&audma1 0x76>;
548 dma-names = "rx", "tx", "rxu", "txu";
551 interrupts = <0 377 IRQ_TYPE_LEVEL_HIGH>;
552 dmas = <&audma0 0x0f>, <&audma1 0x10>, <&audma0 0x79>, <&audma1 0x7a>;
553 dma-names = "rx", "tx", "rxu", "txu";
556 interrupts = <0 378 IRQ_TYPE_LEVEL_HIGH>;
557 dmas = <&audma0 0x11>, <&audma1 0x12>, <&audma0 0x7b>, <&audma1 0x7c>;
558 dma-names = "rx", "tx", "rxu", "txu";
561 interrupts = <0 379 IRQ_TYPE_LEVEL_HIGH>;
562 dmas = <&audma0 0x13>, <&audma1 0x14>, <&audma0 0x7d>, <&audma1 0x7e>;
563 dma-names = "rx", "tx", "rxu", "txu";
569 playback = <&ssi5 &src5>;
587 =============================================
588 Example: simple sound card
589 =============================================
592 compatible = "simple-audio-card";
594 simple-audio-card,format = "left_j";
595 simple-audio-card,bitclock-master = <&sndcodec>;
596 simple-audio-card,frame-master = <&sndcodec>;
598 sndcpu: simple-audio-card,cpu {
599 sound-dai = <&rcar_sound>;
602 sndcodec: simple-audio-card,codec {
603 sound-dai = <&ak4643>;
604 clocks = <&audio_clock>;
609 pinctrl-0 = <&sound_pins &sound_clk_pins>;
610 pinctrl-names = "default";
613 #sound-dai-cells = <0>;
619 playback = <&ssi0 &src2 &dvc0>;
620 capture = <&ssi1 &src3 &dvc1>;
629 =============================================
630 Example: simple sound card for TDM
631 =============================================
634 compatible = "simple-audio-card";
636 simple-audio-card,format = "left_j";
637 simple-audio-card,bitclock-master = <&sndcodec>;
638 simple-audio-card,frame-master = <&sndcodec>;
640 sndcpu: simple-audio-card,cpu {
641 sound-dai = <&rcar_sound>;
642 dai-tdm-slot-num = <6>;
645 sndcodec: simple-audio-card,codec {
650 =============================================
651 Example: simple sound card for Multi channel
652 =============================================
655 pinctrl-0 = <&sound_pins &sound_clk_pins>;
656 pinctrl-names = "default";
659 #sound-dai-cells = <0>;
665 playback = <&ssi0 &ssi1 &ssi2 &src0 &dvc0>;