hymod.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. *
  7. * Hacked for the Hymod board by Murray.Jensen@csiro.au, 20-Oct-00
  8. */
  9. #include <common.h>
  10. #include <bootretry.h>
  11. #include <cli.h>
  12. #include <mpc8260.h>
  13. #include <mpc8260_irq.h>
  14. #include <ioports.h>
  15. #include <i2c.h>
  16. #include <asm/iopin_8260.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. /* ------------------------------------------------------------------------- */
  19. /* imports from eeprom.c */
  20. extern int hymod_eeprom_read (int, hymod_eeprom_t *);
  21. extern void hymod_eeprom_print (hymod_eeprom_t *);
  22. /* imports from env.c */
  23. extern void hymod_check_env (void);
  24. /* ------------------------------------------------------------------------- */
  25. /*
  26. * I/O Port configuration table
  27. *
  28. * if conf is 1, then that port pin will be configured at boot time
  29. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  30. */
  31. const iop_conf_t iop_conf_tab[4][32] = {
  32. /* Port A configuration */
  33. {
  34. /* cnf par sor dir odr dat */
  35. { 1, 1, 1, 0, 0, 0 }, /* PA31: FCC1 MII COL */
  36. { 1, 1, 1, 0, 0, 0 }, /* PA30: FCC1 MII CRS */
  37. { 1, 1, 1, 1, 0, 0 }, /* PA29: FCC1 MII TX_ER */
  38. { 1, 1, 1, 1, 0, 0 }, /* PA28: FCC1 MII TX_EN */
  39. { 1, 1, 1, 0, 0, 0 }, /* PA27: FCC1 MII RX_DV */
  40. { 1, 1, 1, 0, 0, 0 }, /* PA26: FCC1 MII RX_ER */
  41. { 1, 0, 0, 1, 0, 0 }, /* PA25: FCC2 MII MDIO */
  42. { 1, 0, 0, 1, 0, 0 }, /* PA24: FCC2 MII MDC */
  43. { 1, 0, 0, 1, 0, 0 }, /* PA23: FCC3 MII MDIO */
  44. { 1, 0, 0, 1, 0, 0 }, /* PA22: FCC3 MII MDC */
  45. { 1, 1, 0, 1, 0, 0 }, /* PA21: FCC1 MII TxD[3] */
  46. { 1, 1, 0, 1, 0, 0 }, /* PA20: FCC1 MII TxD[2] */
  47. { 1, 1, 0, 1, 0, 0 }, /* PA19: FCC1 MII TxD[1] */
  48. { 1, 1, 0, 1, 0, 0 }, /* PA18: FCC1 MII TxD[0] */
  49. { 1, 1, 0, 0, 0, 0 }, /* PA17: FCC1 MII RxD[3] */
  50. { 1, 1, 0, 0, 0, 0 }, /* PA16: FCC1 MII RxD[2] */
  51. { 1, 1, 0, 0, 0, 0 }, /* PA15: FCC1 MII RxD[1] */
  52. { 1, 1, 0, 0, 0, 0 }, /* PA14: FCC1 MII RxD[0] */
  53. { 1, 0, 0, 1, 0, 0 }, /* PA13: FCC1 MII MDIO */
  54. { 1, 0, 0, 1, 0, 0 }, /* PA12: FCC1 MII MDC */
  55. { 1, 0, 0, 1, 0, 0 }, /* PA11: SEL_CD */
  56. { 1, 0, 0, 0, 0, 0 }, /* PA10: FLASH STS1 */
  57. { 1, 0, 0, 0, 0, 0 }, /* PA09: FLASH STS0 */
  58. { 1, 0, 0, 0, 0, 0 }, /* PA08: FLASH ~PE */
  59. { 1, 0, 0, 0, 0, 0 }, /* PA07: WATCH ~HRESET */
  60. { 1, 0, 0, 0, 1, 0 }, /* PA06: VC DONE */
  61. { 1, 0, 0, 1, 1, 0 }, /* PA05: VC INIT */
  62. { 1, 0, 0, 1, 0, 0 }, /* PA04: VC ~PROG */
  63. { 1, 0, 0, 1, 0, 0 }, /* PA03: VM ENABLE */
  64. { 1, 0, 0, 0, 1, 0 }, /* PA02: VM DONE */
  65. { 1, 0, 0, 1, 1, 0 }, /* PA01: VM INIT */
  66. { 1, 0, 0, 1, 0, 0 } /* PA00: VM ~PROG */
  67. },
  68. /* Port B configuration */
  69. {
  70. /* cnf par sor dir odr dat */
  71. { 1, 1, 0, 1, 0, 0 }, /* PB31: FCC2 MII TX_ER */
  72. { 1, 1, 0, 0, 0, 0 }, /* PB30: FCC2 MII RX_DV */
  73. { 1, 1, 1, 1, 0, 0 }, /* PB29: FCC2 MII TX_EN */
  74. { 1, 1, 0, 0, 0, 0 }, /* PB28: FCC2 MII RX_ER */
  75. { 1, 1, 0, 0, 0, 0 }, /* PB27: FCC2 MII COL */
  76. { 1, 1, 0, 0, 0, 0 }, /* PB26: FCC2 MII CRS */
  77. { 1, 1, 0, 1, 0, 0 }, /* PB25: FCC2 MII TxD[3] */
  78. { 1, 1, 0, 1, 0, 0 }, /* PB24: FCC2 MII TxD[2] */
  79. { 1, 1, 0, 1, 0, 0 }, /* PB23: FCC2 MII TxD[1] */
  80. { 1, 1, 0, 1, 0, 0 }, /* PB22: FCC2 MII TxD[0] */
  81. { 1, 1, 0, 0, 0, 0 }, /* PB21: FCC2 MII RxD[0] */
  82. { 1, 1, 0, 0, 0, 0 }, /* PB20: FCC2 MII RxD[1] */
  83. { 1, 1, 0, 0, 0, 0 }, /* PB19: FCC2 MII RxD[2] */
  84. { 1, 1, 0, 0, 0, 0 }, /* PB18: FCC2 MII RxD[3] */
  85. { 1, 1, 0, 0, 0, 0 }, /* PB17: FCC3 MII RX_DV */
  86. { 1, 1, 0, 0, 0, 0 }, /* PB16: FCC3 MII RX_ER */
  87. { 1, 1, 0, 1, 0, 0 }, /* PB15: FCC3 MII TX_ER */
  88. { 1, 1, 0, 1, 0, 0 }, /* PB14: FCC3 MII TX_EN */
  89. { 1, 1, 0, 0, 0, 0 }, /* PB13: FCC3 MII COL */
  90. { 1, 1, 0, 0, 0, 0 }, /* PB12: FCC3 MII CRS */
  91. { 1, 1, 0, 0, 0, 0 }, /* PB11: FCC3 MII RxD[3] */
  92. { 1, 1, 0, 0, 0, 0 }, /* PB10: FCC3 MII RxD[2] */
  93. { 1, 1, 0, 0, 0, 0 }, /* PB09: FCC3 MII RxD[1] */
  94. { 1, 1, 0, 0, 0, 0 }, /* PB08: FCC3 MII RxD[0] */
  95. { 1, 1, 0, 1, 0, 0 }, /* PB07: FCC3 MII TxD[3] */
  96. { 1, 1, 0, 1, 0, 0 }, /* PB06: FCC3 MII TxD[2] */
  97. { 1, 1, 0, 1, 0, 0 }, /* PB05: FCC3 MII TxD[1] */
  98. { 1, 1, 0, 1, 0, 0 }, /* PB04: FCC3 MII TxD[0] */
  99. { 0, 0, 0, 0, 0, 0 }, /* PB03: pin doesn't exist */
  100. { 0, 0, 0, 0, 0, 0 }, /* PB02: pin doesn't exist */
  101. { 0, 0, 0, 0, 0, 0 }, /* PB01: pin doesn't exist */
  102. { 0, 0, 0, 0, 0, 0 } /* PB00: pin doesn't exist */
  103. },
  104. /* Port C configuration */
  105. {
  106. /* cnf par sor dir odr dat */
  107. { 1, 0, 0, 0, 0, 0 }, /* PC31: MEZ ~IACK */
  108. { 0, 0, 0, 0, 0, 0 }, /* PC30: ? */
  109. { 1, 1, 0, 0, 0, 0 }, /* PC29: CLK SCCx */
  110. { 1, 1, 0, 0, 0, 0 }, /* PC28: CLK4 */
  111. { 1, 1, 0, 0, 0, 0 }, /* PC27: CLK SCCF */
  112. { 1, 1, 0, 0, 0, 0 }, /* PC26: CLK 32K */
  113. { 1, 1, 0, 0, 0, 0 }, /* PC25: BRG4/CLK7 */
  114. { 0, 0, 0, 0, 0, 0 }, /* PC24: ? */
  115. { 1, 1, 0, 0, 0, 0 }, /* PC23: CLK SCCx */
  116. { 1, 1, 0, 0, 0, 0 }, /* PC22: FCC1 MII RX_CLK */
  117. { 1, 1, 0, 0, 0, 0 }, /* PC21: FCC1 MII TX_CLK */
  118. { 1, 1, 0, 0, 0, 0 }, /* PC20: CLK SCCF */
  119. { 1, 1, 0, 0, 0, 0 }, /* PC19: FCC2 MII RX_CLK */
  120. { 1, 1, 0, 0, 0, 0 }, /* PC18: FCC2 MII TX_CLK */
  121. { 1, 1, 0, 0, 0, 0 }, /* PC17: FCC3 MII RX_CLK */
  122. { 1, 1, 0, 0, 0, 0 }, /* PC16: FCC3 MII TX_CLK */
  123. { 1, 0, 0, 0, 0, 0 }, /* PC15: SCC1 UART ~CTS */
  124. { 1, 0, 0, 0, 0, 0 }, /* PC14: SCC1 UART ~CD */
  125. { 1, 0, 0, 0, 0, 0 }, /* PC13: SCC2 UART ~CTS */
  126. { 1, 0, 0, 0, 0, 0 }, /* PC12: SCC2 UART ~CD */
  127. { 1, 0, 0, 1, 0, 0 }, /* PC11: SCC1 UART ~DTR */
  128. { 1, 0, 0, 1, 0, 0 }, /* PC10: SCC1 UART ~DSR */
  129. { 1, 0, 0, 1, 0, 0 }, /* PC09: SCC2 UART ~DTR */
  130. { 1, 0, 0, 1, 0, 0 }, /* PC08: SCC2 UART ~DSR */
  131. { 1, 0, 0, 0, 0, 0 }, /* PC07: TEMP ~ALERT */
  132. { 1, 0, 0, 0, 0, 0 }, /* PC06: FCC3 INT */
  133. { 1, 0, 0, 0, 0, 0 }, /* PC05: FCC2 INT */
  134. { 1, 0, 0, 0, 0, 0 }, /* PC04: FCC1 INT */
  135. { 0, 1, 1, 1, 0, 0 }, /* PC03: SDMA IDMA2 ~DACK */
  136. { 0, 1, 1, 0, 0, 0 }, /* PC02: SDMA IDMA2 ~DONE */
  137. { 0, 1, 0, 0, 0, 0 }, /* PC01: SDMA IDMA2 ~DREQ */
  138. { 1, 1, 0, 1, 0, 0 } /* PC00: BRG7 */
  139. },
  140. /* Port D configuration */
  141. {
  142. /* cnf par sor dir odr dat */
  143. { 1, 1, 0, 0, 0, 0 }, /* PD31: SCC1 UART RxD */
  144. { 1, 1, 1, 1, 0, 0 }, /* PD30: SCC1 UART TxD */
  145. { 1, 0, 0, 1, 0, 0 }, /* PD29: SCC1 UART ~RTS */
  146. { 1, 1, 0, 0, 0, 0 }, /* PD28: SCC2 UART RxD */
  147. { 1, 1, 0, 1, 0, 0 }, /* PD27: SCC2 UART TxD */
  148. { 1, 0, 0, 1, 0, 0 }, /* PD26: SCC2 UART ~RTS */
  149. { 1, 0, 0, 0, 0, 0 }, /* PD25: SCC1 UART ~RI */
  150. { 1, 0, 0, 0, 0, 0 }, /* PD24: SCC2 UART ~RI */
  151. { 1, 0, 0, 1, 0, 0 }, /* PD23: CLKGEN PD */
  152. { 1, 0, 0, 0, 0, 0 }, /* PD22: USER3 */
  153. { 1, 0, 0, 0, 0, 0 }, /* PD21: USER2 */
  154. { 1, 0, 0, 0, 0, 0 }, /* PD20: USER1 */
  155. { 1, 1, 1, 0, 0, 0 }, /* PD19: SPI ~SEL */
  156. { 1, 1, 1, 0, 0, 0 }, /* PD18: SPI CLK */
  157. { 1, 1, 1, 0, 0, 0 }, /* PD17: SPI MOSI */
  158. { 1, 1, 1, 0, 0, 0 }, /* PD16: SPI MISO */
  159. { 1, 1, 1, 0, 1, 0 }, /* PD15: I2C SDA */
  160. { 1, 1, 1, 0, 1, 0 }, /* PD14: I2C SCL */
  161. { 1, 0, 0, 1, 0, 1 }, /* PD13: TEMP ~STDBY */
  162. { 1, 0, 0, 1, 0, 1 }, /* PD12: FCC3 ~RESET */
  163. { 1, 0, 0, 1, 0, 1 }, /* PD11: FCC2 ~RESET */
  164. { 1, 0, 0, 1, 0, 1 }, /* PD10: FCC1 ~RESET */
  165. { 1, 0, 0, 0, 0, 0 }, /* PD09: PD9 */
  166. { 1, 0, 0, 0, 0, 0 }, /* PD08: PD8 */
  167. { 1, 0, 0, 1, 0, 1 }, /* PD07: PD7 */
  168. { 1, 0, 0, 1, 0, 1 }, /* PD06: PD6 */
  169. { 1, 0, 0, 1, 0, 1 }, /* PD05: PD5 */
  170. { 1, 0, 0, 1, 0, 1 }, /* PD04: PD4 */
  171. { 0, 0, 0, 0, 0, 0 }, /* PD03: pin doesn't exist */
  172. { 0, 0, 0, 0, 0, 0 }, /* PD02: pin doesn't exist */
  173. { 0, 0, 0, 0, 0, 0 }, /* PD01: pin doesn't exist */
  174. { 0, 0, 0, 0, 0, 0 } /* PD00: pin doesn't exist */
  175. }
  176. };
  177. /* ------------------------------------------------------------------------- */
  178. /*
  179. * AMI FS6377 Clock Generator configuration table
  180. *
  181. * the "fs6377_regs[]" table entries correspond to FS6377 registers
  182. * 0 - 15 (total of 16 bytes).
  183. *
  184. * the data is written to the FS6377 via the i2c bus using address in
  185. * "fs6377_addr" (address is 7 bits - R/W bit not included).
  186. *
  187. * The fs6377 has four clock outputs: A, B, C and D.
  188. *
  189. * Outputs C and D can each provide two different clock outputs C1/D1 or
  190. * C2/D2 depending on the state of the SEL_CD input which is connected to
  191. * the MPC8260 I/O port pin PA11. PA11 output (SEL_CD input) low (or 0)
  192. * selects C1/D1 and PA11 output (SEL_CD input) high (or 1) selects C2/D2.
  193. *
  194. * PA11 defaults to output low (or 0) in the i/o port config table above.
  195. *
  196. * Output A provides a 100MHz for the High Speed Serial chips. Output B
  197. * provides a 3.6864MHz clock for more accurate asynchronous serial bit
  198. * rates. Output C is routed to the mezzanine connector but is currently
  199. * unused - both C1 and C2 are set to 16MHz. Output D is used by both the
  200. * alt-input and display mezzanine boards for their video chips. The
  201. * alt-input board requires a clock of 24.576MHz and this is available on
  202. * D1 (PA11=SEL_CD=0). The display board requires a clock of 27MHz and this
  203. * is available on D2 (PA11=SEL_CD=1).
  204. *
  205. * So the default is a clock suitable for the alt-input board. PA11 is toggled
  206. * later in misc_init_r(), if a display board is detected.
  207. */
  208. uchar fs6377_addr = 0x5c;
  209. uchar fs6377_regs[16] = {
  210. 12, 75, 64, 25, 144, 128, 25, 192,
  211. 0, 16, 135, 192, 224, 64, 64, 192
  212. };
  213. /* ------------------------------------------------------------------------- */
  214. /*
  215. * special board initialisation, after clocks and timebase have been
  216. * set up but before environment and serial are initialised.
  217. *
  218. * added so that very early initialisations can be done using the i2c
  219. * driver (which requires the clocks, to calculate the dividers, and
  220. * the timebase, for udelay())
  221. */
  222. int
  223. board_postclk_init (void)
  224. {
  225. i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  226. /*
  227. * Initialise the FS6377 clock chip
  228. *
  229. * the secondary address is the register number from where to
  230. * start the write - I want to write all the registers
  231. *
  232. * don't bother checking return status - we have no console yet
  233. * to print it on, nor any RAM to store it in - it will be obvious
  234. * if this doesn't work
  235. */
  236. (void) i2c_write (fs6377_addr, 0, 1, fs6377_regs,
  237. sizeof (fs6377_regs));
  238. return (0);
  239. }
  240. /* ------------------------------------------------------------------------- */
  241. /*
  242. * Check Board Identity: Hardwired to HYMOD
  243. */
  244. int
  245. checkboard (void)
  246. {
  247. puts ("Board: HYMOD\n");
  248. return (0);
  249. }
  250. /* ------------------------------------------------------------------------- */
  251. /*
  252. * miscellaneous (early - while running in flash) initialisations.
  253. */
  254. #define _NOT_USED_ 0xFFFFFFFF
  255. uint upmb_table[] = {
  256. /* Read Single Beat (RSS) - offset 0x00 */
  257. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  258. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  259. /* Read Burst (RBS) - offset 0x08 */
  260. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  261. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  262. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  263. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  264. /* Write Single Beat (WSS) - offset 0x18 */
  265. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  266. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  267. /* Write Burst (WSS) - offset 0x20 */
  268. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  269. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  270. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  271. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  272. /* Refresh Timer (PTS) - offset 0x30 */
  273. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  274. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  275. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  276. /* Exception Condition (EXS) - offset 0x3c */
  277. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_
  278. };
  279. uint upmc_table[] = {
  280. /* Read Single Beat (RSS) - offset 0x00 */
  281. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  282. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  283. /* Read Burst (RBS) - offset 0x08 */
  284. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  285. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  286. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  287. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  288. /* Write Single Beat (WSS) - offset 0x18 */
  289. 0xF0E00000, 0xF0A00000, 0x00A00000, 0x30A00000,
  290. 0xF0F40007, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  291. /* Write Burst (WSS) - offset 0x20 */
  292. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  293. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  294. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  295. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  296. /* Refresh Timer (PTS) - offset 0x30 */
  297. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  298. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  299. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  300. /* Exception Condition (EXS) - offset 0x3c */
  301. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_
  302. };
  303. int
  304. misc_init_f (void)
  305. {
  306. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  307. volatile memctl8260_t *memctl = &immap->im_memctl;
  308. printf ("UPMs: ");
  309. upmconfig (UPMB, upmb_table, sizeof upmb_table / sizeof upmb_table[0]);
  310. memctl->memc_mbmr = CONFIG_SYS_MBMR;
  311. upmconfig (UPMC, upmc_table, sizeof upmc_table / sizeof upmc_table[0]);
  312. memctl->memc_mcmr = CONFIG_SYS_MCMR;
  313. printf ("configured\n");
  314. return (0);
  315. }
  316. /* ------------------------------------------------------------------------- */
  317. phys_size_t
  318. initdram (int board_type)
  319. {
  320. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  321. volatile memctl8260_t *memctl = &immap->im_memctl;
  322. volatile uchar c = 0, *ramaddr = (uchar *) (CONFIG_SYS_SDRAM_BASE + 0x8);
  323. ulong psdmr = CONFIG_SYS_PSDMR;
  324. int i;
  325. /*
  326. * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
  327. *
  328. * "At system reset, initialization software must set up the
  329. * programmable parameters in the memory controller banks registers
  330. * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
  331. * system software should execute the following initialization sequence
  332. * for each SDRAM device.
  333. *
  334. * 1. Issue a PRECHARGE-ALL-BANKS command
  335. * 2. Issue eight CBR REFRESH commands
  336. * 3. Issue a MODE-SET command to initialize the mode register
  337. *
  338. * The initial commands are executed by setting P/LSDMR[OP] and
  339. * accessing the SDRAM with a single-byte transaction."
  340. *
  341. * The appropriate BRx/ORx registers have already been set when we
  342. * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
  343. */
  344. memctl->memc_psrt = CONFIG_SYS_PSRT;
  345. memctl->memc_mptpr = CONFIG_SYS_MPTPR;
  346. memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
  347. *ramaddr = c;
  348. memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
  349. for (i = 0; i < 8; i++)
  350. *ramaddr = c;
  351. memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
  352. *ramaddr = c;
  353. memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  354. *ramaddr = c;
  355. return (CONFIG_SYS_SDRAM_SIZE << 20);
  356. }
  357. /* ------------------------------------------------------------------------- */
  358. /* miscellaneous initialisations after relocation into ram (misc_init_r) */
  359. /* */
  360. /* loads the data in the main board and mezzanine board eeproms into */
  361. /* the hymod configuration struct stored in the board information area. */
  362. /* */
  363. /* if the contents of either eeprom is invalid, prompts for a serial */
  364. /* number (and an ethernet address if required) then fetches a file */
  365. /* containing information to be stored in the eeprom from the tftp server */
  366. /* (the file name is based on the serial number and a built-in path) */
  367. int
  368. last_stage_init (void)
  369. {
  370. hymod_conf_t *cp = &gd->bd->bi_hymod_conf;
  371. int rc;
  372. #ifdef CONFIG_BOOT_RETRY_TIME
  373. /*
  374. * we use the cli_readline() function, but we also want
  375. * command timeout enabled
  376. */
  377. init_cmd_timeout ();
  378. #endif
  379. memset ((void *) cp, 0, sizeof (*cp));
  380. /* set up main board config info */
  381. rc = hymod_eeprom_read (0, &cp->main.eeprom);
  382. puts ("EEPROM:main...");
  383. if (rc < 0)
  384. puts ("NOT PRESENT\n");
  385. else if (rc == 0)
  386. puts ("INVALID\n");
  387. else {
  388. cp->main.eeprom.valid = 1;
  389. printf ("OK (ver %u)\n", cp->main.eeprom.ver);
  390. hymod_eeprom_print (&cp->main.eeprom);
  391. /*
  392. * hard-wired assumption here: all hymod main boards will have
  393. * one xilinx fpga, with the interrupt line connected to IRQ2
  394. *
  395. * One day, this might be based on the board type
  396. */
  397. cp->main.xlx[0].mmap.prog.exists = 1;
  398. cp->main.xlx[0].mmap.prog.size = FPGA_MAIN_CFG_SIZE;
  399. cp->main.xlx[0].mmap.prog.base = FPGA_MAIN_CFG_BASE;
  400. cp->main.xlx[0].mmap.reg.exists = 1;
  401. cp->main.xlx[0].mmap.reg.size = FPGA_MAIN_REG_SIZE;
  402. cp->main.xlx[0].mmap.reg.base = FPGA_MAIN_REG_BASE;
  403. cp->main.xlx[0].mmap.port.exists = 1;
  404. cp->main.xlx[0].mmap.port.size = FPGA_MAIN_PORT_SIZE;
  405. cp->main.xlx[0].mmap.port.base = FPGA_MAIN_PORT_BASE;
  406. cp->main.xlx[0].iopins.prog_pin.port = FPGA_MAIN_PROG_PORT;
  407. cp->main.xlx[0].iopins.prog_pin.pin = FPGA_MAIN_PROG_PIN;
  408. cp->main.xlx[0].iopins.prog_pin.flag = 1;
  409. cp->main.xlx[0].iopins.init_pin.port = FPGA_MAIN_INIT_PORT;
  410. cp->main.xlx[0].iopins.init_pin.pin = FPGA_MAIN_INIT_PIN;
  411. cp->main.xlx[0].iopins.init_pin.flag = 1;
  412. cp->main.xlx[0].iopins.done_pin.port = FPGA_MAIN_DONE_PORT;
  413. cp->main.xlx[0].iopins.done_pin.pin = FPGA_MAIN_DONE_PIN;
  414. cp->main.xlx[0].iopins.done_pin.flag = 1;
  415. #ifdef FPGA_MAIN_ENABLE_PORT
  416. cp->main.xlx[0].iopins.enable_pin.port = FPGA_MAIN_ENABLE_PORT;
  417. cp->main.xlx[0].iopins.enable_pin.pin = FPGA_MAIN_ENABLE_PIN;
  418. cp->main.xlx[0].iopins.enable_pin.flag = 1;
  419. #endif
  420. cp->main.xlx[0].irq = FPGA_MAIN_IRQ;
  421. }
  422. /* set up mezzanine board config info */
  423. rc = hymod_eeprom_read (1, &cp->mezz.eeprom);
  424. puts ("EEPROM:mezz...");
  425. if (rc < 0)
  426. puts ("NOT PRESENT\n");
  427. else if (rc == 0)
  428. puts ("INVALID\n");
  429. else {
  430. cp->main.eeprom.valid = 1;
  431. printf ("OK (ver %u)\n", cp->mezz.eeprom.ver);
  432. hymod_eeprom_print (&cp->mezz.eeprom);
  433. }
  434. cp->crc = crc32 (0, (unsigned char *)cp, offsetof (hymod_conf_t, crc));
  435. hymod_check_env ();
  436. return (0);
  437. }
  438. #ifdef CONFIG_SHOW_ACTIVITY
  439. void board_show_activity (ulong timebase)
  440. {
  441. #ifdef CONFIG_SYS_HYMOD_DBLEDS
  442. volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
  443. volatile iop8260_t *iop = &immr->im_ioport;
  444. static int shift = 0;
  445. if ((timestamp % CONFIG_SYS_HZ) == 0) {
  446. if (++shift > 3)
  447. shift = 0;
  448. iop->iop_pdatd =
  449. (iop->iop_pdatd & ~0x0f000000) | (1 << (24 + shift));
  450. }
  451. #endif /* CONFIG_SYS_HYMOD_DBLEDS */
  452. }
  453. void show_activity(int arg)
  454. {
  455. }
  456. #endif /* CONFIG_SHOW_ACTIVITY */