zpc1900.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * (C) Copyright 2001-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2003-2005 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 <miiphy.h>
  30. /*
  31. * I/O Port configuration table
  32. *
  33. * if conf is 1, then that port pin will be configured at boot time
  34. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  35. */
  36. const iop_conf_t iop_conf_tab[4][32] = {
  37. /* Port A */
  38. { /* conf ppar psor pdir podr pdat */
  39. /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
  40. /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
  41. /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
  42. /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
  43. /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
  44. /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
  45. /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
  46. /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
  47. /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
  48. /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
  49. /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
  50. /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
  51. /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
  52. /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
  53. /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  54. /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  55. /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  56. /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  57. /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  58. /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  59. /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  60. /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  61. /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* SMC2 TXD */
  62. /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* SMC2 RXD */
  63. /* PA7 */ { 0, 0, 0, 0, 0, 0 }, /* PA7 */
  64. /* PA6 */ { 0, 0, 0, 0, 0, 0 }, /* PA6 */
  65. /* PA5 */ { 0, 0, 0, 0, 0, 0 }, /* PA5 */
  66. /* PA4 */ { 0, 0, 0, 0, 0, 0 }, /* PA4 */
  67. /* PA3 */ { 0, 0, 0, 0, 0, 0 }, /* PA3 */
  68. /* PA2 */ { 0, 0, 0, 0, 0, 0 }, /* PA2 */
  69. /* PA1 */ { 0, 0, 0, 0, 0, 0 }, /* PA1 */
  70. /* PA0 */ { 0, 0, 0, 0, 0, 0 } /* PA0 */
  71. },
  72. /* Port B */
  73. { /* conf ppar psor pdir podr pdat */
  74. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  75. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  76. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  77. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  78. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  79. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  80. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  81. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  82. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  83. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  84. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  85. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  86. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  87. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  88. /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
  89. /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
  90. /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
  91. /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
  92. /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
  93. /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
  94. /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  95. /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  96. /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  97. /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  98. /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  99. /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  100. /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  101. /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  102. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  103. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  104. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  105. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  106. },
  107. /* Port C */
  108. { /* conf ppar psor pdir podr pdat */
  109. /* PC31 */ { 0, 0, 0, 0, 0, 0 }, /* PC31 */
  110. /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
  111. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN CLSN */
  112. /* PC28 */ { 0, 0, 0, 0, 0, 0 }, /* PC28 */
  113. /* PC27 */ { 0, 0, 0, 0, 0, 0 }, /* PC27 */
  114. /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
  115. /* PC25 */ { 0, 0, 0, 0, 0, 0 }, /* PC25 */
  116. /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
  117. /* PC23 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  118. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  119. /* PC21 */ { 0, 0, 0, 0, 0, 0 }, /* PC21 */
  120. /* PC20 */ { 0, 0, 0, 0, 0, 0 }, /* PC20 */
  121. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII Rx Clock (CLK13) */
  122. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII Tx Clock (CLK14) */
  123. /* PC17 */ { 0, 0, 0, 0, 0, 0 }, /* PC17 */
  124. /* PC16 */ { 0, 0, 0, 0, 0, 0 }, /* PC16 */
  125. /* PC15 */ { 0, 0, 0, 0, 0, 0 }, /* PC15 */
  126. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RENA */
  127. /* PC13 */ { 0, 0, 0, 0, 0, 0 }, /* PC13 */
  128. /* PC12 */ { 0, 0, 0, 0, 0, 0 }, /* PC12 */
  129. /* PC11 */ { 0, 0, 0, 0, 0, 0 }, /* PC11 */
  130. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* LXT972 MDC */
  131. /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* LXT972 MDIO */
  132. /* PC8 */ { 0, 0, 0, 0, 0, 0 }, /* PC8 */
  133. /* PC7 */ { 0, 0, 0, 0, 0, 0 }, /* PC7 */
  134. /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* PC6 */
  135. /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* PC5 */
  136. /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* PC4 */
  137. /* PC3 */ { 0, 0, 0, 0, 0, 0 }, /* PC3 */
  138. /* PC2 */ { 0, 0, 0, 0, 0, 0 }, /* PC2 */
  139. /* PC1 */ { 0, 0, 0, 0, 0, 0 }, /* PC1 */
  140. /* PC0 */ { 0, 0, 0, 0, 0, 0 }, /* PC0 */
  141. },
  142. /* Port D */
  143. { /* conf ppar psor pdir podr pdat */
  144. /* PD31 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  145. /* PD30 */ { 0, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  146. /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
  147. /* PD28 */ { 0, 0, 0, 0, 0, 0 }, /* PD28 */
  148. /* PD27 */ { 0, 0, 0, 0, 0, 0 }, /* PD27 */
  149. /* PD26 */ { 0, 0, 0, 0, 0, 0 }, /* PD26 */
  150. /* PD25 */ { 0, 0, 0, 0, 0, 0 }, /* PD25 */
  151. /* PD24 */ { 0, 0, 0, 0, 0, 0 }, /* PD24 */
  152. /* PD23 */ { 0, 0, 0, 0, 0, 0 }, /* PD23 */
  153. /* PD22 */ { 0, 0, 0, 0, 0, 0 }, /* PD22 */
  154. /* PD21 */ { 0, 0, 0, 0, 0, 0 }, /* PD21 */
  155. /* PD20 */ { 0, 0, 0, 0, 0, 0 }, /* PD20 */
  156. /* PD19 */ { 0, 0, 0, 0, 0, 0 }, /* PD19 */
  157. /* PD18 */ { 0, 0, 0, 0, 0, 0 }, /* PD18 */
  158. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  159. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
  160. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
  161. /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
  162. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  163. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  164. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  165. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  166. /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  167. /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  168. /* PD7 */ { 0, 0, 0, 0, 0, 0 }, /* PD7 */
  169. /* PD6 */ { 0, 0, 0, 0, 0, 0 }, /* PD6 */
  170. /* PD5 */ { 0, 0, 0, 0, 0, 0 }, /* PD5 */
  171. /* PD4 */ { 0, 0, 0, 0, 0, 0 }, /* PD4 */
  172. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  173. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  174. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  175. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  176. }
  177. };
  178. #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
  179. void *nvram_read(void *dest, long src, size_t count)
  180. {
  181. return memcpy(dest, (const void *)src, count);
  182. }
  183. void nvram_write(long dest, const void *src, size_t count)
  184. {
  185. vu_char *p1 = (vu_char *)(CONFIG_SYS_EEPROM + 0x1555);
  186. vu_char *p2 = (vu_char *)(CONFIG_SYS_EEPROM + 0x0AAA);
  187. vu_char *d = (vu_char *)dest;
  188. const uchar *s = (const uchar *)src;
  189. /* Unprotect the EEPROM */
  190. *p1 = 0xAA;
  191. *p2 = 0x55;
  192. *p1 = 0x80;
  193. *p1 = 0xAA;
  194. *p2 = 0x55;
  195. *p1 = 0x20;
  196. udelay(10000);
  197. /* Write the data to the EEPROM */
  198. while (count--) {
  199. *d++ = *s++;
  200. while (*(d - 1) != *(s - 1))
  201. /* wait */;
  202. }
  203. /* Protect the EEPROM */
  204. *p1 = 0xAA;
  205. *p2 = 0x55;
  206. *p1 = 0xA0;
  207. udelay(10000);
  208. }
  209. #endif /* CONFIG_SYS_NVRAM_ACCESS_ROUTINE */
  210. phys_size_t initdram(int board_type)
  211. {
  212. vu_char *bcsr = (vu_char *)CONFIG_SYS_BCSR;
  213. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  214. volatile memctl8260_t *memctl = &immap->im_memctl;
  215. vu_char *ramaddr;
  216. uchar c = 0xFF;
  217. long int msize = CONFIG_SYS_SDRAM_SIZE;
  218. int i;
  219. if (bcsr[4] & BCSR_PCI_MODE) { /* PCI mode selected by JP9 */
  220. immap->im_clkrst.car_sccr |= SCCR_PCI_MODE;
  221. immap->im_siu_conf.sc_siumcr =
  222. (immap->im_siu_conf.sc_siumcr & ~SIUMCR_LBPC11)
  223. | SIUMCR_LBPC01;
  224. }
  225. #ifndef CONFIG_SYS_RAMBOOT
  226. immap->im_siu_conf.sc_ppc_acr = 0x03;
  227. immap->im_siu_conf.sc_ppc_alrh = 0x30126745;
  228. immap->im_siu_conf.sc_tescr1 = 0x00004000;
  229. memctl->memc_mptpr = CONFIG_SYS_MPTPR;
  230. #ifdef CONFIG_SYS_LSDRAM_BASE
  231. /*
  232. Initialise local bus SDRAM only if the pins
  233. are configured as local bus pins and not as PCI.
  234. */
  235. if ((immap->im_siu_conf.sc_siumcr & SIUMCR_LBPC11) == SIUMCR_LBPC00) {
  236. memctl->memc_lsrt = CONFIG_SYS_LSRT;
  237. memctl->memc_or4 = CONFIG_SYS_LSDRAM_OR;
  238. memctl->memc_br4 = CONFIG_SYS_LSDRAM_BR;
  239. ramaddr = (vu_char *)CONFIG_SYS_LSDRAM_BASE;
  240. memctl->memc_lsdmr = CONFIG_SYS_LSDMR | PSDMR_OP_PREA;
  241. *ramaddr = c;
  242. memctl->memc_lsdmr = CONFIG_SYS_LSDMR | PSDMR_OP_CBRR;
  243. for (i = 0; i < 8; i++)
  244. *ramaddr = c;
  245. memctl->memc_lsdmr = CONFIG_SYS_LSDMR | PSDMR_OP_MRW;
  246. *ramaddr = c;
  247. memctl->memc_lsdmr = CONFIG_SYS_LSDMR | PSDMR_RFEN;
  248. }
  249. #endif /* CONFIG_SYS_LSDRAM_BASE */
  250. /* Initialise 60x bus SDRAM */
  251. memctl->memc_psrt = CONFIG_SYS_PSRT;
  252. memctl->memc_or2 = CONFIG_SYS_PSDRAM_OR;
  253. memctl->memc_br2 = CONFIG_SYS_PSDRAM_BR;
  254. /*
  255. * The mode data for Mode Register Write command must appear on
  256. * the address lines during a mode-set cycle. It is driven by
  257. * the memory controller, in single PowerQUICC II mode,
  258. * according to PSDMR[CL] and PSDMR[BL] fields. In
  259. * 60x-compatible mode, software must drive the correct value on
  260. * the address lines. BL=0 because for 64-bit port size burst
  261. * length must be 4.
  262. */
  263. ramaddr = (vu_char *)(CONFIG_SYS_SDRAM_BASE |
  264. ((CONFIG_SYS_PSDMR & PSDMR_CL_MSK) << 7) | 0x10);
  265. memctl->memc_psdmr = CONFIG_SYS_PSDMR | PSDMR_OP_PREA; /* Precharge all banks */
  266. *ramaddr = c;
  267. memctl->memc_psdmr = CONFIG_SYS_PSDMR | PSDMR_OP_CBRR; /* CBR refresh */
  268. for (i = 0; i < 8; i++)
  269. *ramaddr = c;
  270. memctl->memc_psdmr = CONFIG_SYS_PSDMR | PSDMR_OP_MRW; /* Mode Register write */
  271. *ramaddr = c;
  272. memctl->memc_psdmr = CONFIG_SYS_PSDMR | PSDMR_RFEN; /* Refresh enable */
  273. *ramaddr = c;
  274. #endif /* CONFIG_SYS_RAMBOOT */
  275. /* Return total 60x bus SDRAM size */
  276. return msize * 1024 * 1024;
  277. }
  278. int checkboard(void)
  279. {
  280. vu_char *bcsr = (vu_char *)CONFIG_SYS_BCSR;
  281. printf("Board: Zephyr ZPC.1900 Rev. %c\n", bcsr[2] + 0x40);
  282. return 0;
  283. }