ep82xxm.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*
  2. * Copyright (C) 2006 Embedded Planet, LLC.
  3. *
  4. * Support for Embedded Planet EP82xxM boards.
  5. * Tested on EP82xxM (MPC8270).
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <mpc8260.h>
  27. #include <ioports.h>
  28. #include <asm/m8260_pci.h>
  29. #ifdef CONFIG_PCI
  30. #include <pci.h>
  31. #endif
  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. #define CFG_FCC2 1
  40. #define CFG_FCC3 1
  41. const iop_conf_t iop_conf_tab[4][32] = {
  42. /* Port A */
  43. { /* conf ppar psor pdir podr pdat */
  44. /* PA31 */ { 0, 0, 0, 0, 0, 1 }, /* PA31 */
  45. /* PA30 */ { 0, 0, 0, 0, 0, 1 }, /* PA30 */
  46. /* PA29 */ { 0, 0, 0, 0, 0, 1 }, /* PA29 */
  47. /* PA28 */ { 0, 0, 0, 0, 0, 1 }, /* PA28 */
  48. /* PA27 */ { 0, 0, 0, 0, 0, 1 }, /* PA27 */
  49. /* PA26 */ { 0, 0, 0, 0, 0, 1 }, /* PA26 */
  50. /* PA25 */ { 0, 0, 0, 0, 0, 1 }, /* PA25 */
  51. /* PA24 */ { 0, 0, 0, 0, 0, 1 }, /* PA24 */
  52. /* PA23 */ { 0, 0, 0, 0, 0, 1 }, /* PA23 */
  53. /* PA22 */ { 0, 0, 0, 0, 0, 0 }, /* PA22 */
  54. /* PA21 */ { 0, 0, 0, 0, 0, 1 }, /* PA21 */
  55. /* PA20 */ { 0, 0, 0, 0, 0, 1 }, /* PA20 */
  56. /* PA19 */ { 0, 0, 0, 0, 0, 1 }, /* PA19 */
  57. /* PA18 */ { 0, 0, 0, 0, 0, 1 }, /* PA18 */
  58. /* PA17 */ { 0, 0, 0, 0, 0, 1 }, /* PA17 */
  59. /* PA16 */ { 0, 0, 0, 0, 0, 1 }, /* PA16 */
  60. /* PA15 */ { 0, 0, 0, 0, 0, 1 }, /* PA15 */
  61. /* PA14 */ { 0, 0, 0, 0, 0, 1 }, /* PA14 */
  62. /* PA13 */ { 0, 0, 0, 0, 0, 1 }, /* PA13 */
  63. /* PA12 */ { 0, 0, 0, 0, 0, 1 }, /* PA12 */
  64. /* PA11 */ { 0, 0, 0, 0, 0, 1 }, /* PA11 */
  65. /* PA10 */ { 0, 0, 0, 0, 0, 1 }, /* PA10 */
  66. /* PA9 */ { 1, 1, 0, 1, 0, 1 }, /* SMC2 TxD */
  67. /* PA8 */ { 1, 1, 0, 0, 0, 1 }, /* SMC2 RxD */
  68. /* PA7 */ { 0, 0, 0, 0, 0, 1 }, /* PA7 */
  69. /* PA6 */ { 0, 0, 0, 0, 0, 1 }, /* PA6 */
  70. /* PA5 */ { 0, 0, 0, 0, 0, 1 }, /* PA5 */
  71. /* PA4 */ { 0, 0, 0, 0, 0, 1 }, /* PA4 */
  72. /* PA3 */ { 0, 0, 0, 0, 0, 1 }, /* PA3 */
  73. /* PA2 */ { 0, 0, 0, 0, 0, 1 }, /* PA2 */
  74. /* PA1 */ { 0, 0, 0, 0, 0, 1 }, /* PA1 */
  75. /* PA0 */ { 0, 0, 0, 0, 0, 1 } /* PA0 */
  76. },
  77. /* Port B */
  78. { /* conf ppar psor pdir podr pdat */
  79. /* PB31 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  80. /* PB30 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  81. /* PB29 */ { CFG_FCC2, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  82. /* PB28 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  83. /* PB27 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  84. /* PB26 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  85. /* PB25 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  86. /* PB24 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  87. /* PB23 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  88. /* PB22 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  89. /* PB21 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  90. /* PB20 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  91. /* PB19 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  92. /* PB18 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  93. /* PB17 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
  94. /* PB16 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
  95. /* PB15 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
  96. /* PB14 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
  97. /* PB13 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3:COL */
  98. /* PB12 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
  99. /* PB11 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  100. /* PB10 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  101. /* PB9 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  102. /* PB8 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
  103. /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
  104. /* PB6 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  105. /* PB5 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  106. /* PB4 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
  107. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  108. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  109. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  110. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* non-existent */
  111. },
  112. /* Port C */
  113. { /* conf ppar psor pdir podr pdat */
  114. /* PC31 */ { 0, 0, 0, 0, 0, 0 }, /* PC31 */
  115. /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
  116. /* PC29 */ { 1, 1, 1, 0, 0, 0 }, /* SCC1 CTS# */
  117. /* PC28 */ { 0, 0, 0, 0, 0, 0 }, /* PC28 */
  118. /* PC27 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3: TXD[0] */
  119. /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
  120. /* PC25 */ { 0, 0, 0, 0, 0, 0 }, /* PC25 */
  121. /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
  122. /* PC23 */ { 0, 0, 0, 0, 0, 0 }, /* PC23 */
  123. /* PC22 */ { 0, 0, 0, 0, 0, 0 }, /* PC22 */
  124. /* PC21 */ { 0, 0, 0, 0, 0, 0 }, /* PC21 */
  125. /* PC20 */ { 0, 0, 0, 0, 0, 0 }, /* PC20 */
  126. /* PC19 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* RxClk (CLK13) */
  127. /* PC18 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* TxClk (CLK14) */
  128. /* PC17 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* RxClk (CLK15) */
  129. /* PC16 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* TxClk (CLK16) */
  130. /* PC15 */ { 0, 0, 0, 0, 0, 0 }, /* PC15 */
  131. /* PC14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 CD# */
  132. /* PC13 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 CTS# */
  133. /* PC12 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 CD# */
  134. /* PC11 */ { 0, 0, 0, 0, 0, 0 }, /* PC11 */
  135. /* PC10 */ { 1, 1, 0, 0, 0, 0 }, /* SCC3 CD# */
  136. /* PC9 */ { 0, 0, 0, 0, 0, 0 }, /* PC9 */
  137. /* PC8 */ { 1, 1, 1, 0, 0, 0 }, /* SCC3 CTS# */
  138. /* PC7 */ { 0, 0, 0, 0, 0, 0 }, /* PC7 */
  139. /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* PC6 */
  140. /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* PC5 */
  141. /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* PC4 */
  142. /* PC3 */ { 0, 0, 0, 0, 0, 0 }, /* PC3 */
  143. /* PC2 */ { 0, 0, 0, 0, 0, 0 }, /* PC2 */
  144. /* PC1 */ { 0, 0, 0, 0, 0, 0 }, /* PC1 */
  145. /* PC0 */ { 0, 0, 0, 0, 0, 0 }, /* PC0 */
  146. },
  147. /* Port D */
  148. { /* conf ppar psor pdir podr pdat */
  149. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 RXD */
  150. /* PD30 */ { 1, 1, 1, 1, 0, 1 }, /* SCC1 TXD */
  151. /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 RTS# */
  152. /* PD28 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 RXD */
  153. /* PD27 */ { 1, 1, 0, 1, 0, 0 }, /* SCC2 TXD */
  154. /* PD26 */ { 1, 1, 0, 1, 0, 0 }, /* SCC2 RTS# */
  155. /* PD25 */ { 1, 1, 0, 0, 0, 0 }, /* SCC3 RXD */
  156. /* PD24 */ { 1, 1, 0, 1, 0, 0 }, /* SCC3 TXD */
  157. /* PD23 */ { 1, 1, 0, 1, 0, 0 }, /* SCC3 RTS# */
  158. /* PD22 */ { 0, 0, 0, 0, 0, 1 }, /* PD22 */
  159. /* PD21 */ { 0, 0, 0, 0, 0, 1 }, /* PD21 */
  160. /* PD20 */ { 0, 0, 0, 0, 0, 1 }, /* PD20 */
  161. /* PD19 */ { 0, 0, 0, 0, 0, 1 }, /* PD19 */
  162. /* PD18 */ { 0, 0, 0, 0, 0, 1 }, /* PD18 */
  163. /* PD17 */ { 0, 0, 0, 0, 0, 1 }, /* PD17 */
  164. /* PD16 */ { 0, 0, 0, 0, 0, 1 }, /* PD16 */
  165. /* PD15 */ { 1, 1, 1, 0, 1, 1 }, /* I2C SDA */
  166. /* PD14 */ { 1, 1, 1, 0, 1, 1 }, /* I2C SCL */
  167. /* PD13 */ { 0, 0, 0, 0, 0, 1 }, /* PD13 */
  168. /* PD12 */ { 0, 0, 0, 0, 0, 1 }, /* PD12 */
  169. /* PD11 */ { 0, 0, 0, 0, 0, 1 }, /* PD11 */
  170. /* PD10 */ { 0, 0, 0, 0, 0, 1 }, /* PD10 */
  171. /* PD9 */ { 1, 1, 0, 1, 0, 1 }, /* SMC1 TxD */
  172. /* PD8 */ { 1, 1, 0, 0, 0, 1 }, /* SMC1 RxD */
  173. /* PD7 */ { 1, 1, 0, 0, 0, 1 }, /* SMC1 SMSYN */
  174. /* PD6 */ { 0, 0, 0, 0, 0, 1 }, /* PD6 */
  175. /* PD5 */ { 0, 0, 0, 0, 0, 1 }, /* PD5 */
  176. /* PD4 */ { 0, 0, 0, 0, 0, 1 }, /* PD4 */
  177. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  178. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  179. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
  180. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* non-existent */
  181. }
  182. };
  183. #ifdef CONFIG_PCI
  184. typedef struct pci_ic_s {
  185. unsigned long pci_int_stat;
  186. unsigned long pci_int_mask;
  187. }pci_ic_t;
  188. #endif
  189. int board_early_init_f (void)
  190. {
  191. vu_char *bcsr = (vu_char *)CFG_BCSR;
  192. bcsr[4] |= 0x30; /* Turn the LEDs off */
  193. #if defined(CONFIG_CONS_ON_SMC) || defined(CONFIG_KGDB_ON_SMC)
  194. bcsr[6] |= 0x10;
  195. #endif
  196. #if defined(CONFIG_CONS_ON_SCC) || defined(CONFIG_KGDB_ON_SCC)
  197. bcsr[7] |= 0x10;
  198. #endif
  199. #if CFG_FCC3
  200. bcsr[8] |= 0xC0;
  201. #endif /* CFG_FCC3 */
  202. #if CFG_FCC2
  203. bcsr[8] |= 0x30;
  204. #endif /* CFG_FCC2 */
  205. return 0;
  206. }
  207. long int initdram(int board_type)
  208. {
  209. /* Size in MB of SDRAM populated on board*/
  210. long int msize = 256;
  211. #ifndef CFG_RAMBOOT
  212. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  213. volatile memctl8260_t *memctl = &immap->im_memctl;
  214. vu_char *ramaddr = (vu_char *)CFG_SDRAM_BASE;
  215. uchar c = 0xFF;
  216. uint psdmr = CFG_PSDMR;
  217. int i;
  218. unsigned char ramtmp;
  219. unsigned char *ramptr1 = (unsigned char *)0x00000110;
  220. memctl->memc_mptpr = CFG_MPTPR;
  221. udelay(400);
  222. /* Initialise 60x bus SDRAM */
  223. memctl->memc_psrt = CFG_PSRT;
  224. memctl->memc_or1 = CFG_SDRAM_OR;
  225. memctl->memc_br1 = CFG_SDRAM_BR;
  226. memctl->memc_psdmr = psdmr;
  227. udelay(400);
  228. memctl->memc_psdmr = psdmr | PSDMR_OP_PREA; /* Precharge all banks */
  229. ramtmp = *ramptr1;
  230. memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR; /* CBR refresh */
  231. for (i = 0; i < 8; i++) {
  232. memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR; /* CBR refresh */
  233. }
  234. ramtmp = *ramptr1;
  235. memctl->memc_psdmr = psdmr | PSDMR_OP_MRW; /* Mode Register write */
  236. *ramptr1 = 0xFF;
  237. memctl->memc_psdmr = psdmr | PSDMR_RFEN; /* Refresh enable */
  238. #endif /* !CFG_RAMBOOT */
  239. /* Return total 60x bus SDRAM size */
  240. return msize * 1024 * 1024;
  241. }
  242. int checkboard(void)
  243. {
  244. vu_char *bcsr = (vu_char *)CFG_BCSR;
  245. puts("Board: ");
  246. switch (bcsr[0]) {
  247. case 0x0A:
  248. printf("EP82xxM 1.0 CPLD revision %d\n", bcsr[1]);
  249. break;
  250. default:
  251. printf("unknown: ID=%02X\n", bcsr[0]);
  252. }
  253. return 0;
  254. }
  255. #ifdef CONFIG_PCI
  256. struct pci_controller hose;
  257. extern void pci_mpc8250_init(struct pci_controller *);
  258. void pci_init_board(void)
  259. {
  260. pci_mpc8250_init(&hose);
  261. }
  262. #endif