wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 1 | /* |
Stefan Roese | a4c8d13 | 2006-06-02 16:18:04 +0200 | [diff] [blame] | 2 | * (C) Copyright 2000-2006 |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 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 <watchdog.h> |
Stefan Roese | d6c61aa | 2005-08-16 18:18:00 +0200 | [diff] [blame] | 26 | #include <ppc4xx_enet.h> |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 27 | #include <asm/processor.h> |
| 28 | #include <ppc4xx.h> |
| 29 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 30 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) |
| 31 | DECLARE_GLOBAL_DATA_PTR; |
| 32 | #endif |
| 33 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 34 | #ifdef CFG_INIT_DCACHE_CS |
| 35 | # if (CFG_INIT_DCACHE_CS == 0) |
| 36 | # define PBxAP pb0ap |
| 37 | # define PBxCR pb0cr |
| 38 | # if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR)) |
| 39 | # define PBxAP_VAL CFG_EBC_PB0AP |
| 40 | # define PBxCR_VAL CFG_EBC_PB0CR |
| 41 | # endif |
| 42 | # endif |
| 43 | # if (CFG_INIT_DCACHE_CS == 1) |
| 44 | # define PBxAP pb1ap |
| 45 | # define PBxCR pb1cr |
| 46 | # if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR)) |
| 47 | # define PBxAP_VAL CFG_EBC_PB1AP |
| 48 | # define PBxCR_VAL CFG_EBC_PB1CR |
| 49 | # endif |
| 50 | # endif |
| 51 | # if (CFG_INIT_DCACHE_CS == 2) |
| 52 | # define PBxAP pb2ap |
| 53 | # define PBxCR pb2cr |
| 54 | # if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR)) |
| 55 | # define PBxAP_VAL CFG_EBC_PB2AP |
| 56 | # define PBxCR_VAL CFG_EBC_PB2CR |
| 57 | # endif |
| 58 | # endif |
| 59 | # if (CFG_INIT_DCACHE_CS == 3) |
| 60 | # define PBxAP pb3ap |
| 61 | # define PBxCR pb3cr |
| 62 | # if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR)) |
| 63 | # define PBxAP_VAL CFG_EBC_PB3AP |
| 64 | # define PBxCR_VAL CFG_EBC_PB3CR |
| 65 | # endif |
| 66 | # endif |
| 67 | # if (CFG_INIT_DCACHE_CS == 4) |
| 68 | # define PBxAP pb4ap |
| 69 | # define PBxCR pb4cr |
| 70 | # if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR)) |
| 71 | # define PBxAP_VAL CFG_EBC_PB4AP |
| 72 | # define PBxCR_VAL CFG_EBC_PB4CR |
| 73 | # endif |
| 74 | # endif |
| 75 | # if (CFG_INIT_DCACHE_CS == 5) |
| 76 | # define PBxAP pb5ap |
| 77 | # define PBxCR pb5cr |
| 78 | # if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR)) |
| 79 | # define PBxAP_VAL CFG_EBC_PB5AP |
| 80 | # define PBxCR_VAL CFG_EBC_PB5CR |
| 81 | # endif |
| 82 | # endif |
| 83 | # if (CFG_INIT_DCACHE_CS == 6) |
| 84 | # define PBxAP pb6ap |
| 85 | # define PBxCR pb6cr |
| 86 | # if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR)) |
| 87 | # define PBxAP_VAL CFG_EBC_PB6AP |
| 88 | # define PBxCR_VAL CFG_EBC_PB6CR |
| 89 | # endif |
| 90 | # endif |
| 91 | # if (CFG_INIT_DCACHE_CS == 7) |
| 92 | # define PBxAP pb7ap |
| 93 | # define PBxCR pb7cr |
| 94 | # if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR)) |
| 95 | # define PBxAP_VAL CFG_EBC_PB7AP |
| 96 | # define PBxCR_VAL CFG_EBC_PB7CR |
| 97 | # endif |
| 98 | # endif |
| 99 | #endif /* CFG_INIT_DCACHE_CS */ |
| 100 | |
Stefan Roese | a4c8d13 | 2006-06-02 16:18:04 +0200 | [diff] [blame] | 101 | #if defined(CFG_440_GPIO_TABLE) |
| 102 | gpio_param_s gpio_tab[GPIO_GROUP_MAX][GPIO_MAX] = CFG_440_GPIO_TABLE; |
| 103 | |
| 104 | void set_chip_gpio_configuration(gpio_param_s (*gpio_tab)[GPIO_GROUP_MAX][GPIO_MAX]) |
| 105 | { |
| 106 | unsigned char i=0, j=0, reg_offset = 0, gpio_core; |
| 107 | unsigned long gpio_reg, gpio_core_add; |
| 108 | |
| 109 | for (gpio_core=0; gpio_core<GPIO_GROUP_MAX; gpio_core++) { |
| 110 | j = 0; |
| 111 | reg_offset = 0; |
| 112 | /* GPIO config of the GPIOs 0 to 31 */ |
| 113 | for (i=0; i<GPIO_MAX; i++, j++) { |
| 114 | if (i == GPIO_MAX/2) { |
| 115 | reg_offset = 4; |
| 116 | j = i-16; |
| 117 | } |
| 118 | |
| 119 | gpio_core_add = (*gpio_tab)[gpio_core][i].add; |
| 120 | |
| 121 | if (((*gpio_tab)[gpio_core][i].in_out == GPIO_IN) || |
| 122 | ((*gpio_tab)[gpio_core][i].in_out == GPIO_BI)) { |
| 123 | |
| 124 | switch ((*gpio_tab)[gpio_core][i].alt_nb) { |
| 125 | case GPIO_SEL: |
| 126 | break; |
| 127 | |
| 128 | case GPIO_ALT1: |
| 129 | gpio_reg = in32(GPIO_IS1(gpio_core_add+reg_offset)) |
| 130 | & ~(GPIO_MASK >> (j*2)); |
| 131 | gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2)); |
| 132 | out32(GPIO_IS1(gpio_core_add+reg_offset), gpio_reg); |
| 133 | break; |
| 134 | |
| 135 | case GPIO_ALT2: |
| 136 | gpio_reg = in32(GPIO_IS2(gpio_core_add+reg_offset)) |
| 137 | & ~(GPIO_MASK >> (j*2)); |
| 138 | gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2)); |
| 139 | out32(GPIO_IS2(gpio_core_add+reg_offset), gpio_reg); |
| 140 | break; |
| 141 | |
| 142 | case GPIO_ALT3: |
| 143 | gpio_reg = in32(GPIO_IS3(gpio_core_add+reg_offset)) |
| 144 | & ~(GPIO_MASK >> (j*2)); |
| 145 | gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2)); |
| 146 | out32(GPIO_IS3(gpio_core_add+reg_offset), gpio_reg); |
| 147 | break; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | if (((*gpio_tab)[gpio_core][i].in_out == GPIO_OUT) || |
| 152 | ((*gpio_tab)[gpio_core][i].in_out == GPIO_BI)) { |
| 153 | |
| 154 | switch ((*gpio_tab)[gpio_core][i].alt_nb) { |
| 155 | case GPIO_SEL: |
| 156 | if (gpio_core == GPIO0) { |
| 157 | gpio_reg = in32(GPIO0_TCR) | (0x80000000 >> (j)); |
| 158 | out32(GPIO0_TCR, gpio_reg); |
| 159 | } |
| 160 | |
| 161 | if (gpio_core == GPIO1) { |
| 162 | gpio_reg = in32(GPIO1_TCR) | (0x80000000 >> (j)); |
| 163 | out32(GPIO1_TCR, gpio_reg); |
| 164 | } |
| 165 | |
| 166 | gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) |
| 167 | & ~(GPIO_MASK >> (j*2)); |
| 168 | out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg); |
| 169 | gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) |
| 170 | & ~(GPIO_MASK >> (j*2)); |
| 171 | out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg); |
| 172 | break; |
| 173 | |
| 174 | case GPIO_ALT1: |
| 175 | gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) |
| 176 | & ~(GPIO_MASK >> (j*2)); |
| 177 | gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2)); |
| 178 | out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg); |
| 179 | gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) |
| 180 | & ~(GPIO_MASK >> (j*2)); |
| 181 | gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2)); |
| 182 | out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg); |
| 183 | break; |
| 184 | |
| 185 | case GPIO_ALT2: |
| 186 | gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) |
| 187 | & ~(GPIO_MASK >> (j*2)); |
| 188 | gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2)); |
| 189 | out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg); |
| 190 | gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) |
| 191 | & ~(GPIO_MASK >> (j*2)); |
| 192 | gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2)); |
| 193 | out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg); |
| 194 | break; |
| 195 | |
| 196 | case GPIO_ALT3: |
| 197 | gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) |
| 198 | & ~(GPIO_MASK >> (j*2)); |
| 199 | gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2)); |
| 200 | out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg); |
| 201 | gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) |
| 202 | & ~(GPIO_MASK >> (j*2)); |
| 203 | gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2)); |
| 204 | out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg); |
| 205 | break; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | #endif /* CFG_440_GPIO_TABLE */ |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 212 | |
| 213 | /* |
| 214 | * Breath some life into the CPU... |
| 215 | * |
| 216 | * Set up the memory map, |
| 217 | * initialize a bunch of registers |
| 218 | */ |
| 219 | void |
| 220 | cpu_init_f (void) |
| 221 | { |
Wolfgang Denk | f11033e | 2007-01-15 13:41:04 +0100 | [diff] [blame] | 222 | #if defined(CONFIG_WATCHDOG) |
| 223 | unsigned long val; |
| 224 | #endif |
| 225 | |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 226 | #if defined(CONFIG_405EP) |
| 227 | /* |
| 228 | * GPIO0 setup (select GPIO or alternate function) |
| 229 | */ |
Stefan Roese | e0a4655 | 2006-10-12 19:43:29 +0200 | [diff] [blame] | 230 | #if defined(CFG_GPIO0_OR) |
| 231 | out32(GPIO0_OR, CFG_GPIO0_OR); /* set initial state of output pins */ |
| 232 | #endif |
| 233 | #if defined(CFG_GPIO0_ODR) |
| 234 | out32(GPIO0_ODR, CFG_GPIO0_ODR); /* open-drain select */ |
| 235 | #endif |
| 236 | out32(GPIO0_OSRH, CFG_GPIO0_OSRH); /* output select */ |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 237 | out32(GPIO0_OSRL, CFG_GPIO0_OSRL); |
Stefan Roese | e0a4655 | 2006-10-12 19:43:29 +0200 | [diff] [blame] | 238 | out32(GPIO0_ISR1H, CFG_GPIO0_ISR1H); /* input select */ |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 239 | out32(GPIO0_ISR1L, CFG_GPIO0_ISR1L); |
Stefan Roese | e0a4655 | 2006-10-12 19:43:29 +0200 | [diff] [blame] | 240 | out32(GPIO0_TSRH, CFG_GPIO0_TSRH); /* three-state select */ |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 241 | out32(GPIO0_TSRL, CFG_GPIO0_TSRL); |
Stefan Roese | e0a4655 | 2006-10-12 19:43:29 +0200 | [diff] [blame] | 242 | out32(GPIO0_TCR, CFG_GPIO0_TCR); /* enable output driver for outputs */ |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 243 | |
| 244 | /* |
| 245 | * Set EMAC noise filter bits |
| 246 | */ |
| 247 | mtdcr(cpc0_epctl, CPC0_EPRCSR_E0NFE | CPC0_EPRCSR_E1NFE); |
| 248 | #endif /* CONFIG_405EP */ |
| 249 | |
Stefan Roese | a4c8d13 | 2006-06-02 16:18:04 +0200 | [diff] [blame] | 250 | #if defined(CFG_440_GPIO_TABLE) |
| 251 | set_chip_gpio_configuration(&gpio_tab); |
| 252 | #endif /* CFG_440_GPIO_TABLE */ |
| 253 | |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 254 | /* |
| 255 | * External Bus Controller (EBC) Setup |
| 256 | */ |
| 257 | #if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR)) |
Stefan Roese | a4c8d13 | 2006-06-02 16:18:04 +0200 | [diff] [blame] | 258 | #if (defined(CONFIG_405GP) || defined(CONFIG_405CR) || \ |
| 259 | defined(CONFIG_405EP) || defined(CONFIG_405)) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 260 | /* |
| 261 | * Move the next instructions into icache, since these modify the flash |
| 262 | * we are running from! |
| 263 | */ |
| 264 | asm volatile(" bl 0f" ::: "lr"); |
| 265 | asm volatile("0: mflr 3" ::: "r3"); |
| 266 | asm volatile(" addi 4, 0, 14" ::: "r4"); |
| 267 | asm volatile(" mtctr 4" ::: "ctr"); |
| 268 | asm volatile("1: icbt 0, 3"); |
| 269 | asm volatile(" addi 3, 3, 32" ::: "r3"); |
| 270 | asm volatile(" bdnz 1b" ::: "ctr", "cr0"); |
| 271 | asm volatile(" addis 3, 0, 0x0" ::: "r3"); |
| 272 | asm volatile(" ori 3, 3, 0xA000" ::: "r3"); |
| 273 | asm volatile(" mtctr 3" ::: "ctr"); |
| 274 | asm volatile("2: bdnz 2b" ::: "ctr", "cr0"); |
Stefan Roese | a4c8d13 | 2006-06-02 16:18:04 +0200 | [diff] [blame] | 275 | #endif |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 276 | |
| 277 | mtebc(pb0ap, CFG_EBC_PB0AP); |
| 278 | mtebc(pb0cr, CFG_EBC_PB0CR); |
| 279 | #endif |
| 280 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 281 | #if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR) && !(CFG_INIT_DCACHE_CS == 1)) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 282 | mtebc(pb1ap, CFG_EBC_PB1AP); |
| 283 | mtebc(pb1cr, CFG_EBC_PB1CR); |
| 284 | #endif |
| 285 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 286 | #if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR) && !(CFG_INIT_DCACHE_CS == 2)) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 287 | mtebc(pb2ap, CFG_EBC_PB2AP); |
| 288 | mtebc(pb2cr, CFG_EBC_PB2CR); |
| 289 | #endif |
| 290 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 291 | #if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR) && !(CFG_INIT_DCACHE_CS == 3)) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 292 | mtebc(pb3ap, CFG_EBC_PB3AP); |
| 293 | mtebc(pb3cr, CFG_EBC_PB3CR); |
| 294 | #endif |
| 295 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 296 | #if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR) && !(CFG_INIT_DCACHE_CS == 4)) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 297 | mtebc(pb4ap, CFG_EBC_PB4AP); |
| 298 | mtebc(pb4cr, CFG_EBC_PB4CR); |
| 299 | #endif |
| 300 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 301 | #if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR) && !(CFG_INIT_DCACHE_CS == 5)) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 302 | mtebc(pb5ap, CFG_EBC_PB5AP); |
| 303 | mtebc(pb5cr, CFG_EBC_PB5CR); |
| 304 | #endif |
| 305 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 306 | #if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR) && !(CFG_INIT_DCACHE_CS == 6)) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 307 | mtebc(pb6ap, CFG_EBC_PB6AP); |
| 308 | mtebc(pb6cr, CFG_EBC_PB6CR); |
| 309 | #endif |
| 310 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 311 | #if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR) && !(CFG_INIT_DCACHE_CS == 7)) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 312 | mtebc(pb7ap, CFG_EBC_PB7AP); |
| 313 | mtebc(pb7cr, CFG_EBC_PB7CR); |
| 314 | #endif |
| 315 | |
Heiko Schocher | ca43ba1 | 2007-01-11 15:44:44 +0100 | [diff] [blame] | 316 | #if defined (CONFIG_SOLIDCARD3) |
Wolfgang Denk | f11033e | 2007-01-15 13:41:04 +0100 | [diff] [blame] | 317 | mtebc(epcr, 0xb84ef000); |
| 318 | *(unsigned long *)0x79000080 = 0x0001; |
Heiko Schocher | ca43ba1 | 2007-01-11 15:44:44 +0100 | [diff] [blame] | 319 | #endif |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 320 | |
Wolfgang Denk | f11033e | 2007-01-15 13:41:04 +0100 | [diff] [blame] | 321 | #if defined(CONFIG_WATCHDOG) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 322 | val = mfspr(tcr); |
Stefan Roese | 846b0dd | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 323 | #if defined(CONFIG_440EP) || defined(CONFIG_440GR) |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 324 | val |= 0xb8000000; /* generate system reset after 1.34 seconds */ |
| 325 | #else |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 326 | val |= 0xf0000000; /* generate system reset after 2.684 seconds */ |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 327 | #endif |
Stefan Roese | 1c2ce22 | 2006-11-27 14:12:17 +0100 | [diff] [blame] | 328 | #if defined(CFG_4xx_RESET_TYPE) |
| 329 | val &= ~0x30000000; /* clear WRC bits */ |
| 330 | val |= CFG_4xx_RESET_TYPE << 28; /* set board specific WRC type */ |
| 331 | #endif |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 332 | mtspr(tcr, val); |
| 333 | |
| 334 | val = mfspr(tsr); |
| 335 | val |= 0x80000000; /* enable watchdog timer */ |
| 336 | mtspr(tsr, val); |
| 337 | |
| 338 | reset_4xx_watchdog(); |
| 339 | #endif /* CONFIG_WATCHDOG */ |
| 340 | } |
| 341 | |
| 342 | /* |
| 343 | * initialize higher level parts of CPU like time base and timers |
| 344 | */ |
| 345 | int cpu_init_r (void) |
| 346 | { |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 347 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 348 | bd_t *bd = gd->bd; |
| 349 | unsigned long reg; |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 350 | #if defined(CONFIG_405GP) |
stroese | 38daa27 | 2003-03-20 15:21:50 +0000 | [diff] [blame] | 351 | uint pvr = get_pvr(); |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 352 | #endif |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 353 | |
stroese | 3720878 | 2003-06-05 15:35:20 +0000 | [diff] [blame] | 354 | #ifdef CFG_INIT_DCACHE_CS |
| 355 | /* |
| 356 | * Flush and invalidate dcache, then disable CS for temporary stack. |
| 357 | * Afterwards, this CS can be used for other purposes |
| 358 | */ |
| 359 | dcache_disable(); /* flush and invalidate dcache */ |
| 360 | mtebc(PBxAP, 0); |
| 361 | mtebc(PBxCR, 0); /* disable CS for temporary stack */ |
| 362 | |
| 363 | #if (defined(PBxAP_VAL) && defined(PBxCR_VAL)) |
| 364 | /* |
| 365 | * Write new value into CS register |
| 366 | */ |
| 367 | mtebc(PBxAP, PBxAP_VAL); |
| 368 | mtebc(PBxCR, PBxCR_VAL); |
| 369 | #endif |
| 370 | #endif /* CFG_INIT_DCACHE_CS */ |
| 371 | |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 372 | /* |
| 373 | * Write Ethernetaddress into on-chip register |
| 374 | */ |
| 375 | reg = 0x00000000; |
| 376 | reg |= bd->bi_enetaddr[0]; /* set high address */ |
| 377 | reg = reg << 8; |
| 378 | reg |= bd->bi_enetaddr[1]; |
| 379 | out32 (EMAC_IAH, reg); |
| 380 | |
| 381 | reg = 0x00000000; |
| 382 | reg |= bd->bi_enetaddr[2]; /* set low address */ |
| 383 | reg = reg << 8; |
| 384 | reg |= bd->bi_enetaddr[3]; |
| 385 | reg = reg << 8; |
| 386 | reg |= bd->bi_enetaddr[4]; |
| 387 | reg = reg << 8; |
| 388 | reg |= bd->bi_enetaddr[5]; |
| 389 | out32 (EMAC_IAL, reg); |
stroese | 38daa27 | 2003-03-20 15:21:50 +0000 | [diff] [blame] | 390 | |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 391 | #if defined(CONFIG_405GP) |
stroese | 38daa27 | 2003-03-20 15:21:50 +0000 | [diff] [blame] | 392 | /* |
| 393 | * Set edge conditioning circuitry on PPC405GPr |
| 394 | * for compatibility to existing PPC405GP designs. |
| 395 | */ |
stroese | baa3d52 | 2003-04-04 16:00:33 +0000 | [diff] [blame] | 396 | if ((pvr & 0xfffffff0) == (PVR_405GPR_RB & 0xfffffff0)) { |
stroese | 38daa27 | 2003-03-20 15:21:50 +0000 | [diff] [blame] | 397 | mtdcr(ecr, 0x60606000); |
| 398 | } |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 399 | #endif /* defined(CONFIG_405GP) */ |
| 400 | #endif /* defined(CONFIG_405GP) || defined(CONFIG_405EP) */ |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 401 | return (0); |
| 402 | } |