cpu_init.c 21 KB

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