cpu_init.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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. l2cache = (void __iomem *)(CONFIG_SYS_FSL_CLUSTER_1_L2 + i * 0x40000);
  275. cluster = in_be32(&gur->tp_cluster[i].lower);
  276. /* set stash ID to (cluster) * 2 + 32 + 1 */
  277. clrsetbits_be32(&l2cache->l2csr1, 0xff, 32 + i * 2 + 1);
  278. printf("enable l2 for cluster %d %p\n", i, l2cache);
  279. out_be32(&l2cache->l2csr0, L2CSR0_L2FI|L2CSR0_L2LFC);
  280. while ((in_be32(&l2cache->l2csr0) &
  281. (L2CSR0_L2FI|L2CSR0_L2LFC)) != 0)
  282. ;
  283. out_be32(&l2cache->l2csr0, L2CSR0_L2E);
  284. i++;
  285. } while (!(cluster & TP_CLUSTER_EOC));
  286. return 0;
  287. }
  288. #endif
  289. /*
  290. * Initialize L2 as cache.
  291. *
  292. * The newer 8548, etc, parts have twice as much cache, but
  293. * use the same bit-encoding as the older 8555, etc, parts.
  294. *
  295. */
  296. int cpu_init_r(void)
  297. {
  298. __maybe_unused u32 svr = get_svr();
  299. #ifdef CONFIG_SYS_LBC_LCRR
  300. fsl_lbc_t *lbc = (void __iomem *)LBC_BASE_ADDR;
  301. #endif
  302. #ifdef CONFIG_L2_CACHE
  303. ccsr_l2cache_t *l2cache = (void __iomem *)CONFIG_SYS_MPC85xx_L2_ADDR;
  304. #elif defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2)
  305. struct ccsr_cluster_l2 * l2cache = (void __iomem *)CONFIG_SYS_FSL_CLUSTER_1_L2;
  306. #endif
  307. #ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
  308. extern int spin_table_compat;
  309. const char *spin;
  310. #endif
  311. #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \
  312. defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
  313. /*
  314. * CPU22 and NMG_CPU_A011 share the same workaround.
  315. * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0
  316. * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
  317. * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1, both
  318. * fixed in 2.0. NMG_CPU_A011 is activated by default and can
  319. * be disabled by hwconfig with syntax:
  320. *
  321. * fsl_cpu_a011:disable
  322. */
  323. extern int enable_cpu_a011_workaround;
  324. #ifdef CONFIG_SYS_P4080_ERRATUM_CPU22
  325. enable_cpu_a011_workaround = (SVR_MAJ(svr) < 3);
  326. #else
  327. char buffer[HWCONFIG_BUFFER_SIZE];
  328. char *buf = NULL;
  329. int n, res;
  330. n = getenv_f("hwconfig", buffer, sizeof(buffer));
  331. if (n > 0)
  332. buf = buffer;
  333. res = hwconfig_arg_cmp_f("fsl_cpu_a011", "disable", buf);
  334. if (res > 0)
  335. enable_cpu_a011_workaround = 0;
  336. else {
  337. if (n >= HWCONFIG_BUFFER_SIZE) {
  338. printf("fsl_cpu_a011 was not found. hwconfig variable "
  339. "may be too long\n");
  340. }
  341. enable_cpu_a011_workaround =
  342. (SVR_SOC_VER(svr) == SVR_P4080 && SVR_MAJ(svr) < 3) ||
  343. (SVR_SOC_VER(svr) != SVR_P4080 && SVR_MAJ(svr) < 2);
  344. }
  345. #endif
  346. if (enable_cpu_a011_workaround) {
  347. flush_dcache();
  348. mtspr(L1CSR2, (mfspr(L1CSR2) | L1CSR2_DCWS));
  349. sync();
  350. }
  351. #endif
  352. #ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
  353. spin = getenv("spin_table_compat");
  354. if (spin && (*spin == 'n'))
  355. spin_table_compat = 0;
  356. else
  357. spin_table_compat = 1;
  358. #endif
  359. puts ("L2: ");
  360. #if defined(CONFIG_L2_CACHE)
  361. volatile uint cache_ctl;
  362. uint ver;
  363. u32 l2siz_field;
  364. ver = SVR_SOC_VER(svr);
  365. asm("msync;isync");
  366. cache_ctl = l2cache->l2ctl;
  367. #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
  368. if (cache_ctl & MPC85xx_L2CTL_L2E) {
  369. /* Clear L2 SRAM memory-mapped base address */
  370. out_be32(&l2cache->l2srbar0, 0x0);
  371. out_be32(&l2cache->l2srbar1, 0x0);
  372. /* set MBECCDIS=0, SBECCDIS=0 */
  373. clrbits_be32(&l2cache->l2errdis,
  374. (MPC85xx_L2ERRDIS_MBECC |
  375. MPC85xx_L2ERRDIS_SBECC));
  376. /* set L2E=0, L2SRAM=0 */
  377. clrbits_be32(&l2cache->l2ctl,
  378. (MPC85xx_L2CTL_L2E |
  379. MPC85xx_L2CTL_L2SRAM_ENTIRE));
  380. }
  381. #endif
  382. l2siz_field = (cache_ctl >> 28) & 0x3;
  383. switch (l2siz_field) {
  384. case 0x0:
  385. printf(" unknown size (0x%08x)\n", cache_ctl);
  386. return -1;
  387. break;
  388. case 0x1:
  389. if (ver == SVR_8540 || ver == SVR_8560 ||
  390. ver == SVR_8541 || ver == SVR_8555) {
  391. puts("128 KB ");
  392. /* set L2E=1, L2I=1, & L2BLKSZ=1 (128 Kbyte) */
  393. cache_ctl = 0xc4000000;
  394. } else {
  395. puts("256 KB ");
  396. cache_ctl = 0xc0000000; /* set L2E=1, L2I=1, & L2SRAM=0 */
  397. }
  398. break;
  399. case 0x2:
  400. if (ver == SVR_8540 || ver == SVR_8560 ||
  401. ver == SVR_8541 || ver == SVR_8555) {
  402. puts("256 KB ");
  403. /* set L2E=1, L2I=1, & L2BLKSZ=2 (256 Kbyte) */
  404. cache_ctl = 0xc8000000;
  405. } else {
  406. puts ("512 KB ");
  407. /* set L2E=1, L2I=1, & L2SRAM=0 */
  408. cache_ctl = 0xc0000000;
  409. }
  410. break;
  411. case 0x3:
  412. puts("1024 KB ");
  413. /* set L2E=1, L2I=1, & L2SRAM=0 */
  414. cache_ctl = 0xc0000000;
  415. break;
  416. }
  417. if (l2cache->l2ctl & MPC85xx_L2CTL_L2E) {
  418. puts("already enabled");
  419. #if defined(CONFIG_SYS_INIT_L2_ADDR) && defined(CONFIG_SYS_FLASH_BASE)
  420. u32 l2srbar = l2cache->l2srbar0;
  421. if (l2cache->l2ctl & MPC85xx_L2CTL_L2SRAM_ENTIRE
  422. && l2srbar >= CONFIG_SYS_FLASH_BASE) {
  423. l2srbar = CONFIG_SYS_INIT_L2_ADDR;
  424. l2cache->l2srbar0 = l2srbar;
  425. printf(", moving to 0x%08x", CONFIG_SYS_INIT_L2_ADDR);
  426. }
  427. #endif /* CONFIG_SYS_INIT_L2_ADDR */
  428. puts("\n");
  429. } else {
  430. asm("msync;isync");
  431. l2cache->l2ctl = cache_ctl; /* invalidate & enable */
  432. asm("msync;isync");
  433. puts("enabled\n");
  434. }
  435. #elif defined(CONFIG_BACKSIDE_L2_CACHE)
  436. if (SVR_SOC_VER(svr) == SVR_P2040) {
  437. puts("N/A\n");
  438. goto skip_l2;
  439. }
  440. u32 l2cfg0 = mfspr(SPRN_L2CFG0);
  441. /* invalidate the L2 cache */
  442. mtspr(SPRN_L2CSR0, (L2CSR0_L2FI|L2CSR0_L2LFC));
  443. while (mfspr(SPRN_L2CSR0) & (L2CSR0_L2FI|L2CSR0_L2LFC))
  444. ;
  445. #ifdef CONFIG_SYS_CACHE_STASHING
  446. /* set stash id to (coreID) * 2 + 32 + L2 (1) */
  447. mtspr(SPRN_L2CSR1, (32 + 1));
  448. #endif
  449. /* enable the cache */
  450. mtspr(SPRN_L2CSR0, CONFIG_SYS_INIT_L2CSR0);
  451. if (CONFIG_SYS_INIT_L2CSR0 & L2CSR0_L2E) {
  452. while (!(mfspr(SPRN_L2CSR0) & L2CSR0_L2E))
  453. ;
  454. printf("%d KB enabled\n", (l2cfg0 & 0x3fff) * 64);
  455. }
  456. skip_l2:
  457. #elif defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2)
  458. if (l2cache->l2csr0 & L2CSR0_L2E)
  459. printf("%d KB enabled\n", (l2cache->l2cfg0 & 0x3fff) * 64);
  460. enable_cluster_l2();
  461. #else
  462. puts("disabled\n");
  463. #endif
  464. enable_cpc();
  465. /* needs to be in ram since code uses global static vars */
  466. fsl_serdes_init();
  467. #ifdef CONFIG_SYS_SRIO
  468. srio_init();
  469. #ifdef CONFIG_SYS_FSL_SRIO_PCIE_BOOT_MASTER
  470. char *s = getenv("bootmaster");
  471. if (s) {
  472. if (!strcmp(s, "SRIO1")) {
  473. srio_boot_master(1);
  474. srio_boot_master_release_slave(1);
  475. }
  476. if (!strcmp(s, "SRIO2")) {
  477. srio_boot_master(2);
  478. srio_boot_master_release_slave(2);
  479. }
  480. }
  481. #endif
  482. #endif
  483. #if defined(CONFIG_MP)
  484. setup_mp();
  485. #endif
  486. #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC13
  487. {
  488. if (SVR_MAJ(svr) < 3) {
  489. void *p;
  490. p = (void *)CONFIG_SYS_DCSRBAR + 0x20520;
  491. setbits_be32(p, 1 << (31 - 14));
  492. }
  493. }
  494. #endif
  495. #ifdef CONFIG_SYS_LBC_LCRR
  496. /*
  497. * Modify the CLKDIV field of LCRR register to improve the writing
  498. * speed for NOR flash.
  499. */
  500. clrsetbits_be32(&lbc->lcrr, LCRR_CLKDIV, CONFIG_SYS_LBC_LCRR);
  501. __raw_readl(&lbc->lcrr);
  502. isync();
  503. #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103
  504. udelay(100);
  505. #endif
  506. #endif
  507. #ifdef CONFIG_SYS_FSL_USB1_PHY_ENABLE
  508. {
  509. ccsr_usb_phy_t *usb_phy1 =
  510. (void *)CONFIG_SYS_MPC85xx_USB1_PHY_ADDR;
  511. out_be32(&usb_phy1->usb_enable_override,
  512. CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE);
  513. }
  514. #endif
  515. #ifdef CONFIG_SYS_FSL_USB2_PHY_ENABLE
  516. {
  517. ccsr_usb_phy_t *usb_phy2 =
  518. (void *)CONFIG_SYS_MPC85xx_USB2_PHY_ADDR;
  519. out_be32(&usb_phy2->usb_enable_override,
  520. CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE);
  521. }
  522. #endif
  523. #ifdef CONFIG_FMAN_ENET
  524. fman_enet_init();
  525. #endif
  526. #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001)
  527. /*
  528. * For P1022/1013 Rev1.0 silicon, after power on SATA host
  529. * controller is configured in legacy mode instead of the
  530. * expected enterprise mode. Software needs to clear bit[28]
  531. * of HControl register to change to enterprise mode from
  532. * legacy mode. We assume that the controller is offline.
  533. */
  534. if (IS_SVR_REV(svr, 1, 0) &&
  535. ((SVR_SOC_VER(svr) == SVR_P1022) ||
  536. (SVR_SOC_VER(svr) == SVR_P1013))) {
  537. fsl_sata_reg_t *reg;
  538. /* first SATA controller */
  539. reg = (void *)CONFIG_SYS_MPC85xx_SATA1_ADDR;
  540. clrbits_le32(&reg->hcontrol, HCONTROL_ENTERPRISE_EN);
  541. /* second SATA controller */
  542. reg = (void *)CONFIG_SYS_MPC85xx_SATA2_ADDR;
  543. clrbits_le32(&reg->hcontrol, HCONTROL_ENTERPRISE_EN);
  544. }
  545. #endif
  546. return 0;
  547. }
  548. extern void setup_ivors(void);
  549. void arch_preboot_os(void)
  550. {
  551. u32 msr;
  552. /*
  553. * We are changing interrupt offsets and are about to boot the OS so
  554. * we need to make sure we disable all async interrupts. EE is already
  555. * disabled by the time we get called.
  556. */
  557. msr = mfmsr();
  558. msr &= ~(MSR_ME|MSR_CE);
  559. mtmsr(msr);
  560. setup_ivors();
  561. }
  562. #if defined(CONFIG_CMD_SATA) && defined(CONFIG_FSL_SATA)
  563. int sata_initialize(void)
  564. {
  565. if (is_serdes_configured(SATA1) || is_serdes_configured(SATA2))
  566. return __sata_initialize();
  567. return 1;
  568. }
  569. #endif
  570. void cpu_secondary_init_r(void)
  571. {
  572. #ifdef CONFIG_QE
  573. uint qe_base = CONFIG_SYS_IMMR + 0x00080000; /* QE immr base */
  574. #ifdef CONFIG_SYS_QE_FMAN_FW_IN_NAND
  575. int ret;
  576. size_t fw_length = CONFIG_SYS_QE_FMAN_FW_LENGTH;
  577. /* load QE firmware from NAND flash to DDR first */
  578. ret = nand_read(&nand_info[0], (loff_t)CONFIG_SYS_QE_FMAN_FW_IN_NAND,
  579. &fw_length, (u_char *)CONFIG_SYS_QE_FMAN_FW_ADDR);
  580. if (ret && ret == -EUCLEAN) {
  581. printf ("NAND read for QE firmware at offset %x failed %d\n",
  582. CONFIG_SYS_QE_FMAN_FW_IN_NAND, ret);
  583. }
  584. #endif
  585. qe_init(qe_base);
  586. qe_reset();
  587. #endif
  588. }