sbc8560.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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. extern long int spd_sdram (void);
  29. #include <common.h>
  30. #include <asm/processor.h>
  31. #include <asm/immap_85xx.h>
  32. #include <ioports.h>
  33. #include <spd.h>
  34. #include <miiphy.h>
  35. long int fixed_sdram (void);
  36. /*
  37. * I/O Port configuration table
  38. *
  39. * if conf is 1, then that port pin will be configured at boot time
  40. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  41. */
  42. const iop_conf_t iop_conf_tab[4][32] = {
  43. /* Port A configuration */
  44. { /* conf ppar psor pdir podr pdat */
  45. /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
  46. /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
  47. /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
  48. /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
  49. /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
  50. /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
  51. /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
  52. /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
  53. /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
  54. /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
  55. /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
  56. /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
  57. /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
  58. /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
  59. /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  60. /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  61. /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  62. /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  63. /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  64. /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  65. /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  66. /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  67. /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */
  68. /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */
  69. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  70. /* PA6 */ { 0, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */
  71. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  72. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  73. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  74. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  75. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
  76. /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
  77. },
  78. /* Port B configuration */
  79. { /* conf ppar psor pdir podr pdat */
  80. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  81. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  82. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  83. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  84. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  85. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  86. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  87. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  88. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  89. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  90. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  91. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  92. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  93. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  94. /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
  95. /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
  96. /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
  97. /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
  98. /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
  99. /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
  100. /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  101. /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  102. /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  103. /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  104. /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  105. /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  106. /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  107. /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  108. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  109. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  110. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  111. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  112. },
  113. /* Port C */
  114. { /* conf ppar psor pdir podr pdat */
  115. /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
  116. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  117. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
  118. /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
  119. /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */
  120. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  121. /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
  122. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  123. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
  124. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
  125. /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  126. /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  127. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */
  128. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */
  129. /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
  130. /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */
  131. /* PC15 */ { 1, 1, 0, 0, 0, 0 }, /* PC15 */
  132. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
  133. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  134. /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */
  135. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */
  136. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FETHMDC */
  137. /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* FETHMDIO */
  138. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
  139. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  140. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  141. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  142. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  143. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  144. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
  145. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
  146. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
  147. },
  148. /* Port D */
  149. { /* conf ppar psor pdir podr pdat */
  150. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  151. /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  152. /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 RTS */
  153. /* PD28 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 RxD */
  154. /* PD27 */ { 1, 1, 1, 1, 0, 0 }, /* SCC2 TxD */
  155. /* PD26 */ { 1, 1, 0, 1, 0, 0 }, /* SCC2 RTS */
  156. /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
  157. /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
  158. /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
  159. /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
  160. /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
  161. /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
  162. /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  163. /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
  164. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  165. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
  166. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
  167. /* PD14 */ { 0, 0, 0, 1, 0, 0 }, /* LED */
  168. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  169. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  170. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  171. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  172. /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  173. /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  174. /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
  175. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  176. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  177. /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
  178. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  179. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  180. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  181. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  182. }
  183. };
  184. int board_early_init_f (void)
  185. {
  186. #if defined(CONFIG_PCI)
  187. volatile immap_t *immr = (immap_t *)CFG_IMMR;
  188. volatile ccsr_pcix_t *pci = &immr->im_pcix;
  189. pci->peer &= 0xfffffffdf; /* disable master abort */
  190. #endif
  191. return 0;
  192. }
  193. void reset_phy (void)
  194. {
  195. #if defined(CONFIG_ETHER_ON_FCC) /* avoid compile warnings for now */
  196. volatile unsigned char *bcsr = (unsigned char *) CFG_BCSR;
  197. #endif
  198. /* reset Giga bit Ethernet port if needed here */
  199. /* reset the CPM FEC port */
  200. #if (CONFIG_ETHER_INDEX == 2)
  201. bcsr[0] &= ~0x20;
  202. udelay(2);
  203. bcsr[0] |= 0x20;
  204. udelay(1000);
  205. #elif (CONFIG_ETHER_INDEX == 3)
  206. bcsr[0] &= ~0x10;
  207. udelay(2);
  208. bcsr[0] |= 0x10;
  209. udelay(1000);
  210. #endif
  211. #if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
  212. /* reset PHY */
  213. miiphy_reset("FCC1 ETHERNET", 0x0);
  214. /* change PHY address to 0x02 */
  215. bb_miiphy_write(NULL, 0, PHY_MIPSCR, 0xf028);
  216. bb_miiphy_write(NULL, 0x02, PHY_BMCR,
  217. PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
  218. #endif /* CONFIG_MII */
  219. }
  220. int checkboard (void)
  221. {
  222. sys_info_t sysinfo;
  223. get_sys_info (&sysinfo);
  224. #ifdef CONFIG_SBC8560
  225. printf ("Board: Wind River SBC8560 Board\n");
  226. #else
  227. printf ("Board: Wind River SBC8540 Board\n");
  228. #endif
  229. printf ("\tCPU: %lu MHz\n", sysinfo.freqProcessor / 1000000);
  230. printf ("\tCCB: %lu MHz\n", sysinfo.freqSystemBus / 1000000);
  231. printf ("\tDDR: %lu MHz\n", sysinfo.freqSystemBus / 2000000);
  232. if((CFG_LBC_LCRR & 0x0f) == 2 || (CFG_LBC_LCRR & 0x0f) == 4 \
  233. || (CFG_LBC_LCRR & 0x0f) == 8) {
  234. printf ("\tLBC: %lu MHz\n", sysinfo.freqSystemBus / 1000000 /(CFG_LBC_LCRR & 0x0f));
  235. } else {
  236. printf("\tLBC: unknown\n");
  237. }
  238. printf("\tCPM: %lu Mhz\n", sysinfo.freqSystemBus / 1000000);
  239. printf("L1 D-cache 32KB, L1 I-cache 32KB enabled.\n");
  240. return (0);
  241. }
  242. long int initdram (int board_type)
  243. {
  244. long dram_size = 0;
  245. extern long spd_sdram (void);
  246. #if 0
  247. #if !defined(CONFIG_RAM_AS_FLASH)
  248. volatile ccsr_lbc_t *lbc= &immap->im_lbc;
  249. sys_info_t sysinfo;
  250. uint temp_lbcdll = 0;
  251. #endif
  252. #endif /* 0 */
  253. #if !defined(CONFIG_RAM_AS_FLASH) || defined(CONFIG_DDR_DLL)
  254. volatile ccsr_gur_t *gur = (void *)(CFG_MPC85xx_GUTS_ADDR);
  255. #endif
  256. #if defined(CONFIG_DDR_DLL)
  257. uint temp_ddrdll = 0;
  258. /* Work around to stabilize DDR DLL */
  259. temp_ddrdll = gur->ddrdllcr;
  260. gur->ddrdllcr = ((temp_ddrdll & 0xff) << 16) | 0x80000000;
  261. asm("sync;isync;msync");
  262. #endif
  263. #if defined(CONFIG_SPD_EEPROM)
  264. dram_size = spd_sdram ();
  265. #else
  266. dram_size = fixed_sdram ();
  267. #endif
  268. #if 0
  269. #if !defined(CONFIG_RAM_AS_FLASH) /* LocalBus SDRAM is not emulating flash */
  270. get_sys_info(&sysinfo);
  271. /* if localbus freq is less than 66Mhz,we use bypass mode,otherwise use DLL */
  272. if(sysinfo.freqSystemBus/(CFG_LBC_LCRR & 0x0f) < 66000000) {
  273. lbc->lcrr = (CFG_LBC_LCRR & 0x0fffffff)| 0x80000000;
  274. } else {
  275. #if defined(CONFIG_MPC85xx_REV1) /* need change CLKDIV before enable DLL */
  276. lbc->lcrr = 0x10000004; /* default CLKDIV is 8, change it to 4 temporarily */
  277. #endif
  278. lbc->lcrr = CFG_LBC_LCRR & 0x7fffffff;
  279. udelay(200);
  280. temp_lbcdll = gur->lbcdllcr;
  281. gur->lbcdllcr = ((temp_lbcdll & 0xff) << 16 ) | 0x80000000;
  282. asm("sync;isync;msync");
  283. }
  284. lbc->or2 = CFG_OR2_PRELIM; /* 64MB SDRAM */
  285. lbc->br2 = CFG_BR2_PRELIM;
  286. lbc->lbcr = CFG_LBC_LBCR;
  287. lbc->lsdmr = CFG_LBC_LSDMR_1;
  288. asm("sync");
  289. (unsigned int) * (ulong *)0 = 0x000000ff;
  290. lbc->lsdmr = CFG_LBC_LSDMR_2;
  291. asm("sync");
  292. (unsigned int) * (ulong *)0 = 0x000000ff;
  293. lbc->lsdmr = CFG_LBC_LSDMR_3;
  294. asm("sync");
  295. (unsigned int) * (ulong *)0 = 0x000000ff;
  296. lbc->lsdmr = CFG_LBC_LSDMR_4;
  297. asm("sync");
  298. (unsigned int) * (ulong *)0 = 0x000000ff;
  299. lbc->lsdmr = CFG_LBC_LSDMR_5;
  300. asm("sync");
  301. lbc->lsrt = CFG_LBC_LSRT;
  302. asm("sync");
  303. lbc->mrtpr = CFG_LBC_MRTPR;
  304. asm("sync");
  305. #endif
  306. #endif
  307. #if defined(CONFIG_DDR_ECC)
  308. {
  309. /* Initialize all of memory for ECC, then
  310. * enable errors */
  311. uint *p = 0;
  312. uint i = 0;
  313. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  314. volatile ccsr_ddr_t *ddr= &immap->im_ddr;
  315. dma_init();
  316. for (*p = 0; p < (uint *)(8 * 1024); p++) {
  317. if (((unsigned int)p & 0x1f) == 0) { dcbz(p); }
  318. *p = (unsigned int)0xdeadbeef;
  319. if (((unsigned int)p & 0x1c) == 0x1c) { dcbf(p); }
  320. }
  321. /* 8K */
  322. dma_xfer((uint *)0x2000,0x2000,(uint *)0);
  323. /* 16K */
  324. dma_xfer((uint *)0x4000,0x4000,(uint *)0);
  325. /* 32K */
  326. dma_xfer((uint *)0x8000,0x8000,(uint *)0);
  327. /* 64K */
  328. dma_xfer((uint *)0x10000,0x10000,(uint *)0);
  329. /* 128k */
  330. dma_xfer((uint *)0x20000,0x20000,(uint *)0);
  331. /* 256k */
  332. dma_xfer((uint *)0x40000,0x40000,(uint *)0);
  333. /* 512k */
  334. dma_xfer((uint *)0x80000,0x80000,(uint *)0);
  335. /* 1M */
  336. dma_xfer((uint *)0x100000,0x100000,(uint *)0);
  337. /* 2M */
  338. dma_xfer((uint *)0x200000,0x200000,(uint *)0);
  339. /* 4M */
  340. dma_xfer((uint *)0x400000,0x400000,(uint *)0);
  341. for (i = 1; i < dram_size / 0x800000; i++) {
  342. dma_xfer((uint *)(0x800000*i),0x800000,(uint *)0);
  343. }
  344. /* Enable errors for ECC */
  345. ddr->err_disable = 0x00000000;
  346. asm("sync;isync;msync");
  347. }
  348. #endif
  349. return dram_size;
  350. }
  351. #if defined(CFG_DRAM_TEST)
  352. int testdram (void)
  353. {
  354. uint *pstart = (uint *) CFG_MEMTEST_START;
  355. uint *pend = (uint *) CFG_MEMTEST_END;
  356. uint *p;
  357. printf("SDRAM test phase 1:\n");
  358. for (p = pstart; p < pend; p++)
  359. *p = 0xaaaaaaaa;
  360. for (p = pstart; p < pend; p++) {
  361. if (*p != 0xaaaaaaaa) {
  362. printf ("SDRAM test fails at: %08x\n", (uint) p);
  363. return 1;
  364. }
  365. }
  366. printf("SDRAM test phase 2:\n");
  367. for (p = pstart; p < pend; p++)
  368. *p = 0x55555555;
  369. for (p = pstart; p < pend; p++) {
  370. if (*p != 0x55555555) {
  371. printf ("SDRAM test fails at: %08x\n", (uint) p);
  372. return 1;
  373. }
  374. }
  375. printf("SDRAM test passed.\n");
  376. return 0;
  377. }
  378. #endif
  379. #if !defined(CONFIG_SPD_EEPROM)
  380. /*************************************************************************
  381. * fixed sdram init -- doesn't use serial presence detect.
  382. ************************************************************************/
  383. long int fixed_sdram (void)
  384. {
  385. #define CFG_DDR_CONTROL 0xc2000000
  386. #ifndef CFG_RAMBOOT
  387. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  388. volatile ccsr_ddr_t *ddr= &immap->im_ddr;
  389. ddr->cs0_bnds = 0x00000007;
  390. ddr->cs1_bnds = 0x0010001f;
  391. ddr->cs2_bnds = 0x00000000;
  392. ddr->cs3_bnds = 0x00000000;
  393. ddr->cs0_config = 0x80000102;
  394. ddr->cs1_config = 0x80000102;
  395. ddr->cs2_config = 0x00000000;
  396. ddr->cs3_config = 0x00000000;
  397. ddr->timing_cfg_1 = 0x37334321;
  398. ddr->timing_cfg_2 = 0x00000800;
  399. ddr->sdram_cfg = 0x42000000;
  400. ddr->sdram_mode = 0x00000022;
  401. ddr->sdram_interval = 0x05200100;
  402. ddr->err_sbe = 0x00ff0000;
  403. #if defined (CONFIG_DDR_ECC)
  404. ddr->err_disable = 0x0000000D;
  405. #endif
  406. asm("sync;isync;msync");
  407. udelay(500);
  408. #if defined (CONFIG_DDR_ECC)
  409. /* Enable ECC checking */
  410. ddr->sdram_cfg = (CFG_DDR_CONTROL | 0x20000000);
  411. #else
  412. ddr->sdram_cfg = CFG_DDR_CONTROL;
  413. #endif
  414. asm("sync; isync; msync");
  415. udelay(500);
  416. #endif
  417. return CFG_SDRAM_SIZE * 1024 * 1024;
  418. }
  419. #endif /* !defined(CONFIG_SPD_EEPROM) */