xref: /openbmc/u-boot/include/fsl_sec.h (revision 94e3c8c4fd7bfe395fa467973cd647551d6d98c7)
148ef0d2aSRuchika Gupta /*
248ef0d2aSRuchika Gupta  * Common internal memory map for some Freescale SoCs
348ef0d2aSRuchika Gupta  *
448ef0d2aSRuchika Gupta  * Copyright 2014 Freescale Semiconductor, Inc.
548ef0d2aSRuchika Gupta  *
648ef0d2aSRuchika Gupta  */
748ef0d2aSRuchika Gupta 
848ef0d2aSRuchika Gupta #ifndef __FSL_SEC_H
948ef0d2aSRuchika Gupta #define __FSL_SEC_H
1048ef0d2aSRuchika Gupta 
1148ef0d2aSRuchika Gupta #include <common.h>
1248ef0d2aSRuchika Gupta #include <asm/io.h>
1348ef0d2aSRuchika Gupta 
14028dbb8dSRuchika Gupta #ifdef CONFIG_SYS_FSL_SEC_LE
15028dbb8dSRuchika Gupta #define sec_in32(a)       in_le32(a)
16028dbb8dSRuchika Gupta #define sec_out32(a, v)   out_le32(a, v)
17028dbb8dSRuchika Gupta #define sec_in16(a)       in_le16(a)
18028dbb8dSRuchika Gupta #define sec_clrbits32     clrbits_le32
19028dbb8dSRuchika Gupta #define sec_setbits32     setbits_le32
20028dbb8dSRuchika Gupta #elif defined(CONFIG_SYS_FSL_SEC_BE)
21028dbb8dSRuchika Gupta #define sec_in32(a)       in_be32(a)
22028dbb8dSRuchika Gupta #define sec_out32(a, v)   out_be32(a, v)
23028dbb8dSRuchika Gupta #define sec_in16(a)       in_be16(a)
24028dbb8dSRuchika Gupta #define sec_clrbits32     clrbits_be32
25028dbb8dSRuchika Gupta #define sec_setbits32     setbits_be32
26028dbb8dSRuchika Gupta #else
27028dbb8dSRuchika Gupta #error Neither CONFIG_SYS_FSL_SEC_LE nor CONFIG_SYS_FSL_SEC_BE is defined
28028dbb8dSRuchika Gupta #endif
29028dbb8dSRuchika Gupta 
3048ef0d2aSRuchika Gupta /* Security Engine Block (MS = Most Sig., LS = Least Sig.) */
3148ef0d2aSRuchika Gupta #if CONFIG_SYS_FSL_SEC_COMPAT >= 4
32c5de15cbSRuchika Gupta /* RNG4 TRNG test registers */
33c5de15cbSRuchika Gupta struct rng4tst {
34c5de15cbSRuchika Gupta #define RTMCTL_PRGM 0x00010000	/* 1 -> program mode, 0 -> run mode */
35c5de15cbSRuchika Gupta 	u32 rtmctl;		/* misc. control register */
36c5de15cbSRuchika Gupta 	u32 rtscmisc;		/* statistical check misc. register */
37c5de15cbSRuchika Gupta 	u32 rtpkrrng;		/* poker range register */
38c5de15cbSRuchika Gupta #define RTSDCTL_ENT_DLY_MIN	1200
39c5de15cbSRuchika Gupta #define RTSDCTL_ENT_DLY_MAX	12800
40c5de15cbSRuchika Gupta 	union {
41c5de15cbSRuchika Gupta 		u32 rtpkrmax;	/* PRGM=1: poker max. limit register */
42c5de15cbSRuchika Gupta 		u32 rtpkrsq;	/* PRGM=0: poker square calc. result register */
43c5de15cbSRuchika Gupta 	};
44c5de15cbSRuchika Gupta #define RTSDCTL_ENT_DLY_SHIFT 16
45c5de15cbSRuchika Gupta #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
46c5de15cbSRuchika Gupta 	u32 rtsdctl;		/* seed control register */
47c5de15cbSRuchika Gupta 	union {
48c5de15cbSRuchika Gupta 		u32 rtsblim;	/* PRGM=1: sparse bit limit register */
49c5de15cbSRuchika Gupta 		u32 rttotsam;	/* PRGM=0: total samples register */
50c5de15cbSRuchika Gupta 	};
51c5de15cbSRuchika Gupta 	u32 rtfreqmin;		/* frequency count min. limit register */
52c5de15cbSRuchika Gupta 	union {
53c5de15cbSRuchika Gupta 		u32 rtfreqmax;	/* PRGM=1: freq. count max. limit register */
54c5de15cbSRuchika Gupta 		u32 rtfreqcnt;	/* PRGM=0: freq. count register */
55c5de15cbSRuchika Gupta 	};
56c5de15cbSRuchika Gupta 	u32 rsvd1[40];
57c5de15cbSRuchika Gupta #define RNG_STATE0_HANDLE_INSTANTIATED	0x00000001
58c5de15cbSRuchika Gupta 	u32 rdsta;		/*RNG DRNG Status Register*/
59c5de15cbSRuchika Gupta 	u32 rsvd2[15];
60c5de15cbSRuchika Gupta };
61c5de15cbSRuchika Gupta 
6248ef0d2aSRuchika Gupta typedef struct ccsr_sec {
6348ef0d2aSRuchika Gupta 	u32	res0;
6448ef0d2aSRuchika Gupta 	u32	mcfgr;		/* Master CFG Register */
6548ef0d2aSRuchika Gupta 	u8	res1[0x4];
6648ef0d2aSRuchika Gupta 	u32	scfgr;
6748ef0d2aSRuchika Gupta 	struct {
6848ef0d2aSRuchika Gupta 		u32	ms;	/* Job Ring LIODN Register, MS */
6948ef0d2aSRuchika Gupta 		u32	ls;	/* Job Ring LIODN Register, LS */
7048ef0d2aSRuchika Gupta 	} jrliodnr[4];
7148ef0d2aSRuchika Gupta 	u8	res2[0x2c];
7248ef0d2aSRuchika Gupta 	u32	jrstartr;	/* Job Ring Start Register */
7348ef0d2aSRuchika Gupta 	struct {
7448ef0d2aSRuchika Gupta 		u32	ms;	/* RTIC LIODN Register, MS */
7548ef0d2aSRuchika Gupta 		u32	ls;	/* RTIC LIODN Register, LS */
7648ef0d2aSRuchika Gupta 	} rticliodnr[4];
7748ef0d2aSRuchika Gupta 	u8	res3[0x1c];
7848ef0d2aSRuchika Gupta 	u32	decorr;		/* DECO Request Register */
7948ef0d2aSRuchika Gupta 	struct {
8048ef0d2aSRuchika Gupta 		u32	ms;	/* DECO LIODN Register, MS */
8148ef0d2aSRuchika Gupta 		u32	ls;	/* DECO LIODN Register, LS */
8248ef0d2aSRuchika Gupta 	} decoliodnr[8];
8348ef0d2aSRuchika Gupta 	u8	res4[0x40];
8448ef0d2aSRuchika Gupta 	u32	dar;		/* DECO Avail Register */
8548ef0d2aSRuchika Gupta 	u32	drr;		/* DECO Reset Register */
86c5de15cbSRuchika Gupta 	u8	res5[0x4d8];
87c5de15cbSRuchika Gupta 	struct rng4tst rng;	/* RNG Registers */
88c5de15cbSRuchika Gupta 	u8	res11[0x8a0];
8948ef0d2aSRuchika Gupta 	u32	crnr_ms;	/* CHA Revision Number Register, MS */
9048ef0d2aSRuchika Gupta 	u32	crnr_ls;	/* CHA Revision Number Register, LS */
9148ef0d2aSRuchika Gupta 	u32	ctpr_ms;	/* Compile Time Parameters Register, MS */
9248ef0d2aSRuchika Gupta 	u32	ctpr_ls;	/* Compile Time Parameters Register, LS */
9348ef0d2aSRuchika Gupta 	u8	res6[0x10];
9448ef0d2aSRuchika Gupta 	u32	far_ms;		/* Fault Address Register, MS */
9548ef0d2aSRuchika Gupta 	u32	far_ls;		/* Fault Address Register, LS */
9648ef0d2aSRuchika Gupta 	u32	falr;		/* Fault Address LIODN Register */
9748ef0d2aSRuchika Gupta 	u32	fadr;		/* Fault Address Detail Register */
9848ef0d2aSRuchika Gupta 	u8	res7[0x4];
9948ef0d2aSRuchika Gupta 	u32	csta;		/* CAAM Status Register */
10048ef0d2aSRuchika Gupta 	u8	res8[0x8];
10148ef0d2aSRuchika Gupta 	u32	rvid;		/* Run Time Integrity Checking Version ID Reg.*/
10248ef0d2aSRuchika Gupta 	u32	ccbvid;		/* CHA Cluster Block Version ID Register */
10348ef0d2aSRuchika Gupta 	u32	chavid_ms;	/* CHA Version ID Register, MS */
10448ef0d2aSRuchika Gupta 	u32	chavid_ls;	/* CHA Version ID Register, LS */
10548ef0d2aSRuchika Gupta 	u32	chanum_ms;	/* CHA Number Register, MS */
10648ef0d2aSRuchika Gupta 	u32	chanum_ls;	/* CHA Number Register, LS */
10748ef0d2aSRuchika Gupta 	u32	secvid_ms;	/* SEC Version ID Register, MS */
10848ef0d2aSRuchika Gupta 	u32	secvid_ls;	/* SEC Version ID Register, LS */
10948ef0d2aSRuchika Gupta 	u8	res9[0x6020];
11048ef0d2aSRuchika Gupta 	u32	qilcr_ms;	/* Queue Interface LIODN CFG Register, MS */
11148ef0d2aSRuchika Gupta 	u32	qilcr_ls;	/* Queue Interface LIODN CFG Register, LS */
11248ef0d2aSRuchika Gupta 	u8	res10[0x8fd8];
11348ef0d2aSRuchika Gupta } ccsr_sec_t;
11448ef0d2aSRuchika Gupta 
11548ef0d2aSRuchika Gupta #define SEC_CTPR_MS_AXI_LIODN		0x08000000
11648ef0d2aSRuchika Gupta #define SEC_CTPR_MS_QI			0x02000000
11748ef0d2aSRuchika Gupta #define SEC_CTPR_MS_VIRT_EN_INCL	0x00000001
11848ef0d2aSRuchika Gupta #define SEC_CTPR_MS_VIRT_EN_POR		0x00000002
11948ef0d2aSRuchika Gupta #define SEC_RVID_MA			0x0f000000
12048ef0d2aSRuchika Gupta #define SEC_CHANUM_MS_JRNUM_MASK	0xf0000000
12148ef0d2aSRuchika Gupta #define SEC_CHANUM_MS_JRNUM_SHIFT	28
12248ef0d2aSRuchika Gupta #define SEC_CHANUM_MS_DECONUM_MASK	0x0f000000
12348ef0d2aSRuchika Gupta #define SEC_CHANUM_MS_DECONUM_SHIFT	24
12448ef0d2aSRuchika Gupta #define SEC_SECVID_MS_IPID_MASK	0xffff0000
12548ef0d2aSRuchika Gupta #define SEC_SECVID_MS_IPID_SHIFT	16
12648ef0d2aSRuchika Gupta #define SEC_SECVID_MS_MAJ_REV_MASK	0x0000ff00
12748ef0d2aSRuchika Gupta #define SEC_SECVID_MS_MAJ_REV_SHIFT	8
12848ef0d2aSRuchika Gupta #define SEC_CCBVID_ERA_MASK		0xff000000
12948ef0d2aSRuchika Gupta #define SEC_CCBVID_ERA_SHIFT		24
13048ef0d2aSRuchika Gupta #define SEC_SCFGR_RDBENABLE		0x00000400
13148ef0d2aSRuchika Gupta #define SEC_SCFGR_VIRT_EN		0x00008000
13248ef0d2aSRuchika Gupta #define SEC_CHAVID_LS_RNG_SHIFT		16
13348ef0d2aSRuchika Gupta #define SEC_CHAVID_RNG_LS_MASK		0x000f0000
134b9eebfadSRuchika Gupta 
135b9eebfadSRuchika Gupta #define CONFIG_JRSTARTR_JR0		0x00000001
136b9eebfadSRuchika Gupta 
137b9eebfadSRuchika Gupta struct jr_regs {
138b9eebfadSRuchika Gupta #ifdef CONFIG_SYS_FSL_SEC_LE
139b9eebfadSRuchika Gupta 	u32 irba_l;
140b9eebfadSRuchika Gupta 	u32 irba_h;
141b9eebfadSRuchika Gupta #else
142b9eebfadSRuchika Gupta 	u32 irba_h;
143b9eebfadSRuchika Gupta 	u32 irba_l;
144b9eebfadSRuchika Gupta #endif
145b9eebfadSRuchika Gupta 	u32 rsvd1;
146b9eebfadSRuchika Gupta 	u32 irs;
147b9eebfadSRuchika Gupta 	u32 rsvd2;
148b9eebfadSRuchika Gupta 	u32 irsa;
149b9eebfadSRuchika Gupta 	u32 rsvd3;
150b9eebfadSRuchika Gupta 	u32 irja;
151b9eebfadSRuchika Gupta #ifdef CONFIG_SYS_FSL_SEC_LE
152b9eebfadSRuchika Gupta 	u32 orba_l;
153b9eebfadSRuchika Gupta 	u32 orba_h;
154b9eebfadSRuchika Gupta #else
155b9eebfadSRuchika Gupta 	u32 orba_h;
156b9eebfadSRuchika Gupta 	u32 orba_l;
157b9eebfadSRuchika Gupta #endif
158b9eebfadSRuchika Gupta 	u32 rsvd4;
159b9eebfadSRuchika Gupta 	u32 ors;
160b9eebfadSRuchika Gupta 	u32 rsvd5;
161b9eebfadSRuchika Gupta 	u32 orjr;
162b9eebfadSRuchika Gupta 	u32 rsvd6;
163b9eebfadSRuchika Gupta 	u32 orsf;
164b9eebfadSRuchika Gupta 	u32 rsvd7;
165b9eebfadSRuchika Gupta 	u32 jrsta;
166b9eebfadSRuchika Gupta 	u32 rsvd8;
167b9eebfadSRuchika Gupta 	u32 jrint;
168b9eebfadSRuchika Gupta 	u32 jrcfg0;
169b9eebfadSRuchika Gupta 	u32 jrcfg1;
170b9eebfadSRuchika Gupta 	u32 rsvd9;
171b9eebfadSRuchika Gupta 	u32 irri;
172b9eebfadSRuchika Gupta 	u32 rsvd10;
173b9eebfadSRuchika Gupta 	u32 orwi;
174b9eebfadSRuchika Gupta 	u32 rsvd11;
175b9eebfadSRuchika Gupta 	u32 jrcr;
176b9eebfadSRuchika Gupta };
177b9eebfadSRuchika Gupta 
178*94e3c8c4Sgaurav rana /*
179*94e3c8c4Sgaurav rana  * Scatter Gather Entry - Specifies the the Scatter Gather Format
180*94e3c8c4Sgaurav rana  * related information
181*94e3c8c4Sgaurav rana  */
182*94e3c8c4Sgaurav rana struct sg_entry {
183*94e3c8c4Sgaurav rana #ifdef CONFIG_SYS_FSL_SEC_LE
184*94e3c8c4Sgaurav rana 	uint32_t addr_lo;	/* Memory Address - lo */
185*94e3c8c4Sgaurav rana 	uint16_t addr_hi;	/* Memory Address of start of buffer - hi */
186*94e3c8c4Sgaurav rana 	uint16_t reserved_zero;
187*94e3c8c4Sgaurav rana #else
188*94e3c8c4Sgaurav rana 	uint16_t reserved_zero;
189*94e3c8c4Sgaurav rana 	uint16_t addr_hi;	/* Memory Address of start of buffer - hi */
190*94e3c8c4Sgaurav rana 	uint32_t addr_lo;	/* Memory Address - lo */
191*94e3c8c4Sgaurav rana #endif
192*94e3c8c4Sgaurav rana 
193*94e3c8c4Sgaurav rana 	uint32_t len_flag;	/* Length of the data in the frame */
194*94e3c8c4Sgaurav rana #define SG_ENTRY_LENGTH_MASK	0x3FFFFFFF
195*94e3c8c4Sgaurav rana #define SG_ENTRY_EXTENSION_BIT	0x80000000
196*94e3c8c4Sgaurav rana #define SG_ENTRY_FINAL_BIT	0x40000000
197*94e3c8c4Sgaurav rana 	uint32_t bpid_offset;
198*94e3c8c4Sgaurav rana #define SG_ENTRY_BPID_MASK	0x00FF0000
199*94e3c8c4Sgaurav rana #define SG_ENTRY_BPID_SHIFT	16
200*94e3c8c4Sgaurav rana #define SG_ENTRY_OFFSET_MASK	0x00001FFF
201*94e3c8c4Sgaurav rana #define SG_ENTRY_OFFSET_SHIFT	0
202*94e3c8c4Sgaurav rana };
203*94e3c8c4Sgaurav rana 
204b9eebfadSRuchika Gupta int sec_init(void);
20548ef0d2aSRuchika Gupta #endif
20648ef0d2aSRuchika Gupta 
20748ef0d2aSRuchika Gupta #endif /* __FSL_SEC_H */
208