mpc8560ads.c 16 KB

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