mpc8569mds.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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 "bcsr.h"
  42. #if defined(CONFIG_PQ_MDS_PIB)
  43. #include "../common/pq-mds-pib.h"
  44. #endif
  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. #if !defined(CONFIG_SPD_EEPROM)
  214. phys_size_t fixed_sdram(void)
  215. {
  216. volatile ccsr_ddr_t *ddr = (ccsr_ddr_t *)CONFIG_SYS_MPC85xx_DDR_ADDR;
  217. uint d_init;
  218. out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS);
  219. out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG);
  220. out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3);
  221. out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0);
  222. out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1);
  223. out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2);
  224. out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_SDRAM_CFG);
  225. out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_SDRAM_CFG_2);
  226. out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_SDRAM_MODE);
  227. out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_SDRAM_MODE_2);
  228. out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_SDRAM_INTERVAL);
  229. out_be32(&ddr->sdram_data_init, CONFIG_SYS_DDR_DATA_INIT);
  230. out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_SDRAM_CLK_CNTL);
  231. out_be32(&ddr->timing_cfg_4, CONFIG_SYS_DDR_TIMING_4);
  232. out_be32(&ddr->timing_cfg_5, CONFIG_SYS_DDR_TIMING_5);
  233. out_be32(&ddr->ddr_zq_cntl, CONFIG_SYS_DDR_ZQ_CNTL);
  234. out_be32(&ddr->ddr_wrlvl_cntl, CONFIG_SYS_DDR_WRLVL_CNTL);
  235. out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_SDRAM_CFG_2);
  236. #if defined (CONFIG_DDR_ECC)
  237. out_be32(&ddr->err_int_en, CONFIG_SYS_DDR_ERR_INT_EN);
  238. out_be32(&ddr->err_disable, CONFIG_SYS_DDR_ERR_DIS);
  239. out_be32(&ddr->err_sbe, CONFIG_SYS_DDR_SBE);
  240. #endif
  241. udelay(500);
  242. out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL);
  243. #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  244. d_init = 1;
  245. debug("DDR - 1st controller: memory initializing\n");
  246. /*
  247. * Poll until memory is initialized.
  248. * 512 Meg at 400 might hit this 200 times or so.
  249. */
  250. while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0) {
  251. udelay(1000);
  252. }
  253. debug("DDR: memory initialized\n\n");
  254. udelay(500);
  255. #endif
  256. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  257. }
  258. #endif
  259. /*
  260. * Initialize Local Bus
  261. */
  262. void
  263. local_bus_init(void)
  264. {
  265. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  266. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  267. uint clkdiv;
  268. uint lbc_hz;
  269. sys_info_t sysinfo;
  270. get_sys_info(&sysinfo);
  271. clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
  272. lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
  273. out_be32(&gur->lbiuiplldcr1, 0x00078080);
  274. if (clkdiv == 16)
  275. out_be32(&gur->lbiuiplldcr0, 0x7c0f1bf0);
  276. else if (clkdiv == 8)
  277. out_be32(&gur->lbiuiplldcr0, 0x6c0f1bf0);
  278. else if (clkdiv == 4)
  279. out_be32(&gur->lbiuiplldcr0, 0x5c0f1bf0);
  280. out_be32(&lbc->lcrr, (u32)in_be32(&lbc->lcrr)| 0x00030000);
  281. }
  282. static void fdt_board_disable_serial(void *blob, bd_t *bd, const char *alias)
  283. {
  284. const char *status = "disabled";
  285. int off;
  286. int err;
  287. off = fdt_path_offset(blob, alias);
  288. if (off < 0) {
  289. printf("WARNING: could not find %s alias: %s.\n", alias,
  290. fdt_strerror(off));
  291. return;
  292. }
  293. err = fdt_setprop(blob, off, "status", status, strlen(status) + 1);
  294. if (err) {
  295. printf("WARNING: could not set status for serial0: %s.\n",
  296. fdt_strerror(err));
  297. return;
  298. }
  299. }
  300. /*
  301. * Because of an erratum in prototype boards it is impossible to use eSDHC
  302. * without disabling UART0 (which makes it quite easy to 'brick' the board
  303. * by simply issung 'setenv hwconfig esdhc', and not able to interact with
  304. * U-Boot anylonger).
  305. *
  306. * So, but default we assume that the board is a prototype, which is a most
  307. * safe assumption. There is no way to determine board revision from a
  308. * register, so we use hwconfig.
  309. */
  310. static int prototype_board(void)
  311. {
  312. if (hwconfig_subarg("board", "rev", NULL))
  313. return hwconfig_subarg_cmp("board", "rev", "prototype");
  314. return 1;
  315. }
  316. static int esdhc_disables_uart0(void)
  317. {
  318. return prototype_board() ||
  319. hwconfig_subarg_cmp("esdhc", "mode", "4-bits");
  320. }
  321. static void fdt_board_fixup_qe_uart(void *blob, bd_t *bd)
  322. {
  323. u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
  324. const char *devtype = "serial";
  325. const char *compat = "ucc_uart";
  326. const char *clk = "brg9";
  327. u32 portnum = 0;
  328. int off = -1;
  329. if (!hwconfig("qe_uart"))
  330. return;
  331. if (hwconfig("esdhc") && esdhc_disables_uart0()) {
  332. printf("QE UART: won't enable with esdhc.\n");
  333. return;
  334. }
  335. fdt_board_disable_serial(blob, bd, "serial1");
  336. while (1) {
  337. const u32 *idx;
  338. int len;
  339. off = fdt_node_offset_by_compatible(blob, off, "ucc_geth");
  340. if (off < 0) {
  341. printf("WARNING: unable to fixup device tree for "
  342. "QE UART\n");
  343. return;
  344. }
  345. idx = fdt_getprop(blob, off, "cell-index", &len);
  346. if (!idx || len != sizeof(*idx) || *idx != fdt32_to_cpu(2))
  347. continue;
  348. break;
  349. }
  350. fdt_setprop(blob, off, "device_type", devtype, strlen(devtype) + 1);
  351. fdt_setprop(blob, off, "compatible", compat, strlen(compat) + 1);
  352. fdt_setprop(blob, off, "tx-clock-name", clk, strlen(clk) + 1);
  353. fdt_setprop(blob, off, "rx-clock-name", clk, strlen(clk) + 1);
  354. fdt_setprop(blob, off, "port-number", &portnum, sizeof(portnum));
  355. setbits_8(&bcsr[15], BCSR15_QEUART_EN);
  356. }
  357. #ifdef CONFIG_FSL_ESDHC
  358. int board_mmc_init(bd_t *bd)
  359. {
  360. struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  361. u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
  362. u8 bcsr6 = BCSR6_SD_CARD_1BIT;
  363. if (!hwconfig("esdhc"))
  364. return 0;
  365. printf("Enabling eSDHC...\n"
  366. " For eSDHC to function, I2C2 ");
  367. if (esdhc_disables_uart0()) {
  368. printf("and UART0 should be disabled.\n");
  369. printf(" Redirecting stderr, stdout and stdin to UART1...\n");
  370. console_assign(stderr, "eserial1");
  371. console_assign(stdout, "eserial1");
  372. console_assign(stdin, "eserial1");
  373. printf("Switched to UART1 (initial log has been printed to "
  374. "UART0).\n");
  375. clrsetbits_be32(&gur->plppar1, PLPPAR1_UART0_BIT_MASK,
  376. PLPPAR1_ESDHC_4BITS_VAL);
  377. clrsetbits_be32(&gur->plpdir1, PLPDIR1_UART0_BIT_MASK,
  378. PLPDIR1_ESDHC_4BITS_VAL);
  379. bcsr6 |= BCSR6_SD_CARD_4BITS;
  380. } else {
  381. printf("should be disabled.\n");
  382. }
  383. /* Assign I2C2 signals to eSDHC. */
  384. clrsetbits_be32(&gur->plppar1, PLPPAR1_I2C_BIT_MASK,
  385. PLPPAR1_ESDHC_VAL);
  386. clrsetbits_be32(&gur->plpdir1, PLPDIR1_I2C_BIT_MASK,
  387. PLPDIR1_ESDHC_VAL);
  388. /* Mux I2C2 (and optionally UART0) signals to eSDHC. */
  389. setbits_8(&bcsr[6], bcsr6);
  390. return fsl_esdhc_mmc_init(bd);
  391. }
  392. static void fdt_board_fixup_esdhc(void *blob, bd_t *bd)
  393. {
  394. const char *status = "disabled";
  395. int off = -1;
  396. if (!hwconfig("esdhc"))
  397. return;
  398. if (esdhc_disables_uart0())
  399. fdt_board_disable_serial(blob, bd, "serial0");
  400. while (1) {
  401. const u32 *idx;
  402. int len;
  403. off = fdt_node_offset_by_compatible(blob, off, "fsl-i2c");
  404. if (off < 0)
  405. break;
  406. idx = fdt_getprop(blob, off, "cell-index", &len);
  407. if (!idx || len != sizeof(*idx))
  408. continue;
  409. if (*idx == 1) {
  410. fdt_setprop(blob, off, "status", status,
  411. strlen(status) + 1);
  412. break;
  413. }
  414. }
  415. if (hwconfig_subarg_cmp("esdhc", "mode", "4-bits")) {
  416. off = fdt_node_offset_by_compatible(blob, -1, "fsl,esdhc");
  417. if (off < 0) {
  418. printf("WARNING: could not find esdhc node\n");
  419. return;
  420. }
  421. fdt_delprop(blob, off, "sdhci,1-bit-only");
  422. }
  423. }
  424. #else
  425. static inline void fdt_board_fixup_esdhc(void *blob, bd_t *bd) {}
  426. #endif
  427. static void fdt_board_fixup_qe_usb(void *blob, bd_t *bd)
  428. {
  429. u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
  430. if (hwconfig_subarg_cmp("qe_usb", "speed", "low"))
  431. clrbits_8(&bcsr[17], BCSR17_nUSBLOWSPD);
  432. else
  433. setbits_8(&bcsr[17], BCSR17_nUSBLOWSPD);
  434. if (hwconfig_subarg_cmp("qe_usb", "mode", "peripheral")) {
  435. clrbits_8(&bcsr[17], BCSR17_USBVCC);
  436. clrbits_8(&bcsr[17], BCSR17_USBMODE);
  437. do_fixup_by_compat(blob, "fsl,mpc8569-qe-usb", "mode",
  438. "peripheral", sizeof("peripheral"), 1);
  439. } else {
  440. setbits_8(&bcsr[17], BCSR17_USBVCC);
  441. setbits_8(&bcsr[17], BCSR17_USBMODE);
  442. }
  443. clrbits_8(&bcsr[17], BCSR17_nUSBEN);
  444. }
  445. #ifdef CONFIG_PCIE1
  446. static struct pci_controller pcie1_hose;
  447. #endif /* CONFIG_PCIE1 */
  448. #ifdef CONFIG_PCI
  449. void pci_init_board(void)
  450. {
  451. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  452. struct fsl_pci_info pci_info[1];
  453. u32 devdisr, pordevsr, io_sel;
  454. int first_free_busno = 0;
  455. int num = 0;
  456. int pcie_ep, pcie_configured;
  457. devdisr = in_be32(&gur->devdisr);
  458. pordevsr = in_be32(&gur->pordevsr);
  459. io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  460. debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
  461. #if defined(CONFIG_PQ_MDS_PIB)
  462. pib_init();
  463. #endif
  464. #ifdef CONFIG_PCIE1
  465. pcie_configured = is_serdes_configured(PCIE1);
  466. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  467. SET_STD_PCIE_INFO(pci_info[num], 1);
  468. pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs);
  469. printf("PCIE1: connected to Slot as %s (base addr %lx)\n",
  470. pcie_ep ? "Endpoint" : "Root Complex",
  471. pci_info[num].regs);
  472. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  473. &pcie1_hose, first_free_busno);
  474. } else {
  475. printf("PCIE1: disabled\n");
  476. }
  477. puts("\n");
  478. #else
  479. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
  480. #endif
  481. }
  482. #endif /* CONFIG_PCI */
  483. #if defined(CONFIG_OF_BOARD_SETUP)
  484. void ft_board_setup(void *blob, bd_t *bd)
  485. {
  486. #if defined(CONFIG_SYS_UCC_RMII_MODE)
  487. int nodeoff, off, err;
  488. unsigned int val;
  489. const u32 *ph;
  490. const u32 *index;
  491. /* fixup device tree for supporting rmii mode */
  492. nodeoff = -1;
  493. while ((nodeoff = fdt_node_offset_by_compatible(blob, nodeoff,
  494. "ucc_geth")) >= 0) {
  495. err = fdt_setprop_string(blob, nodeoff, "tx-clock-name",
  496. "clk16");
  497. if (err < 0) {
  498. printf("WARNING: could not set tx-clock-name %s.\n",
  499. fdt_strerror(err));
  500. break;
  501. }
  502. err = fdt_fixup_phy_connection(blob, nodeoff, RMII);
  503. if (err < 0) {
  504. printf("WARNING: could not set phy-connection-type "
  505. "%s.\n", fdt_strerror(err));
  506. break;
  507. }
  508. index = fdt_getprop(blob, nodeoff, "cell-index", 0);
  509. if (index == NULL) {
  510. printf("WARNING: could not get cell-index of ucc\n");
  511. break;
  512. }
  513. ph = fdt_getprop(blob, nodeoff, "phy-handle", 0);
  514. if (ph == NULL) {
  515. printf("WARNING: could not get phy-handle of ucc\n");
  516. break;
  517. }
  518. off = fdt_node_offset_by_phandle(blob, *ph);
  519. if (off < 0) {
  520. printf("WARNING: could not get phy node %s.\n",
  521. fdt_strerror(err));
  522. break;
  523. }
  524. val = 0x7 + *index; /* RMII phy address starts from 0x8 */
  525. err = fdt_setprop(blob, off, "reg", &val, sizeof(u32));
  526. if (err < 0) {
  527. printf("WARNING: could not set reg for phy-handle "
  528. "%s.\n", fdt_strerror(err));
  529. break;
  530. }
  531. }
  532. #endif
  533. ft_cpu_setup(blob, bd);
  534. FT_FSL_PCI_SETUP;
  535. fdt_board_fixup_esdhc(blob, bd);
  536. fdt_board_fixup_qe_uart(blob, bd);
  537. fdt_board_fixup_qe_usb(blob, bd);
  538. }
  539. #endif