mpc8541cds.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /*
  2. * Copyright 2004 Freescale Semiconductor.
  3. *
  4. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <pci.h>
  26. #include <asm/processor.h>
  27. #include <asm/immap_85xx.h>
  28. #include <ioports.h>
  29. #include <spd.h>
  30. #include "../common/cadmus.h"
  31. #include "../common/eeprom.h"
  32. #include "../common/via.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. /*
  40. * I/O Port configuration table
  41. *
  42. * if conf is 1, then that port pin will be configured at boot time
  43. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  44. */
  45. const iop_conf_t iop_conf_tab[4][32] = {
  46. /* Port A configuration */
  47. { /* conf ppar psor pdir podr pdat */
  48. /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
  49. /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
  50. /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
  51. /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
  52. /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
  53. /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
  54. /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
  55. /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
  56. /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
  57. /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
  58. /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
  59. /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
  60. /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
  61. /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
  62. /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  63. /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  64. /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  65. /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  66. /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  67. /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  68. /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  69. /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  70. /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */
  71. /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */
  72. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  73. /* PA6 */ { 0, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */
  74. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  75. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  76. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  77. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  78. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
  79. /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
  80. },
  81. /* Port B configuration */
  82. { /* conf ppar psor pdir podr pdat */
  83. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  84. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  85. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  86. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  87. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  88. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  89. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  90. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  91. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  92. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  93. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  94. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  95. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  96. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  97. /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
  98. /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
  99. /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
  100. /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
  101. /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
  102. /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
  103. /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  104. /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  105. /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  106. /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  107. /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  108. /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  109. /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  110. /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  111. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  112. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  113. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  114. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  115. },
  116. /* Port C */
  117. { /* conf ppar psor pdir podr pdat */
  118. /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
  119. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  120. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
  121. /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
  122. /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */
  123. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  124. /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
  125. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  126. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
  127. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
  128. /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  129. /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  130. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */
  131. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */
  132. /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
  133. /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */
  134. /* PC15 */ { 1, 1, 0, 0, 0, 0 }, /* PC15 */
  135. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
  136. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  137. /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */
  138. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */
  139. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FETHMDC */
  140. /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* FETHMDIO */
  141. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
  142. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  143. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  144. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  145. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  146. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  147. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
  148. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
  149. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
  150. },
  151. /* Port D */
  152. { /* conf ppar psor pdir podr pdat */
  153. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  154. /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  155. /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
  156. /* PD28 */ { 0, 1, 0, 0, 0, 0 }, /* PD28 */
  157. /* PD27 */ { 0, 1, 1, 1, 0, 0 }, /* PD27 */
  158. /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
  159. /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
  160. /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
  161. /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
  162. /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
  163. /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
  164. /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
  165. /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  166. /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
  167. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  168. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
  169. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
  170. /* PD14 */ { 0, 0, 0, 1, 0, 0 }, /* LED */
  171. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  172. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  173. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  174. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  175. /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  176. /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  177. /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
  178. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  179. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  180. /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
  181. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  182. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  183. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  184. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  185. }
  186. };
  187. int board_early_init_f (void)
  188. {
  189. return 0;
  190. }
  191. int checkboard (void)
  192. {
  193. volatile immap_t *immap = (immap_t *) CFG_CCSRBAR;
  194. volatile ccsr_gur_t *gur = &immap->im_gur;
  195. /* PCI slot in USER bits CSR[6:7] by convention. */
  196. uint pci_slot = get_pci_slot ();
  197. uint pci_dual = get_pci_dual (); /* PCI DUAL in CM_PCI[3] */
  198. uint pci1_32 = gur->pordevsr & 0x10000; /* PORDEVSR[15] */
  199. uint pci1_clk_sel = gur->porpllsr & 0x8000; /* PORPLLSR[16] */
  200. uint pci2_clk_sel = gur->porpllsr & 0x4000; /* PORPLLSR[17] */
  201. uint pci1_speed = get_clock_freq (); /* PCI PSPEED in [4:5] */
  202. uint cpu_board_rev = get_cpu_board_revision ();
  203. printf ("Board: CDS Version 0x%02x, PCI Slot %d\n",
  204. get_board_version (), pci_slot);
  205. printf ("CPU Board Revision %d.%d (0x%04x)\n",
  206. MPC85XX_CPU_BOARD_MAJOR (cpu_board_rev),
  207. MPC85XX_CPU_BOARD_MINOR (cpu_board_rev), cpu_board_rev);
  208. printf (" PCI1: %d bit, %s MHz, %s\n",
  209. (pci1_32) ? 32 : 64,
  210. (pci1_speed == 33000000) ? "33" :
  211. (pci1_speed == 66000000) ? "66" : "unknown",
  212. pci1_clk_sel ? "sync" : "async");
  213. if (pci_dual) {
  214. printf (" PCI2: 32 bit, 66 MHz, %s\n",
  215. pci2_clk_sel ? "sync" : "async");
  216. } else {
  217. printf (" PCI2: disabled\n");
  218. }
  219. /*
  220. * Initialize local bus.
  221. */
  222. local_bus_init ();
  223. return 0;
  224. }
  225. long int
  226. initdram(int board_type)
  227. {
  228. long dram_size = 0;
  229. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  230. puts("Initializing\n");
  231. #if defined(CONFIG_DDR_DLL)
  232. {
  233. /*
  234. * Work around to stabilize DDR DLL MSYNC_IN.
  235. * Errata DDR9 seems to have been fixed.
  236. * This is now the workaround for Errata DDR11:
  237. * Override DLL = 1, Course Adj = 1, Tap Select = 0
  238. */
  239. volatile ccsr_gur_t *gur= &immap->im_gur;
  240. gur->ddrdllcr = 0x81000000;
  241. asm("sync;isync;msync");
  242. udelay(200);
  243. }
  244. #endif
  245. dram_size = spd_sdram();
  246. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  247. /*
  248. * Initialize and enable DDR ECC.
  249. */
  250. ddr_enable_ecc(dram_size);
  251. #endif
  252. /*
  253. * SDRAM Initialization
  254. */
  255. sdram_init();
  256. puts(" DDR: ");
  257. return dram_size;
  258. }
  259. /*
  260. * Initialize Local Bus
  261. */
  262. void
  263. local_bus_init(void)
  264. {
  265. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  266. volatile ccsr_gur_t *gur = &immap->im_gur;
  267. volatile ccsr_lbc_t *lbc = &immap->im_lbc;
  268. uint clkdiv;
  269. uint lbc_hz;
  270. sys_info_t sysinfo;
  271. uint temp_lbcdll;
  272. /*
  273. * Errata LBC11.
  274. * Fix Local Bus clock glitch when DLL is enabled.
  275. *
  276. * If localbus freq is < 66Mhz, DLL bypass mode must be used.
  277. * If localbus freq is > 133Mhz, DLL can be safely enabled.
  278. * Between 66 and 133, the DLL is enabled with an override workaround.
  279. */
  280. get_sys_info(&sysinfo);
  281. clkdiv = lbc->lcrr & 0x0f;
  282. lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
  283. if (lbc_hz < 66) {
  284. lbc->lcrr |= 0x80000000; /* DLL Bypass */
  285. } else if (lbc_hz >= 133) {
  286. lbc->lcrr &= (~0x80000000); /* DLL Enabled */
  287. } else {
  288. lbc->lcrr &= (~0x8000000); /* DLL Enabled */
  289. udelay(200);
  290. /*
  291. * Sample LBC DLL ctrl reg, upshift it to set the
  292. * override bits.
  293. */
  294. temp_lbcdll = gur->lbcdllcr;
  295. gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000);
  296. asm("sync;isync;msync");
  297. }
  298. }
  299. /*
  300. * Initialize SDRAM memory on the Local Bus.
  301. */
  302. void
  303. sdram_init(void)
  304. {
  305. #if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM)
  306. uint idx;
  307. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  308. volatile ccsr_lbc_t *lbc = &immap->im_lbc;
  309. uint *sdram_addr = (uint *)CFG_LBC_SDRAM_BASE;
  310. uint cpu_board_rev;
  311. uint lsdmr_common;
  312. puts(" SDRAM: ");
  313. print_size (CFG_LBC_SDRAM_SIZE * 1024 * 1024, "\n");
  314. /*
  315. * Setup SDRAM Base and Option Registers
  316. */
  317. lbc->or2 = CFG_OR2_PRELIM;
  318. asm("msync");
  319. lbc->br2 = CFG_BR2_PRELIM;
  320. asm("msync");
  321. lbc->lbcr = CFG_LBC_LBCR;
  322. asm("msync");
  323. lbc->lsrt = CFG_LBC_LSRT;
  324. lbc->mrtpr = CFG_LBC_MRTPR;
  325. asm("msync");
  326. /*
  327. * Determine which address lines to use baed on CPU board rev.
  328. */
  329. cpu_board_rev = get_cpu_board_revision();
  330. lsdmr_common = CFG_LBC_LSDMR_COMMON;
  331. if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_0) {
  332. lsdmr_common |= CFG_LBC_LSDMR_BSMA1617;
  333. } else if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_1) {
  334. lsdmr_common |= CFG_LBC_LSDMR_BSMA1516;
  335. } else {
  336. /*
  337. * Assume something unable to identify itself is
  338. * really old, and likely has lines 16/17 mapped.
  339. */
  340. lsdmr_common |= CFG_LBC_LSDMR_BSMA1617;
  341. }
  342. /*
  343. * Issue PRECHARGE ALL command.
  344. */
  345. lbc->lsdmr = lsdmr_common | CFG_LBC_LSDMR_OP_PCHALL;
  346. asm("sync;msync");
  347. *sdram_addr = 0xff;
  348. ppcDcbf((unsigned long) sdram_addr);
  349. udelay(100);
  350. /*
  351. * Issue 8 AUTO REFRESH commands.
  352. */
  353. for (idx = 0; idx < 8; idx++) {
  354. lbc->lsdmr = lsdmr_common | CFG_LBC_LSDMR_OP_ARFRSH;
  355. asm("sync;msync");
  356. *sdram_addr = 0xff;
  357. ppcDcbf((unsigned long) sdram_addr);
  358. udelay(100);
  359. }
  360. /*
  361. * Issue 8 MODE-set command.
  362. */
  363. lbc->lsdmr = lsdmr_common | CFG_LBC_LSDMR_OP_MRW;
  364. asm("sync;msync");
  365. *sdram_addr = 0xff;
  366. ppcDcbf((unsigned long) sdram_addr);
  367. udelay(100);
  368. /*
  369. * Issue NORMAL OP command.
  370. */
  371. lbc->lsdmr = lsdmr_common | CFG_LBC_LSDMR_OP_NORMAL;
  372. asm("sync;msync");
  373. *sdram_addr = 0xff;
  374. ppcDcbf((unsigned long) sdram_addr);
  375. udelay(200); /* Overkill. Must wait > 200 bus cycles */
  376. #endif /* enable SDRAM init */
  377. }
  378. #if defined(CFG_DRAM_TEST)
  379. int
  380. testdram(void)
  381. {
  382. uint *pstart = (uint *) CFG_MEMTEST_START;
  383. uint *pend = (uint *) CFG_MEMTEST_END;
  384. uint *p;
  385. printf("Testing DRAM from 0x%08x to 0x%08x\n",
  386. CFG_MEMTEST_START,
  387. CFG_MEMTEST_END);
  388. printf("DRAM test phase 1:\n");
  389. for (p = pstart; p < pend; p++)
  390. *p = 0xaaaaaaaa;
  391. for (p = pstart; p < pend; p++) {
  392. if (*p != 0xaaaaaaaa) {
  393. printf ("DRAM test fails at: %08x\n", (uint) p);
  394. return 1;
  395. }
  396. }
  397. printf("DRAM test phase 2:\n");
  398. for (p = pstart; p < pend; p++)
  399. *p = 0x55555555;
  400. for (p = pstart; p < pend; p++) {
  401. if (*p != 0x55555555) {
  402. printf ("DRAM test fails at: %08x\n", (uint) p);
  403. return 1;
  404. }
  405. }
  406. printf("DRAM test passed.\n");
  407. return 0;
  408. }
  409. #endif
  410. #if defined(CONFIG_PCI)
  411. /* For some reason the Tundra PCI bridge shows up on itself as a
  412. * different device. Work around that by refusing to configure it.
  413. */
  414. void dummy_func(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *tab) { }
  415. static struct pci_config_table pci_mpc85xxcds_config_table[] = {
  416. {0x10e3, 0x0513, PCI_ANY_ID, 1, 3, PCI_ANY_ID, dummy_func, {0,0,0}},
  417. {0x1106, 0x0686, PCI_ANY_ID, 1, 2, 0, mpc85xx_config_via, {0,0,0}},
  418. {0x1106, 0x0571, PCI_ANY_ID, 1, 2, 1,
  419. mpc85xx_config_via_usbide, {0,0,0}},
  420. {0x1105, 0x3038, PCI_ANY_ID, 1, 2, 2, mpc85xx_config_via_usb, {0,0,0}},
  421. {0x1106, 0x3038, PCI_ANY_ID, 1, 2, 3, mpc85xx_config_via_usb2, {0,0,0}},
  422. {0x1106, 0x3058, PCI_ANY_ID, 1, 2, 5,
  423. mpc85xx_config_via_power, {0,0,0}},
  424. {0x1106, 0x3068, PCI_ANY_ID, 1, 2, 6, mpc85xx_config_via_ac97, {0,0,0}},
  425. {},
  426. };
  427. static struct pci_controller hose[] = {
  428. { config_table: pci_mpc85xxcds_config_table,},
  429. #ifdef CONFIG_MPC85XX_PCI2
  430. {},
  431. #endif
  432. };
  433. #endif /* CONFIG_PCI */
  434. void
  435. pci_init_board(void)
  436. {
  437. #ifdef CONFIG_PCI
  438. pci_mpc85xx_init(hose);
  439. #endif
  440. }