ids8247.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. * (C) Copyright 2005
  3. * Heiko Schocher, DENX Software Engineering, <hs@denx.de>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <ioports.h>
  25. #include <mpc8260.h>
  26. DECLARE_GLOBAL_DATA_PTR;
  27. /*
  28. * I/O Port configuration table
  29. *
  30. * if conf is 1, then that port pin will be configured at boot time
  31. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  32. */
  33. const iop_conf_t iop_conf_tab[4][32] = {
  34. /* Port A configuration */
  35. { /* conf ppar psor pdir podr pdat */
  36. /* PA31 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 COL */
  37. /* PA30 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 CRS */
  38. /* PA29 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 TXER */
  39. /* PA28 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 TXEN */
  40. /* PA27 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 RXDV */
  41. /* PA26 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 RXER */
  42. /* PA25 */ { 0, 0, 0, 0, 1, 0 }, /* 8247_P0 */
  43. #if defined(CONFIG_SOFT_I2C)
  44. /* PA24 */ { 1, 0, 0, 0, 1, 1 }, /* I2C_SDA2 */
  45. /* PA23 */ { 1, 0, 0, 1, 1, 1 }, /* I2C_SCL2 */
  46. #else /* normal I/O port pins */
  47. /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* PA24 */
  48. /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* PA23 */
  49. #endif
  50. /* PA22 */ { 0, 0, 0, 0, 1, 0 }, /* SMC2_DCD */
  51. /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TXD3 */
  52. /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TXD2 */
  53. /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TXD1 */
  54. /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TXD0 */
  55. /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RXD0 */
  56. /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RXD1 */
  57. /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RXD2 */
  58. /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RXD3 */
  59. /* PA13 */ { 0, 0, 0, 1, 1, 0 }, /* SMC2_RTS */
  60. /* PA12 */ { 0, 0, 0, 0, 1, 0 }, /* SMC2_CTS */
  61. /* PA11 */ { 0, 0, 0, 1, 1, 0 }, /* SMC2_DTR */
  62. /* PA10 */ { 0, 0, 0, 0, 1, 0 }, /* SMC2_DSR */
  63. /* PA9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
  64. /* PA8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC2 RXD */
  65. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  66. /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */
  67. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  68. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  69. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  70. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  71. /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */
  72. /* PA0 */ { 0, 0, 0, 1, 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 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
  91. /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */
  92. /* PB15 */ { 0, 0, 0, 0, 0, 0 }, /* PB15 */
  93. /* PB14 */ { 0, 0, 0, 0, 0, 0 }, /* PB14 */
  94. /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
  95. /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */
  96. /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */
  97. /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */
  98. /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */
  99. /* PB8 */ { 0, 0, 0, 0, 0, 0 }, /* PB8 */
  100. /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
  101. /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
  102. /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
  103. /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
  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 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
  112. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  113. /* PC29 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CLSN */
  114. /* PC28 */ { 0, 1, 1, 0, 0, 0 }, /* SYNC_OUT */
  115. /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* PC27 */
  116. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  117. /* PC25 */ { 0, 1, 1, 0, 0, 0 }, /* SYNC_IN */
  118. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  119. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
  120. /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
  121. /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
  122. /* PC20 */ { 0, 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 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
  126. /* PC16 */ { 0, 0, 0, 1, 0, 0 }, /* PC16 */
  127. /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */
  128. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
  129. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  130. /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* PC12 */
  131. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* PC11 */
  132. /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* FCC2 MDC */
  133. /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* FCC2 MDIO */
  134. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
  135. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  136. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  137. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  138. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  139. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  140. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
  141. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
  142. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
  143. },
  144. /* Port D */
  145. { /* conf ppar psor pdir podr pdat */
  146. /* PD31 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  147. /* PD30 */ { 0, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  148. /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
  149. /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */
  150. /* PD27 */ { 0, 0, 0, 1, 0, 0 }, /* PD27 */
  151. /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
  152. /* PD25 */ { 0, 1, 0, 0, 0, 0 }, /* SCC3_RX */
  153. /* PD24 */ { 0, 1, 0, 1, 0, 0 }, /* SCC3_TX */
  154. /* PD23 */ { 0, 1, 0, 1, 0, 0 }, /* SCC3_RTS */
  155. /* PD22 */ { 0, 1, 0, 0, 0, 0 }, /* SCC4_RXD */
  156. /* PD21 */ { 0, 1, 0, 1, 0, 0 }, /* SCC4_TXD */
  157. /* PD20 */ { 0, 1, 0, 1, 0, 0 }, /* SCC4_RTS */
  158. /* PD19 */ { 0, 1, 1, 0, 0, 0 }, /* SPI_SEL */
  159. /* PD18 */ { 0, 1, 1, 0, 0, 0 }, /* SPI_CLK */
  160. /* PD17 */ { 0, 1, 1, 0, 0, 0 }, /* SPI_MOSI */
  161. /* PD16 */ { 0, 1, 1, 0, 0, 0 }, /* SPI_MISO */
  162. #if defined(CONFIG_HARD_I2C)
  163. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA1 */
  164. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL1 */
  165. #else /* normal I/O port pins */
  166. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* PD15 */
  167. /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* PD14 */
  168. #endif
  169. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  170. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  171. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  172. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  173. /* PD9 */ { 0, 0, 0, 0, 0, 0 }, /* PD9 */
  174. /* PD8 */ { 0, 0, 0, 0, 0, 0 }, /* PD8 */
  175. /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* MII_MDIO */
  176. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  177. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  178. /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
  179. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  180. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  181. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  182. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  183. }
  184. };
  185. /* ------------------------------------------------------------------------- */
  186. /* Check Board Identity:
  187. */
  188. int checkboard (void)
  189. {
  190. puts ("Board: IDS 8247\n");
  191. return 0;
  192. }
  193. /* ------------------------------------------------------------------------- */
  194. /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
  195. *
  196. * This routine performs standard 8260 initialization sequence
  197. * and calculates the available memory size. It may be called
  198. * several times to try different SDRAM configurations on both
  199. * 60x and local buses.
  200. */
  201. static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
  202. ulong orx, volatile uchar * base)
  203. {
  204. volatile uchar c = 0xff;
  205. volatile uint *sdmr_ptr;
  206. volatile uint *orx_ptr;
  207. ulong maxsize, size;
  208. int i;
  209. /* We must be able to test a location outsize the maximum legal size
  210. * to find out THAT we are outside; but this address still has to be
  211. * mapped by the controller. That means, that the initial mapping has
  212. * to be (at least) twice as large as the maximum expected size.
  213. */
  214. maxsize = (1 + (~orx | 0x7fff)) / 2;
  215. sdmr_ptr = &memctl->memc_psdmr;
  216. orx_ptr = &memctl->memc_or2;
  217. *orx_ptr = orx;
  218. /*
  219. * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
  220. *
  221. * "At system reset, initialization software must set up the
  222. * programmable parameters in the memory controller banks registers
  223. * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
  224. * system software should execute the following initialization sequence
  225. * for each SDRAM device.
  226. *
  227. * 1. Issue a PRECHARGE-ALL-BANKS command
  228. * 2. Issue eight CBR REFRESH commands
  229. * 3. Issue a MODE-SET command to initialize the mode register
  230. *
  231. * The initial commands are executed by setting P/LSDMR[OP] and
  232. * accessing the SDRAM with a single-byte transaction."
  233. *
  234. * The appropriate BRx/ORx registers have already been set when we
  235. * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
  236. */
  237. *sdmr_ptr = sdmr | PSDMR_OP_PREA;
  238. *base = c;
  239. *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
  240. for (i = 0; i < 8; i++)
  241. *base = c;
  242. *sdmr_ptr = sdmr | PSDMR_OP_MRW;
  243. *(base + CFG_MRS_OFFS) = c; /* setting MR on address lines */
  244. *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  245. *base = c;
  246. size = get_ram_size((long *)base, maxsize);
  247. *orx_ptr = orx | ~(size - 1);
  248. return (size);
  249. }
  250. long int initdram (int board_type)
  251. {
  252. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  253. volatile memctl8260_t *memctl = &immap->im_memctl;
  254. long psize, lsize;
  255. psize = 16 * 1024 * 1024;
  256. lsize = 0;
  257. memctl->memc_psrt = CFG_PSRT;
  258. memctl->memc_mptpr = CFG_MPTPR;
  259. #ifndef CFG_RAMBOOT
  260. /* 60x SDRAM setup:
  261. */
  262. psize = try_init (memctl, CFG_PSDMR, CFG_OR2,
  263. (uchar *) CFG_SDRAM_BASE);
  264. #endif /* CFG_RAMBOOT */
  265. icache_enable ();
  266. return (psize);
  267. }
  268. int misc_init_r (void)
  269. {
  270. gd->bd->bi_flashstart = 0xff800000;
  271. }
  272. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  273. extern ulong
  274. nand_probe (ulong physadr);
  275. void
  276. nand_init (void)
  277. {
  278. ulong totlen = 0;
  279. debug ("Probing at 0x%.8x\n", CFG_NAND0_BASE);
  280. totlen += nand_probe (CFG_NAND0_BASE);
  281. printf ("%4lu MB\n", totlen >>20);
  282. }
  283. #endif /* CFG_CMD_NAND */