mpc8560ads.c 18 KB

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