1// SPDX-License-Identifier: GPL-2.0
2/*
3 * audio-graph-card2-custom-sample.dtsi
4 *
5 * Copyright (C) 2020 Renesas Electronics Corp.
6 * Copyright (C) 2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 *
8 * This sample indicates how to use audio-graph-card2 and its
9 * custom driver. "audio-graph-card2-custom-sample" is the custome driver
10 * which is using audio-graph-card2.
11 *
12 * You can easily use this sample by adding below line on your DT file,
13 * and add new CONFIG to your .config.
14 *
15 *	#include "../../../../../sound/soc/generic/audio-graph-card2-custom-sample.dtsi"
16 *
17 *	CONFIG_SND_AUDIO_GRAPH_CARD2
18 *	CONFIG_SND_AUDIO_GRAPH_CARD2_CUSTOM_SAMPLE
19 *	CONFIG_SND_TEST_COMPONENT
20 *
21 *
22 * You can indicate more detail each device behavior as debug if you modify
23 * "compatible" on each test-component. see below
24 *
25 *	test_cpu {
26 *	-	compatible = "test-cpu";
27 *	+	compatible = "test-cpu-verbose";
28 *		...
29 *	};
30 *
31 *	test_codec {
32 *	-	compatible = "test-codec";
33 *	+	compatible = "test-codec-verbose";
34 *		...
35 *	};
36 *
37 *
38 * Below sample doesn't use "format" property,
39 * because test-component driver (test-cpu/test-codec) is supporting
40 * snd_soc_dai_ops :: .auto_selectable_formats.
41 * see
42 *	snd_soc_runtime_get_dai_fmt()
43 *	linux/sound/soc/generic/test-component.c :: test_dai_formats
44 */
45/ {
46	/*
47	 * @ : used at links
48	 *
49	 * [Normal]
50	 *	cpu0 <-@-----------------> codec0
51	 *
52	 * [Semi-Multi]
53	 *
54	 * CPU:Codec = 1:N
55	 *
56	 *			+-+
57	 *	cpu7 <-@------->| |-> codec12
58	 *			| |-> codec13
59	 *			+-+
60	 *
61	 * [Multi-CPU/Codec]
62	 *		+-+		+-+
63	 *	cpu1 <--| |<-@--------->| |-> codec1
64	 *	cpu2 <--| |		| |-> codec2
65	 *		+-+		+-+
66	 *
67	 * [DPCM]
68	 *
69	 *	CPU3/CPU4 are converting rate to 44100
70	 *
71	 *	FE		BE
72	 *		  ****
73	 *	cpu3 <-@--*  *--@-> codec3
74	 *	cpu4 <-@--*  *  (44.1kHz)
75	 *		  ****
76	 *
77	 * [DPCM-Multi]
78	 *
79	 * --NOTE--
80	 * Multi-FE is not supported by ASoC.
81	 *
82	 *	FE		BE
83	 *		  ****	    +-+
84	 *	cpu5 <-@--*  *--@-> | | -> codec4
85	 *	cpu6 <-@--*  *	    | | -> codec5
86	 *		  ****	    +-+
87	 *
88	 * [Codec2Codec]
89	 *			   +-@-> codec6
90	 *			   |
91	 *			   +---> codec7
92	 *
93	 * [Codec2Codec-Multi]
94	 *
95	 * --NOTE--
96	 * Multi connect N:M is not supported by ASoC.
97	 *
98	 *				+-+
99	 *			   +-@->| |-> codec8
100	 *			   |	| |-> codec9
101	 *			   |	+-+
102	 *			   |	+-+
103	 *			   +--->| |-> codec10
104	 *				| |-> codec11
105	 *				+-+
106	 */
107	audio-graph-card2-custom-sample {
108		/*
109		 * You can use audio-graph-card2 directly by using
110		 *
111		 * compatible = "audio-graph-card2";
112		 */
113		compatible = "audio-graph-card2-custom-sample";
114
115			/* for [DPCM]		   */
116			/* BE			FE */
117		routing = "TC DAI3 Playback",	"DAI3 Playback",
118			  "TC DAI3 Playback",	"DAI4 Playback",
119			  "DAI3 Capture",	"TC DAI3 Capture",
120			  "DAI4 Capture",	"TC DAI3 Capture",
121			/* for [DPCM-Multi]	   */
122			/* BE			FE */
123			  "TC DAI4 Playback",	"DAI5 Playback",
124			  "TC DAI5 Playback",	"DAI5 Playback",
125			  "TC DAI4 Playback",	"DAI6 Playback",
126			  "TC DAI5 Playback",	"DAI6 Playback",
127			  "DAI5 Capture",	"TC DAI4 Capture",
128			  "DAI5 Capture",	"TC DAI5 Capture",
129			  "DAI6 Capture",	"TC DAI4 Capture",
130			  "DAI6 Capture",	"TC DAI5 Capture",
131			/* for [Codec2Codec] */
132			  "TC OUT",		"TC DAI7 Playback",
133			  "TC DAI6 Capture",	"TC IN",
134			/* for [Codec2Codec-Multi] */
135			  "TC OUT",		"TC DAI10 Playback",
136			  "TC DAI8 Capture",	"TC IN",
137			  "TC OUT",		"TC DAI11 Playback",
138			  "TC DAI9 Capture",	"TC IN";
139
140		links = <
141			/*
142			 * [Normal]: cpu side only
143			 * cpu0/codec0
144			 */
145			 &cpu0
146
147			/* [Semi-Multi] */
148			&sm0
149
150			/*
151			 * [Multi-CPU/Codec]: cpu side only
152			 * cpu1/cpu2/codec1/codec2
153			 */
154			 &mcpu0
155
156			/*
157			 * [DPCM]: both FE / BE
158			 * cpu3/cpu4/codec3
159			 */
160			 &fe00 &fe01 &be0
161
162			/*
163			 * [DPCM-Multi]: both FE / BE
164			 * cpu5/cpu6/codec4/codec5
165			 */
166			 &fe10 &fe11 &be1
167
168			/*
169			 * [Codec2Codec]: cpu side only
170			 * codec6/codec7
171			 */
172			 &c2c
173
174			/*
175			 * [Codec2Codec-Multi]: cpu side only
176			 * codec8/codec9/codec10/codec11
177			 */
178			 &c2c_m
179		>;
180
181		multi {
182			#address-cells = <1>;
183			#size-cells = <0>;
184
185			ports@0 {
186				reg = <0>;
187				#address-cells = <1>;
188				#size-cells = <0>;
189			/* [Multi-CPU] */
190			mcpu0:	port@0 { reg = <0>; mcpu0_ep: endpoint { remote-endpoint = <&mcodec0_ep>; }; };
191				port@1 { reg = <1>; mcpu1_ep: endpoint { remote-endpoint = <&cpu1_ep>;    }; };
192				port@2 { reg = <2>; mcpu2_ep: endpoint { remote-endpoint = <&cpu2_ep>;    }; };
193			};
194
195			/* [Multi-Codec] */
196			ports@1 {
197				reg = <1>;
198				#address-cells = <1>;
199				#size-cells = <0>;
200				port@0 { reg = <0>; mcodec0_ep: endpoint { remote-endpoint = <&mcpu0_ep>;  }; };
201				port@1 { reg = <1>; mcodec1_ep: endpoint { remote-endpoint = <&codec1_ep>; }; };
202				port@2 { reg = <2>; mcodec2_ep: endpoint { remote-endpoint = <&codec2_ep>; }; };
203			};
204
205			/* [DPCM-Multi]::BE */
206			ports@2 {
207				reg = <2>;
208				#address-cells = <1>;
209				#size-cells = <0>;
210				port@0 { reg = <0>; mbe_ep:  endpoint { remote-endpoint = <&be10_ep>;  }; };
211				port@1 { reg = <1>; mbe1_ep: endpoint { remote-endpoint = <&codec4_ep>; }; };
212				port@2 { reg = <2>; mbe2_ep: endpoint { remote-endpoint = <&codec5_ep>; }; };
213			};
214
215			/* [Codec2Codec-Multi]::CPU */
216			ports@3 {
217				reg = <3>;
218				#address-cells = <1>;
219				#size-cells = <0>;
220				port@0 { reg = <0>; mc2c0_ep:  endpoint { remote-endpoint = <&c2cmf_ep>;  }; };
221				port@1 { reg = <1>; mc2c00_ep: endpoint { remote-endpoint = <&codec8_ep>; }; };
222				port@2 { reg = <2>; mc2c01_ep: endpoint { remote-endpoint = <&codec9_ep>; }; };
223			};
224
225			/* [Codec2Codec-Multi]::Codec */
226			ports@4 {
227				reg = <4>;
228				#address-cells = <1>;
229				#size-cells = <0>;
230				port@0 { reg = <0>; mc2c1_ep:  endpoint { remote-endpoint = <&c2cmb_ep>;  }; };
231				port@1 { reg = <1>; mc2c10_ep: endpoint { remote-endpoint = <&codec10_ep>; }; };
232				port@2 { reg = <2>; mc2c11_ep: endpoint { remote-endpoint = <&codec11_ep>; }; };
233			};
234
235			/* [Semi-Multi] */
236			ports@5 {
237				reg = <5>;
238				#address-cells = <1>;
239				#size-cells = <0>;
240				port@0 { reg = <0>; smcodec0_ep: endpoint { remote-endpoint = <&cpu7_ep>;    }; };
241				port@1 { reg = <1>; smcodec1_ep: endpoint { remote-endpoint = <&codec12_ep>; }; };
242				port@2 { reg = <2>; smcodec2_ep: endpoint { remote-endpoint = <&codec13_ep>; }; };
243			};
244		};
245
246		dpcm {
247			#address-cells = <1>;
248			#size-cells = <0>;
249
250			ports@0 {
251				reg = <0>;
252
253				#address-cells = <1>;
254				#size-cells = <0>;
255			/* [DPCM]::FE */
256			fe00:	port@0 { reg = <0>; fe00_ep: endpoint { remote-endpoint = <&cpu3_ep>; }; };
257			fe01:	port@1 { reg = <1>; fe01_ep: endpoint { remote-endpoint = <&cpu4_ep>; }; };
258
259			/* [DPCM-Multi]::FE */
260			fe10:	port@2 { reg = <2>; fe10_ep: endpoint { remote-endpoint = <&cpu5_ep>; }; };
261			fe11:	port@3 { reg = <3>; fe11_ep: endpoint { remote-endpoint = <&cpu6_ep>; }; };
262			};
263
264			ports@1 {
265				reg = <1>;
266
267				#address-cells = <1>;
268				#size-cells = <0>;
269			/* [DPCM]::BE */
270			be0:	port@0 { reg = <0>; be00_ep: endpoint { remote-endpoint = <&codec3_ep>; }; };
271
272			/* [DPCM-Multi]::BE */
273			be1:	port@1 { reg = <1>; be10_ep: endpoint { remote-endpoint = <&mbe_ep>; }; };
274			};
275		};
276
277		codec2codec {
278			#address-cells = <1>;
279			#size-cells = <0>;
280			/* [Codec2Codec] */
281			ports@0 {
282				reg = <0>;
283
284				#address-cells = <1>;
285				#size-cells = <0>;
286
287				/* use default settings */
288			c2c:	port@0 { reg = <0>; c2cf_ep: endpoint { remote-endpoint = <&codec6_ep>; }; };
289				port@1 { reg = <1>; c2cb_ep: endpoint { remote-endpoint = <&codec7_ep>; }; };
290			};
291
292			/* [Codec2Codec-Multi] */
293			ports@1 {
294				reg = <1>;
295
296				#address-cells = <1>;
297				#size-cells = <0>;
298
299				/* use original settings */
300				rate = <48000>;
301			c2c_m:	port@0 { reg = <0>; c2cmf_ep: endpoint { remote-endpoint = <&mc2c0_ep>; }; };
302				port@1 { reg = <1>; c2cmb_ep: endpoint { remote-endpoint = <&mc2c1_ep>; }; };
303			};
304		};
305	};
306
307	test_cpu {
308		/*
309		 * update compatible to indicate more detail behaviour
310		 * if you want. see test-compatible for more detail.
311		 *
312		 * ex)
313		 *	- compatible = "test-cpu";
314		 *	+ compatible = "test-cpu-verbose";
315		 */
316		compatible = "test-cpu";
317		ports {
318			#address-cells = <1>;
319			#size-cells = <0>;
320
321			bitclock-master;
322			frame-master;
323			/* [Normal] */
324			cpu0: port@0 { reg = <0>; cpu0_ep: endpoint { remote-endpoint = <&codec0_ep>; }; };
325
326			/* [Multi-CPU] */
327			      port@1 { reg = <1>; cpu1_ep: endpoint { remote-endpoint = <&mcpu1_ep>; }; };
328			      port@2 { reg = <2>; cpu2_ep: endpoint { remote-endpoint = <&mcpu2_ep>; }; };
329
330			/* [DPCM]::FE */
331			      port@3 { reg = <3>; cpu3_ep: endpoint { remote-endpoint = <&fe00_ep>; }; };
332			      port@4 { reg = <4>; cpu4_ep: endpoint { remote-endpoint = <&fe01_ep>; }; };
333
334			/* [DPCM-Multi]::FE */
335			      port@5 { reg = <5>; cpu5_ep: endpoint { remote-endpoint = <&fe10_ep>; }; };
336			      port@6 { reg = <6>; cpu6_ep: endpoint { remote-endpoint = <&fe11_ep>; }; };
337
338			/* [Semi-Multi] */
339			sm0:  port@7 { reg = <7>; cpu7_ep: endpoint { remote-endpoint = <&smcodec0_ep>; }; };
340		};
341	};
342
343	test_codec {
344		/*
345		 * update compatible to indicate more detail behaviour
346		 * if you want. see test-compatible for more detail.
347		 *
348		 * ex)
349		 *	- compatible = "test-codec";
350		 *	+ compatible = "test-codec-verbose";
351		 */
352		compatible = "test-codec";
353		ports {
354			#address-cells = <1>;
355			#size-cells = <0>;
356
357			/*
358			 * prefix can be added to *component*,
359			 * see audio-graph-card2::routing
360			 */
361			prefix = "TC";
362
363			/* [Normal] */
364			port@0  { reg = <0>; codec0_ep:  endpoint { remote-endpoint = <&cpu0_ep>; }; };
365
366			/* [Multi-Codec] */
367			port@1  { reg = <1>; codec1_ep:  endpoint { remote-endpoint = <&mcodec1_ep>; }; };
368			port@2  { reg = <2>; codec2_ep:  endpoint { remote-endpoint = <&mcodec2_ep>; }; };
369
370			/* [DPCM]::BE */
371			port@3  {
372				convert-rate = <44100>;
373				reg = <3>; codec3_ep:  endpoint { remote-endpoint = <&be00_ep>; };
374			};
375
376			/* [DPCM-Multi]::BE */
377			port@4  { reg = <4>; codec4_ep:  endpoint { remote-endpoint = <&mbe1_ep>; }; };
378			port@5  { reg = <5>; codec5_ep:  endpoint { remote-endpoint = <&mbe2_ep>; }; };
379
380			/* [Codec2Codec] */
381			port@6  { bitclock-master;
382				  frame-master;
383				  reg = <6>; codec6_ep:  endpoint { remote-endpoint = <&c2cf_ep>; }; };
384			port@7  { reg = <7>; codec7_ep:  endpoint { remote-endpoint = <&c2cb_ep>; }; };
385
386			/* [Codec2Codec-Multi] */
387			port@8  { bitclock-master;
388				  frame-master;
389				  reg = <8>;  codec8_ep:  endpoint { remote-endpoint = <&mc2c00_ep>; }; };
390			port@9  { reg = <9>;  codec9_ep:  endpoint { remote-endpoint = <&mc2c01_ep>; }; };
391			port@a  { reg = <10>; codec10_ep: endpoint { remote-endpoint = <&mc2c10_ep>; }; };
392			port@b  { reg = <11>; codec11_ep: endpoint { remote-endpoint = <&mc2c11_ep>; }; };
393
394			/* [Semi-Multi] */
395			port@c { reg = <12>; codec12_ep: endpoint { remote-endpoint = <&smcodec1_ep>; }; };
396			port@d { reg = <13>; codec13_ep: endpoint { remote-endpoint = <&smcodec2_ep>; }; };
397
398		};
399	};
400};
401