rpxsuper.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /*
  2. * (C) Copyright 2000
  3. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  4. * Marius Groeger <mgroeger@sysgo.de>
  5. *
  6. * (C) Copyright 2001
  7. * Advent Networks, Inc. <http://www.adventnetworks.com>
  8. * Jay Monkman <jtm@smoothsmoothie.com>
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <common.h>
  29. #include <ioports.h>
  30. #include <mpc8260.h>
  31. #include "rpxsuper.h"
  32. /*
  33. * I/O Port configuration table
  34. *
  35. * if conf is 1, then that port pin will be configured at boot time
  36. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  37. */
  38. const iop_conf_t iop_conf_tab[4][32] = {
  39. /* Port A configuration */
  40. { /* conf ppar psor pdir podr pdat */
  41. /* PA31 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 *ATMTXEN */
  42. /* PA30 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTCA */
  43. /* PA29 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTSOC */
  44. /* PA28 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 *ATMRXEN */
  45. /* PA27 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRSOC */
  46. /* PA26 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRCA */
  47. /* PA25 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[0] */
  48. /* PA24 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[1] */
  49. /* PA23 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[2] */
  50. /* PA22 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[3] */
  51. /* PA21 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[4] */
  52. /* PA20 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[5] */
  53. /* PA19 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[6] */
  54. /* PA18 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[7] */
  55. /* PA17 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  56. /* PA16 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  57. /* PA15 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  58. /* PA14 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  59. /* PA13 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  60. /* PA12 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  61. /* PA11 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  62. /* PA10 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  63. /* PA9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
  64. /* PA8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC2 RXD */
  65. /* PA7 */ { 1, 0, 0, 0, 0, 0 }, /* PA7 */
  66. /* PA6 */ { 1, 0, 0, 0, 0, 0 }, /* PA6 */
  67. /* PA5 */ { 1, 0, 0, 0, 0, 0 }, /* PA5 */
  68. /* PA4 */ { 1, 0, 0, 0, 0, 0 }, /* PA4 */
  69. /* PA3 */ { 1, 0, 0, 0, 0, 0 }, /* PA3 */
  70. /* PA2 */ { 1, 0, 0, 0, 0, 0 }, /* PA2 */
  71. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* PA1 */
  72. /* PA0 */ { 1, 0, 0, 0, 0, 0 } /* PA0 */
  73. },
  74. /* Port B configuration */
  75. { /* conf ppar psor pdir podr pdat */
  76. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  77. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  78. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  79. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  80. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  81. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  82. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  83. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  84. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  85. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  86. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  87. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  88. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  89. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  90. /* PB17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_DV */
  91. /* PB16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_ER */
  92. /* PB15 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TX_ER */
  93. /* PB14 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TX_EN */
  94. /* PB13 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII COL */
  95. /* PB12 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII CRS */
  96. /* PB11 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[3] */
  97. /* PB10 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[2] */
  98. /* PB9 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[1] */
  99. /* PB8 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[0] */
  100. /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
  101. /* PB6 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[1] */
  102. /* PB5 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[2] */
  103. /* PB4 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[3] */
  104. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  105. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  106. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  107. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  108. },
  109. /* Port C */
  110. { /* conf ppar psor pdir podr pdat */
  111. /* PC31 */ { 1, 0, 0, 1, 0, 0 }, /* PC31 */
  112. /* PC30 */ { 1, 0, 0, 1, 0, 0 }, /* PC30 */
  113. /* PC29 */ { 1, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
  114. /* PC28 */ { 1, 0, 0, 1, 0, 0 }, /* PC28 */
  115. /* PC27 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[0] */
  116. /* PC26 */ { 1, 0, 0, 1, 0, 0 }, /* PC26 */
  117. /* PC25 */ { 1, 0, 0, 1, 0, 0 }, /* PC25 */
  118. /* PC24 */ { 1, 0, 0, 1, 0, 0 }, /* PC24 */
  119. /* PC23 */ { 1, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
  120. /* PC22 */ { 1, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
  121. /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  122. /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
  123. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK */
  124. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII TX_CLK */
  125. /* PC17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_CLK */
  126. /* PC16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII TX_CLK */
  127. /* PC15 */ { 1, 0, 0, 0, 0, 0 }, /* PC15 */
  128. /* PC14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
  129. /* PC13 */ { 1, 0, 0, 1, 0, 0 }, /* PC13 */
  130. /* PC12 */ { 1, 0, 0, 1, 0, 0 }, /* PC12 */
  131. /* PC11 */ { 1, 0, 0, 1, 0, 0 }, /* PC11 */
  132. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FCC2 MDC */
  133. /* PC9 */ { 1, 0, 0, 1, 0, 0 }, /* FCC2 MDIO */
  134. /* PC8 */ { 1, 0, 0, 1, 0, 0 }, /* PC8 */
  135. /* PC7 */ { 1, 0, 0, 1, 0, 0 }, /* PC7 */
  136. /* PC6 */ { 1, 0, 0, 1, 0, 0 }, /* PC6 */
  137. /* PC5 */ { 1, 0, 0, 1, 0, 0 }, /* PC5 */
  138. /* PC4 */ { 1, 0, 0, 1, 0, 0 }, /* PC4 */
  139. /* PC3 */ { 1, 0, 0, 1, 0, 0 }, /* PC3 */
  140. /* PC2 */ { 1, 0, 0, 1, 0, 1 }, /* ENET FDE */
  141. /* PC1 */ { 1, 0, 0, 1, 0, 0 }, /* ENET DSQE */
  142. /* PC0 */ { 1, 0, 0, 1, 0, 0 }, /* ENET LBK */
  143. },
  144. /* Port D */
  145. { /* conf ppar psor pdir podr pdat */
  146. /* PD31 */ { 1, 0, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  147. /* PD30 */ { 1, 0, 0, 0, 0, 0 }, /* SCC1 EN TxD */
  148. /* PD29 */ { 1, 0, 0, 0, 0, 0 }, /* SCC1 EN TENA */
  149. /* PD28 */ { 1, 0, 0, 0, 0, 0 }, /* PD28 */
  150. /* PD27 */ { 1, 0, 0, 0, 0, 0 }, /* PD27 */
  151. /* PD26 */ { 1, 0, 0, 0, 0, 0 }, /* PD26 */
  152. /* PD25 */ { 1, 0, 0, 0, 0, 0 }, /* PD25 */
  153. /* PD24 */ { 1, 0, 0, 0, 0, 0 }, /* PD24 */
  154. /* PD23 */ { 1, 0, 0, 0, 0, 0 }, /* PD23 */
  155. /* PD22 */ { 1, 0, 0, 0, 0, 0 }, /* PD22 */
  156. /* PD21 */ { 1, 0, 0, 0, 0, 0 }, /* PD21 */
  157. /* PD20 */ { 1, 0, 0, 0, 0, 0 }, /* PD20 */
  158. /* PD19 */ { 1, 0, 0, 0, 0, 0 }, /* PD19 */
  159. /* PD18 */ { 1, 0, 0, 0, 0, 0 }, /* PD19 */
  160. /* PD17 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  161. /* PD16 */ { 1, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXPRTY */
  162. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  163. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  164. /* PD13 */ { 1, 0, 0, 0, 0, 0 }, /* PD13 */
  165. /* PD12 */ { 1, 0, 0, 0, 0, 0 }, /* PD12 */
  166. /* PD11 */ { 1, 0, 0, 0, 0, 0 }, /* PD11 */
  167. /* PD10 */ { 1, 0, 0, 0, 0, 0 }, /* PD10 */
  168. /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  169. /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  170. /* PD7 */ { 1, 0, 0, 0, 0, 0 }, /* PD7 */
  171. /* PD6 */ { 1, 0, 0, 0, 0, 0 }, /* PD6 */
  172. /* PD5 */ { 1, 0, 0, 0, 0, 0 }, /* PD5 */
  173. /* PD4 */ { 1, 0, 0, 0, 0, 0 }, /* PD4 */
  174. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  175. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  176. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  177. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  178. }
  179. };
  180. /* ------------------------------------------------------------------------- */
  181. /*
  182. * Setup CS4 to enable the Board Control/Status registers.
  183. * Otherwise the smcs won't work.
  184. */
  185. int board_early_init_f (void)
  186. {
  187. volatile t_rpx_regs *regs = (t_rpx_regs*)CONFIG_SYS_REGS_BASE;
  188. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  189. volatile memctl8260_t *memctl = &immap->im_memctl;
  190. memctl->memc_br4 = CONFIG_SYS_BR4_PRELIM;
  191. memctl->memc_or4 = CONFIG_SYS_OR4_PRELIM;
  192. regs->bcsr1 = 0x70; /* to enable terminal no SMC1 */
  193. regs->bcsr2 = 0x20; /* mut be written to enable writing FLASH */
  194. return 0;
  195. }
  196. void
  197. reset_phy(void)
  198. {
  199. volatile t_rpx_regs *regs = (t_rpx_regs*)CONFIG_SYS_REGS_BASE;
  200. regs->bcsr4 = 0xC3;
  201. }
  202. /*
  203. * Check Board Identity:
  204. */
  205. int checkboard(void)
  206. {
  207. volatile t_rpx_regs *regs = (t_rpx_regs*)CONFIG_SYS_REGS_BASE;
  208. printf ("Board: Embedded Planet RPX Super, Revision %d\n",
  209. regs->bcsr0 >> 4);
  210. return 0;
  211. }
  212. /* ------------------------------------------------------------------------- */
  213. phys_size_t initdram(int board_type)
  214. {
  215. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  216. volatile memctl8260_t *memctl = &immap->im_memctl;
  217. volatile uchar c = 0, *ramaddr;
  218. ulong psdmr, lsdmr, bcr;
  219. long size = 0;
  220. int i;
  221. psdmr = CONFIG_SYS_PSDMR;
  222. lsdmr = CONFIG_SYS_LSDMR;
  223. /*
  224. * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
  225. *
  226. * "At system reset, initialization software must set up the
  227. * programmable parameters in the memory controller banks registers
  228. * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
  229. * system software should execute the following initialization sequence
  230. * for each SDRAM device.
  231. *
  232. * 1. Issue a PRECHARGE-ALL-BANKS command
  233. * 2. Issue eight CBR REFRESH commands
  234. * 3. Issue a MODE-SET command to initialize the mode register
  235. *
  236. * The initial commands are executed by setting P/LSDMR[OP] and
  237. * accessing the SDRAM with a single-byte transaction."
  238. *
  239. * The appropriate BRx/ORx registers have already been set when we
  240. * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
  241. */
  242. size = CONFIG_SYS_SDRAM0_SIZE;
  243. bcr = immap->im_siu_conf.sc_bcr;
  244. immap->im_siu_conf.sc_bcr = (bcr & ~BCR_EBM);
  245. memctl->memc_mptpr = CONFIG_SYS_MPTPR;
  246. ramaddr = (uchar *)(CONFIG_SYS_SDRAM0_BASE);
  247. memctl->memc_psrt = CONFIG_SYS_PSRT;
  248. memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
  249. *ramaddr = c;
  250. memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
  251. for (i = 0; i < 8; i++)
  252. *ramaddr = c;
  253. memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
  254. *ramaddr = c;
  255. memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  256. *ramaddr = c;
  257. immap->im_siu_conf.sc_bcr = bcr;
  258. #ifndef CONFIG_SYS_RAMBOOT
  259. /* size += CONFIG_SYS_SDRAM1_SIZE; */
  260. ramaddr = (uchar *)(CONFIG_SYS_SDRAM1_BASE);
  261. memctl->memc_lsrt = CONFIG_SYS_LSRT;
  262. memctl->memc_lsdmr = lsdmr | PSDMR_OP_PREA;
  263. *ramaddr = c;
  264. memctl->memc_lsdmr = lsdmr | PSDMR_OP_CBRR;
  265. for (i = 0; i < 8; i++)
  266. *ramaddr = c;
  267. memctl->memc_lsdmr = lsdmr | PSDMR_OP_MRW;
  268. *ramaddr = c;
  269. memctl->memc_lsdmr = lsdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  270. *ramaddr = c;
  271. #endif
  272. /* return total ram size */
  273. return (size * 1024 * 1024);
  274. }