cpu87.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /*
  2. * (C) Copyright 2001-2005
  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 "cpu87.h"
  27. #include <pci.h>
  28. #include <netdev.h>
  29. /*
  30. * I/O Port configuration table
  31. *
  32. * if conf is 1, then that port pin will be configured at boot time
  33. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  34. */
  35. const iop_conf_t iop_conf_tab[4][32] = {
  36. /* Port A configuration */
  37. { /* conf ppar psor pdir podr pdat */
  38. /* PA31 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 MII COL */
  39. /* PA30 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 MII CRS */
  40. /* PA29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 MII TX_ER */
  41. /* PA28 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 MII TX_EN */
  42. /* PA27 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 MII RX_DV */
  43. /* PA26 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 MII RX_ER */
  44. /* PA25 */ { 1, 0, 0, 1, 0, 0 }, /* FCC2 MII MDIO */
  45. /* PA24 */ { 1, 0, 0, 1, 0, 0 }, /* FCC2 MII MDC */
  46. /* PA23 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1 MII MDIO */
  47. /* PA22 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1 MII MDC */
  48. /* PA21 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[3] */
  49. /* PA20 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[2] */
  50. /* PA19 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[1] */
  51. /* PA18 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[0] */
  52. /* PA17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[0] */
  53. /* PA16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[1] */
  54. /* PA15 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[2] */
  55. /* PA14 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[3] */
  56. /* PA13 */ { 1, 0, 0, 1, 0, 0 }, /* FCC2 MII TXSL1 */
  57. /* PA12 */ { 1, 0, 0, 1, 0, 1 }, /* FCC2 MII TXSL0 */
  58. /* PA11 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1 MII TXSL1 */
  59. /* PA10 */ { 1, 0, 0, 1, 0, 1 }, /* FCC1 MII TXSL0 */
  60. /* PA9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
  61. /* PA8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC2 RXD */
  62. /* PA7 */ { 0, 0, 0, 0, 0, 0 }, /* PA7 */
  63. /* PA6 */ { 1, 0, 0, 1, 0, 1 }, /* FCC2 MII PAUSE */
  64. /* PA5 */ { 1, 0, 0, 1, 0, 1 }, /* FCC1 MII PAUSE */
  65. /* PA4 */ { 1, 0, 0, 1, 0, 0 }, /* FCC2 MII PWRDN */
  66. /* PA3 */ { 1, 0, 0, 1, 0, 0 }, /* FCC1 MII PWRDN */
  67. /* PA2 */ { 0, 0, 0, 0, 0, 0 }, /* PA2 */
  68. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FCC2 MII MDINT */
  69. /* PA0 */ { 1, 0, 0, 1, 0, 0 } /* FCC1 MII MDINT */
  70. },
  71. /* Port B configuration */
  72. { /* conf ppar psor pdir podr pdat */
  73. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  74. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  75. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  76. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  77. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  78. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  79. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  80. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  81. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  82. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  83. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  84. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  85. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  86. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  87. /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
  88. /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */
  89. /* PB15 */ { 0, 0, 0, 0, 0, 0 }, /* PB15 */
  90. /* PB14 */ { 0, 0, 0, 0, 0, 0 }, /* PB14 */
  91. /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
  92. /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */
  93. /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */
  94. /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */
  95. /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */
  96. /* PB8 */ { 0, 0, 0, 0, 0, 0 }, /* PB8 */
  97. /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
  98. /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
  99. /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
  100. /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
  101. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* PB3 */
  102. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* PB2 */
  103. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* PB1 */
  104. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* PB0 */
  105. },
  106. /* Port C */
  107. { /* conf ppar psor pdir podr pdat */
  108. /* PC31 */ { 0, 0, 0, 0, 0, 0 }, /* PC31 */
  109. /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
  110. /* PC29 */ { 1, 0, 0, 0, 0, 0 }, /* SCC1 CTS */
  111. /* PC28 */ { 1, 0, 0, 0, 0, 0 }, /* SCC2 CTS */
  112. /* PC27 */ { 0, 0, 0, 0, 0, 0 }, /* PC27 */
  113. /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
  114. /* PC25 */ { 0, 0, 0, 0, 0, 0 }, /* PC25 */
  115. /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
  116. /* PC23 */ { 0, 0, 0, 0, 0, 0 }, /* FDC37C78 DACFD */
  117. /* PC22 */ { 0, 0, 0, 0, 0, 0 }, /* FDC37C78 DNFD */
  118. /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RX_CLK */
  119. /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII TX_CLK */
  120. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK */
  121. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII TX_CLK */
  122. /* PC17 */ { 0, 0, 0, 0, 0, 0 }, /* PC17 */
  123. /* PC16 */ { 0, 0, 0, 0, 0, 0 }, /* PC16 */
  124. /* PC15 */ { 0, 0, 0, 0, 0, 0 }, /* PC15 */
  125. /* PC14 */ { 0, 0, 0, 0, 0, 0 }, /* PC14 */
  126. /* PC13 */ { 0, 0, 0, 0, 0, 0 }, /* PC13 */
  127. /* PC12 */ { 0, 0, 0, 0, 0, 0 }, /* PC12 */
  128. /* PC11 */ { 0, 0, 0, 0, 0, 0 }, /* PC11 */
  129. /* PC10 */ { 0, 0, 0, 0, 0, 0 }, /* PC10 */
  130. /* PC9 */ { 0, 0, 0, 0, 0, 0 }, /* FC9 */
  131. /* PC8 */ { 0, 0, 0, 0, 0, 0 }, /* PC8 */
  132. /* PC7 */ { 0, 0, 0, 0, 0, 0 }, /* PC7 */
  133. /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* PC6 */
  134. /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* PC5 */
  135. /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* PC4 */
  136. /* PC3 */ { 0, 0, 0, 0, 0, 0 }, /* PC3 */
  137. /* PC2 */ { 0, 0, 0, 0, 0, 0 }, /* PC2 */
  138. /* PC1 */ { 0, 0, 0, 0, 0, 0 }, /* PC1 */
  139. /* PC0 */ { 0, 0, 0, 0, 0, 0 }, /* FDC37C78 DRQFD */
  140. },
  141. /* Port D */
  142. { /* conf ppar psor pdir podr pdat */
  143. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 RXD */
  144. /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 TXD */
  145. /* PD29 */ { 1, 0, 0, 1, 0, 0 }, /* SCC1 RTS */
  146. /* PD28 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 RXD */
  147. /* PD27 */ { 1, 1, 0, 1, 0, 0 }, /* SCC2 TXD */
  148. /* PD26 */ { 1, 0, 0, 1, 0, 0 }, /* SCC2 RTS */
  149. /* PD25 */ { 0, 0, 0, 0, 0, 0 }, /* PD25 */
  150. /* PD24 */ { 0, 0, 0, 0, 0, 0 }, /* PD24 */
  151. /* PD23 */ { 0, 0, 0, 0, 0, 0 }, /* PD23 */
  152. /* PD22 */ { 0, 0, 0, 0, 0, 0 }, /* PD22 */
  153. /* PD21 */ { 0, 0, 0, 0, 0, 0 }, /* PD21 */
  154. /* PD20 */ { 0, 0, 0, 0, 0, 0 }, /* PD20 */
  155. /* PD19 */ { 0, 0, 0, 0, 0, 0 }, /* PD19 */
  156. /* PD18 */ { 0, 0, 0, 0, 0, 0 }, /* PD18 */
  157. /* PD17 */ { 0, 0, 0, 0, 0, 0 }, /* PD17 */
  158. /* PD16 */ { 0, 0, 0, 0, 0, 0 }, /* PD16 */
  159. #if defined(CONFIG_SOFT_I2C)
  160. /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */
  161. /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */
  162. #else
  163. #if defined(CONFIG_HARD_I2C)
  164. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  165. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  166. #else /* normal I/O port pins */
  167. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  168. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  169. #endif
  170. #endif
  171. /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
  172. /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
  173. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  174. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  175. /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  176. /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  177. /* PD7 */ { 0, 0, 0, 0, 0, 0 }, /* PD7 */
  178. /* PD6 */ { 0, 0, 0, 0, 0, 0 }, /* PD6 */
  179. /* PD5 */ { 0, 0, 0, 0, 0, 0 }, /* PD5 */
  180. /* PD4 */ { 0, 0, 0, 0, 0, 0 }, /* PD4 */
  181. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* PD3 */
  182. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* PD2 */
  183. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* PD1 */
  184. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* PD0 */
  185. }
  186. };
  187. /* ------------------------------------------------------------------------- */
  188. /* Check Board Identity:
  189. */
  190. int checkboard (void)
  191. {
  192. printf ("Board: CPU87 (Rev %02x)\n", CPU86_REV & 0x7f);
  193. return 0;
  194. }
  195. /* ------------------------------------------------------------------------- */
  196. /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
  197. *
  198. * This routine performs standard 8260 initialization sequence
  199. * and calculates the available memory size. It may be called
  200. * several times to try different SDRAM configurations on both
  201. * 60x and local buses.
  202. */
  203. static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
  204. ulong orx, volatile uchar * base)
  205. {
  206. volatile uchar c = 0xff;
  207. volatile uint *sdmr_ptr;
  208. volatile uint *orx_ptr;
  209. ulong maxsize, size;
  210. int i;
  211. /* We must be able to test a location outsize the maximum legal size
  212. * to find out THAT we are outside; but this address still has to be
  213. * mapped by the controller. That means, that the initial mapping has
  214. * to be (at least) twice as large as the maximum expected size.
  215. */
  216. maxsize = (1 + (~orx | 0x7fff)) / 2;
  217. /* Since CONFIG_SYS_SDRAM_BASE is always 0 (??), we assume that
  218. * we are configuring CS1 if base != 0
  219. */
  220. sdmr_ptr = &memctl->memc_psdmr;
  221. orx_ptr = &memctl->memc_or2;
  222. *orx_ptr = orx;
  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. *sdmr_ptr = sdmr | PSDMR_OP_PREA;
  243. *base = c;
  244. *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
  245. for (i = 0; i < 8; i++)
  246. *base = c;
  247. *sdmr_ptr = sdmr | PSDMR_OP_MRW;
  248. *(base + CONFIG_SYS_MRS_OFFS) = c; /* setting MR on address lines */
  249. *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  250. *base = c;
  251. size = get_ram_size((long *)base, maxsize);
  252. *orx_ptr = orx | ~(size - 1);
  253. return (size);
  254. }
  255. phys_size_t initdram (int board_type)
  256. {
  257. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  258. volatile memctl8260_t *memctl = &immap->im_memctl;
  259. #ifndef CONFIG_SYS_RAMBOOT
  260. ulong size8, size9, size10;
  261. #endif
  262. long psize;
  263. psize = 32 * 1024 * 1024;
  264. memctl->memc_mptpr = CONFIG_SYS_MPTPR;
  265. memctl->memc_psrt = CONFIG_SYS_PSRT;
  266. #ifndef CONFIG_SYS_RAMBOOT
  267. /* 60x SDRAM setup:
  268. */
  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. size10 = try_init (memctl, CONFIG_SYS_PSDMR_10COL, CONFIG_SYS_OR2_10COL,
  274. (uchar *) CONFIG_SYS_SDRAM_BASE);
  275. psize = max(size8,max(size9,size10));
  276. if (psize == size8) {
  277. psize = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR2_8COL,
  278. (uchar *) CONFIG_SYS_SDRAM_BASE);
  279. printf ("(60x:8COL) ");
  280. } else if (psize == size9){
  281. psize = try_init (memctl, CONFIG_SYS_PSDMR_9COL, CONFIG_SYS_OR2_9COL,
  282. (uchar *) CONFIG_SYS_SDRAM_BASE);
  283. printf ("(60x:9COL) ");
  284. } else
  285. printf ("(60x:10COL) ");
  286. #endif /* CONFIG_SYS_RAMBOOT */
  287. icache_enable ();
  288. return (psize);
  289. }
  290. #if defined(CONFIG_CMD_DOC)
  291. void doc_init (void)
  292. {
  293. doc_probe (CONFIG_SYS_DOC_BASE);
  294. }
  295. #endif
  296. #ifdef CONFIG_PCI
  297. struct pci_controller hose;
  298. extern void pci_mpc8250_init(struct pci_controller *);
  299. void pci_init_board(void)
  300. {
  301. pci_mpc8250_init(&hose);
  302. }
  303. #endif
  304. int board_eth_init(bd_t *bis)
  305. {
  306. return pci_eth_init(bis);
  307. }