wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Josef Baumgartner <josef.baumgartner@telex.de> |
| 4 | * |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 5 | * MCF5282 additionals |
| 6 | * (C) Copyright 2005 |
| 7 | * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de> |
| 8 | * |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <watchdog.h> |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 30 | #include <asm/immap.h> |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 31 | |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 32 | #if defined(CONFIG_M5271) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 33 | void cpu_init_f(void) |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 34 | { |
| 35 | #ifndef CONFIG_WATCHDOG |
| 36 | /* Disable the watchdog if we aren't using it */ |
| 37 | mbar_writeShort(MCF_WTM_WCR, 0); |
| 38 | #endif |
| 39 | |
| 40 | /* Set clockspeed to 100MHz */ |
| 41 | mbar_writeShort(MCF_FMPLL_SYNCR, |
| 42 | MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0)); |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 43 | while (!mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK) ; |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | /* |
| 47 | * initialize higher level parts of CPU like timers |
| 48 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 49 | int cpu_init_r(void) |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 50 | { |
| 51 | return (0); |
| 52 | } |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 53 | |
| 54 | void uart_port_conf(void) |
| 55 | { |
| 56 | /* Setup Ports: */ |
| 57 | switch (CFG_UART_PORT) { |
| 58 | case 0: |
| 59 | mbar_writeShort(MCF_GPIO_PAR_UART, MCF_GPIO_PAR_UART_U0TXD | |
| 60 | MCF_GPIO_PAR_UART_U0RXD); |
| 61 | break; |
| 62 | case 1: |
| 63 | mbar_writeShort(MCF_GPIO_PAR_UART, |
| 64 | MCF_GPIO_PAR_UART_U1RXD_UART1 | |
| 65 | MCF_GPIO_PAR_UART_U1TXD_UART1); |
| 66 | break; |
| 67 | case 2: |
| 68 | mbar_writeShort(MCF_GPIO_PAR_UART, 0x3000); |
| 69 | break; |
| 70 | } |
| 71 | } |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 72 | #endif |
| 73 | |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 74 | #if defined(CONFIG_M5272) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 75 | /* |
| 76 | * Breath some life into the CPU... |
| 77 | * |
| 78 | * Set up the memory map, |
| 79 | * initialize a bunch of registers, |
| 80 | * initialize the UPM's |
| 81 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 82 | void cpu_init_f(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 83 | { |
| 84 | /* if we come from RAM we assume the CPU is |
| 85 | * already initialized. |
| 86 | */ |
| 87 | #ifndef CONFIG_MONITOR_IS_IN_RAM |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 88 | volatile sysctrl_t *sysctrl = (sysctrl_t *) (CFG_MBAR); |
| 89 | volatile gpio_t *gpio = (gpio_t *) (MMAP_GPIO); |
| 90 | volatile csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 91 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 92 | sysctrl->sc_scr = CFG_SCR; |
| 93 | sysctrl->sc_spr = CFG_SPR; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 94 | |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 95 | /* Setup Ports: */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 96 | gpio->gpio_pacnt = CFG_PACNT; |
| 97 | gpio->gpio_paddr = CFG_PADDR; |
| 98 | gpio->gpio_padat = CFG_PADAT; |
| 99 | gpio->gpio_pbcnt = CFG_PBCNT; |
| 100 | gpio->gpio_pbddr = CFG_PBDDR; |
| 101 | gpio->gpio_pbdat = CFG_PBDAT; |
| 102 | gpio->gpio_pdcnt = CFG_PDCNT; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 103 | |
| 104 | /* Memory Controller: */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 105 | csctrl->cs_br0 = CFG_BR0_PRELIM; |
| 106 | csctrl->cs_or0 = CFG_OR0_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 107 | |
| 108 | #if (defined(CFG_OR1_PRELIM) && defined(CFG_BR1_PRELIM)) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 109 | csctrl->cs_br1 = CFG_BR1_PRELIM; |
| 110 | csctrl->cs_or1 = CFG_OR1_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 111 | #endif |
| 112 | |
| 113 | #if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 114 | csctrl->cs_br2 = CFG_BR2_PRELIM; |
| 115 | csctrl->cs_or2 = CFG_OR2_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 116 | #endif |
| 117 | |
| 118 | #if defined(CFG_OR3_PRELIM) && defined(CFG_BR3_PRELIM) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 119 | csctrl->cs_br3 = CFG_BR3_PRELIM; |
| 120 | csctrl->cs_or3 = CFG_OR3_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 121 | #endif |
| 122 | |
| 123 | #if defined(CFG_OR4_PRELIM) && defined(CFG_BR4_PRELIM) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 124 | csctrl->cs_br4 = CFG_BR4_PRELIM; |
| 125 | csctrl->cs_or4 = CFG_OR4_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 126 | #endif |
| 127 | |
| 128 | #if defined(CFG_OR5_PRELIM) && defined(CFG_BR5_PRELIM) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 129 | csctrl->cs_br5 = CFG_BR5_PRELIM; |
| 130 | csctrl->cs_or5 = CFG_OR5_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 131 | #endif |
| 132 | |
| 133 | #if defined(CFG_OR6_PRELIM) && defined(CFG_BR6_PRELIM) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 134 | csctrl->cs_br6 = CFG_BR6_PRELIM; |
| 135 | csctrl->cs_or6 = CFG_OR6_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 136 | #endif |
| 137 | |
| 138 | #if defined(CFG_OR7_PRELIM) && defined(CFG_BR7_PRELIM) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 139 | csctrl->cs_br7 = CFG_BR7_PRELIM; |
| 140 | csctrl->cs_or7 = CFG_OR7_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 141 | #endif |
| 142 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 143 | #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 144 | |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 145 | /* enable instruction cache now */ |
| 146 | icache_enable(); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 147 | |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | * initialize higher level parts of CPU like timers |
| 152 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 153 | int cpu_init_r(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 154 | { |
| 155 | return (0); |
| 156 | } |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 157 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 158 | void uart_port_conf(void) |
| 159 | { |
| 160 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 161 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 162 | /* Setup Ports: */ |
| 163 | switch (CFG_UART_PORT) { |
| 164 | case 0: |
| 165 | gpio->gpio_pbcnt &= ~(GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK); |
| 166 | gpio->gpio_pbcnt |= (GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD); |
| 167 | break; |
| 168 | case 1: |
| 169 | gpio->gpio_pdcnt &= ~(GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK); |
| 170 | gpio->gpio_pdcnt |= (GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD); |
| 171 | break; |
| 172 | } |
| 173 | } |
| 174 | #endif /* #if defined(CONFIG_M5272) */ |
| 175 | |
| 176 | #if defined(CONFIG_M5282) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 177 | /* |
| 178 | * Breath some life into the CPU... |
| 179 | * |
| 180 | * Set up the memory map, |
| 181 | * initialize a bunch of registers, |
| 182 | * initialize the UPM's |
| 183 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 184 | void cpu_init_f(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 185 | { |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 186 | #ifndef CONFIG_WATCHDOG |
| 187 | /* disable watchdog if we aren't using it */ |
| 188 | MCFWTM_WCR = 0; |
| 189 | #endif |
| 190 | |
| 191 | #ifndef CONFIG_MONITOR_IS_IN_RAM |
| 192 | /* Set speed /PLL */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 193 | MCFCLOCK_SYNCR = |
| 194 | MCFCLOCK_SYNCR_MFD(CFG_MFD) | MCFCLOCK_SYNCR_RFD(CFG_RFD); |
| 195 | while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ; |
| 196 | |
| 197 | MCFGPIO_PBCDPAR = 0xc0; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 198 | |
| 199 | /* Set up the GPIO ports */ |
| 200 | #ifdef CFG_PEPAR |
| 201 | MCFGPIO_PEPAR = CFG_PEPAR; |
| 202 | #endif |
| 203 | #ifdef CFG_PFPAR |
| 204 | MCFGPIO_PFPAR = CFG_PFPAR; |
| 205 | #endif |
| 206 | #ifdef CFG_PJPAR |
| 207 | MCFGPIO_PJPAR = CFG_PJPAR; |
| 208 | #endif |
| 209 | #ifdef CFG_PSDPAR |
| 210 | MCFGPIO_PSDPAR = CFG_PSDPAR; |
| 211 | #endif |
| 212 | #ifdef CFG_PASPAR |
| 213 | MCFGPIO_PASPAR = CFG_PASPAR; |
| 214 | #endif |
| 215 | #ifdef CFG_PEHLPAR |
| 216 | MCFGPIO_PEHLPAR = CFG_PEHLPAR; |
| 217 | #endif |
| 218 | #ifdef CFG_PQSPAR |
| 219 | MCFGPIO_PQSPAR = CFG_PQSPAR; |
| 220 | #endif |
| 221 | #ifdef CFG_PTCPAR |
| 222 | MCFGPIO_PTCPAR = CFG_PTCPAR; |
| 223 | #endif |
| 224 | #ifdef CFG_PTDPAR |
| 225 | MCFGPIO_PTDPAR = CFG_PTDPAR; |
| 226 | #endif |
| 227 | #ifdef CFG_PUAPAR |
| 228 | MCFGPIO_PUAPAR = CFG_PUAPAR; |
| 229 | #endif |
| 230 | |
| 231 | #ifdef CFG_DDRUA |
| 232 | MCFGPIO_DDRUA = CFG_DDRUA; |
| 233 | #endif |
| 234 | |
| 235 | /* This is probably a bad place to setup chip selects, but everyone |
| 236 | else is doing it! */ |
| 237 | |
| 238 | #if defined(CFG_CS0_BASE) & defined(CFG_CS0_SIZE) & \ |
| 239 | defined(CFG_CS0_WIDTH) & defined(CFG_CS0_RO) & \ |
| 240 | defined(CFG_CS0_WS) |
| 241 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 242 | MCFCSM_CSAR0 = (CFG_CS0_BASE >> 16) & 0xFFFF; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 243 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 244 | #if (CFG_CS0_WIDTH == 8) |
| 245 | #define CFG_CS0_PS MCFCSM_CSCR_PS_8 |
| 246 | #elif (CFG_CS0_WIDTH == 16) |
| 247 | #define CFG_CS0_PS MCFCSM_CSCR_PS_16 |
| 248 | #elif (CFG_CS0_WIDTH == 32) |
| 249 | #define CFG_CS0_PS MCFCSM_CSCR_PS_32 |
| 250 | #else |
| 251 | #error "CFG_CS0_WIDTH: Fault - wrong bus with for CS0" |
| 252 | #endif |
| 253 | MCFCSM_CSCR0 = MCFCSM_CSCR_WS(CFG_CS0_WS) |
| 254 | | CFG_CS0_PS | MCFCSM_CSCR_AA; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 255 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 256 | #if (CFG_CS0_RO != 0) |
| 257 | MCFCSM_CSMR0 = MCFCSM_CSMR_BAM(CFG_CS0_SIZE - 1) |
| 258 | | MCFCSM_CSMR_WP | MCFCSM_CSMR_V; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 259 | #else |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 260 | MCFCSM_CSMR0 = MCFCSM_CSMR_BAM(CFG_CS0_SIZE - 1) | MCFCSM_CSMR_V; |
| 261 | #endif |
| 262 | #else |
| 263 | #waring "Chip Select 0 are not initialized/used" |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 264 | #endif |
| 265 | |
| 266 | #if defined(CFG_CS1_BASE) & defined(CFG_CS1_SIZE) & \ |
| 267 | defined(CFG_CS1_WIDTH) & defined(CFG_CS1_RO) & \ |
| 268 | defined(CFG_CS1_WS) |
| 269 | |
| 270 | MCFCSM_CSAR1 = (CFG_CS1_BASE >> 16) & 0xFFFF; |
| 271 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 272 | #if (CFG_CS1_WIDTH == 8) |
| 273 | #define CFG_CS1_PS MCFCSM_CSCR_PS_8 |
| 274 | #elif (CFG_CS1_WIDTH == 16) |
| 275 | #define CFG_CS1_PS MCFCSM_CSCR_PS_16 |
| 276 | #elif (CFG_CS1_WIDTH == 32) |
| 277 | #define CFG_CS1_PS MCFCSM_CSCR_PS_32 |
| 278 | #else |
| 279 | #error "CFG_CS1_WIDTH: Fault - wrong bus with for CS1" |
| 280 | #endif |
| 281 | MCFCSM_CSCR1 = MCFCSM_CSCR_WS(CFG_CS1_WS) |
| 282 | | CFG_CS1_PS | MCFCSM_CSCR_AA; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 283 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 284 | #if (CFG_CS1_RO != 0) |
| 285 | MCFCSM_CSMR1 = MCFCSM_CSMR_BAM(CFG_CS1_SIZE - 1) |
| 286 | | MCFCSM_CSMR_WP | MCFCSM_CSMR_V; |
| 287 | #else |
| 288 | MCFCSM_CSMR1 = MCFCSM_CSMR_BAM(CFG_CS1_SIZE - 1) |
| 289 | | MCFCSM_CSMR_V; |
| 290 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 291 | #else |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 292 | #warning "Chip Select 1 are not initialized/used" |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 293 | #endif |
| 294 | |
| 295 | #if defined(CFG_CS2_BASE) & defined(CFG_CS2_SIZE) & \ |
| 296 | defined(CFG_CS2_WIDTH) & defined(CFG_CS2_RO) & \ |
| 297 | defined(CFG_CS2_WS) |
| 298 | |
| 299 | MCFCSM_CSAR2 = (CFG_CS2_BASE >> 16) & 0xFFFF; |
| 300 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 301 | #if (CFG_CS2_WIDTH == 8) |
| 302 | #define CFG_CS2_PS MCFCSM_CSCR_PS_8 |
| 303 | #elif (CFG_CS2_WIDTH == 16) |
| 304 | #define CFG_CS2_PS MCFCSM_CSCR_PS_16 |
| 305 | #elif (CFG_CS2_WIDTH == 32) |
| 306 | #define CFG_CS2_PS MCFCSM_CSCR_PS_32 |
| 307 | #else |
| 308 | #error "CFG_CS2_WIDTH: Fault - wrong bus with for CS2" |
| 309 | #endif |
| 310 | MCFCSM_CSCR2 = MCFCSM_CSCR_WS(CFG_CS2_WS) |
| 311 | | CFG_CS2_PS | MCFCSM_CSCR_AA; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 312 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 313 | #if (CFG_CS2_RO != 0) |
| 314 | MCFCSM_CSMR2 = MCFCSM_CSMR_BAM(CFG_CS2_SIZE - 1) |
| 315 | | MCFCSM_CSMR_WP | MCFCSM_CSMR_V; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 316 | #else |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 317 | MCFCSM_CSMR2 = MCFCSM_CSMR_BAM(CFG_CS2_SIZE - 1) |
| 318 | | MCFCSM_CSMR_V; |
| 319 | #endif |
| 320 | #else |
| 321 | #warning "Chip Select 2 are not initialized/used" |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 322 | #endif |
| 323 | |
| 324 | #if defined(CFG_CS3_BASE) & defined(CFG_CS3_SIZE) & \ |
| 325 | defined(CFG_CS3_WIDTH) & defined(CFG_CS3_RO) & \ |
| 326 | defined(CFG_CS3_WS) |
| 327 | |
| 328 | MCFCSM_CSAR3 = (CFG_CS3_BASE >> 16) & 0xFFFF; |
| 329 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 330 | #if (CFG_CS3_WIDTH == 8) |
| 331 | #define CFG_CS3_PS MCFCSM_CSCR_PS_8 |
| 332 | #elif (CFG_CS3_WIDTH == 16) |
| 333 | #define CFG_CS3_PS MCFCSM_CSCR_PS_16 |
| 334 | #elif (CFG_CS3_WIDTH == 32) |
| 335 | #define CFG_CS3_PS MCFCSM_CSCR_PS_32 |
| 336 | #else |
| 337 | #error "CFG_CS3_WIDTH: Fault - wrong bus with for CS1" |
| 338 | #endif |
| 339 | MCFCSM_CSCR3 = MCFCSM_CSCR_WS(CFG_CS3_WS) |
| 340 | | CFG_CS3_PS | MCFCSM_CSCR_AA; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 341 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 342 | #if (CFG_CS3_RO != 0) |
| 343 | MCFCSM_CSMR3 = MCFCSM_CSMR_BAM(CFG_CS3_SIZE - 1) |
| 344 | | MCFCSM_CSMR_WP | MCFCSM_CSMR_V; |
| 345 | #else |
| 346 | MCFCSM_CSMR3 = MCFCSM_CSMR_BAM(CFG_CS3_SIZE - 1) |
| 347 | | MCFCSM_CSMR_V; |
| 348 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 349 | #else |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 350 | #warning "Chip Select 3 are not initialized/used" |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 351 | #endif |
| 352 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 353 | #endif /* CONFIG_MONITOR_IS_IN_RAM */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 354 | |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 355 | /* defer enabling cache until boot (see do_go) */ |
| 356 | /* icache_enable(); */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | /* |
| 360 | * initialize higher level parts of CPU like timers |
| 361 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 362 | int cpu_init_r(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 363 | { |
| 364 | return (0); |
| 365 | } |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 366 | |
| 367 | void uart_port_conf(void) |
| 368 | { |
| 369 | /* Setup Ports: */ |
| 370 | switch (CFG_UART_PORT) { |
| 371 | case 0: |
| 372 | MCFGPIO_PUAPAR &= 0xFc; |
| 373 | MCFGPIO_PUAPAR |= 0x03; |
| 374 | break; |
| 375 | case 1: |
| 376 | MCFGPIO_PUAPAR &= 0xF3; |
| 377 | MCFGPIO_PUAPAR |= 0x0C; |
| 378 | break; |
| 379 | case 2: |
| 380 | MCFGPIO_PASPAR &= 0xFF0F; |
| 381 | MCFGPIO_PASPAR |= 0x00A0; |
| 382 | break; |
| 383 | } |
| 384 | } |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 385 | #endif |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 386 | |
| 387 | #if defined(CONFIG_M5249) |
| 388 | /* |
| 389 | * Breath some life into the CPU... |
| 390 | * |
| 391 | * Set up the memory map, |
| 392 | * initialize a bunch of registers, |
| 393 | * initialize the UPM's |
| 394 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 395 | void cpu_init_f(void) |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 396 | { |
| 397 | #ifndef CFG_PLL_BYPASS |
| 398 | /* |
| 399 | * Setup the PLL to run at the specified speed |
| 400 | * |
| 401 | */ |
| 402 | volatile unsigned long cpll = mbar2_readLong(MCFSIM_PLLCR); |
| 403 | unsigned long pllcr; |
| 404 | #ifdef CFG_FAST_CLK |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 405 | pllcr = 0x925a3100; /* ~140MHz clock (PLL bypass = 0) */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 406 | #else |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 407 | pllcr = 0x135a4140; /* ~72MHz clock (PLL bypass = 0) */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 408 | #endif |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 409 | cpll = cpll & 0xfffffffe; /* Set PLL bypass mode = 0 (PSTCLK = crystal) */ |
| 410 | mbar2_writeLong(MCFSIM_PLLCR, cpll); /* Set the PLL to bypass mode (PSTCLK = crystal) */ |
| 411 | mbar2_writeLong(MCFSIM_PLLCR, pllcr); /* set the clock speed */ |
| 412 | pllcr ^= 0x00000001; /* Set pll bypass to 1 */ |
| 413 | mbar2_writeLong(MCFSIM_PLLCR, pllcr); /* Start locking (pll bypass = 1) */ |
| 414 | udelay(0x20); /* Wait for a lock ... */ |
| 415 | #endif /* #ifndef CFG_PLL_BYPASS */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 416 | |
| 417 | /* |
| 418 | * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 419 | * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins |
| 420 | * which is their primary function. |
| 421 | * ~Jeremy |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 422 | */ |
| 423 | mbar2_writeLong(MCFSIM_GPIO_FUNC, CFG_GPIO_FUNC); |
| 424 | mbar2_writeLong(MCFSIM_GPIO1_FUNC, CFG_GPIO1_FUNC); |
| 425 | mbar2_writeLong(MCFSIM_GPIO_EN, CFG_GPIO_EN); |
| 426 | mbar2_writeLong(MCFSIM_GPIO1_EN, CFG_GPIO1_EN); |
| 427 | mbar2_writeLong(MCFSIM_GPIO_OUT, CFG_GPIO_OUT); |
| 428 | mbar2_writeLong(MCFSIM_GPIO1_OUT, CFG_GPIO1_OUT); |
| 429 | |
| 430 | /* |
| 431 | * dBug Compliance: |
| 432 | * You can verify these values by using dBug's 'ird' |
| 433 | * (Internal Register Display) command |
| 434 | * ~Jeremy |
| 435 | * |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 436 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 437 | mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 438 | mbar_writeByte(MCFSIM_SYPCR, 0x00); |
| 439 | mbar_writeByte(MCFSIM_SWIVR, 0x0f); |
| 440 | mbar_writeByte(MCFSIM_SWSR, 0x00); |
| 441 | mbar_writeLong(MCFSIM_IMR, 0xfffffbff); |
| 442 | mbar_writeByte(MCFSIM_SWDICR, 0x00); |
| 443 | mbar_writeByte(MCFSIM_TIMER1ICR, 0x00); |
| 444 | mbar_writeByte(MCFSIM_TIMER2ICR, 0x88); |
| 445 | mbar_writeByte(MCFSIM_I2CICR, 0x00); |
| 446 | mbar_writeByte(MCFSIM_UART1ICR, 0x00); |
| 447 | mbar_writeByte(MCFSIM_UART2ICR, 0x00); |
| 448 | mbar_writeByte(MCFSIM_ICR6, 0x00); |
| 449 | mbar_writeByte(MCFSIM_ICR7, 0x00); |
| 450 | mbar_writeByte(MCFSIM_ICR8, 0x00); |
| 451 | mbar_writeByte(MCFSIM_ICR9, 0x00); |
| 452 | mbar_writeByte(MCFSIM_QSPIICR, 0x00); |
| 453 | |
| 454 | mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080); |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 455 | mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 456 | mbar2_writeByte(MCFSIM_SPURVEC, 0x00); |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 457 | mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 458 | |
| 459 | /* Setup interrupt priorities for gpio7 */ |
| 460 | /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */ |
| 461 | |
| 462 | /* IDE Config registers */ |
| 463 | mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); |
| 464 | mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000); |
| 465 | |
| 466 | /* |
| 467 | * Setup chip selects... |
| 468 | */ |
| 469 | |
| 470 | mbar_writeShort(MCFSIM_CSAR1, CFG_CSAR1); |
| 471 | mbar_writeShort(MCFSIM_CSCR1, CFG_CSCR1); |
| 472 | mbar_writeLong(MCFSIM_CSMR1, CFG_CSMR1); |
| 473 | |
| 474 | mbar_writeShort(MCFSIM_CSAR0, CFG_CSAR0); |
| 475 | mbar_writeShort(MCFSIM_CSCR0, CFG_CSCR0); |
| 476 | mbar_writeLong(MCFSIM_CSMR0, CFG_CSMR0); |
| 477 | |
| 478 | /* enable instruction cache now */ |
| 479 | icache_enable(); |
| 480 | } |
| 481 | |
| 482 | /* |
| 483 | * initialize higher level parts of CPU like timers |
| 484 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 485 | int cpu_init_r(void) |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 486 | { |
| 487 | return (0); |
| 488 | } |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame^] | 489 | |
| 490 | void uart_port_conf(void) |
| 491 | { |
| 492 | /* Setup Ports: */ |
| 493 | switch (CFG_UART_PORT) { |
| 494 | case 0: |
| 495 | break; |
| 496 | case 1: |
| 497 | break; |
| 498 | } |
| 499 | } |
| 500 | #endif /* #if defined(CONFIG_M5249) */ |