blob: 5736d0f26c121ddb0ac1783767e62ba3e4dc8d8f [file] [log] [blame]
wdenke65527f2004-02-12 00:47:09 +00001/*
2 * (C) Copyright 2003
3 * Josef Baumgartner <josef.baumgartner@telex.de>
4 *
Heiko Schocherac1956e2006-04-20 08:42:42 +02005 * MCF5282 additionals
6 * (C) Copyright 2005
7 * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de>
8 *
wdenke65527f2004-02-12 00:47:09 +00009 * 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 Denkc2c49442006-05-10 17:43:20 +020019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wdenke65527f2004-02-12 00:47:09 +000020 * 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>
TsiChungLiew8cd73be2007-08-15 19:21:21 -050030#include <asm/immap.h>
stroese53395a22004-12-16 18:09:49 +000031
Zachary P. Landau0bba8622006-01-26 17:35:56 -050032#if defined(CONFIG_M5271)
TsiChungLiew8cd73be2007-08-15 19:21:21 -050033void cpu_init_f(void)
Zachary P. Landau0bba8622006-01-26 17:35:56 -050034{
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));
TsiChungLiew8cd73be2007-08-15 19:21:21 -050043 while (!mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK) ;
Zachary P. Landau0bba8622006-01-26 17:35:56 -050044}
45
46/*
47 * initialize higher level parts of CPU like timers
48 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -050049int cpu_init_r(void)
Zachary P. Landau0bba8622006-01-26 17:35:56 -050050{
51 return (0);
52}
TsiChungLiew8cd73be2007-08-15 19:21:21 -050053
54void 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. Landau0bba8622006-01-26 17:35:56 -050072#endif
73
stroese53395a22004-12-16 18:09:49 +000074#if defined(CONFIG_M5272)
wdenke65527f2004-02-12 00:47:09 +000075/*
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 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -050082void cpu_init_f(void)
wdenke65527f2004-02-12 00:47:09 +000083{
84 /* if we come from RAM we assume the CPU is
85 * already initialized.
86 */
87#ifndef CONFIG_MONITOR_IS_IN_RAM
TsiChungLiew8cd73be2007-08-15 19:21:21 -050088 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);
wdenke65527f2004-02-12 00:47:09 +000091
TsiChungLiew8cd73be2007-08-15 19:21:21 -050092 sysctrl->sc_scr = CFG_SCR;
93 sysctrl->sc_spr = CFG_SPR;
wdenke65527f2004-02-12 00:47:09 +000094
Wolfgang Denkc2c49442006-05-10 17:43:20 +020095 /* Setup Ports: */
TsiChungLiew8cd73be2007-08-15 19:21:21 -050096 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;
wdenke65527f2004-02-12 00:47:09 +0000103
104 /* Memory Controller: */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500105 csctrl->cs_br0 = CFG_BR0_PRELIM;
106 csctrl->cs_or0 = CFG_OR0_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000107
108#if (defined(CFG_OR1_PRELIM) && defined(CFG_BR1_PRELIM))
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500109 csctrl->cs_br1 = CFG_BR1_PRELIM;
110 csctrl->cs_or1 = CFG_OR1_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000111#endif
112
113#if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500114 csctrl->cs_br2 = CFG_BR2_PRELIM;
115 csctrl->cs_or2 = CFG_OR2_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000116#endif
117
118#if defined(CFG_OR3_PRELIM) && defined(CFG_BR3_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500119 csctrl->cs_br3 = CFG_BR3_PRELIM;
120 csctrl->cs_or3 = CFG_OR3_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000121#endif
122
123#if defined(CFG_OR4_PRELIM) && defined(CFG_BR4_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500124 csctrl->cs_br4 = CFG_BR4_PRELIM;
125 csctrl->cs_or4 = CFG_OR4_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000126#endif
127
128#if defined(CFG_OR5_PRELIM) && defined(CFG_BR5_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500129 csctrl->cs_br5 = CFG_BR5_PRELIM;
130 csctrl->cs_or5 = CFG_OR5_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000131#endif
132
133#if defined(CFG_OR6_PRELIM) && defined(CFG_BR6_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500134 csctrl->cs_br6 = CFG_BR6_PRELIM;
135 csctrl->cs_or6 = CFG_OR6_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000136#endif
137
138#if defined(CFG_OR7_PRELIM) && defined(CFG_BR7_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500139 csctrl->cs_br7 = CFG_BR7_PRELIM;
140 csctrl->cs_or7 = CFG_OR7_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000141#endif
142
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500143#endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
wdenke65527f2004-02-12 00:47:09 +0000144
Wolfgang Denkc2c49442006-05-10 17:43:20 +0200145 /* enable instruction cache now */
146 icache_enable();
wdenke65527f2004-02-12 00:47:09 +0000147
148}
149
150/*
151 * initialize higher level parts of CPU like timers
152 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500153int cpu_init_r(void)
wdenke65527f2004-02-12 00:47:09 +0000154{
155 return (0);
156}
wdenke65527f2004-02-12 00:47:09 +0000157
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500158void uart_port_conf(void)
159{
160 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
wdenke65527f2004-02-12 00:47:09 +0000161
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500162 /* 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)
wdenke65527f2004-02-12 00:47:09 +0000177/*
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 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500184void cpu_init_f(void)
wdenke65527f2004-02-12 00:47:09 +0000185{
Heiko Schocherac1956e2006-04-20 08:42:42 +0200186#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 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500193 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 Schocherac1956e2006-04-20 08:42:42 +0200198
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
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500242 MCFCSM_CSAR0 = (CFG_CS0_BASE >> 16) & 0xFFFF;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200243
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500244#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 Schocherac1956e2006-04-20 08:42:42 +0200255
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500256#if (CFG_CS0_RO != 0)
257 MCFCSM_CSMR0 = MCFCSM_CSMR_BAM(CFG_CS0_SIZE - 1)
258 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200259#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500260 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 Schocherac1956e2006-04-20 08:42:42 +0200264#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
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500272#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 Schocherac1956e2006-04-20 08:42:42 +0200283
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500284#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 Schocherac1956e2006-04-20 08:42:42 +0200291#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500292#warning "Chip Select 1 are not initialized/used"
Heiko Schocherac1956e2006-04-20 08:42:42 +0200293#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
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500301#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 Schocherac1956e2006-04-20 08:42:42 +0200312
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500313#if (CFG_CS2_RO != 0)
314 MCFCSM_CSMR2 = MCFCSM_CSMR_BAM(CFG_CS2_SIZE - 1)
315 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200316#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500317 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 Schocherac1956e2006-04-20 08:42:42 +0200322#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
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500330#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 Schocherac1956e2006-04-20 08:42:42 +0200341
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500342#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 Schocherac1956e2006-04-20 08:42:42 +0200349#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500350#warning "Chip Select 3 are not initialized/used"
Heiko Schocherac1956e2006-04-20 08:42:42 +0200351#endif
352
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500353#endif /* CONFIG_MONITOR_IS_IN_RAM */
wdenke65527f2004-02-12 00:47:09 +0000354
Heiko Schocherac1956e2006-04-20 08:42:42 +0200355 /* defer enabling cache until boot (see do_go) */
356 /* icache_enable(); */
wdenke65527f2004-02-12 00:47:09 +0000357}
358
359/*
360 * initialize higher level parts of CPU like timers
361 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500362int cpu_init_r(void)
wdenke65527f2004-02-12 00:47:09 +0000363{
364 return (0);
365}
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500366
367void 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}
wdenke65527f2004-02-12 00:47:09 +0000385#endif
stroese53395a22004-12-16 18:09:49 +0000386
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 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500395void cpu_init_f(void)
stroese53395a22004-12-16 18:09:49 +0000396{
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
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500405 pllcr = 0x925a3100; /* ~140MHz clock (PLL bypass = 0) */
stroese53395a22004-12-16 18:09:49 +0000406#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500407 pllcr = 0x135a4140; /* ~72MHz clock (PLL bypass = 0) */
stroese53395a22004-12-16 18:09:49 +0000408#endif
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500409 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 */
stroese53395a22004-12-16 18:09:49 +0000416
417 /*
418 * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500419 * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins
420 * which is their primary function.
421 * ~Jeremy
stroese53395a22004-12-16 18:09:49 +0000422 */
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 Denkc2c49442006-05-10 17:43:20 +0200436 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500437 mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */
stroese53395a22004-12-16 18:09:49 +0000438 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 Denkc2c49442006-05-10 17:43:20 +0200455 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
stroese53395a22004-12-16 18:09:49 +0000456 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500457 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */
stroese53395a22004-12-16 18:09:49 +0000458
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 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500485int cpu_init_r(void)
stroese53395a22004-12-16 18:09:49 +0000486{
487 return (0);
488}
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500489
490void 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) */