cpu_init.c 16 KB

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