mpc8569mds.c 17 KB

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