mpc8569mds.c 18 KB

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