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. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <common.h>
  29. #include <watchdog.h>
  30. #include <asm/processor.h>
  31. #include <ioports.h>
  32. #include <sata.h>
  33. #include <fm_eth.h>
  34. #include <asm/io.h>
  35. #include <asm/cache.h>
  36. #include <asm/mmu.h>
  37. #include <asm/fsl_law.h>
  38. #include <asm/fsl_serdes.h>
  39. #include <asm/fsl_srio.h>
  40. #include <hwconfig.h>
  41. #include <linux/compiler.h>
  42. #include "mp.h"
  43. #ifdef CONFIG_SYS_QE_FMAN_FW_IN_NAND
  44. #include <nand.h>
  45. #include <errno.h>
  46. #endif
  47. #include "../../../../drivers/block/fsl_sata.h"
  48. DECLARE_GLOBAL_DATA_PTR;
  49. #ifdef CONFIG_QE
  50. extern qe_iop_conf_t qe_iop_conf_tab[];
  51. extern void qe_config_iopin(u8 port, u8 pin, int dir,
  52. int open_drain, int assign);
  53. extern void qe_init(uint qe_base);
  54. extern void qe_reset(void);
  55. static void config_qe_ioports(void)
  56. {
  57. u8 port, pin;
  58. int dir, open_drain, assign;
  59. int i;
  60. for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
  61. port = qe_iop_conf_tab[i].port;
  62. pin = qe_iop_conf_tab[i].pin;
  63. dir = qe_iop_conf_tab[i].dir;
  64. open_drain = qe_iop_conf_tab[i].open_drain;
  65. assign = qe_iop_conf_tab[i].assign;
  66. qe_config_iopin(port, pin, dir, open_drain, assign);
  67. }
  68. }
  69. #endif
  70. #ifdef CONFIG_CPM2
  71. void config_8560_ioports (volatile ccsr_cpm_t * cpm)
  72. {
  73. int portnum;
  74. for (portnum = 0; portnum < 4; portnum++) {
  75. uint pmsk = 0,
  76. ppar = 0,
  77. psor = 0,
  78. pdir = 0,
  79. podr = 0,
  80. pdat = 0;
  81. iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0];
  82. iop_conf_t *eiopc = iopc + 32;
  83. uint msk = 1;
  84. /*
  85. * NOTE:
  86. * index 0 refers to pin 31,
  87. * index 31 refers to pin 0
  88. */
  89. while (iopc < eiopc) {
  90. if (iopc->conf) {
  91. pmsk |= msk;
  92. if (iopc->ppar)
  93. ppar |= msk;
  94. if (iopc->psor)
  95. psor |= msk;
  96. if (iopc->pdir)
  97. pdir |= msk;
  98. if (iopc->podr)
  99. podr |= msk;
  100. if (iopc->pdat)
  101. pdat |= msk;
  102. }
  103. msk <<= 1;
  104. iopc++;
  105. }
  106. if (pmsk != 0) {
  107. volatile ioport_t *iop = ioport_addr (cpm, portnum);
  108. uint tpmsk = ~pmsk;
  109. /*
  110. * the (somewhat confused) paragraph at the
  111. * bottom of page 35-5 warns that there might
  112. * be "unknown behaviour" when programming
  113. * PSORx and PDIRx, if PPARx = 1, so I
  114. * decided this meant I had to disable the
  115. * dedicated function first, and enable it
  116. * last.
  117. */
  118. iop->ppar &= tpmsk;
  119. iop->psor = (iop->psor & tpmsk) | psor;
  120. iop->podr = (iop->podr & tpmsk) | podr;
  121. iop->pdat = (iop->pdat & tpmsk) | pdat;
  122. iop->pdir = (iop->pdir & tpmsk) | pdir;
  123. iop->ppar |= ppar;
  124. }
  125. }
  126. }
  127. #endif
  128. #ifdef CONFIG_SYS_FSL_CPC
  129. static void enable_cpc(void)
  130. {
  131. int i;
  132. u32 size = 0;
  133. cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
  134. for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
  135. u32 cpccfg0 = in_be32(&cpc->cpccfg0);
  136. size += CPC_CFG0_SZ_K(cpccfg0);
  137. #ifdef CONFIG_RAMBOOT_PBL
  138. if (in_be32(&cpc->cpcsrcr0) & CPC_SRCR0_SRAMEN) {
  139. /* find and disable LAW of SRAM */
  140. struct law_entry law = find_law(CONFIG_SYS_INIT_L3_ADDR);
  141. if (law.index == -1) {
  142. printf("\nFatal error happened\n");
  143. return;
  144. }
  145. disable_law(law.index);
  146. clrbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_CDQ_SPEC_DIS);
  147. out_be32(&cpc->cpccsr0, 0);
  148. out_be32(&cpc->cpcsrcr0, 0);
  149. }
  150. #endif
  151. #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002
  152. setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_TAG_ECC_SCRUB_DIS);
  153. #endif
  154. #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003
  155. setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_DATA_ECC_SCRUB_DIS);
  156. #endif
  157. out_be32(&cpc->cpccsr0, CPC_CSR0_CE | CPC_CSR0_PE);
  158. /* Read back to sync write */
  159. in_be32(&cpc->cpccsr0);
  160. }
  161. printf("Corenet Platform Cache: %d KB enabled\n", size);
  162. }
  163. static void invalidate_cpc(void)
  164. {
  165. int i;
  166. cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
  167. for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
  168. /* skip CPC when it used as all SRAM */
  169. if (in_be32(&cpc->cpcsrcr0) & CPC_SRCR0_SRAMEN)
  170. continue;
  171. /* Flash invalidate the CPC and clear all the locks */
  172. out_be32(&cpc->cpccsr0, CPC_CSR0_FI | CPC_CSR0_LFC);
  173. while (in_be32(&cpc->cpccsr0) & (CPC_CSR0_FI | CPC_CSR0_LFC))
  174. ;
  175. }
  176. }
  177. #else
  178. #define enable_cpc()
  179. #define invalidate_cpc()
  180. #endif /* CONFIG_SYS_FSL_CPC */
  181. /*
  182. * Breathe some life into the CPU...
  183. *
  184. * Set up the memory map
  185. * initialize a bunch of registers
  186. */
  187. #ifdef CONFIG_FSL_CORENET
  188. static void corenet_tb_init(void)
  189. {
  190. volatile ccsr_rcpm_t *rcpm =
  191. (void *)(CONFIG_SYS_FSL_CORENET_RCPM_ADDR);
  192. volatile ccsr_pic_t *pic =
  193. (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
  194. u32 whoami = in_be32(&pic->whoami);
  195. /* Enable the timebase register for this core */
  196. out_be32(&rcpm->ctbenrl, (1 << whoami));
  197. }
  198. #endif
  199. void cpu_init_f (void)
  200. {
  201. extern void m8560_cpm_reset (void);
  202. #ifdef CONFIG_SYS_DCSRBAR_PHYS
  203. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  204. #endif
  205. #if defined(CONFIG_SECURE_BOOT)
  206. struct law_entry law;
  207. #endif
  208. #ifdef CONFIG_MPC8548
  209. ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
  210. uint svr = get_svr();
  211. /*
  212. * CPU2 errata workaround: A core hang possible while executing
  213. * a msync instruction and a snoopable transaction from an I/O
  214. * master tagged to make quick forward progress is present.
  215. * Fixed in silicon rev 2.1.
  216. */
  217. if ((SVR_MAJ(svr) == 1) || ((SVR_MAJ(svr) == 2 && SVR_MIN(svr) == 0x0)))
  218. out_be32(&ecm->eebpcr, in_be32(&ecm->eebpcr) | (1 << 16));
  219. #endif
  220. disable_tlb(14);
  221. disable_tlb(15);
  222. #if defined(CONFIG_SECURE_BOOT)
  223. /* Disable the LAW created for NOR flash by the PBI commands */
  224. law = find_law(CONFIG_SYS_PBI_FLASH_BASE);
  225. if (law.index != -1)
  226. disable_law(law.index);
  227. #endif
  228. #ifdef CONFIG_CPM2
  229. config_8560_ioports((ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR);
  230. #endif
  231. init_early_memctl_regs();
  232. #if defined(CONFIG_CPM2)
  233. m8560_cpm_reset();
  234. #endif
  235. #ifdef CONFIG_QE
  236. /* Config QE ioports */
  237. config_qe_ioports();
  238. #endif
  239. #if defined(CONFIG_FSL_DMA)
  240. dma_init();
  241. #endif
  242. #ifdef CONFIG_FSL_CORENET
  243. corenet_tb_init();
  244. #endif
  245. init_used_tlb_cams();
  246. /* Invalidate the CPC before DDR gets enabled */
  247. invalidate_cpc();
  248. #ifdef CONFIG_SYS_DCSRBAR_PHYS
  249. /* set DCSRCR so that DCSR space is 1G */
  250. setbits_be32(&gur->dcsrcr, FSL_CORENET_DCSR_SZ_1G);
  251. in_be32(&gur->dcsrcr);
  252. #endif
  253. }
  254. /* Implement a dummy function for those platforms w/o SERDES */
  255. static void __fsl_serdes__init(void)
  256. {
  257. return ;
  258. }
  259. __attribute__((weak, alias("__fsl_serdes__init"))) void fsl_serdes_init(void);
  260. #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
  261. int enable_cluster_l2(void)
  262. {
  263. int i = 0;
  264. u32 cluster;
  265. ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  266. struct ccsr_cluster_l2 __iomem *l2cache;
  267. cluster = in_be32(&gur->tp_cluster[i].lower);
  268. if (cluster & TP_CLUSTER_EOC)
  269. return 0;
  270. /* The first cache has already been set up, so skip it */
  271. i++;
  272. /* Look through the remaining clusters, and set up their caches */
  273. do {
  274. int j, cluster_valid = 0;
  275. l2cache = (void __iomem *)(CONFIG_SYS_FSL_CLUSTER_1_L2 + i * 0x40000);
  276. cluster = in_be32(&gur->tp_cluster[i].lower);
  277. /* check that at least one core/accel is enabled in cluster */
  278. for (j = 0; j < 4; j++) {
  279. u32 idx = (cluster >> (j*8)) & TP_CLUSTER_INIT_MASK;
  280. u32 type = in_be32(&gur->tp_ityp[idx]);
  281. if (type & TP_ITYP_AV)
  282. cluster_valid = 1;
  283. }
  284. if (cluster_valid) {
  285. /* set stash ID to (cluster) * 2 + 32 + 1 */
  286. clrsetbits_be32(&l2cache->l2csr1, 0xff, 32 + i * 2 + 1);
  287. printf("enable l2 for cluster %d %p\n", i, l2cache);
  288. out_be32(&l2cache->l2csr0, L2CSR0_L2FI|L2CSR0_L2LFC);
  289. while ((in_be32(&l2cache->l2csr0)
  290. & (L2CSR0_L2FI|L2CSR0_L2LFC)) != 0)
  291. ;
  292. out_be32(&l2cache->l2csr0, L2CSR0_L2E|L2CSR0_L2PE|L2CSR0_L2REP_MODE);
  293. }
  294. i++;
  295. } while (!(cluster & TP_CLUSTER_EOC));
  296. return 0;
  297. }
  298. #endif
  299. /*
  300. * Initialize L2 as cache.
  301. *
  302. * The newer 8548, etc, parts have twice as much cache, but
  303. * use the same bit-encoding as the older 8555, etc, parts.
  304. *
  305. */
  306. int cpu_init_r(void)
  307. {
  308. __maybe_unused u32 svr = get_svr();
  309. #ifdef CONFIG_SYS_LBC_LCRR
  310. fsl_lbc_t *lbc = (void __iomem *)LBC_BASE_ADDR;
  311. #endif
  312. #ifdef CONFIG_L2_CACHE
  313. ccsr_l2cache_t *l2cache = (void __iomem *)CONFIG_SYS_MPC85xx_L2_ADDR;
  314. #elif defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2)
  315. struct ccsr_cluster_l2 * l2cache = (void __iomem *)CONFIG_SYS_FSL_CLUSTER_1_L2;
  316. #endif
  317. #if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
  318. extern int spin_table_compat;
  319. const char *spin;
  320. #endif
  321. #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \
  322. defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
  323. /*
  324. * CPU22 and NMG_CPU_A011 share the same workaround.
  325. * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0
  326. * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
  327. * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1, both
  328. * fixed in 2.0. NMG_CPU_A011 is activated by default and can
  329. * be disabled by hwconfig with syntax:
  330. *
  331. * fsl_cpu_a011:disable
  332. */
  333. extern int enable_cpu_a011_workaround;
  334. #ifdef CONFIG_SYS_P4080_ERRATUM_CPU22
  335. enable_cpu_a011_workaround = (SVR_MAJ(svr) < 3);
  336. #else
  337. char buffer[HWCONFIG_BUFFER_SIZE];
  338. char *buf = NULL;
  339. int n, res;
  340. n = getenv_f("hwconfig", buffer, sizeof(buffer));
  341. if (n > 0)
  342. buf = buffer;
  343. res = hwconfig_arg_cmp_f("fsl_cpu_a011", "disable", buf);
  344. if (res > 0)
  345. enable_cpu_a011_workaround = 0;
  346. else {
  347. if (n >= HWCONFIG_BUFFER_SIZE) {
  348. printf("fsl_cpu_a011 was not found. hwconfig variable "
  349. "may be too long\n");
  350. }
  351. enable_cpu_a011_workaround =
  352. (SVR_SOC_VER(svr) == SVR_P4080 && SVR_MAJ(svr) < 3) ||
  353. (SVR_SOC_VER(svr) != SVR_P4080 && SVR_MAJ(svr) < 2);
  354. }
  355. #endif
  356. if (enable_cpu_a011_workaround) {
  357. flush_dcache();
  358. mtspr(L1CSR2, (mfspr(L1CSR2) | L1CSR2_DCWS));
  359. sync();
  360. }
  361. #endif
  362. #if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
  363. spin = getenv("spin_table_compat");
  364. if (spin && (*spin == 'n'))
  365. spin_table_compat = 0;
  366. else
  367. spin_table_compat = 1;
  368. #endif
  369. puts ("L2: ");
  370. #if defined(CONFIG_L2_CACHE)
  371. volatile uint cache_ctl;
  372. uint ver;
  373. u32 l2siz_field;
  374. ver = SVR_SOC_VER(svr);
  375. asm("msync;isync");
  376. cache_ctl = l2cache->l2ctl;
  377. #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
  378. if (cache_ctl & MPC85xx_L2CTL_L2E) {
  379. /* Clear L2 SRAM memory-mapped base address */
  380. out_be32(&l2cache->l2srbar0, 0x0);
  381. out_be32(&l2cache->l2srbar1, 0x0);
  382. /* set MBECCDIS=0, SBECCDIS=0 */
  383. clrbits_be32(&l2cache->l2errdis,
  384. (MPC85xx_L2ERRDIS_MBECC |
  385. MPC85xx_L2ERRDIS_SBECC));
  386. /* set L2E=0, L2SRAM=0 */
  387. clrbits_be32(&l2cache->l2ctl,
  388. (MPC85xx_L2CTL_L2E |
  389. MPC85xx_L2CTL_L2SRAM_ENTIRE));
  390. }
  391. #endif
  392. l2siz_field = (cache_ctl >> 28) & 0x3;
  393. switch (l2siz_field) {
  394. case 0x0:
  395. printf(" unknown size (0x%08x)\n", cache_ctl);
  396. return -1;
  397. break;
  398. case 0x1:
  399. if (ver == SVR_8540 || ver == SVR_8560 ||
  400. ver == SVR_8541 || ver == SVR_8555) {
  401. puts("128 KB ");
  402. /* set L2E=1, L2I=1, & L2BLKSZ=1 (128 Kbyte) */
  403. cache_ctl = 0xc4000000;
  404. } else {
  405. puts("256 KB ");
  406. cache_ctl = 0xc0000000; /* set L2E=1, L2I=1, & L2SRAM=0 */
  407. }
  408. break;
  409. case 0x2:
  410. if (ver == SVR_8540 || ver == SVR_8560 ||
  411. ver == SVR_8541 || ver == SVR_8555) {
  412. puts("256 KB ");
  413. /* set L2E=1, L2I=1, & L2BLKSZ=2 (256 Kbyte) */
  414. cache_ctl = 0xc8000000;
  415. } else {
  416. puts ("512 KB ");
  417. /* set L2E=1, L2I=1, & L2SRAM=0 */
  418. cache_ctl = 0xc0000000;
  419. }
  420. break;
  421. case 0x3:
  422. puts("1024 KB ");
  423. /* set L2E=1, L2I=1, & L2SRAM=0 */
  424. cache_ctl = 0xc0000000;
  425. break;
  426. }
  427. if (l2cache->l2ctl & MPC85xx_L2CTL_L2E) {
  428. puts("already enabled");
  429. #if defined(CONFIG_SYS_INIT_L2_ADDR) && defined(CONFIG_SYS_FLASH_BASE)
  430. u32 l2srbar = l2cache->l2srbar0;
  431. if (l2cache->l2ctl & MPC85xx_L2CTL_L2SRAM_ENTIRE
  432. && l2srbar >= CONFIG_SYS_FLASH_BASE) {
  433. l2srbar = CONFIG_SYS_INIT_L2_ADDR;
  434. l2cache->l2srbar0 = l2srbar;
  435. printf(", moving to 0x%08x", CONFIG_SYS_INIT_L2_ADDR);
  436. }
  437. #endif /* CONFIG_SYS_INIT_L2_ADDR */
  438. puts("\n");
  439. } else {
  440. asm("msync;isync");
  441. l2cache->l2ctl = cache_ctl; /* invalidate & enable */
  442. asm("msync;isync");
  443. puts("enabled\n");
  444. }
  445. #elif defined(CONFIG_BACKSIDE_L2_CACHE)
  446. if (SVR_SOC_VER(svr) == SVR_P2040) {
  447. puts("N/A\n");
  448. goto skip_l2;
  449. }
  450. u32 l2cfg0 = mfspr(SPRN_L2CFG0);
  451. /* invalidate the L2 cache */
  452. mtspr(SPRN_L2CSR0, (L2CSR0_L2FI|L2CSR0_L2LFC));
  453. while (mfspr(SPRN_L2CSR0) & (L2CSR0_L2FI|L2CSR0_L2LFC))
  454. ;
  455. #ifdef CONFIG_SYS_CACHE_STASHING
  456. /* set stash id to (coreID) * 2 + 32 + L2 (1) */
  457. mtspr(SPRN_L2CSR1, (32 + 1));
  458. #endif
  459. /* enable the cache */
  460. mtspr(SPRN_L2CSR0, CONFIG_SYS_INIT_L2CSR0);
  461. if (CONFIG_SYS_INIT_L2CSR0 & L2CSR0_L2E) {
  462. while (!(mfspr(SPRN_L2CSR0) & L2CSR0_L2E))
  463. ;
  464. printf("%d KB enabled\n", (l2cfg0 & 0x3fff) * 64);
  465. }
  466. skip_l2:
  467. #elif defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2)
  468. if (l2cache->l2csr0 & L2CSR0_L2E)
  469. printf("%d KB enabled\n", (l2cache->l2cfg0 & 0x3fff) * 64);
  470. enable_cluster_l2();
  471. #else
  472. puts("disabled\n");
  473. #endif
  474. enable_cpc();
  475. /* needs to be in ram since code uses global static vars */
  476. fsl_serdes_init();
  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_SYS_FSL_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. ccsr_usb_phy_t *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. ccsr_usb_phy_t *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. ccsr_usb_phy_t *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. }