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 j7200_src_ep_map[] = {
638c2ecf20Sopenharmony_ci	/* PDMA_MCASP - McASP0-2 */
648c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4400),
658c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4401),
668c2ecf20Sopenharmony_ci	PSIL_PDMA_MCASP(0x4402),
678c2ecf20Sopenharmony_ci	/* PDMA_SPI_G0 - SPI0-3 */
688c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4600),
698c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4601),
708c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4602),
718c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4603),
728c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4604),
738c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4605),
748c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4606),
758c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4607),
768c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4608),
778c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4609),
788c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460a),
798c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460b),
808c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460c),
818c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460d),
828c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460e),
838c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460f),
848c2ecf20Sopenharmony_ci	/* PDMA_SPI_G1 - SPI4-7 */
858c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4610),
868c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4611),
878c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4612),
888c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4613),
898c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4614),
908c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4615),
918c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4616),
928c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4617),
938c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4618),
948c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4619),
958c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461a),
968c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461b),
978c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461c),
988c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461d),
998c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461e),
1008c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461f),
1018c2ecf20Sopenharmony_ci	/* PDMA_USART_G0 - UART0-1 */
1028c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4700),
1038c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4701),
1048c2ecf20Sopenharmony_ci	/* PDMA_USART_G1 - UART2-3 */
1058c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4702),
1068c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4703),
1078c2ecf20Sopenharmony_ci	/* PDMA_USART_G2 - UART4-9 */
1088c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4704),
1098c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4705),
1108c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4706),
1118c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4707),
1128c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4708),
1138c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4709),
1148c2ecf20Sopenharmony_ci	/* CPSW5 */
1158c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x4a00),
1168c2ecf20Sopenharmony_ci	/* CPSW0 */
1178c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0x7000),
1188c2ecf20Sopenharmony_ci	/* MCU_PDMA_MISC_G0 - SPI0 */
1198c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7100),
1208c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7101),
1218c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7102),
1228c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7103),
1238c2ecf20Sopenharmony_ci	/* MCU_PDMA_MISC_G1 - SPI1-2 */
1248c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7200),
1258c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7201),
1268c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7202),
1278c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7203),
1288c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7204),
1298c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7205),
1308c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7206),
1318c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7207),
1328c2ecf20Sopenharmony_ci	/* MCU_PDMA_MISC_G2 - UART0 */
1338c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7300),
1348c2ecf20Sopenharmony_ci	/* MCU_PDMA_ADC - ADC0-1 */
1358c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7400),
1368c2ecf20Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7401),
1378c2ecf20Sopenharmony_ci	/* SA2UL */
1388c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x7500, 0),
1398c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x7501, 0),
1408c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x7502, 0),
1418c2ecf20Sopenharmony_ci	PSIL_SA2UL(0x7503, 0),
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* PSI-L destination thread IDs, used for TX (DMA_MEM_TO_DEV) */
1458c2ecf20Sopenharmony_cistatic struct psil_ep j7200_dst_ep_map[] = {
1468c2ecf20Sopenharmony_ci	/* CPSW5 */
1478c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca00),
1488c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca01),
1498c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca02),
1508c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca03),
1518c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca04),
1528c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca05),
1538c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca06),
1548c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xca07),
1558c2ecf20Sopenharmony_ci	/* CPSW0 */
1568c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf000),
1578c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf001),
1588c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf002),
1598c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf003),
1608c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf004),
1618c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf005),
1628c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf006),
1638c2ecf20Sopenharmony_ci	PSIL_ETHERNET(0xf007),
1648c2ecf20Sopenharmony_ci	/* SA2UL */
1658c2ecf20Sopenharmony_ci	PSIL_SA2UL(0xf500, 1),
1668c2ecf20Sopenharmony_ci	PSIL_SA2UL(0xf501, 1),
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_cistruct psil_ep_map j7200_ep_map = {
1708c2ecf20Sopenharmony_ci	.name = "j7200",
1718c2ecf20Sopenharmony_ci	.src = j7200_src_ep_map,
1728c2ecf20Sopenharmony_ci	.src_count = ARRAY_SIZE(j7200_src_ep_map),
1738c2ecf20Sopenharmony_ci	.dst = j7200_dst_ep_map,
1748c2ecf20Sopenharmony_ci	.dst_count = ARRAY_SIZE(j7200_dst_ep_map),
1758c2ecf20Sopenharmony_ci};
176