blob: 0c3394f2a81b90b95ab907e5eb2d9c032cb848fd [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dipen Dudhat00c42942011-01-20 16:29:35 +05302/*
3 * Copyright 2010-2011 Freescale Semiconductor, Inc.
4 * Author: Dipen Dudhat <dipen.dudhat@freescale.com>
Dipen Dudhat00c42942011-01-20 16:29:35 +05305 */
6
7#include <common.h>
York Sun37562f62013-10-22 12:39:02 -07008#include <fsl_ifc.h>
Dipen Dudhat00c42942011-01-20 16:29:35 +05309
Pankit Garg92d443b2018-11-05 18:01:33 +000010struct ifc_regs ifc_cfg_default_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = {
11 {
12 "cs0",
Dipen Dudhat00c42942011-01-20 16:29:35 +053013#if defined(CONFIG_SYS_CSPR0) && defined(CONFIG_SYS_CSOR0)
Pankit Garg92d443b2018-11-05 18:01:33 +000014 CONFIG_SYS_CSPR0,
Kumar Gala7bc4f622012-08-17 08:20:25 +000015#ifdef CONFIG_SYS_CSPR0_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +000016 CONFIG_SYS_CSPR0_EXT,
17#else
18 0,
Kumar Gala7bc4f622012-08-17 08:20:25 +000019#endif
Pankit Garg92d443b2018-11-05 18:01:33 +000020#ifdef CONFIG_SYS_AMASK0
21 CONFIG_SYS_AMASK0,
22#else
23 0,
24#endif
25 CONFIG_SYS_CSOR0,
26 {
27 CONFIG_SYS_CS0_FTIM0,
28 CONFIG_SYS_CS0_FTIM1,
29 CONFIG_SYS_CS0_FTIM2,
30 CONFIG_SYS_CS0_FTIM3,
31 },
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +053032#ifdef CONFIG_SYS_CSOR0_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +000033 CONFIG_SYS_CSOR0_EXT,
34#else
35 0,
36#endif
37#ifdef CONFIG_SYS_CSPR0_FINAL
38 CONFIG_SYS_CSPR0_FINAL,
39#else
40 0,
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +053041#endif
Pankit Garg92d443b2018-11-05 18:01:33 +000042#ifdef CONFIG_SYS_AMASK0_FINAL
43 CONFIG_SYS_AMASK0_FINAL,
44#else
45 0,
Dipen Dudhat00c42942011-01-20 16:29:35 +053046#endif
Poonam Aggrwal46b86ca2011-07-07 20:36:47 +053047#endif
Pankit Garg92d443b2018-11-05 18:01:33 +000048 },
Dipen Dudhat00c42942011-01-20 16:29:35 +053049
Pankit Garg92d443b2018-11-05 18:01:33 +000050#if CONFIG_SYS_FSL_IFC_BANK_COUNT >= 2
51 {
52 "cs1",
53#if defined(CONFIG_SYS_CSPR1) && defined(CONFIG_SYS_CSOR1)
54 CONFIG_SYS_CSPR1,
Kumar Gala7bc4f622012-08-17 08:20:25 +000055#ifdef CONFIG_SYS_CSPR1_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +000056 CONFIG_SYS_CSPR1_EXT,
57#else
58 0,
Kumar Gala7bc4f622012-08-17 08:20:25 +000059#endif
Pankit Garg92d443b2018-11-05 18:01:33 +000060#ifdef CONFIG_SYS_AMASK1
61 CONFIG_SYS_AMASK1,
62#else
63 0,
64#endif
65 CONFIG_SYS_CSOR1,
66 {
67 CONFIG_SYS_CS1_FTIM0,
68 CONFIG_SYS_CS1_FTIM1,
69 CONFIG_SYS_CS1_FTIM2,
70 CONFIG_SYS_CS1_FTIM3,
71 },
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +053072#ifdef CONFIG_SYS_CSOR1_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +000073 CONFIG_SYS_CSOR1_EXT,
74#else
75 0,
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +053076#endif
Pankit Garg92d443b2018-11-05 18:01:33 +000077#ifdef CONFIG_SYS_CSPR1_FINAL
78 CONFIG_SYS_CSPR1_FINAL,
79#else
80 0,
81#endif
82#ifdef CONFIG_SYS_AMASK1_FINAL
83 CONFIG_SYS_AMASK1_FINAL,
84#else
85 0,
86#endif
87#endif
88 },
Dipen Dudhat00c42942011-01-20 16:29:35 +053089#endif
90
Pankit Garg92d443b2018-11-05 18:01:33 +000091#if CONFIG_SYS_FSL_IFC_BANK_COUNT >= 3
92 {
93 "cs2",
94#if defined(CONFIG_SYS_CSPR2) && defined(CONFIG_SYS_CSOR2)
95 CONFIG_SYS_CSPR2,
Kumar Gala7bc4f622012-08-17 08:20:25 +000096#ifdef CONFIG_SYS_CSPR2_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +000097 CONFIG_SYS_CSPR2_EXT,
98#else
99 0,
Kumar Gala7bc4f622012-08-17 08:20:25 +0000100#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000101#ifdef CONFIG_SYS_AMASK2
102 CONFIG_SYS_AMASK2,
103#else
104 0,
105#endif
106 CONFIG_SYS_CSOR2,
107 {
108 CONFIG_SYS_CS2_FTIM0,
109 CONFIG_SYS_CS2_FTIM1,
110 CONFIG_SYS_CS2_FTIM2,
111 CONFIG_SYS_CS2_FTIM3,
112 },
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530113#ifdef CONFIG_SYS_CSOR2_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000114 CONFIG_SYS_CSOR2_EXT,
115#else
116 0,
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530117#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000118#ifdef CONFIG_SYS_CSPR2_FINAL
119 CONFIG_SYS_CSPR2_FINAL,
120#else
121 0,
122#endif
123#ifdef CONFIG_SYS_AMASK2_FINAL
124 CONFIG_SYS_AMASK2_FINAL,
125#else
126 0,
127#endif
128#endif
129 },
Dipen Dudhat00c42942011-01-20 16:29:35 +0530130#endif
131
Pankit Garg92d443b2018-11-05 18:01:33 +0000132#if CONFIG_SYS_FSL_IFC_BANK_COUNT >= 4
133 {
134 "cs3",
135#if defined(CONFIG_SYS_CSPR3) && defined(CONFIG_SYS_CSOR3)
136 CONFIG_SYS_CSPR3,
Kumar Gala7bc4f622012-08-17 08:20:25 +0000137#ifdef CONFIG_SYS_CSPR3_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000138 CONFIG_SYS_CSPR3_EXT,
139#else
140 0,
141#endif
142#ifdef CONFIG_SYS_AMASK3
143 CONFIG_SYS_AMASK3,
144#else
145 0,
Kumar Gala7bc4f622012-08-17 08:20:25 +0000146#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000147 CONFIG_SYS_CSOR3,
148 {
149 CONFIG_SYS_CS3_FTIM0,
150 CONFIG_SYS_CS3_FTIM1,
151 CONFIG_SYS_CS3_FTIM2,
152 CONFIG_SYS_CS3_FTIM3,
153 },
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530154#ifdef CONFIG_SYS_CSOR3_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000155 CONFIG_SYS_CSOR3_EXT,
156#else
157 0,
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530158#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000159#ifdef CONFIG_SYS_CSPR3_FINAL
160 CONFIG_SYS_CSPR3_FINAL,
161#else
162 0,
163#endif
164#ifdef CONFIG_SYS_AMASK3_FINAL
165 CONFIG_SYS_AMASK3_FINAL,
166#else
167 0,
168#endif
169#endif
170 },
Dipen Dudhat00c42942011-01-20 16:29:35 +0530171#endif
Mingkai Hu6f024c92013-05-16 10:18:13 +0800172
Pankit Garg92d443b2018-11-05 18:01:33 +0000173#if CONFIG_SYS_FSL_IFC_BANK_COUNT >= 5
174 {
175 "cs4",
176#if defined(CONFIG_SYS_CSPR4) && defined(CONFIG_SYS_CSOR4)
177 CONFIG_SYS_CSPR4,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800178#ifdef CONFIG_SYS_CSPR4_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000179 CONFIG_SYS_CSPR4_EXT,
180#else
181 0,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800182#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000183#ifdef CONFIG_SYS_AMASK4
184 CONFIG_SYS_AMASK4,
185#else
186 0,
187#endif
188 CONFIG_SYS_CSOR4,
189 {
190 CONFIG_SYS_CS4_FTIM0,
191 CONFIG_SYS_CS4_FTIM1,
192 CONFIG_SYS_CS4_FTIM2,
193 CONFIG_SYS_CS4_FTIM3,
194 },
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530195#ifdef CONFIG_SYS_CSOR4_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000196 CONFIG_SYS_CSOR4_EXT,
197#else
198 0,
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530199#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000200#ifdef CONFIG_SYS_CSPR4_FINAL
201 CONFIG_SYS_CSPR4_FINAL,
202#else
203 0,
204#endif
205#ifdef CONFIG_SYS_AMASK4_FINAL
206 CONFIG_SYS_AMASK4_FINAL,
207#else
208 0,
209#endif
210#endif
211 },
Mingkai Hu6f024c92013-05-16 10:18:13 +0800212#endif
213
Pankit Garg92d443b2018-11-05 18:01:33 +0000214#if CONFIG_SYS_FSL_IFC_BANK_COUNT >= 6
215 {
216 "cs5",
217#if defined(CONFIG_SYS_CSPR5) && defined(CONFIG_SYS_CSOR5)
218 CONFIG_SYS_CSPR5,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800219#ifdef CONFIG_SYS_CSPR5_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000220 CONFIG_SYS_CSPR5_EXT,
221#else
222 0,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800223#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000224#ifdef CONFIG_SYS_AMASK5
225 CONFIG_SYS_AMASK5,
226#else
227 0,
228#endif
229 CONFIG_SYS_CSOR5,
230 {
231 CONFIG_SYS_CS5_FTIM0,
232 CONFIG_SYS_CS5_FTIM1,
233 CONFIG_SYS_CS5_FTIM2,
234 CONFIG_SYS_CS5_FTIM3,
235 },
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530236#ifdef CONFIG_SYS_CSOR5_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000237 CONFIG_SYS_CSOR5_EXT,
238#else
239 0,
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530240#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000241#ifdef CONFIG_SYS_CSPR5_FINAL
242 CONFIG_SYS_CSPR5_FINAL,
243#else
244 0,
245#endif
246#ifdef CONFIG_SYS_AMASK5_FINAL
247 CONFIG_SYS_AMASK5_FINAL,
248#else
249 0,
250#endif
251#endif
252 },
Mingkai Hu6f024c92013-05-16 10:18:13 +0800253#endif
254
Pankit Garg92d443b2018-11-05 18:01:33 +0000255#if CONFIG_SYS_FSL_IFC_BANK_COUNT >= 7
256 {
257 "cs6",
258#if defined(CONFIG_SYS_CSPR6) && defined(CONFIG_SYS_CSOR6)
259 CONFIG_SYS_CSPR6,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800260#ifdef CONFIG_SYS_CSPR6_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000261 CONFIG_SYS_CSPR6_EXT,
262#else
263 0,
264#endif
265#ifdef CONFIG_SYS_AMASK6
266 CONFIG_SYS_AMASK6,
267#else
268 0,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800269#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000270 CONFIG_SYS_CSOR6,
271 {
272 CONFIG_SYS_CS6_FTIM0,
273 CONFIG_SYS_CS6_FTIM1,
274 CONFIG_SYS_CS6_FTIM2,
275 CONFIG_SYS_CS6_FTIM3,
276 },
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530277#ifdef CONFIG_SYS_CSOR6_EXT
Pankit Garg92d443b2018-11-05 18:01:33 +0000278 CONFIG_SYS_CSOR6_EXT,
279#else
280 0,
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530281#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000282#ifdef CONFIG_SYS_CSPR6_FINAL
283 CONFIG_SYS_CSPR6_FINAL,
284#else
285 0,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800286#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000287#ifdef CONFIG_SYS_AMASK6_FINAL
288 CONFIG_SYS_AMASK6_FINAL,
289#else
290 0,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800291#endif
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530292#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000293 },
Mingkai Hu6f024c92013-05-16 10:18:13 +0800294#endif
York Sund377b612014-03-19 13:52:34 -0700295
Pankit Garg92d443b2018-11-05 18:01:33 +0000296#if CONFIG_SYS_FSL_IFC_BANK_COUNT >= 8
297 {
298 "cs7",
299#if defined(CONFIG_SYS_CSPR7) && defined(CONFIG_SYS_CSOR7)
300 CONFIG_SYS_CSPR7,
301#ifdef CONFIG_SYS_CSPR7_EXT
302 CONFIG_SYS_CSPR7_EXT,
303#else
304 0,
York Sund377b612014-03-19 13:52:34 -0700305#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000306#ifdef CONFIG_SYS_AMASK7
307 CONFIG_SYS_AMASK7,
308#else
309 0,
Scott Wood8e728cd2015-03-24 13:25:02 -0700310#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000311 CONFIG_SYS_CSOR7,
312#ifdef CONFIG_SYS_CSOR7_EXT
313 CONFIG_SYS_CSOR7_EXT,
314#else
315 0,
Prabhakar Kushwaha1c56fb22015-03-19 09:20:48 -0700316#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000317 {
318 CONFIG_SYS_CS7_FTIM0,
319 CONFIG_SYS_CS7_FTIM1,
320 CONFIG_SYS_CS7_FTIM2,
321 CONFIG_SYS_CS7_FTIM3,
322 },
323#ifdef CONFIG_SYS_CSPR7_FINAL
324 CONFIG_SYS_CSPR7_FINAL,
325#else
326 0,
Scott Wood8e728cd2015-03-24 13:25:02 -0700327#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000328#ifdef CONFIG_SYS_AMASK7_FINAL
329 CONFIG_SYS_AMASK7_FINAL,
330#else
331 0,
Scott Wood8e728cd2015-03-24 13:25:02 -0700332#endif
Prabhakar Kushwaha1c56fb22015-03-19 09:20:48 -0700333#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000334 },
Scott Wood8e728cd2015-03-24 13:25:02 -0700335#endif
Pankit Garg92d443b2018-11-05 18:01:33 +0000336};
337
338__weak void ifc_cfg_boot_info(struct ifc_regs_info *regs_info)
339{
340 regs_info->regs = ifc_cfg_default_boot;
341 regs_info->cs_size = CONFIG_SYS_FSL_IFC_BANK_COUNT;
342}
343
344void print_ifc_regs(void)
345{
346 int i, j;
347
348 printf("IFC Controller Registers\n");
349 for (i = 0; i < CONFIG_SYS_FSL_IFC_BANK_COUNT; i++) {
350 printf("CSPR%d:0x%08X\tAMASK%d:0x%08X\tCSOR%d:0x%08X\n",
351 i, get_ifc_cspr(i), i, get_ifc_amask(i),
352 i, get_ifc_csor(i));
353 for (j = 0; j < 4; j++)
354 printf("IFC_FTIM%d:0x%08X\n", j, get_ifc_ftim(i, j));
355 }
356}
357
358void init_early_memctl_regs(void)
359{
360 int i, j;
361 struct ifc_regs *regs;
362 struct ifc_regs_info regs_info = {0};
363
364 ifc_cfg_boot_info(&regs_info);
365 regs = regs_info.regs;
366
367 for (i = 0 ; i < regs_info.cs_size; i++) {
368 if (regs[i].pr && (regs[i].pr & CSPR_V)) {
369 /* skip setting cspr/csor_ext in below condition */
370 if (!(CONFIG_IS_ENABLED(A003399_NOR_WORKAROUND) &&
371 i == 0 &&
372 ((regs[0].pr & CSPR_MSEL) == CSPR_MSEL_NOR))) {
373 if (regs[i].pr_ext)
374 set_ifc_cspr_ext(i, regs[i].pr_ext);
375 if (regs[i].or_ext)
376 set_ifc_csor_ext(i, regs[i].or_ext);
377 }
378
379 for (j = 0; j < ARRAY_SIZE(regs->ftim); j++)
380 set_ifc_ftim(i, j, regs[i].ftim[j]);
381
382 set_ifc_csor(i, regs[i].or);
383 set_ifc_amask(i, regs[i].amask);
384 set_ifc_cspr(i, regs[i].pr);
385 }
386 }
387}
388
389void init_final_memctl_regs(void)
390{
391 int i;
392 struct ifc_regs *regs;
393 struct ifc_regs_info regs_info;
394
395 ifc_cfg_boot_info(&regs_info);
396 regs = regs_info.regs;
397
398 for (i = 0 ; i < regs_info.cs_size && i < ARRAY_SIZE(regs->ftim); i++) {
399 if (!(regs[i].pr_final & CSPR_V))
400 continue;
401 if (regs[i].pr_final)
402 set_ifc_cspr(i, regs[i].pr_final);
403 if (regs[i].amask_final)
404 set_ifc_amask(i, (i == 1) ? regs[i].amask_final :
405 regs[i].amask);
406 }
York Sund377b612014-03-19 13:52:34 -0700407}