ep8248.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * Copyright (C) 2004 Arabella Software Ltd.
  3. * Yuli Barcohen <yuli@arabellasw.com>
  4. *
  5. * Support for Embedded Planet EP8248 boards.
  6. * Tested on EP8248E.
  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 <mpc8260.h>
  28. #include <ioports.h>
  29. /*
  30. * I/O Port configuration table
  31. *
  32. * if conf is 1, then that port pin will be configured at boot time
  33. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  34. */
  35. #define CONFIG_SYS_FCC1 (CONFIG_ETHER_INDEX == 1)
  36. #define CONFIG_SYS_FCC2 (CONFIG_ETHER_INDEX == 2)
  37. const iop_conf_t iop_conf_tab[4][32] = {
  38. /* Port A */
  39. { /* conf ppar psor pdir podr pdat */
  40. /* PA31 */ { CONFIG_SYS_FCC1, 1, 1, 0, 0, 0 }, /* FCC1 MII COL */
  41. /* PA30 */ { CONFIG_SYS_FCC1, 1, 1, 0, 0, 0 }, /* FCC1 MII CRS */
  42. /* PA29 */ { CONFIG_SYS_FCC1, 1, 1, 1, 0, 0 }, /* FCC1 MII TX_ER */
  43. /* PA28 */ { CONFIG_SYS_FCC1, 1, 1, 1, 0, 0 }, /* FCC1 MII TX_EN */
  44. /* PA27 */ { CONFIG_SYS_FCC1, 1, 1, 0, 0, 0 }, /* FCC1 MII RX_DV */
  45. /* PA26 */ { CONFIG_SYS_FCC1, 1, 1, 0, 0, 0 }, /* FCC1 MII RX_ER */
  46. /* PA25 */ { 0, 0, 0, 0, 0, 0 }, /* PA25 */
  47. /* PA24 */ { 0, 0, 0, 0, 0, 0 }, /* PA24 */
  48. /* PA23 */ { 0, 0, 0, 0, 0, 0 }, /* PA23 */
  49. /* PA22 */ { 0, 0, 0, 0, 0, 0 }, /* PA22 */
  50. /* PA21 */ { CONFIG_SYS_FCC1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[3] */
  51. /* PA20 */ { CONFIG_SYS_FCC1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[2] */
  52. /* PA19 */ { CONFIG_SYS_FCC1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[1] */
  53. /* PA18 */ { CONFIG_SYS_FCC1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[0] */
  54. /* PA17 */ { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[0] */
  55. /* PA16 */ { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[1] */
  56. /* PA15 */ { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[2] */
  57. /* PA14 */ { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[3] */
  58. /* PA13 */ { 0, 0, 0, 0, 0, 0 }, /* PA13 */
  59. /* PA12 */ { 0, 0, 0, 0, 0, 0 }, /* PA12 */
  60. /* PA11 */ { 0, 0, 0, 0, 0, 0 }, /* PA11 */
  61. /* PA10 */ { 0, 0, 0, 0, 0, 0 }, /* PA10 */
  62. /* PA9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC2 TxD */
  63. /* PA8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC2 RxD */
  64. /* PA7 */ { 0, 0, 0, 0, 0, 0 }, /* PA7 */
  65. /* PA6 */ { 0, 0, 0, 0, 0, 0 }, /* PA6 */
  66. /* PA5 */ { 0, 0, 0, 0, 0, 0 }, /* PA5 */
  67. /* PA4 */ { 0, 0, 0, 0, 0, 0 }, /* PA4 */
  68. /* PA3 */ { 0, 0, 0, 0, 0, 0 }, /* PA3 */
  69. /* PA2 */ { 0, 0, 0, 0, 0, 0 }, /* PA2 */
  70. /* PA1 */ { 0, 0, 0, 0, 0, 0 }, /* PA1 */
  71. /* PA0 */ { 0, 0, 0, 0, 0, 0 } /* PA0 */
  72. },
  73. /* Port B */
  74. { /* conf ppar psor pdir podr pdat */
  75. /* PB31 */ { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  76. /* PB30 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  77. /* PB29 */ { CONFIG_SYS_FCC2, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  78. /* PB28 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  79. /* PB27 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  80. /* PB26 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  81. /* PB25 */ { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  82. /* PB24 */ { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  83. /* PB23 */ { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  84. /* PB22 */ { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  85. /* PB21 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  86. /* PB20 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  87. /* PB19 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  88. /* PB18 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  89. /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  90. /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  91. /* PB15 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  92. /* PB14 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  93. /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  94. /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  95. /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  96. /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  97. /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  98. /* PB8 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  99. /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  100. /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  101. /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  102. /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  103. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  104. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  105. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  106. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* non-existent */
  107. },
  108. /* Port C */
  109. { /* conf ppar psor pdir podr pdat */
  110. /* PC31 */ { 0, 0, 0, 0, 0, 0 }, /* PC31 */
  111. /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
  112. /* PC29 */ { 0, 0, 0, 0, 0, 0 }, /* PC29 */
  113. /* PC28 */ { 0, 0, 0, 0, 0, 0 }, /* PC28 */
  114. /* PC27 */ { 0, 0, 0, 0, 0, 0 }, /* PC27 */
  115. /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
  116. /* PC25 */ { 0, 0, 0, 0, 0, 0 }, /* PC25 */
  117. /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
  118. /* PC23 */ { 0, 0, 0, 0, 0, 0 }, /* PC23 */
  119. /* PC22 */ { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 RxClk (CLK10) */
  120. /* PC21 */ { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 TxClk (CLK11) */
  121. /* PC20 */ { 0, 0, 0, 0, 0, 0 }, /* PC20 */
  122. /* PC19 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 RxClk (CLK13) */
  123. /* PC18 */ { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 TxClk (CLK14) */
  124. /* PC17 */ { 0, 0, 0, 0, 0, 0 }, /* PC17 */
  125. /* PC16 */ { 0, 0, 0, 0, 0, 0 }, /* PC16 */
  126. /* PC15 */ { 0, 0, 0, 0, 0, 0 }, /* PC15 */
  127. /* PC14 */ { 0, 0, 0, 0, 0, 0 }, /* PC14 */
  128. /* PC13 */ { 0, 0, 0, 0, 0, 0 }, /* PC13 */
  129. /* PC12 */ { 0, 0, 0, 0, 0, 0 }, /* PC12 */
  130. /* PC11 */ { 0, 0, 0, 0, 0, 0 }, /* PC11 */
  131. /* PC10 */ { 0, 0, 0, 0, 0, 0 }, /* PC10 */
  132. /* PC9 */ { 1, 0, 0, 1, 0, 1 }, /* MDIO */
  133. /* PC8 */ { 1, 0, 0, 1, 0, 1 }, /* MDC */
  134. /* PC7 */ { 0, 0, 0, 0, 0, 0 }, /* PC7 */
  135. /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* PC6 */
  136. /* PC5 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TxD */
  137. /* PC4 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RxD */
  138. /* PC3 */ { 0, 0, 0, 0, 0, 0 }, /* PC3 */
  139. /* PC2 */ { 0, 0, 0, 0, 0, 0 }, /* PC2 */
  140. /* PC1 */ { 0, 0, 0, 0, 0, 0 }, /* PC1 */
  141. /* PC0 */ { 0, 0, 0, 0, 0, 0 }, /* PC0 */
  142. },
  143. /* Port D */
  144. { /* conf ppar psor pdir podr pdat */
  145. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 RxD */
  146. /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 TxD */
  147. /* PD29 */ { 0, 0, 0, 0, 0, 0 }, /* PD29 */
  148. /* PD28 */ { 0, 0, 0, 0, 0, 0 }, /* PD28 */
  149. /* PD27 */ { 0, 0, 0, 0, 0, 0 }, /* PD27 */
  150. /* PD26 */ { 0, 0, 0, 0, 0, 0 }, /* PD26 */
  151. /* PD25 */ { 0, 0, 0, 0, 0, 0 }, /* PD25 */
  152. /* PD24 */ { 0, 0, 0, 0, 0, 0 }, /* PD24 */
  153. /* PD23 */ { 0, 0, 0, 0, 0, 0 }, /* PD23 */
  154. /* PD22 */ { 0, 0, 0, 0, 0, 0 }, /* PD22 */
  155. /* PD21 */ { 0, 0, 0, 0, 0, 0 }, /* PD21 */
  156. /* PD20 */ { 0, 0, 0, 0, 0, 0 }, /* PD20 */
  157. /* PD19 */ { 0, 0, 0, 0, 0, 0 }, /* PD19 */
  158. /* PD18 */ { 0, 0, 0, 0, 0, 0 }, /* PD18 */
  159. /* PD17 */ { 0, 0, 0, 0, 0, 0 }, /* PD17 */
  160. /* PD16 */ { 0, 0, 0, 0, 0, 0 }, /* PD16 */
  161. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  162. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  163. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  164. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  165. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  166. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  167. /* PD9 */ { 0, 0, 0, 0, 0, 0 }, /* PD9 */
  168. /* PD8 */ { 0, 0, 0, 0, 0, 0 }, /* PD8 */
  169. /* PD7 */ { 0, 0, 0, 0, 0, 0 }, /* PD7 */
  170. /* PD6 */ { 0, 0, 0, 0, 0, 0 }, /* PD6 */
  171. /* PD5 */ { 0, 0, 0, 0, 0, 0 }, /* PD5 */
  172. /* PD4 */ { 0, 0, 0, 0, 0, 0 }, /* PD4 */
  173. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  174. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  175. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  176. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* non-existent */
  177. }
  178. };
  179. int board_early_init_f (void)
  180. {
  181. vu_char *bcsr = (vu_char *)CONFIG_SYS_BCSR;
  182. bcsr[4] |= 0x30; /* Turn the LEDs off */
  183. #if defined(CONFIG_CONS_ON_SMC) || defined(CONFIG_KGDB_ON_SMC)
  184. bcsr[6] |= 0x10;
  185. #endif
  186. #if defined(CONFIG_CONS_ON_SCC) || defined(CONFIG_KGDB_ON_SCC)
  187. bcsr[7] |= 0x10;
  188. #endif
  189. #if CONFIG_SYS_FCC1
  190. bcsr[8] |= 0xC0;
  191. #endif /* CONFIG_SYS_FCC1 */
  192. #if CONFIG_SYS_FCC2
  193. bcsr[8] |= 0x30;
  194. #endif /* CONFIG_SYS_FCC2 */
  195. return 0;
  196. }
  197. phys_size_t initdram(int board_type)
  198. {
  199. vu_char *bcsr = (vu_char *)CONFIG_SYS_BCSR;
  200. long int msize = 16L << (bcsr[2] & 3);
  201. #ifndef CONFIG_SYS_RAMBOOT
  202. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  203. volatile memctl8260_t *memctl = &immap->im_memctl;
  204. vu_char *ramaddr = (vu_char *)CONFIG_SYS_SDRAM_BASE;
  205. uchar c = 0xFF;
  206. uint psdmr = CONFIG_SYS_PSDMR;
  207. int i;
  208. immap->im_siu_conf.sc_ppc_acr = 0x02;
  209. immap->im_siu_conf.sc_ppc_alrh = 0x30126745;
  210. immap->im_siu_conf.sc_tescr1 = 0x00004000;
  211. memctl->memc_mptpr = CONFIG_SYS_MPTPR;
  212. /* Initialise 60x bus SDRAM */
  213. memctl->memc_psrt = CONFIG_SYS_PSRT;
  214. memctl->memc_or1 = CONFIG_SYS_SDRAM_OR;
  215. memctl->memc_br1 = CONFIG_SYS_SDRAM_BR;
  216. memctl->memc_psdmr = psdmr | PSDMR_OP_PREA; /* Precharge all banks */
  217. *ramaddr = c;
  218. memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR; /* CBR refresh */
  219. for (i = 0; i < 8; i++)
  220. *ramaddr = c;
  221. memctl->memc_psdmr = psdmr | PSDMR_OP_MRW; /* Mode Register write */
  222. *ramaddr = c;
  223. memctl->memc_psdmr = psdmr | PSDMR_RFEN; /* Refresh enable */
  224. *ramaddr = c;
  225. #endif /* !CONFIG_SYS_RAMBOOT */
  226. /* Return total 60x bus SDRAM size */
  227. return msize * 1024 * 1024;
  228. }
  229. int checkboard(void)
  230. {
  231. vu_char *bcsr = (vu_char *)CONFIG_SYS_BCSR;
  232. puts("Board: ");
  233. switch (bcsr[0]) {
  234. case 0x0C:
  235. printf("EP8248E 1.0 CPLD revision %d\n", bcsr[1]);
  236. break;
  237. default:
  238. printf("unknown: ID=%02X\n", bcsr[0]);
  239. }
  240. return 0;
  241. }