sbc8560.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. /*
  2. * (C) Copyright 2003,Motorola Inc.
  3. * Xianghua Xiao, (X.Xiao@motorola.com)
  4. *
  5. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  6. *
  7. * (C) Copyright 2004 Wind River Systems Inc <www.windriver.com>.
  8. * Added support for Wind River SBC8560 board
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <common.h>
  29. #include <asm/processor.h>
  30. #include <asm/mmu.h>
  31. #include <asm/immap_85xx.h>
  32. #include <asm/fsl_ddr_sdram.h>
  33. #include <ioports.h>
  34. #include <spd_sdram.h>
  35. #include <miiphy.h>
  36. #include <libfdt.h>
  37. #include <fdt_support.h>
  38. /*
  39. * I/O Port configuration table
  40. *
  41. * if conf is 1, then that port pin will be configured at boot time
  42. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  43. */
  44. const iop_conf_t iop_conf_tab[4][32] = {
  45. /* Port A configuration */
  46. { /* conf ppar psor pdir podr pdat */
  47. /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
  48. /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
  49. /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
  50. /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
  51. /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
  52. /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
  53. /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
  54. /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
  55. /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
  56. /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
  57. /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
  58. /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
  59. /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
  60. /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
  61. /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  62. /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  63. /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  64. /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  65. /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  66. /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  67. /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  68. /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  69. /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */
  70. /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */
  71. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  72. /* PA6 */ { 0, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */
  73. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  74. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  75. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  76. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  77. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
  78. /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
  79. },
  80. /* Port B configuration */
  81. { /* conf ppar psor pdir podr pdat */
  82. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  83. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  84. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  85. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  86. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  87. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  88. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  89. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  90. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  91. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  92. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  93. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  94. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  95. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  96. /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
  97. /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
  98. /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
  99. /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
  100. /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
  101. /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
  102. /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  103. /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  104. /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  105. /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  106. /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  107. /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  108. /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  109. /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  110. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  111. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  112. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  113. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  114. },
  115. /* Port C */
  116. { /* conf ppar psor pdir podr pdat */
  117. /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
  118. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  119. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
  120. /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
  121. /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */
  122. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  123. /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
  124. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  125. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
  126. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
  127. /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  128. /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  129. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */
  130. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */
  131. /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
  132. /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */
  133. /* PC15 */ { 1, 1, 0, 0, 0, 0 }, /* PC15 */
  134. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
  135. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  136. /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */
  137. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */
  138. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FETHMDC */
  139. /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* FETHMDIO */
  140. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
  141. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  142. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  143. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  144. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  145. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  146. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
  147. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
  148. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
  149. },
  150. /* Port D */
  151. { /* conf ppar psor pdir podr pdat */
  152. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  153. /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  154. /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 RTS */
  155. /* PD28 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 RxD */
  156. /* PD27 */ { 1, 1, 1, 1, 0, 0 }, /* SCC2 TxD */
  157. /* PD26 */ { 1, 1, 0, 1, 0, 0 }, /* SCC2 RTS */
  158. /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
  159. /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
  160. /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
  161. /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
  162. /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
  163. /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
  164. /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  165. /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
  166. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  167. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
  168. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
  169. /* PD14 */ { 0, 0, 0, 1, 0, 0 }, /* LED */
  170. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  171. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  172. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  173. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  174. /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  175. /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  176. /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
  177. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  178. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  179. /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
  180. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  181. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  182. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  183. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  184. }
  185. };
  186. int board_early_init_f (void)
  187. {
  188. #if defined(CONFIG_PCI)
  189. volatile ccsr_pcix_t *pci = (void *)(CONFIG_SYS_MPC85xx_PCIX_ADDR);
  190. pci->peer &= 0xfffffffdf; /* disable master abort */
  191. #endif
  192. return 0;
  193. }
  194. void reset_phy (void)
  195. {
  196. #if defined(CONFIG_ETHER_ON_FCC) /* avoid compile warnings for now */
  197. volatile unsigned char *bcsr = (unsigned char *) CONFIG_SYS_BCSR;
  198. #endif
  199. /* reset Giga bit Ethernet port if needed here */
  200. /* reset the CPM FEC port */
  201. #if (CONFIG_ETHER_INDEX == 2)
  202. bcsr[0] &= ~0x20;
  203. udelay(2);
  204. bcsr[0] |= 0x20;
  205. udelay(1000);
  206. #elif (CONFIG_ETHER_INDEX == 3)
  207. bcsr[0] &= ~0x10;
  208. udelay(2);
  209. bcsr[0] |= 0x10;
  210. udelay(1000);
  211. #endif
  212. #if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
  213. /* reset PHY */
  214. miiphy_reset("FCC1", 0x0);
  215. /* change PHY address to 0x02 */
  216. bb_miiphy_write(NULL, 0, MII_MIPSCR, 0xf028);
  217. bb_miiphy_write(NULL, 0x02, MII_BMCR,
  218. BMCR_ANENABLE | BMCR_ANRESTART);
  219. #endif /* CONFIG_MII */
  220. }
  221. int checkboard (void)
  222. {
  223. sys_info_t sysinfo;
  224. char buf[32];
  225. get_sys_info (&sysinfo);
  226. #ifdef CONFIG_SBC8560
  227. printf ("Board: Wind River SBC8560 Board\n");
  228. #else
  229. printf ("Board: Wind River SBC8540 Board\n");
  230. #endif
  231. printf ("\tCPU: %s MHz\n", strmhz(buf, sysinfo.freqProcessor[0]));
  232. printf ("\tCCB: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus));
  233. printf ("\tDDR: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus/2));
  234. if((CONFIG_SYS_LBC_LCRR & 0x0f) == 2 || (CONFIG_SYS_LBC_LCRR & 0x0f) == 4 \
  235. || (CONFIG_SYS_LBC_LCRR & 0x0f) == 8) {
  236. printf ("\tLBC: %s MHz\n",
  237. strmhz(buf, sysinfo.freqSystemBus/(CONFIG_SYS_LBC_LCRR & 0x0f)));
  238. } else {
  239. printf("\tLBC: unknown\n");
  240. }
  241. printf("\tCPM: %s MHz\n", strmhz(buf, sysinfo.freqSystemBus));
  242. printf("L1 D-cache 32KB, L1 I-cache 32KB enabled.\n");
  243. return (0);
  244. }
  245. #if defined(CONFIG_SYS_DRAM_TEST)
  246. int testdram (void)
  247. {
  248. uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
  249. uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
  250. uint *p;
  251. printf("SDRAM test phase 1:\n");
  252. for (p = pstart; p < pend; p++)
  253. *p = 0xaaaaaaaa;
  254. for (p = pstart; p < pend; p++) {
  255. if (*p != 0xaaaaaaaa) {
  256. printf ("SDRAM test fails at: %08x\n", (uint) p);
  257. return 1;
  258. }
  259. }
  260. printf("SDRAM test phase 2:\n");
  261. for (p = pstart; p < pend; p++)
  262. *p = 0x55555555;
  263. for (p = pstart; p < pend; p++) {
  264. if (*p != 0x55555555) {
  265. printf ("SDRAM test fails at: %08x\n", (uint) p);
  266. return 1;
  267. }
  268. }
  269. printf("SDRAM test passed.\n");
  270. return 0;
  271. }
  272. #endif
  273. #if !defined(CONFIG_SPD_EEPROM)
  274. /*************************************************************************
  275. * fixed sdram init -- doesn't use serial presence detect.
  276. ************************************************************************/
  277. phys_size_t fixed_sdram(void)
  278. {
  279. #define CONFIG_SYS_DDR_CONTROL 0xc2000000
  280. #ifndef CONFIG_SYS_RAMBOOT
  281. volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
  282. #if (CONFIG_SYS_SDRAM_SIZE == 512)
  283. ddr->cs0_bnds = 0x0000000f;
  284. #else
  285. ddr->cs0_bnds = 0x00000007;
  286. #endif
  287. ddr->cs1_bnds = 0x0010001f;
  288. ddr->cs2_bnds = 0x00000000;
  289. ddr->cs3_bnds = 0x00000000;
  290. ddr->cs0_config = 0x80000102;
  291. ddr->cs1_config = 0x80000102;
  292. ddr->cs2_config = 0x00000000;
  293. ddr->cs3_config = 0x00000000;
  294. ddr->timing_cfg_1 = 0x37334321;
  295. ddr->timing_cfg_2 = 0x00000800;
  296. ddr->sdram_cfg = 0x42000000;
  297. ddr->sdram_mode = 0x00000022;
  298. ddr->sdram_interval = 0x05200100;
  299. ddr->err_sbe = 0x00ff0000;
  300. #if defined (CONFIG_DDR_ECC)
  301. ddr->err_disable = 0x0000000D;
  302. #endif
  303. asm("sync;isync;msync");
  304. udelay(500);
  305. #if defined (CONFIG_DDR_ECC)
  306. /* Enable ECC checking */
  307. ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
  308. #else
  309. ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
  310. #endif
  311. asm("sync; isync; msync");
  312. udelay(500);
  313. #endif
  314. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  315. }
  316. #endif /* !defined(CONFIG_SPD_EEPROM) */
  317. #if defined(CONFIG_OF_BOARD_SETUP)
  318. void
  319. ft_board_setup(void *blob, bd_t *bd)
  320. {
  321. int node, tmp[2];
  322. #ifdef CONFIG_PCI
  323. const char *path;
  324. #endif
  325. ft_cpu_setup(blob, bd);
  326. node = fdt_path_offset(blob, "/aliases");
  327. tmp[0] = 0;
  328. if (node >= 0) {
  329. #ifdef CONFIG_PCI
  330. path = fdt_getprop(blob, node, "pci0", NULL);
  331. if (path) {
  332. tmp[1] = hose.last_busno - hose.first_busno;
  333. do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
  334. }
  335. #endif
  336. }
  337. }
  338. #endif