3 =============================================
5 =============================================
7 Renesas R-Car and RZ/G 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 "simple-scu-audio-card" sound card for it.
90 compatible = "simple-scu-audio-card";
93 * SRC Asynchronous mode setting
95 * All input data will be converted to 48kHz
97 * Inputed 48kHz data will be converted to
100 simple-audio-card,convert-rate = <48000>;
102 simple-audio-card,cpu {
103 sound-dai = <&rcar_sound>;
105 simple-audio-card,codec {
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 "simple-scu-audio-card" sound card for it.
148 compatible = "simple-scu-audio-card";
152 * All input data will be converted to 2ch
155 simple-audio-card,convert-channels = <2>;
157 simple-audio-card,cpu {
158 sound-dai = <&rcar_sound>;
160 simple-audio-card,codec {
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 "simple-scu-audio-card" sound card for it.
195 [MEM] -> [SRC1] -> [CTU02] -+-> [MIX0] -> [DVC0] -> [SSI0]
197 [MEM] -> [SRC2] -> [CTU03] -+
200 #address-cells = <1>;
203 compatible = "simple-scu-audio-card";
205 simple-audio-card,cpu@0 {
207 sound-dai = <&rcar_sound 0>;
209 simple-audio-card,cpu@1 {
211 sound-dai = <&rcar_sound 1>;
213 simple-audio-card,codec {
222 playback = <&src1 &ctu02 &mix0 &dvc0 &ssi0>;
225 playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>;
230 =============================================
231 * DVC (Digital Volume and Mute Function)
232 =============================================
234 DVC controls Playback/Capture volume.
237 amixer set "DVC Out" 100%
240 amixer set "DVC In" 100%
243 amixer set "DVC Out Mute" on
246 amixer set "DVC In Mute" on
249 amixer set "DVC Out Ramp Up Rate" "0.125 dB/64 steps"
250 amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
251 amixer set "DVC Out Ramp" on
253 amixer set "DVC Out" 80% // Volume Down
254 amixer set "DVC Out" 100% // Volume Up
256 =============================================
257 * SSIU (Serial Sound Interface Unit)
258 =============================================
260 There is no DT settings for SSIU, because SSIU will be automatically
262 SSIU can avoid some under/over run error, because it has some buffer.
263 But you can't use it if SSI was PIO mode.
264 In DMA mode, you can select not to use SSIU by using "no-busif" on DT.
270 =============================================
271 * SSI (Serial Sound Interface)
272 =============================================
276 You can use PIO mode which is for connection check by using.
277 Note: The system will drop non-SSI modules in PIO mode
278 even though if DT is selecting other modules.
284 ** DMA mode without SSIU
286 You can use DMA without SSIU.
287 Note: under/over run, or noise are likely to occur
295 Each SSI can share WS pin. It is based on platform.
296 This is example if SSI1 want to share WS pin with SSI0
304 You can use Multi-SSI.
305 This is example of SSI0/SSI1/SSI2 (= for 6ch)
311 playback = <&ssi0 &ssi1 &ssi2 &src0 &dvc0>;
318 You can use TDM with SSI.
319 This is example of TDM 6ch.
320 Driver can automatically switches TDM <-> stereo mode in this case.
323 compatible = "simple-audio-card";
325 simple-audio-card,cpu {
326 /* system can use TDM 6ch */
327 dai-tdm-slot-num = <6>;
328 sound-dai = <&rcar_sound>;
330 simple-audio-card,codec {
336 =============================================
338 =============================================
340 - compatible : "renesas,rcar_sound-<soctype>", fallbacks
341 "renesas,rcar_sound-gen1" if generation1, and
342 "renesas,rcar_sound-gen2" if generation2 (or RZ/G1)
343 "renesas,rcar_sound-gen3" if generation3
344 Examples with soctypes are:
345 - "renesas,rcar_sound-r8a7743" (RZ/G1M)
346 - "renesas,rcar_sound-r8a7745" (RZ/G1E)
347 - "renesas,rcar_sound-r8a7778" (R-Car M1A)
348 - "renesas,rcar_sound-r8a7779" (R-Car H1)
349 - "renesas,rcar_sound-r8a7790" (R-Car H2)
350 - "renesas,rcar_sound-r8a7791" (R-Car M2-W)
351 - "renesas,rcar_sound-r8a7793" (R-Car M2-N)
352 - "renesas,rcar_sound-r8a7794" (R-Car E2)
353 - "renesas,rcar_sound-r8a7795" (R-Car H3)
354 - reg : Should contain the register physical address.
356 SRU/ADG/SSI if generation1
357 SRU/ADG/SSIU/SSI if generation2
358 - rcar_sound,ssi : Should contain SSI feature.
359 The number of SSI subnode should be same as HW.
360 see below for detail.
361 - rcar_sound,src : Should contain SRC feature.
362 The number of SRC subnode should be same as HW.
363 see below for detail.
364 - rcar_sound,ctu : Should contain CTU feature.
365 The number of CTU subnode should be same as HW.
366 see below for detail.
367 - rcar_sound,mix : Should contain MIX feature.
368 The number of MIX subnode should be same as HW.
369 see below for detail.
370 - rcar_sound,dvc : Should contain DVC feature.
371 The number of DVC subnode should be same as HW.
372 see below for detail.
373 - rcar_sound,dai : DAI contents.
374 The number of DAI subnode should be same as HW.
375 see below for detail.
376 - #sound-dai-cells : it must be 0 if your system is using single DAI
377 it must be 1 if your system is using multi DAI
378 - clocks : References to SSI/SRC/MIX/CTU/DVC/AUDIO_CLK clocks.
379 - clock-names : List of necessary clock names.
380 "ssi-all", "ssi.X", "src.X", "mix.X", "ctu.X",
381 "dvc.X", "clk_a", "clk_b", "clk_c", "clk_i"
384 - #clock-cells : it must be 0 if your system has audio_clkout
385 it must be 1 if your system has audio_clkout0/1/2/3
386 - clock-frequency : for all audio_clkout0/1/2/3
387 - clkout-lr-asynchronous : boolean property. it indicates that audio_clkoutn
388 is asynchronizes with lr-clock.
389 - resets : References to SSI resets.
390 - reset-names : List of valid reset names.
393 SSI subnode properties:
394 - interrupts : Should contain SSI interrupt for PIO transfer
395 - shared-pin : if shared clock pin
396 - pio-transfer : use PIO transfer mode
397 - no-busif : BUSIF is not ussed when [mem -> SSI] via DMA case
398 - dma : Should contain Audio DMAC entry
399 - dma-names : SSI case "rx" (=playback), "tx" (=capture)
400 SSIU case "rxu" (=playback), "txu" (=capture)
402 SRC subnode properties:
403 - dma : Should contain Audio DMAC entry
404 - dma-names : "rx" (=playback), "tx" (=capture)
406 DVC subnode properties:
407 - dma : Should contain Audio DMAC entry
408 - dma-names : "tx" (=playback/capture)
410 DAI subnode properties:
411 - playback : list of playback modules
412 - capture : list of capture modules
415 =============================================
417 =============================================
419 rcar_sound: sound@ec500000 {
420 #sound-dai-cells = <1>;
421 compatible = "renesas,rcar_sound-r8a7791", "renesas,rcar_sound-gen2";
422 reg = <0 0xec500000 0 0x1000>, /* SCU */
423 <0 0xec5a0000 0 0x100>, /* ADG */
424 <0 0xec540000 0 0x1000>, /* SSIU */
425 <0 0xec541000 0 0x1280>, /* SSI */
426 <0 0xec740000 0 0x200>; /* Audio DMAC peri peri*/
427 reg-names = "scu", "adg", "ssiu", "ssi", "audmapp";
429 clocks = <&mstp10_clks R8A7790_CLK_SSI_ALL>,
430 <&mstp10_clks R8A7790_CLK_SSI9>, <&mstp10_clks R8A7790_CLK_SSI8>,
431 <&mstp10_clks R8A7790_CLK_SSI7>, <&mstp10_clks R8A7790_CLK_SSI6>,
432 <&mstp10_clks R8A7790_CLK_SSI5>, <&mstp10_clks R8A7790_CLK_SSI4>,
433 <&mstp10_clks R8A7790_CLK_SSI3>, <&mstp10_clks R8A7790_CLK_SSI2>,
434 <&mstp10_clks R8A7790_CLK_SSI1>, <&mstp10_clks R8A7790_CLK_SSI0>,
435 <&mstp10_clks R8A7790_CLK_SCU_SRC9>, <&mstp10_clks R8A7790_CLK_SCU_SRC8>,
436 <&mstp10_clks R8A7790_CLK_SCU_SRC7>, <&mstp10_clks R8A7790_CLK_SCU_SRC6>,
437 <&mstp10_clks R8A7790_CLK_SCU_SRC5>, <&mstp10_clks R8A7790_CLK_SCU_SRC4>,
438 <&mstp10_clks R8A7790_CLK_SCU_SRC3>, <&mstp10_clks R8A7790_CLK_SCU_SRC2>,
439 <&mstp10_clks R8A7790_CLK_SCU_SRC1>, <&mstp10_clks R8A7790_CLK_SCU_SRC0>,
440 <&mstp10_clks R8A7790_CLK_SCU_DVC0>, <&mstp10_clks R8A7790_CLK_SCU_DVC1>,
441 <&audio_clk_a>, <&audio_clk_b>, <&audio_clk_c>, <&m2_clk>;
442 clock-names = "ssi-all",
443 "ssi.9", "ssi.8", "ssi.7", "ssi.6", "ssi.5",
444 "ssi.4", "ssi.3", "ssi.2", "ssi.1", "ssi.0",
445 "src.9", "src.8", "src.7", "src.6", "src.5",
446 "src.4", "src.3", "src.2", "src.1", "src.0",
448 "clk_a", "clk_b", "clk_c", "clk_i";
452 dmas = <&audma0 0xbc>;
456 dmas = <&audma0 0xbe>;
479 interrupts = <0 352 IRQ_TYPE_LEVEL_HIGH>;
480 dmas = <&audma0 0x85>, <&audma1 0x9a>;
481 dma-names = "rx", "tx";
484 interrupts = <0 353 IRQ_TYPE_LEVEL_HIGH>;
485 dmas = <&audma0 0x87>, <&audma1 0x9c>;
486 dma-names = "rx", "tx";
489 interrupts = <0 354 IRQ_TYPE_LEVEL_HIGH>;
490 dmas = <&audma0 0x89>, <&audma1 0x9e>;
491 dma-names = "rx", "tx";
494 interrupts = <0 355 IRQ_TYPE_LEVEL_HIGH>;
495 dmas = <&audma0 0x8b>, <&audma1 0xa0>;
496 dma-names = "rx", "tx";
499 interrupts = <0 356 IRQ_TYPE_LEVEL_HIGH>;
500 dmas = <&audma0 0x8d>, <&audma1 0xb0>;
501 dma-names = "rx", "tx";
504 interrupts = <0 357 IRQ_TYPE_LEVEL_HIGH>;
505 dmas = <&audma0 0x8f>, <&audma1 0xb2>;
506 dma-names = "rx", "tx";
509 interrupts = <0 358 IRQ_TYPE_LEVEL_HIGH>;
510 dmas = <&audma0 0x91>, <&audma1 0xb4>;
511 dma-names = "rx", "tx";
514 interrupts = <0 359 IRQ_TYPE_LEVEL_HIGH>;
515 dmas = <&audma0 0x93>, <&audma1 0xb6>;
516 dma-names = "rx", "tx";
519 interrupts = <0 360 IRQ_TYPE_LEVEL_HIGH>;
520 dmas = <&audma0 0x95>, <&audma1 0xb8>;
521 dma-names = "rx", "tx";
524 interrupts = <0 361 IRQ_TYPE_LEVEL_HIGH>;
525 dmas = <&audma0 0x97>, <&audma1 0xba>;
526 dma-names = "rx", "tx";
532 interrupts = <0 370 IRQ_TYPE_LEVEL_HIGH>;
533 dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
534 dma-names = "rx", "tx", "rxu", "txu";
537 interrupts = <0 371 IRQ_TYPE_LEVEL_HIGH>;
538 dmas = <&audma0 0x03>, <&audma1 0x04>, <&audma0 0x49>, <&audma1 0x4a>;
539 dma-names = "rx", "tx", "rxu", "txu";
542 interrupts = <0 372 IRQ_TYPE_LEVEL_HIGH>;
543 dmas = <&audma0 0x05>, <&audma1 0x06>, <&audma0 0x63>, <&audma1 0x64>;
544 dma-names = "rx", "tx", "rxu", "txu";
547 interrupts = <0 373 IRQ_TYPE_LEVEL_HIGH>;
548 dmas = <&audma0 0x07>, <&audma1 0x08>, <&audma0 0x6f>, <&audma1 0x70>;
549 dma-names = "rx", "tx", "rxu", "txu";
552 interrupts = <0 374 IRQ_TYPE_LEVEL_HIGH>;
553 dmas = <&audma0 0x09>, <&audma1 0x0a>, <&audma0 0x71>, <&audma1 0x72>;
554 dma-names = "rx", "tx", "rxu", "txu";
557 interrupts = <0 375 IRQ_TYPE_LEVEL_HIGH>;
558 dmas = <&audma0 0x0b>, <&audma1 0x0c>, <&audma0 0x73>, <&audma1 0x74>;
559 dma-names = "rx", "tx", "rxu", "txu";
562 interrupts = <0 376 IRQ_TYPE_LEVEL_HIGH>;
563 dmas = <&audma0 0x0d>, <&audma1 0x0e>, <&audma0 0x75>, <&audma1 0x76>;
564 dma-names = "rx", "tx", "rxu", "txu";
567 interrupts = <0 377 IRQ_TYPE_LEVEL_HIGH>;
568 dmas = <&audma0 0x0f>, <&audma1 0x10>, <&audma0 0x79>, <&audma1 0x7a>;
569 dma-names = "rx", "tx", "rxu", "txu";
572 interrupts = <0 378 IRQ_TYPE_LEVEL_HIGH>;
573 dmas = <&audma0 0x11>, <&audma1 0x12>, <&audma0 0x7b>, <&audma1 0x7c>;
574 dma-names = "rx", "tx", "rxu", "txu";
577 interrupts = <0 379 IRQ_TYPE_LEVEL_HIGH>;
578 dmas = <&audma0 0x13>, <&audma1 0x14>, <&audma0 0x7d>, <&audma1 0x7e>;
579 dma-names = "rx", "tx", "rxu", "txu";
585 playback = <&ssi5 &src5>;
603 =============================================
604 Example: simple sound card
605 =============================================
608 compatible = "simple-audio-card";
610 simple-audio-card,format = "left_j";
611 simple-audio-card,bitclock-master = <&sndcodec>;
612 simple-audio-card,frame-master = <&sndcodec>;
614 sndcpu: simple-audio-card,cpu {
615 sound-dai = <&rcar_sound>;
618 sndcodec: simple-audio-card,codec {
619 sound-dai = <&ak4643>;
620 clocks = <&audio_clock>;
625 pinctrl-0 = <&sound_pins &sound_clk_pins>;
626 pinctrl-names = "default";
629 #sound-dai-cells = <0>;
634 playback = <&ssi0 &src2 &dvc0>;
635 capture = <&ssi1 &src3 &dvc1>;
644 =============================================
645 Example: simple sound card for TDM
646 =============================================
649 compatible = "simple-audio-card";
651 simple-audio-card,format = "left_j";
652 simple-audio-card,bitclock-master = <&sndcodec>;
653 simple-audio-card,frame-master = <&sndcodec>;
655 sndcpu: simple-audio-card,cpu {
656 sound-dai = <&rcar_sound>;
657 dai-tdm-slot-num = <6>;
660 sndcodec: simple-audio-card,codec {
665 =============================================
666 Example: simple sound card for Multi channel
667 =============================================
670 pinctrl-0 = <&sound_pins &sound_clk_pins>;
671 pinctrl-names = "default";
674 #sound-dai-cells = <0>;
679 playback = <&ssi0 &ssi1 &ssi2 &src0 &dvc0>;