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]
42 see "Example: simple sound card"
45 ${LINUX}/arch/arm/boot/dts/r8a7790.dts can be good example.
47 &src0 &ctu00 &mix0 &dvc0 &ssi0
48 &src1 &ctu01 &mix1 &dvc1 &ssi1
58 =============================================
59 * SRC (Sampling Rate Converter)
60 =============================================
65 SRC can convert [xx]Hz to [yy]Hz. Then, it has below 2 modes
67 Asynchronous mode: input data / output data are based on different clocks.
68 you can use this mode on Playback / Capture
69 Synchronous mode: input data / output data are based on same clocks.
70 This mode will be used if system doesn't have its input clock,
71 for example digital TV case.
72 you can use this mode on Playback
78 You need to use "simple-scu-audio-card" or "audio-graph-scu-card" for it.
79 see "Example: simple sound card for Asynchronous mode"
85 > amixer set "SRC Out Rate" on
87 > amixer set "SRC Out Rate" 48000
88 > amixer set "SRC Out Rate" 44100
90 =============================================
91 * CTU (Channel Transfer Unit)
92 =============================================
95 ------> [CTU] -------->
97 CTU can convert [xx]ch to [yy]ch, or exchange outputed channel.
98 CTU conversion needs matrix settings.
99 For more detail information, see below
101 Renesas R-Car datasheet
102 - Sampling Rate Converter Unit (SCU)
105 - Functional Blocks in CMD
107 Renesas R-Car datasheet
108 - Sampling Rate Converter Unit (SCU)
109 - Register Description
110 - CTUn Scale Value exx Register (CTUn_SVxxR)
112 ${LINUX}/sound/soc/sh/rcar/ctu.c
115 You need to use "simple-scu-audio-card" or "audio-graph-scu-card" for it.
116 see "Example: simple sound card for channel convert"
118 Ex) Exchange output channel
123 example of using matrix
124 output 0ch = (input 0ch x 0) + (input 1ch x 1)
125 output 1ch = (input 0ch x 1) + (input 1ch x 0)
127 amixer set "CTU Reset" on
128 amixer set "CTU Pass" 9,10
129 amixer set "CTU SV0" 0,4194304
130 amixer set "CTU SV1" 4194304,0
132 example of changing connection
133 amixer set "CTU Reset" on
134 amixer set "CTU Pass" 2,1
136 =============================================
138 =============================================
140 MIX merges 2 sounds path. You can see 2 sound interface on system,
141 and these sounds will be merged by MIX.
143 aplay -D plughw:0,0 xxxx.wav &
144 aplay -D plughw:0,1 yyyy.wav
146 You need to use "simple-scu-audio-card" or "audio-graph-scu-card" for it.
148 [MEM] -> [SRC1] -> [CTU02] -+-> [MIX0] -> [DVC0] -> [SSI0]
150 [MEM] -> [SRC2] -> [CTU03] -+
152 see "Example: simple sound card for MIXer"
154 =============================================
155 * DVC (Digital Volume and Mute Function)
156 =============================================
158 DVC controls Playback/Capture volume.
161 amixer set "DVC Out" 100%
164 amixer set "DVC In" 100%
167 amixer set "DVC Out Mute" on
170 amixer set "DVC In Mute" on
173 amixer set "DVC Out Ramp Up Rate" "0.125 dB/64 steps"
174 amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
175 amixer set "DVC Out Ramp" on
177 amixer set "DVC Out" 80% // Volume Down
178 amixer set "DVC Out" 100% // Volume Up
180 =============================================
181 * SSIU (Serial Sound Interface Unit)
182 =============================================
184 SSIU can avoid some under/over run error, because it has some buffer.
185 But you can't use it if SSI was PIO mode.
186 In DMA mode, you can select not to use SSIU by using "no-busif" via SSI.
188 SSIU handles BUSIF which will be used for TDM Split mode.
189 This driver is assuming that audio-graph card will be used.
191 TDM Split mode merges 4 sounds. You can see 4 sound interface on system,
192 and these sounds will be merged SSIU/SSI.
194 aplay -D plughw:0,0 xxxx.wav &
195 aplay -D plughw:0,1 xxxx.wav &
196 aplay -D plughw:0,2 xxxx.wav &
197 aplay -D plughw:0,3 xxxx.wav
200 [MEM] -> [SSIU 30] -+-> [SSIU 3] --> [Codec]
202 [MEM] -> [SSIU 31] -+
204 [MEM] -> [SSIU 32] -+
206 [MEM] -> [SSIU 33] -+
208 see "Example: simple sound card for TDM Split"
210 =============================================
211 * SSI (Serial Sound Interface)
212 =============================================
216 You can use PIO mode which is for connection check by using.
217 Note: The system will drop non-SSI modules in PIO mode
218 even though if DT is selecting other modules.
224 ** DMA mode without SSIU
226 You can use DMA without SSIU.
227 Note: under/over run, or noise are likely to occur
235 Each SSI can share WS pin. It is based on platform.
236 This is example if SSI1 want to share WS pin with SSI0
244 You can use Multi-SSI.
245 This is example of SSI0/SSI1/SSI2 (= for 6ch)
247 see "Example: simple sound card for Multi channel"
251 You can use TDM with SSI.
252 This is example of TDM 6ch.
253 Driver can automatically switches TDM <-> stereo mode in this case.
255 see "Example: simple sound card for TDM"
257 =============================================
259 =============================================
261 - compatible : "renesas,rcar_sound-<soctype>", fallbacks
262 "renesas,rcar_sound-gen1" if generation1, and
263 "renesas,rcar_sound-gen2" if generation2 (or RZ/G1)
264 "renesas,rcar_sound-gen3" if generation3 (or RZ/G2)
265 Examples with soctypes are:
266 - "renesas,rcar_sound-r8a7742" (RZ/G1H)
267 - "renesas,rcar_sound-r8a7743" (RZ/G1M)
268 - "renesas,rcar_sound-r8a7744" (RZ/G1N)
269 - "renesas,rcar_sound-r8a7745" (RZ/G1E)
270 - "renesas,rcar_sound-r8a77470" (RZ/G1C)
271 - "renesas,rcar_sound-r8a774a1" (RZ/G2M)
272 - "renesas,rcar_sound-r8a774b1" (RZ/G2N)
273 - "renesas,rcar_sound-r8a774c0" (RZ/G2E)
274 - "renesas,rcar_sound-r8a7778" (R-Car M1A)
275 - "renesas,rcar_sound-r8a7779" (R-Car H1)
276 - "renesas,rcar_sound-r8a7790" (R-Car H2)
277 - "renesas,rcar_sound-r8a7791" (R-Car M2-W)
278 - "renesas,rcar_sound-r8a7793" (R-Car M2-N)
279 - "renesas,rcar_sound-r8a7794" (R-Car E2)
280 - "renesas,rcar_sound-r8a7795" (R-Car H3)
281 - "renesas,rcar_sound-r8a7796" (R-Car M3-W)
282 - "renesas,rcar_sound-r8a77965" (R-Car M3-N)
283 - "renesas,rcar_sound-r8a77990" (R-Car E3)
284 - "renesas,rcar_sound-r8a77995" (R-Car D3)
285 - reg : Should contain the register physical address.
287 SRU/ADG/SSI if generation1
288 SRU/ADG/SSIU/SSI/AUDIO-DMAC-periperi if generation2/generation3
289 Select extended AUDIO-DMAC-periperi address if SoC has it,
290 otherwise select normal AUDIO-DMAC-periperi address.
291 - reg-names : Should contain the register names.
292 scu/adg/ssi if generation1
293 scu/adg/ssiu/ssi/audmapp if generation2/generation3
294 - rcar_sound,ssi : Should contain SSI feature.
295 The number of SSI subnode should be same as HW.
296 see below for detail.
297 - rcar_sound,ssiu : Should contain SSIU feature.
298 The number of SSIU subnode should be same as HW.
299 see below for detail.
300 - rcar_sound,src : Should contain SRC feature.
301 The number of SRC subnode should be same as HW.
302 see below for detail.
303 - rcar_sound,ctu : Should contain CTU feature.
304 The number of CTU subnode should be same as HW.
305 see below for detail.
306 - rcar_sound,mix : Should contain MIX feature.
307 The number of MIX subnode should be same as HW.
308 see below for detail.
309 - rcar_sound,dvc : Should contain DVC feature.
310 The number of DVC subnode should be same as HW.
311 see below for detail.
312 - rcar_sound,dai : DAI contents.
313 The number of DAI subnode should be same as HW.
314 see below for detail.
315 - #sound-dai-cells : it must be 0 if your system is using single DAI
316 it must be 1 if your system is using multi DAI
317 - clocks : References to SSI/SRC/MIX/CTU/DVC/AUDIO_CLK clocks.
318 - clock-names : List of necessary clock names.
319 "ssi-all", "ssi.X", "src.X", "mix.X", "ctu.X",
320 "dvc.X", "clk_a", "clk_b", "clk_c", "clk_i"
323 - #clock-cells : it must be 0 if your system has audio_clkout
324 it must be 1 if your system has audio_clkout0/1/2/3
325 - clock-frequency : for all audio_clkout0/1/2/3
326 - clkout-lr-asynchronous : boolean property. it indicates that audio_clkoutn
327 is asynchronizes with lr-clock.
328 - resets : References to SSI resets.
329 - reset-names : List of valid reset names.
332 SSI subnode properties:
333 - interrupts : Should contain SSI interrupt for PIO transfer
334 - shared-pin : if shared clock pin
335 - pio-transfer : use PIO transfer mode
336 - no-busif : BUSIF is not ussed when [mem -> SSI] via DMA case
337 - dma : Should contain Audio DMAC entry
338 - dma-names : SSI case "rx" (=playback), "tx" (=capture)
339 Deprecated: see SSIU subnode properties
340 SSIU case "rxu" (=playback), "txu" (=capture)
342 SSIU subnode properties:
343 - dma : Should contain Audio DMAC entry
344 - dma-names : "rx" (=playback), "tx" (=capture)
346 SRC subnode properties:
347 - dma : Should contain Audio DMAC entry
348 - dma-names : "rx" (=playback), "tx" (=capture)
350 DVC subnode properties:
351 - dma : Should contain Audio DMAC entry
352 - dma-names : "tx" (=playback/capture)
354 DAI subnode properties:
355 - playback : list of playback modules
356 - capture : list of capture modules
359 =============================================
361 =============================================
363 rcar_sound: sound@ec500000 {
364 #sound-dai-cells = <1>;
365 compatible = "renesas,rcar_sound-r8a7791", "renesas,rcar_sound-gen2";
366 reg = <0 0xec500000 0 0x1000>, /* SCU */
367 <0 0xec5a0000 0 0x100>, /* ADG */
368 <0 0xec540000 0 0x1000>, /* SSIU */
369 <0 0xec541000 0 0x1280>, /* SSI */
370 <0 0xec740000 0 0x200>; /* Audio DMAC peri peri*/
371 reg-names = "scu", "adg", "ssiu", "ssi", "audmapp";
373 clocks = <&mstp10_clks R8A7790_CLK_SSI_ALL>,
374 <&mstp10_clks R8A7790_CLK_SSI9>, <&mstp10_clks R8A7790_CLK_SSI8>,
375 <&mstp10_clks R8A7790_CLK_SSI7>, <&mstp10_clks R8A7790_CLK_SSI6>,
376 <&mstp10_clks R8A7790_CLK_SSI5>, <&mstp10_clks R8A7790_CLK_SSI4>,
377 <&mstp10_clks R8A7790_CLK_SSI3>, <&mstp10_clks R8A7790_CLK_SSI2>,
378 <&mstp10_clks R8A7790_CLK_SSI1>, <&mstp10_clks R8A7790_CLK_SSI0>,
379 <&mstp10_clks R8A7790_CLK_SCU_SRC9>, <&mstp10_clks R8A7790_CLK_SCU_SRC8>,
380 <&mstp10_clks R8A7790_CLK_SCU_SRC7>, <&mstp10_clks R8A7790_CLK_SCU_SRC6>,
381 <&mstp10_clks R8A7790_CLK_SCU_SRC5>, <&mstp10_clks R8A7790_CLK_SCU_SRC4>,
382 <&mstp10_clks R8A7790_CLK_SCU_SRC3>, <&mstp10_clks R8A7790_CLK_SCU_SRC2>,
383 <&mstp10_clks R8A7790_CLK_SCU_SRC1>, <&mstp10_clks R8A7790_CLK_SCU_SRC0>,
384 <&mstp10_clks R8A7790_CLK_SCU_DVC0>, <&mstp10_clks R8A7790_CLK_SCU_DVC1>,
385 <&audio_clk_a>, <&audio_clk_b>, <&audio_clk_c>, <&m2_clk>;
386 clock-names = "ssi-all",
387 "ssi.9", "ssi.8", "ssi.7", "ssi.6", "ssi.5",
388 "ssi.4", "ssi.3", "ssi.2", "ssi.1", "ssi.0",
389 "src.9", "src.8", "src.7", "src.6", "src.5",
390 "src.4", "src.3", "src.2", "src.1", "src.0",
392 "clk_a", "clk_b", "clk_c", "clk_i";
396 dmas = <&audma0 0xbc>;
400 dmas = <&audma0 0xbe>;
423 interrupts = <0 352 IRQ_TYPE_LEVEL_HIGH>;
424 dmas = <&audma0 0x85>, <&audma1 0x9a>;
425 dma-names = "rx", "tx";
428 interrupts = <0 353 IRQ_TYPE_LEVEL_HIGH>;
429 dmas = <&audma0 0x87>, <&audma1 0x9c>;
430 dma-names = "rx", "tx";
433 interrupts = <0 354 IRQ_TYPE_LEVEL_HIGH>;
434 dmas = <&audma0 0x89>, <&audma1 0x9e>;
435 dma-names = "rx", "tx";
438 interrupts = <0 355 IRQ_TYPE_LEVEL_HIGH>;
439 dmas = <&audma0 0x8b>, <&audma1 0xa0>;
440 dma-names = "rx", "tx";
443 interrupts = <0 356 IRQ_TYPE_LEVEL_HIGH>;
444 dmas = <&audma0 0x8d>, <&audma1 0xb0>;
445 dma-names = "rx", "tx";
448 interrupts = <0 357 IRQ_TYPE_LEVEL_HIGH>;
449 dmas = <&audma0 0x8f>, <&audma1 0xb2>;
450 dma-names = "rx", "tx";
453 interrupts = <0 358 IRQ_TYPE_LEVEL_HIGH>;
454 dmas = <&audma0 0x91>, <&audma1 0xb4>;
455 dma-names = "rx", "tx";
458 interrupts = <0 359 IRQ_TYPE_LEVEL_HIGH>;
459 dmas = <&audma0 0x93>, <&audma1 0xb6>;
460 dma-names = "rx", "tx";
463 interrupts = <0 360 IRQ_TYPE_LEVEL_HIGH>;
464 dmas = <&audma0 0x95>, <&audma1 0xb8>;
465 dma-names = "rx", "tx";
468 interrupts = <0 361 IRQ_TYPE_LEVEL_HIGH>;
469 dmas = <&audma0 0x97>, <&audma1 0xba>;
470 dma-names = "rx", "tx";
476 dmas = <&audma0 0x15>, <&audma1 0x16>;
477 dma-names = "rx", "tx";
480 dmas = <&audma0 0x35>, <&audma1 0x36>;
481 dma-names = "rx", "tx";
487 dmas = <&audma0 0xA5>, <&audma1 0xA6>;
488 dma-names = "rx", "tx";
491 dmas = <&audma0 0xA7>, <&audma1 0xA8>;
492 dma-names = "rx", "tx";
495 dmas = <&audma0 0xA9>, <&audma1 0xAA>;
496 dma-names = "rx", "tx";
502 interrupts = <0 370 IRQ_TYPE_LEVEL_HIGH>;
503 dmas = <&audma0 0x01>, <&audma1 0x02>;
504 dma-names = "rx", "tx";
507 interrupts = <0 371 IRQ_TYPE_LEVEL_HIGH>;
508 dmas = <&audma0 0x03>, <&audma1 0x04>;
509 dma-names = "rx", "tx";
515 interrupts = <0 378 IRQ_TYPE_LEVEL_HIGH>;
516 dmas = <&audma0 0x11>, <&audma1 0x12>;
517 dma-names = "rx", "tx";
520 interrupts = <0 379 IRQ_TYPE_LEVEL_HIGH>;
521 dmas = <&audma0 0x13>, <&audma1 0x14>;
522 dma-names = "rx", "tx";
528 playback = <&ssi5 &src5>;
546 =============================================
547 Example: simple sound card
548 =============================================
551 compatible = "simple-audio-card";
553 simple-audio-card,format = "left_j";
554 simple-audio-card,bitclock-master = <&sndcodec>;
555 simple-audio-card,frame-master = <&sndcodec>;
557 sndcpu: simple-audio-card,cpu {
558 sound-dai = <&rcar_sound>;
561 sndcodec: simple-audio-card,codec {
562 sound-dai = <&ak4643>;
563 clocks = <&audio_clock>;
568 pinctrl-0 = <&sound_pins &sound_clk_pins>;
569 pinctrl-names = "default";
572 #sound-dai-cells = <0>;
577 playback = <&ssi0 &src2 &dvc0>;
578 capture = <&ssi1 &src3 &dvc1>;
587 =============================================
588 Example: simple sound card for Asynchronous mode
589 =============================================
592 compatible = "simple-scu-audio-card";
595 * SRC Asynchronous mode setting
597 * All input data will be converted to 48kHz
599 * Inputed 48kHz data will be converted to
600 * system specified Hz
602 simple-audio-card,convert-rate = <48000>;
604 simple-audio-card,cpu {
605 sound-dai = <&rcar_sound>;
607 simple-audio-card,codec {
612 =============================================
613 Example: simple sound card for channel convert
614 =============================================
617 compatible = "simple-scu-audio-card";
621 * All input data will be converted to 2ch
624 simple-audio-card,convert-channels = <2>;
626 simple-audio-card,cpu {
627 sound-dai = <&rcar_sound>;
629 simple-audio-card,codec {
634 =============================================
635 Example: simple sound card for MIXer
636 =============================================
639 compatible = "simple-scu-audio-card";
641 simple-audio-card,cpu@0 {
642 sound-dai = <&rcar_sound 0>;
644 simple-audio-card,cpu@1 {
645 sound-dai = <&rcar_sound 1>;
647 simple-audio-card,codec {
656 playback = <&src1 &ctu02 &mix0 &dvc0 &ssi0>;
659 playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>;
664 =============================================
665 Example: simple sound card for TDM
666 =============================================
669 compatible = "simple-audio-card";
671 simple-audio-card,format = "left_j";
672 simple-audio-card,bitclock-master = <&sndcodec>;
673 simple-audio-card,frame-master = <&sndcodec>;
675 sndcpu: simple-audio-card,cpu {
676 sound-dai = <&rcar_sound>;
677 dai-tdm-slot-num = <6>;
680 sndcodec: simple-audio-card,codec {
685 =============================================
686 Example: simple sound card for TDM Split
687 =============================================
690 compatible = "audio-graph-scu-card";
692 routing = "xxxx Playback", "DAI0 Playback",
693 "xxxx Playback", "DAI1 Playback",
694 "xxxx Playback", "DAI2 Playback",
695 "xxxx Playback", "DAI3 Playback";
696 convert-channels = <8>; /* TDM Split */
698 dais = <&rsnd_port0 /* playback ch1/ch2 */
699 &rsnd_port1 /* playback ch3/ch4 */
700 &rsnd_port2 /* playback ch5/ch6 */
701 &rsnd_port3 /* playback ch7/ch8 */
708 codec_0: endpoint@1 {
709 remote-endpoint = <&rsnd_ep0>;
711 codec_1: endpoint@2 {
712 remote-endpoint = <&rsnd_ep1>;
714 codec_2: endpoint@3 {
715 remote-endpoint = <&rsnd_ep2>;
717 codec_3: endpoint@4 {
718 remote-endpoint = <&rsnd_ep3>;
728 remote-endpoint = <&codec_0>;
730 playback = <&ssiu30 &ssi3>;
735 remote-endpoint = <&codec_1>;
737 playback = <&ssiu31 &ssi3>;
742 remote-endpoint = <&codec_2>;
744 playback = <&ssiu32 &ssi3>;
749 remote-endpoint = <&codec_3>;
751 playback = <&ssiu33 &ssi3>;
757 =============================================
758 Example: simple sound card for Multi channel
759 =============================================
762 pinctrl-0 = <&sound_pins &sound_clk_pins>;
763 pinctrl-names = "default";
766 #sound-dai-cells = <0>;
771 playback = <&ssi0 &ssi1 &ssi2 &src0 &dvc0>;