162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#include <linux/kernel.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include "k3-psil-priv.h"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#define PSIL_PDMA_XY_TR(x)				\
1162306a36Sopenharmony_ci	{						\
1262306a36Sopenharmony_ci		.thread_id = x,				\
1362306a36Sopenharmony_ci		.ep_config = {				\
1462306a36Sopenharmony_ci			.ep_type = PSIL_EP_PDMA_XY,	\
1562306a36Sopenharmony_ci		},					\
1662306a36Sopenharmony_ci	}
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define PSIL_PDMA_XY_PKT(x)				\
1962306a36Sopenharmony_ci	{						\
2062306a36Sopenharmony_ci		.thread_id = x,				\
2162306a36Sopenharmony_ci		.ep_config = {				\
2262306a36Sopenharmony_ci			.ep_type = PSIL_EP_PDMA_XY,	\
2362306a36Sopenharmony_ci			.pkt_mode = 1,			\
2462306a36Sopenharmony_ci		},					\
2562306a36Sopenharmony_ci	}
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#define PSIL_PDMA_MCASP(x)				\
2862306a36Sopenharmony_ci	{						\
2962306a36Sopenharmony_ci		.thread_id = x,				\
3062306a36Sopenharmony_ci		.ep_config = {				\
3162306a36Sopenharmony_ci			.ep_type = PSIL_EP_PDMA_XY,	\
3262306a36Sopenharmony_ci			.pdma_acc32 = 1,		\
3362306a36Sopenharmony_ci			.pdma_burst = 1,		\
3462306a36Sopenharmony_ci		},					\
3562306a36Sopenharmony_ci	}
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define PSIL_ETHERNET(x)				\
3862306a36Sopenharmony_ci	{						\
3962306a36Sopenharmony_ci		.thread_id = x,				\
4062306a36Sopenharmony_ci		.ep_config = {				\
4162306a36Sopenharmony_ci			.ep_type = PSIL_EP_NATIVE,	\
4262306a36Sopenharmony_ci			.pkt_mode = 1,			\
4362306a36Sopenharmony_ci			.needs_epib = 1,		\
4462306a36Sopenharmony_ci			.psd_size = 16,			\
4562306a36Sopenharmony_ci		},					\
4662306a36Sopenharmony_ci	}
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define PSIL_SA2UL(x, tx)				\
4962306a36Sopenharmony_ci	{						\
5062306a36Sopenharmony_ci		.thread_id = x,				\
5162306a36Sopenharmony_ci		.ep_config = {				\
5262306a36Sopenharmony_ci			.ep_type = PSIL_EP_NATIVE,	\
5362306a36Sopenharmony_ci			.pkt_mode = 1,			\
5462306a36Sopenharmony_ci			.needs_epib = 1,		\
5562306a36Sopenharmony_ci			.psd_size = 64,			\
5662306a36Sopenharmony_ci			.notdpkt = tx,			\
5762306a36Sopenharmony_ci		},					\
5862306a36Sopenharmony_ci	}
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci/* PSI-L source thread IDs, used for RX (DMA_DEV_TO_MEM) */
6162306a36Sopenharmony_cistatic struct psil_ep j721s2_src_ep_map[] = {
6262306a36Sopenharmony_ci	/* PDMA_MCASP - McASP0-4 */
6362306a36Sopenharmony_ci	PSIL_PDMA_MCASP(0x4400),
6462306a36Sopenharmony_ci	PSIL_PDMA_MCASP(0x4401),
6562306a36Sopenharmony_ci	PSIL_PDMA_MCASP(0x4402),
6662306a36Sopenharmony_ci	PSIL_PDMA_MCASP(0x4403),
6762306a36Sopenharmony_ci	PSIL_PDMA_MCASP(0x4404),
6862306a36Sopenharmony_ci	/* PDMA_SPI_G0 - SPI0-3 */
6962306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4600),
7062306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4601),
7162306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4602),
7262306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4603),
7362306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4604),
7462306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4605),
7562306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4606),
7662306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4607),
7762306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4608),
7862306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4609),
7962306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460a),
8062306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460b),
8162306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460c),
8262306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460d),
8362306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460e),
8462306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x460f),
8562306a36Sopenharmony_ci	/* PDMA_SPI_G1 - SPI4-7 */
8662306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4610),
8762306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4611),
8862306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4612),
8962306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4613),
9062306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4614),
9162306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4615),
9262306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4616),
9362306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4617),
9462306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4618),
9562306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4619),
9662306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461a),
9762306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461b),
9862306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461c),
9962306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461d),
10062306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461e),
10162306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x461f),
10262306a36Sopenharmony_ci	/* MAIN_CPSW2G */
10362306a36Sopenharmony_ci	PSIL_ETHERNET(0x4640),
10462306a36Sopenharmony_ci	/* PDMA_USART_G0 - UART0-1 */
10562306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4700),
10662306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4701),
10762306a36Sopenharmony_ci	/* PDMA_USART_G1 - UART2-3 */
10862306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4702),
10962306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4703),
11062306a36Sopenharmony_ci	/* PDMA_USART_G2 - UART4-9 */
11162306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4704),
11262306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4705),
11362306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4706),
11462306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4707),
11562306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4708),
11662306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x4709),
11762306a36Sopenharmony_ci	/* MAIN SA2UL */
11862306a36Sopenharmony_ci	PSIL_SA2UL(0x4a40, 0),
11962306a36Sopenharmony_ci	PSIL_SA2UL(0x4a41, 0),
12062306a36Sopenharmony_ci	PSIL_SA2UL(0x4a42, 0),
12162306a36Sopenharmony_ci	PSIL_SA2UL(0x4a43, 0),
12262306a36Sopenharmony_ci	/* CPSW0 */
12362306a36Sopenharmony_ci	PSIL_ETHERNET(0x7000),
12462306a36Sopenharmony_ci	/* MCU_PDMA0 (MCU_PDMA_MISC_G0) - SPI0 */
12562306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7100),
12662306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7101),
12762306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7102),
12862306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7103),
12962306a36Sopenharmony_ci	/* MCU_PDMA1 (MCU_PDMA_MISC_G1) - SPI1-2 */
13062306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7200),
13162306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7201),
13262306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7202),
13362306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7203),
13462306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7204),
13562306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7205),
13662306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7206),
13762306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7207),
13862306a36Sopenharmony_ci	/* MCU_PDMA2 (MCU_PDMA_MISC_G2) - UART0 */
13962306a36Sopenharmony_ci	PSIL_PDMA_XY_PKT(0x7300),
14062306a36Sopenharmony_ci	/* MCU_PDMA_ADC - ADC0-1 */
14162306a36Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7400),
14262306a36Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7401),
14362306a36Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7402),
14462306a36Sopenharmony_ci	PSIL_PDMA_XY_TR(0x7403),
14562306a36Sopenharmony_ci	/* SA2UL */
14662306a36Sopenharmony_ci	PSIL_SA2UL(0x7500, 0),
14762306a36Sopenharmony_ci	PSIL_SA2UL(0x7501, 0),
14862306a36Sopenharmony_ci	PSIL_SA2UL(0x7502, 0),
14962306a36Sopenharmony_ci	PSIL_SA2UL(0x7503, 0),
15062306a36Sopenharmony_ci};
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci/* PSI-L destination thread IDs, used for TX (DMA_MEM_TO_DEV) */
15362306a36Sopenharmony_cistatic struct psil_ep j721s2_dst_ep_map[] = {
15462306a36Sopenharmony_ci	/* MAIN SA2UL */
15562306a36Sopenharmony_ci	PSIL_SA2UL(0xca40, 1),
15662306a36Sopenharmony_ci	PSIL_SA2UL(0xca41, 1),
15762306a36Sopenharmony_ci	/* CPSW0 */
15862306a36Sopenharmony_ci	PSIL_ETHERNET(0xf000),
15962306a36Sopenharmony_ci	PSIL_ETHERNET(0xf001),
16062306a36Sopenharmony_ci	PSIL_ETHERNET(0xf002),
16162306a36Sopenharmony_ci	PSIL_ETHERNET(0xf003),
16262306a36Sopenharmony_ci	PSIL_ETHERNET(0xf004),
16362306a36Sopenharmony_ci	PSIL_ETHERNET(0xf005),
16462306a36Sopenharmony_ci	PSIL_ETHERNET(0xf006),
16562306a36Sopenharmony_ci	PSIL_ETHERNET(0xf007),
16662306a36Sopenharmony_ci	/* MAIN_CPSW2G */
16762306a36Sopenharmony_ci	PSIL_ETHERNET(0xc640),
16862306a36Sopenharmony_ci	PSIL_ETHERNET(0xc641),
16962306a36Sopenharmony_ci	PSIL_ETHERNET(0xc642),
17062306a36Sopenharmony_ci	PSIL_ETHERNET(0xc643),
17162306a36Sopenharmony_ci	PSIL_ETHERNET(0xc644),
17262306a36Sopenharmony_ci	PSIL_ETHERNET(0xc645),
17362306a36Sopenharmony_ci	PSIL_ETHERNET(0xc646),
17462306a36Sopenharmony_ci	PSIL_ETHERNET(0xc647),
17562306a36Sopenharmony_ci	/* SA2UL */
17662306a36Sopenharmony_ci	PSIL_SA2UL(0xf500, 1),
17762306a36Sopenharmony_ci	PSIL_SA2UL(0xf501, 1),
17862306a36Sopenharmony_ci};
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_cistruct psil_ep_map j721s2_ep_map = {
18162306a36Sopenharmony_ci	.name = "j721s2",
18262306a36Sopenharmony_ci	.src = j721s2_src_ep_map,
18362306a36Sopenharmony_ci	.src_count = ARRAY_SIZE(j721s2_src_ep_map),
18462306a36Sopenharmony_ci	.dst = j721s2_dst_ep_map,
18562306a36Sopenharmony_ci	.dst_count = ARRAY_SIZE(j721s2_dst_ep_map),
18662306a36Sopenharmony_ci};
187