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