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