xref: /linux/drivers/dma/ti/k3-psil-am62p.c (revision be3382ecdf317f005e7d47356d0a9256cc36dd88)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  *  Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com
4  */
5 
6 #include <linux/kernel.h>
7 
8 #include "k3-psil-priv.h"
9 
10 #define PSIL_PDMA_XY_TR(x)					\
11 	{							\
12 		.thread_id = x,					\
13 		.ep_config = {					\
14 			.ep_type = PSIL_EP_PDMA_XY,		\
15 			.mapped_channel_id = -1,		\
16 			.default_flow_id = -1,			\
17 		},						\
18 	}
19 
20 #define PSIL_PDMA_XY_PKT(x)					\
21 	{							\
22 		.thread_id = x,					\
23 		.ep_config = {					\
24 			.ep_type = PSIL_EP_PDMA_XY,		\
25 			.mapped_channel_id = -1,		\
26 			.default_flow_id = -1,			\
27 			.pkt_mode = 1,				\
28 		},						\
29 	}
30 
31 #define PSIL_ETHERNET(x, ch, flow_base, flow_cnt)		\
32 	{							\
33 		.thread_id = x,					\
34 		.ep_config = {					\
35 			.ep_type = PSIL_EP_NATIVE,		\
36 			.pkt_mode = 1,				\
37 			.needs_epib = 1,			\
38 			.psd_size = 16,				\
39 			.mapped_channel_id = ch,		\
40 			.flow_start = flow_base,		\
41 			.flow_num = flow_cnt,			\
42 			.default_flow_id = flow_base,		\
43 		},						\
44 	}
45 
46 #define PSIL_SAUL(x, ch, flow_base, flow_cnt, default_flow, tx)	\
47 	{							\
48 		.thread_id = x,					\
49 		.ep_config = {					\
50 			.ep_type = PSIL_EP_NATIVE,		\
51 			.pkt_mode = 1,				\
52 			.needs_epib = 1,			\
53 			.psd_size = 64,				\
54 			.mapped_channel_id = ch,		\
55 			.flow_start = flow_base,		\
56 			.flow_num = flow_cnt,			\
57 			.default_flow_id = default_flow,	\
58 			.notdpkt = tx,				\
59 		},						\
60 	}
61 
62 #define PSIL_PDMA_MCASP(x)				\
63 	{						\
64 		.thread_id = x,				\
65 		.ep_config = {				\
66 			.ep_type = PSIL_EP_PDMA_XY,	\
67 			.pdma_acc32 = 1,		\
68 			.pdma_burst = 1,		\
69 		},					\
70 	}
71 
72 #define PSIL_CSI2RX(x)					\
73 	{						\
74 		.thread_id = x,				\
75 		.ep_config = {				\
76 			.ep_type = PSIL_EP_NATIVE,	\
77 		},					\
78 	}
79 
80 /* PSI-L source thread IDs, used for RX (DMA_DEV_TO_MEM) */
81 static struct psil_ep am62p_src_ep_map[] = {
82 	/* SAUL */
83 	PSIL_SAUL(0x7504, 20, 35, 8, 35, 0),
84 	PSIL_SAUL(0x7505, 21, 35, 8, 36, 0),
85 	PSIL_SAUL(0x7506, 22, 43, 8, 43, 0),
86 	PSIL_SAUL(0x7507, 23, 43, 8, 44, 0),
87 	/* PDMA_MAIN0 - SPI0-2 */
88 	PSIL_PDMA_XY_PKT(0x4300),
89 	PSIL_PDMA_XY_PKT(0x4301),
90 	PSIL_PDMA_XY_PKT(0x4302),
91 	PSIL_PDMA_XY_PKT(0x4303),
92 	PSIL_PDMA_XY_PKT(0x4304),
93 	PSIL_PDMA_XY_PKT(0x4305),
94 	PSIL_PDMA_XY_PKT(0x4306),
95 	PSIL_PDMA_XY_PKT(0x4307),
96 	PSIL_PDMA_XY_PKT(0x4308),
97 	PSIL_PDMA_XY_PKT(0x4309),
98 	PSIL_PDMA_XY_PKT(0x430a),
99 	PSIL_PDMA_XY_PKT(0x430b),
100 	/* PDMA_MAIN1 - UART0-6 */
101 	PSIL_PDMA_XY_PKT(0x4400),
102 	PSIL_PDMA_XY_PKT(0x4401),
103 	PSIL_PDMA_XY_PKT(0x4402),
104 	PSIL_PDMA_XY_PKT(0x4403),
105 	PSIL_PDMA_XY_PKT(0x4404),
106 	PSIL_PDMA_XY_PKT(0x4405),
107 	PSIL_PDMA_XY_PKT(0x4406),
108 	/* PDMA_MAIN2 - MCASP0-2 */
109 	PSIL_PDMA_MCASP(0x4500),
110 	PSIL_PDMA_MCASP(0x4501),
111 	PSIL_PDMA_MCASP(0x4502),
112 	/* CPSW3G */
113 	PSIL_ETHERNET(0x4600, 19, 19, 16),
114 	/* CSI2RX */
115 	PSIL_CSI2RX(0x5000),
116 	PSIL_CSI2RX(0x5001),
117 	PSIL_CSI2RX(0x5002),
118 	PSIL_CSI2RX(0x5003),
119 	PSIL_CSI2RX(0x5004),
120 	PSIL_CSI2RX(0x5005),
121 	PSIL_CSI2RX(0x5006),
122 	PSIL_CSI2RX(0x5007),
123 	PSIL_CSI2RX(0x5008),
124 	PSIL_CSI2RX(0x5009),
125 	PSIL_CSI2RX(0x500a),
126 	PSIL_CSI2RX(0x500b),
127 	PSIL_CSI2RX(0x500c),
128 	PSIL_CSI2RX(0x500d),
129 	PSIL_CSI2RX(0x500e),
130 	PSIL_CSI2RX(0x500f),
131 	PSIL_CSI2RX(0x5010),
132 	PSIL_CSI2RX(0x5011),
133 	PSIL_CSI2RX(0x5012),
134 	PSIL_CSI2RX(0x5013),
135 	PSIL_CSI2RX(0x5014),
136 	PSIL_CSI2RX(0x5015),
137 	PSIL_CSI2RX(0x5016),
138 	PSIL_CSI2RX(0x5017),
139 	PSIL_CSI2RX(0x5018),
140 	PSIL_CSI2RX(0x5019),
141 	PSIL_CSI2RX(0x501a),
142 	PSIL_CSI2RX(0x501b),
143 	PSIL_CSI2RX(0x501c),
144 	PSIL_CSI2RX(0x501d),
145 	PSIL_CSI2RX(0x501e),
146 	PSIL_CSI2RX(0x501f),
147 	PSIL_CSI2RX(0x5000),
148 	PSIL_CSI2RX(0x5001),
149 	PSIL_CSI2RX(0x5002),
150 	PSIL_CSI2RX(0x5003),
151 	PSIL_CSI2RX(0x5004),
152 	PSIL_CSI2RX(0x5005),
153 	PSIL_CSI2RX(0x5006),
154 	PSIL_CSI2RX(0x5007),
155 	PSIL_CSI2RX(0x5008),
156 	PSIL_CSI2RX(0x5009),
157 	PSIL_CSI2RX(0x500a),
158 	PSIL_CSI2RX(0x500b),
159 	PSIL_CSI2RX(0x500c),
160 	PSIL_CSI2RX(0x500d),
161 	PSIL_CSI2RX(0x500e),
162 	PSIL_CSI2RX(0x500f),
163 	PSIL_CSI2RX(0x5010),
164 	PSIL_CSI2RX(0x5011),
165 	PSIL_CSI2RX(0x5012),
166 	PSIL_CSI2RX(0x5013),
167 	PSIL_CSI2RX(0x5014),
168 	PSIL_CSI2RX(0x5015),
169 	PSIL_CSI2RX(0x5016),
170 	PSIL_CSI2RX(0x5017),
171 	PSIL_CSI2RX(0x5018),
172 	PSIL_CSI2RX(0x5019),
173 	PSIL_CSI2RX(0x501a),
174 	PSIL_CSI2RX(0x501b),
175 	PSIL_CSI2RX(0x501c),
176 	PSIL_CSI2RX(0x501d),
177 	PSIL_CSI2RX(0x501e),
178 	PSIL_CSI2RX(0x501f),
179 	/* CSIRX 1-3 (only for J722S) */
180 	PSIL_CSI2RX(0x5100),
181 	PSIL_CSI2RX(0x5101),
182 	PSIL_CSI2RX(0x5102),
183 	PSIL_CSI2RX(0x5103),
184 	PSIL_CSI2RX(0x5104),
185 	PSIL_CSI2RX(0x5105),
186 	PSIL_CSI2RX(0x5106),
187 	PSIL_CSI2RX(0x5107),
188 	PSIL_CSI2RX(0x5108),
189 	PSIL_CSI2RX(0x5109),
190 	PSIL_CSI2RX(0x510a),
191 	PSIL_CSI2RX(0x510b),
192 	PSIL_CSI2RX(0x510c),
193 	PSIL_CSI2RX(0x510d),
194 	PSIL_CSI2RX(0x510e),
195 	PSIL_CSI2RX(0x510f),
196 	PSIL_CSI2RX(0x5110),
197 	PSIL_CSI2RX(0x5111),
198 	PSIL_CSI2RX(0x5112),
199 	PSIL_CSI2RX(0x5113),
200 	PSIL_CSI2RX(0x5114),
201 	PSIL_CSI2RX(0x5115),
202 	PSIL_CSI2RX(0x5116),
203 	PSIL_CSI2RX(0x5117),
204 	PSIL_CSI2RX(0x5118),
205 	PSIL_CSI2RX(0x5119),
206 	PSIL_CSI2RX(0x511a),
207 	PSIL_CSI2RX(0x511b),
208 	PSIL_CSI2RX(0x511c),
209 	PSIL_CSI2RX(0x511d),
210 	PSIL_CSI2RX(0x511e),
211 	PSIL_CSI2RX(0x511f),
212 	PSIL_CSI2RX(0x5200),
213 	PSIL_CSI2RX(0x5201),
214 	PSIL_CSI2RX(0x5202),
215 	PSIL_CSI2RX(0x5203),
216 	PSIL_CSI2RX(0x5204),
217 	PSIL_CSI2RX(0x5205),
218 	PSIL_CSI2RX(0x5206),
219 	PSIL_CSI2RX(0x5207),
220 	PSIL_CSI2RX(0x5208),
221 	PSIL_CSI2RX(0x5209),
222 	PSIL_CSI2RX(0x520a),
223 	PSIL_CSI2RX(0x520b),
224 	PSIL_CSI2RX(0x520c),
225 	PSIL_CSI2RX(0x520d),
226 	PSIL_CSI2RX(0x520e),
227 	PSIL_CSI2RX(0x520f),
228 	PSIL_CSI2RX(0x5210),
229 	PSIL_CSI2RX(0x5211),
230 	PSIL_CSI2RX(0x5212),
231 	PSIL_CSI2RX(0x5213),
232 	PSIL_CSI2RX(0x5214),
233 	PSIL_CSI2RX(0x5215),
234 	PSIL_CSI2RX(0x5216),
235 	PSIL_CSI2RX(0x5217),
236 	PSIL_CSI2RX(0x5218),
237 	PSIL_CSI2RX(0x5219),
238 	PSIL_CSI2RX(0x521a),
239 	PSIL_CSI2RX(0x521b),
240 	PSIL_CSI2RX(0x521c),
241 	PSIL_CSI2RX(0x521d),
242 	PSIL_CSI2RX(0x521e),
243 	PSIL_CSI2RX(0x521f),
244 	PSIL_CSI2RX(0x5300),
245 	PSIL_CSI2RX(0x5301),
246 	PSIL_CSI2RX(0x5302),
247 	PSIL_CSI2RX(0x5303),
248 	PSIL_CSI2RX(0x5304),
249 	PSIL_CSI2RX(0x5305),
250 	PSIL_CSI2RX(0x5306),
251 	PSIL_CSI2RX(0x5307),
252 	PSIL_CSI2RX(0x5308),
253 	PSIL_CSI2RX(0x5309),
254 	PSIL_CSI2RX(0x530a),
255 	PSIL_CSI2RX(0x530b),
256 	PSIL_CSI2RX(0x530c),
257 	PSIL_CSI2RX(0x530d),
258 	PSIL_CSI2RX(0x530e),
259 	PSIL_CSI2RX(0x530f),
260 	PSIL_CSI2RX(0x5310),
261 	PSIL_CSI2RX(0x5311),
262 	PSIL_CSI2RX(0x5312),
263 	PSIL_CSI2RX(0x5313),
264 	PSIL_CSI2RX(0x5314),
265 	PSIL_CSI2RX(0x5315),
266 	PSIL_CSI2RX(0x5316),
267 	PSIL_CSI2RX(0x5317),
268 	PSIL_CSI2RX(0x5318),
269 	PSIL_CSI2RX(0x5319),
270 	PSIL_CSI2RX(0x531a),
271 	PSIL_CSI2RX(0x531b),
272 	PSIL_CSI2RX(0x531c),
273 	PSIL_CSI2RX(0x531d),
274 	PSIL_CSI2RX(0x531e),
275 	PSIL_CSI2RX(0x531f),
276 };
277 
278 /* PSI-L destination thread IDs, used for TX (DMA_MEM_TO_DEV) */
279 static struct psil_ep am62p_dst_ep_map[] = {
280 	/* SAUL */
281 	PSIL_SAUL(0xf500, 27, 83, 8, 83, 1),
282 	PSIL_SAUL(0xf501, 28, 91, 8, 91, 1),
283 	/* PDMA_MAIN0 - SPI0-2 */
284 	PSIL_PDMA_XY_PKT(0xc300),
285 	PSIL_PDMA_XY_PKT(0xc301),
286 	PSIL_PDMA_XY_PKT(0xc302),
287 	PSIL_PDMA_XY_PKT(0xc303),
288 	PSIL_PDMA_XY_PKT(0xc304),
289 	PSIL_PDMA_XY_PKT(0xc305),
290 	PSIL_PDMA_XY_PKT(0xc306),
291 	PSIL_PDMA_XY_PKT(0xc307),
292 	PSIL_PDMA_XY_PKT(0xc308),
293 	PSIL_PDMA_XY_PKT(0xc309),
294 	PSIL_PDMA_XY_PKT(0xc30a),
295 	PSIL_PDMA_XY_PKT(0xc30b),
296 	/* PDMA_MAIN1 - UART0-6 */
297 	PSIL_PDMA_XY_PKT(0xc400),
298 	PSIL_PDMA_XY_PKT(0xc401),
299 	PSIL_PDMA_XY_PKT(0xc402),
300 	PSIL_PDMA_XY_PKT(0xc403),
301 	PSIL_PDMA_XY_PKT(0xc404),
302 	PSIL_PDMA_XY_PKT(0xc405),
303 	PSIL_PDMA_XY_PKT(0xc406),
304 	/* PDMA_MAIN2 - MCASP0-2 */
305 	PSIL_PDMA_MCASP(0xc500),
306 	PSIL_PDMA_MCASP(0xc501),
307 	PSIL_PDMA_MCASP(0xc502),
308 	/* CPSW3G */
309 	PSIL_ETHERNET(0xc600, 19, 19, 8),
310 	PSIL_ETHERNET(0xc601, 20, 27, 8),
311 	PSIL_ETHERNET(0xc602, 21, 35, 8),
312 	PSIL_ETHERNET(0xc603, 22, 43, 8),
313 	PSIL_ETHERNET(0xc604, 23, 51, 8),
314 	PSIL_ETHERNET(0xc605, 24, 59, 8),
315 	PSIL_ETHERNET(0xc606, 25, 67, 8),
316 	PSIL_ETHERNET(0xc607, 26, 75, 8),
317 };
318 
319 struct psil_ep_map am62p_ep_map = {
320 	.name = "am62p",
321 	.src = am62p_src_ep_map,
322 	.src_count = ARRAY_SIZE(am62p_src_ep_map),
323 	.dst = am62p_dst_ep_map,
324 	.dst_count = ARRAY_SIZE(am62p_dst_ep_map),
325 };
326