blob: 7bb358e63f5760e41a44a6b978d17f45bdc19df2 [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
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020075 mbar_writeShort(MCFSIM_CSAR1, CONFIG_SYS_CSAR1);
76 mbar_writeShort(MCFSIM_CSCR1, CONFIG_SYS_CSCR1);
77 mbar_writeLong(MCFSIM_CSMR1, CONFIG_SYS_CSMR1);
TsiChungLiew34674692007-08-16 13:20:50 -050078
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020079 mbar_writeShort(MCFSIM_CSAR0, CONFIG_SYS_CSAR0);
80 mbar_writeShort(MCFSIM_CSCR0, CONFIG_SYS_CSCR0);
81 mbar_writeLong(MCFSIM_CSMR0, CONFIG_SYS_CSMR0);
TsiChungLiew34674692007-08-16 13:20:50 -050082
TsiChung Liew0c1e3252008-08-19 03:01:19 +060083#ifdef CONFIG_FSL_I2C
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020084 CONFIG_SYS_I2C_PINMUX_REG = CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR;
85 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
86#ifdef CONFIG_SYS_I2C2_OFFSET
87 CONFIG_SYS_I2C2_PINMUX_REG &= CONFIG_SYS_I2C2_PINMUX_CLR;
88 CONFIG_SYS_I2C2_PINMUX_REG |= CONFIG_SYS_I2C2_PINMUX_SET;
TsiChung Liew0c1e3252008-08-19 03:01:19 +060089#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: */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200105 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew34674692007-08-16 13:20:50 -0500106 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: */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200141 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500142 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
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200172 volatile sysctrl_t *sysctrl = (sysctrl_t *) (CONFIG_SYS_MBAR);
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500173 volatile gpio_t *gpio = (gpio_t *) (MMAP_GPIO);
174 volatile csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS);
wdenke65527f2004-02-12 00:47:09 +0000175
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200176 sysctrl->sc_scr = CONFIG_SYS_SCR;
177 sysctrl->sc_spr = CONFIG_SYS_SPR;
wdenke65527f2004-02-12 00:47:09 +0000178
Wolfgang Denkc2c49442006-05-10 17:43:20 +0200179 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200180 gpio->gpio_pacnt = CONFIG_SYS_PACNT;
181 gpio->gpio_paddr = CONFIG_SYS_PADDR;
182 gpio->gpio_padat = CONFIG_SYS_PADAT;
183 gpio->gpio_pbcnt = CONFIG_SYS_PBCNT;
184 gpio->gpio_pbddr = CONFIG_SYS_PBDDR;
185 gpio->gpio_pbdat = CONFIG_SYS_PBDAT;
186 gpio->gpio_pdcnt = CONFIG_SYS_PDCNT;
wdenke65527f2004-02-12 00:47:09 +0000187
188 /* Memory Controller: */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200189 csctrl->cs_br0 = CONFIG_SYS_BR0_PRELIM;
190 csctrl->cs_or0 = CONFIG_SYS_OR0_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000191
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200192#if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM))
193 csctrl->cs_br1 = CONFIG_SYS_BR1_PRELIM;
194 csctrl->cs_or1 = CONFIG_SYS_OR1_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000195#endif
196
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200197#if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
198 csctrl->cs_br2 = CONFIG_SYS_BR2_PRELIM;
199 csctrl->cs_or2 = CONFIG_SYS_OR2_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000200#endif
201
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200202#if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM)
203 csctrl->cs_br3 = CONFIG_SYS_BR3_PRELIM;
204 csctrl->cs_or3 = CONFIG_SYS_OR3_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000205#endif
206
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200207#if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM)
208 csctrl->cs_br4 = CONFIG_SYS_BR4_PRELIM;
209 csctrl->cs_or4 = CONFIG_SYS_OR4_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000210#endif
211
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200212#if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM)
213 csctrl->cs_br5 = CONFIG_SYS_BR5_PRELIM;
214 csctrl->cs_or5 = CONFIG_SYS_OR5_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000215#endif
216
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200217#if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM)
218 csctrl->cs_br6 = CONFIG_SYS_BR6_PRELIM;
219 csctrl->cs_or6 = CONFIG_SYS_OR6_PRELIM;
wdenke65527f2004-02-12 00:47:09 +0000220#endif
221
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200222#if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM)
223 csctrl->cs_br7 = CONFIG_SYS_BR7_PRELIM;
224 csctrl->cs_or7 = CONFIG_SYS_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: */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200247 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500248 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 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200285 csctrl_reg->ar0 = CONFIG_SYS_AR0_PRELIM;
286 csctrl_reg->cr0 = CONFIG_SYS_CR0_PRELIM;
287 csctrl_reg->mr0 = CONFIG_SYS_MR0_PRELIM;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600288
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200289#if (defined(CONFIG_SYS_AR1_PRELIM) && defined(CONFIG_SYS_CR1_PRELIM) && defined(CONFIG_SYS_MR1_PRELIM))
290 csctrl_reg->ar1 = CONFIG_SYS_AR1_PRELIM;
291 csctrl_reg->cr1 = CONFIG_SYS_CR1_PRELIM;
292 csctrl_reg->mr1 = CONFIG_SYS_MR1_PRELIM;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600293#endif
294
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200295#if (defined(CONFIG_SYS_AR2_PRELIM) && defined(CONFIG_SYS_CR2_PRELIM) && defined(CONFIG_SYS_MR2_PRELIM))
296 csctrl_reg->ar2 = CONFIG_SYS_AR2_PRELIM;
297 csctrl_reg->cr2 = CONFIG_SYS_CR2_PRELIM;
298 csctrl_reg->mr2 = CONFIG_SYS_MR2_PRELIM;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600299#endif
300
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200301#if (defined(CONFIG_SYS_AR3_PRELIM) && defined(CONFIG_SYS_CR3_PRELIM) && defined(CONFIG_SYS_MR3_PRELIM))
302 csctrl_reg->ar3 = CONFIG_SYS_AR3_PRELIM;
303 csctrl_reg->cr3 = CONFIG_SYS_CR3_PRELIM;
304 csctrl_reg->mr3 = CONFIG_SYS_MR3_PRELIM;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600305#endif
306
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200307#if (defined(CONFIG_SYS_AR4_PRELIM) && defined(CONFIG_SYS_CR4_PRELIM) && defined(CONFIG_SYS_MR4_PRELIM))
308 csctrl_reg->ar4 = CONFIG_SYS_AR4_PRELIM;
309 csctrl_reg->cr4 = CONFIG_SYS_CR4_PRELIM;
310 csctrl_reg->mr4 = CONFIG_SYS_MR4_PRELIM;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600311#endif
312
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200313#if (defined(CONFIG_SYS_AR5_PRELIM) && defined(CONFIG_SYS_CR5_PRELIM) && defined(CONFIG_SYS_MR5_PRELIM))
314 csctrl_reg->ar5 = CONFIG_SYS_AR5_PRELIM;
315 csctrl_reg->cr5 = CONFIG_SYS_CR5_PRELIM;
316 csctrl_reg->mr5 = CONFIG_SYS_MR5_PRELIM;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600317#endif
318
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200319#if (defined(CONFIG_SYS_AR6_PRELIM) && defined(CONFIG_SYS_CR6_PRELIM) && defined(CONFIG_SYS_MR6_PRELIM))
320 csctrl_reg->ar6 = CONFIG_SYS_AR6_PRELIM;
321 csctrl_reg->cr6 = CONFIG_SYS_CR6_PRELIM;
322 csctrl_reg->mr6 = CONFIG_SYS_MR6_PRELIM;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600323#endif
324
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200325#if (defined(CONFIG_SYS_AR7_PRELIM) && defined(CONFIG_SYS_CR7_PRELIM) && defined(CONFIG_SYS_MR7_PRELIM))
326 csctrl_reg->ar7 = CONFIG_SYS_AR7_PRELIM;
327 csctrl_reg->cr7 = CONFIG_SYS_CR7_PRELIM;
328 csctrl_reg->mr7 = CONFIG_SYS_MR7_PRELIM;
Matthew Fettke761e2e92008-02-04 15:38:20 -0600329#endif
330
331#endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
332
333#ifdef CONFIG_FSL_I2C
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200334 CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
335 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_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: */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200355 switch (CONFIG_SYS_UART_PORT) {
Matthew Fettke761e2e92008-02-04 15:38:20 -0600356 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 =
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200387 MCFCLOCK_SYNCR_MFD(CONFIG_SYS_MFD) | MCFCLOCK_SYNCR_RFD(CONFIG_SYS_RFD);
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500388 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 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200393#ifdef CONFIG_SYS_PEPAR
394 MCFGPIO_PEPAR = CONFIG_SYS_PEPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200395#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200396#ifdef CONFIG_SYS_PFPAR
397 MCFGPIO_PFPAR = CONFIG_SYS_PFPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200398#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200399#ifdef CONFIG_SYS_PJPAR
400 MCFGPIO_PJPAR = CONFIG_SYS_PJPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200401#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200402#ifdef CONFIG_SYS_PSDPAR
403 MCFGPIO_PSDPAR = CONFIG_SYS_PSDPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200404#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200405#ifdef CONFIG_SYS_PASPAR
406 MCFGPIO_PASPAR = CONFIG_SYS_PASPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200407#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200408#ifdef CONFIG_SYS_PEHLPAR
409 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200410#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200411#ifdef CONFIG_SYS_PQSPAR
412 MCFGPIO_PQSPAR = CONFIG_SYS_PQSPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200413#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200414#ifdef CONFIG_SYS_PTCPAR
415 MCFGPIO_PTCPAR = CONFIG_SYS_PTCPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200416#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200417#ifdef CONFIG_SYS_PTDPAR
418 MCFGPIO_PTDPAR = CONFIG_SYS_PTDPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200419#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200420#ifdef CONFIG_SYS_PUAPAR
421 MCFGPIO_PUAPAR = CONFIG_SYS_PUAPAR;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200422#endif
423
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200424#ifdef CONFIG_SYS_DDRUA
425 MCFGPIO_DDRUA = CONFIG_SYS_DDRUA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200426#endif
427
428 /* This is probably a bad place to setup chip selects, but everyone
429 else is doing it! */
430
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200431#if defined(CONFIG_SYS_CS0_BASE) & defined(CONFIG_SYS_CS0_SIZE) & \
432 defined(CONFIG_SYS_CS0_WIDTH) & defined(CONFIG_SYS_CS0_WS)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200433
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200434 MCFCSM_CSAR0 = (CONFIG_SYS_CS0_BASE >> 16) & 0xFFFF;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200435
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200436#if (CONFIG_SYS_CS0_WIDTH == 8)
437#define CONFIG_SYS_CS0_PS MCFCSM_CSCR_PS_8
438#elif (CONFIG_SYS_CS0_WIDTH == 16)
439#define CONFIG_SYS_CS0_PS MCFCSM_CSCR_PS_16
440#elif (CONFIG_SYS_CS0_WIDTH == 32)
441#define CONFIG_SYS_CS0_PS MCFCSM_CSCR_PS_32
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500442#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200443#error "CONFIG_SYS_CS0_WIDTH: Fault - wrong bus with for CS0"
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500444#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200445 MCFCSM_CSCR0 = MCFCSM_CSCR_WS(CONFIG_SYS_CS0_WS)
446 | CONFIG_SYS_CS0_PS | MCFCSM_CSCR_AA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200447
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200448#if (CONFIG_SYS_CS0_RO != 0)
449 MCFCSM_CSMR0 = MCFCSM_CSMR_BAM(CONFIG_SYS_CS0_SIZE - 1)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500450 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200451#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200452 MCFCSM_CSMR0 = MCFCSM_CSMR_BAM(CONFIG_SYS_CS0_SIZE - 1) | MCFCSM_CSMR_V;
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500453#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
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200458#if defined(CONFIG_SYS_CS1_BASE) & defined(CONFIG_SYS_CS1_SIZE) & \
459 defined(CONFIG_SYS_CS1_WIDTH) & defined(CONFIG_SYS_CS1_WS)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200460
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200461 MCFCSM_CSAR1 = (CONFIG_SYS_CS1_BASE >> 16) & 0xFFFF;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200462
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200463#if (CONFIG_SYS_CS1_WIDTH == 8)
464#define CONFIG_SYS_CS1_PS MCFCSM_CSCR_PS_8
465#elif (CONFIG_SYS_CS1_WIDTH == 16)
466#define CONFIG_SYS_CS1_PS MCFCSM_CSCR_PS_16
467#elif (CONFIG_SYS_CS1_WIDTH == 32)
468#define CONFIG_SYS_CS1_PS MCFCSM_CSCR_PS_32
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500469#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200470#error "CONFIG_SYS_CS1_WIDTH: Fault - wrong bus with for CS1"
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500471#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200472 MCFCSM_CSCR1 = MCFCSM_CSCR_WS(CONFIG_SYS_CS1_WS)
473 | CONFIG_SYS_CS1_PS | MCFCSM_CSCR_AA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200474
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200475#if (CONFIG_SYS_CS1_RO != 0)
476 MCFCSM_CSMR1 = MCFCSM_CSMR_BAM(CONFIG_SYS_CS1_SIZE - 1)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500477 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
478#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200479 MCFCSM_CSMR1 = MCFCSM_CSMR_BAM(CONFIG_SYS_CS1_SIZE - 1)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500480 | 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
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200486#if defined(CONFIG_SYS_CS2_BASE) & defined(CONFIG_SYS_CS2_SIZE) & \
487 defined(CONFIG_SYS_CS2_WIDTH) & defined(CONFIG_SYS_CS2_WS)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200488
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200489 MCFCSM_CSAR2 = (CONFIG_SYS_CS2_BASE >> 16) & 0xFFFF;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200490
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200491#if (CONFIG_SYS_CS2_WIDTH == 8)
492#define CONFIG_SYS_CS2_PS MCFCSM_CSCR_PS_8
493#elif (CONFIG_SYS_CS2_WIDTH == 16)
494#define CONFIG_SYS_CS2_PS MCFCSM_CSCR_PS_16
495#elif (CONFIG_SYS_CS2_WIDTH == 32)
496#define CONFIG_SYS_CS2_PS MCFCSM_CSCR_PS_32
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500497#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200498#error "CONFIG_SYS_CS2_WIDTH: Fault - wrong bus with for CS2"
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500499#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200500 MCFCSM_CSCR2 = MCFCSM_CSCR_WS(CONFIG_SYS_CS2_WS)
501 | CONFIG_SYS_CS2_PS | MCFCSM_CSCR_AA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200502
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200503#if (CONFIG_SYS_CS2_RO != 0)
504 MCFCSM_CSMR2 = MCFCSM_CSMR_BAM(CONFIG_SYS_CS2_SIZE - 1)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500505 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200506#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200507 MCFCSM_CSMR2 = MCFCSM_CSMR_BAM(CONFIG_SYS_CS2_SIZE - 1)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500508 | 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
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200514#if defined(CONFIG_SYS_CS3_BASE) & defined(CONFIG_SYS_CS3_SIZE) & \
515 defined(CONFIG_SYS_CS3_WIDTH) & defined(CONFIG_SYS_CS3_WS)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200516
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200517 MCFCSM_CSAR3 = (CONFIG_SYS_CS3_BASE >> 16) & 0xFFFF;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200518
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200519#if (CONFIG_SYS_CS3_WIDTH == 8)
520#define CONFIG_SYS_CS3_PS MCFCSM_CSCR_PS_8
521#elif (CONFIG_SYS_CS3_WIDTH == 16)
522#define CONFIG_SYS_CS3_PS MCFCSM_CSCR_PS_16
523#elif (CONFIG_SYS_CS3_WIDTH == 32)
524#define CONFIG_SYS_CS3_PS MCFCSM_CSCR_PS_32
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500525#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200526#error "CONFIG_SYS_CS3_WIDTH: Fault - wrong bus with for CS1"
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500527#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200528 MCFCSM_CSCR3 = MCFCSM_CSCR_WS(CONFIG_SYS_CS3_WS)
529 | CONFIG_SYS_CS3_PS | MCFCSM_CSCR_AA;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200530
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200531#if (CONFIG_SYS_CS3_RO != 0)
532 MCFCSM_CSMR3 = MCFCSM_CSMR_BAM(CONFIG_SYS_CS3_SIZE - 1)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500533 | MCFCSM_CSMR_WP | MCFCSM_CSMR_V;
534#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200535 MCFCSM_CSMR3 = MCFCSM_CSMR_BAM(CONFIG_SYS_CS3_SIZE - 1)
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500536 | 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: */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200559 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500560 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 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200592 mbar2_writeLong(MCFSIM_GPIO_FUNC, CONFIG_SYS_GPIO_FUNC);
593 mbar2_writeLong(MCFSIM_GPIO1_FUNC, CONFIG_SYS_GPIO1_FUNC);
594 mbar2_writeLong(MCFSIM_GPIO_EN, CONFIG_SYS_GPIO_EN);
595 mbar2_writeLong(MCFSIM_GPIO1_EN, CONFIG_SYS_GPIO1_EN);
596 mbar2_writeLong(MCFSIM_GPIO_OUT, CONFIG_SYS_GPIO_OUT);
597 mbar2_writeLong(MCFSIM_GPIO1_OUT, CONFIG_SYS_GPIO1_OUT);
stroese53395a22004-12-16 18:09:49 +0000598
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
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200639 mbar_writeShort(MCFSIM_CSAR1, CONFIG_SYS_CSAR1);
640 mbar_writeShort(MCFSIM_CSCR1, CONFIG_SYS_CSCR1);
641 mbar_writeLong(MCFSIM_CSMR1, CONFIG_SYS_CSMR1);
stroese53395a22004-12-16 18:09:49 +0000642
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200643 mbar_writeShort(MCFSIM_CSAR0, CONFIG_SYS_CSAR0);
644 mbar_writeShort(MCFSIM_CSCR0, CONFIG_SYS_CSCR0);
645 mbar_writeLong(MCFSIM_CSMR0, CONFIG_SYS_CSMR0);
stroese53395a22004-12-16 18:09:49 +0000646
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: */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200662 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew8cd73be2007-08-15 19:21:21 -0500663 case 0:
664 break;
665 case 1:
666 break;
667 }
668}
669#endif /* #if defined(CONFIG_M5249) */