blob: b0aa72ed6e0213a28db99b4feae0d0322be892e4 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kumar Galaec2b74f2008-01-17 16:48:33 -06002/*
Ed Swarthoute81241a2011-03-03 18:28:14 -06003 * Copyright 2008-2011 Freescale Semiconductor, Inc.
Kumar Galaec2b74f2008-01-17 16:48:33 -06004 */
5
6#include <common.h>
7#include <asm/processor.h>
8#include <ioports.h>
Kumar Galadd6c9102008-03-26 08:53:53 -05009#include <lmb.h>
Kumar Galaec2b74f2008-01-17 16:48:33 -060010#include <asm/io.h>
Kumar Galac7259082009-09-03 08:41:31 -050011#include <asm/mmu.h>
Kumar Gala39a7e7f2009-09-17 01:44:39 -050012#include <asm/fsl_law.h>
York Sun5614e712013-09-30 09:22:09 -070013#include <fsl_ddr_sdram.h>
Kumar Galaec2b74f2008-01-17 16:48:33 -060014#include "mp.h"
15
16DECLARE_GLOBAL_DATA_PTR;
York Suneb539412012-10-08 07:44:25 +000017u32 fsl_ddr_get_intl3r(void);
Kumar Galaec2b74f2008-01-17 16:48:33 -060018
York Sunffd06e02012-10-08 07:44:30 +000019extern u32 __spin_table[];
20
Kumar Galaec2b74f2008-01-17 16:48:33 -060021u32 get_my_id()
22{
23 return mfspr(SPRN_PIR);
24}
25
Aaron Sierra9d64c6b2010-09-30 12:22:16 -050026/*
27 * Determine if U-Boot should keep secondary cores in reset, or let them out
28 * of reset and hold them in a spinloop
29 */
30int hold_cores_in_reset(int verbose)
31{
Robert P. J. Day62a3b7d2016-07-15 13:44:45 -040032 /* Default to no, overridden by 'y', 'yes', 'Y', 'Yes', or '1' */
Simon Glassbfebc8c2017-08-03 12:22:13 -060033 if (env_get_yesno("mp_holdoff") == 1) {
Aaron Sierra9d64c6b2010-09-30 12:22:16 -050034 if (verbose) {
35 puts("Secondary cores are being held in reset.\n");
36 puts("See 'mp_holdoff' environment variable\n");
37 }
38
39 return 1;
40 }
41
42 return 0;
43}
44
Michal Simek20b016a2018-06-13 08:56:31 +020045int cpu_reset(u32 nr)
Kumar Galaec2b74f2008-01-17 16:48:33 -060046{
Kim Phillips680c6132010-08-09 18:39:57 -050047 volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
Kumar Galaec2b74f2008-01-17 16:48:33 -060048 out_be32(&pic->pir, 1 << nr);
Kumar Galac840d262009-03-31 23:11:05 -050049 /* the dummy read works around an errata on early 85xx MP PICs */
Kumar Galaec2b74f2008-01-17 16:48:33 -060050 (void)in_be32(&pic->pir);
51 out_be32(&pic->pir, 0x0);
52
53 return 0;
54}
55
Michal Simek20b016a2018-06-13 08:56:31 +020056int cpu_status(u32 nr)
Kumar Galaec2b74f2008-01-17 16:48:33 -060057{
58 u32 *table, id = get_my_id();
59
Aaron Sierra9d64c6b2010-09-30 12:22:16 -050060 if (hold_cores_in_reset(1))
61 return 0;
62
Kumar Galaec2b74f2008-01-17 16:48:33 -060063 if (nr == id) {
York Sunffd06e02012-10-08 07:44:30 +000064 table = (u32 *)&__spin_table;
Kumar Gala348753d2008-07-14 14:03:02 -050065 printf("table base @ 0x%p\n", table);
York Sun0c9ab432013-03-25 07:40:00 +000066 } else if (is_core_disabled(nr)) {
67 puts("Disabled\n");
Kumar Galaec2b74f2008-01-17 16:48:33 -060068 } else {
York Sunffd06e02012-10-08 07:44:30 +000069 table = (u32 *)&__spin_table + nr * NUM_BOOT_ENTRY;
Kumar Galaec2b74f2008-01-17 16:48:33 -060070 printf("Running on cpu %d\n", id);
71 printf("\n");
Kumar Gala348753d2008-07-14 14:03:02 -050072 printf("table @ 0x%p\n", table);
Kumar Gala79679d82008-03-26 08:34:25 -050073 printf(" addr - 0x%08x\n", table[BOOT_ENTRY_ADDR_LOWER]);
Kumar Gala79679d82008-03-26 08:34:25 -050074 printf(" r3 - 0x%08x\n", table[BOOT_ENTRY_R3_LOWER]);
York Sun3f0997b2012-10-08 07:44:29 +000075 printf(" pir - 0x%08x\n", table[BOOT_ENTRY_PIR]);
Kumar Galaec2b74f2008-01-17 16:48:33 -060076 }
77
78 return 0;
79}
80
Kumar Galaa9c3ac72010-01-12 12:56:05 -060081#ifdef CONFIG_FSL_CORENET
Michal Simek20b016a2018-06-13 08:56:31 +020082int cpu_disable(u32 nr)
Kumar Gala4194b362010-01-12 11:42:43 -060083{
Kumar Galaa9c3ac72010-01-12 12:56:05 -060084 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
85
86 setbits_be32(&gur->coredisrl, 1 << nr);
87
88 return 0;
Kumar Gala4194b362010-01-12 11:42:43 -060089}
Kumar Gala8f3a7fa2010-06-09 22:33:53 -050090
91int is_core_disabled(int nr) {
92 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
93 u32 coredisrl = in_be32(&gur->coredisrl);
94
95 return (coredisrl & (1 << nr));
96}
Kumar Galaa9c3ac72010-01-12 12:56:05 -060097#else
Michal Simek20b016a2018-06-13 08:56:31 +020098int cpu_disable(u32 nr)
Kumar Galaa9c3ac72010-01-12 12:56:05 -060099{
100 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
101
102 switch (nr) {
103 case 0:
104 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_CPU0);
105 break;
106 case 1:
107 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_CPU1);
108 break;
109 default:
110 printf("Invalid cpu number for disable %d\n", nr);
111 return 1;
112 }
113
114 return 0;
115}
Kumar Gala8f3a7fa2010-06-09 22:33:53 -0500116
117int is_core_disabled(int nr) {
118 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
119 u32 devdisr = in_be32(&gur->devdisr);
120
121 switch (nr) {
122 case 0:
123 return (devdisr & MPC85xx_DEVDISR_CPU0);
124 case 1:
125 return (devdisr & MPC85xx_DEVDISR_CPU1);
126 default:
127 printf("Invalid cpu number for disable %d\n", nr);
128 }
129
130 return 0;
131}
Kumar Galaa9c3ac72010-01-12 12:56:05 -0600132#endif
Kumar Gala4194b362010-01-12 11:42:43 -0600133
Kumar Gala79679d82008-03-26 08:34:25 -0500134static u8 boot_entry_map[4] = {
135 0,
136 BOOT_ENTRY_PIR,
137 BOOT_ENTRY_R3_LOWER,
Kumar Gala79679d82008-03-26 08:34:25 -0500138};
139
Michal Simek20b016a2018-06-13 08:56:31 +0200140int cpu_release(u32 nr, int argc, char * const argv[])
Kumar Galaec2b74f2008-01-17 16:48:33 -0600141{
York Sunffd06e02012-10-08 07:44:30 +0000142 u32 i, val, *table = (u32 *)&__spin_table + nr * NUM_BOOT_ENTRY;
Kumar Gala79679d82008-03-26 08:34:25 -0500143 u64 boot_addr;
Kumar Galaec2b74f2008-01-17 16:48:33 -0600144
Aaron Sierra9d64c6b2010-09-30 12:22:16 -0500145 if (hold_cores_in_reset(1))
146 return 0;
147
Kumar Galaec2b74f2008-01-17 16:48:33 -0600148 if (nr == get_my_id()) {
149 printf("Invalid to release the boot core.\n\n");
150 return 1;
151 }
152
Kumar Gala79679d82008-03-26 08:34:25 -0500153 if (argc != 4) {
Kumar Galaec2b74f2008-01-17 16:48:33 -0600154 printf("Invalid number of arguments to release.\n\n");
155 return 1;
156 }
157
Kumar Gala79679d82008-03-26 08:34:25 -0500158 boot_addr = simple_strtoull(argv[0], NULL, 16);
Kumar Gala79679d82008-03-26 08:34:25 -0500159
York Sun3f0997b2012-10-08 07:44:29 +0000160 /* handle pir, r3 */
161 for (i = 1; i < 3; i++) {
Kumar Galaec2b74f2008-01-17 16:48:33 -0600162 if (argv[i][0] != '-') {
Kumar Gala79679d82008-03-26 08:34:25 -0500163 u8 entry = boot_entry_map[i];
Kumar Galaec2b74f2008-01-17 16:48:33 -0600164 val = simple_strtoul(argv[i], NULL, 16);
Kumar Gala79679d82008-03-26 08:34:25 -0500165 table[entry] = val;
Kumar Galaec2b74f2008-01-17 16:48:33 -0600166 }
167 }
168
Kumar Gala79679d82008-03-26 08:34:25 -0500169 table[BOOT_ENTRY_ADDR_UPPER] = (u32)(boot_addr >> 32);
Kumar Galacf6cc012008-04-28 02:24:04 -0500170
171 /* ensure all table updates complete before final address write */
172 eieio();
173
Kumar Gala79679d82008-03-26 08:34:25 -0500174 table[BOOT_ENTRY_ADDR_LOWER] = (u32)(boot_addr & 0xffffffff);
Kumar Galaec2b74f2008-01-17 16:48:33 -0600175
176 return 0;
177}
178
York Suneb539412012-10-08 07:44:25 +0000179u32 determine_mp_bootpg(unsigned int *pagesize)
Kumar Galac840d262009-03-31 23:11:05 -0500180{
York Suneb539412012-10-08 07:44:25 +0000181 u32 bootpg;
182#ifdef CONFIG_SYS_FSL_ERRATUM_A004468
183 u32 svr = get_svr();
184 u32 granule_size, check;
185 struct law_entry e;
186#endif
187
York Sunffd06e02012-10-08 07:44:30 +0000188
189 /* use last 4K of mapped memory */
190 bootpg = ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
191 CONFIG_MAX_MEM_MAPPED : gd->ram_size) +
192 CONFIG_SYS_SDRAM_BASE - 4096;
York Suneb539412012-10-08 07:44:25 +0000193 if (pagesize)
194 *pagesize = 4096;
Kumar Galac840d262009-03-31 23:11:05 -0500195
York Suneb539412012-10-08 07:44:25 +0000196#ifdef CONFIG_SYS_FSL_ERRATUM_A004468
197/*
198 * Erratum A004468 has two parts. The 3-way interleaving applies to T4240,
199 * to be fixed in rev 2.0. The 2-way interleaving applies to many SoCs. But
200 * the way boot page chosen in u-boot avoids hitting this erratum. So only
201 * thw workaround for 3-way interleaving is needed.
202 *
203 * To make sure boot page translation works with 3-Way DDR interleaving
204 * enforce a check for the following constrains
205 * 8K granule size requires BRSIZE=8K and
206 * bootpg >> log2(BRSIZE) %3 == 1
207 * 4K and 1K granule size requires BRSIZE=4K and
208 * bootpg >> log2(BRSIZE) %3 == 0
209 */
210 if (SVR_SOC_VER(svr) == SVR_T4240 && SVR_MAJ(svr) < 2) {
211 e = find_law(bootpg);
212 switch (e.trgt_id) {
213 case LAW_TRGT_IF_DDR_INTLV_123:
214 granule_size = fsl_ddr_get_intl3r() & 0x1f;
215 if (granule_size == FSL_DDR_3WAY_8KB_INTERLEAVING) {
216 if (pagesize)
217 *pagesize = 8192;
218 bootpg &= 0xffffe000; /* align to 8KB */
219 check = bootpg >> 13;
220 while ((check % 3) != 1)
221 check--;
222 bootpg = check << 13;
223 debug("Boot page (8K) at 0x%08x\n", bootpg);
224 break;
225 } else {
226 bootpg &= 0xfffff000; /* align to 4KB */
227 check = bootpg >> 12;
228 while ((check % 3) != 0)
229 check--;
230 bootpg = check << 12;
231 debug("Boot page (4K) at 0x%08x\n", bootpg);
232 }
233 break;
234 default:
235 break;
236 }
237 }
238#endif /* CONFIG_SYS_FSL_ERRATUM_A004468 */
239
240 return bootpg;
Kumar Galac840d262009-03-31 23:11:05 -0500241}
242
York Sunffd06e02012-10-08 07:44:30 +0000243phys_addr_t get_spin_phys_addr(void)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600244{
York Sunffd06e02012-10-08 07:44:30 +0000245 return virt_to_phys(&__spin_table);
Kumar Galaec2b74f2008-01-17 16:48:33 -0600246}
247
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500248#ifdef CONFIG_FSL_CORENET
York Suneb539412012-10-08 07:44:25 +0000249static void plat_mp_up(unsigned long bootpg, unsigned int pagesize)
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500250{
York Suneb539412012-10-08 07:44:25 +0000251 u32 cpu_up_mask, whoami, brsize = LAW_SIZE_4K;
York Sunffd06e02012-10-08 07:44:30 +0000252 u32 *table = (u32 *)&__spin_table;
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500253 volatile ccsr_gur_t *gur;
254 volatile ccsr_local_t *ccm;
255 volatile ccsr_rcpm_t *rcpm;
256 volatile ccsr_pic_t *pic;
257 int timeout = 10;
Timur Tabifbb9ecf2011-08-05 16:15:24 -0500258 u32 mask = cpu_mask();
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500259 struct law_entry e;
260
261 gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
262 ccm = (void *)(CONFIG_SYS_FSL_CORENET_CCM_ADDR);
263 rcpm = (void *)(CONFIG_SYS_FSL_CORENET_RCPM_ADDR);
Kim Phillips680c6132010-08-09 18:39:57 -0500264 pic = (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500265
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500266 whoami = in_be32(&pic->whoami);
267 cpu_up_mask = 1 << whoami;
268 out_be32(&ccm->bstrl, bootpg);
269
270 e = find_law(bootpg);
York Suneb539412012-10-08 07:44:25 +0000271 /* pagesize is only 4K or 8K */
272 if (pagesize == 8192)
273 brsize = LAW_SIZE_8K;
274 out_be32(&ccm->bstrar, LAW_EN | e.trgt_id << 20 | brsize);
275 debug("BRSIZE is 0x%x\n", brsize);
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500276
Dave Liuf5ecc6e2009-11-17 20:01:24 -0600277 /* readback to sync write */
278 in_be32(&ccm->bstrar);
279
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500280 /* disable time base at the platform */
281 out_be32(&rcpm->ctbenrl, cpu_up_mask);
282
Timur Tabifbb9ecf2011-08-05 16:15:24 -0500283 out_be32(&gur->brrl, mask);
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500284
285 /* wait for everyone */
286 while (timeout) {
Timur Tabifbb9ecf2011-08-05 16:15:24 -0500287 unsigned int i, cpu, nr_cpus = cpu_numcores();
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500288
Timur Tabifbb9ecf2011-08-05 16:15:24 -0500289 for_each_cpu(i, cpu, nr_cpus, mask) {
290 if (table[cpu * NUM_BOOT_ENTRY + BOOT_ENTRY_ADDR_LOWER])
291 cpu_up_mask |= (1 << cpu);
292 }
293
294 if ((cpu_up_mask & mask) == mask)
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500295 break;
296
297 udelay(100);
298 timeout--;
299 }
300
301 if (timeout == 0)
302 printf("CPU up timeout. CPU up mask is %x should be %x\n",
Timur Tabifbb9ecf2011-08-05 16:15:24 -0500303 cpu_up_mask, mask);
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500304
305 /* enable time base at the platform */
306 out_be32(&rcpm->ctbenrl, 0);
Kumar Gala7afc45a2011-03-13 10:55:53 -0500307
308 /* readback to sync write */
309 in_be32(&rcpm->ctbenrl);
310
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500311 mtspr(SPRN_TBWU, 0);
312 mtspr(SPRN_TBWL, 0);
Kumar Gala7afc45a2011-03-13 10:55:53 -0500313
Timur Tabifbb9ecf2011-08-05 16:15:24 -0500314 out_be32(&rcpm->ctbenrl, mask);
Peter Tyser5ccd29c2009-10-23 15:55:47 -0500315
316#ifdef CONFIG_MPC8xxx_DISABLE_BPTR
317 /*
318 * Disabling Boot Page Translation allows the memory region 0xfffff000
319 * to 0xffffffff to be used normally. Leaving Boot Page Translation
320 * enabled remaps 0xfffff000 to SDRAM which makes that memory region
321 * unusable for normal operation but it does allow OSes to easily
322 * reset a processor core to put it back into U-Boot's spinloop.
323 */
Ed Swarthoute81241a2011-03-03 18:28:14 -0600324 clrbits_be32(&ccm->bstrar, LAW_EN);
Peter Tyser5ccd29c2009-10-23 15:55:47 -0500325#endif
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500326}
327#else
York Suneb539412012-10-08 07:44:25 +0000328static void plat_mp_up(unsigned long bootpg, unsigned int pagesize)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600329{
330 u32 up, cpu_up_mask, whoami;
York Sunffd06e02012-10-08 07:44:30 +0000331 u32 *table = (u32 *)&__spin_table;
Kumar Galaec2b74f2008-01-17 16:48:33 -0600332 volatile u32 bpcr;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200333 volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
334 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Kim Phillips680c6132010-08-09 18:39:57 -0500335 volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
Kumar Galaec2b74f2008-01-17 16:48:33 -0600336 u32 devdisr;
337 int timeout = 10;
338
339 whoami = in_be32(&pic->whoami);
340 out_be32(&ecm->bptr, 0x80000000 | (bootpg >> 12));
341
342 /* disable time base at the platform */
343 devdisr = in_be32(&gur->devdisr);
344 if (whoami)
345 devdisr |= MPC85xx_DEVDISR_TB0;
346 else
347 devdisr |= MPC85xx_DEVDISR_TB1;
348 out_be32(&gur->devdisr, devdisr);
349
350 /* release the hounds */
Poonam Aggrwal0e870982009-07-31 12:08:14 +0530351 up = ((1 << cpu_numcores()) - 1);
Kumar Galaec2b74f2008-01-17 16:48:33 -0600352 bpcr = in_be32(&ecm->eebpcr);
353 bpcr |= (up << 24);
354 out_be32(&ecm->eebpcr, bpcr);
355 asm("sync; isync; msync");
356
357 cpu_up_mask = 1 << whoami;
358 /* wait for everyone */
359 while (timeout) {
360 int i;
Poonam Aggrwal0e870982009-07-31 12:08:14 +0530361 for (i = 0; i < cpu_numcores(); i++) {
Kumar Gala97b3ecb2008-04-09 04:20:57 -0500362 if (table[i * NUM_BOOT_ENTRY + BOOT_ENTRY_ADDR_LOWER])
Kumar Galaec2b74f2008-01-17 16:48:33 -0600363 cpu_up_mask |= (1 << i);
364 };
365
366 if ((cpu_up_mask & up) == up)
367 break;
368
369 udelay(100);
370 timeout--;
371 }
372
Kumar Gala97b3ecb2008-04-09 04:20:57 -0500373 if (timeout == 0)
374 printf("CPU up timeout. CPU up mask is %x should be %x\n",
375 cpu_up_mask, up);
376
Kumar Galaec2b74f2008-01-17 16:48:33 -0600377 /* enable time base at the platform */
378 if (whoami)
379 devdisr |= MPC85xx_DEVDISR_TB1;
380 else
381 devdisr |= MPC85xx_DEVDISR_TB0;
382 out_be32(&gur->devdisr, devdisr);
Kumar Gala7afc45a2011-03-13 10:55:53 -0500383
384 /* readback to sync write */
385 in_be32(&gur->devdisr);
386
Kumar Galaec2b74f2008-01-17 16:48:33 -0600387 mtspr(SPRN_TBWU, 0);
388 mtspr(SPRN_TBWL, 0);
389
390 devdisr &= ~(MPC85xx_DEVDISR_TB0 | MPC85xx_DEVDISR_TB1);
391 out_be32(&gur->devdisr, devdisr);
Peter Tyser5ccd29c2009-10-23 15:55:47 -0500392
393#ifdef CONFIG_MPC8xxx_DISABLE_BPTR
394 /*
395 * Disabling Boot Page Translation allows the memory region 0xfffff000
396 * to 0xffffffff to be used normally. Leaving Boot Page Translation
397 * enabled remaps 0xfffff000 to SDRAM which makes that memory region
398 * unusable for normal operation but it does allow OSes to easily
399 * reset a processor core to put it back into U-Boot's spinloop.
400 */
401 clrbits_be32(&ecm->bptr, 0x80000000);
402#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -0600403}
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500404#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -0600405
Kumar Galadd6c9102008-03-26 08:53:53 -0500406void cpu_mp_lmb_reserve(struct lmb *lmb)
407{
York Suneb539412012-10-08 07:44:25 +0000408 u32 bootpg = determine_mp_bootpg(NULL);
Kumar Galadd6c9102008-03-26 08:53:53 -0500409
410 lmb_reserve(lmb, bootpg, 4096);
411}
412
Kumar Galaec2b74f2008-01-17 16:48:33 -0600413void setup_mp(void)
414{
York Sunffd06e02012-10-08 07:44:30 +0000415 extern u32 __secondary_start_page;
416 extern u32 __bootpg_addr, __spin_table_addr, __second_half_boot_page;
York Suneb539412012-10-08 07:44:25 +0000417
York Sunffd06e02012-10-08 07:44:30 +0000418 int i;
419 ulong fixup = (u32)&__secondary_start_page;
York Suneb539412012-10-08 07:44:25 +0000420 u32 bootpg, bootpg_map, pagesize;
421
422 bootpg = determine_mp_bootpg(&pagesize);
423
424 /*
425 * pagesize is only 4K or 8K
426 * we only use the last 4K of boot page
427 * bootpg_map saves the address for the boot page
428 * 8K is used for the workaround of 3-way DDR interleaving
429 */
430
431 bootpg_map = bootpg;
432
433 if (pagesize == 8192)
434 bootpg += 4096; /* use 2nd half */
Kumar Galaec2b74f2008-01-17 16:48:33 -0600435
Aaron Sierra9d64c6b2010-09-30 12:22:16 -0500436 /* Some OSes expect secondary cores to be held in reset */
437 if (hold_cores_in_reset(0))
438 return;
439
York Sunffd06e02012-10-08 07:44:30 +0000440 /*
441 * Store the bootpg's cache-able half address for use by secondary
442 * CPU cores to continue to boot
443 */
444 __bootpg_addr = (u32)virt_to_phys(&__second_half_boot_page);
445
446 /* Store spin table's physical address for use by secondary cores */
447 __spin_table_addr = (u32)get_spin_phys_addr();
448
449 /* flush bootpg it before copying invalidate any staled cacheline */
450 flush_cache(bootpg, 4096);
Peter Tyser5ccd29c2009-10-23 15:55:47 -0500451
Kumar Galac7259082009-09-03 08:41:31 -0500452 /* look for the tlb covering the reset page, there better be one */
York Sunffd06e02012-10-08 07:44:30 +0000453 i = find_tlb_idx((void *)CONFIG_BPTR_VIRT_ADDR, 1);
Kumar Galaec2b74f2008-01-17 16:48:33 -0600454
Kumar Galac7259082009-09-03 08:41:31 -0500455 /* we found a match */
456 if (i != -1) {
457 /* map reset page to bootpg so we can copy code there */
458 disable_tlb(i);
Kumar Gala39a7e7f2009-09-17 01:44:39 -0500459
Peter Tyser5ccd29c2009-10-23 15:55:47 -0500460 set_tlb(1, CONFIG_BPTR_VIRT_ADDR, bootpg, /* tlb, epn, rpn */
Kumar Galaabc76eb2009-11-17 20:21:20 -0600461 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
Kumar Galac7259082009-09-03 08:41:31 -0500462 0, i, BOOKE_PAGESZ_4K, 1); /* ts, esel, tsize, iprot */
463
Peter Tyser5ccd29c2009-10-23 15:55:47 -0500464 memcpy((void *)CONFIG_BPTR_VIRT_ADDR, (void *)fixup, 4096);
465
York Suneb539412012-10-08 07:44:25 +0000466 plat_mp_up(bootpg_map, pagesize);
Kumar Galac7259082009-09-03 08:41:31 -0500467 } else {
468 puts("WARNING: No reset page TLB. "
469 "Skipping secondary core setup\n");
470 }
Kumar Galaec2b74f2008-01-17 16:48:33 -0600471}