scm.c 19 KB

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