xref: /linux/drivers/dma/ti/k3-psil-am62a.c (revision 06d07429858317ded2db7986113a9e0129cd599b)
1aac6db7eSJai Luthra // SPDX-License-Identifier: GPL-2.0
2aac6db7eSJai Luthra /*
3aac6db7eSJai Luthra  *  Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com
4aac6db7eSJai Luthra  */
5aac6db7eSJai Luthra 
6aac6db7eSJai Luthra #include <linux/kernel.h>
7aac6db7eSJai Luthra 
8aac6db7eSJai Luthra #include "k3-psil-priv.h"
9aac6db7eSJai Luthra 
10aac6db7eSJai Luthra #define PSIL_PDMA_XY_TR(x)					\
11aac6db7eSJai Luthra 	{							\
12aac6db7eSJai Luthra 		.thread_id = x,					\
13aac6db7eSJai Luthra 		.ep_config = {					\
14aac6db7eSJai Luthra 			.ep_type = PSIL_EP_PDMA_XY,		\
15aac6db7eSJai Luthra 			.mapped_channel_id = -1,		\
16aac6db7eSJai Luthra 			.default_flow_id = -1,			\
17aac6db7eSJai Luthra 		},						\
18aac6db7eSJai Luthra 	}
19aac6db7eSJai Luthra 
20aac6db7eSJai Luthra #define PSIL_PDMA_XY_PKT(x)					\
21aac6db7eSJai Luthra 	{							\
22aac6db7eSJai Luthra 		.thread_id = x,					\
23aac6db7eSJai Luthra 		.ep_config = {					\
24aac6db7eSJai Luthra 			.ep_type = PSIL_EP_PDMA_XY,		\
25aac6db7eSJai Luthra 			.mapped_channel_id = -1,		\
26aac6db7eSJai Luthra 			.default_flow_id = -1,			\
27aac6db7eSJai Luthra 			.pkt_mode = 1,				\
28aac6db7eSJai Luthra 		},						\
29aac6db7eSJai Luthra 	}
30aac6db7eSJai Luthra 
31aac6db7eSJai Luthra #define PSIL_ETHERNET(x, ch, flow_base, flow_cnt)		\
32aac6db7eSJai Luthra 	{							\
33aac6db7eSJai Luthra 		.thread_id = x,					\
34aac6db7eSJai Luthra 		.ep_config = {					\
35aac6db7eSJai Luthra 			.ep_type = PSIL_EP_NATIVE,		\
36aac6db7eSJai Luthra 			.pkt_mode = 1,				\
37aac6db7eSJai Luthra 			.needs_epib = 1,			\
38aac6db7eSJai Luthra 			.psd_size = 16,				\
39aac6db7eSJai Luthra 			.mapped_channel_id = ch,		\
40aac6db7eSJai Luthra 			.flow_start = flow_base,		\
41aac6db7eSJai Luthra 			.flow_num = flow_cnt,			\
42aac6db7eSJai Luthra 			.default_flow_id = flow_base,		\
43aac6db7eSJai Luthra 		},						\
44aac6db7eSJai Luthra 	}
45aac6db7eSJai Luthra 
46aac6db7eSJai Luthra #define PSIL_SAUL(x, ch, flow_base, flow_cnt, default_flow, tx)	\
47aac6db7eSJai Luthra 	{							\
48aac6db7eSJai Luthra 		.thread_id = x,					\
49aac6db7eSJai Luthra 		.ep_config = {					\
50aac6db7eSJai Luthra 			.ep_type = PSIL_EP_NATIVE,		\
51aac6db7eSJai Luthra 			.pkt_mode = 1,				\
52aac6db7eSJai Luthra 			.needs_epib = 1,			\
53aac6db7eSJai Luthra 			.psd_size = 64,				\
54aac6db7eSJai Luthra 			.mapped_channel_id = ch,		\
55aac6db7eSJai Luthra 			.flow_start = flow_base,		\
56aac6db7eSJai Luthra 			.flow_num = flow_cnt,			\
57aac6db7eSJai Luthra 			.default_flow_id = default_flow,	\
58aac6db7eSJai Luthra 			.notdpkt = tx,				\
59aac6db7eSJai Luthra 		},						\
60aac6db7eSJai Luthra 	}
61aac6db7eSJai Luthra 
62aac6db7eSJai Luthra #define PSIL_PDMA_MCASP(x)				\
63aac6db7eSJai Luthra 	{						\
64aac6db7eSJai Luthra 		.thread_id = x,				\
65aac6db7eSJai Luthra 		.ep_config = {				\
66aac6db7eSJai Luthra 			.ep_type = PSIL_EP_PDMA_XY,	\
67aac6db7eSJai Luthra 			.pdma_acc32 = 1,		\
68aac6db7eSJai Luthra 			.pdma_burst = 1,		\
69aac6db7eSJai Luthra 		},					\
70aac6db7eSJai Luthra 	}
71aac6db7eSJai Luthra 
72aac6db7eSJai Luthra #define PSIL_CSI2RX(x)					\
73aac6db7eSJai Luthra 	{						\
74aac6db7eSJai Luthra 		.thread_id = x,				\
75aac6db7eSJai Luthra 		.ep_config = {				\
76aac6db7eSJai Luthra 			.ep_type = PSIL_EP_NATIVE,	\
77aac6db7eSJai Luthra 		},					\
78aac6db7eSJai Luthra 	}
79aac6db7eSJai Luthra 
80aac6db7eSJai Luthra /* PSI-L source thread IDs, used for RX (DMA_DEV_TO_MEM) */
81aac6db7eSJai Luthra static struct psil_ep am62a_src_ep_map[] = {
82aac6db7eSJai Luthra 	/* SAUL */
83aac6db7eSJai Luthra 	PSIL_SAUL(0x7504, 20, 35, 8, 35, 0),
84aac6db7eSJai Luthra 	PSIL_SAUL(0x7505, 21, 35, 8, 36, 0),
85aac6db7eSJai Luthra 	PSIL_SAUL(0x7506, 22, 43, 8, 43, 0),
86aac6db7eSJai Luthra 	PSIL_SAUL(0x7507, 23, 43, 8, 44, 0),
87*be37542aSJai Luthra 	/* PDMA_MAIN0 - SPI0-2 */
88*be37542aSJai Luthra 	PSIL_PDMA_XY_PKT(0x4300),
89*be37542aSJai Luthra 	PSIL_PDMA_XY_PKT(0x4301),
90aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4302),
91aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4303),
92aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4304),
93aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4305),
94aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4306),
95aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4307),
96aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4308),
97aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4309),
98aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x430a),
99aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x430b),
100aac6db7eSJai Luthra 	/* PDMA_MAIN1 - UART0-6 */
101aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4400),
102aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4401),
103aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4402),
104aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4403),
105aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4404),
106aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4405),
107aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0x4406),
108aac6db7eSJai Luthra 	/* PDMA_MAIN2 - MCASP0-2 */
109aac6db7eSJai Luthra 	PSIL_PDMA_MCASP(0x4500),
110aac6db7eSJai Luthra 	PSIL_PDMA_MCASP(0x4501),
111aac6db7eSJai Luthra 	PSIL_PDMA_MCASP(0x4502),
112aac6db7eSJai Luthra 	/* CPSW3G */
113aac6db7eSJai Luthra 	PSIL_ETHERNET(0x4600, 19, 19, 16),
114aac6db7eSJai Luthra 	/* CSI2RX */
115aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5000),
116aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5001),
117aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5002),
118aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5003),
119aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5004),
120aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5005),
121aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5006),
122aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5007),
123aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5008),
124aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5009),
125aac6db7eSJai Luthra 	PSIL_CSI2RX(0x500a),
126aac6db7eSJai Luthra 	PSIL_CSI2RX(0x500b),
127aac6db7eSJai Luthra 	PSIL_CSI2RX(0x500c),
128aac6db7eSJai Luthra 	PSIL_CSI2RX(0x500d),
129aac6db7eSJai Luthra 	PSIL_CSI2RX(0x500e),
130aac6db7eSJai Luthra 	PSIL_CSI2RX(0x500f),
131aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5010),
132aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5011),
133aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5012),
134aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5013),
135aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5014),
136aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5015),
137aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5016),
138aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5017),
139aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5018),
140aac6db7eSJai Luthra 	PSIL_CSI2RX(0x5019),
141aac6db7eSJai Luthra 	PSIL_CSI2RX(0x501a),
142aac6db7eSJai Luthra 	PSIL_CSI2RX(0x501b),
143aac6db7eSJai Luthra 	PSIL_CSI2RX(0x501c),
144aac6db7eSJai Luthra 	PSIL_CSI2RX(0x501d),
145aac6db7eSJai Luthra 	PSIL_CSI2RX(0x501e),
146aac6db7eSJai Luthra 	PSIL_CSI2RX(0x501f),
147aac6db7eSJai Luthra };
148aac6db7eSJai Luthra 
149aac6db7eSJai Luthra /* PSI-L destination thread IDs, used for TX (DMA_MEM_TO_DEV) */
150aac6db7eSJai Luthra static struct psil_ep am62a_dst_ep_map[] = {
151aac6db7eSJai Luthra 	/* SAUL */
152aac6db7eSJai Luthra 	PSIL_SAUL(0xf500, 27, 83, 8, 83, 1),
153aac6db7eSJai Luthra 	PSIL_SAUL(0xf501, 28, 91, 8, 91, 1),
154*be37542aSJai Luthra 	/* PDMA_MAIN0 - SPI0-2 */
155*be37542aSJai Luthra 	PSIL_PDMA_XY_PKT(0xc300),
156*be37542aSJai Luthra 	PSIL_PDMA_XY_PKT(0xc301),
157aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc302),
158aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc303),
159aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc304),
160aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc305),
161aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc306),
162aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc307),
163aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc308),
164aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc309),
165aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc30a),
166aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc30b),
167aac6db7eSJai Luthra 	/* PDMA_MAIN1 - UART0-6 */
168aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc400),
169aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc401),
170aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc402),
171aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc403),
172aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc404),
173aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc405),
174aac6db7eSJai Luthra 	PSIL_PDMA_XY_PKT(0xc406),
175aac6db7eSJai Luthra 	/* PDMA_MAIN2 - MCASP0-2 */
176aac6db7eSJai Luthra 	PSIL_PDMA_MCASP(0xc500),
177aac6db7eSJai Luthra 	PSIL_PDMA_MCASP(0xc501),
178aac6db7eSJai Luthra 	PSIL_PDMA_MCASP(0xc502),
179aac6db7eSJai Luthra 	/* CPSW3G */
180aac6db7eSJai Luthra 	PSIL_ETHERNET(0xc600, 19, 19, 8),
181aac6db7eSJai Luthra 	PSIL_ETHERNET(0xc601, 20, 27, 8),
182aac6db7eSJai Luthra 	PSIL_ETHERNET(0xc602, 21, 35, 8),
183aac6db7eSJai Luthra 	PSIL_ETHERNET(0xc603, 22, 43, 8),
184aac6db7eSJai Luthra 	PSIL_ETHERNET(0xc604, 23, 51, 8),
185aac6db7eSJai Luthra 	PSIL_ETHERNET(0xc605, 24, 59, 8),
186aac6db7eSJai Luthra 	PSIL_ETHERNET(0xc606, 25, 67, 8),
187aac6db7eSJai Luthra 	PSIL_ETHERNET(0xc607, 26, 75, 8),
188aac6db7eSJai Luthra };
189aac6db7eSJai Luthra 
190aac6db7eSJai Luthra struct psil_ep_map am62a_ep_map = {
191aac6db7eSJai Luthra 	.name = "am62a",
192aac6db7eSJai Luthra 	.src = am62a_src_ep_map,
193aac6db7eSJai Luthra 	.src_count = ARRAY_SIZE(am62a_src_ep_map),
194aac6db7eSJai Luthra 	.dst = am62a_dst_ep_map,
195aac6db7eSJai Luthra 	.dst_count = ARRAY_SIZE(am62a_dst_ep_map),
196aac6db7eSJai Luthra };
197