blob: 68aefe9151b3032eaa851caf39875503a75d9e96 [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 *
TsiChungLiew34674692007-08-16 13:20:50 -05009 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
10 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
11 * Hayden Fraser (Hayden.Fraser@freescale.com)
12 *
Matthew Fettke761e2e92008-02-04 15:38:20 -060013 * MCF5275 additions
14 * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com)
15 *
wdenke65527f2004-02-12 00:47:09 +000016 * See file CREDITS for list of people who contributed to this
17 * project.
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License as
21 * published by the Free Software Foundation; either version 2 of
22 * the License, or (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Wolfgang Denkc2c49442006-05-10 17:43:20 +020026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wdenke65527f2004-02-12 00:47:09 +000027 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
33 */
34
35#include <common.h>
36#include <watchdog.h>
TsiChungLiew8cd73be2007-08-15 19:21:21 -050037#include <asm/immap.h>
stroese53395a22004-12-16 18:09:49 +000038
TsiChungLiew34674692007-08-16 13:20:50 -050039#if defined(CONFIG_M5253)
40/*
41 * Breath some life into the CPU...
42 *
43 * Set up the memory map,
44 * initialize a bunch of registers,
45 * initialize the UPM's
46 */
47void cpu_init_f(void)
48{
49 mbar_writeByte(MCFSIM_MPARK, 0x40); /* 5249 Internal Core takes priority over DMA */
50 mbar_writeByte(MCFSIM_SYPCR, 0x00);
51 mbar_writeByte(MCFSIM_SWIVR, 0x0f);
52 mbar_writeByte(MCFSIM_SWSR, 0x00);
53 mbar_writeByte(MCFSIM_SWDICR, 0x00);
54 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
55 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
56 mbar_writeByte(MCFSIM_I2CICR, 0x00);
57 mbar_writeByte(MCFSIM_UART1ICR, 0x00);
58 mbar_writeByte(MCFSIM_UART2ICR, 0x00);
59 mbar_writeByte(MCFSIM_ICR6, 0x00);
60 mbar_writeByte(MCFSIM_ICR7, 0x00);
61 mbar_writeByte(MCFSIM_ICR8, 0x00);
62 mbar_writeByte(MCFSIM_ICR9, 0x00);
63 mbar_writeByte(MCFSIM_QSPIICR, 0x00);
64
65 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
66 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
67 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
68
Stefan Roesefe9dae62007-08-18 14:33:02 +020069 /*mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); */ /* Enable a 1 cycle pre-drive cycle on CS1 */
TsiChungLiew34674692007-08-16 13:20:50 -050070
71 /*
72 * Setup chip selects...
73 */
74
75 mbar_writeShort(MCFSIM_CSAR1, CFG_CSAR1);
76 mbar_writeShort(MCFSIM_CSCR1, CFG_CSCR1);
77 mbar_writeLong(MCFSIM_CSMR1, CFG_CSMR1);
78
79 mbar_writeShort(MCFSIM_CSAR0, CFG_CSAR0);
80 mbar_writeShort(MCFSIM_CSCR0, CFG_CSCR0);
81 mbar_writeLong(MCFSIM_CSMR0, CFG_CSMR0);
82
TsiChung Liew0c1e3252008-08-19 03:01:19 +060083#ifdef CONFIG_FSL_I2C
84 CFG_I2C_PINMUX_REG = CFG_I2C_PINMUX_REG & CFG_I2C_PINMUX_CLR;
85 CFG_I2C_PINMUX_REG |= CFG_I2C_PINMUX_SET;
86#ifdef CFG_I2C2_OFFSET
87 CFG_I2C2_PINMUX_REG &= CFG_I2C2_PINMUX_CLR;
88 CFG_I2C2_PINMUX_REG |= CFG_I2C2_PINMUX_SET;
89#endif
90#endif
91
TsiChungLiew34674692007-08-16 13:20:50 -050092 /* enable instruction cache now */
93 icache_enable();
94}
95
96/*initialize higher level parts of CPU like timers */
97int cpu_init_r(void)
98{
99 return (0);
100}
101
102void uart_port_conf(void)
103{
104 /* Setup Ports: */
105 switch (CFG_UART_PORT) {
106 case 0:
107 break;
108 case 1:
109 break;
110 case 2:
111 break;
112 }
113}
114#endif /* #if defined(CONFIG_M5253) */
115
Zachary P. Landau0bba8622006-01-26 17:35:56 -0500116#if defined(CONFIG_M5271)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500117void cpu_init_f(void)
Zachary P. Landau0bba8622006-01-26 17:35:56 -0500118{
119#ifndef CONFIG_WATCHDOG
120 /* Disable the watchdog if we aren't using it */
121 mbar_writeShort(MCF_WTM_WCR, 0);
122#endif
123
124 /* Set clockspeed to 100MHz */
125 mbar_writeShort(MCF_FMPLL_SYNCR,
126 MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0));
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500127 while (!mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK) ;
Zachary P. Landau0bba8622006-01-26 17:35:56 -0500128}
129
130/*
131 * initialize higher level parts of CPU like timers
132 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500133int cpu_init_r(void)
Zachary P. Landau0bba8622006-01-26 17:35:56 -0500134{
135 return (0);
136}
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500137
138void uart_port_conf(void)
139{
140 /* Setup Ports: */
141 switch (CFG_UART_PORT) {
142 case 0:
143 mbar_writeShort(MCF_GPIO_PAR_UART, MCF_GPIO_PAR_UART_U0TXD |
144 MCF_GPIO_PAR_UART_U0RXD);
145 break;
146 case 1:
147 mbar_writeShort(MCF_GPIO_PAR_UART,
148 MCF_GPIO_PAR_UART_U1RXD_UART1 |
149 MCF_GPIO_PAR_UART_U1TXD_UART1);
150 break;
151 case 2:
152 mbar_writeShort(MCF_GPIO_PAR_UART, 0x3000);
153 break;
154 }
155}
Zachary P. Landau0bba8622006-01-26 17:35:56 -0500156#endif
157
stroese53395a22004-12-16 18:09:49 +0000158#if defined(CONFIG_M5272)
wdenke65527f2004-02-12 00:47:09 +0000159/*
160 * Breath some life into the CPU...
161 *
162 * Set up the memory map,
163 * initialize a bunch of registers,
164 * initialize the UPM's
165 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500166void cpu_init_f(void)
wdenke65527f2004-02-12 00:47:09 +0000167{
168 /* if we come from RAM we assume the CPU is
169 * already initialized.
170 */
171#ifndef CONFIG_MONITOR_IS_IN_RAM
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500172 volatile sysctrl_t *sysctrl = (sysctrl_t *) (CFG_MBAR);
173 volatile gpio_t *gpio = (gpio_t *) (MMAP_GPIO);
174 volatile csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS);
wdenke65527f2004-02-12 00:47:09 +0000175
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500176 sysctrl->sc_scr = CFG_SCR;
177 sysctrl->sc_spr = CFG_SPR;
wdenke65527f2004-02-12 00:47:09 +0000178
Wolfgang Denkc2c49442006-05-10 17:43:20 +0200179 /* Setup Ports: */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500180 gpio->gpio_pacnt = CFG_PACNT;
181 gpio->gpio_paddr = CFG_PADDR;
182 gpio->gpio_padat = CFG_PADAT;
183 gpio->gpio_pbcnt = CFG_PBCNT;
184 gpio->gpio_pbddr = CFG_PBDDR;
185 gpio->gpio_pbdat = CFG_PBDAT;
186 gpio->gpio_pdcnt = CFG_PDCNT;
wdenke65527f2004-02-12 00:47:09 +0000187
188 /* Memory Controller: */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500189 csctrl->cs_br0 = CFG_BR0_PRELIM;
190 csctrl->cs_or0 = CFG_OR0_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000191
192#if (defined(CFG_OR1_PRELIM) && defined(CFG_BR1_PRELIM))
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500193 csctrl->cs_br1 = CFG_BR1_PRELIM;
194 csctrl->cs_or1 = CFG_OR1_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000195#endif
196
197#if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500198 csctrl->cs_br2 = CFG_BR2_PRELIM;
199 csctrl->cs_or2 = CFG_OR2_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000200#endif
201
202#if defined(CFG_OR3_PRELIM) && defined(CFG_BR3_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500203 csctrl->cs_br3 = CFG_BR3_PRELIM;
204 csctrl->cs_or3 = CFG_OR3_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000205#endif
206
207#if defined(CFG_OR4_PRELIM) && defined(CFG_BR4_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500208 csctrl->cs_br4 = CFG_BR4_PRELIM;
209 csctrl->cs_or4 = CFG_OR4_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000210#endif
211
212#if defined(CFG_OR5_PRELIM) && defined(CFG_BR5_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500213 csctrl->cs_br5 = CFG_BR5_PRELIM;
214 csctrl->cs_or5 = CFG_OR5_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000215#endif
216
217#if defined(CFG_OR6_PRELIM) && defined(CFG_BR6_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500218 csctrl->cs_br6 = CFG_BR6_PRELIM;
219 csctrl->cs_or6 = CFG_OR6_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000220#endif
221
222#if defined(CFG_OR7_PRELIM) && defined(CFG_BR7_PRELIM)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500223 csctrl->cs_br7 = CFG_BR7_PRELIM;
224 csctrl->cs_or7 = CFG_OR7_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000225#endif
226
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500227#endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
wdenke65527f2004-02-12 00:47:09 +0000228
Wolfgang Denkc2c49442006-05-10 17:43:20 +0200229 /* enable instruction cache now */
230 icache_enable();
wdenke65527f2004-02-12 00:47:09 +0000231
232}
233
234/*
235 * initialize higher level parts of CPU like timers
236 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500237int cpu_init_r(void)
wdenke65527f2004-02-12 00:47:09 +0000238{
239 return (0);
240}
wdenke65527f2004-02-12 00:47:09 +0000241
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500242void uart_port_conf(void)
243{
244 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
wdenke65527f2004-02-12 00:47:09 +0000245
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500246 /* Setup Ports: */
247 switch (CFG_UART_PORT) {
248 case 0:
249 gpio->gpio_pbcnt &= ~(GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK);
250 gpio->gpio_pbcnt |= (GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD);
251 break;
252 case 1:
253 gpio->gpio_pdcnt &= ~(GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK);
254 gpio->gpio_pdcnt |= (GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD);
255 break;
256 }
257}
258#endif /* #if defined(CONFIG_M5272) */
259
Matthew Fettke761e2e92008-02-04 15:38:20 -0600260#if defined(CONFIG_M5275)
261
262/*
263 * Breathe some life into the CPU...
264 *
265 * Set up the memory map,
266 * initialize a bunch of registers,
267 * initialize the UPM's
268 */
269void cpu_init_f(void)
270{
271 /* if we come from RAM we assume the CPU is
272 * already initialized.
273 */
274
275#ifndef CONFIG_MONITOR_IS_IN_RAM
276 volatile wdog_t *wdog_reg = (wdog_t *)(MMAP_WDOG);
277 volatile gpio_t *gpio_reg = (gpio_t *)(MMAP_GPIO);
278 volatile csctrl_t *csctrl_reg = (csctrl_t *)(MMAP_FBCS);
279
280 /* Kill watchdog so we can initialize the PLL */
281 wdog_reg->wcr = 0;
282
283 /* Memory Controller: */
284 /* Flash */
285 csctrl_reg->ar0 = CFG_AR0_PRELIM;
286 csctrl_reg->cr0 = CFG_CR0_PRELIM;
287 csctrl_reg->mr0 = CFG_MR0_PRELIM;
288
289#if (defined(CFG_AR1_PRELIM) && defined(CFG_CR1_PRELIM) && defined(CFG_MR1_PRELIM))
290 csctrl_reg->ar1 = CFG_AR1_PRELIM;
291 csctrl_reg->cr1 = CFG_CR1_PRELIM;
292 csctrl_reg->mr1 = CFG_MR1_PRELIM;
293#endif
294
295#if (defined(CFG_AR2_PRELIM) && defined(CFG_CR2_PRELIM) && defined(CFG_MR2_PRELIM))
296 csctrl_reg->ar2 = CFG_AR2_PRELIM;
297 csctrl_reg->cr2 = CFG_CR2_PRELIM;
298 csctrl_reg->mr2 = CFG_MR2_PRELIM;
299#endif
300
301#if (defined(CFG_AR3_PRELIM) && defined(CFG_CR3_PRELIM) && defined(CFG_MR3_PRELIM))
302 csctrl_reg->ar3 = CFG_AR3_PRELIM;
303 csctrl_reg->cr3 = CFG_CR3_PRELIM;
304 csctrl_reg->mr3 = CFG_MR3_PRELIM;
305#endif
306
307#if (defined(CFG_AR4_PRELIM) && defined(CFG_CR4_PRELIM) && defined(CFG_MR4_PRELIM))
308 csctrl_reg->ar4 = CFG_AR4_PRELIM;
309 csctrl_reg->cr4 = CFG_CR4_PRELIM;
310 csctrl_reg->mr4 = CFG_MR4_PRELIM;
311#endif
312
313#if (defined(CFG_AR5_PRELIM) && defined(CFG_CR5_PRELIM) && defined(CFG_MR5_PRELIM))
314 csctrl_reg->ar5 = CFG_AR5_PRELIM;
315 csctrl_reg->cr5 = CFG_CR5_PRELIM;
316 csctrl_reg->mr5 = CFG_MR5_PRELIM;
317#endif
318
319#if (defined(CFG_AR6_PRELIM) && defined(CFG_CR6_PRELIM) && defined(CFG_MR6_PRELIM))
320 csctrl_reg->ar6 = CFG_AR6_PRELIM;
321 csctrl_reg->cr6 = CFG_CR6_PRELIM;
322 csctrl_reg->mr6 = CFG_MR6_PRELIM;
323#endif
324
325#if (defined(CFG_AR7_PRELIM) && defined(CFG_CR7_PRELIM) && defined(CFG_MR7_PRELIM))
326 csctrl_reg->ar7 = CFG_AR7_PRELIM;
327 csctrl_reg->cr7 = CFG_CR7_PRELIM;
328 csctrl_reg->mr7 = CFG_MR7_PRELIM;
329#endif
330
331#endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
332
333#ifdef CONFIG_FSL_I2C
TsiChung Liew0c1e3252008-08-19 03:01:19 +0600334 CFG_I2C_PINMUX_REG &= CFG_I2C_PINMUX_CLR;
335 CFG_I2C_PINMUX_REG |= CFG_I2C_PINMUX_SET;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600336#endif
337
338 /* enable instruction cache now */
339 icache_enable();
340}
341
342/*
343 * initialize higher level parts of CPU like timers
344 */
345int cpu_init_r(void)
346{
347 return (0);
348}
349
350void uart_port_conf(void)
351{
352 volatile gpio_t *gpio = (gpio_t *)MMAP_GPIO;
353
354 /* Setup Ports: */
355 switch (CFG_UART_PORT) {
356 case 0:
357 gpio->par_uart |= UART0_ENABLE_MASK;
358 break;
359 case 1:
360 gpio->par_uart |= UART1_ENABLE_MASK;
361 break;
362 case 2:
363 gpio->par_uart |= UART2_ENABLE_MASK;
364 break;
365 }
366}
367#endif /* #if defined(CONFIG_M5275) */
368
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500369#if defined(CONFIG_M5282)
wdenke65527f2004-02-12 00:47:09 +0000370/*
371 * Breath some life into the CPU...
372 *
373 * Set up the memory map,
374 * initialize a bunch of registers,
375 * initialize the UPM's
376 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500377void cpu_init_f(void)
wdenke65527f2004-02-12 00:47:09 +0000378{
Heiko Schocherac1956e2006-04-20 08:42:42 +0200379#ifndef CONFIG_WATCHDOG
380 /* disable watchdog if we aren't using it */
381 MCFWTM_WCR = 0;
382#endif
383
384#ifndef CONFIG_MONITOR_IS_IN_RAM
385 /* Set speed /PLL */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500386 MCFCLOCK_SYNCR =
387 MCFCLOCK_SYNCR_MFD(CFG_MFD) | MCFCLOCK_SYNCR_RFD(CFG_RFD);
388 while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ;
389
390 MCFGPIO_PBCDPAR = 0xc0;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200391
392 /* Set up the GPIO ports */
393#ifdef CFG_PEPAR
394 MCFGPIO_PEPAR = CFG_PEPAR;
395#endif
396#ifdef CFG_PFPAR
397 MCFGPIO_PFPAR = CFG_PFPAR;
398#endif
399#ifdef CFG_PJPAR
400 MCFGPIO_PJPAR = CFG_PJPAR;
401#endif
402#ifdef CFG_PSDPAR
403 MCFGPIO_PSDPAR = CFG_PSDPAR;
404#endif
405#ifdef CFG_PASPAR
406 MCFGPIO_PASPAR = CFG_PASPAR;
407#endif
408#ifdef CFG_PEHLPAR
409 MCFGPIO_PEHLPAR = CFG_PEHLPAR;
410#endif
411#ifdef CFG_PQSPAR
412 MCFGPIO_PQSPAR = CFG_PQSPAR;
413#endif
414#ifdef CFG_PTCPAR
415 MCFGPIO_PTCPAR = CFG_PTCPAR;
416#endif
417#ifdef CFG_PTDPAR
418 MCFGPIO_PTDPAR = CFG_PTDPAR;
419#endif
420#ifdef CFG_PUAPAR
421 MCFGPIO_PUAPAR = CFG_PUAPAR;
422#endif
423
424#ifdef CFG_DDRUA
425 MCFGPIO_DDRUA = CFG_DDRUA;
426#endif
427
428 /* This is probably a bad place to setup chip selects, but everyone
429 else is doing it! */
430
431#if defined(CFG_CS0_BASE) & defined(CFG_CS0_SIZE) & \
TsiChung Liew9352e3f2008-07-09 16:20:23 -0500432 defined(CFG_CS0_WIDTH) & defined(CFG_CS0_WS)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200433
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500434 MCFCSM_CSAR0 = (CFG_CS0_BASE >> 16) & 0xFFFF;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200435
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500436#if (CFG_CS0_WIDTH == 8)
437#define CFG_CS0_PS MCFCSM_CSCR_PS_8
438#elif (CFG_CS0_WIDTH == 16)
439#define CFG_CS0_PS MCFCSM_CSCR_PS_16
440#elif (CFG_CS0_WIDTH == 32)
441#define CFG_CS0_PS MCFCSM_CSCR_PS_32
442#else
443#error "CFG_CS0_WIDTH: Fault - wrong bus with for CS0"
444#endif
445 MCFCSM_CSCR0 = MCFCSM_CSCR_WS(CFG_CS0_WS)
446 | CFG_CS0_PS | MCFCSM_CSCR_AA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200447
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500448#if (CFG_CS0_RO != 0)
449 MCFCSM_CSMR0 = MCFCSM_CSMR_BAM(CFG_CS0_SIZE - 1)
450 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200451#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500452 MCFCSM_CSMR0 = MCFCSM_CSMR_BAM(CFG_CS0_SIZE - 1) | MCFCSM_CSMR_V;
453#endif
454#else
TsiChung Liewfcd4aac2008-08-11 15:54:25 +0000455#warning "Chip Select 0 are not initialized/used"
Heiko Schocherac1956e2006-04-20 08:42:42 +0200456#endif
457
458#if defined(CFG_CS1_BASE) & defined(CFG_CS1_SIZE) & \
TsiChung Liew9352e3f2008-07-09 16:20:23 -0500459 defined(CFG_CS1_WIDTH) & defined(CFG_CS1_WS)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200460
461 MCFCSM_CSAR1 = (CFG_CS1_BASE >> 16) & 0xFFFF;
462
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500463#if (CFG_CS1_WIDTH == 8)
464#define CFG_CS1_PS MCFCSM_CSCR_PS_8
465#elif (CFG_CS1_WIDTH == 16)
466#define CFG_CS1_PS MCFCSM_CSCR_PS_16
467#elif (CFG_CS1_WIDTH == 32)
468#define CFG_CS1_PS MCFCSM_CSCR_PS_32
469#else
470#error "CFG_CS1_WIDTH: Fault - wrong bus with for CS1"
471#endif
472 MCFCSM_CSCR1 = MCFCSM_CSCR_WS(CFG_CS1_WS)
473 | CFG_CS1_PS | MCFCSM_CSCR_AA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200474
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500475#if (CFG_CS1_RO != 0)
476 MCFCSM_CSMR1 = MCFCSM_CSMR_BAM(CFG_CS1_SIZE - 1)
477 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
478#else
479 MCFCSM_CSMR1 = MCFCSM_CSMR_BAM(CFG_CS1_SIZE - 1)
480 | MCFCSM_CSMR_V;
481#endif
Heiko Schocherac1956e2006-04-20 08:42:42 +0200482#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500483#warning "Chip Select 1 are not initialized/used"
Heiko Schocherac1956e2006-04-20 08:42:42 +0200484#endif
485
486#if defined(CFG_CS2_BASE) & defined(CFG_CS2_SIZE) & \
TsiChung Liew9352e3f2008-07-09 16:20:23 -0500487 defined(CFG_CS2_WIDTH) & defined(CFG_CS2_WS)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200488
489 MCFCSM_CSAR2 = (CFG_CS2_BASE >> 16) & 0xFFFF;
490
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500491#if (CFG_CS2_WIDTH == 8)
492#define CFG_CS2_PS MCFCSM_CSCR_PS_8
493#elif (CFG_CS2_WIDTH == 16)
494#define CFG_CS2_PS MCFCSM_CSCR_PS_16
495#elif (CFG_CS2_WIDTH == 32)
496#define CFG_CS2_PS MCFCSM_CSCR_PS_32
497#else
498#error "CFG_CS2_WIDTH: Fault - wrong bus with for CS2"
499#endif
500 MCFCSM_CSCR2 = MCFCSM_CSCR_WS(CFG_CS2_WS)
501 | CFG_CS2_PS | MCFCSM_CSCR_AA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200502
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500503#if (CFG_CS2_RO != 0)
504 MCFCSM_CSMR2 = MCFCSM_CSMR_BAM(CFG_CS2_SIZE - 1)
505 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200506#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500507 MCFCSM_CSMR2 = MCFCSM_CSMR_BAM(CFG_CS2_SIZE - 1)
508 | MCFCSM_CSMR_V;
509#endif
510#else
511#warning "Chip Select 2 are not initialized/used"
Heiko Schocherac1956e2006-04-20 08:42:42 +0200512#endif
513
514#if defined(CFG_CS3_BASE) & defined(CFG_CS3_SIZE) & \
TsiChung Liew9352e3f2008-07-09 16:20:23 -0500515 defined(CFG_CS3_WIDTH) & defined(CFG_CS3_WS)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200516
517 MCFCSM_CSAR3 = (CFG_CS3_BASE >> 16) & 0xFFFF;
518
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500519#if (CFG_CS3_WIDTH == 8)
520#define CFG_CS3_PS MCFCSM_CSCR_PS_8
521#elif (CFG_CS3_WIDTH == 16)
522#define CFG_CS3_PS MCFCSM_CSCR_PS_16
523#elif (CFG_CS3_WIDTH == 32)
524#define CFG_CS3_PS MCFCSM_CSCR_PS_32
525#else
526#error "CFG_CS3_WIDTH: Fault - wrong bus with for CS1"
527#endif
528 MCFCSM_CSCR3 = MCFCSM_CSCR_WS(CFG_CS3_WS)
529 | CFG_CS3_PS | MCFCSM_CSCR_AA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200530
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500531#if (CFG_CS3_RO != 0)
532 MCFCSM_CSMR3 = MCFCSM_CSMR_BAM(CFG_CS3_SIZE - 1)
533 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
534#else
535 MCFCSM_CSMR3 = MCFCSM_CSMR_BAM(CFG_CS3_SIZE - 1)
536 | MCFCSM_CSMR_V;
537#endif
Heiko Schocherac1956e2006-04-20 08:42:42 +0200538#else
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500539#warning "Chip Select 3 are not initialized/used"
Heiko Schocherac1956e2006-04-20 08:42:42 +0200540#endif
541
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500542#endif /* CONFIG_MONITOR_IS_IN_RAM */
wdenke65527f2004-02-12 00:47:09 +0000543
Heiko Schocherac1956e2006-04-20 08:42:42 +0200544 /* defer enabling cache until boot (see do_go) */
545 /* icache_enable(); */
wdenke65527f2004-02-12 00:47:09 +0000546}
547
548/*
549 * initialize higher level parts of CPU like timers
550 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500551int cpu_init_r(void)
wdenke65527f2004-02-12 00:47:09 +0000552{
553 return (0);
554}
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500555
556void uart_port_conf(void)
557{
558 /* Setup Ports: */
559 switch (CFG_UART_PORT) {
560 case 0:
561 MCFGPIO_PUAPAR &= 0xFc;
562 MCFGPIO_PUAPAR |= 0x03;
563 break;
564 case 1:
565 MCFGPIO_PUAPAR &= 0xF3;
566 MCFGPIO_PUAPAR |= 0x0C;
567 break;
568 case 2:
569 MCFGPIO_PASPAR &= 0xFF0F;
570 MCFGPIO_PASPAR |= 0x00A0;
571 break;
572 }
573}
wdenke65527f2004-02-12 00:47:09 +0000574#endif
stroese53395a22004-12-16 18:09:49 +0000575
576#if defined(CONFIG_M5249)
577/*
578 * Breath some life into the CPU...
579 *
580 * Set up the memory map,
581 * initialize a bunch of registers,
582 * initialize the UPM's
583 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500584void cpu_init_f(void)
stroese53395a22004-12-16 18:09:49 +0000585{
stroese53395a22004-12-16 18:09:49 +0000586 /*
587 * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500588 * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins
589 * which is their primary function.
590 * ~Jeremy
stroese53395a22004-12-16 18:09:49 +0000591 */
592 mbar2_writeLong(MCFSIM_GPIO_FUNC, CFG_GPIO_FUNC);
593 mbar2_writeLong(MCFSIM_GPIO1_FUNC, CFG_GPIO1_FUNC);
594 mbar2_writeLong(MCFSIM_GPIO_EN, CFG_GPIO_EN);
595 mbar2_writeLong(MCFSIM_GPIO1_EN, CFG_GPIO1_EN);
596 mbar2_writeLong(MCFSIM_GPIO_OUT, CFG_GPIO_OUT);
597 mbar2_writeLong(MCFSIM_GPIO1_OUT, CFG_GPIO1_OUT);
598
599 /*
600 * dBug Compliance:
601 * You can verify these values by using dBug's 'ird'
602 * (Internal Register Display) command
603 * ~Jeremy
604 *
Wolfgang Denkc2c49442006-05-10 17:43:20 +0200605 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500606 mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */
stroese53395a22004-12-16 18:09:49 +0000607 mbar_writeByte(MCFSIM_SYPCR, 0x00);
608 mbar_writeByte(MCFSIM_SWIVR, 0x0f);
609 mbar_writeByte(MCFSIM_SWSR, 0x00);
610 mbar_writeLong(MCFSIM_IMR, 0xfffffbff);
611 mbar_writeByte(MCFSIM_SWDICR, 0x00);
612 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
613 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
614 mbar_writeByte(MCFSIM_I2CICR, 0x00);
615 mbar_writeByte(MCFSIM_UART1ICR, 0x00);
616 mbar_writeByte(MCFSIM_UART2ICR, 0x00);
617 mbar_writeByte(MCFSIM_ICR6, 0x00);
618 mbar_writeByte(MCFSIM_ICR7, 0x00);
619 mbar_writeByte(MCFSIM_ICR8, 0x00);
620 mbar_writeByte(MCFSIM_ICR9, 0x00);
621 mbar_writeByte(MCFSIM_QSPIICR, 0x00);
622
623 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
Wolfgang Denkc2c49442006-05-10 17:43:20 +0200624 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
stroese53395a22004-12-16 18:09:49 +0000625 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500626 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */
stroese53395a22004-12-16 18:09:49 +0000627
628 /* Setup interrupt priorities for gpio7 */
629 /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */
630
631 /* IDE Config registers */
632 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020);
633 mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000);
634
635 /*
636 * Setup chip selects...
637 */
638
639 mbar_writeShort(MCFSIM_CSAR1, CFG_CSAR1);
640 mbar_writeShort(MCFSIM_CSCR1, CFG_CSCR1);
641 mbar_writeLong(MCFSIM_CSMR1, CFG_CSMR1);
642
643 mbar_writeShort(MCFSIM_CSAR0, CFG_CSAR0);
644 mbar_writeShort(MCFSIM_CSCR0, CFG_CSCR0);
645 mbar_writeLong(MCFSIM_CSMR0, CFG_CSMR0);
646
647 /* enable instruction cache now */
648 icache_enable();
649}
650
651/*
652 * initialize higher level parts of CPU like timers
653 */
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500654int cpu_init_r(void)
stroese53395a22004-12-16 18:09:49 +0000655{
656 return (0);
657}
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500658
659void uart_port_conf(void)
660{
661 /* Setup Ports: */
662 switch (CFG_UART_PORT) {
663 case 0:
664 break;
665 case 1:
666 break;
667 }
668}
669#endif /* #if defined(CONFIG_M5249) */