cpu_init.c 18 KB

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