1 /*
2  * Copyright 2014 Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #ifndef __FSL_LS102XA_STREAM_ID_H_
8 #define __FSL_LS102XA_STREAM_ID_H_
9 
10 #include <fsl_sec.h>
11 
12 #define SET_LIODN_ENTRY_1(name, idA, off, compatoff) \
13 	{ .compat = name, \
14 	  .id = { idA }, .num_ids = 1, \
15 	  .reg_offset = off + CONFIG_SYS_IMMR, \
16 	  .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \
17 	}
18 
19 #define SET_LIODN_ENTRY_2(name, idA, idB, off, compatoff) \
20 	{ .compat = name, \
21 	  .id = { idA, idB }, .num_ids = 2, \
22 	  .reg_offset = off + CONFIG_SYS_IMMR, \
23 	  .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \
24 	}
25 
26 /*
27  * handle both old and new versioned SEC properties:
28  * "fsl,secX.Y" became "fsl,sec-vX.Y" during development
29  */
30 #define SET_SEC_JR_LIODN_ENTRY(jrnum, liodnA, liodnB) \
31 	SET_LIODN_ENTRY_2("fsl,sec4.0-job-ring", liodnA, liodnB, \
32 		offsetof(ccsr_sec_t, jrliodnr[jrnum].ls) + \
33 		CONFIG_SYS_FSL_SEC_OFFSET, \
34 		CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrnum), \
35 	SET_LIODN_ENTRY_2("fsl,sec-v4.0-job-ring", liodnA, liodnB,\
36 		offsetof(ccsr_sec_t, jrliodnr[jrnum].ls) + \
37 		CONFIG_SYS_FSL_SEC_OFFSET, \
38 		CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrnum)
39 
40 /* This is a bit evil since we treat rtic param as both a string & hex value */
41 #define SET_SEC_RTIC_LIODN_ENTRY(rtic, liodnA) \
42 	SET_LIODN_ENTRY_1("fsl,sec4.0-rtic-memory", \
43 		liodnA,	\
44 		offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
45 		CONFIG_SYS_FSL_SEC_OFFSET, \
46 		CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)), \
47 	SET_LIODN_ENTRY_1("fsl,sec-v4.0-rtic-memory", \
48 		liodnA,	\
49 		offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
50 		CONFIG_SYS_FSL_SEC_OFFSET, \
51 		CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa))
52 
53 #define SET_SEC_DECO_LIODN_ENTRY(num, liodnA, liodnB) \
54 	SET_LIODN_ENTRY_2(NULL, liodnA, liodnB, \
55 		offsetof(ccsr_sec_t, decoliodnr[num].ls) + \
56 		CONFIG_SYS_FSL_SEC_OFFSET, 0)
57 
58 struct liodn_id_table {
59 	const char *compat;
60 	u32 id[2];
61 	u8 num_ids;
62 	phys_addr_t compat_offset;
63 	unsigned long reg_offset;
64 };
65 
66 struct smmu_stream_id {
67 	uint16_t offset;
68 	uint16_t stream_id;
69 	char dev_name[32];
70 };
71 
72 void ls1021x_config_caam_stream_id(struct liodn_id_table *tbl, int size);
73 void ls102xa_config_smmu_stream_id(struct smmu_stream_id *id, uint32_t num);
74 #endif
75