cpu87.c 13 KB

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