cpu_init.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. /*
  2. * Copyright 2007-2011 Freescale Semiconductor, Inc.
  3. *
  4. * (C) Copyright 2003 Motorola Inc.
  5. * Modified by Xianghua Xiao, X.Xiao@motorola.com
  6. *
  7. * (C) Copyright 2000
  8. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  9. *
  10. * SPDX-License-Identifier: GPL-2.0+
  11. */
  12. #include <common.h>
  13. #include <watchdog.h>
  14. #include <asm/processor.h>
  15. #include <ioports.h>
  16. #include <sata.h>
  17. #include <fm_eth.h>
  18. #include <asm/io.h>
  19. #include <asm/cache.h>
  20. #include <asm/mmu.h>
  21. #include <asm/fsl_law.h>
  22. #include <asm/fsl_serdes.h>
  23. #include <asm/fsl_srio.h>
  24. #include <hwconfig.h>
  25. #include <linux/compiler.h>
  26. #include "mp.h"
  27. #ifdef CONFIG_SYS_QE_FMAN_FW_IN_NAND
  28. #include <nand.h>
  29. #include <errno.h>
  30. #endif
  31. #include "../../../../drivers/block/fsl_sata.h"
  32. DECLARE_GLOBAL_DATA_PTR;
  33. #ifdef CONFIG_QE
  34. extern qe_iop_conf_t qe_iop_conf_tab[];
  35. extern void qe_config_iopin(u8 port, u8 pin, int dir,
  36. int open_drain, int assign);
  37. extern void qe_init(uint qe_base);
  38. extern void qe_reset(void);
  39. static void config_qe_ioports(void)
  40. {
  41. u8 port, pin;
  42. int dir, open_drain, assign;
  43. int i;
  44. for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
  45. port = qe_iop_conf_tab[i].port;
  46. pin = qe_iop_conf_tab[i].pin;
  47. dir = qe_iop_conf_tab[i].dir;
  48. open_drain = qe_iop_conf_tab[i].open_drain;
  49. assign = qe_iop_conf_tab[i].assign;
  50. qe_config_iopin(port, pin, dir, open_drain, assign);
  51. }
  52. }
  53. #endif
  54. #ifdef CONFIG_CPM2
  55. void config_8560_ioports (volatile ccsr_cpm_t * cpm)
  56. {
  57. int portnum;
  58. for (portnum = 0; portnum < 4; portnum++) {
  59. uint pmsk = 0,
  60. ppar = 0,
  61. psor = 0,
  62. pdir = 0,
  63. podr = 0,
  64. pdat = 0;
  65. iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0];
  66. iop_conf_t *eiopc = iopc + 32;
  67. uint msk = 1;
  68. /*
  69. * NOTE:
  70. * index 0 refers to pin 31,
  71. * index 31 refers to pin 0
  72. */
  73. while (iopc < eiopc) {
  74. if (iopc->conf) {
  75. pmsk |= msk;
  76. if (iopc->ppar)
  77. ppar |= msk;
  78. if (iopc->psor)
  79. psor |= msk;
  80. if (iopc->pdir)
  81. pdir |= msk;
  82. if (iopc->podr)
  83. podr |= msk;
  84. if (iopc->pdat)
  85. pdat |= msk;
  86. }
  87. msk <<= 1;
  88. iopc++;
  89. }
  90. if (pmsk != 0) {
  91. volatile ioport_t *iop = ioport_addr (cpm, portnum);
  92. uint tpmsk = ~pmsk;
  93. /*
  94. * the (somewhat confused) paragraph at the
  95. * bottom of page 35-5 warns that there might
  96. * be "unknown behaviour" when programming
  97. * PSORx and PDIRx, if PPARx = 1, so I
  98. * decided this meant I had to disable the
  99. * dedicated function first, and enable it
  100. * last.
  101. */
  102. iop->ppar &= tpmsk;
  103. iop->psor = (iop->psor & tpmsk) | psor;
  104. iop->podr = (iop->podr & tpmsk) | podr;
  105. iop->pdat = (iop->pdat & tpmsk) | pdat;
  106. iop->pdir = (iop->pdir & tpmsk) | pdir;
  107. iop->ppar |= ppar;
  108. }
  109. }
  110. }
  111. #endif
  112. #ifdef CONFIG_SYS_FSL_CPC
  113. static void enable_cpc(void)
  114. {
  115. int i;
  116. u32 size = 0;
  117. cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
  118. for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
  119. u32 cpccfg0 = in_be32(&cpc->cpccfg0);
  120. size += CPC_CFG0_SZ_K(cpccfg0);
  121. #ifdef CONFIG_RAMBOOT_PBL
  122. if (in_be32(&cpc->cpcsrcr0) & CPC_SRCR0_SRAMEN) {
  123. /* find and disable LAW of SRAM */
  124. struct law_entry law = find_law(CONFIG_SYS_INIT_L3_ADDR);
  125. if (law.index == -1) {
  126. printf("\nFatal error happened\n");
  127. return;
  128. }
  129. disable_law(law.index);
  130. clrbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_CDQ_SPEC_DIS);
  131. out_be32(&cpc->cpccsr0, 0);
  132. out_be32(&cpc->cpcsrcr0, 0);
  133. }
  134. #endif
  135. #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002
  136. setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_TAG_ECC_SCRUB_DIS);
  137. #endif
  138. #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003
  139. setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_DATA_ECC_SCRUB_DIS);
  140. #endif
  141. #ifdef CONFIG_SYS_FSL_ERRATUM_A006593
  142. setbits_be32(&cpc->cpchdbcr0, 1 << (31 - 21));
  143. #endif
  144. out_be32(&cpc->cpccsr0, CPC_CSR0_CE | CPC_CSR0_PE);
  145. /* Read back to sync write */
  146. in_be32(&cpc->cpccsr0);
  147. }
  148. printf("Corenet Platform Cache: %d KB enabled\n", size);
  149. }
  150. static void invalidate_cpc(void)
  151. {
  152. int i;
  153. cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
  154. for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
  155. /* skip CPC when it used as all SRAM */
  156. if (in_be32(&cpc->cpcsrcr0) & CPC_SRCR0_SRAMEN)
  157. continue;
  158. /* Flash invalidate the CPC and clear all the locks */
  159. out_be32(&cpc->cpccsr0, CPC_CSR0_FI | CPC_CSR0_LFC);
  160. while (in_be32(&cpc->cpccsr0) & (CPC_CSR0_FI | CPC_CSR0_LFC))
  161. ;
  162. }
  163. }
  164. #else
  165. #define enable_cpc()
  166. #define invalidate_cpc()
  167. #endif /* CONFIG_SYS_FSL_CPC */
  168. /*
  169. * Breathe some life into the CPU...
  170. *
  171. * Set up the memory map
  172. * initialize a bunch of registers
  173. */
  174. #ifdef CONFIG_FSL_CORENET
  175. static void corenet_tb_init(void)
  176. {
  177. volatile ccsr_rcpm_t *rcpm =
  178. (void *)(CONFIG_SYS_FSL_CORENET_RCPM_ADDR);
  179. volatile ccsr_pic_t *pic =
  180. (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
  181. u32 whoami = in_be32(&pic->whoami);
  182. /* Enable the timebase register for this core */
  183. out_be32(&rcpm->ctbenrl, (1 << whoami));
  184. }
  185. #endif
  186. void cpu_init_f (void)
  187. {
  188. extern void m8560_cpm_reset (void);
  189. #ifdef CONFIG_SYS_DCSRBAR_PHYS
  190. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  191. #endif
  192. #if defined(CONFIG_SECURE_BOOT)
  193. struct law_entry law;
  194. #endif
  195. #ifdef CONFIG_MPC8548
  196. ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
  197. uint svr = get_svr();
  198. /*
  199. * CPU2 errata workaround: A core hang possible while executing
  200. * a msync instruction and a snoopable transaction from an I/O
  201. * master tagged to make quick forward progress is present.
  202. * Fixed in silicon rev 2.1.
  203. */
  204. if ((SVR_MAJ(svr) == 1) || ((SVR_MAJ(svr) == 2 && SVR_MIN(svr) == 0x0)))
  205. out_be32(&ecm->eebpcr, in_be32(&ecm->eebpcr) | (1 << 16));
  206. #endif
  207. disable_tlb(14);
  208. disable_tlb(15);
  209. #if defined(CONFIG_SECURE_BOOT)
  210. /* Disable the LAW created for NOR flash by the PBI commands */
  211. law = find_law(CONFIG_SYS_PBI_FLASH_BASE);
  212. if (law.index != -1)
  213. disable_law(law.index);
  214. #endif
  215. #ifdef CONFIG_CPM2
  216. config_8560_ioports((ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR);
  217. #endif
  218. init_early_memctl_regs();
  219. #if defined(CONFIG_CPM2)
  220. m8560_cpm_reset();
  221. #endif
  222. #ifdef CONFIG_QE
  223. /* Config QE ioports */
  224. config_qe_ioports();
  225. #endif
  226. #if defined(CONFIG_FSL_DMA)
  227. dma_init();
  228. #endif
  229. #ifdef CONFIG_FSL_CORENET
  230. corenet_tb_init();
  231. #endif
  232. init_used_tlb_cams();
  233. /* Invalidate the CPC before DDR gets enabled */
  234. invalidate_cpc();
  235. #ifdef CONFIG_SYS_DCSRBAR_PHYS
  236. /* set DCSRCR so that DCSR space is 1G */
  237. setbits_be32(&gur->dcsrcr, FSL_CORENET_DCSR_SZ_1G);
  238. in_be32(&gur->dcsrcr);
  239. #endif
  240. }
  241. /* Implement a dummy function for those platforms w/o SERDES */
  242. static void __fsl_serdes__init(void)
  243. {
  244. return ;
  245. }
  246. __attribute__((weak, alias("__fsl_serdes__init"))) void fsl_serdes_init(void);
  247. #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
  248. int enable_cluster_l2(void)
  249. {
  250. int i = 0;
  251. u32 cluster;
  252. ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  253. struct ccsr_cluster_l2 __iomem *l2cache;
  254. cluster = in_be32(&gur->tp_cluster[i].lower);
  255. if (cluster & TP_CLUSTER_EOC)
  256. return 0;
  257. /* The first cache has already been set up, so skip it */
  258. i++;
  259. /* Look through the remaining clusters, and set up their caches */
  260. do {
  261. int j, cluster_valid = 0;
  262. l2cache = (void __iomem *)(CONFIG_SYS_FSL_CLUSTER_1_L2 + i * 0x40000);
  263. cluster = in_be32(&gur->tp_cluster[i].lower);
  264. /* check that at least one core/accel is enabled in cluster */
  265. for (j = 0; j < 4; j++) {
  266. u32 idx = (cluster >> (j*8)) & TP_CLUSTER_INIT_MASK;
  267. u32 type = in_be32(&gur->tp_ityp[idx]);
  268. if (type & TP_ITYP_AV)
  269. cluster_valid = 1;
  270. }
  271. if (cluster_valid) {
  272. /* set stash ID to (cluster) * 2 + 32 + 1 */
  273. clrsetbits_be32(&l2cache->l2csr1, 0xff, 32 + i * 2 + 1);
  274. printf("enable l2 for cluster %d %p\n", i, l2cache);
  275. out_be32(&l2cache->l2csr0, L2CSR0_L2FI|L2CSR0_L2LFC);
  276. while ((in_be32(&l2cache->l2csr0)
  277. & (L2CSR0_L2FI|L2CSR0_L2LFC)) != 0)
  278. ;
  279. out_be32(&l2cache->l2csr0, L2CSR0_L2E|L2CSR0_L2PE|L2CSR0_L2REP_MODE);
  280. }
  281. i++;
  282. } while (!(cluster & TP_CLUSTER_EOC));
  283. return 0;
  284. }
  285. #endif
  286. /*
  287. * Initialize L2 as cache.
  288. *
  289. * The newer 8548, etc, parts have twice as much cache, but
  290. * use the same bit-encoding as the older 8555, etc, parts.
  291. *
  292. */
  293. int cpu_init_r(void)
  294. {
  295. __maybe_unused u32 svr = get_svr();
  296. #ifdef CONFIG_SYS_LBC_LCRR
  297. fsl_lbc_t *lbc = (void __iomem *)LBC_BASE_ADDR;
  298. #endif
  299. #ifdef CONFIG_L2_CACHE
  300. ccsr_l2cache_t *l2cache = (void __iomem *)CONFIG_SYS_MPC85xx_L2_ADDR;
  301. #elif defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2)
  302. struct ccsr_cluster_l2 * l2cache = (void __iomem *)CONFIG_SYS_FSL_CLUSTER_1_L2;
  303. #endif
  304. #if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
  305. extern int spin_table_compat;
  306. const char *spin;
  307. #endif
  308. #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \
  309. defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
  310. /*
  311. * CPU22 and NMG_CPU_A011 share the same workaround.
  312. * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0
  313. * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
  314. * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1, both
  315. * fixed in 2.0. NMG_CPU_A011 is activated by default and can
  316. * be disabled by hwconfig with syntax:
  317. *
  318. * fsl_cpu_a011:disable
  319. */
  320. extern int enable_cpu_a011_workaround;
  321. #ifdef CONFIG_SYS_P4080_ERRATUM_CPU22
  322. enable_cpu_a011_workaround = (SVR_MAJ(svr) < 3);
  323. #else
  324. char buffer[HWCONFIG_BUFFER_SIZE];
  325. char *buf = NULL;
  326. int n, res;
  327. n = getenv_f("hwconfig", buffer, sizeof(buffer));
  328. if (n > 0)
  329. buf = buffer;
  330. res = hwconfig_arg_cmp_f("fsl_cpu_a011", "disable", buf);
  331. if (res > 0)
  332. enable_cpu_a011_workaround = 0;
  333. else {
  334. if (n >= HWCONFIG_BUFFER_SIZE) {
  335. printf("fsl_cpu_a011 was not found. hwconfig variable "
  336. "may be too long\n");
  337. }
  338. enable_cpu_a011_workaround =
  339. (SVR_SOC_VER(svr) == SVR_P4080 && SVR_MAJ(svr) < 3) ||
  340. (SVR_SOC_VER(svr) != SVR_P4080 && SVR_MAJ(svr) < 2);
  341. }
  342. #endif
  343. if (enable_cpu_a011_workaround) {
  344. flush_dcache();
  345. mtspr(L1CSR2, (mfspr(L1CSR2) | L1CSR2_DCWS));
  346. sync();
  347. }
  348. #endif
  349. #ifdef CONFIG_SYS_FSL_ERRATUM_A005812
  350. /*
  351. * A-005812 workaround sets bit 32 of SPR 976 for SoCs running
  352. * in write shadow mode. Checking DCWS before setting SPR 976.
  353. */
  354. if (mfspr(L1CSR2) & L1CSR2_DCWS)
  355. mtspr(SPRN_HDBCR0, (mfspr(SPRN_HDBCR0) | 0x80000000));
  356. #endif
  357. #if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
  358. spin = getenv("spin_table_compat");
  359. if (spin && (*spin == 'n'))
  360. spin_table_compat = 0;
  361. else
  362. spin_table_compat = 1;
  363. #endif
  364. puts ("L2: ");
  365. #if defined(CONFIG_L2_CACHE)
  366. volatile uint cache_ctl;
  367. uint ver;
  368. u32 l2siz_field;
  369. ver = SVR_SOC_VER(svr);
  370. asm("msync;isync");
  371. cache_ctl = l2cache->l2ctl;
  372. #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
  373. if (cache_ctl & MPC85xx_L2CTL_L2E) {
  374. /* Clear L2 SRAM memory-mapped base address */
  375. out_be32(&l2cache->l2srbar0, 0x0);
  376. out_be32(&l2cache->l2srbar1, 0x0);
  377. /* set MBECCDIS=0, SBECCDIS=0 */
  378. clrbits_be32(&l2cache->l2errdis,
  379. (MPC85xx_L2ERRDIS_MBECC |
  380. MPC85xx_L2ERRDIS_SBECC));
  381. /* set L2E=0, L2SRAM=0 */
  382. clrbits_be32(&l2cache->l2ctl,
  383. (MPC85xx_L2CTL_L2E |
  384. MPC85xx_L2CTL_L2SRAM_ENTIRE));
  385. }
  386. #endif
  387. l2siz_field = (cache_ctl >> 28) & 0x3;
  388. switch (l2siz_field) {
  389. case 0x0:
  390. printf(" unknown size (0x%08x)\n", cache_ctl);
  391. return -1;
  392. break;
  393. case 0x1:
  394. if (ver == SVR_8540 || ver == SVR_8560 ||
  395. ver == SVR_8541 || ver == SVR_8555) {
  396. puts("128 KB ");
  397. /* set L2E=1, L2I=1, & L2BLKSZ=1 (128 Kbyte) */
  398. cache_ctl = 0xc4000000;
  399. } else {
  400. puts("256 KB ");
  401. cache_ctl = 0xc0000000; /* set L2E=1, L2I=1, & L2SRAM=0 */
  402. }
  403. break;
  404. case 0x2:
  405. if (ver == SVR_8540 || ver == SVR_8560 ||
  406. ver == SVR_8541 || ver == SVR_8555) {
  407. puts("256 KB ");
  408. /* set L2E=1, L2I=1, & L2BLKSZ=2 (256 Kbyte) */
  409. cache_ctl = 0xc8000000;
  410. } else {
  411. puts ("512 KB ");
  412. /* set L2E=1, L2I=1, & L2SRAM=0 */
  413. cache_ctl = 0xc0000000;
  414. }
  415. break;
  416. case 0x3:
  417. puts("1024 KB ");
  418. /* set L2E=1, L2I=1, & L2SRAM=0 */
  419. cache_ctl = 0xc0000000;
  420. break;
  421. }
  422. if (l2cache->l2ctl & MPC85xx_L2CTL_L2E) {
  423. puts("already enabled");
  424. #if defined(CONFIG_SYS_INIT_L2_ADDR) && defined(CONFIG_SYS_FLASH_BASE)
  425. u32 l2srbar = l2cache->l2srbar0;
  426. if (l2cache->l2ctl & MPC85xx_L2CTL_L2SRAM_ENTIRE
  427. && l2srbar >= CONFIG_SYS_FLASH_BASE) {
  428. l2srbar = CONFIG_SYS_INIT_L2_ADDR;
  429. l2cache->l2srbar0 = l2srbar;
  430. printf(", moving to 0x%08x", CONFIG_SYS_INIT_L2_ADDR);
  431. }
  432. #endif /* CONFIG_SYS_INIT_L2_ADDR */
  433. puts("\n");
  434. } else {
  435. asm("msync;isync");
  436. l2cache->l2ctl = cache_ctl; /* invalidate & enable */
  437. asm("msync;isync");
  438. puts("enabled\n");
  439. }
  440. #elif defined(CONFIG_BACKSIDE_L2_CACHE)
  441. if (SVR_SOC_VER(svr) == SVR_P2040) {
  442. puts("N/A\n");
  443. goto skip_l2;
  444. }
  445. u32 l2cfg0 = mfspr(SPRN_L2CFG0);
  446. /* invalidate the L2 cache */
  447. mtspr(SPRN_L2CSR0, (L2CSR0_L2FI|L2CSR0_L2LFC));
  448. while (mfspr(SPRN_L2CSR0) & (L2CSR0_L2FI|L2CSR0_L2LFC))
  449. ;
  450. #ifdef CONFIG_SYS_CACHE_STASHING
  451. /* set stash id to (coreID) * 2 + 32 + L2 (1) */
  452. mtspr(SPRN_L2CSR1, (32 + 1));
  453. #endif
  454. /* enable the cache */
  455. mtspr(SPRN_L2CSR0, CONFIG_SYS_INIT_L2CSR0);
  456. if (CONFIG_SYS_INIT_L2CSR0 & L2CSR0_L2E) {
  457. while (!(mfspr(SPRN_L2CSR0) & L2CSR0_L2E))
  458. ;
  459. printf("%d KB enabled\n", (l2cfg0 & 0x3fff) * 64);
  460. }
  461. skip_l2:
  462. #elif defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2)
  463. if (l2cache->l2csr0 & L2CSR0_L2E)
  464. printf("%d KB enabled\n", (l2cache->l2cfg0 & 0x3fff) * 64);
  465. enable_cluster_l2();
  466. #else
  467. puts("disabled\n");
  468. #endif
  469. enable_cpc();
  470. #ifndef CONFIG_SYS_FSL_NO_SERDES
  471. /* needs to be in ram since code uses global static vars */
  472. fsl_serdes_init();
  473. #endif
  474. #ifdef CONFIG_SYS_FSL_ERRATUM_A005871
  475. if (IS_SVR_REV(svr, 1, 0)) {
  476. int i;
  477. __be32 *p = (void __iomem *)CONFIG_SYS_DCSRBAR + 0xb004c;
  478. for (i = 0; i < 12; i++) {
  479. p += i + (i > 5 ? 11 : 0);
  480. out_be32(p, 0x2);
  481. }
  482. p = (void __iomem *)CONFIG_SYS_DCSRBAR + 0xb0108;
  483. out_be32(p, 0x34);
  484. }
  485. #endif
  486. #ifdef CONFIG_SYS_SRIO
  487. srio_init();
  488. #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
  489. char *s = getenv("bootmaster");
  490. if (s) {
  491. if (!strcmp(s, "SRIO1")) {
  492. srio_boot_master(1);
  493. srio_boot_master_release_slave(1);
  494. }
  495. if (!strcmp(s, "SRIO2")) {
  496. srio_boot_master(2);
  497. srio_boot_master_release_slave(2);
  498. }
  499. }
  500. #endif
  501. #endif
  502. #if defined(CONFIG_MP)
  503. setup_mp();
  504. #endif
  505. #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC13
  506. {
  507. if (SVR_MAJ(svr) < 3) {
  508. void *p;
  509. p = (void *)CONFIG_SYS_DCSRBAR + 0x20520;
  510. setbits_be32(p, 1 << (31 - 14));
  511. }
  512. }
  513. #endif
  514. #ifdef CONFIG_SYS_LBC_LCRR
  515. /*
  516. * Modify the CLKDIV field of LCRR register to improve the writing
  517. * speed for NOR flash.
  518. */
  519. clrsetbits_be32(&lbc->lcrr, LCRR_CLKDIV, CONFIG_SYS_LBC_LCRR);
  520. __raw_readl(&lbc->lcrr);
  521. isync();
  522. #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103
  523. udelay(100);
  524. #endif
  525. #endif
  526. #ifdef CONFIG_SYS_FSL_USB1_PHY_ENABLE
  527. {
  528. ccsr_usb_phy_t *usb_phy1 =
  529. (void *)CONFIG_SYS_MPC85xx_USB1_PHY_ADDR;
  530. out_be32(&usb_phy1->usb_enable_override,
  531. CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE);
  532. }
  533. #endif
  534. #ifdef CONFIG_SYS_FSL_USB2_PHY_ENABLE
  535. {
  536. ccsr_usb_phy_t *usb_phy2 =
  537. (void *)CONFIG_SYS_MPC85xx_USB2_PHY_ADDR;
  538. out_be32(&usb_phy2->usb_enable_override,
  539. CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE);
  540. }
  541. #endif
  542. #ifdef CONFIG_SYS_FSL_ERRATUM_USB14
  543. /* On P204x/P304x/P50x0 Rev1.0, USB transmit will result internal
  544. * multi-bit ECC errors which has impact on performance, so software
  545. * should disable all ECC reporting from USB1 and USB2.
  546. */
  547. if (IS_SVR_REV(get_svr(), 1, 0)) {
  548. struct dcsr_dcfg_regs *dcfg = (struct dcsr_dcfg_regs *)
  549. (CONFIG_SYS_DCSRBAR + CONFIG_SYS_DCSR_DCFG_OFFSET);
  550. setbits_be32(&dcfg->ecccr1,
  551. (DCSR_DCFG_ECC_DISABLE_USB1 |
  552. DCSR_DCFG_ECC_DISABLE_USB2));
  553. }
  554. #endif
  555. #if defined(CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE)
  556. ccsr_usb_phy_t *usb_phy =
  557. (void *)CONFIG_SYS_MPC85xx_USB1_PHY_ADDR;
  558. setbits_be32(&usb_phy->pllprg[1],
  559. CONFIG_SYS_FSL_USB_PLLPRG2_PHY2_CLK_EN |
  560. CONFIG_SYS_FSL_USB_PLLPRG2_PHY1_CLK_EN |
  561. CONFIG_SYS_FSL_USB_PLLPRG2_MFI |
  562. CONFIG_SYS_FSL_USB_PLLPRG2_PLL_EN);
  563. setbits_be32(&usb_phy->port1.ctrl,
  564. CONFIG_SYS_FSL_USB_CTRL_PHY_EN);
  565. setbits_be32(&usb_phy->port1.drvvbuscfg,
  566. CONFIG_SYS_FSL_USB_DRVVBUS_CR_EN);
  567. setbits_be32(&usb_phy->port1.pwrfltcfg,
  568. CONFIG_SYS_FSL_USB_PWRFLT_CR_EN);
  569. setbits_be32(&usb_phy->port2.ctrl,
  570. CONFIG_SYS_FSL_USB_CTRL_PHY_EN);
  571. setbits_be32(&usb_phy->port2.drvvbuscfg,
  572. CONFIG_SYS_FSL_USB_DRVVBUS_CR_EN);
  573. setbits_be32(&usb_phy->port2.pwrfltcfg,
  574. CONFIG_SYS_FSL_USB_PWRFLT_CR_EN);
  575. #endif
  576. #ifdef CONFIG_FMAN_ENET
  577. fman_enet_init();
  578. #endif
  579. #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001)
  580. /*
  581. * For P1022/1013 Rev1.0 silicon, after power on SATA host
  582. * controller is configured in legacy mode instead of the
  583. * expected enterprise mode. Software needs to clear bit[28]
  584. * of HControl register to change to enterprise mode from
  585. * legacy mode. We assume that the controller is offline.
  586. */
  587. if (IS_SVR_REV(svr, 1, 0) &&
  588. ((SVR_SOC_VER(svr) == SVR_P1022) ||
  589. (SVR_SOC_VER(svr) == SVR_P1013))) {
  590. fsl_sata_reg_t *reg;
  591. /* first SATA controller */
  592. reg = (void *)CONFIG_SYS_MPC85xx_SATA1_ADDR;
  593. clrbits_le32(&reg->hcontrol, HCONTROL_ENTERPRISE_EN);
  594. /* second SATA controller */
  595. reg = (void *)CONFIG_SYS_MPC85xx_SATA2_ADDR;
  596. clrbits_le32(&reg->hcontrol, HCONTROL_ENTERPRISE_EN);
  597. }
  598. #endif
  599. return 0;
  600. }
  601. extern void setup_ivors(void);
  602. void arch_preboot_os(void)
  603. {
  604. u32 msr;
  605. /*
  606. * We are changing interrupt offsets and are about to boot the OS so
  607. * we need to make sure we disable all async interrupts. EE is already
  608. * disabled by the time we get called.
  609. */
  610. msr = mfmsr();
  611. msr &= ~(MSR_ME|MSR_CE);
  612. mtmsr(msr);
  613. setup_ivors();
  614. }
  615. #if defined(CONFIG_CMD_SATA) && defined(CONFIG_FSL_SATA)
  616. int sata_initialize(void)
  617. {
  618. if (is_serdes_configured(SATA1) || is_serdes_configured(SATA2))
  619. return __sata_initialize();
  620. return 1;
  621. }
  622. #endif
  623. void cpu_secondary_init_r(void)
  624. {
  625. #ifdef CONFIG_QE
  626. uint qe_base = CONFIG_SYS_IMMR + 0x00080000; /* QE immr base */
  627. #ifdef CONFIG_SYS_QE_FMAN_FW_IN_NAND
  628. int ret;
  629. size_t fw_length = CONFIG_SYS_QE_FMAN_FW_LENGTH;
  630. /* load QE firmware from NAND flash to DDR first */
  631. ret = nand_read(&nand_info[0], (loff_t)CONFIG_SYS_QE_FMAN_FW_IN_NAND,
  632. &fw_length, (u_char *)CONFIG_SYS_QE_FMAN_FW_ADDR);
  633. if (ret && ret == -EUCLEAN) {
  634. printf ("NAND read for QE firmware at offset %x failed %d\n",
  635. CONFIG_SYS_QE_FMAN_FW_IN_NAND, ret);
  636. }
  637. #endif
  638. qe_init(qe_base);
  639. qe_reset();
  640. #endif
  641. }