ppmc8260.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. /*
  32. * I/O Port configuration table
  33. *
  34. * if conf is 1, then that port pin will be configured at boot time
  35. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  36. */
  37. const iop_conf_t iop_conf_tab[4][32] = {
  38. /* Port A configuration */
  39. { /* conf ppar psor pdir podr pdat */
  40. /* PA31 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 *ATMTXEN */
  41. /* PA30 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTCA */
  42. /* PA29 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTSOC */
  43. /* PA28 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 *ATMRXEN */
  44. /* PA27 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRSOC */
  45. /* PA26 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRCA */
  46. /* PA25 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[0] */
  47. /* PA24 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[1] */
  48. /* PA23 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[2] */
  49. /* PA22 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[3] */
  50. /* PA21 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[4] */
  51. /* PA20 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[5] */
  52. /* PA19 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[6] */
  53. /* PA18 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMTXD[7] */
  54. /* PA17 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
  55. /* PA16 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
  56. /* PA15 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
  57. /* PA14 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
  58. /* PA13 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
  59. /* PA12 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
  60. /* PA11 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
  61. /* PA10 */ { 0, 0, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
  62. /* PA9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
  63. /* PA8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC2 RXD */
  64. /* PA7 */ { 1, 0, 0, 1, 0, 0 }, /* TDM_A1:L1TSYNC */
  65. /* PA6 */ { 1, 0, 0, 1, 0, 0 }, /* TDN_A1:L1RSYNC */
  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 configuration */
  74. { /* conf ppar psor pdir podr pdat */
  75. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  76. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  77. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  78. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  79. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  80. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  81. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  82. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  83. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  84. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  85. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  86. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  87. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  88. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  89. /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
  90. /* PB16 */ { 1, 0, 0, 0, 0, 0 }, /* TDM_A1:L1CLK0 */
  91. /* PB15 */ { 1, 0, 0, 1, 0, 1 }, /* /FETHRST */
  92. /* PB14 */ { 1, 0, 0, 1, 0, 0 }, /* FETHDIS */
  93. /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
  94. /* PB12 */ { 1, 0, 0, 1, 0, 0 }, /* TDM_B1:L1CLK0 */
  95. /* PB11 */ { 1, 0, 0, 1, 0, 0 }, /* TDM_D1:L1TXD */
  96. /* PB10 */ { 1, 0, 0, 1, 0, 0 }, /* TDM_D1:L1RXD */
  97. /* PB9 */ { 1, 0, 0, 1, 0, 0 }, /* TDM_D1:L1TSYNC */
  98. /* PB8 */ { 1, 0, 0, 1, 0, 0 }, /* TDM_D1:L1RSYNC */
  99. /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
  100. /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
  101. /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
  102. /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
  103. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  104. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  105. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  106. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  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 }, /* PC28 */
  113. /* PC28 */ { 1, 1, 0, 0, 0, 0 }, /* CLK4 */
  114. /* PC27 */ { 0, 0, 0, 0, 0, 0 }, /* PC27 */
  115. /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
  116. /* PC25 */ { 1, 1, 0, 0, 0, 0 }, /* CLK7 */
  117. /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
  118. /* PC23 */ { 1, 0, 0, 1, 0, 0 }, /* ATMTFCLK */
  119. /* PC22 */ { 0, 0, 0, 0, 0, 0 }, /* PC22 */
  120. /* PC21 */ { 0, 0, 0, 0, 0, 0 }, /* PC23 */
  121. /* PC20 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
  122. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK */
  123. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII TX_CLK */
  124. /* PC17 */ { 0, 0, 0, 0, 0, 0 }, /* PC17 */
  125. /* PC16 */ { 0, 0, 0, 0, 0, 0 }, /* PC16 */
  126. /* PC15 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1:TxAddr[0] */
  127. /* PC14 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1:RxAddr[0] */
  128. /* PC13 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1:TxAddr[1] */
  129. /* PC12 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1:RxAddr[1] */
  130. /* PC11 */ { 1, 1, 0, 1, 0, 0 }, /* TDM_D1:L1CLK0 */
  131. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FCC2 MDC */
  132. /* PC9 */ { 1, 0, 0, 1, 0, 0 }, /* FCC2 MDIO */
  133. /* PC8 */ { 0, 0, 0, 0, 0, 0 }, /* PC8 */
  134. /* PC7 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1:TxAddr[2]*/
  135. /* PC6 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1:RxAddr[2] */
  136. /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* PC5 */
  137. /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* PC4 */
  138. /* PC3 */ { 1, 0, 0, 1, 0, 0 }, /* IDMA2:DACK */
  139. /* PC2 */ { 1, 0, 0, 1, 0, 0 }, /* IDMA2:DONE */
  140. /* PC1 */ { 1, 0, 0, 1, 0, 0 }, /* IDMA2:DREQ */
  141. /* PC0 */ { 1, 0, 0, 1, 0, 0 }, /* IDMA1:DREQ */
  142. },
  143. /* Port D */
  144. { /* conf ppar psor pdir podr pdat */
  145. /* PD31 */ { 0, 0, 0, 0, 0, 0 }, /* PD31 */
  146. /* PD30 */ { 0, 0, 0, 0, 0, 0 }, /* PD30 */
  147. /* PD29 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1:RxAddr[3] */
  148. /* PD28 */ { 0, 0, 0, 0, 0, 0 }, /* PD28 */
  149. /* PD27 */ { 0, 0, 0, 0, 0, 0 }, /* PD27 */
  150. /* PD26 */ { 1, 0, 0, 1, 0, 0 }, /* TDM_C1:L1RSYNC */
  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 }, /* PD19 */
  159. /* PD17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
  160. /* PD16 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
  161. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  162. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  163. /* PD13 */ { 1, 0, 0, 0, 0, 0 }, /* TDM_B1:L1TXD */
  164. /* PD12 */ { 1, 0, 0, 0, 0, 0 }, /* TDM_B1:L1RXD */
  165. /* PD11 */ { 1, 0, 0, 0, 0, 0 }, /* TDM_B1:L1TSYNC */
  166. /* PD10 */ { 1, 0, 0, 0, 0, 0 }, /* TDM_B1:L1RSYNC*/
  167. /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1:TXD */
  168. /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1:RXD */
  169. /* PD7 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1:SMSYN */
  170. /* PD6 */ { 1, 0, 0, 1, 0, 0 }, /* IDMA1:DACK */
  171. /* PD5 */ { 1, 0, 0, 1, 0, 0 }, /* IDMA1:DONE */
  172. /* PD4 */ { 0, 0, 0, 0, 0, 0 }, /* PD4 */
  173. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  174. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  175. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  176. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  177. }
  178. };
  179. /* ------------------------------------------------------------------------- */
  180. /*
  181. * Check Board Identity:
  182. */
  183. int checkboard (void)
  184. {
  185. puts ("Board: Wind River PPMC8260\n");
  186. return 0;
  187. }
  188. /* ------------------------------------------------------------------------- */
  189. long int initdram (int board_type)
  190. {
  191. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  192. volatile memctl8260_t *memctl = &immap->im_memctl;
  193. volatile uchar c = 0xff;
  194. volatile uchar *ramaddr0 = (uchar *) (CFG_SDRAM0_BASE);
  195. volatile uchar *ramaddr1 = (uchar *) (CFG_SDRAM1_BASE);
  196. ulong psdmr = CFG_PSDMR;
  197. volatile uchar *ramaddr2 = (uchar *) (CFG_SDRAM2_BASE);
  198. ulong lsdmr = CFG_LSDMR;
  199. int i;
  200. /*
  201. * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
  202. *
  203. * "At system reset, initialization software must set up the
  204. * programmable parameters in the memory controller banks registers
  205. * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
  206. * system software should execute the following initialization sequence
  207. * for each SDRAM device.
  208. *
  209. * 1. Issue a PRECHARGE-ALL-BANKS command
  210. * 2. Issue eight CBR REFRESH commands
  211. * 3. Issue a MODE-SET command to initialize the mode register
  212. *
  213. * The initial commands are executed by setting P/LSDMR[OP] and
  214. * accessing the SDRAM with a single-byte transaction."
  215. *
  216. * The appropriate BRx/ORx registers have already been set when we
  217. * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
  218. */
  219. memctl->memc_psrt = CFG_PSRT;
  220. memctl->memc_mptpr = CFG_MPTPR;
  221. #ifndef CFG_RAMBOOT
  222. memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
  223. *ramaddr0++ = c;
  224. *ramaddr1++ = c;
  225. memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
  226. for (i = 0; i < 8; i++) {
  227. *ramaddr0++ = c;
  228. *ramaddr1++ = c;
  229. }
  230. memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
  231. ramaddr0 = (uchar *) (CFG_SDRAM0_BASE + 0x110);
  232. ramaddr1 = (uchar *) (CFG_SDRAM1_BASE + 0x110);
  233. *ramaddr0 = c;
  234. *ramaddr1 = c;
  235. memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  236. *ramaddr0 = c;
  237. *ramaddr1 = c;
  238. memctl->memc_lsdmr = lsdmr | PSDMR_OP_PREA;
  239. *ramaddr2++ = c;
  240. memctl->memc_lsdmr = lsdmr | PSDMR_OP_CBRR;
  241. for (i = 0; i < 8; i++) {
  242. *ramaddr2++ = c;
  243. }
  244. memctl->memc_lsdmr = lsdmr | PSDMR_OP_MRW;
  245. *ramaddr2++ = c;
  246. memctl->memc_lsdmr = lsdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  247. *ramaddr2 = c;
  248. #endif
  249. /* return total ram size */
  250. return ((CFG_SDRAM0_SIZE + CFG_SDRAM1_SIZE) * 1024 * 1024);
  251. }
  252. #ifdef CONFIG_MISC_INIT_R
  253. /* ------------------------------------------------------------------------- */
  254. int misc_init_r (void)
  255. {
  256. #ifdef CFG_LED_BASE
  257. uchar ds = *(unsigned char *) (CFG_LED_BASE + 1);
  258. uchar ss;
  259. uchar tmp[64];
  260. int res;
  261. if ((ds != 0) && (ds != 0xff)) {
  262. res = getenv_r ("ethaddr", (char *)tmp, sizeof (tmp));
  263. if (res > 0) {
  264. ss = ((ds >> 4) & 0x0f);
  265. ss += ss < 0x0a ? '0' : ('a' - 10);
  266. tmp[15] = ss;
  267. ss = (ds & 0x0f);
  268. ss += ss < 0x0a ? '0' : ('a' - 10);
  269. tmp[16] = ss;
  270. tmp[17] = '\0';
  271. setenv ("ethaddr", (char *)tmp);
  272. /* set the led to show the address */
  273. *((unsigned char *) (CFG_LED_BASE + 1)) = ds;
  274. }
  275. }
  276. #endif /* CFG_LED_BASE */
  277. return (0);
  278. }
  279. #endif /* CONFIG_MISC_INIT_R */