18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com
48c2ecf20Sopenharmony_ci *  Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/kernel.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include "k3-psil-priv.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define PSIL_PDMA_XY_TR(x)				\
128c2ecf20Sopenharmony_ci	{						\
138c2ecf20Sopenharmony_ci		.thread_id = x,				\
148c2ecf20Sopenharmony_ci		.ep_config = {				\
158c2ecf20Sopenharmony_ci			.ep_type = PSIL_EP_PDMA_XY,	\
168c2ecf20Sopenharmony_ci		},					\
178c2ecf20Sopenharmony_ci	}
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define PSIL_PDMA_XY_PKT(x)				\
208c2ecf20Sopenharmony_ci	{						\
218c2ecf20Sopenharmony_ci		.thread_id = x,				\
228c2ecf20Sopenharmony_ci		.ep_config = {				\
238c2ecf20Sopenharmony_ci			.ep_type = PSIL_EP_PDMA_XY,	\
248c2ecf20Sopenharmony_ci			.pkt_mode = 1,			\
258c2ecf20Sopenharmony_ci		},					\
268c2ecf20Sopenharmony_ci	}
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define PSIL_PDMA_MCASP(x)				\
298c2ecf20Sopenharmony_ci	{						\
308c2ecf20Sopenharmony_ci		.thread_id = x,				\
318c2ecf20Sopenharmony_ci		.ep_config = {				\
328c2ecf20Sopenharmony_ci			.ep_type = PSIL_EP_PDMA_XY,	\
338c2ecf20Sopenharmony_ci			.pdma_acc32 = 1,		\
348c2ecf20Sopenharmony_ci			.pdma_burst = 1,		\
358c2ecf20Sopenharmony_ci		},					\
368c2ecf20Sopenharmony_ci	}
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define PSIL_ETHERNET(x)				\
398c2ecf20Sopenharmony_ci	{						\
408c2ecf20Sopenharmony_ci		.thread_id = x,				\
418c2ecf20Sopenharmony_ci		.ep_config = {				\
428c2ecf20Sopenharmony_ci			.ep_type = PSIL_EP_NATIVE,	\
438c2ecf20Sopenharmony_ci			.pkt_mode = 1,			\
448c2ecf20Sopenharmony_ci			.needs_epib = 1,		\
458c2ecf20Sopenharmony_ci			.psd_size = 16,			\
468c2ecf20Sopenharmony_ci		},					\
478c2ecf20Sopenharmony_ci	}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define PSIL_SA2UL(x, tx)				\
508c2ecf20Sopenharmony_ci	{						\
518c2ecf20Sopenharmony_ci		.thread_id = x,				\
528c2ecf20Sopenharmony_ci		.ep_config = {				\
538c2ecf20Sopenharmony_ci			.ep_type = PSIL_EP_NATIVE,	\
548c2ecf20Sopenharmony_ci			.pkt_mode = 1,			\
558c2ecf20Sopenharmony_ci			.needs_epib = 1,		\
568c2ecf20Sopenharmony_ci			.psd_size = 64,			\
578c2ecf20Sopenharmony_ci			.notdpkt = tx,			\
588c2ecf20Sopenharmony_ci		},					\
598c2ecf20Sopenharmony_ci	}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* PSI-L source thread IDs, used for RX (DMA_DEV_TO_MEM) */
628c2ecf20Sopenharmony_cistatic struct psil_ep j721e_src_ep_map[] = {
638c2ecf20Sopenharmony_ci	/* SA2UL */
648c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x4000, 0),
658c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x4001, 0),
668c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x4002, 0),
678c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x4003, 0),
688c2ecf20Sopenharmony_ci	/* PRU_ICSSG0 */
698c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4100),
708c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4101),
718c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4102),
728c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4103),
738c2ecf20Sopenharmony_ci	/* PRU_ICSSG1 */
748c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4200),
758c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4201),
768c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4202),
778c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4203),
788c2ecf20Sopenharmony_ci	/* PDMA6 (PSIL_PDMA_MCASP_G0) - McASP0-2 */
798c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4400),
808c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4401),
818c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4402),
828c2ecf20Sopenharmony_ci	/* PDMA7 (PSIL_PDMA_MCASP_G1) - McASP3-11 */
838c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4500),
848c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4501),
858c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4502),
868c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4503),
878c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4504),
888c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4505),
898c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4506),
908c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4507),
918c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4508),
928c2ecf20Sopenharmony_ci	/* PDMA8 (PDMA_MISC_G0) - SPI0-1 */
938c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4600),
948c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4601),
958c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4602),
968c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4603),
978c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4604),
988c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4605),
998c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4606),
1008c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4607),
1018c2ecf20Sopenharmony_ci	/* PDMA9 (PDMA_MISC_G1) - SPI2-3 */
1028c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460c),
1038c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460d),
1048c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460e),
1058c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460f),
1068c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4610),
1078c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4611),
1088c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4612),
1098c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4613),
1108c2ecf20Sopenharmony_ci	/* PDMA10 (PDMA_MISC_G2) - SPI4-5 */
1118c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4618),
1128c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4619),
1138c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461a),
1148c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461b),
1158c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461c),
1168c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461d),
1178c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461e),
1188c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461f),
1198c2ecf20Sopenharmony_ci	/* PDMA11 (PDMA_MISC_G3) */
1208c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4624),
1218c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4625),
1228c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4626),
1238c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4627),
1248c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4628),
1258c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4629),
1268c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4630),
1278c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x463a),
1288c2ecf20Sopenharmony_ci	/* PDMA13 (PDMA_USART_G0) - UART0-1 */
1298c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4700),
1308c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4701),
1318c2ecf20Sopenharmony_ci	/* PDMA14 (PDMA_USART_G1) - UART2-3 */
1328c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4702),
1338c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4703),
1348c2ecf20Sopenharmony_ci	/* PDMA15 (PDMA_USART_G2) - UART4-9 */
1358c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4704),
1368c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4705),
1378c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4706),
1388c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4707),
1398c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4708),
1408c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4709),
1418c2ecf20Sopenharmony_ci	/* CPSW9 */
1428c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4a00),
1438c2ecf20Sopenharmony_ci	/* CPSW0 */
1448c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x7000),
1458c2ecf20Sopenharmony_ci	/* MCU_PDMA0 (MCU_PDMA_MISC_G0) - SPI0 */
1468c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7100),
1478c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7101),
1488c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7102),
1498c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7103),
1508c2ecf20Sopenharmony_ci	/* MCU_PDMA1 (MCU_PDMA_MISC_G1) - SPI1-2 */
1518c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7200),
1528c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7201),
1538c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7202),
1548c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7203),
1558c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7204),
1568c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7205),
1578c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7206),
1588c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7207),
1598c2ecf20Sopenharmony_ci	/* MCU_PDMA2 (MCU_PDMA_MISC_G2) - UART0 */
1608c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7300),
1618c2ecf20Sopenharmony_ci	/* MCU_PDMA_ADC - ADC0-1 */
1628c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7400),
1638c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7401),
1648c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7402),
1658c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7403),
1668c2ecf20Sopenharmony_ci	/* SA2UL */
1678c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x7500, 0),
1688c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x7501, 0),
1698c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x7502, 0),
1708c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x7503, 0),
1718c2ecf20Sopenharmony_ci};
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/* PSI-L destination thread IDs, used for TX (DMA_MEM_TO_DEV) */
1748c2ecf20Sopenharmony_cistatic struct psil_ep j721e_dst_ep_map[] = {
1758c2ecf20Sopenharmony_ci	/* SA2UL */
1768c2ecf20Sopenharmony_ci	PSIL_SA2UL(0xc000, 1),
1778c2ecf20Sopenharmony_ci	PSIL_SA2UL(0xc001, 1),
1788c2ecf20Sopenharmony_ci	/* PRU_ICSSG0 */
1798c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc100),
1808c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc101),
1818c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc102),
1828c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc103),
1838c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc104),
1848c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc105),
1858c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc106),
1868c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc107),
1878c2ecf20Sopenharmony_ci	/* PRU_ICSSG1 */
1888c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc200),
1898c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc201),
1908c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc202),
1918c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc203),
1928c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc204),
1938c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc205),
1948c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc206),
1958c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xc207),
1968c2ecf20Sopenharmony_ci	/* CPSW9 */
1978c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca00),
1988c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca01),
1998c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca02),
2008c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca03),
2018c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca04),
2028c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca05),
2038c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca06),
2048c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca07),
2058c2ecf20Sopenharmony_ci	/* CPSW0 */
2068c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf000),
2078c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf001),
2088c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf002),
2098c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf003),
2108c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf004),
2118c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf005),
2128c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf006),
2138c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf007),
2148c2ecf20Sopenharmony_ci	/* SA2UL */
2158c2ecf20Sopenharmony_ci	PSIL_SA2UL(0xf500, 1),
2168c2ecf20Sopenharmony_ci	PSIL_SA2UL(0xf501, 1),
2178c2ecf20Sopenharmony_ci};
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_cistruct psil_ep_map j721e_ep_map = {
2208c2ecf20Sopenharmony_ci	.name = "j721e",
2218c2ecf20Sopenharmony_ci	.src = j721e_src_ep_map,
2228c2ecf20Sopenharmony_ci	.src_count = ARRAY_SIZE(j721e_src_ep_map),
2238c2ecf20Sopenharmony_ci	.dst = j721e_dst_ep_map,
2248c2ecf20Sopenharmony_ci	.dst_count = ARRAY_SIZE(j721e_dst_ep_map),
2258c2ecf20Sopenharmony_ci};
226