pm826.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /*
  2. * (C) Copyright 2001
  3. * Wolfgang Denk, DENX Software Engineering, wd@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. #include <pci.h>
  27. #include <netdev.h>
  28. /*
  29. * I/O Port configuration table
  30. *
  31. * if conf is 1, then that port pin will be configured at boot time
  32. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  33. */
  34. const iop_conf_t iop_conf_tab[4][32] = {
  35. /* Port A configuration */
  36. { /* conf ppar psor pdir podr pdat */
  37. /* PA31 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 COL */
  38. /* PA30 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 CRS */
  39. /* PA29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 TXER */
  40. /* PA28 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 TXEN */
  41. /* PA27 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 RXDV */
  42. /* PA26 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 RXER */
  43. /* PA25 */ { 0, 0, 0, 1, 0, 0 }, /* PA25 */
  44. /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* PA24 */
  45. /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* PA23 */
  46. /* PA22 */ { 0, 0, 0, 1, 0, 0 }, /* PA22 */
  47. /* PA21 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD3 */
  48. /* PA20 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD2 */
  49. /* PA19 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD1 */
  50. /* PA18 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD0 */
  51. /* PA17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD0 */
  52. /* PA16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD1*/
  53. /* PA15 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD2 */
  54. /* PA14 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD3 */
  55. /* PA13 */ { 0, 0, 0, 1, 0, 0 }, /* PA13 */
  56. /* PA12 */ { 0, 0, 0, 1, 0, 0 }, /* PA12 */
  57. /* PA11 */ { 0, 0, 0, 1, 0, 0 }, /* PA11 */
  58. /* PA10 */ { 0, 0, 0, 1, 0, 0 }, /* PA10 */
  59. /* PA9 */ { 0, 1, 0, 1, 0, 0 }, /* PA9 */
  60. /* PA8 */ { 0, 1, 0, 0, 0, 0 }, /* PA8 */
  61. /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
  62. /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */
  63. /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
  64. /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
  65. /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
  66. /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
  67. /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */
  68. /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
  69. },
  70. /* Port B configuration */
  71. { /* conf ppar psor pdir podr pdat */
  72. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TX_ER */
  73. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RX_DV */
  74. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 TX_EN */
  75. #if defined(CONFIG_ETHER_ON_SCC) && (CONFIG_ETHER_INDEX == 1)
  76. #ifdef CONFIG_ETHER_ON_FCC2
  77. #error "SCC1 conflicts with FCC2"
  78. #endif
  79. /* PB28 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 TXD */
  80. #else
  81. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RX_ER */
  82. #endif
  83. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 COL */
  84. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 CRS */
  85. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TxD[3] */
  86. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TxD[2] */
  87. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TxD[1] */
  88. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TxD[0] */
  89. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RxD[0] */
  90. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RxD[1] */
  91. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RxD[2] */
  92. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RxD[3] */
  93. /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
  94. /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */
  95. /* PB15 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 RXD */
  96. /* PB14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC3 RXD */
  97. /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
  98. /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */
  99. /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */
  100. /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */
  101. /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */
  102. /* PB8 */ { 1, 1, 1, 1, 0, 0 }, /* SCC3 TXD */
  103. /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
  104. /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
  105. /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
  106. /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
  107. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  108. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  109. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  110. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  111. },
  112. /* Port C */
  113. { /* conf ppar psor pdir podr pdat */
  114. /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
  115. /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
  116. /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 CTS */
  117. /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* SCC2 CTS */
  118. /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* PC27 */
  119. /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
  120. /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
  121. /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
  122. /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* PC23 */
  123. /* PC22 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 TXCK */
  124. /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXCK */
  125. /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 TXCK(2) */
  126. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RXCK */
  127. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 TXCK */
  128. /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
  129. /* PC16 */ { 0, 0, 0, 1, 0, 0 }, /* PC16 */
  130. /* PC15 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
  131. /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 DCD */
  132. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
  133. /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* SCC2 DCD */
  134. /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* SCC3 CTS */
  135. /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* SCC3 DCD */
  136. /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* SCC4 CTS */
  137. /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* SCC4 DCD */
  138. /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
  139. /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
  140. /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
  141. /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
  142. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
  143. /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* PC2 */
  144. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* PC1 */
  145. /* PC0 */ { 0, 0, 0, 1, 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 */ { 0, 1, 1, 1, 0, 0 }, /* PD30 */
  151. /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 RTS */
  152. /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */
  153. /* PD27 */ { 0, 1, 0, 1, 0, 0 }, /* SCC2 RTS */
  154. /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
  155. /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
  156. /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
  157. /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* SCC3 RTS */
  158. /* PD22 */ { 1, 1, 0, 0, 0, 0 }, /* SCC4 RXD */
  159. /* PD21 */ { 1, 1, 0, 1, 0, 0 }, /* SCC4 TXD */
  160. /* PD20 */ { 0, 0, 1, 1, 0, 0 }, /* SCC4 RTS */
  161. /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
  162. /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
  163. /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* PD17 */
  164. /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* PD16 */
  165. #if defined(CONFIG_SOFT_I2C)
  166. /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */
  167. /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */
  168. #else
  169. #if defined(CONFIG_HARD_I2C)
  170. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  171. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  172. #else /* normal I/O port pins */
  173. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
  174. /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
  175. #endif
  176. #endif
  177. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  178. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  179. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  180. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  181. /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* PD9 */
  182. /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* PD8 */
  183. /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
  184. /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
  185. /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
  186. /* PD4 */ { 1, 1, 1, 0, 0, 0 }, /* SMC2 RXD */
  187. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  188. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  189. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  190. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  191. }
  192. };
  193. /* ------------------------------------------------------------------------- */
  194. /* Check Board Identity:
  195. */
  196. int checkboard (void)
  197. {
  198. puts ("Board: PM826\n");
  199. return 0;
  200. }
  201. /* ------------------------------------------------------------------------- */
  202. /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
  203. *
  204. * This routine performs standard 8260 initialization sequence
  205. * and calculates the available memory size. It may be called
  206. * several times to try different SDRAM configurations on both
  207. * 60x and local buses.
  208. */
  209. static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
  210. ulong orx, volatile uchar * base)
  211. {
  212. volatile uchar c = 0xff;
  213. volatile uint *sdmr_ptr;
  214. volatile uint *orx_ptr;
  215. ulong maxsize, size;
  216. int i;
  217. /* We must be able to test a location outsize the maximum legal size
  218. * to find out THAT we are outside; but this address still has to be
  219. * mapped by the controller. That means, that the initial mapping has
  220. * to be (at least) twice as large as the maximum expected size.
  221. */
  222. maxsize = (1 + (~orx | 0x7fff)) / 2;
  223. sdmr_ptr = &memctl->memc_psdmr;
  224. orx_ptr = &memctl->memc_or2;
  225. *orx_ptr = orx;
  226. /*
  227. * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
  228. *
  229. * "At system reset, initialization software must set up the
  230. * programmable parameters in the memory controller banks registers
  231. * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
  232. * system software should execute the following initialization sequence
  233. * for each SDRAM device.
  234. *
  235. * 1. Issue a PRECHARGE-ALL-BANKS command
  236. * 2. Issue eight CBR REFRESH commands
  237. * 3. Issue a MODE-SET command to initialize the mode register
  238. *
  239. * The initial commands are executed by setting P/LSDMR[OP] and
  240. * accessing the SDRAM with a single-byte transaction."
  241. *
  242. * The appropriate BRx/ORx registers have already been set when we
  243. * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
  244. */
  245. *sdmr_ptr = sdmr | PSDMR_OP_PREA;
  246. *base = c;
  247. *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
  248. for (i = 0; i < 8; i++)
  249. *base = c;
  250. *sdmr_ptr = sdmr | PSDMR_OP_MRW;
  251. *(base + CONFIG_SYS_MRS_OFFS) = c; /* setting MR on address lines */
  252. *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  253. *base = c;
  254. size = get_ram_size((long *)base, maxsize);
  255. *orx_ptr = orx | ~(size - 1);
  256. return (size);
  257. }
  258. phys_size_t initdram (int board_type)
  259. {
  260. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  261. volatile memctl8260_t *memctl = &immap->im_memctl;
  262. #ifndef CONFIG_SYS_RAMBOOT
  263. ulong size8, size9;
  264. #endif
  265. ulong psize = 32 * 1024 * 1024;
  266. memctl->memc_psrt = CONFIG_SYS_PSRT;
  267. memctl->memc_mptpr = CONFIG_SYS_MPTPR;
  268. #ifndef CONFIG_SYS_RAMBOOT
  269. size8 = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR2_8COL,
  270. (uchar *) CONFIG_SYS_SDRAM_BASE);
  271. size9 = try_init (memctl, CONFIG_SYS_PSDMR_9COL, CONFIG_SYS_OR2_9COL,
  272. (uchar *) CONFIG_SYS_SDRAM_BASE);
  273. if (size8 < size9) {
  274. psize = size9;
  275. printf ("(60x:9COL) ");
  276. } else {
  277. psize = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR2_8COL,
  278. (uchar *) CONFIG_SYS_SDRAM_BASE);
  279. printf ("(60x:8COL) ");
  280. }
  281. #endif
  282. return (psize);
  283. }
  284. #if defined(CONFIG_CMD_DOC)
  285. void doc_init (void)
  286. {
  287. doc_probe (CONFIG_SYS_DOC_BASE);
  288. }
  289. #endif
  290. #ifdef CONFIG_PCI
  291. struct pci_controller hose;
  292. extern void pci_mpc8250_init(struct pci_controller *);
  293. void pci_init_board(void)
  294. {
  295. pci_mpc8250_init(&hose);
  296. }
  297. #endif
  298. int board_eth_init(bd_t *bis)
  299. {
  300. return pci_eth_init(bis);
  301. }