hymod.c 19 KB

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