mpc8569mds.c 18 KB

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