ep8260.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*
  2. * (C) Copyright 2001, 2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2002
  6. * Frank Panno <fpanno@delphintech.com>, Delphin Technology AG
  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 "ep8260.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 configuration */
  38. { /* conf ppar psor pdir podr pdat */
  39. /* PA31 */ { 0, 0, 0, 1, 0, 0 }, /* */
  40. /* PA30 */ { 0, 0, 0, 1, 0, 0 }, /* */
  41. /* PA29 */ { 0, 0, 0, 1, 0, 0 }, /* */
  42. /* PA28 */ { 0, 0, 0, 1, 0, 0 }, /* */
  43. /* PA27 */ { 0, 0, 0, 1, 0, 0 }, /* */
  44. /* PA26 */ { 0, 0, 0, 1, 0, 0 }, /* */
  45. /* PA25 */ { 0, 0, 0, 1, 0, 0 }, /* */
  46. /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* */
  47. /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* */
  48. /* PA22 */ { 0, 0, 0, 1, 0, 0 }, /* */
  49. /* PA21 */ { 0, 0, 0, 1, 0, 0 }, /* */
  50. /* PA20 */ { 0, 0, 0, 1, 0, 0 }, /* */
  51. /* PA19 */ { 0, 0, 0, 1, 0, 0 }, /* */
  52. /* PA18 */ { 0, 0, 0, 1, 0, 0 }, /* */
  53. /* PA17 */ { 0, 0, 0, 1, 0, 0 }, /* */
  54. /* PA16 */ { 0, 0, 0, 1, 0, 0 }, /* */
  55. /* PA15 */ { 0, 0, 0, 1, 0, 0 }, /* */
  56. /* PA14 */ { 0, 0, 0, 1, 0, 0 }, /* */
  57. /* PA13 */ { 0, 0, 0, 1, 0, 0 }, /* */
  58. /* PA12 */ { 0, 0, 0, 1, 0, 0 }, /* */
  59. /* PA11 */ { 0, 0, 0, 1, 0, 0 }, /* */
  60. /* PA10 */ { 0, 0, 0, 1, 0, 0 }, /* */
  61. /* PA9 */ { 0, 1, 0, 1, 0, 0 }, /* */
  62. /* PA8 */ { 0, 1, 0, 0, 0, 0 }, /* */
  63. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  64. /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */
  65. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  66. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  67. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  68. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  69. /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */
  70. /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
  71. },
  72. /* Port B configuration */
  73. { /* conf ppar psor pdir podr pdat */
  74. /* PB31 */ { 0, 1, 0, 1, 0, 0 }, /* */
  75. /* PB30 */ { 0, 1, 0, 0, 0, 0 }, /* */
  76. /* PB29 */ { 0, 1, 1, 1, 0, 0 }, /* */
  77. /* PB28 */ { 0, 1, 0, 0, 0, 0 }, /* */
  78. /* PB27 */ { 0, 1, 0, 0, 0, 0 }, /* */
  79. /* PB26 */ { 0, 1, 0, 0, 0, 0 }, /* */
  80. /* PB25 */ { 0, 1, 0, 1, 0, 0 }, /* */
  81. /* PB24 */ { 0, 1, 0, 1, 0, 0 }, /* */
  82. /* PB23 */ { 0, 1, 0, 1, 0, 0 }, /* */
  83. /* PB22 */ { 0, 1, 0, 1, 0, 0 }, /* */
  84. /* PB21 */ { 0, 1, 0, 0, 0, 0 }, /* */
  85. /* PB20 */ { 0, 1, 0, 0, 0, 0 }, /* */
  86. /* PB19 */ { 0, 1, 0, 0, 0, 0 }, /* */
  87. /* PB18 */ { 0, 1, 0, 0, 0, 0 }, /* */
  88. /* PB17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_DV */
  89. /* PB16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_ER */
  90. /* PB15 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TX_ER */
  91. /* PB14 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TX_EN */
  92. /* PB13 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII COL */
  93. /* PB12 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII CRS */
  94. /* PB11 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[3] */
  95. /* PB10 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[2] */
  96. /* PB9 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[1] */
  97. /* PB8 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[0] */
  98. /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
  99. /* PB6 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[1] */
  100. /* PB5 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[2] */
  101. /* PB4 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[3] */
  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, 1, 0, 0 }, /* PC31 */
  110. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  111. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* */
  112. /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
  113. /* PC27 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[0] */
  114. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  115. /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
  116. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  117. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* */
  118. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* */
  119. /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* */
  120. /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* */
  121. /* PC19 */ { 0, 1, 0, 0, 0, 0 }, /* */
  122. /* PC18 */ { 0, 1, 0, 0, 0, 0 }, /* */
  123. /* PC17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII CLK15 */
  124. /* PC16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII CLK16 */
  125. /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */
  126. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* */
  127. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  128. /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* PC12 */
  129. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* PC11 */
  130. /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* */
  131. /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* */
  132. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
  133. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  134. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  135. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  136. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  137. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  138. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* */
  139. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* */
  140. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* */
  141. },
  142. /* Port D */
  143. { /* conf ppar psor pdir podr pdat */
  144. /* PD31 */ { 0, 1, 0, 0, 0, 0 }, /* */
  145. /* PD30 */ { 0, 1, 1, 1, 0, 0 }, /* */
  146. /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* */
  147. /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */
  148. /* PD27 */ { 0, 0, 0, 1, 0, 0 }, /* PD27 */
  149. /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
  150. /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
  151. /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
  152. /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
  153. /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
  154. /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
  155. /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
  156. /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  157. /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  158. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* */
  159. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* */
  160. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  161. /* PD14 */ { 1, 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, 1, 0, 1 }, /* PD7 */
  169. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  170. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  171. /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* 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. /* ------------------------------------------------------------------------- */
  179. /*
  180. * Setup CS4 to enable the Board Control/Status registers.
  181. * Otherwise the smcs won't work.
  182. */
  183. int board_early_init_f (void)
  184. {
  185. volatile t_ep_regs *regs = (t_ep_regs *) CFG_REGS_BASE;
  186. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  187. volatile memctl8260_t *memctl = &immap->im_memctl;
  188. memctl->memc_br4 = CFG_BR4_PRELIM;
  189. memctl->memc_or4 = CFG_OR4_PRELIM;
  190. regs->bcsr1 = 0x62; /* to enable terminal on SMC1 */
  191. regs->bcsr2 = 0x30; /* enable NVRAM and writing FLASH */
  192. return 0;
  193. }
  194. void reset_phy (void)
  195. {
  196. volatile t_ep_regs *regs = (t_ep_regs *) CFG_REGS_BASE;
  197. regs->bcsr4 = 0xC0;
  198. }
  199. /*
  200. * Check Board Identity:
  201. * I don' know, how the next board revisions will be coded.
  202. * Thats why its a static interpretation ...
  203. */
  204. int checkboard (void)
  205. {
  206. volatile t_ep_regs *regs = (t_ep_regs *) CFG_REGS_BASE;
  207. uint major = 0, minor = 0;
  208. switch (regs->bcsr0) {
  209. case 0x02:
  210. major = 1;
  211. break;
  212. case 0x03:
  213. major = 1;
  214. minor = 1;
  215. break;
  216. default:
  217. break;
  218. }
  219. printf ("Board: Embedded Planet EP8260, Revision %d.%d\n",
  220. major, minor);
  221. return 0;
  222. }
  223. /* ------------------------------------------------------------------------- */
  224. long int initdram (int board_type)
  225. {
  226. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  227. volatile memctl8260_t *memctl = &immap->im_memctl;
  228. volatile uchar c = 0;
  229. volatile uchar *ramaddr = (uchar *) (CFG_SDRAM_BASE) + 0x110;
  230. /*
  231. ulong psdmr = CFG_PSDMR;
  232. #ifdef CFG_LSDRAM
  233. ulong lsdmr = CFG_LSDMR;
  234. #endif
  235. */
  236. long size = CFG_SDRAM0_SIZE;
  237. int i;
  238. /*
  239. * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
  240. *
  241. * "At system reset, initialization software must set up the
  242. * programmable parameters in the memory controller banks registers
  243. * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
  244. * system software should execute the following initialization sequence
  245. * for each SDRAM device.
  246. *
  247. * 1. Issue a PRECHARGE-ALL-BANKS command
  248. * 2. Issue eight CBR REFRESH commands
  249. * 3. Issue a MODE-SET command to initialize the mode register
  250. *
  251. * The initial commands are executed by setting P/LSDMR[OP] and
  252. * accessing the SDRAM with a single-byte transaction."
  253. *
  254. * The appropriate BRx/ORx registers have already been set when we
  255. * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
  256. */
  257. memctl->memc_psrt = CFG_PSRT;
  258. memctl->memc_mptpr = CFG_MPTPR;
  259. memctl->memc_psdmr = (ulong) CFG_PSDMR | PSDMR_OP_PREA;
  260. *ramaddr = c;
  261. memctl->memc_psdmr = (ulong) CFG_PSDMR | PSDMR_OP_CBRR;
  262. for (i = 0; i < 8; i++)
  263. *ramaddr = c;
  264. memctl->memc_psdmr = (ulong) CFG_PSDMR | PSDMR_OP_MRW;
  265. *ramaddr = c;
  266. memctl->memc_psdmr = (ulong) CFG_PSDMR | PSDMR_OP_NORM | PSDMR_RFEN;
  267. *ramaddr = c;
  268. #ifndef CFG_RAMBOOT
  269. #ifdef CFG_LSDRAM
  270. size += CFG_SDRAM1_SIZE;
  271. ramaddr = (uchar *) (CFG_SDRAM1_BASE) + 0x8c;
  272. memctl->memc_lsrt = CFG_LSRT;
  273. memctl->memc_lsdmr = (ulong) CFG_LSDMR | PSDMR_OP_PREA;
  274. *ramaddr = c;
  275. memctl->memc_lsdmr = (ulong) CFG_LSDMR | PSDMR_OP_CBRR;
  276. for (i = 0; i < 8; i++)
  277. *ramaddr = c;
  278. memctl->memc_lsdmr = (ulong) CFG_LSDMR | PSDMR_OP_MRW;
  279. *ramaddr = c;
  280. memctl->memc_lsdmr = (ulong) CFG_LSDMR | PSDMR_OP_NORM | PSDMR_RFEN;
  281. *ramaddr = c;
  282. #endif /* CFG_LSDRAM */
  283. #endif /* CFG_RAMBOOT */
  284. return (size * 1024 * 1024);
  285. }