stxssa.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /*
  2. * (C) Copyright 2005, Embedded Alley Solutions, Inc.
  3. * Dan Malek, <dan@embeddedalley.com>
  4. * Copied from STx GP3.
  5. * Updates for Silicon Tx GP3 SSA
  6. *
  7. * (C) Copyright 2003,Motorola Inc.
  8. * Xianghua Xiao, (X.Xiao@motorola.com)
  9. *
  10. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. */
  30. #include <common.h>
  31. #include <pci.h>
  32. #include <asm/processor.h>
  33. #include <asm/mmu.h>
  34. #include <asm/immap_85xx.h>
  35. #include <asm/fsl_ddr_sdram.h>
  36. #include <ioports.h>
  37. #include <asm/io.h>
  38. #include <spd_sdram.h>
  39. #include <miiphy.h>
  40. long int fixed_sdram (void);
  41. /*
  42. * I/O Port configuration table
  43. *
  44. * if conf is 1, then that port pin will be configured at boot time
  45. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  46. */
  47. const iop_conf_t iop_conf_tab[4][32] = {
  48. /* Port A configuration */
  49. { /* conf ppar psor pdir podr pdat */
  50. /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
  51. /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
  52. /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
  53. /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
  54. /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
  55. /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
  56. /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
  57. /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
  58. /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
  59. /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
  60. /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
  61. /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
  62. /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
  63. /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
  64. /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  65. /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  66. /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  67. /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  68. /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  69. /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  70. /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  71. /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  72. /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */
  73. /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */
  74. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  75. /* PA6 */ { 0, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */
  76. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  77. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  78. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  79. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  80. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
  81. /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
  82. },
  83. /* Port B configuration */
  84. { /* conf ppar psor pdir podr pdat */
  85. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  86. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  87. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  88. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  89. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  90. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  91. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  92. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  93. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  94. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  95. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  96. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  97. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  98. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  99. /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
  100. /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
  101. /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
  102. /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
  103. /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
  104. /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
  105. /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  106. /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  107. /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  108. /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  109. /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  110. /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  111. /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  112. /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  113. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  114. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  115. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  116. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  117. },
  118. /* Port C */
  119. { /* conf ppar psor pdir podr pdat */
  120. /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
  121. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  122. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
  123. /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
  124. /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */
  125. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  126. /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
  127. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  128. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
  129. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
  130. /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  131. /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  132. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */
  133. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */
  134. /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
  135. /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */
  136. /* PC15 */ { 0, 1, 0, 0, 0, 0 }, /* PC15 */
  137. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
  138. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  139. /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */
  140. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */
  141. /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* FETHMDC */
  142. /* PC9 */ { 0, 0, 0, 0, 0, 0 }, /* FETHMDIO */
  143. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
  144. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  145. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  146. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  147. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  148. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  149. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
  150. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
  151. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
  152. },
  153. /* Port D */
  154. { /* conf ppar psor pdir podr pdat */
  155. /* PD31 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  156. /* PD30 */ { 0, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  157. /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
  158. /* PD28 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 RxD */
  159. /* PD27 */ { 1, 1, 0, 1, 0, 0 }, /* SCC2 TxD */
  160. /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
  161. /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
  162. /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
  163. /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
  164. /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
  165. /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
  166. /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
  167. /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  168. /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
  169. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  170. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
  171. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  172. /* PD14 */ { 1, 1, 1, 0, 0, 0 }, /* I2C CLK */
  173. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  174. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  175. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  176. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  177. /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  178. /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  179. /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
  180. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  181. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  182. /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
  183. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  184. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  185. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  186. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  187. }
  188. };
  189. static uint64_t next_led_update;
  190. static uint led_bit;
  191. void
  192. reset_phy(void)
  193. {
  194. volatile uint *blatch;
  195. #if 0
  196. int i;
  197. #endif
  198. blatch = (volatile uint *)CFG_LBC_CFGLATCH_BASE;
  199. /* reset Giga bit Ethernet port if needed here */
  200. #if 1
  201. *blatch &= ~0x000000c0;
  202. udelay(100);
  203. #else
  204. *blatch = 0;
  205. asm("eieio");
  206. for (i=0; i<1000; i++)
  207. udelay(1000);
  208. #endif
  209. *blatch = 0x000000c1; /* Light one led, too */
  210. udelay(1000);
  211. #if 0 /* This is the port we really want to use for debugging. */
  212. /* reset the CPM FEC port */
  213. #if (CONFIG_ETHER_INDEX == 2)
  214. bcsr->bcsr2 &= ~FETH2_RST;
  215. udelay(2);
  216. bcsr->bcsr2 |= FETH2_RST;
  217. udelay(1000);
  218. #elif (CONFIG_ETHER_INDEX == 3)
  219. bcsr->bcsr3 &= ~FETH3_RST;
  220. udelay(2);
  221. bcsr->bcsr3 |= FETH3_RST;
  222. udelay(1000);
  223. #endif
  224. #if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
  225. /* reset PHY */
  226. miiphy_reset("FCC1 ETHERNET", 0x0);
  227. /* change PHY address to 0x02 */
  228. bb_miiphy_write(NULL, 0, PHY_MIPSCR, 0xf028);
  229. bb_miiphy_write(NULL, 0x02, PHY_BMCR,
  230. PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
  231. #endif /* CONFIG_MII */
  232. #endif
  233. }
  234. int
  235. board_early_init_f(void)
  236. {
  237. #if defined(CONFIG_PCI)
  238. volatile ccsr_pcix_t *pci = (void *)(CFG_MPC85xx_PCIX_ADDR);
  239. pci->peer &= 0xffffffdf; /* disable master abort */
  240. #endif
  241. /* Why is the phy reset done _after_ the ethernet
  242. * initialization in lib_ppc/board.c?
  243. * Do it here so it's done before the TSECs are used.
  244. */
  245. reset_phy();
  246. return 0;
  247. }
  248. int
  249. checkboard(void)
  250. {
  251. printf ("Board: Silicon Tx GPPP SSA Board\n");
  252. return (0);
  253. }
  254. /* Blinkin' LEDS for Robert.
  255. */
  256. void
  257. show_activity(int flag)
  258. {
  259. volatile uint *blatch;
  260. if (next_led_update > get_ticks())
  261. return;
  262. blatch = (volatile uint *)CFG_LBC_CFGLATCH_BASE;
  263. led_bit >>= 1;
  264. if (led_bit == 0)
  265. led_bit = 0x08;
  266. *blatch = (0xc0 | led_bit);
  267. eieio();
  268. next_led_update += (get_tbclk() / 4);
  269. }
  270. phys_size_t
  271. initdram (int board_type)
  272. {
  273. long dram_size = 0;
  274. #if defined(CONFIG_DDR_DLL)
  275. {
  276. volatile ccsr_gur_t *gur = (void *)(CFG_MPC85xx_GUTS_ADDR);
  277. uint temp_ddrdll = 0;
  278. /* Work around to stabilize DDR DLL */
  279. temp_ddrdll = gur->ddrdllcr;
  280. gur->ddrdllcr = ((temp_ddrdll & 0xff) << 16) | 0x80000000;
  281. asm("sync;isync;msync");
  282. }
  283. #endif
  284. dram_size = fsl_ddr_sdram();
  285. dram_size = setup_ddr_tlbs(dram_size / 0x100000);
  286. dram_size *= 0x100000;
  287. #if defined(CONFIG_DDR_ECC)
  288. /* Initialize and enable DDR ECC.
  289. */
  290. ddr_enable_ecc(dram_size);
  291. #endif
  292. return dram_size;
  293. }
  294. #if defined(CFG_DRAM_TEST)
  295. int testdram (void)
  296. {
  297. uint *pstart = (uint *) CFG_MEMTEST_START;
  298. uint *pend = (uint *) CFG_MEMTEST_END;
  299. uint *p;
  300. printf("SDRAM test phase 1:\n");
  301. for (p = pstart; p < pend; p++)
  302. *p = 0xaaaaaaaa;
  303. for (p = pstart; p < pend; p++) {
  304. if (*p != 0xaaaaaaaa) {
  305. printf ("SDRAM test fails at: %08x\n", (uint) p);
  306. return 1;
  307. }
  308. }
  309. printf("SDRAM test phase 2:\n");
  310. for (p = pstart; p < pend; p++)
  311. *p = 0x55555555;
  312. for (p = pstart; p < pend; p++) {
  313. if (*p != 0x55555555) {
  314. printf ("SDRAM test fails at: %08x\n", (uint) p);
  315. return 1;
  316. }
  317. }
  318. printf("SDRAM test passed.\n");
  319. return 0;
  320. }
  321. #endif
  322. #if defined(CONFIG_PCI)
  323. /*
  324. * Initialize PCI Devices, report devices found.
  325. */
  326. #ifndef CONFIG_PCI_PNP
  327. static struct pci_config_table pci_stxgp3_config_table[] = {
  328. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  329. PCI_IDSEL_NUMBER, PCI_ANY_ID,
  330. pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
  331. PCI_ENET0_MEMADDR,
  332. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
  333. } },
  334. { }
  335. };
  336. #endif
  337. static struct pci_controller hose[] = {
  338. #ifndef CONFIG_PCI_PNP
  339. { config_table: pci_stxgp3_config_table,},
  340. #else
  341. {},
  342. #endif
  343. #ifdef CONFIG_MPC85XX_PCI2
  344. {},
  345. #endif
  346. };
  347. #endif /* CONFIG_PCI */
  348. void
  349. pci_init_board(void)
  350. {
  351. #ifdef CONFIG_PCI
  352. extern void pci_mpc85xx_init(struct pci_controller *hose);
  353. pci_mpc85xx_init(hose);
  354. #endif /* CONFIG_PCI */
  355. }