mpc8569mds.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /*
  2. * Copyright 2009-2010 Freescale Semiconductor.
  3. *
  4. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <hwconfig.h>
  26. #include <pci.h>
  27. #include <asm/processor.h>
  28. #include <asm/mmu.h>
  29. #include <asm/cache.h>
  30. #include <asm/immap_85xx.h>
  31. #include <asm/fsl_pci.h>
  32. #include <asm/fsl_ddr_sdram.h>
  33. #include <asm/io.h>
  34. #include <spd_sdram.h>
  35. #include <i2c.h>
  36. #include <ioports.h>
  37. #include <libfdt.h>
  38. #include <fdt_support.h>
  39. #include <fsl_esdhc.h>
  40. #include "bcsr.h"
  41. #if defined(CONFIG_PQ_MDS_PIB)
  42. #include "../common/pq-mds-pib.h"
  43. #endif
  44. phys_size_t fixed_sdram(void);
  45. const qe_iop_conf_t qe_iop_conf_tab[] = {
  46. /* QE_MUX_MDC */
  47. {2, 31, 1, 0, 1}, /* QE_MUX_MDC */
  48. /* QE_MUX_MDIO */
  49. {2, 30, 3, 0, 2}, /* QE_MUX_MDIO */
  50. #if defined(CONFIG_SYS_UCC_RGMII_MODE)
  51. /* UCC_1_RGMII */
  52. {2, 11, 2, 0, 1}, /* CLK12 */
  53. {0, 0, 1, 0, 3}, /* ENET1_TXD0_SER1_TXD0 */
  54. {0, 1, 1, 0, 3}, /* ENET1_TXD1_SER1_TXD1 */
  55. {0, 2, 1, 0, 1}, /* ENET1_TXD2_SER1_TXD2 */
  56. {0, 3, 1, 0, 2}, /* ENET1_TXD3_SER1_TXD3 */
  57. {0, 6, 2, 0, 3}, /* ENET1_RXD0_SER1_RXD0 */
  58. {0, 7, 2, 0, 1}, /* ENET1_RXD1_SER1_RXD1 */
  59. {0, 8, 2, 0, 2}, /* ENET1_RXD2_SER1_RXD2 */
  60. {0, 9, 2, 0, 2}, /* ENET1_RXD3_SER1_RXD3 */
  61. {0, 4, 1, 0, 2}, /* ENET1_TX_EN_SER1_RTS_B */
  62. {0, 12, 2, 0, 3}, /* ENET1_RX_DV_SER1_CTS_B */
  63. {2, 8, 2, 0, 1}, /* ENET1_GRXCLK */
  64. {2, 20, 1, 0, 2}, /* ENET1_GTXCLK */
  65. /* UCC_2_RGMII */
  66. {2, 16, 2, 0, 3}, /* CLK17 */
  67. {0, 14, 1, 0, 2}, /* ENET2_TXD0_SER2_TXD0 */
  68. {0, 15, 1, 0, 2}, /* ENET2_TXD1_SER2_TXD1 */
  69. {0, 16, 1, 0, 1}, /* ENET2_TXD2_SER2_TXD2 */
  70. {0, 17, 1, 0, 1}, /* ENET2_TXD3_SER2_TXD3 */
  71. {0, 20, 2, 0, 2}, /* ENET2_RXD0_SER2_RXD0 */
  72. {0, 21, 2, 0, 1}, /* ENET2_RXD1_SER2_RXD1 */
  73. {0, 22, 2, 0, 1}, /* ENET2_RXD2_SER2_RXD2 */
  74. {0, 23, 2, 0, 1}, /* ENET2_RXD3_SER2_RXD3 */
  75. {0, 18, 1, 0, 2}, /* ENET2_TX_EN_SER2_RTS_B */
  76. {0, 26, 2, 0, 3}, /* ENET2_RX_DV_SER2_CTS_B */
  77. {2, 3, 2, 0, 1}, /* ENET2_GRXCLK */
  78. {2, 2, 1, 0, 2}, /* ENET2_GTXCLK */
  79. /* UCC_3_RGMII */
  80. {2, 11, 2, 0, 1}, /* CLK12 */
  81. {0, 29, 1, 0, 2}, /* ENET3_TXD0_SER3_TXD0 */
  82. {0, 30, 1, 0, 3}, /* ENET3_TXD1_SER3_TXD1 */
  83. {0, 31, 1, 0, 2}, /* ENET3_TXD2_SER3_TXD2 */
  84. {1, 0, 1, 0, 3}, /* ENET3_TXD3_SER3_TXD3 */
  85. {1, 3, 2, 0, 3}, /* ENET3_RXD0_SER3_RXD0 */
  86. {1, 4, 2, 0, 1}, /* ENET3_RXD1_SER3_RXD1 */
  87. {1, 5, 2, 0, 2}, /* ENET3_RXD2_SER3_RXD2 */
  88. {1, 6, 2, 0, 3}, /* ENET3_RXD3_SER3_RXD3 */
  89. {1, 1, 1, 0, 1}, /* ENET3_TX_EN_SER3_RTS_B */
  90. {1, 9, 2, 0, 3}, /* ENET3_RX_DV_SER3_CTS_B */
  91. {2, 9, 2, 0, 2}, /* ENET3_GRXCLK */
  92. {2, 25, 1, 0, 2}, /* ENET3_GTXCLK */
  93. /* UCC_4_RGMII */
  94. {2, 16, 2, 0, 3}, /* CLK17 */
  95. {1, 12, 1, 0, 2}, /* ENET4_TXD0_SER4_TXD0 */
  96. {1, 13, 1, 0, 2}, /* ENET4_TXD1_SER4_TXD1 */
  97. {1, 14, 1, 0, 1}, /* ENET4_TXD2_SER4_TXD2 */
  98. {1, 15, 1, 0, 2}, /* ENET4_TXD3_SER4_TXD3 */
  99. {1, 18, 2, 0, 2}, /* ENET4_RXD0_SER4_RXD0 */
  100. {1, 19, 2, 0, 1}, /* ENET4_RXD1_SER4_RXD1 */
  101. {1, 20, 2, 0, 1}, /* ENET4_RXD2_SER4_RXD2 */
  102. {1, 21, 2, 0, 2}, /* ENET4_RXD3_SER4_RXD3 */
  103. {1, 16, 1, 0, 2}, /* ENET4_TX_EN_SER4_RTS_B */
  104. {1, 24, 2, 0, 3}, /* ENET4_RX_DV_SER4_CTS_B */
  105. {2, 17, 2, 0, 2}, /* ENET4_GRXCLK */
  106. {2, 24, 1, 0, 2}, /* ENET4_GTXCLK */
  107. #elif defined(CONFIG_SYS_UCC_RMII_MODE)
  108. /* UCC_1_RMII */
  109. {2, 15, 2, 0, 1}, /* CLK16 */
  110. {0, 0, 1, 0, 3}, /* ENET1_TXD0_SER1_TXD0 */
  111. {0, 1, 1, 0, 3}, /* ENET1_TXD1_SER1_TXD1 */
  112. {0, 6, 2, 0, 3}, /* ENET1_RXD0_SER1_RXD0 */
  113. {0, 7, 2, 0, 1}, /* ENET1_RXD1_SER1_RXD1 */
  114. {0, 4, 1, 0, 2}, /* ENET1_TX_EN_SER1_RTS_B */
  115. {0, 12, 2, 0, 3}, /* ENET1_RX_DV_SER1_CTS_B */
  116. /* UCC_2_RMII */
  117. {2, 15, 2, 0, 1}, /* CLK16 */
  118. {0, 14, 1, 0, 2}, /* ENET2_TXD0_SER2_TXD0 */
  119. {0, 15, 1, 0, 2}, /* ENET2_TXD1_SER2_TXD1 */
  120. {0, 20, 2, 0, 2}, /* ENET2_RXD0_SER2_RXD0 */
  121. {0, 21, 2, 0, 1}, /* ENET2_RXD1_SER2_RXD1 */
  122. {0, 18, 1, 0, 2}, /* ENET2_TX_EN_SER2_RTS_B */
  123. {0, 26, 2, 0, 3}, /* ENET2_RX_DV_SER2_CTS_B */
  124. /* UCC_3_RMII */
  125. {2, 15, 2, 0, 1}, /* CLK16 */
  126. {0, 29, 1, 0, 2}, /* ENET3_TXD0_SER3_TXD0 */
  127. {0, 30, 1, 0, 3}, /* ENET3_TXD1_SER3_TXD1 */
  128. {1, 3, 2, 0, 3}, /* ENET3_RXD0_SER3_RXD0 */
  129. {1, 4, 2, 0, 1}, /* ENET3_RXD1_SER3_RXD1 */
  130. {1, 1, 1, 0, 1}, /* ENET3_TX_EN_SER3_RTS_B */
  131. {1, 9, 2, 0, 3}, /* ENET3_RX_DV_SER3_CTS_B */
  132. /* UCC_4_RMII */
  133. {2, 15, 2, 0, 1}, /* CLK16 */
  134. {1, 12, 1, 0, 2}, /* ENET4_TXD0_SER4_TXD0 */
  135. {1, 13, 1, 0, 2}, /* ENET4_TXD1_SER4_TXD1 */
  136. {1, 18, 2, 0, 2}, /* ENET4_RXD0_SER4_RXD0 */
  137. {1, 19, 2, 0, 1}, /* ENET4_RXD1_SER4_RXD1 */
  138. {1, 16, 1, 0, 2}, /* ENET4_TX_EN_SER4_RTS_B */
  139. {1, 24, 2, 0, 3}, /* ENET4_RX_DV_SER4_CTS_B */
  140. #endif
  141. /* UART1 is muxed with QE PortF bit [9-12].*/
  142. {5, 12, 2, 0, 3}, /* UART1_SIN */
  143. {5, 9, 1, 0, 3}, /* UART1_SOUT */
  144. {5, 10, 2, 0, 3}, /* UART1_CTS_B */
  145. {5, 11, 1, 0, 2}, /* UART1_RTS_B */
  146. /* QE UART */
  147. {0, 19, 1, 0, 2}, /* QEUART_TX */
  148. {1, 17, 2, 0, 3}, /* QEUART_RX */
  149. {0, 25, 1, 0, 1}, /* QEUART_RTS */
  150. {1, 23, 2, 0, 1}, /* QEUART_CTS */
  151. /* QE USB */
  152. {5, 3, 1, 0, 1}, /* USB_OE */
  153. {5, 4, 1, 0, 2}, /* USB_TP */
  154. {5, 5, 1, 0, 2}, /* USB_TN */
  155. {5, 6, 2, 0, 2}, /* USB_RP */
  156. {5, 7, 2, 0, 1}, /* USB_RX */
  157. {5, 8, 2, 0, 1}, /* USB_RN */
  158. {2, 4, 2, 0, 2}, /* CLK5 */
  159. /* SPI Flash, M25P40 */
  160. {4, 27, 3, 0, 1}, /* SPI_MOSI */
  161. {4, 28, 3, 0, 1}, /* SPI_MISO */
  162. {4, 29, 3, 0, 1}, /* SPI_CLK */
  163. {4, 30, 1, 0, 0}, /* SPI_SEL, GPIO */
  164. {0, 0, 0, 0, QE_IOP_TAB_END} /* END of table */
  165. };
  166. void local_bus_init(void);
  167. int board_early_init_f (void)
  168. {
  169. /*
  170. * Initialize local bus.
  171. */
  172. local_bus_init ();
  173. enable_8569mds_flash_write();
  174. #ifdef CONFIG_QE
  175. enable_8569mds_qe_uec();
  176. #endif
  177. #if CONFIG_SYS_I2C2_OFFSET
  178. /* Enable I2C2 signals instead of SD signals */
  179. volatile struct ccsr_gur *gur;
  180. gur = (struct ccsr_gur *)(CONFIG_SYS_IMMR + 0xe0000);
  181. gur->plppar1 &= ~PLPPAR1_I2C_BIT_MASK;
  182. gur->plppar1 |= PLPPAR1_I2C2_VAL;
  183. gur->plpdir1 &= ~PLPDIR1_I2C_BIT_MASK;
  184. gur->plpdir1 |= PLPDIR1_I2C2_VAL;
  185. disable_8569mds_brd_eeprom_write_protect();
  186. #endif
  187. return 0;
  188. }
  189. int board_early_init_r(void)
  190. {
  191. const unsigned int flashbase = CONFIG_SYS_NAND_BASE;
  192. const u8 flash_esel = 0;
  193. /*
  194. * Remap Boot flash to caching-inhibited
  195. * so that flash can be erased properly.
  196. */
  197. /* Flush d-cache and invalidate i-cache of any FLASH data */
  198. flush_dcache();
  199. invalidate_icache();
  200. /* invalidate existing TLB entry for flash */
  201. disable_tlb(flash_esel);
  202. set_tlb(1, flashbase, CONFIG_SYS_NAND_BASE, /* tlb, epn, rpn */
  203. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
  204. 0, flash_esel, /* ts, esel */
  205. BOOKE_PAGESZ_64M, 1); /* tsize, iprot */
  206. return 0;
  207. }
  208. int checkboard (void)
  209. {
  210. printf ("Board: 8569 MDS\n");
  211. return 0;
  212. }
  213. phys_size_t
  214. initdram(int board_type)
  215. {
  216. long dram_size = 0;
  217. puts("Initializing\n");
  218. #if defined(CONFIG_DDR_DLL)
  219. /*
  220. * Work around to stabilize DDR DLL MSYNC_IN.
  221. * Errata DDR9 seems to have been fixed.
  222. * This is now the workaround for Errata DDR11:
  223. * Override DLL = 1, Course Adj = 1, Tap Select = 0
  224. */
  225. volatile ccsr_gur_t *gur =
  226. (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  227. out_be32(&gur->ddrdllcr, 0x81000000);
  228. udelay(200);
  229. #endif
  230. #ifdef CONFIG_SPD_EEPROM
  231. dram_size = fsl_ddr_sdram();
  232. #else
  233. dram_size = fixed_sdram();
  234. #endif
  235. dram_size = setup_ddr_tlbs(dram_size / 0x100000);
  236. dram_size *= 0x100000;
  237. puts(" DDR: ");
  238. return dram_size;
  239. }
  240. #if !defined(CONFIG_SPD_EEPROM)
  241. phys_size_t fixed_sdram(void)
  242. {
  243. volatile ccsr_ddr_t *ddr = (ccsr_ddr_t *)CONFIG_SYS_MPC85xx_DDR_ADDR;
  244. uint d_init;
  245. out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS);
  246. out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG);
  247. out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3);
  248. out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0);
  249. out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1);
  250. out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2);
  251. out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_SDRAM_CFG);
  252. out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_SDRAM_CFG_2);
  253. out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_SDRAM_MODE);
  254. out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_SDRAM_MODE_2);
  255. out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_SDRAM_INTERVAL);
  256. out_be32(&ddr->sdram_data_init, CONFIG_SYS_DDR_DATA_INIT);
  257. out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_SDRAM_CLK_CNTL);
  258. out_be32(&ddr->timing_cfg_4, CONFIG_SYS_DDR_TIMING_4);
  259. out_be32(&ddr->timing_cfg_5, CONFIG_SYS_DDR_TIMING_5);
  260. out_be32(&ddr->ddr_zq_cntl, CONFIG_SYS_DDR_ZQ_CNTL);
  261. out_be32(&ddr->ddr_wrlvl_cntl, CONFIG_SYS_DDR_WRLVL_CNTL);
  262. out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_SDRAM_CFG_2);
  263. #if defined (CONFIG_DDR_ECC)
  264. out_be32(&ddr->err_int_en, CONFIG_SYS_DDR_ERR_INT_EN);
  265. out_be32(&ddr->err_disable, CONFIG_SYS_DDR_ERR_DIS);
  266. out_be32(&ddr->err_sbe, CONFIG_SYS_DDR_SBE);
  267. #endif
  268. udelay(500);
  269. out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL);
  270. #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  271. d_init = 1;
  272. debug("DDR - 1st controller: memory initializing\n");
  273. /*
  274. * Poll until memory is initialized.
  275. * 512 Meg at 400 might hit this 200 times or so.
  276. */
  277. while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0) {
  278. udelay(1000);
  279. }
  280. debug("DDR: memory initialized\n\n");
  281. udelay(500);
  282. #endif
  283. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  284. }
  285. #endif
  286. /*
  287. * Initialize Local Bus
  288. */
  289. void
  290. local_bus_init(void)
  291. {
  292. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  293. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  294. uint clkdiv;
  295. uint lbc_hz;
  296. sys_info_t sysinfo;
  297. get_sys_info(&sysinfo);
  298. clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
  299. lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
  300. out_be32(&gur->lbiuiplldcr1, 0x00078080);
  301. if (clkdiv == 16)
  302. out_be32(&gur->lbiuiplldcr0, 0x7c0f1bf0);
  303. else if (clkdiv == 8)
  304. out_be32(&gur->lbiuiplldcr0, 0x6c0f1bf0);
  305. else if (clkdiv == 4)
  306. out_be32(&gur->lbiuiplldcr0, 0x5c0f1bf0);
  307. out_be32(&lbc->lcrr, (u32)in_be32(&lbc->lcrr)| 0x00030000);
  308. }
  309. static void fdt_board_disable_serial(void *blob, bd_t *bd, const char *alias)
  310. {
  311. const char *status = "disabled";
  312. int off;
  313. int err;
  314. off = fdt_path_offset(blob, alias);
  315. if (off < 0) {
  316. printf("WARNING: could not find %s alias: %s.\n", alias,
  317. fdt_strerror(off));
  318. return;
  319. }
  320. err = fdt_setprop(blob, off, "status", status, strlen(status) + 1);
  321. if (err) {
  322. printf("WARNING: could not set status for serial0: %s.\n",
  323. fdt_strerror(err));
  324. return;
  325. }
  326. }
  327. /*
  328. * Because of an erratum in prototype boards it is impossible to use eSDHC
  329. * without disabling UART0 (which makes it quite easy to 'brick' the board
  330. * by simply issung 'setenv hwconfig esdhc', and not able to interact with
  331. * U-Boot anylonger).
  332. *
  333. * So, but default we assume that the board is a prototype, which is a most
  334. * safe assumption. There is no way to determine board revision from a
  335. * register, so we use hwconfig.
  336. */
  337. static int prototype_board(void)
  338. {
  339. if (hwconfig_subarg("board", "rev", NULL))
  340. return hwconfig_subarg_cmp("board", "rev", "prototype");
  341. return 1;
  342. }
  343. static int esdhc_disables_uart0(void)
  344. {
  345. return prototype_board() ||
  346. hwconfig_subarg_cmp("esdhc", "mode", "4-bits");
  347. }
  348. static void fdt_board_fixup_qe_uart(void *blob, bd_t *bd)
  349. {
  350. u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
  351. const char *devtype = "serial";
  352. const char *compat = "ucc_uart";
  353. const char *clk = "brg9";
  354. u32 portnum = 0;
  355. int off = -1;
  356. if (!hwconfig("qe_uart"))
  357. return;
  358. if (hwconfig("esdhc") && esdhc_disables_uart0()) {
  359. printf("QE UART: won't enable with esdhc.\n");
  360. return;
  361. }
  362. fdt_board_disable_serial(blob, bd, "serial1");
  363. while (1) {
  364. const u32 *idx;
  365. int len;
  366. off = fdt_node_offset_by_compatible(blob, off, "ucc_geth");
  367. if (off < 0) {
  368. printf("WARNING: unable to fixup device tree for "
  369. "QE UART\n");
  370. return;
  371. }
  372. idx = fdt_getprop(blob, off, "cell-index", &len);
  373. if (!idx || len != sizeof(*idx) || *idx != fdt32_to_cpu(2))
  374. continue;
  375. break;
  376. }
  377. fdt_setprop(blob, off, "device_type", devtype, strlen(devtype) + 1);
  378. fdt_setprop(blob, off, "compatible", compat, strlen(compat) + 1);
  379. fdt_setprop(blob, off, "tx-clock-name", clk, strlen(clk) + 1);
  380. fdt_setprop(blob, off, "rx-clock-name", clk, strlen(clk) + 1);
  381. fdt_setprop(blob, off, "port-number", &portnum, sizeof(portnum));
  382. setbits_8(&bcsr[15], BCSR15_QEUART_EN);
  383. }
  384. #ifdef CONFIG_FSL_ESDHC
  385. int board_mmc_init(bd_t *bd)
  386. {
  387. struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  388. u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
  389. u8 bcsr6 = BCSR6_SD_CARD_1BIT;
  390. if (!hwconfig("esdhc"))
  391. return 0;
  392. printf("Enabling eSDHC...\n"
  393. " For eSDHC to function, I2C2 ");
  394. if (esdhc_disables_uart0()) {
  395. printf("and UART0 should be disabled.\n");
  396. printf(" Redirecting stderr, stdout and stdin to UART1...\n");
  397. console_assign(stderr, "eserial1");
  398. console_assign(stdout, "eserial1");
  399. console_assign(stdin, "eserial1");
  400. printf("Switched to UART1 (initial log has been printed to "
  401. "UART0).\n");
  402. clrsetbits_be32(&gur->plppar1, PLPPAR1_UART0_BIT_MASK,
  403. PLPPAR1_ESDHC_4BITS_VAL);
  404. clrsetbits_be32(&gur->plpdir1, PLPDIR1_UART0_BIT_MASK,
  405. PLPDIR1_ESDHC_4BITS_VAL);
  406. bcsr6 |= BCSR6_SD_CARD_4BITS;
  407. } else {
  408. printf("should be disabled.\n");
  409. }
  410. /* Assign I2C2 signals to eSDHC. */
  411. clrsetbits_be32(&gur->plppar1, PLPPAR1_I2C_BIT_MASK,
  412. PLPPAR1_ESDHC_VAL);
  413. clrsetbits_be32(&gur->plpdir1, PLPDIR1_I2C_BIT_MASK,
  414. PLPDIR1_ESDHC_VAL);
  415. /* Mux I2C2 (and optionally UART0) signals to eSDHC. */
  416. setbits_8(&bcsr[6], bcsr6);
  417. return fsl_esdhc_mmc_init(bd);
  418. }
  419. static void fdt_board_fixup_esdhc(void *blob, bd_t *bd)
  420. {
  421. const char *status = "disabled";
  422. int off = -1;
  423. if (!hwconfig("esdhc"))
  424. return;
  425. if (esdhc_disables_uart0())
  426. fdt_board_disable_serial(blob, bd, "serial0");
  427. while (1) {
  428. const u32 *idx;
  429. int len;
  430. off = fdt_node_offset_by_compatible(blob, off, "fsl-i2c");
  431. if (off < 0)
  432. break;
  433. idx = fdt_getprop(blob, off, "cell-index", &len);
  434. if (!idx || len != sizeof(*idx))
  435. continue;
  436. if (*idx == 1) {
  437. fdt_setprop(blob, off, "status", status,
  438. strlen(status) + 1);
  439. break;
  440. }
  441. }
  442. if (hwconfig_subarg_cmp("esdhc", "mode", "4-bits")) {
  443. off = fdt_node_offset_by_compatible(blob, -1, "fsl,esdhc");
  444. if (off < 0) {
  445. printf("WARNING: could not find esdhc node\n");
  446. return;
  447. }
  448. fdt_delprop(blob, off, "sdhci,1-bit-only");
  449. }
  450. }
  451. #else
  452. static inline void fdt_board_fixup_esdhc(void *blob, bd_t *bd) {}
  453. #endif
  454. static void fdt_board_fixup_qe_usb(void *blob, bd_t *bd)
  455. {
  456. u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
  457. if (hwconfig_subarg_cmp("qe_usb", "speed", "low"))
  458. clrbits_8(&bcsr[17], BCSR17_nUSBLOWSPD);
  459. else
  460. setbits_8(&bcsr[17], BCSR17_nUSBLOWSPD);
  461. if (hwconfig_subarg_cmp("qe_usb", "mode", "peripheral")) {
  462. clrbits_8(&bcsr[17], BCSR17_USBVCC);
  463. clrbits_8(&bcsr[17], BCSR17_USBMODE);
  464. do_fixup_by_compat(blob, "fsl,mpc8569-qe-usb", "mode",
  465. "peripheral", sizeof("peripheral"), 1);
  466. } else {
  467. setbits_8(&bcsr[17], BCSR17_USBVCC);
  468. setbits_8(&bcsr[17], BCSR17_USBMODE);
  469. }
  470. clrbits_8(&bcsr[17], BCSR17_nUSBEN);
  471. }
  472. #ifdef CONFIG_PCIE1
  473. static struct pci_controller pcie1_hose;
  474. #endif /* CONFIG_PCIE1 */
  475. #ifdef CONFIG_PCI
  476. void pci_init_board(void)
  477. {
  478. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  479. struct fsl_pci_info pci_info[1];
  480. u32 devdisr, pordevsr, io_sel;
  481. int first_free_busno = 0;
  482. int num = 0;
  483. int pcie_ep, pcie_configured;
  484. devdisr = in_be32(&gur->devdisr);
  485. pordevsr = in_be32(&gur->pordevsr);
  486. io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  487. debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
  488. #if defined(CONFIG_PQ_MDS_PIB)
  489. pib_init();
  490. #endif
  491. #ifdef CONFIG_PCIE1
  492. pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_1, io_sel);
  493. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  494. SET_STD_PCIE_INFO(pci_info[num], 1);
  495. pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs);
  496. printf (" PCIE1 connected to Slot as %s (base addr %lx)\n",
  497. pcie_ep ? "Endpoint" : "Root Complex",
  498. pci_info[num].regs);
  499. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  500. &pcie1_hose, first_free_busno);
  501. } else {
  502. printf (" PCIE1: disabled\n");
  503. }
  504. puts("\n");
  505. #else
  506. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
  507. #endif
  508. }
  509. #endif /* CONFIG_PCI */
  510. #if defined(CONFIG_OF_BOARD_SETUP)
  511. void ft_board_setup(void *blob, bd_t *bd)
  512. {
  513. #if defined(CONFIG_SYS_UCC_RMII_MODE)
  514. int nodeoff, off, err;
  515. unsigned int val;
  516. const u32 *ph;
  517. const u32 *index;
  518. /* fixup device tree for supporting rmii mode */
  519. nodeoff = -1;
  520. while ((nodeoff = fdt_node_offset_by_compatible(blob, nodeoff,
  521. "ucc_geth")) >= 0) {
  522. err = fdt_setprop_string(blob, nodeoff, "tx-clock-name",
  523. "clk16");
  524. if (err < 0) {
  525. printf("WARNING: could not set tx-clock-name %s.\n",
  526. fdt_strerror(err));
  527. break;
  528. }
  529. err = fdt_setprop_string(blob, nodeoff, "phy-connection-type",
  530. "rmii");
  531. if (err < 0) {
  532. printf("WARNING: could not set phy-connection-type "
  533. "%s.\n", fdt_strerror(err));
  534. break;
  535. }
  536. index = fdt_getprop(blob, nodeoff, "cell-index", 0);
  537. if (index == NULL) {
  538. printf("WARNING: could not get cell-index of ucc\n");
  539. break;
  540. }
  541. ph = fdt_getprop(blob, nodeoff, "phy-handle", 0);
  542. if (ph == NULL) {
  543. printf("WARNING: could not get phy-handle of ucc\n");
  544. break;
  545. }
  546. off = fdt_node_offset_by_phandle(blob, *ph);
  547. if (off < 0) {
  548. printf("WARNING: could not get phy node %s.\n",
  549. fdt_strerror(err));
  550. break;
  551. }
  552. val = 0x7 + *index; /* RMII phy address starts from 0x8 */
  553. err = fdt_setprop(blob, off, "reg", &val, sizeof(u32));
  554. if (err < 0) {
  555. printf("WARNING: could not set reg for phy-handle "
  556. "%s.\n", fdt_strerror(err));
  557. break;
  558. }
  559. }
  560. #endif
  561. ft_cpu_setup(blob, bd);
  562. FT_FSL_PCI_SETUP;
  563. fdt_board_fixup_esdhc(blob, bd);
  564. fdt_board_fixup_qe_uart(blob, bd);
  565. fdt_board_fixup_qe_usb(blob, bd);
  566. }
  567. #endif