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 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 28 | #ifndef CONFIG_SYS_BANK0_ROW |
| 29 | #define CONFIG_SYS_BANK0_ROW 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 30 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 31 | #ifndef CONFIG_SYS_BANK1_ROW |
| 32 | #define CONFIG_SYS_BANK1_ROW 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 33 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 34 | #ifndef CONFIG_SYS_BANK2_ROW |
| 35 | #define CONFIG_SYS_BANK2_ROW 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 36 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 37 | #ifndef CONFIG_SYS_BANK3_ROW |
| 38 | #define CONFIG_SYS_BANK3_ROW 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 39 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | #ifndef CONFIG_SYS_BANK4_ROW |
| 41 | #define CONFIG_SYS_BANK4_ROW 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 42 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 43 | #ifndef CONFIG_SYS_BANK5_ROW |
| 44 | #define CONFIG_SYS_BANK5_ROW 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 45 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | #ifndef CONFIG_SYS_BANK6_ROW |
| 47 | #define CONFIG_SYS_BANK6_ROW 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 48 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 49 | #ifndef CONFIG_SYS_BANK7_ROW |
| 50 | #define CONFIG_SYS_BANK7_ROW 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 51 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | #ifndef CONFIG_SYS_DBUS_SIZE2 |
| 53 | #define CONFIG_SYS_DBUS_SIZE2 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 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 */ |
Stefan Roese | ed06204 | 2012-09-19 03:18:53 +0000 | [diff] [blame] | 66 | #if !defined(CONFIG_MOUSSE) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 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 | 310b4fc | 2005-01-09 18:12:51 +0000 | [diff] [blame] | 93 | CONFIG_WRITE_BYTE (PLTR, 0x40); /* set PCI latency timer */ |
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 | bc3202a | 2005-04-03 23:11:38 +0000 | [diff] [blame] | 109 | #if 0 |
| 110 | /* |
| 111 | * The following bug only affects older (XPC8245) processors. |
| 112 | * DMA transfers initiated by external devices get corrupted due |
| 113 | * to a hardware scheduling problem. |
| 114 | * |
| 115 | * The effect is: |
| 116 | * when transferring X words, the first 32 words are transferred |
| 117 | * OK, the next 3 x 32 words are 'old' data (from previous DMA) |
| 118 | * while the rest of the X words is xferred fine. |
| 119 | * |
| 120 | * Disabling 3 of the 4 32 word hardware buffers solves the problem |
| 121 | * with no significant performance loss. |
| 122 | */ |
| 123 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 124 | CONFIG_READ_BYTE(PCMBCR,val); |
| 125 | /* 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] | 126 | * 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] | 127 | * 4.11 in the processor user manual |
| 128 | * */ |
| 129 | |
| 130 | #if 1 |
| 131 | CONFIG_WRITE_BYTE(PCMBCR,(val|0xC0)); /* 1 PCMRB */ |
| 132 | #else |
| 133 | CONFIG_WRITE_BYTE(PCMBCR,(val|0x80)); /* 2 PCMRBs */ |
| 134 | CONFIG_WRITE_BYTE(PCMBCR,(val|0x40)); /* 3 PCMRBs */ |
wdenk | bc3202a | 2005-04-03 23:11:38 +0000 | [diff] [blame] | 135 | /* default, 4 PCMRBs are used */ |
| 136 | #endif |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 137 | #endif |
| 138 | #endif |
| 139 | |
| 140 | CONFIG_READ_WORD(PICR1, val); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 141 | #if defined(CONFIG_MPC8240) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 142 | CONFIG_WRITE_WORD( PICR1, |
| 143 | (val & (PICR1_ADDRESS_MAP | PICR1_RCS0)) | |
| 144 | PIRC1_MSK | PICR1_PROC_TYPE_603E | |
| 145 | PICR1_FLASH_WR_EN | PICR1_MCP_EN | |
| 146 | PICR1_CF_DPARK | PICR1_EN_PCS | |
| 147 | PICR1_CF_APARK ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 148 | #elif defined(CONFIG_MPC8245) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 149 | CONFIG_WRITE_WORD( PICR1, |
| 150 | (val & (PICR1_RCS0)) | |
| 151 | PICR1_PROC_TYPE_603E | |
| 152 | PICR1_FLASH_WR_EN | PICR1_MCP_EN | |
| 153 | PICR1_CF_DPARK | PICR1_NO_BUSW_CK | |
| 154 | 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] | 155 | #else |
| 156 | #error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240) |
| 157 | #endif |
| 158 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 159 | CONFIG_READ_WORD(PICR2, val); |
| 160 | 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] | 161 | #ifndef CONFIG_PN62 |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 162 | 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] | 163 | #endif |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 164 | CONFIG_WRITE_WORD(PICR2, val); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 165 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 166 | CONFIG_WRITE_WORD(EUMBBAR, CONFIG_SYS_EUMB_ADDR); |
| 167 | #ifndef CONFIG_SYS_RAMBOOT |
| 168 | CONFIG_WRITE_WORD(MCCR1, (CONFIG_SYS_ROMNAL << MCCR1_ROMNAL_SHIFT) | |
| 169 | (CONFIG_SYS_BANK0_ROW) | |
| 170 | (CONFIG_SYS_BANK1_ROW << MCCR1_BANK1ROW_SHIFT) | |
| 171 | (CONFIG_SYS_BANK2_ROW << MCCR1_BANK2ROW_SHIFT) | |
| 172 | (CONFIG_SYS_BANK3_ROW << MCCR1_BANK3ROW_SHIFT) | |
| 173 | (CONFIG_SYS_BANK4_ROW << MCCR1_BANK4ROW_SHIFT) | |
| 174 | (CONFIG_SYS_BANK5_ROW << MCCR1_BANK5ROW_SHIFT) | |
| 175 | (CONFIG_SYS_BANK6_ROW << MCCR1_BANK6ROW_SHIFT) | |
| 176 | (CONFIG_SYS_BANK7_ROW << MCCR1_BANK7ROW_SHIFT) | |
| 177 | (CONFIG_SYS_ROMFAL << MCCR1_ROMFAL_SHIFT)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 178 | #endif |
| 179 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 180 | #if defined(CONFIG_SYS_ASRISE) && defined(CONFIG_SYS_ASFALL) |
| 181 | CONFIG_WRITE_WORD(MCCR2, CONFIG_SYS_REFINT << MCCR2_REFINT_SHIFT | |
| 182 | CONFIG_SYS_ASRISE << MCCR2_ASRISE_SHIFT | |
| 183 | CONFIG_SYS_ASFALL << MCCR2_ASFALL_SHIFT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 184 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 185 | CONFIG_WRITE_WORD(MCCR2, CONFIG_SYS_REFINT << MCCR2_REFINT_SHIFT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 186 | #endif |
| 187 | |
| 188 | #if defined(CONFIG_MPC8240) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 189 | CONFIG_WRITE_WORD(MCCR3, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 190 | (((CONFIG_SYS_BSTOPRE & 0x003c) >> 2) << MCCR3_BSTOPRE2TO5_SHIFT) | |
| 191 | (CONFIG_SYS_REFREC << MCCR3_REFREC_SHIFT) | |
| 192 | (CONFIG_SYS_RDLAT << MCCR3_RDLAT_SHIFT)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 193 | #elif defined(CONFIG_MPC8245) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 194 | CONFIG_WRITE_WORD(MCCR3, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 195 | (((CONFIG_SYS_BSTOPRE & 0x003c) >> 2) << MCCR3_BSTOPRE2TO5_SHIFT) | |
| 196 | (CONFIG_SYS_REFREC << MCCR3_REFREC_SHIFT)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 197 | #else |
| 198 | #error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240) |
| 199 | #endif |
| 200 | |
| 201 | /* this is gross. We think these should all be the same, and various boards |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 202 | * should define CONFIG_SYS_ACTORW to 0 if they don't want to set it, or even, if |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 203 | * its not set, we define it to zero in this file |
| 204 | */ |
| 205 | #if defined(CONFIG_CU824) || defined(CONFIG_PN62) |
| 206 | CONFIG_WRITE_WORD(MCCR4, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 207 | (CONFIG_SYS_PRETOACT << MCCR4_PRETOACT_SHIFT) | |
| 208 | (CONFIG_SYS_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 209 | MCCR4_BIT21 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 210 | (CONFIG_SYS_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | |
| 211 | ((CONFIG_SYS_BSTOPRE & 0x0003) <<MCCR4_BSTOPRE0TO1_SHIFT ) | |
| 212 | (((CONFIG_SYS_SDMODE_CAS_LAT <<4) | (CONFIG_SYS_SDMODE_WRAP <<3) | |
| 213 | CONFIG_SYS_SDMODE_BURSTLEN) << MCCR4_SDMODE_SHIFT) | |
| 214 | (CONFIG_SYS_ACTORW << MCCR4_ACTTORW_SHIFT) | |
| 215 | (((CONFIG_SYS_BSTOPRE & 0x03c0) >> 6) << MCCR4_BSTOPRE6TO9_SHIFT)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 216 | #elif defined(CONFIG_MPC8240) |
| 217 | CONFIG_WRITE_WORD(MCCR4, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 218 | (CONFIG_SYS_PRETOACT << MCCR4_PRETOACT_SHIFT) | |
| 219 | (CONFIG_SYS_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 220 | MCCR4_BIT21 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 221 | (CONFIG_SYS_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | |
| 222 | ((CONFIG_SYS_BSTOPRE & 0x0003) <<MCCR4_BSTOPRE0TO1_SHIFT ) | |
| 223 | (((CONFIG_SYS_SDMODE_CAS_LAT <<4) | (CONFIG_SYS_SDMODE_WRAP <<3) | |
| 224 | (CONFIG_SYS_SDMODE_BURSTLEN)) <<MCCR4_SDMODE_SHIFT) | |
| 225 | (((CONFIG_SYS_BSTOPRE & 0x03c0) >> 6) <<MCCR4_BSTOPRE6TO9_SHIFT )); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 226 | #elif defined(CONFIG_MPC8245) |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 227 | CONFIG_READ_WORD(MCCR1, val); |
| 228 | val &= MCCR1_DBUS_SIZE0; /* test for 64-bit mem bus */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 229 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 230 | CONFIG_WRITE_WORD(MCCR4, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 231 | (CONFIG_SYS_PRETOACT << MCCR4_PRETOACT_SHIFT) | |
| 232 | (CONFIG_SYS_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | |
| 233 | (CONFIG_SYS_EXTROM ? MCCR4_EXTROM : 0) | |
| 234 | (CONFIG_SYS_REGDIMM ? MCCR4_REGDIMM : 0) | |
| 235 | (CONFIG_SYS_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | |
| 236 | ((CONFIG_SYS_BSTOPRE & 0x0003) <<MCCR4_BSTOPRE0TO1_SHIFT ) | |
| 237 | (CONFIG_SYS_DBUS_SIZE2 << MCCR4_DBUS_SIZE2_SHIFT) | |
| 238 | (((CONFIG_SYS_SDMODE_CAS_LAT <<4) | (CONFIG_SYS_SDMODE_WRAP <<3) | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 239 | (val ? 2 : 3)) << MCCR4_SDMODE_SHIFT) | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 240 | (CONFIG_SYS_ACTORW << MCCR4_ACTTORW_SHIFT) | |
| 241 | (((CONFIG_SYS_BSTOPRE & 0x03c0) >> 6) <<MCCR4_BSTOPRE6TO9_SHIFT )); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 242 | #else |
| 243 | #error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240) |
| 244 | #endif |
| 245 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 246 | CONFIG_WRITE_WORD(MSAR1, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 247 | ( (CONFIG_SYS_BANK0_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | |
| 248 | (((CONFIG_SYS_BANK1_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | |
| 249 | (((CONFIG_SYS_BANK2_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | |
| 250 | (((CONFIG_SYS_BANK3_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 251 | CONFIG_WRITE_WORD(EMSAR1, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 252 | ( (CONFIG_SYS_BANK0_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | |
| 253 | (((CONFIG_SYS_BANK1_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | |
| 254 | (((CONFIG_SYS_BANK2_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | |
| 255 | (((CONFIG_SYS_BANK3_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 256 | CONFIG_WRITE_WORD(MSAR2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 257 | ( (CONFIG_SYS_BANK4_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | |
| 258 | (((CONFIG_SYS_BANK5_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | |
| 259 | (((CONFIG_SYS_BANK6_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | |
| 260 | (((CONFIG_SYS_BANK7_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 261 | CONFIG_WRITE_WORD(EMSAR2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 262 | ( (CONFIG_SYS_BANK4_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | |
| 263 | (((CONFIG_SYS_BANK5_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | |
| 264 | (((CONFIG_SYS_BANK6_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | |
| 265 | (((CONFIG_SYS_BANK7_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 266 | CONFIG_WRITE_WORD(MEAR1, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 267 | ( (CONFIG_SYS_BANK0_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | |
| 268 | (((CONFIG_SYS_BANK1_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | |
| 269 | (((CONFIG_SYS_BANK2_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | |
| 270 | (((CONFIG_SYS_BANK3_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 271 | CONFIG_WRITE_WORD(EMEAR1, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 272 | ( (CONFIG_SYS_BANK0_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | |
| 273 | (((CONFIG_SYS_BANK1_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | |
| 274 | (((CONFIG_SYS_BANK2_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | |
| 275 | (((CONFIG_SYS_BANK3_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 276 | CONFIG_WRITE_WORD(MEAR2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 277 | ( (CONFIG_SYS_BANK4_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | |
| 278 | (((CONFIG_SYS_BANK5_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | |
| 279 | (((CONFIG_SYS_BANK6_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | |
| 280 | (((CONFIG_SYS_BANK7_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 281 | CONFIG_WRITE_WORD(EMEAR2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 282 | ( (CONFIG_SYS_BANK4_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | |
| 283 | (((CONFIG_SYS_BANK5_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | |
| 284 | (((CONFIG_SYS_BANK6_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | |
| 285 | (((CONFIG_SYS_BANK7_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 286 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 287 | CONFIG_WRITE_BYTE(ODCR, CONFIG_SYS_ODCR); |
| 288 | #ifdef CONFIG_SYS_DLL_MAX_DELAY |
| 289 | CONFIG_WRITE_BYTE(MIOCR1, CONFIG_SYS_DLL_MAX_DELAY); /* needed to make DLL lock */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 290 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 291 | #if defined(CONFIG_SYS_DLL_EXTEND) && defined(CONFIG_SYS_PCI_HOLD_DEL) |
| 292 | CONFIG_WRITE_BYTE(PMCR2, CONFIG_SYS_DLL_EXTEND | CONFIG_SYS_PCI_HOLD_DEL); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 293 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 294 | #if defined(MIOCR2) && defined(CONFIG_SYS_SDRAM_DSCD) |
| 295 | CONFIG_WRITE_BYTE(MIOCR2, CONFIG_SYS_SDRAM_DSCD); /* change memory input */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 296 | #endif /* setup & hold time */ |
| 297 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 298 | CONFIG_WRITE_BYTE(MBER, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 299 | CONFIG_SYS_BANK0_ENABLE | |
| 300 | (CONFIG_SYS_BANK1_ENABLE << 1) | |
| 301 | (CONFIG_SYS_BANK2_ENABLE << 2) | |
| 302 | (CONFIG_SYS_BANK3_ENABLE << 3) | |
| 303 | (CONFIG_SYS_BANK4_ENABLE << 4) | |
| 304 | (CONFIG_SYS_BANK5_ENABLE << 5) | |
| 305 | (CONFIG_SYS_BANK6_ENABLE << 6) | |
| 306 | (CONFIG_SYS_BANK7_ENABLE << 7)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 307 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 308 | #ifdef CONFIG_SYS_PGMAX |
| 309 | CONFIG_WRITE_BYTE(MPMR, CONFIG_SYS_PGMAX); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 310 | #endif |
| 311 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 312 | /* ! Wait 200us before initialize other registers */ |
| 313 | /*FIXME: write a decent udelay wait */ |
| 314 | __asm__ __volatile__( |
| 315 | " mtctr %0 \n \ |
| 316 | 0: bdnz 0b\n" |
| 317 | : |
| 318 | : "r" (0x10000)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 319 | |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 320 | CONFIG_READ_WORD(MCCR1, val); |
| 321 | CONFIG_WRITE_WORD(MCCR1, val | MCCR1_MEMGO); /* set memory access going */ |
| 322 | __asm__ __volatile__("eieio"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 323 | |
Stefan Roese | ed06204 | 2012-09-19 03:18:53 +0000 | [diff] [blame] | 324 | #endif /* !CONFIG_MOUSSE */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | |
| 328 | #ifdef CONFIG_MOUSSE |
| 329 | #ifdef INCLUDE_MPC107_REPORT |
wdenk | f2140d5 | 2004-07-01 16:30:44 +0000 | [diff] [blame] | 330 | struct MPC107_s { |
| 331 | unsigned int iobase; |
| 332 | char desc[120]; |
| 333 | } MPC107Regs[] = { |
| 334 | { BMC_BASE + 0x00, "MPC107 Vendor/Device ID" }, |
| 335 | { BMC_BASE + 0x04, "MPC107 PCI Command/Status Register" }, |
| 336 | { BMC_BASE + 0x08, "MPC107 Revision" }, |
| 337 | { BMC_BASE + 0x0C, "MPC107 Cache Line Size" }, |
| 338 | { BMC_BASE + 0x10, "MPC107 LMBAR" }, |
| 339 | { BMC_BASE + 0x14, "MPC824x PCSR" }, |
| 340 | { BMC_BASE + 0xA8, "MPC824x PICR1" }, |
| 341 | { BMC_BASE + 0xAC, "MPC824x PICR2" }, |
| 342 | { BMC_BASE + 0x46, "MPC824x PACR" }, |
| 343 | { BMC_BASE + 0x310, "MPC824x ITWR" }, |
| 344 | { BMC_BASE + 0x300, "MPC824x OMBAR" }, |
| 345 | { BMC_BASE + 0x308, "MPC824x OTWR" }, |
| 346 | { BMC_BASE + 0x14, "MPC107 Peripheral Control and Status Register" }, |
| 347 | { BMC_BASE + 0x78, "MPC107 EUMBAR" }, |
| 348 | { BMC_BASE + 0xC0, "MPC107 Processor Bus Error Status" }, |
| 349 | { BMC_BASE + 0xC4, "MPC107 PCI Bus Error Status" }, |
| 350 | { BMC_BASE + 0xC8, "MPC107 Processor/PCI Error Address" }, |
| 351 | { BMC_BASE + 0xE0, "MPC107 AMBOR Register" }, |
| 352 | { BMC_BASE + 0xF0, "MPC107 MCCR1 Register" }, |
| 353 | { BMC_BASE + 0xF4, "MPC107 MCCR2 Register" }, |
| 354 | { BMC_BASE + 0xF8, "MPC107 MCCR3 Register" }, |
| 355 | { BMC_BASE + 0xFC, "MPC107 MCCR4 Register" }, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 356 | }; |
| 357 | #define N_MPC107_Regs (sizeof(MPC107Regs)/sizeof(MPC107Regs[0])) |
| 358 | #endif /* INCLUDE_MPC107_REPORT */ |
| 359 | #endif /* CONFIG_MOUSSE */ |
| 360 | |
| 361 | /* |
| 362 | * initialize higher level parts of CPU like time base and timers |
| 363 | */ |
| 364 | int cpu_init_r (void) |
| 365 | { |
| 366 | #ifdef CONFIG_MOUSSE |
| 367 | #ifdef INCLUDE_MPC107_REPORT |
| 368 | unsigned int tmp = 0, i; |
| 369 | #endif |
| 370 | /* |
| 371 | * Initialize the EUMBBAR (Embedded Util Mem Block Base Addr Reg). |
| 372 | * This is necessary before the EPIC, DMA ctlr, I2C ctlr, etc. can |
| 373 | * be accessed. |
| 374 | */ |
| 375 | |
| 376 | #ifdef CONFIG_MPC8240 /* only on MPC8240 */ |
| 377 | mpc824x_mpc107_setreg (EUMBBAR, EUMBBAR_VAL); |
| 378 | /* MOT/SPS: Issue #10002, PCI (FD Alias enable) */ |
| 379 | mpc824x_mpc107_setreg (AMBOR, 0x000000C0); |
| 380 | #endif |
| 381 | |
| 382 | |
| 383 | #ifdef INCLUDE_MPC107_REPORT |
| 384 | /* Check MPC824x PCI Device and Vendor ID */ |
| 385 | while ((tmp = mpc824x_mpc107_getreg (BMC_BASE)) != 0x31057) { |
| 386 | printf (" MPC107: offset=0x%x, val = 0x%x\n", |
| 387 | BMC_BASE, |
| 388 | tmp); |
| 389 | } |
| 390 | |
| 391 | for (i = 0; i < N_MPC107_Regs; i++) { |
| 392 | printf (" 0x%x/%s = 0x%x\n", |
| 393 | MPC107Regs[i].iobase, |
| 394 | MPC107Regs[i].desc, |
| 395 | mpc824x_mpc107_getreg (MPC107Regs[i].iobase)); |
| 396 | } |
| 397 | |
| 398 | printf ("IBAT0L = 0x%08X\n", mfspr (IBAT0L)); |
| 399 | printf ("IBAT0U = 0x%08X\n", mfspr (IBAT0U)); |
| 400 | printf ("IBAT1L = 0x%08X\n", mfspr (IBAT1L)); |
| 401 | printf ("IBAT1U = 0x%08X\n", mfspr (IBAT1U)); |
| 402 | printf ("IBAT2L = 0x%08X\n", mfspr (IBAT2L)); |
| 403 | printf ("IBAT2U = 0x%08X\n", mfspr (IBAT2U)); |
| 404 | printf ("IBAT3L = 0x%08X\n", mfspr (IBAT3L)); |
| 405 | printf ("IBAT3U = 0x%08X\n", mfspr (IBAT3U)); |
| 406 | printf ("DBAT0L = 0x%08X\n", mfspr (DBAT0L)); |
| 407 | printf ("DBAT0U = 0x%08X\n", mfspr (DBAT0U)); |
| 408 | printf ("DBAT1L = 0x%08X\n", mfspr (DBAT1L)); |
| 409 | printf ("DBAT1U = 0x%08X\n", mfspr (DBAT1U)); |
| 410 | printf ("DBAT2L = 0x%08X\n", mfspr (DBAT2L)); |
| 411 | printf ("DBAT2U = 0x%08X\n", mfspr (DBAT2U)); |
| 412 | printf ("DBAT3L = 0x%08X\n", mfspr (DBAT3L)); |
| 413 | printf ("DBAT3U = 0x%08X\n", mfspr (DBAT3U)); |
| 414 | #endif /* INCLUDE_MPC107_REPORT */ |
| 415 | #endif /* CONFIG_MOUSSE */ |
| 416 | return (0); |
| 417 | } |