zpc1900.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /*
  2. * (C) Copyright 2001-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2003 Arabella Software Ltd.
  6. * Yuli Barcohen <yuli@arabellasw.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 <ioports.h>
  28. #include <mpc8260.h>
  29. #include <asm/m8260_pci.h>
  30. #include <i2c.h>
  31. #include <spd.h>
  32. #include <miiphy.h>
  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 */
  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 }, /* SMC2 TXD */
  65. /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* SMC2 RXD */
  66. /* PA7 */ { 0, 0, 0, 0, 0, 0 }, /* PA7 */
  67. /* PA6 */ { 0, 0, 0, 0, 0, 0 }, /* PA6 */
  68. /* PA5 */ { 0, 0, 0, 0, 0, 0 }, /* PA5 */
  69. /* PA4 */ { 0, 0, 0, 0, 0, 0 }, /* PA4 */
  70. /* PA3 */ { 0, 0, 0, 0, 0, 0 }, /* PA3 */
  71. /* PA2 */ { 0, 0, 0, 0, 0, 0 }, /* PA2 */
  72. /* PA1 */ { 0, 0, 0, 0, 0, 0 }, /* PA1 */
  73. /* PA0 */ { 0, 0, 0, 0, 0, 0 } /* PA0 */
  74. },
  75. /* Port B */
  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, 0, 0, 0 }, /* PC31 */
  113. /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
  114. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN CLSN */
  115. /* PC28 */ { 0, 0, 0, 0, 0, 0 }, /* PC28 */
  116. /* PC27 */ { 0, 0, 0, 0, 0, 0 }, /* PC27 */
  117. /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
  118. /* PC25 */ { 0, 0, 0, 0, 0, 0 }, /* PC25 */
  119. /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
  120. /* PC23 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  121. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  122. /* PC21 */ { 0, 0, 0, 0, 0, 0 }, /* PC21 */
  123. /* PC20 */ { 0, 0, 0, 0, 0, 0 }, /* PC20 */
  124. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII Rx Clock (CLK13) */
  125. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII Tx Clock (CLK14) */
  126. /* PC17 */ { 0, 0, 0, 0, 0, 0 }, /* PC17 */
  127. /* PC16 */ { 0, 0, 0, 0, 0, 0 }, /* PC16 */
  128. /* PC15 */ { 0, 0, 0, 0, 0, 0 }, /* PC15 */
  129. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RENA */
  130. /* PC13 */ { 0, 0, 0, 0, 0, 0 }, /* PC13 */
  131. /* PC12 */ { 0, 0, 0, 0, 0, 0 }, /* PC12 */
  132. /* PC11 */ { 0, 0, 0, 0, 0, 0 }, /* PC11 */
  133. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* LXT972 MDC */
  134. /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* LXT972 MDIO */
  135. /* PC8 */ { 0, 0, 0, 0, 0, 0 }, /* PC8 */
  136. /* PC7 */ { 0, 0, 0, 0, 0, 0 }, /* PC7 */
  137. /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* PC6 */
  138. /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* PC5 */
  139. /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* PC4 */
  140. /* PC3 */ { 0, 0, 0, 0, 0, 0 }, /* PC3 */
  141. /* PC2 */ { 0, 0, 0, 0, 0, 0 }, /* PC2 */
  142. /* PC1 */ { 0, 0, 0, 0, 0, 0 }, /* PC1 */
  143. /* PC0 */ { 0, 0, 0, 0, 0, 0 }, /* PC0 */
  144. },
  145. /* Port D */
  146. { /* conf ppar psor pdir podr pdat */
  147. /* PD31 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  148. /* PD30 */ { 0, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  149. /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
  150. /* PD28 */ { 0, 0, 0, 0, 0, 0 }, /* PD28 */
  151. /* PD27 */ { 0, 0, 0, 0, 0, 0 }, /* PD27 */
  152. /* PD26 */ { 0, 0, 0, 0, 0, 0 }, /* PD26 */
  153. /* PD25 */ { 0, 0, 0, 0, 0, 0 }, /* PD25 */
  154. /* PD24 */ { 0, 0, 0, 0, 0, 0 }, /* PD24 */
  155. /* PD23 */ { 0, 0, 0, 0, 0, 0 }, /* PD23 */
  156. /* PD22 */ { 0, 0, 0, 0, 0, 0 }, /* PD22 */
  157. /* PD21 */ { 0, 0, 0, 0, 0, 0 }, /* PD21 */
  158. /* PD20 */ { 0, 0, 0, 0, 0, 0 }, /* PD20 */
  159. /* PD19 */ { 0, 0, 0, 0, 0, 0 }, /* PD19 */
  160. /* PD18 */ { 0, 0, 0, 0, 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 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  164. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  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 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  170. /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  171. /* PD7 */ { 0, 0, 0, 0, 0, 0 }, /* PD7 */
  172. /* PD6 */ { 0, 0, 0, 0, 0, 0 }, /* PD6 */
  173. /* PD5 */ { 0, 0, 0, 0, 0, 0 }, /* PD5 */
  174. /* PD4 */ { 0, 0, 0, 0, 0, 0 }, /* 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. #ifdef CFG_NVRAM_ACCESS_ROUTINE
  182. void *nvram_read(void *dest, long src, size_t count)
  183. {
  184. return memcpy(dest, (const void *)src, count);
  185. }
  186. void nvram_write(long dest, const void *src, size_t count)
  187. {
  188. vu_char *p1 = (vu_char *)(CFG_EEPROM + 0x1555);
  189. vu_char *p2 = (vu_char *)(CFG_EEPROM + 0x0AAA);
  190. vu_char *d = (vu_char *)dest;
  191. const uchar *s = (const uchar *)src;
  192. /* Unprotect the EEPROM */
  193. *p1 = 0xAA;
  194. *p2 = 0x55;
  195. *p1 = 0x80;
  196. *p1 = 0xAA;
  197. *p2 = 0x55;
  198. *p1 = 0x20;
  199. udelay(10000);
  200. /* Write the data to the EEPROM */
  201. while (count--) {
  202. *d++ = *s++;
  203. while (*(d - 1) != *(s - 1))
  204. /* wait */;
  205. }
  206. /* Protect the EEPROM */
  207. *p1 = 0xAA;
  208. *p2 = 0x55;
  209. *p1 = 0xA0;
  210. udelay(10000);
  211. }
  212. #endif /* CFG_NVRAM_ACCESS_ROUTINE */
  213. long int initdram(int board_type)
  214. {
  215. vu_char *bcsr = (vu_char *)CFG_BCSR;
  216. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  217. volatile memctl8260_t *memctl = &immap->im_memctl;
  218. vu_char *ramaddr;
  219. uchar c = 0xFF;
  220. long int msize = CFG_SDRAM_SIZE;
  221. uint psdmr = CFG_PSDMR;
  222. int i;
  223. if (bcsr[4] & BCSR_PCI_MODE) { /* PCI mode selected by JP9 */
  224. immap->im_clkrst.car_sccr |= M826X_SCCR_PCI_MODE_EN;
  225. immap->im_siu_conf.sc_siumcr =
  226. (immap->im_siu_conf.sc_siumcr & ~SIUMCR_LBPC11)
  227. | SIUMCR_LBPC01;
  228. }
  229. #ifndef CFG_RAMBOOT
  230. immap->im_siu_conf.sc_ppc_acr = 0x03;
  231. immap->im_siu_conf.sc_ppc_alrh = 0x30126745;
  232. immap->im_siu_conf.sc_tescr1 = 0x00004000;
  233. memctl->memc_mptpr = CFG_MPTPR;
  234. #ifdef CFG_LSDRAM_BASE
  235. /*
  236. Initialise local bus SDRAM only if the pins
  237. are configured as local bus pins and not as PCI.
  238. */
  239. if ((immap->im_siu_conf.sc_siumcr & SIUMCR_LBPC11) == SIUMCR_LBPC00) {
  240. memctl->memc_lsrt = CFG_LSRT;
  241. memctl->memc_or4 = 0xFFC01480;
  242. memctl->memc_br4 = CFG_LSDRAM_BASE | 0x00001861;
  243. memctl->memc_lsdmr = CFG_LSDMR | PSDMR_OP_PREA;
  244. ramaddr = (vu_char *)CFG_LSDRAM_BASE;
  245. *ramaddr = c;
  246. memctl->memc_lsdmr = CFG_LSDMR | PSDMR_OP_CBRR;
  247. for (i = 0; i < 8; i++)
  248. *ramaddr = c;
  249. memctl->memc_lsdmr = CFG_LSDMR | PSDMR_OP_MRW;
  250. *ramaddr = c;
  251. memctl->memc_lsdmr = CFG_LSDMR | PSDMR_RFEN;
  252. }
  253. #endif /* CFG_LSDRAM_BASE */
  254. /* Initialise 60x bus SDRAM */
  255. memctl->memc_psrt = CFG_PSRT;
  256. memctl->memc_or2 = 0xFC0028C0;
  257. memctl->memc_br2 = CFG_SDRAM_BASE | 0x00000041;
  258. /*
  259. * The mode data for Mode Register Write command must appear on
  260. * the address lines during a mode-set cycle. It is driven by
  261. * the memory controller, in single PowerQUICC II mode,
  262. * according to PSDMR[CL] and PSDMR[BL] fields. In
  263. * 60x-compatible mode, software must drive the correct value on
  264. * the address lines. BL=0 because for 64-bit port size burst
  265. * length must be 4.
  266. */
  267. ramaddr = (vu_char *)(CFG_SDRAM_BASE |
  268. ((psdmr & PSDMR_CL_MSK) << 7) | 0x10);
  269. memctl->memc_psdmr = psdmr | PSDMR_OP_PREA; /* Precharge all banks */
  270. *ramaddr = c;
  271. memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR; /* CBR refresh */
  272. for (i = 0; i < 8; i++)
  273. *ramaddr = c;
  274. memctl->memc_psdmr = psdmr | PSDMR_OP_MRW; /* Mode Register write */
  275. *ramaddr = c;
  276. memctl->memc_psdmr = psdmr | PSDMR_RFEN; /* Refresh enable */
  277. *ramaddr = c;
  278. #endif /* CFG_RAMBOOT */
  279. /* Return total 60x bus SDRAM size */
  280. return msize * 1024 * 1024;
  281. }
  282. int checkboard(void)
  283. {
  284. vu_char *bcsr = (vu_char *)CFG_BCSR;
  285. printf("Board: Zephyr ZPC.1900 Rev. %c\n", bcsr[2] + 0x40);
  286. return 0;
  287. }