scm.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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 "scm.h"
  27. static void config_scoh_cs(void);
  28. extern int fpga_init(void);
  29. #if 0
  30. #define DEBUGF(fmt,args...) printf (fmt ,##args)
  31. #else
  32. #define DEBUGF(fmt,args...)
  33. #endif
  34. /*
  35. * I/O Port configuration table
  36. *
  37. * if conf is 1, then that port pin will be configured at boot time
  38. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  39. */
  40. const iop_conf_t iop_conf_tab[4][32] = {
  41. /* Port A configuration */
  42. { /* conf ppar psor pdir podr pdat */
  43. /* PA31 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 MII COL */
  44. /* PA30 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 MII CRS */
  45. /* PA29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 MII TX_ER */
  46. /* PA28 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 MII TX_EN */
  47. /* PA27 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 MII RX_DV */
  48. /* PA26 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 MII RX_ER */
  49. /* PA25 */ { 0, 0, 0, 1, 0, 0 },
  50. /* PA24 */ { 0, 0, 0, 1, 0, 0 },
  51. /* PA23 */ { 0, 0, 0, 1, 0, 0 },
  52. /* PA22 */ { 0, 0, 0, 1, 0, 0 },
  53. /* PA21 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[3] */
  54. /* PA20 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[2] */
  55. /* PA19 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[1] */
  56. /* PA18 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[0] */
  57. /* PA17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[0] */
  58. /* PA16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[1]*/
  59. /* PA15 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[2] */
  60. /* PA14 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[3] */
  61. /* PA13 */ { 0, 0, 0, 1, 0, 0 },
  62. /* PA12 */ { 0, 0, 0, 1, 0, 0 },
  63. /* PA11 */ { 0, 0, 0, 1, 0, 0 },
  64. /* PA10 */ { 0, 0, 0, 1, 0, 0 },
  65. /* PA9 */ { 1, 1, 1, 1, 0, 0 }, /* TDM_A1 L1TXD0 */
  66. /* PA8 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_A1 L1RXD0 */
  67. /* PA7 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_A1 L1TSYNC */
  68. /* PA6 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_A1 L1RSYNC */
  69. /* PA5 */ { 1, 0, 0, 0, 0, 0 }, /* FIOX_FPGA_PR */
  70. /* PA4 */ { 1, 0, 0, 0, 0, 0 }, /* DOHM_FPGA_PR */
  71. /* PA3 */ { 1, 1, 0, 0, 0, 0 }, /* TDM RXCLK4 */
  72. /* PA2 */ { 1, 1, 0, 0, 0, 0 }, /* TDM TXCLK4 */
  73. /* PA1 */ { 0, 0, 0, 1, 0, 0 },
  74. /* PA0 */ { 1, 0, 0, 0, 0, 0 } /* BUSY */
  75. },
  76. /* Port B configuration */
  77. { /* conf ppar psor pdir podr pdat */
  78. /* PB31 */ { 1, 0, 0, 1, 0, 0 }, /* EQ_ALARM_MIN */
  79. /* PB30 */ { 1, 0, 0, 1, 0, 0 }, /* EQ_ALARM_MAJ */
  80. /* PB29 */ { 1, 0, 0, 1, 0, 0 }, /* COM_ALARM_MIN */
  81. /* PB28 */ { 1, 0, 0, 1, 0, 0 }, /* COM_ALARM_MAJ */
  82. /* PB27 */ { 0, 1, 0, 0, 0, 0 },
  83. /* PB26 */ { 0, 1, 0, 0, 0, 0 },
  84. /* PB25 */ { 1, 0, 0, 1, 0, 0 }, /* LED_GREEN_L */
  85. /* PB24 */ { 1, 0, 0, 1, 0, 0 }, /* LED_RED_L */
  86. /* PB23 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_D2 L1TXD */
  87. /* PB22 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_D2 L1RXD */
  88. /* PB21 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_D2 L1TSYNC */
  89. /* PB20 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_D2 L1RSYNC */
  90. /* PB19 */ { 1, 0, 0, 0, 0, 0 }, /* UID */
  91. /* PB18 */ { 0, 1, 0, 0, 0, 0 },
  92. /* PB17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_DV */
  93. /* PB16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_ER */
  94. /* PB15 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TX_ER */
  95. /* PB14 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TX_EN */
  96. /* PB13 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII COL */
  97. /* PB12 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII CRS */
  98. /* PB11 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[3] */
  99. /* PB10 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[2] */
  100. /* PB9 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[1] */
  101. /* PB8 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[0] */
  102. /* PB7 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[3] */
  103. /* PB6 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[2] */
  104. /* PB5 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[1] */
  105. /* PB4 */ { 1, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[0] */
  106. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  107. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  108. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  109. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  110. },
  111. /* Port C configuration */
  112. { /* conf ppar psor pdir podr pdat */
  113. /* PC31 */ { 1, 1, 0, 0, 0, 0 }, /* TDM RXCLK1 */
  114. /* PC30 */ { 1, 1, 0, 0, 0, 0 }, /* TDM TXCLK1 */
  115. /* PC29 */ { 1, 1, 0, 0, 0, 0 }, /* TDM RXCLK3 */
  116. /* PC28 */ { 1, 1, 0, 0, 0, 0 }, /* TDM TXCLK3 */
  117. /* PC27 */ { 1, 1, 0, 0, 0, 0 }, /* TDM RXCLK2 */
  118. /* PC26 */ { 1, 1, 0, 0, 0, 0 }, /* TDM TXCLK2 */
  119. /* PC25 */ { 0, 0, 0, 1, 0, 0 },
  120. /* PC24 */ { 0, 0, 0, 1, 0, 0 },
  121. /* PC23 */ { 0, 1, 0, 1, 0, 0 },
  122. /* PC22 */ { 0, 1, 0, 0, 0, 0 },
  123. /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII TX_CLK */
  124. /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 MII RX_CLK */
  125. /* PC19 */ { 0, 1, 0, 0, 0, 0 },
  126. /* PC18 */ { 0, 1, 0, 0, 0, 0 },
  127. /* PC17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_CLK */
  128. /* PC16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC3 MII TX_CLK */
  129. /* PC15 */ { 0, 0, 0, 1, 0, 0 },
  130. /* PC14 */ { 0, 1, 0, 0, 0, 0 },
  131. /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* RES_PHY_L */
  132. /* PC12 */ { 0, 0, 0, 1, 0, 0 },
  133. /* PC11 */ { 0, 0, 0, 1, 0, 0 },
  134. /* PC10 */ { 0, 0, 0, 1, 0, 0 },
  135. /* PC9 */ { 0, 1, 1, 0, 0, 0 }, /* TDM_A2 L1TSYNC */
  136. /* PC8 */ { 0, 0, 0, 0, 0, 0 }, /* FEP_RDY */
  137. /* PC7 */ { 0, 0, 0, 0, 0, 0 },
  138. /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* UC4_ALARM_L */
  139. /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* UC3_ALARM_L */
  140. /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* UC2_ALARM_L */
  141. /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* RES_MISC_L */
  142. /* PC2 */ { 0, 0, 0, 1, 0, 0 }, /* RES_OH_L */
  143. /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* RES_DOHM_L */
  144. /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* RES_FIOX_L */
  145. },
  146. /* Port D configuration */
  147. { /* conf ppar psor pdir podr pdat */
  148. /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
  149. /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
  150. /* PD29 */ { 0, 0, 0, 0, 0, 0 }, /* INIT_F */
  151. /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* DONE_F */
  152. /* PD27 */ { 0, 0, 0, 0, 0, 0 }, /* INIT_D */
  153. /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* DONE_D */
  154. /* PD25 */ { 0, 0, 0, 1, 0, 0 },
  155. /* PD24 */ { 0, 0, 0, 1, 0, 0 },
  156. /* PD23 */ { 0, 0, 0, 1, 0, 0 },
  157. /* PD22 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_A2 L1TXD */
  158. /* PD21 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_A2 L1RXD */
  159. /* PD20 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_A2 L1RSYNC */
  160. /* PD19 */ { 1, 1, 1, 0, 0, 0 }, /* SPI SPISEL */
  161. /* PD18 */ { 1, 1, 1, 0, 0, 0 }, /* SPI SPICLK */
  162. /* PD17 */ { 1, 1, 1, 0, 0, 0 }, /* SPI SPIMOSI */
  163. /* PD16 */ { 1, 1, 1, 0, 0, 0 }, /* SPI SPIMOSO */
  164. #if defined(CONFIG_SOFT_I2C)
  165. /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */
  166. /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */
  167. #else
  168. #if defined(CONFIG_HARD_I2C)
  169. /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
  170. /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
  171. #else /* normal I/O port pins */
  172. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
  173. /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
  174. #endif
  175. #endif
  176. /* PD13 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_B1 L1TXD */
  177. /* PD12 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_B1 L1RXD */
  178. /* PD11 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_B1 L1TSYNC */
  179. /* PD10 */ { 1, 1, 1, 0, 0, 0 }, /* TDM_B1 L1RSYNC */
  180. /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
  181. /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
  182. /* PD7 */ { 0, 0, 0, 1, 0, 1 },
  183. /* PD6 */ { 0, 0, 0, 1, 0, 1 },
  184. /* PD5 */ { 0, 0, 0, 1, 0, 0 }, /* PROG_F */
  185. /* PD4 */ { 0, 0, 0, 1, 0, 0 }, /* PROG_D */
  186. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  187. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  188. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  189. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  190. }
  191. };
  192. /* ------------------------------------------------------------------------- */
  193. /* Check Board Identity:
  194. */
  195. int checkboard (void)
  196. {
  197. unsigned char str[64];
  198. int i = getenv_r ("serial#", str, sizeof (str));
  199. puts ("Board: ");
  200. if (!i || strncmp (str, "TQM8260", 7)) {
  201. puts ("### No HW ID - assuming TQM8260\n");
  202. return (0);
  203. }
  204. puts (str);
  205. putc ('\n');
  206. return 0;
  207. }
  208. /* ------------------------------------------------------------------------- */
  209. /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
  210. *
  211. * This routine performs standard 8260 initialization sequence
  212. * and calculates the available memory size. It may be called
  213. * several times to try different SDRAM configurations on both
  214. * 60x and local buses.
  215. */
  216. static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
  217. ulong orx, volatile uchar * base)
  218. {
  219. volatile uchar c = 0xff;
  220. ulong cnt, val;
  221. volatile ulong *addr;
  222. volatile uint *sdmr_ptr;
  223. volatile uint *orx_ptr;
  224. int i;
  225. ulong save[32]; /* to make test non-destructive */
  226. ulong maxsize;
  227. /* We must be able to test a location outsize the maximum legal size
  228. * to find out THAT we are outside; but this address still has to be
  229. * mapped by the controller. That means, that the initial mapping has
  230. * to be (at least) twice as large as the maximum expected size.
  231. */
  232. maxsize = (1 + (~orx | 0x7fff)) / 2;
  233. /* Since CFG_SDRAM_BASE is always 0 (??), we assume that
  234. * we are configuring CS1 if base != 0
  235. */
  236. sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
  237. orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
  238. *orx_ptr = orx;
  239. /*
  240. * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
  241. *
  242. * "At system reset, initialization software must set up the
  243. * programmable parameters in the memory controller banks registers
  244. * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
  245. * system software should execute the following initialization sequence
  246. * for each SDRAM device.
  247. *
  248. * 1. Issue a PRECHARGE-ALL-BANKS command
  249. * 2. Issue eight CBR REFRESH commands
  250. * 3. Issue a MODE-SET command to initialize the mode register
  251. *
  252. * The initial commands are executed by setting P/LSDMR[OP] and
  253. * accessing the SDRAM with a single-byte transaction."
  254. *
  255. * The appropriate BRx/ORx registers have already been set when we
  256. * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
  257. */
  258. *sdmr_ptr = sdmr | PSDMR_OP_PREA;
  259. *base = c;
  260. *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
  261. for (i = 0; i < 8; i++)
  262. *base = c;
  263. *sdmr_ptr = sdmr | PSDMR_OP_MRW;
  264. *(base + CFG_MRS_OFFS) = c; /* setting MR on address lines */
  265. *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  266. *base = c;
  267. /*
  268. * Check memory range for valid RAM. A simple memory test determines
  269. * the actually available RAM size between addresses `base' and
  270. * `base + maxsize'. Some (not all) hardware errors are detected:
  271. * - short between address lines
  272. * - short between data lines
  273. */
  274. i = 0;
  275. for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) {
  276. addr = (volatile ulong *) base + cnt; /* pointer arith! */
  277. save[i++] = *addr;
  278. *addr = ~cnt;
  279. }
  280. addr = (volatile ulong *) base;
  281. save[i] = *addr;
  282. *addr = 0;
  283. if ((val = *addr) != 0) {
  284. *addr = save[i];
  285. return (0);
  286. }
  287. for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) {
  288. addr = (volatile ulong *) base + cnt; /* pointer arith! */
  289. val = *addr;
  290. *addr = save[--i];
  291. if (val != ~cnt) {
  292. /* Write the actual size to ORx
  293. */
  294. *orx_ptr = orx | ~(cnt * sizeof (long) - 1);
  295. return (cnt * sizeof (long));
  296. }
  297. }
  298. return (maxsize);
  299. }
  300. /*
  301. * Test Power-On-Reset.
  302. */
  303. int power_on_reset (void)
  304. {
  305. DECLARE_GLOBAL_DATA_PTR;
  306. /* Test Reset Status Register */
  307. return gd->reset_status & RSR_CSRS ? 0 : 1;
  308. }
  309. long int initdram (int board_type)
  310. {
  311. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  312. volatile memctl8260_t *memctl = &immap->im_memctl;
  313. #ifndef CFG_RAMBOOT
  314. long size8, size9;
  315. #endif
  316. long psize, lsize;
  317. psize = 16 * 1024 * 1024;
  318. lsize = 0;
  319. memctl->memc_psrt = CFG_PSRT;
  320. memctl->memc_mptpr = CFG_MPTPR;
  321. #if 0 /* Just for debugging */
  322. #define prt_br_or(brX,orX) do { \
  323. ulong start = memctl->memc_ ## brX & 0xFFFF8000; \
  324. ulong sizem = ~memctl->memc_ ## orX | 0x00007FFF; \
  325. printf ("\n" \
  326. #brX " 0x%08x " #orX " 0x%08x " \
  327. "==> 0x%08lx ... 0x%08lx = %ld MB\n", \
  328. memctl->memc_ ## brX, memctl->memc_ ## orX, \
  329. start, start+sizem, (sizem+1)>>20); \
  330. } while (0)
  331. prt_br_or (br0, or0);
  332. prt_br_or (br1, or1);
  333. prt_br_or (br2, or2);
  334. prt_br_or (br3, or3);
  335. #endif
  336. #ifndef CFG_RAMBOOT
  337. /* 60x SDRAM setup:
  338. */
  339. size8 = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
  340. (uchar *) CFG_SDRAM_BASE);
  341. size9 = try_init (memctl, CFG_PSDMR_9COL, CFG_OR1_9COL,
  342. (uchar *) CFG_SDRAM_BASE);
  343. if (size8 < size9) {
  344. psize = size9;
  345. printf ("(60x:9COL - %ld MB, ", psize >> 20);
  346. } else {
  347. psize = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
  348. (uchar *) CFG_SDRAM_BASE);
  349. printf ("(60x:8COL - %ld MB, ", psize >> 20);
  350. }
  351. /* Local SDRAM setup:
  352. */
  353. #ifdef CFG_INIT_LOCAL_SDRAM
  354. memctl->memc_lsrt = CFG_LSRT;
  355. size8 = try_init (memctl, CFG_LSDMR_8COL, CFG_OR2_8COL,
  356. (uchar *) SDRAM_BASE2_PRELIM);
  357. size9 = try_init (memctl, CFG_LSDMR_9COL, CFG_OR2_9COL,
  358. (uchar *) SDRAM_BASE2_PRELIM);
  359. if (size8 < size9) {
  360. lsize = size9;
  361. printf ("Local:9COL - %ld MB) using ", lsize >> 20);
  362. } else {
  363. lsize = try_init (memctl, CFG_LSDMR_8COL, CFG_OR2_8COL,
  364. (uchar *) SDRAM_BASE2_PRELIM);
  365. printf ("Local:8COL - %ld MB) using ", lsize >> 20);
  366. }
  367. #if 0
  368. /* Set up BR2 so that the local SDRAM goes
  369. * right after the 60x SDRAM
  370. */
  371. memctl->memc_br2 = (CFG_BR2_PRELIM & ~BRx_BA_MSK) |
  372. (CFG_SDRAM_BASE + psize);
  373. #endif
  374. #endif /* CFG_INIT_LOCAL_SDRAM */
  375. #endif /* CFG_RAMBOOT */
  376. icache_enable ();
  377. config_scoh_cs ();
  378. return (psize);
  379. }
  380. /* ------------------------------------------------------------------------- */
  381. static void config_scoh_cs (void)
  382. {
  383. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  384. volatile memctl8260_t *memctl = &immr->im_memctl;
  385. volatile can_reg_t *can = (volatile can_reg_t *) CFG_CAN0_BASE;
  386. volatile uint tmp, i;
  387. /* Initialize OR3 / BR3 for CAN Bus Controller 0 */
  388. memctl->memc_or3 = CFG_CAN0_OR3;
  389. memctl->memc_br3 = CFG_CAN0_BR3;
  390. /* Initialize OR4 / BR4 for CAN Bus Controller 1 */
  391. memctl->memc_or4 = CFG_CAN1_OR4;
  392. memctl->memc_br4 = CFG_CAN1_BR4;
  393. /* Initialize MAMR to write in the array at address 0x0 */
  394. memctl->memc_mamr = 0x00 | MxMR_OP_WARR | MxMR_GPL_x4DIS;
  395. /* Initialize UPMA for CAN: single read */
  396. memctl->memc_mdr = 0xcffeec00;
  397. udelay (1); /* Necessary to have the data correct in the UPM array!!!! */
  398. /* The read on the CAN controller write the data of mdr in UPMA array. */
  399. /* The index to the array will be incremented automatically
  400. through this read */
  401. tmp = can->cpu_interface;
  402. memctl->memc_mdr = 0x0ffcec00;
  403. udelay (1);
  404. tmp = can->cpu_interface;
  405. memctl->memc_mdr = 0x0ffcec00;
  406. udelay (1);
  407. tmp = can->cpu_interface;
  408. memctl->memc_mdr = 0x0ffcec00;
  409. udelay (1);
  410. tmp = can->cpu_interface;
  411. memctl->memc_mdr = 0x0ffcec00;
  412. udelay (1);
  413. tmp = can->cpu_interface;
  414. memctl->memc_mdr = 0x0ffcfc00;
  415. udelay (1);
  416. tmp = can->cpu_interface;
  417. memctl->memc_mdr = 0x0ffcfc00;
  418. udelay (1);
  419. tmp = can->cpu_interface;
  420. memctl->memc_mdr = 0xfffdec07;
  421. udelay (1);
  422. tmp = can->cpu_interface;
  423. /* Initialize MAMR to write in the array at address 0x18 */
  424. memctl->memc_mamr = 0x18 | MxMR_OP_WARR | MxMR_GPL_x4DIS;
  425. /* Initialize UPMA for CAN: single write */
  426. memctl->memc_mdr = 0xfcffec00;
  427. udelay (1);
  428. tmp = can->cpu_interface;
  429. memctl->memc_mdr = 0x00ffec00;
  430. udelay (1);
  431. tmp = can->cpu_interface;
  432. memctl->memc_mdr = 0x00ffec00;
  433. udelay (1);
  434. tmp = can->cpu_interface;
  435. memctl->memc_mdr = 0x00ffec00;
  436. udelay (1);
  437. tmp = can->cpu_interface;
  438. memctl->memc_mdr = 0x00ffec00;
  439. udelay (1);
  440. tmp = can->cpu_interface;
  441. memctl->memc_mdr = 0x00fffc00;
  442. udelay (1);
  443. tmp = can->cpu_interface;
  444. memctl->memc_mdr = 0x00fffc00;
  445. udelay (1);
  446. tmp = can->cpu_interface;
  447. memctl->memc_mdr = 0x30ffec07;
  448. udelay (1);
  449. tmp = can->cpu_interface;
  450. /* Initialize MAMR */
  451. memctl->memc_mamr = MxMR_GPL_x4DIS; /* GPL_B4 ouput line Disable */
  452. /* Initialize OR5 / BR5 for the extended EEPROM Bank0 */
  453. memctl->memc_or5 = CFG_EXTPROM_OR5;
  454. memctl->memc_br5 = CFG_EXTPROM_BR5;
  455. /* Initialize OR6 / BR6 for the extended EEPROM Bank1 */
  456. memctl->memc_or6 = CFG_EXTPROM_OR6;
  457. memctl->memc_br6 = CFG_EXTPROM_BR6;
  458. /* Initialize OR7 / BR7 for the Glue Logic */
  459. memctl->memc_or7 = CFG_FIOX_OR7;
  460. memctl->memc_br7 = CFG_FIOX_BR7;
  461. /* Initialize OR8 / BR8 for the DOH Logic */
  462. memctl->memc_or8 = CFG_FDOHM_OR8;
  463. memctl->memc_br8 = CFG_FDOHM_BR8;
  464. DEBUGF ("OR0 %08x BR0 %08x\n", memctl->memc_or0, memctl->memc_br0);
  465. DEBUGF ("OR1 %08x BR1 %08x\n", memctl->memc_or1, memctl->memc_br1);
  466. DEBUGF ("OR2 %08x BR2 %08x\n", memctl->memc_or2, memctl->memc_br2);
  467. DEBUGF ("OR3 %08x BR3 %08x\n", memctl->memc_or3, memctl->memc_br3);
  468. DEBUGF ("OR4 %08x BR4 %08x\n", memctl->memc_or4, memctl->memc_br4);
  469. DEBUGF ("OR5 %08x BR5 %08x\n", memctl->memc_or5, memctl->memc_br5);
  470. DEBUGF ("OR6 %08x BR6 %08x\n", memctl->memc_or6, memctl->memc_br6);
  471. DEBUGF ("OR7 %08x BR7 %08x\n", memctl->memc_or7, memctl->memc_br7);
  472. DEBUGF ("OR8 %08x BR8 %08x\n", memctl->memc_or8, memctl->memc_br8);
  473. DEBUGF ("UPMA addr 0x0\n");
  474. memctl->memc_mamr = 0x00 | MxMR_OP_RARR | MxMR_GPL_x4DIS;
  475. for (i = 0; i < 0x8; i++) {
  476. tmp = can->cpu_interface;
  477. udelay (1);
  478. DEBUGF (" %08x ", memctl->memc_mdr);
  479. }
  480. DEBUGF ("\nUPMA addr 0x18\n");
  481. memctl->memc_mamr = 0x18 | MxMR_OP_RARR | MxMR_GPL_x4DIS;
  482. for (i = 0; i < 0x8; i++) {
  483. tmp = can->cpu_interface;
  484. udelay (1);
  485. DEBUGF (" %08x ", memctl->memc_mdr);
  486. }
  487. DEBUGF ("\n");
  488. memctl->memc_mamr = MxMR_GPL_x4DIS;
  489. }
  490. /* ------------------------------------------------------------------------- */
  491. int misc_init_r (void)
  492. {
  493. fpga_init ();
  494. return (0);
  495. }
  496. /* ------------------------------------------------------------------------- */