mpc8560ads.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /*
  2. * Copyright 2004 Freescale Semiconductor.
  3. * (C) Copyright 2003,Motorola Inc.
  4. * Xianghua Xiao, (X.Xiao@motorola.com)
  5. *
  6. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <pci.h>
  28. #include <asm/processor.h>
  29. #include <asm/immap_85xx.h>
  30. #include <ioports.h>
  31. #include <spd.h>
  32. #include <miiphy.h>
  33. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  34. extern void ddr_enable_ecc(unsigned int dram_size);
  35. #endif
  36. extern long int spd_sdram(void);
  37. void local_bus_init(void);
  38. void sdram_init(void);
  39. long int fixed_sdram(void);
  40. /*
  41. * I/O Port configuration table
  42. *
  43. * if conf is 1, then that port pin will be configured at boot time
  44. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  45. */
  46. const iop_conf_t iop_conf_tab[4][32] = {
  47. /* Port A configuration */
  48. { /* conf ppar psor pdir podr pdat */
  49. /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
  50. /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
  51. /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
  52. /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
  53. /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
  54. /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
  55. /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
  56. /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
  57. /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
  58. /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
  59. /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
  60. /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
  61. /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
  62. /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
  63. /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  64. /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  65. /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  66. /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  67. /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  68. /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  69. /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  70. /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  71. /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */
  72. /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */
  73. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  74. /* PA6 */ { 0, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */
  75. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  76. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  77. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  78. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  79. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
  80. /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
  81. },
  82. /* Port B configuration */
  83. { /* conf ppar psor pdir podr pdat */
  84. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  85. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  86. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  87. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  88. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  89. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  90. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  91. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  92. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  93. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  94. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  95. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  96. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  97. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  98. /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
  99. /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
  100. /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
  101. /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
  102. /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
  103. /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
  104. /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  105. /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  106. /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  107. /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  108. /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  109. /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  110. /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  111. /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  112. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  113. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  114. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  115. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  116. },
  117. /* Port C */
  118. { /* conf ppar psor pdir podr pdat */
  119. /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
  120. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  121. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
  122. /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
  123. /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */
  124. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  125. /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
  126. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  127. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
  128. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
  129. /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  130. /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  131. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */
  132. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */
  133. /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
  134. /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */
  135. /* PC15 */ { 1, 1, 0, 0, 0, 0 }, /* PC15 */
  136. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
  137. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  138. /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */
  139. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */
  140. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FETHMDC */
  141. /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* FETHMDIO */
  142. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
  143. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  144. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  145. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  146. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  147. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  148. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
  149. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
  150. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
  151. },
  152. /* Port D */
  153. { /* conf ppar psor pdir podr pdat */
  154. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  155. /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  156. /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
  157. /* PD28 */ { 0, 1, 0, 0, 0, 0 }, /* PD28 */
  158. /* PD27 */ { 0, 1, 1, 1, 0, 0 }, /* PD27 */
  159. /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
  160. /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
  161. /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
  162. /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
  163. /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
  164. /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
  165. /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
  166. /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  167. /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
  168. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  169. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
  170. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
  171. /* PD14 */ { 0, 0, 0, 1, 0, 0 }, /* LED */
  172. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  173. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  174. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  175. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  176. /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  177. /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  178. /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
  179. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  180. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  181. /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
  182. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  183. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  184. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  185. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  186. }
  187. };
  188. /*
  189. * MPC8560ADS Board Status & Control Registers
  190. */
  191. typedef struct bcsr_ {
  192. volatile unsigned char bcsr0;
  193. volatile unsigned char bcsr1;
  194. volatile unsigned char bcsr2;
  195. volatile unsigned char bcsr3;
  196. volatile unsigned char bcsr4;
  197. volatile unsigned char bcsr5;
  198. } bcsr_t;
  199. int board_early_init_f (void)
  200. {
  201. return 0;
  202. }
  203. void reset_phy (void)
  204. {
  205. #if defined(CONFIG_ETHER_ON_FCC) /* avoid compile warnings for now */
  206. volatile bcsr_t *bcsr = (bcsr_t *) CFG_BCSR;
  207. #endif
  208. /* reset Giga bit Ethernet port if needed here */
  209. /* reset the CPM FEC port */
  210. #if (CONFIG_ETHER_INDEX == 2)
  211. bcsr->bcsr2 &= ~FETH2_RST;
  212. udelay(2);
  213. bcsr->bcsr2 |= FETH2_RST;
  214. udelay(1000);
  215. #elif (CONFIG_ETHER_INDEX == 3)
  216. bcsr->bcsr3 &= ~FETH3_RST;
  217. udelay(2);
  218. bcsr->bcsr3 |= FETH3_RST;
  219. udelay(1000);
  220. #endif
  221. #if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
  222. /* reset PHY */
  223. miiphy_reset("FCC1 ETHERNET", 0x0);
  224. /* change PHY address to 0x02 */
  225. bb_miiphy_write(NULL, 0, PHY_MIPSCR, 0xf028);
  226. bb_miiphy_write(NULL, 0x02, PHY_BMCR,
  227. PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
  228. #endif /* CONFIG_MII */
  229. }
  230. int checkboard (void)
  231. {
  232. puts("Board: ADS\n");
  233. #ifdef CONFIG_PCI
  234. printf(" PCI1: 32 bit, %d MHz (compiled)\n",
  235. CONFIG_SYS_CLK_FREQ / 1000000);
  236. #else
  237. printf(" PCI1: disabled\n");
  238. #endif
  239. /*
  240. * Initialize local bus.
  241. */
  242. local_bus_init();
  243. return 0;
  244. }
  245. long int
  246. initdram(int board_type)
  247. {
  248. long dram_size = 0;
  249. extern long spd_sdram (void);
  250. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  251. puts("Initializing\n");
  252. #if defined(CONFIG_DDR_DLL)
  253. {
  254. volatile ccsr_gur_t *gur= &immap->im_gur;
  255. uint temp_ddrdll = 0;
  256. /*
  257. * Work around to stabilize DDR DLL
  258. */
  259. temp_ddrdll = gur->ddrdllcr;
  260. gur->ddrdllcr = ((temp_ddrdll & 0xff) << 16) | 0x80000000;
  261. asm("sync;isync;msync");
  262. }
  263. #endif
  264. #if defined(CONFIG_SPD_EEPROM)
  265. dram_size = spd_sdram ();
  266. #else
  267. dram_size = fixed_sdram ();
  268. #endif
  269. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  270. /*
  271. * Initialize and enable DDR ECC.
  272. */
  273. ddr_enable_ecc(dram_size);
  274. #endif
  275. /*
  276. * Initialize SDRAM.
  277. */
  278. sdram_init();
  279. puts(" DDR: ");
  280. return dram_size;
  281. }
  282. /*
  283. * Initialize Local Bus
  284. */
  285. void
  286. local_bus_init(void)
  287. {
  288. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  289. volatile ccsr_gur_t *gur = &immap->im_gur;
  290. volatile ccsr_lbc_t *lbc = &immap->im_lbc;
  291. uint clkdiv;
  292. uint lbc_hz;
  293. sys_info_t sysinfo;
  294. /*
  295. * Errata LBC11.
  296. * Fix Local Bus clock glitch when DLL is enabled.
  297. *
  298. * If localbus freq is < 66Mhz, DLL bypass mode must be used.
  299. * If localbus freq is > 133Mhz, DLL can be safely enabled.
  300. * Between 66 and 133, the DLL is enabled with an override workaround.
  301. */
  302. get_sys_info(&sysinfo);
  303. clkdiv = lbc->lcrr & 0x0f;
  304. lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
  305. if (lbc_hz < 66) {
  306. lbc->lcrr = CFG_LBC_LCRR | 0x80000000; /* DLL Bypass */
  307. } else if (lbc_hz >= 133) {
  308. lbc->lcrr = CFG_LBC_LCRR & (~0x80000000); /* DLL Enabled */
  309. } else {
  310. /*
  311. * On REV1 boards, need to change CLKDIV before enable DLL.
  312. * Default CLKDIV is 8, change it to 4 temporarily.
  313. */
  314. uint pvr = get_pvr();
  315. uint temp_lbcdll = 0;
  316. if (pvr == PVR_85xx_REV1) {
  317. /* FIXME: Justify the high bit here. */
  318. lbc->lcrr = 0x10000004;
  319. }
  320. lbc->lcrr = CFG_LBC_LCRR & (~0x80000000);/* DLL Enabled */
  321. udelay(200);
  322. /*
  323. * Sample LBC DLL ctrl reg, upshift it to set the
  324. * override bits.
  325. */
  326. temp_lbcdll = gur->lbcdllcr;
  327. gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000);
  328. asm("sync;isync;msync");
  329. }
  330. }
  331. /*
  332. * Initialize SDRAM memory on the Local Bus.
  333. */
  334. void
  335. sdram_init(void)
  336. {
  337. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  338. volatile ccsr_lbc_t *lbc= &immap->im_lbc;
  339. uint *sdram_addr = (uint *)CFG_LBC_SDRAM_BASE;
  340. puts(" SDRAM: ");
  341. print_size (CFG_LBC_SDRAM_SIZE * 1024 * 1024, "\n");
  342. /*
  343. * Setup SDRAM Base and Option Registers
  344. */
  345. lbc->or2 = CFG_OR2_PRELIM;
  346. lbc->br2 = CFG_BR2_PRELIM;
  347. lbc->lbcr = CFG_LBC_LBCR;
  348. asm("msync");
  349. lbc->lsrt = CFG_LBC_LSRT;
  350. lbc->mrtpr = CFG_LBC_MRTPR;
  351. asm("sync");
  352. /*
  353. * Configure the SDRAM controller.
  354. */
  355. lbc->lsdmr = CFG_LBC_LSDMR_1;
  356. asm("sync");
  357. *sdram_addr = 0xff;
  358. ppcDcbf((unsigned long) sdram_addr);
  359. udelay(100);
  360. lbc->lsdmr = CFG_LBC_LSDMR_2;
  361. asm("sync");
  362. *sdram_addr = 0xff;
  363. ppcDcbf((unsigned long) sdram_addr);
  364. udelay(100);
  365. lbc->lsdmr = CFG_LBC_LSDMR_3;
  366. asm("sync");
  367. *sdram_addr = 0xff;
  368. ppcDcbf((unsigned long) sdram_addr);
  369. udelay(100);
  370. lbc->lsdmr = CFG_LBC_LSDMR_4;
  371. asm("sync");
  372. *sdram_addr = 0xff;
  373. ppcDcbf((unsigned long) sdram_addr);
  374. udelay(100);
  375. lbc->lsdmr = CFG_LBC_LSDMR_5;
  376. asm("sync");
  377. *sdram_addr = 0xff;
  378. ppcDcbf((unsigned long) sdram_addr);
  379. udelay(100);
  380. }
  381. #if defined(CFG_DRAM_TEST)
  382. int testdram (void)
  383. {
  384. uint *pstart = (uint *) CFG_MEMTEST_START;
  385. uint *pend = (uint *) CFG_MEMTEST_END;
  386. uint *p;
  387. printf("SDRAM test phase 1:\n");
  388. for (p = pstart; p < pend; p++)
  389. *p = 0xaaaaaaaa;
  390. for (p = pstart; p < pend; p++) {
  391. if (*p != 0xaaaaaaaa) {
  392. printf ("SDRAM test fails at: %08x\n", (uint) p);
  393. return 1;
  394. }
  395. }
  396. printf("SDRAM test phase 2:\n");
  397. for (p = pstart; p < pend; p++)
  398. *p = 0x55555555;
  399. for (p = pstart; p < pend; p++) {
  400. if (*p != 0x55555555) {
  401. printf ("SDRAM test fails at: %08x\n", (uint) p);
  402. return 1;
  403. }
  404. }
  405. printf("SDRAM test passed.\n");
  406. return 0;
  407. }
  408. #endif
  409. #if !defined(CONFIG_SPD_EEPROM)
  410. /*************************************************************************
  411. * fixed sdram init -- doesn't use serial presence detect.
  412. ************************************************************************/
  413. long int fixed_sdram (void)
  414. {
  415. #ifndef CFG_RAMBOOT
  416. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  417. volatile ccsr_ddr_t *ddr= &immap->im_ddr;
  418. ddr->cs0_bnds = CFG_DDR_CS0_BNDS;
  419. ddr->cs0_config = CFG_DDR_CS0_CONFIG;
  420. ddr->timing_cfg_1 = CFG_DDR_TIMING_1;
  421. ddr->timing_cfg_2 = CFG_DDR_TIMING_2;
  422. ddr->sdram_mode = CFG_DDR_MODE;
  423. ddr->sdram_interval = CFG_DDR_INTERVAL;
  424. #if defined (CONFIG_DDR_ECC)
  425. ddr->err_disable = 0x0000000D;
  426. ddr->err_sbe = 0x00ff0000;
  427. #endif
  428. asm("sync;isync;msync");
  429. udelay(500);
  430. #if defined (CONFIG_DDR_ECC)
  431. /* Enable ECC checking */
  432. ddr->sdram_cfg = (CFG_DDR_CONTROL | 0x20000000);
  433. #else
  434. ddr->sdram_cfg = CFG_DDR_CONTROL;
  435. #endif
  436. asm("sync; isync; msync");
  437. udelay(500);
  438. #endif
  439. return CFG_SDRAM_SIZE * 1024 * 1024;
  440. }
  441. #endif /* !defined(CONFIG_SPD_EEPROM) */
  442. #if defined(CONFIG_PCI)
  443. /*
  444. * Initialize PCI Devices, report devices found.
  445. */
  446. #ifndef CONFIG_PCI_PNP
  447. static struct pci_config_table pci_mpc85xxads_config_table[] = {
  448. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  449. PCI_IDSEL_NUMBER, PCI_ANY_ID,
  450. pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
  451. PCI_ENET0_MEMADDR,
  452. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
  453. } },
  454. { }
  455. };
  456. #endif
  457. static struct pci_controller hose = {
  458. #ifndef CONFIG_PCI_PNP
  459. config_table: pci_mpc85xxads_config_table,
  460. #endif
  461. };
  462. #endif /* CONFIG_PCI */
  463. void
  464. pci_init_board(void)
  465. {
  466. #ifdef CONFIG_PCI
  467. pci_mpc85xx_init(&hose);
  468. #endif /* CONFIG_PCI */
  469. }
  470. #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
  471. void
  472. ft_board_setup(void *blob, bd_t *bd)
  473. {
  474. ft_cpu_setup(blob, bd);
  475. }
  476. #endif