1 /*
2  * Copyright 2014 Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #ifndef __ASM_ARCH_LS102XA_IMMAP_H_
8 #define __ASM_ARCH_LS102XA_IMMAP_H_
9 
10 #define SVR_MAJ(svr)		(((svr) >>  4) & 0xf)
11 #define SVR_MIN(svr)		(((svr) >>  0) & 0xf)
12 #define SVR_SOC_VER(svr)	(((svr) >> 8) & 0x7ff)
13 #define IS_E_PROCESSOR(svr)	(svr & 0x80000)
14 
15 #define SOC_VER_SLS1020		0x00
16 #define SOC_VER_LS1020		0x10
17 #define SOC_VER_LS1021		0x11
18 #define SOC_VER_LS1022		0x12
19 
20 #define SOC_MAJOR_VER_1_0	0x1
21 #define SOC_MAJOR_VER_2_0	0x2
22 
23 #define CCSR_BRR_OFFSET		0xe4
24 #define CCSR_SCRATCHRW1_OFFSET	0x200
25 
26 #define RCWSR0_SYS_PLL_RAT_SHIFT	25
27 #define RCWSR0_SYS_PLL_RAT_MASK		0x1f
28 #define RCWSR0_MEM_PLL_RAT_SHIFT	16
29 #define RCWSR0_MEM_PLL_RAT_MASK		0x3f
30 
31 #define RCWSR4_SRDS1_PRTCL_SHIFT	24
32 #define RCWSR4_SRDS1_PRTCL_MASK		0xff000000
33 
34 #define TIMER_COMP_VAL			0xffffffff
35 #define ARCH_TIMER_CTRL_ENABLE		(1 << 0)
36 #define SYS_COUNTER_CTRL_ENABLE		(1 << 24)
37 
38 #define DCFG_CCSR_PORSR1_RCW_MASK	0xff800000
39 #define DCFG_CCSR_PORSR1_RCW_SRC_I2C	0x24800000
40 
41 #define DCFG_DCSR_PORCR1		0
42 
43 /*
44  * Define default values for some CCSR macros to make header files cleaner
45  *
46  * To completely disable CCSR relocation in a board header file, define
47  * CONFIG_SYS_CCSR_DO_NOT_RELOCATE.  This will force CONFIG_SYS_CCSRBAR_PHYS
48  * to a value that is the same as CONFIG_SYS_CCSRBAR.
49  */
50 
51 #ifdef CONFIG_SYS_CCSRBAR_PHYS
52 #error "Do not define CONFIG_SYS_CCSRBAR_PHYS directly."
53 #endif
54 
55 #ifdef CONFIG_SYS_CCSR_DO_NOT_RELOCATE
56 #undef CONFIG_SYS_CCSRBAR_PHYS_HIGH
57 #undef CONFIG_SYS_CCSRBAR_PHYS_LOW
58 #define CONFIG_SYS_CCSRBAR_PHYS_HIGH	0
59 #endif
60 
61 #ifndef CONFIG_SYS_CCSRBAR
62 #define CONFIG_SYS_CCSRBAR		CONFIG_SYS_IMMR
63 #endif
64 
65 #ifndef CONFIG_SYS_CCSRBAR_PHYS_HIGH
66 #ifdef CONFIG_PHYS_64BIT
67 #define CONFIG_SYS_CCSRBAR_PHYS_HIGH	0xf
68 #else
69 #define CONFIG_SYS_CCSRBAR_PHYS_HIGH	0
70 #endif
71 #endif
72 
73 #ifndef CONFIG_SYS_CCSRBAR_PHYS_LOW
74 #define CONFIG_SYS_CCSRBAR_PHYS_LOW	CONFIG_SYS_IMMR
75 #endif
76 
77 #define CONFIG_SYS_CCSRBAR_PHYS ((CONFIG_SYS_CCSRBAR_PHYS_HIGH * 1ull) << 32 | \
78 				 CONFIG_SYS_CCSRBAR_PHYS_LOW)
79 
80 struct sys_info {
81 	unsigned long freq_processor[CONFIG_MAX_CPUS];
82 	unsigned long freq_systembus;
83 	unsigned long freq_ddrbus;
84 	unsigned long freq_localbus;
85 };
86 
87 /* Device Configuration and Pin Control */
88 struct ccsr_gur {
89 	u32     porsr1;         /* POR status 1 */
90 	u32     porsr2;         /* POR status 2 */
91 	u8      res_008[0x20-0x8];
92 	u32     gpporcr1;       /* General-purpose POR configuration */
93 	u32	gpporcr2;
94 	u32     dcfg_fusesr;    /* Fuse status register */
95 	u8      res_02c[0x70-0x2c];
96 	u32     devdisr;        /* Device disable control */
97 	u32     devdisr2;       /* Device disable control 2 */
98 	u32     devdisr3;       /* Device disable control 3 */
99 	u32     devdisr4;       /* Device disable control 4 */
100 	u32     devdisr5;       /* Device disable control 5 */
101 	u8      res_084[0x94-0x84];
102 	u32     coredisru;      /* uppper portion for support of 64 cores */
103 	u32     coredisrl;      /* lower portion for support of 64 cores */
104 	u8      res_09c[0xa4-0x9c];
105 	u32     svr;            /* System version */
106 	u8	res_0a8[0xb0-0xa8];
107 	u32	rstcr;		/* Reset control */
108 	u32	rstrqpblsr;	/* Reset request preboot loader status */
109 	u8	res_0b8[0xc0-0xb8];
110 	u32	rstrqmr1;	/* Reset request mask */
111 	u8	res_0c4[0xc8-0xc4];
112 	u32	rstrqsr1;	/* Reset request status */
113 	u8	res_0cc[0xd4-0xcc];
114 	u32	rstrqwdtmrl;	/* Reset request WDT mask */
115 	u8	res_0d8[0xdc-0xd8];
116 	u32	rstrqwdtsrl;	/* Reset request WDT status */
117 	u8	res_0e0[0xe4-0xe0];
118 	u32	brrl;		/* Boot release */
119 	u8      res_0e8[0x100-0xe8];
120 	u32     rcwsr[16];      /* Reset control word status */
121 	u8      res_140[0x200-0x140];
122 	u32     scratchrw[4];  /* Scratch Read/Write */
123 	u8      res_210[0x300-0x210];
124 	u32     scratchw1r[4];  /* Scratch Read (Write once) */
125 	u8      res_310[0x400-0x310];
126 	u32	crstsr;
127 	u8      res_404[0x550-0x404];
128 	u32	sataliodnr;
129 	u8	res_554[0x604-0x554];
130 	u32	pamubypenr;
131 	u32	dmacr1;
132 	u8      res_60c[0x740-0x60c];   /* add more registers when needed */
133 	u32     tp_ityp[64];    /* Topology Initiator Type Register */
134 	struct {
135 		u32     upper;
136 		u32     lower;
137 	} tp_cluster[1];        /* Core Cluster n Topology Register */
138 	u8	res_848[0xe60-0x848];
139 	u32	ddrclkdr;
140 	u8	res_e60[0xe68-0xe64];
141 	u32	ifcclkdr;
142 	u8	res_e68[0xe80-0xe6c];
143 	u32	sdhcpcr;
144 };
145 
146 #define SCFG_ETSECDMAMCR_LE_BD_FR	0xf8001a0f
147 #define SCFG_ETSECCMCR_GE2_CLK125	0x04000000
148 #define SCFG_ETSECCMCR_GE0_CLK125	0x00000000
149 #define SCFG_ETSECCMCR_GE1_CLK125	0x08000000
150 #define SCFG_PIXCLKCR_PXCKEN		0x80000000
151 #define SCFG_QSPI_CLKSEL		0xc0100000
152 #define SCFG_ENDIANCR_LE		0x80000000
153 
154 /* Supplemental Configuration Unit */
155 struct ccsr_scfg {
156 	u32 dpslpcr;
157 	u32 resv0[2];
158 	u32 etsecclkdpslpcr;
159 	u32 resv1[5];
160 	u32 fuseovrdcr;
161 	u32 pixclkcr;
162 	u32 resv2[5];
163 	u32 spimsicr;
164 	u32 resv3[6];
165 	u32 pex1pmwrcr;
166 	u32 pex1pmrdsr;
167 	u32 resv4[3];
168 	u32 usb3prm1cr;
169 	u32 usb4prm2cr;
170 	u32 pex1rdmsgpldlsbsr;
171 	u32 pex1rdmsgpldmsbsr;
172 	u32 pex2rdmsgpldlsbsr;
173 	u32 pex2rdmsgpldmsbsr;
174 	u32 pex1rdmmsgrqsr;
175 	u32 pex2rdmmsgrqsr;
176 	u32 spimsiclrcr;
177 	u32 pexmscportsr[2];
178 	u32 pex2pmwrcr;
179 	u32 resv5[24];
180 	u32 mac1_streamid;
181 	u32 mac2_streamid;
182 	u32 mac3_streamid;
183 	u32 pex1_streamid;
184 	u32 pex2_streamid;
185 	u32 dma_streamid;
186 	u32 sata_streamid;
187 	u32 usb3_streamid;
188 	u32 qe_streamid;
189 	u32 sdhc_streamid;
190 	u32 adma_streamid;
191 	u32 letechsftrstcr;
192 	u32 core0_sft_rst;
193 	u32 core1_sft_rst;
194 	u32 resv6[1];
195 	u32 usb_hi_addr;
196 	u32 etsecclkadjcr;
197 	u32 sai_clk;
198 	u32 resv7[1];
199 	u32 dcu_streamid;
200 	u32 usb2_streamid;
201 	u32 ftm_reset;
202 	u32 altcbar;
203 	u32 qspi_cfg;
204 	u32 pmcintecr;
205 	u32 pmcintlecr;
206 	u32 pmcintsr;
207 	u32 qos1;
208 	u32 qos2;
209 	u32 qos3;
210 	u32 cci_cfg;
211 	u32 endiancr;
212 	u32 etsecdmamcr;
213 	u32 usb3prm3cr;
214 	u32 resv9[1];
215 	u32 debug_streamid;
216 	u32 resv10[5];
217 	u32 snpcnfgcr;
218 	u32 resv11[1];
219 	u32 intpcr;
220 	u32 resv12[20];
221 	u32 scfgrevcr;
222 	u32 coresrencr;
223 	u32 pex2pmrdsr;
224 	u32 ddrc1cr;
225 	u32 ddrc2cr;
226 	u32 ddrc3cr;
227 	u32 ddrc4cr;
228 	u32 ddrgcr;
229 	u32 resv13[120];
230 	u32 qeioclkcr;
231 	u32 etsecmcr;
232 	u32 sdhciovserlcr;
233 	u32 resv14[61];
234 	u32 sparecr[8];
235 };
236 
237 /* Clocking */
238 struct ccsr_clk {
239 	struct {
240 		u32 clkcncsr;	/* core cluster n clock control status */
241 		u8  res_004[0x1c];
242 	} clkcsr[2];
243 	u8	res_040[0x7c0]; /* 0x100 */
244 	struct {
245 		u32 pllcngsr;
246 		u8 res_804[0x1c];
247 	} pllcgsr[2];
248 	u8	res_840[0x1c0];
249 	u32	clkpcsr;	/* 0xa00 Platform clock domain control/status */
250 	u8	res_a04[0x1fc];
251 	u32	pllpgsr;	/* 0xc00 Platform PLL General Status */
252 	u8	res_c04[0x1c];
253 	u32	plldgsr;	/* 0xc20 DDR PLL General Status */
254 	u8	res_c24[0x3dc];
255 };
256 
257 /* System Counter */
258 struct sctr_regs {
259 	u32 cntcr;
260 	u32 cntsr;
261 	u32 cntcv1;
262 	u32 cntcv2;
263 	u32 resv1[4];
264 	u32 cntfid0;
265 	u32 cntfid1;
266 	u32 resv2[1002];
267 	u32 counterid[12];
268 };
269 
270 #define MAX_SERDES			1
271 #define SRDS_MAX_LANES			4
272 #define SRDS_MAX_BANK			2
273 
274 #define SRDS_RSTCTL_RST			0x80000000
275 #define SRDS_RSTCTL_RSTDONE		0x40000000
276 #define SRDS_RSTCTL_RSTERR		0x20000000
277 #define SRDS_RSTCTL_SWRST		0x10000000
278 #define SRDS_RSTCTL_SDEN		0x00000020
279 #define SRDS_RSTCTL_SDRST_B		0x00000040
280 #define SRDS_RSTCTL_PLLRST_B		0x00000080
281 #define SRDS_PLLCR0_POFF		0x80000000
282 #define SRDS_PLLCR0_RFCK_SEL_MASK	0x70000000
283 #define SRDS_PLLCR0_RFCK_SEL_100	0x00000000
284 #define SRDS_PLLCR0_RFCK_SEL_125	0x10000000
285 #define SRDS_PLLCR0_RFCK_SEL_156_25	0x20000000
286 #define SRDS_PLLCR0_RFCK_SEL_150	0x30000000
287 #define SRDS_PLLCR0_RFCK_SEL_161_13	0x40000000
288 #define SRDS_PLLCR0_RFCK_SEL_122_88	0x50000000
289 #define SRDS_PLLCR0_PLL_LCK		0x00800000
290 #define SRDS_PLLCR0_FRATE_SEL_MASK	0x000f0000
291 #define SRDS_PLLCR0_FRATE_SEL_5		0x00000000
292 #define SRDS_PLLCR0_FRATE_SEL_3_75	0x00050000
293 #define SRDS_PLLCR0_FRATE_SEL_5_15	0x00060000
294 #define SRDS_PLLCR0_FRATE_SEL_4		0x00070000
295 #define SRDS_PLLCR0_FRATE_SEL_3_12	0x00090000
296 #define SRDS_PLLCR0_FRATE_SEL_3		0x000a0000
297 #define SRDS_PLLCR1_PLL_BWSEL		0x08000000
298 
299 struct ccsr_serdes {
300 	struct {
301 		u32	rstctl;	/* Reset Control Register */
302 
303 		u32	pllcr0; /* PLL Control Register 0 */
304 
305 		u32	pllcr1; /* PLL Control Register 1 */
306 		u32	res_0c;	/* 0x00c */
307 		u32	pllcr3;
308 		u32	pllcr4;
309 		u8	res_18[0x20-0x18];
310 	} bank[2];
311 	u8	res_40[0x90-0x40];
312 	u32	srdstcalcr;	/* 0x90 TX Calibration Control */
313 	u8	res_94[0xa0-0x94];
314 	u32	srdsrcalcr;	/* 0xa0 RX Calibration Control */
315 	u8	res_a4[0xb0-0xa4];
316 	u32	srdsgr0;	/* 0xb0 General Register 0 */
317 	u8	res_b4[0xe0-0xb4];
318 	u32	srdspccr0;	/* 0xe0 Protocol Converter Config 0 */
319 	u32	srdspccr1;	/* 0xe4 Protocol Converter Config 1 */
320 	u32	srdspccr2;	/* 0xe8 Protocol Converter Config 2 */
321 	u32	srdspccr3;	/* 0xec Protocol Converter Config 3 */
322 	u32	srdspccr4;	/* 0xf0 Protocol Converter Config 4 */
323 	u8	res_f4[0x100-0xf4];
324 	struct {
325 		u32	lnpssr;	/* 0x100, 0x120, ..., 0x1e0 */
326 		u8	res_104[0x120-0x104];
327 	} srdslnpssr[4];
328 	u8	res_180[0x300-0x180];
329 	u32	srdspexeqcr;
330 	u32	srdspexeqpcr[11];
331 	u8	res_330[0x400-0x330];
332 	u32	srdspexapcr;
333 	u8	res_404[0x440-0x404];
334 	u32	srdspexbpcr;
335 	u8	res_444[0x800-0x444];
336 	struct {
337 		u32	gcr0;	/* 0x800 General Control Register 0 */
338 		u32	gcr1;	/* 0x804 General Control Register 1 */
339 		u32	gcr2;	/* 0x808 General Control Register 2 */
340 		u32	sscr0;
341 		u32	recr0;	/* 0x810 Receive Equalization Control */
342 		u32	recr1;
343 		u32	tecr0;	/* 0x818 Transmit Equalization Control */
344 		u32	sscr1;
345 		u32	ttlcr0;	/* 0x820 Transition Tracking Loop Ctrl 0 */
346 		u8	res_824[0x83c-0x824];
347 		u32	tcsr3;
348 	} lane[4];	/* Lane A, B, C, D, E, F, G, H */
349 	u8	res_a00[0x1000-0xa00];	/* from 0xa00 to 0xfff */
350 };
351 
352 #define CCI400_CTRLORD_TERM_BARRIER	0x00000008
353 #define CCI400_CTRLORD_EN_BARRIER	0
354 #define CCI400_SHAORD_NON_SHAREABLE	0x00000002
355 #define CCI400_DVM_MESSAGE_REQ_EN	0x00000002
356 #define CCI400_SNOOP_REQ_EN		0x00000001
357 
358 /* CCI-400 registers */
359 struct ccsr_cci400 {
360 	u32 ctrl_ord;			/* Control Override */
361 	u32 spec_ctrl;			/* Speculation Control */
362 	u32 secure_access;		/* Secure Access */
363 	u32 status;			/* Status */
364 	u32 impr_err;			/* Imprecise Error */
365 	u8 res_14[0x100 - 0x14];
366 	u32 pmcr;			/* Performance Monitor Control */
367 	u8 res_104[0xfd0 - 0x104];
368 	u32 pid[8];			/* Peripheral ID */
369 	u32 cid[4];			/* Component ID */
370 	struct {
371 		u32 snoop_ctrl;		/* Snoop Control */
372 		u32 sha_ord;		/* Shareable Override */
373 		u8 res_1008[0x1100 - 0x1008];
374 		u32 rc_qos_ord;		/* read channel QoS Value Override */
375 		u32 wc_qos_ord;		/* read channel QoS Value Override */
376 		u8 res_1108[0x110c - 0x1108];
377 		u32 qos_ctrl;		/* QoS Control */
378 		u32 max_ot;		/* Max OT */
379 		u8 res_1114[0x1130 - 0x1114];
380 		u32 target_lat;		/* Target Latency */
381 		u32 latency_regu;	/* Latency Regulation */
382 		u32 qos_range;		/* QoS Range */
383 		u8 res_113c[0x2000 - 0x113c];
384 	} slave[5];			/* Slave Interface */
385 	u8 res_6000[0x9004 - 0x6000];
386 	u32 cycle_counter;		/* Cycle counter */
387 	u32 count_ctrl;			/* Count Control */
388 	u32 overflow_status;		/* Overflow Flag Status */
389 	u8 res_9010[0xa000 - 0x9010];
390 	struct {
391 		u32 event_select;	/* Event Select */
392 		u32 event_count;	/* Event Count */
393 		u32 counter_ctrl;	/* Counter Control */
394 		u32 overflow_status;	/* Overflow Flag Status */
395 		u8 res_a010[0xb000 - 0xa010];
396 	} pcounter[4];			/* Performance Counter */
397 	u8 res_e004[0x10000 - 0xe004];
398 };
399 
400 #endif	/* __ASM_ARCH_LS102XA_IMMAP_H_ */
401