wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Rob Taylor. Flying Pig Systems. robt@flyingpig.com. |
| 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 <asm/processor.h> |
| 26 | #include <mpc824x.h> |
| 27 | |
| 28 | #ifndef CFG_BANK0_ROW |
| 29 | #define CFG_BANK0_ROW 0 |
| 30 | #endif |
| 31 | #ifndef CFG_BANK1_ROW |
| 32 | #define CFG_BANK1_ROW 0 |
| 33 | #endif |
| 34 | #ifndef CFG_BANK2_ROW |
| 35 | #define CFG_BANK2_ROW 0 |
| 36 | #endif |
| 37 | #ifndef CFG_BANK3_ROW |
| 38 | #define CFG_BANK3_ROW 0 |
| 39 | #endif |
| 40 | #ifndef CFG_BANK4_ROW |
| 41 | #define CFG_BANK4_ROW 0 |
| 42 | #endif |
| 43 | #ifndef CFG_BANK5_ROW |
| 44 | #define CFG_BANK5_ROW 0 |
| 45 | #endif |
| 46 | #ifndef CFG_BANK6_ROW |
| 47 | #define CFG_BANK6_ROW 0 |
| 48 | #endif |
| 49 | #ifndef CFG_BANK7_ROW |
| 50 | #define CFG_BANK7_ROW 0 |
| 51 | #endif |
| 52 | #ifndef CFG_DBUS_SIZE2 |
| 53 | #define CFG_DBUS_SIZE2 0 |
| 54 | #endif |
| 55 | |
| 56 | /* |
| 57 | * Breath some life into the CPU... |
| 58 | * |
| 59 | * Set up the memory map, |
| 60 | * initialize a bunch of registers, |
| 61 | */ |
| 62 | void |
| 63 | cpu_init_f (void) |
| 64 | { |
| 65 | /* MOUSSE board is initialized in asm */ |
| 66 | #if !defined(CONFIG_MOUSSE) && !defined(CONFIG_BMW) |
| 67 | register unsigned long val; |
| 68 | CONFIG_WRITE_HALFWORD(PCICR, 0x06); /* Bus Master, respond to PCI memory space acesses*/ |
| 69 | /* CONFIG_WRITE_HALFWORD(PCISR, 0xffff); */ /*reset PCISR*/ |
| 70 | |
| 71 | #if defined(CONFIG_MUSENKI) || defined(CONFIG_PN62) |
| 72 | /* Why is this here, you ask? Try, just try setting 0x8000 |
| 73 | * in PCIACR with CONFIG_WRITE_HALFWORD() |
| 74 | * this one was a stumper, and we are annoyed |
| 75 | */ |
| 76 | |
| 77 | #define M_CONFIG_WRITE_HALFWORD( addr, data ) \ |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 78 | __asm__ __volatile__(" \ |
| 79 | stw %2,0(%0)\n \ |
| 80 | sync\n \ |
| 81 | sth %3,2(%1)\n \ |
| 82 | sync\n \ |
| 83 | " \ |
| 84 | : /* no output */ \ |
| 85 | : "r" (CONFIG_ADDR), "r" (CONFIG_DATA), \ |
| 86 | "r" (PCISWAP(addr & ~3)), "r" (PCISWAP(data << 16)) \ |
| 87 | ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 88 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 89 | M_CONFIG_WRITE_HALFWORD(PCIACR, 0x8000); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 90 | #endif |
| 91 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 92 | CONFIG_WRITE_BYTE(PCLSR, 0x8); /* set PCI cache line size */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 93 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 94 | /* |
| 95 | * Note that although this bit is cleared after a hard reset, it |
| 96 | * must be explicitly set and then cleared by software during |
| 97 | * initialization in order to guarantee correct operation of the |
| 98 | * DLL and the SDRAM_CLK[0:3] signals (if they are used). |
| 99 | */ |
| 100 | CONFIG_READ_BYTE (AMBOR, val); |
| 101 | CONFIG_WRITE_BYTE(AMBOR, val & 0xDF); |
| 102 | CONFIG_WRITE_BYTE(AMBOR, val | 0x20); |
| 103 | CONFIG_WRITE_BYTE(AMBOR, val & 0xDF); |
| 104 | #ifdef CONFIG_MPC8245 |
| 105 | /* silicon bug 28 MPC8245 */ |
| 106 | CONFIG_READ_BYTE(AMBOR,val); |
| 107 | CONFIG_WRITE_BYTE(AMBOR,val|0x1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 108 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 109 | CONFIG_READ_BYTE(PCMBCR,val); |
| 110 | /* in order not to corrupt data which is being read over the PCI bus |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame^] | 111 | * with the PPC as slave, we need to reduce the number of PCMRBs to 1, |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 112 | * 4.11 in the processor user manual |
| 113 | * */ |
| 114 | |
| 115 | #if 1 |
| 116 | CONFIG_WRITE_BYTE(PCMBCR,(val|0xC0)); /* 1 PCMRB */ |
| 117 | #else |
| 118 | CONFIG_WRITE_BYTE(PCMBCR,(val|0x80)); /* 2 PCMRBs */ |
| 119 | CONFIG_WRITE_BYTE(PCMBCR,(val|0x40)); /* 3 PCMRBs */ |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame^] | 120 | /* default, 4 PCMRBs are used, so don't change the |
| 121 | * register is this is _really_ what you want: data |
| 122 | * corruption with no performance gain |
| 123 | */ |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 124 | #endif |
| 125 | #endif |
| 126 | |
| 127 | CONFIG_READ_WORD(PICR1, val); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 128 | #if defined(CONFIG_MPC8240) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 129 | CONFIG_WRITE_WORD( PICR1, |
| 130 | (val & (PICR1_ADDRESS_MAP | PICR1_RCS0)) | |
| 131 | PIRC1_MSK | PICR1_PROC_TYPE_603E | |
| 132 | PICR1_FLASH_WR_EN | PICR1_MCP_EN | |
| 133 | PICR1_CF_DPARK | PICR1_EN_PCS | |
| 134 | PICR1_CF_APARK ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 135 | #elif defined(CONFIG_MPC8245) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 136 | CONFIG_WRITE_WORD( PICR1, |
| 137 | (val & (PICR1_RCS0)) | |
| 138 | PICR1_PROC_TYPE_603E | |
| 139 | PICR1_FLASH_WR_EN | PICR1_MCP_EN | |
| 140 | PICR1_CF_DPARK | PICR1_NO_BUSW_CK | |
| 141 | PICR1_DEC| PICR1_CF_APARK | 0x10); /* 8245 UM says bit 4 must be set */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 142 | #else |
| 143 | #error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240) |
| 144 | #endif |
| 145 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 146 | CONFIG_READ_WORD(PICR2, val); |
| 147 | val= val & ~ (PICR2_CF_SNOOP_WS_MASK | PICR2_CF_APHASE_WS_MASK); /*mask off waitstate bits*/ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 148 | #ifndef CONFIG_PN62 |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 149 | val |= PICR2_CF_SNOOP_WS_1WS | PICR2_CF_APHASE_WS_1WS; /*1 wait state*/ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 150 | #endif |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 151 | CONFIG_WRITE_WORD(PICR2, val); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 152 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 153 | CONFIG_WRITE_WORD(EUMBBAR, CFG_EUMB_ADDR); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 154 | #ifndef CFG_RAMBOOT |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 155 | CONFIG_WRITE_WORD(MCCR1, (CFG_ROMNAL << MCCR1_ROMNAL_SHIFT) | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 156 | (CFG_BANK0_ROW) | |
| 157 | (CFG_BANK1_ROW << MCCR1_BANK1ROW_SHIFT) | |
| 158 | (CFG_BANK2_ROW << MCCR1_BANK2ROW_SHIFT) | |
| 159 | (CFG_BANK3_ROW << MCCR1_BANK3ROW_SHIFT) | |
| 160 | (CFG_BANK4_ROW << MCCR1_BANK4ROW_SHIFT) | |
| 161 | (CFG_BANK5_ROW << MCCR1_BANK5ROW_SHIFT) | |
| 162 | (CFG_BANK6_ROW << MCCR1_BANK6ROW_SHIFT) | |
| 163 | (CFG_BANK7_ROW << MCCR1_BANK7ROW_SHIFT) | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 164 | (CFG_ROMFAL << MCCR1_ROMFAL_SHIFT)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 165 | #endif |
| 166 | |
| 167 | #if defined(CFG_ASRISE) && defined(CFG_ASFALL) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 168 | CONFIG_WRITE_WORD(MCCR2, CFG_REFINT << MCCR2_REFINT_SHIFT | |
| 169 | CFG_ASRISE << MCCR2_ASRISE_SHIFT | |
| 170 | CFG_ASFALL << MCCR2_ASFALL_SHIFT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 171 | #else |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 172 | CONFIG_WRITE_WORD(MCCR2, CFG_REFINT << MCCR2_REFINT_SHIFT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 173 | #endif |
| 174 | |
| 175 | #if defined(CONFIG_MPC8240) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 176 | CONFIG_WRITE_WORD(MCCR3, |
| 177 | (((CFG_BSTOPRE & 0x003c) >> 2) << MCCR3_BSTOPRE2TO5_SHIFT) | |
| 178 | (CFG_REFREC << MCCR3_REFREC_SHIFT) | |
| 179 | (CFG_RDLAT << MCCR3_RDLAT_SHIFT)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 180 | #elif defined(CONFIG_MPC8245) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 181 | CONFIG_WRITE_WORD(MCCR3, |
| 182 | (((CFG_BSTOPRE & 0x003c) >> 2) << MCCR3_BSTOPRE2TO5_SHIFT) | |
| 183 | (CFG_REFREC << MCCR3_REFREC_SHIFT)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 184 | #else |
| 185 | #error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240) |
| 186 | #endif |
| 187 | |
| 188 | /* this is gross. We think these should all be the same, and various boards |
| 189 | * should define CFG_ACTORW to 0 if they don't want to set it, or even, if |
| 190 | * its not set, we define it to zero in this file |
| 191 | */ |
| 192 | #if defined(CONFIG_CU824) || defined(CONFIG_PN62) |
| 193 | CONFIG_WRITE_WORD(MCCR4, |
| 194 | (CFG_PRETOACT << MCCR4_PRETOACT_SHIFT) | |
| 195 | (CFG_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | |
| 196 | MCCR4_BIT21 | |
| 197 | (CFG_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | |
| 198 | ((CFG_BSTOPRE & 0x0003) <<MCCR4_BSTOPRE0TO1_SHIFT ) | |
| 199 | (((CFG_SDMODE_CAS_LAT <<4) | (CFG_SDMODE_WRAP <<3) | |
| 200 | CFG_SDMODE_BURSTLEN) << MCCR4_SDMODE_SHIFT) | |
| 201 | (CFG_ACTORW << MCCR4_ACTTORW_SHIFT) | |
| 202 | (((CFG_BSTOPRE & 0x03c0) >> 6) << MCCR4_BSTOPRE6TO9_SHIFT)); |
| 203 | #elif defined(CONFIG_MPC8240) |
| 204 | CONFIG_WRITE_WORD(MCCR4, |
| 205 | (CFG_PRETOACT << MCCR4_PRETOACT_SHIFT) | |
| 206 | (CFG_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | |
| 207 | MCCR4_BIT21 | |
| 208 | (CFG_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | |
| 209 | ((CFG_BSTOPRE & 0x0003) <<MCCR4_BSTOPRE0TO1_SHIFT ) | |
| 210 | (((CFG_SDMODE_CAS_LAT <<4) | (CFG_SDMODE_WRAP <<3) | |
| 211 | (CFG_SDMODE_BURSTLEN)) <<MCCR4_SDMODE_SHIFT) | |
| 212 | (((CFG_BSTOPRE & 0x03c0) >> 6) <<MCCR4_BSTOPRE6TO9_SHIFT )); |
| 213 | #elif defined(CONFIG_MPC8245) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 214 | CONFIG_READ_WORD(MCCR1, val); |
| 215 | val &= MCCR1_DBUS_SIZE0; /* test for 64-bit mem bus */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 216 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 217 | CONFIG_WRITE_WORD(MCCR4, |
| 218 | (CFG_PRETOACT << MCCR4_PRETOACT_SHIFT) | |
| 219 | (CFG_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | |
| 220 | (CFG_EXTROM ? MCCR4_EXTROM : 0) | |
| 221 | (CFG_REGDIMM ? MCCR4_REGDIMM : 0) | |
| 222 | (CFG_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | |
| 223 | ((CFG_BSTOPRE & 0x0003) <<MCCR4_BSTOPRE0TO1_SHIFT ) | |
| 224 | (CFG_DBUS_SIZE2 << MCCR4_DBUS_SIZE2_SHIFT) | |
| 225 | (((CFG_SDMODE_CAS_LAT <<4) | (CFG_SDMODE_WRAP <<3) | |
| 226 | (val ? 2 : 3)) << MCCR4_SDMODE_SHIFT) | |
| 227 | (CFG_ACTORW << MCCR4_ACTTORW_SHIFT) | |
| 228 | (((CFG_BSTOPRE & 0x03c0) >> 6) <<MCCR4_BSTOPRE6TO9_SHIFT )); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 229 | #else |
| 230 | #error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240) |
| 231 | #endif |
| 232 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 233 | CONFIG_WRITE_WORD(MSAR1, |
| 234 | ( (CFG_BANK0_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | |
| 235 | (((CFG_BANK1_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | |
| 236 | (((CFG_BANK2_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | |
| 237 | (((CFG_BANK3_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); |
| 238 | CONFIG_WRITE_WORD(EMSAR1, |
| 239 | ( (CFG_BANK0_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | |
| 240 | (((CFG_BANK1_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | |
| 241 | (((CFG_BANK2_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | |
| 242 | (((CFG_BANK3_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); |
| 243 | CONFIG_WRITE_WORD(MSAR2, |
| 244 | ( (CFG_BANK4_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | |
| 245 | (((CFG_BANK5_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | |
| 246 | (((CFG_BANK6_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | |
| 247 | (((CFG_BANK7_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); |
| 248 | CONFIG_WRITE_WORD(EMSAR2, |
| 249 | ( (CFG_BANK4_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | |
| 250 | (((CFG_BANK5_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | |
| 251 | (((CFG_BANK6_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | |
| 252 | (((CFG_BANK7_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); |
| 253 | CONFIG_WRITE_WORD(MEAR1, |
| 254 | ( (CFG_BANK0_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | |
| 255 | (((CFG_BANK1_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | |
| 256 | (((CFG_BANK2_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | |
| 257 | (((CFG_BANK3_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); |
| 258 | CONFIG_WRITE_WORD(EMEAR1, |
| 259 | ( (CFG_BANK0_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | |
| 260 | (((CFG_BANK1_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | |
| 261 | (((CFG_BANK2_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | |
| 262 | (((CFG_BANK3_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); |
| 263 | CONFIG_WRITE_WORD(MEAR2, |
| 264 | ( (CFG_BANK4_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | |
| 265 | (((CFG_BANK5_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | |
| 266 | (((CFG_BANK6_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | |
| 267 | (((CFG_BANK7_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); |
| 268 | CONFIG_WRITE_WORD(EMEAR2, |
| 269 | ( (CFG_BANK4_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | |
| 270 | (((CFG_BANK5_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | |
| 271 | (((CFG_BANK6_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | |
| 272 | (((CFG_BANK7_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 273 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 274 | CONFIG_WRITE_BYTE(ODCR, CFG_ODCR); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 275 | #ifdef CFG_DLL_MAX_DELAY |
| 276 | CONFIG_WRITE_BYTE(MIOCR1, CFG_DLL_MAX_DELAY); /* needed to make DLL lock */ |
| 277 | #endif |
| 278 | #if defined(CFG_DLL_EXTEND) && defined(CFG_PCI_HOLD_DEL) |
| 279 | CONFIG_WRITE_BYTE(PMCR2, CFG_DLL_EXTEND | CFG_PCI_HOLD_DEL); |
| 280 | #endif |
| 281 | #if defined(MIOCR2) && defined(CFG_SDRAM_DSCD) |
| 282 | CONFIG_WRITE_BYTE(MIOCR2, CFG_SDRAM_DSCD); /* change memory input */ |
| 283 | #endif /* setup & hold time */ |
| 284 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 285 | CONFIG_WRITE_BYTE(MBER, |
| 286 | CFG_BANK0_ENABLE | |
| 287 | (CFG_BANK1_ENABLE << 1) | |
| 288 | (CFG_BANK2_ENABLE << 2) | |
| 289 | (CFG_BANK3_ENABLE << 3) | |
| 290 | (CFG_BANK4_ENABLE << 4) | |
| 291 | (CFG_BANK5_ENABLE << 5) | |
| 292 | (CFG_BANK6_ENABLE << 6) | |
| 293 | (CFG_BANK7_ENABLE << 7)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 294 | |
| 295 | #ifdef CFG_PGMAX |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 296 | CONFIG_WRITE_BYTE(MPMR, CFG_PGMAX); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 297 | #endif |
| 298 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 299 | /* ! Wait 200us before initialize other registers */ |
| 300 | /*FIXME: write a decent udelay wait */ |
| 301 | __asm__ __volatile__( |
| 302 | " mtctr %0 \n \ |
| 303 | 0: bdnz 0b\n" |
| 304 | : |
| 305 | : "r" (0x10000)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 306 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 307 | CONFIG_READ_WORD(MCCR1, val); |
| 308 | CONFIG_WRITE_WORD(MCCR1, val | MCCR1_MEMGO); /* set memory access going */ |
| 309 | __asm__ __volatile__("eieio"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 310 | |
| 311 | #endif /* !CONFIG_MOUSSE && !CONFIG_BMW */ |
| 312 | } |
| 313 | |
| 314 | |
| 315 | #ifdef CONFIG_MOUSSE |
| 316 | #ifdef INCLUDE_MPC107_REPORT |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 317 | struct MPC107_s { |
| 318 | unsigned int iobase; |
| 319 | char desc[120]; |
| 320 | } MPC107Regs[] = { |
| 321 | { BMC_BASE + 0x00, "MPC107 Vendor/Device ID" }, |
| 322 | { BMC_BASE + 0x04, "MPC107 PCI Command/Status Register" }, |
| 323 | { BMC_BASE + 0x08, "MPC107 Revision" }, |
| 324 | { BMC_BASE + 0x0C, "MPC107 Cache Line Size" }, |
| 325 | { BMC_BASE + 0x10, "MPC107 LMBAR" }, |
| 326 | { BMC_BASE + 0x14, "MPC824x PCSR" }, |
| 327 | { BMC_BASE + 0xA8, "MPC824x PICR1" }, |
| 328 | { BMC_BASE + 0xAC, "MPC824x PICR2" }, |
| 329 | { BMC_BASE + 0x46, "MPC824x PACR" }, |
| 330 | { BMC_BASE + 0x310, "MPC824x ITWR" }, |
| 331 | { BMC_BASE + 0x300, "MPC824x OMBAR" }, |
| 332 | { BMC_BASE + 0x308, "MPC824x OTWR" }, |
| 333 | { BMC_BASE + 0x14, "MPC107 Peripheral Control and Status Register" }, |
| 334 | { BMC_BASE + 0x78, "MPC107 EUMBAR" }, |
| 335 | { BMC_BASE + 0xC0, "MPC107 Processor Bus Error Status" }, |
| 336 | { BMC_BASE + 0xC4, "MPC107 PCI Bus Error Status" }, |
| 337 | { BMC_BASE + 0xC8, "MPC107 Processor/PCI Error Address" }, |
| 338 | { BMC_BASE + 0xE0, "MPC107 AMBOR Register" }, |
| 339 | { BMC_BASE + 0xF0, "MPC107 MCCR1 Register" }, |
| 340 | { BMC_BASE + 0xF4, "MPC107 MCCR2 Register" }, |
| 341 | { BMC_BASE + 0xF8, "MPC107 MCCR3 Register" }, |
| 342 | { BMC_BASE + 0xFC, "MPC107 MCCR4 Register" }, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 343 | }; |
| 344 | #define N_MPC107_Regs (sizeof(MPC107Regs)/sizeof(MPC107Regs[0])) |
| 345 | #endif /* INCLUDE_MPC107_REPORT */ |
| 346 | #endif /* CONFIG_MOUSSE */ |
| 347 | |
| 348 | /* |
| 349 | * initialize higher level parts of CPU like time base and timers |
| 350 | */ |
| 351 | int cpu_init_r (void) |
| 352 | { |
| 353 | #ifdef CONFIG_MOUSSE |
| 354 | #ifdef INCLUDE_MPC107_REPORT |
| 355 | unsigned int tmp = 0, i; |
| 356 | #endif |
| 357 | /* |
| 358 | * Initialize the EUMBBAR (Embedded Util Mem Block Base Addr Reg). |
| 359 | * This is necessary before the EPIC, DMA ctlr, I2C ctlr, etc. can |
| 360 | * be accessed. |
| 361 | */ |
| 362 | |
| 363 | #ifdef CONFIG_MPC8240 /* only on MPC8240 */ |
| 364 | mpc824x_mpc107_setreg (EUMBBAR, EUMBBAR_VAL); |
| 365 | /* MOT/SPS: Issue #10002, PCI (FD Alias enable) */ |
| 366 | mpc824x_mpc107_setreg (AMBOR, 0x000000C0); |
| 367 | #endif |
| 368 | |
| 369 | |
| 370 | #ifdef INCLUDE_MPC107_REPORT |
| 371 | /* Check MPC824x PCI Device and Vendor ID */ |
| 372 | while ((tmp = mpc824x_mpc107_getreg (BMC_BASE)) != 0x31057) { |
| 373 | printf (" MPC107: offset=0x%x, val = 0x%x\n", |
| 374 | BMC_BASE, |
| 375 | tmp); |
| 376 | } |
| 377 | |
| 378 | for (i = 0; i < N_MPC107_Regs; i++) { |
| 379 | printf (" 0x%x/%s = 0x%x\n", |
| 380 | MPC107Regs[i].iobase, |
| 381 | MPC107Regs[i].desc, |
| 382 | mpc824x_mpc107_getreg (MPC107Regs[i].iobase)); |
| 383 | } |
| 384 | |
| 385 | printf ("IBAT0L = 0x%08X\n", mfspr (IBAT0L)); |
| 386 | printf ("IBAT0U = 0x%08X\n", mfspr (IBAT0U)); |
| 387 | printf ("IBAT1L = 0x%08X\n", mfspr (IBAT1L)); |
| 388 | printf ("IBAT1U = 0x%08X\n", mfspr (IBAT1U)); |
| 389 | printf ("IBAT2L = 0x%08X\n", mfspr (IBAT2L)); |
| 390 | printf ("IBAT2U = 0x%08X\n", mfspr (IBAT2U)); |
| 391 | printf ("IBAT3L = 0x%08X\n", mfspr (IBAT3L)); |
| 392 | printf ("IBAT3U = 0x%08X\n", mfspr (IBAT3U)); |
| 393 | printf ("DBAT0L = 0x%08X\n", mfspr (DBAT0L)); |
| 394 | printf ("DBAT0U = 0x%08X\n", mfspr (DBAT0U)); |
| 395 | printf ("DBAT1L = 0x%08X\n", mfspr (DBAT1L)); |
| 396 | printf ("DBAT1U = 0x%08X\n", mfspr (DBAT1U)); |
| 397 | printf ("DBAT2L = 0x%08X\n", mfspr (DBAT2L)); |
| 398 | printf ("DBAT2U = 0x%08X\n", mfspr (DBAT2U)); |
| 399 | printf ("DBAT3L = 0x%08X\n", mfspr (DBAT3L)); |
| 400 | printf ("DBAT3U = 0x%08X\n", mfspr (DBAT3U)); |
| 401 | #endif /* INCLUDE_MPC107_REPORT */ |
| 402 | #endif /* CONFIG_MOUSSE */ |
| 403 | return (0); |
| 404 | } |