hymod.c 19 KB

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