mpc8260ads.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. /*
  2. * (C) Copyright 2001-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * Modified during 2001 by
  6. * Advanced Communications Technologies (Australia) Pty. Ltd.
  7. * Howard Walker, Tuong Vu-Dinh
  8. *
  9. * (C) Copyright 2001, Stuart Hughes, Lineo Inc, stuarth@lineo.com
  10. * Added support for the 16M dram simm on the 8260ads boards
  11. *
  12. * (C) Copyright 2003 Arabella Software Ltd.
  13. * Yuli Barcohen <yuli@arabellasw.com>
  14. * Added support for SDRAM DIMMs SPD EEPROM, MII, Ethernet PHY init.
  15. *
  16. * See file CREDITS for list of people who contributed to this
  17. * project.
  18. *
  19. * This program is free software; you can redistribute it and/or
  20. * modify it under the terms of the GNU General Public License as
  21. * published by the Free Software Foundation; either version 2 of
  22. * the License, or (at your option) any later version.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program; if not, write to the Free Software
  31. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  32. * MA 02111-1307 USA
  33. */
  34. #include <common.h>
  35. #include <ioports.h>
  36. #include <mpc8260.h>
  37. #include <asm/m8260_pci.h>
  38. #include <i2c.h>
  39. #include <spd.h>
  40. #include <miiphy.h>
  41. /*
  42. * I/O Port configuration table
  43. *
  44. * if conf is 1, then that port pin will be configured at boot time
  45. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  46. */
  47. const iop_conf_t iop_conf_tab[4][32] = {
  48. /* Port A configuration */
  49. { /* conf ppar psor pdir podr pdat */
  50. /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
  51. /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
  52. /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
  53. /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
  54. /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
  55. /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
  56. /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
  57. /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
  58. /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
  59. /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
  60. /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
  61. /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
  62. /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
  63. /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
  64. /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  65. /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  66. /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  67. /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  68. /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  69. /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  70. /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  71. /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  72. /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */
  73. /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */
  74. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  75. /* PA6 */ { 1, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */
  76. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  77. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  78. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  79. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  80. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
  81. /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
  82. },
  83. /* Port B configuration */
  84. { /* conf ppar psor pdir podr pdat */
  85. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  86. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  87. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  88. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  89. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  90. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  91. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  92. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  93. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  94. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  95. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  96. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  97. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  98. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  99. /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
  100. /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
  101. /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
  102. /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
  103. /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
  104. /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
  105. /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  106. /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  107. /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  108. /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  109. /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  110. /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  111. /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  112. /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  113. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  114. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  115. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  116. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  117. },
  118. /* Port C */
  119. { /* conf ppar psor pdir podr pdat */
  120. /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
  121. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  122. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
  123. /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
  124. /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */
  125. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  126. /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
  127. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  128. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
  129. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
  130. /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  131. /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  132. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII Rx Clock (CLK13) */
  133. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII Tx Clock (CLK14) */
  134. /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
  135. /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */
  136. /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */
  137. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
  138. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  139. /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */
  140. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */
  141. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* LXT970 FETHMDC */
  142. /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* LXT970 FETHMDIO */
  143. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
  144. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  145. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  146. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  147. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  148. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  149. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
  150. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
  151. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
  152. },
  153. /* Port D */
  154. { /* conf ppar psor pdir podr pdat */
  155. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 UART RxD */
  156. /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 UART TxD */
  157. /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
  158. /* PD28 */ { 0, 1, 0, 0, 0, 0 }, /* PD28 */
  159. /* PD27 */ { 0, 1, 1, 1, 0, 0 }, /* PD27 */
  160. /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
  161. /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
  162. /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
  163. /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
  164. /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
  165. /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
  166. /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
  167. /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  168. /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
  169. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  170. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
  171. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  172. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  173. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  174. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  175. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  176. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  177. /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  178. /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  179. /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
  180. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  181. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  182. /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
  183. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  184. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  185. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  186. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  187. }
  188. };
  189. void reset_phy (void)
  190. {
  191. vu_long *bcsr = (vu_long *)CFG_BCSR;
  192. /* reset the FEC port */
  193. bcsr[1] &= ~FETH1_RST;
  194. udelay(2);
  195. bcsr[1] |= FETH1_RST;
  196. udelay(1000);
  197. #ifdef CONFIG_MII
  198. #if CONFIG_ADSTYPE == CFG_PQ2FADS
  199. /*
  200. * Do not bypass Rx/Tx (de)scrambler (fix configuration error)
  201. * Enable autonegotiation.
  202. */
  203. miiphy_write(0, 16, 0x610);
  204. miiphy_write(0, PHY_BMCR, PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
  205. #else
  206. /*
  207. * Ethernet PHY is configured (by means of configuration pins)
  208. * to work at 10Mb/s only. We reconfigure it using MII
  209. * to advertise all capabilities, including 100Mb/s, and
  210. * restart autonegotiation.
  211. */
  212. miiphy_write(0, PHY_ANAR, 0x01E1); /* Advertise all capabilities */
  213. miiphy_write(0, PHY_DCR, 0x0000); /* Do not bypass Rx/Tx (de)scrambler */
  214. miiphy_write(0, PHY_BMCR, PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
  215. #endif /* CONFIG_ADSTYPE == CFG_PQ2FADS */
  216. #endif /* CONFIG_MII */
  217. }
  218. int board_pre_init (void)
  219. {
  220. vu_long *bcsr = (vu_long *)CFG_BCSR;
  221. bcsr[1] = ~FETHIEN1 & ~RS232EN_1;
  222. return 0;
  223. }
  224. #define ns2clk(ns) (ns / (1000000000 / CONFIG_8260_CLKIN) + 1)
  225. long int initdram (int board_type)
  226. {
  227. vu_long *bcsr = (vu_long *)CFG_BCSR;
  228. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  229. volatile memctl8260_t *memctl = &immap->im_memctl;
  230. volatile uchar *ramaddr, c = 0xff;
  231. long int msize;
  232. uint or;
  233. uint psdmr;
  234. uint psrt;
  235. int i;
  236. #ifndef CFG_RAMBOOT
  237. immap->im_siu_conf.sc_ppc_acr = 0x00000002;
  238. immap->im_siu_conf.sc_ppc_alrh = 0x01267893;
  239. immap->im_siu_conf.sc_tescr1 = 0x00004000;
  240. #if CONFIG_ADSTYPE == CFG_PQ2FADS
  241. if ((bcsr[3] & BCSR_PCI_MODE) == 0) { /* PCI mode selected by JP9 */
  242. immap->im_clkrst.car_sccr |= M826X_SCCR_PCI_MODE_EN;
  243. immap->im_siu_conf.sc_siumcr =
  244. (immap->im_siu_conf.sc_siumcr & ~SIUMCR_LBPC11)
  245. | SIUMCR_LBPC01;
  246. }
  247. #endif /* CONFIG_ADSTYPE == CFG_PQ2FADS */
  248. memctl->memc_mptpr = CFG_MPTPR;
  249. #ifdef CFG_LSDRAM_BASE
  250. /*
  251. Initialise local bus SDRAM only if the pins
  252. are configured as local bus pins and not as PCI.
  253. The configuration is determined by the HRCW.
  254. */
  255. if ((immap->im_siu_conf.sc_siumcr & SIUMCR_LBPC11) == SIUMCR_LBPC00) {
  256. memctl->memc_lsrt = CFG_LSRT;
  257. #if CONFIG_ADSTYPE == CFG_PQ2FADS /* CS3 */
  258. memctl->memc_or3 = 0xFF803280;
  259. memctl->memc_br3 = CFG_LSDRAM_BASE | 0x00001861;
  260. #else /* CS4 */
  261. memctl->memc_or4 = 0xFFC01480;
  262. memctl->memc_br4 = CFG_LSDRAM_BASE | 0x00001861;
  263. #endif /* CONFIG_ADSTYPE == CFG_PQ2FADS */
  264. memctl->memc_lsdmr = CFG_LSDMR | 0x28000000;
  265. ramaddr = (uchar *) CFG_LSDRAM_BASE;
  266. *ramaddr = c;
  267. memctl->memc_lsdmr = CFG_LSDMR | 0x08000000;
  268. for (i = 0; i < 8; i++)
  269. *ramaddr = c;
  270. memctl->memc_lsdmr = CFG_LSDMR | 0x18000000;
  271. *ramaddr = c;
  272. memctl->memc_lsdmr = CFG_LSDMR | 0x40000000;
  273. }
  274. #endif /* CFG_LSDRAM_BASE */
  275. /* Init 60x bus SDRAM */
  276. #ifdef CONFIG_SPD_EEPROM
  277. {
  278. spd_eeprom_t spd;
  279. uint pbi, bsel, rowst, lsb, tmp;
  280. i2c_read (CONFIG_SPD_ADDR, 0, 1, (uchar *) & spd, sizeof (spd));
  281. /* Bank-based interleaving is not supported for physical bank
  282. sizes greater than 128MB which is encoded as 0x20 in SPD
  283. */
  284. pbi = (spd.row_dens > 32) ? 1 : CONFIG_SDRAM_PBI;
  285. msize = spd.nrows * (4 * spd.row_dens); /* Mixed size not supported */
  286. or = ~(msize - 1) << 20; /* SDAM */
  287. switch (spd.nbanks) { /* BPD */
  288. case 2:
  289. bsel = 1;
  290. break;
  291. case 4:
  292. bsel = 2;
  293. or |= 0x00002000;
  294. break;
  295. case 8:
  296. bsel = 3;
  297. or |= 0x00004000;
  298. break;
  299. }
  300. lsb = 3; /* For 64-bit port, lsb is 3 bits */
  301. if (pbi) { /* Bus partition depends on interleaving */
  302. rowst = 32 - (spd.nrow_addr + spd.ncol_addr + bsel + lsb);
  303. or |= (rowst << 9); /* ROWST */
  304. } else {
  305. rowst = 32 - (spd.nrow_addr + spd.ncol_addr + lsb);
  306. or |= ((rowst * 2 - 12) << 9); /* ROWST */
  307. }
  308. or |= ((spd.nrow_addr - 9) << 6); /* NUMR */
  309. psdmr = (pbi << 31); /* PBI */
  310. /* Bus multiplexing parameters */
  311. tmp = 32 - (lsb + spd.nrow_addr); /* Tables 10-19 and 10-20 */
  312. psdmr |= ((tmp - (rowst - 5) - 13) << 24); /* SDAM */
  313. psdmr |= ((tmp - 3 - 12) << 21); /* BSMA */
  314. tmp = (31 - lsb - 10) - tmp;
  315. /* Pin connected to SDA10 is (31 - lsb - 10).
  316. rowst is multiplexed over (32 - (lsb + spd.nrow_addr)),
  317. so (rowst + tmp) alternates with AP.
  318. */
  319. if (pbi) /* Table 10-7 */
  320. psdmr |= ((10 - (rowst + tmp)) << 18); /* SDA10 */
  321. else
  322. psdmr |= ((12 - (rowst + tmp)) << 18); /* SDA10 */
  323. /* SDRAM device-specific parameters */
  324. tmp = ns2clk (70); /* Refresh recovery is not in SPD, so assume 70ns */
  325. switch (tmp) { /* RFRC */
  326. case 1:
  327. case 2:
  328. psdmr |= (1 << 15);
  329. break;
  330. case 3:
  331. case 4:
  332. case 5:
  333. case 6:
  334. case 7:
  335. case 8:
  336. psdmr |= ((tmp - 2) << 15);
  337. break;
  338. default:
  339. psdmr |= (7 << 15);
  340. }
  341. psdmr |= (ns2clk (spd.trp) % 8 << 12); /* PRETOACT */
  342. psdmr |= (ns2clk (spd.trcd) % 8 << 9); /* ACTTORW */
  343. /* BL=0 because for 64-bit SDRAM burst length must be 4 */
  344. /* LDOTOPRE ??? */
  345. for (i = 0, tmp = spd.write_lat; (i < 4) && ((tmp & 1) == 0); i++)
  346. tmp >>= 1;
  347. switch (i) { /* WRC */
  348. case 0:
  349. case 1:
  350. psdmr |= (1 << 4);
  351. break;
  352. case 2:
  353. case 3:
  354. psdmr |= (i << 4);
  355. break;
  356. }
  357. /* EAMUX=0 - no external address multiplexing */
  358. /* BUFCMD=0 - no external buffers */
  359. for (i = 1, tmp = spd.cas_lat; (i < 3) && ((tmp & 1) == 0); i++)
  360. tmp >>= 1;
  361. psdmr |= i; /* CL */
  362. switch (spd.refresh & 0x7F) {
  363. case 1:
  364. tmp = 3900;
  365. break;
  366. case 2:
  367. tmp = 7800;
  368. break;
  369. case 3:
  370. tmp = 31300;
  371. break;
  372. case 4:
  373. tmp = 62500;
  374. break;
  375. case 5:
  376. tmp = 125000;
  377. break;
  378. default:
  379. tmp = 15625;
  380. }
  381. psrt = tmp / (1000000000 / CONFIG_8260_CLKIN *
  382. ((memctl->memc_mptpr >> 8) + 1)) - 1;
  383. #ifdef SPD_DEBUG
  384. printf ("\nDIMM type: %-18.18s\n", spd.mpart);
  385. printf ("SPD size: %d\n", spd.info_size);
  386. printf ("EEPROM size: %d\n", 1 << spd.chip_size);
  387. printf ("Memory type: %d\n", spd.mem_type);
  388. printf ("Row addr: %d\n", spd.nrow_addr);
  389. printf ("Column addr: %d\n", spd.ncol_addr);
  390. printf ("# of rows: %d\n", spd.nrows);
  391. printf ("Row density: %d\n", spd.row_dens);
  392. printf ("# of banks: %d\n", spd.nbanks);
  393. printf ("Data width: %d\n",
  394. 256 * spd.dataw_msb + spd.dataw_lsb);
  395. printf ("Chip width: %d\n", spd.primw);
  396. printf ("Refresh rate: %02X\n", spd.refresh);
  397. printf ("CAS latencies: %02X\n", spd.cas_lat);
  398. printf ("Write latencies: %02X\n", spd.write_lat);
  399. printf ("tRP: %d\n", spd.trp);
  400. printf ("tRCD: %d\n", spd.trcd);
  401. printf ("OR=%X, PSDMR=%08X, PSRT=%0X\n", or, psdmr, psrt);
  402. #endif /* SPD_DEBUG */
  403. }
  404. #else /* !CONFIG_SPD_EEPROM */
  405. #if CONFIG_ADSTYPE == CFG_PQ2FADS
  406. msize = 32;
  407. or = 0xFE002EC0;
  408. #else
  409. msize = 16;
  410. or = 0xFF000CA0;
  411. #endif /* CONFIG_ADSTYPE == CFG_PQ2FADS */
  412. psdmr = CFG_PSDMR;
  413. psrt = CFG_PSRT;
  414. #endif /* CONFIG_SPD_EEPROM */
  415. memctl->memc_psrt = psrt;
  416. memctl->memc_or2 = or;
  417. memctl->memc_br2 = CFG_SDRAM_BASE | 0x00000041;
  418. ramaddr = (uchar *) CFG_SDRAM_BASE;
  419. memctl->memc_psdmr = psdmr | 0x28000000; /* Precharge all banks */
  420. *ramaddr = c;
  421. memctl->memc_psdmr = psdmr | 0x08000000; /* CBR refresh */
  422. for (i = 0; i < 8; i++)
  423. *ramaddr = c;
  424. memctl->memc_psdmr = psdmr | 0x18000000; /* Mode Register write */
  425. *ramaddr = c;
  426. memctl->memc_psdmr = psdmr | 0x40000000; /* Refresh enable */
  427. *ramaddr = c;
  428. #endif
  429. /* return total 60x bus SDRAM size */
  430. return (msize * 1024 * 1024);
  431. }
  432. int checkboard (void)
  433. {
  434. #if CONFIG_ADSTYPE == CFG_8260ADS
  435. puts ("Board: Motorola MPC8260ADS\n");
  436. #elif CONFIG_ADSTYPE == CFG_8266ADS
  437. puts ("Board: Motorola MPC8266ADS\n");
  438. #elif CONFIG_ADSTYPE == CFG_PQ2FADS
  439. puts ("Board: Motorola PQ2FADS-ZU\n");
  440. #else
  441. puts ("Board: unknown\n");
  442. #endif
  443. return 0;
  444. }