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