blob: 18308c8a7ab7e332e6b6386d266dad853c05eaf8 [file] [log] [blame]
wdenkbf9e3b32004-02-12 00:47:09 +00001/*
2 * (C) Copyright 2003
3 * Josef Baumgartner <josef.baumgartner@telex.de>
4 *
Heiko Schocher9acb6262006-04-20 08:42:42 +02005 * MCF5282 additionals
6 * (C) Copyright 2005
7 * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de>
8 *
TsiChungLiewa1436a82007-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 Fettkef71d9d92008-02-04 15:38:20 -060013 * MCF5275 additions
14 * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com)
15 *
wdenkbf9e3b32004-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 Denk977b50f2006-05-10 17:43:20 +020026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wdenkbf9e3b32004-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>
TsiChungLiew83ec20b2007-08-15 19:21:21 -050037#include <asm/immap.h>
stroese8c725b92004-12-16 18:09:49 +000038
TsiChung Liewf3962d32008-10-21 13:47:54 +000039#if defined(CONFIG_CMD_NET)
40#include <config.h>
41#include <net.h>
42#include <asm/fec.h>
43#endif
44
TsiChung Liew012522f2008-10-21 10:03:07 +000045#ifndef CONFIG_M5272
46/* Only 5272 Flexbus chipselect is different from the rest */
47void init_fbcs(void)
48{
49 volatile fbcs_t *fbcs = (fbcs_t *) (MMAP_FBCS);
50
51#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
52 && defined(CONFIG_SYS_CS0_CTRL))
53 fbcs->csar0 = CONFIG_SYS_CS0_BASE;
54 fbcs->cscr0 = CONFIG_SYS_CS0_CTRL;
55 fbcs->csmr0 = CONFIG_SYS_CS0_MASK;
56#else
57#warning "Chip Select 0 are not initialized/used"
58#endif
59#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
60 && defined(CONFIG_SYS_CS1_CTRL))
61 fbcs->csar1 = CONFIG_SYS_CS1_BASE;
62 fbcs->cscr1 = CONFIG_SYS_CS1_CTRL;
63 fbcs->csmr1 = CONFIG_SYS_CS1_MASK;
64#endif
65#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
66 && defined(CONFIG_SYS_CS2_CTRL))
67 fbcs->csar2 = CONFIG_SYS_CS2_BASE;
68 fbcs->cscr2 = CONFIG_SYS_CS2_CTRL;
69 fbcs->csmr2 = CONFIG_SYS_CS2_MASK;
70#endif
71#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
72 && defined(CONFIG_SYS_CS3_CTRL))
73 fbcs->csar3 = CONFIG_SYS_CS3_BASE;
74 fbcs->cscr3 = CONFIG_SYS_CS3_CTRL;
75 fbcs->csmr3 = CONFIG_SYS_CS3_MASK;
76#endif
77#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
78 && defined(CONFIG_SYS_CS4_CTRL))
79 fbcs->csar4 = CONFIG_SYS_CS4_BASE;
80 fbcs->cscr4 = CONFIG_SYS_CS4_CTRL;
81 fbcs->csmr4 = CONFIG_SYS_CS4_MASK;
82#endif
83#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
84 && defined(CONFIG_SYS_CS5_CTRL))
85 fbcs->csar5 = CONFIG_SYS_CS5_BASE;
86 fbcs->cscr5 = CONFIG_SYS_CS5_CTRL;
87 fbcs->csmr5 = CONFIG_SYS_CS5_MASK;
88#endif
89#if (defined(CONFIG_SYS_CS6_BASE) && defined(CONFIG_SYS_CS6_MASK) \
90 && defined(CONFIG_SYS_CS6_CTRL))
91 fbcs->csar6 = CONFIG_SYS_CS6_BASE;
92 fbcs->cscr6 = CONFIG_SYS_CS6_CTRL;
93 fbcs->csmr6 = CONFIG_SYS_CS6_MASK;
94#endif
95#if (defined(CONFIG_SYS_CS7_BASE) && defined(CONFIG_SYS_CS7_MASK) \
96 && defined(CONFIG_SYS_CS7_CTRL))
97 fbcs->csar7 = CONFIG_SYS_CS7_BASE;
98 fbcs->cscr7 = CONFIG_SYS_CS7_CTRL;
99 fbcs->csmr7 = CONFIG_SYS_CS7_MASK;
100#endif
101}
102#endif
103
TsiChungLiewa1436a82007-08-16 13:20:50 -0500104#if defined(CONFIG_M5253)
105/*
106 * Breath some life into the CPU...
107 *
108 * Set up the memory map,
109 * initialize a bunch of registers,
110 * initialize the UPM's
111 */
112void cpu_init_f(void)
113{
114 mbar_writeByte(MCFSIM_MPARK, 0x40); /* 5249 Internal Core takes priority over DMA */
115 mbar_writeByte(MCFSIM_SYPCR, 0x00);
116 mbar_writeByte(MCFSIM_SWIVR, 0x0f);
117 mbar_writeByte(MCFSIM_SWSR, 0x00);
118 mbar_writeByte(MCFSIM_SWDICR, 0x00);
119 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
120 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
121 mbar_writeByte(MCFSIM_I2CICR, 0x00);
122 mbar_writeByte(MCFSIM_UART1ICR, 0x00);
123 mbar_writeByte(MCFSIM_UART2ICR, 0x00);
124 mbar_writeByte(MCFSIM_ICR6, 0x00);
125 mbar_writeByte(MCFSIM_ICR7, 0x00);
126 mbar_writeByte(MCFSIM_ICR8, 0x00);
127 mbar_writeByte(MCFSIM_ICR9, 0x00);
128 mbar_writeByte(MCFSIM_QSPIICR, 0x00);
129
130 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
131 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
132 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
133
TsiChung Liew012522f2008-10-21 10:03:07 +0000134 /*mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); *//* Enable a 1 cycle pre-drive cycle on CS1 */
TsiChungLiewa1436a82007-08-16 13:20:50 -0500135
TsiChung Liew012522f2008-10-21 10:03:07 +0000136 /* FlexBus Chipselect */
137 init_fbcs();
TsiChungLiewa1436a82007-08-16 13:20:50 -0500138
TsiChung Lieweec567a2008-08-19 03:01:19 +0600139#ifdef CONFIG_FSL_I2C
TsiChung Liew012522f2008-10-21 10:03:07 +0000140 CONFIG_SYS_I2C_PINMUX_REG =
141 CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200142 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
143#ifdef CONFIG_SYS_I2C2_OFFSET
144 CONFIG_SYS_I2C2_PINMUX_REG &= CONFIG_SYS_I2C2_PINMUX_CLR;
145 CONFIG_SYS_I2C2_PINMUX_REG |= CONFIG_SYS_I2C2_PINMUX_SET;
TsiChung Lieweec567a2008-08-19 03:01:19 +0600146#endif
147#endif
148
TsiChungLiewa1436a82007-08-16 13:20:50 -0500149 /* enable instruction cache now */
150 icache_enable();
151}
152
153/*initialize higher level parts of CPU like timers */
154int cpu_init_r(void)
155{
156 return (0);
157}
158
159void uart_port_conf(void)
160{
161 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200162 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiewa1436a82007-08-16 13:20:50 -0500163 case 0:
164 break;
165 case 1:
166 break;
167 case 2:
168 break;
169 }
170}
171#endif /* #if defined(CONFIG_M5253) */
172
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500173#if defined(CONFIG_M5271)
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500174void cpu_init_f(void)
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500175{
176#ifndef CONFIG_WATCHDOG
177 /* Disable the watchdog if we aren't using it */
178 mbar_writeShort(MCF_WTM_WCR, 0);
179#endif
180
TsiChung Liew012522f2008-10-21 10:03:07 +0000181 /* FlexBus Chipselect */
182 init_fbcs();
183
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500184 /* Set clockspeed to 100MHz */
185 mbar_writeShort(MCF_FMPLL_SYNCR,
186 MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0));
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500187 while (!mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK) ;
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500188}
189
190/*
191 * initialize higher level parts of CPU like timers
192 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500193int cpu_init_r(void)
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500194{
195 return (0);
196}
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500197
198void uart_port_conf(void)
199{
200 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200201 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500202 case 0:
203 mbar_writeShort(MCF_GPIO_PAR_UART, MCF_GPIO_PAR_UART_U0TXD |
204 MCF_GPIO_PAR_UART_U0RXD);
205 break;
206 case 1:
207 mbar_writeShort(MCF_GPIO_PAR_UART,
208 MCF_GPIO_PAR_UART_U1RXD_UART1 |
209 MCF_GPIO_PAR_UART_U1TXD_UART1);
210 break;
211 case 2:
212 mbar_writeShort(MCF_GPIO_PAR_UART, 0x3000);
213 break;
214 }
215}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000216
217#if defined(CONFIG_CMD_NET)
218int fecpin_setclear(struct eth_device *dev, int setclear)
219{
220 if (setclear) {
221 /* Enable Ethernet pins */
222 mbar_writeByte(MCF_GPIO_PAR_FECI2C, CONFIG_SYS_FECI2C);
223 } else {
224 }
225
226 return 0;
227}
228#endif /* CONFIG_CMD_NET */
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500229#endif
230
stroese8c725b92004-12-16 18:09:49 +0000231#if defined(CONFIG_M5272)
wdenkbf9e3b32004-02-12 00:47:09 +0000232/*
233 * Breath some life into the CPU...
234 *
235 * Set up the memory map,
236 * initialize a bunch of registers,
237 * initialize the UPM's
238 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500239void cpu_init_f(void)
wdenkbf9e3b32004-02-12 00:47:09 +0000240{
241 /* if we come from RAM we assume the CPU is
242 * already initialized.
243 */
244#ifndef CONFIG_MONITOR_IS_IN_RAM
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200245 volatile sysctrl_t *sysctrl = (sysctrl_t *) (CONFIG_SYS_MBAR);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500246 volatile gpio_t *gpio = (gpio_t *) (MMAP_GPIO);
247 volatile csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS);
wdenkbf9e3b32004-02-12 00:47:09 +0000248
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200249 sysctrl->sc_scr = CONFIG_SYS_SCR;
250 sysctrl->sc_spr = CONFIG_SYS_SPR;
wdenkbf9e3b32004-02-12 00:47:09 +0000251
Wolfgang Denk977b50f2006-05-10 17:43:20 +0200252 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200253 gpio->gpio_pacnt = CONFIG_SYS_PACNT;
254 gpio->gpio_paddr = CONFIG_SYS_PADDR;
255 gpio->gpio_padat = CONFIG_SYS_PADAT;
256 gpio->gpio_pbcnt = CONFIG_SYS_PBCNT;
257 gpio->gpio_pbddr = CONFIG_SYS_PBDDR;
258 gpio->gpio_pbdat = CONFIG_SYS_PBDAT;
259 gpio->gpio_pdcnt = CONFIG_SYS_PDCNT;
wdenkbf9e3b32004-02-12 00:47:09 +0000260
261 /* Memory Controller: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200262 csctrl->cs_br0 = CONFIG_SYS_BR0_PRELIM;
263 csctrl->cs_or0 = CONFIG_SYS_OR0_PRELIM;
wdenkbf9e3b32004-02-12 00:47:09 +0000264
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200265#if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM))
266 csctrl->cs_br1 = CONFIG_SYS_BR1_PRELIM;
267 csctrl->cs_or1 = CONFIG_SYS_OR1_PRELIM;
wdenkbf9e3b32004-02-12 00:47:09 +0000268#endif
269
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200270#if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
271 csctrl->cs_br2 = CONFIG_SYS_BR2_PRELIM;
272 csctrl->cs_or2 = CONFIG_SYS_OR2_PRELIM;
wdenkbf9e3b32004-02-12 00:47:09 +0000273#endif
274
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200275#if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM)
276 csctrl->cs_br3 = CONFIG_SYS_BR3_PRELIM;
277 csctrl->cs_or3 = CONFIG_SYS_OR3_PRELIM;
wdenkbf9e3b32004-02-12 00:47:09 +0000278#endif
279
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200280#if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM)
281 csctrl->cs_br4 = CONFIG_SYS_BR4_PRELIM;
282 csctrl->cs_or4 = CONFIG_SYS_OR4_PRELIM;
wdenkbf9e3b32004-02-12 00:47:09 +0000283#endif
284
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200285#if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM)
286 csctrl->cs_br5 = CONFIG_SYS_BR5_PRELIM;
287 csctrl->cs_or5 = CONFIG_SYS_OR5_PRELIM;
wdenkbf9e3b32004-02-12 00:47:09 +0000288#endif
289
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200290#if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM)
291 csctrl->cs_br6 = CONFIG_SYS_BR6_PRELIM;
292 csctrl->cs_or6 = CONFIG_SYS_OR6_PRELIM;
wdenkbf9e3b32004-02-12 00:47:09 +0000293#endif
294
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200295#if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM)
296 csctrl->cs_br7 = CONFIG_SYS_BR7_PRELIM;
297 csctrl->cs_or7 = CONFIG_SYS_OR7_PRELIM;
wdenkbf9e3b32004-02-12 00:47:09 +0000298#endif
299
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500300#endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
wdenkbf9e3b32004-02-12 00:47:09 +0000301
Wolfgang Denk977b50f2006-05-10 17:43:20 +0200302 /* enable instruction cache now */
303 icache_enable();
wdenkbf9e3b32004-02-12 00:47:09 +0000304
305}
306
307/*
308 * initialize higher level parts of CPU like timers
309 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500310int cpu_init_r(void)
wdenkbf9e3b32004-02-12 00:47:09 +0000311{
312 return (0);
313}
wdenkbf9e3b32004-02-12 00:47:09 +0000314
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500315void uart_port_conf(void)
316{
317 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
wdenkbf9e3b32004-02-12 00:47:09 +0000318
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500319 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200320 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500321 case 0:
322 gpio->gpio_pbcnt &= ~(GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK);
323 gpio->gpio_pbcnt |= (GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD);
324 break;
325 case 1:
326 gpio->gpio_pdcnt &= ~(GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK);
327 gpio->gpio_pdcnt |= (GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD);
328 break;
329 }
330}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000331
332#if defined(CONFIG_CMD_NET)
333int fecpin_setclear(struct eth_device *dev, int setclear)
334{
335 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
336
337 if (setclear) {
338 gpio->gpio_pbcnt |= GPIO_PBCNT_E_MDC | GPIO_PBCNT_E_RXER |
339 GPIO_PBCNT_E_RXD1 | GPIO_PBCNT_E_RXD2 |
340 GPIO_PBCNT_E_RXD3 | GPIO_PBCNT_E_TXD1 |
341 GPIO_PBCNT_E_TXD2 | GPIO_PBCNT_E_TXD3;
342 } else {
343 }
344 return 0;
345}
346#endif /* CONFIG_CMD_NET */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500347#endif /* #if defined(CONFIG_M5272) */
348
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600349#if defined(CONFIG_M5275)
350
351/*
352 * Breathe some life into the CPU...
353 *
354 * Set up the memory map,
355 * initialize a bunch of registers,
356 * initialize the UPM's
357 */
358void cpu_init_f(void)
359{
TsiChung Liew012522f2008-10-21 10:03:07 +0000360 /*
361 * if we come from RAM we assume the CPU is
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600362 * already initialized.
363 */
364
365#ifndef CONFIG_MONITOR_IS_IN_RAM
TsiChung Liew012522f2008-10-21 10:03:07 +0000366 volatile wdog_t *wdog_reg = (wdog_t *) (MMAP_WDOG);
367 volatile gpio_t *gpio_reg = (gpio_t *) (MMAP_GPIO);
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600368
369 /* Kill watchdog so we can initialize the PLL */
370 wdog_reg->wcr = 0;
371
TsiChung Liew012522f2008-10-21 10:03:07 +0000372 /* FlexBus Chipselect */
373 init_fbcs();
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600374#endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
375
376#ifdef CONFIG_FSL_I2C
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200377 CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
378 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600379#endif
380
381 /* enable instruction cache now */
382 icache_enable();
383}
384
385/*
386 * initialize higher level parts of CPU like timers
387 */
388int cpu_init_r(void)
389{
390 return (0);
391}
392
393void uart_port_conf(void)
394{
TsiChung Liew012522f2008-10-21 10:03:07 +0000395 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600396
397 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200398 switch (CONFIG_SYS_UART_PORT) {
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600399 case 0:
400 gpio->par_uart |= UART0_ENABLE_MASK;
401 break;
402 case 1:
403 gpio->par_uart |= UART1_ENABLE_MASK;
404 break;
405 case 2:
406 gpio->par_uart |= UART2_ENABLE_MASK;
407 break;
408 }
409}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000410
411#if defined(CONFIG_CMD_NET)
412int fecpin_setclear(struct eth_device *dev, int setclear)
413{
414 struct fec_info_s *info = (struct fec_info_s *) dev->priv;
415 volatile gpio_t *gpio = (gpio_t *)MMAP_GPIO;
416
417 if (setclear) {
418 /* Enable Ethernet pins */
419 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
420 gpio->par_feci2c |= 0x0F00;
421 gpio->par_fec0hl |= 0xC0;
422 } else {
423 gpio->par_feci2c |= 0x00A0;
424 gpio->par_fec1hl |= 0xC0;
425 }
426 } else {
427 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
428 gpio->par_feci2c &= ~0x0F00;
429 gpio->par_fec0hl &= ~0xC0;
430 } else {
431 gpio->par_feci2c &= ~0x00A0;
432 gpio->par_fec1hl &= ~0xC0;
433 }
434 }
435
436 return 0;
437}
438#endif /* CONFIG_CMD_NET */
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600439#endif /* #if defined(CONFIG_M5275) */
440
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500441#if defined(CONFIG_M5282)
wdenkbf9e3b32004-02-12 00:47:09 +0000442/*
443 * Breath some life into the CPU...
444 *
445 * Set up the memory map,
446 * initialize a bunch of registers,
447 * initialize the UPM's
448 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500449void cpu_init_f(void)
wdenkbf9e3b32004-02-12 00:47:09 +0000450{
Heiko Schocher9acb6262006-04-20 08:42:42 +0200451#ifndef CONFIG_WATCHDOG
452 /* disable watchdog if we aren't using it */
453 MCFWTM_WCR = 0;
454#endif
wdenkbf9e3b32004-02-12 00:47:09 +0000455
Heiko Schocher9acb6262006-04-20 08:42:42 +0200456#ifndef CONFIG_MONITOR_IS_IN_RAM
457 /* Set speed /PLL */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500458 MCFCLOCK_SYNCR =
TsiChung Liew012522f2008-10-21 10:03:07 +0000459 MCFCLOCK_SYNCR_MFD(CONFIG_SYS_MFD) |
460 MCFCLOCK_SYNCR_RFD(CONFIG_SYS_RFD);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500461 while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ;
462
463 MCFGPIO_PBCDPAR = 0xc0;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200464
465 /* Set up the GPIO ports */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200466#ifdef CONFIG_SYS_PEPAR
467 MCFGPIO_PEPAR = CONFIG_SYS_PEPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200468#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200469#ifdef CONFIG_SYS_PFPAR
470 MCFGPIO_PFPAR = CONFIG_SYS_PFPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200471#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200472#ifdef CONFIG_SYS_PJPAR
473 MCFGPIO_PJPAR = CONFIG_SYS_PJPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200474#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200475#ifdef CONFIG_SYS_PSDPAR
476 MCFGPIO_PSDPAR = CONFIG_SYS_PSDPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200477#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200478#ifdef CONFIG_SYS_PASPAR
479 MCFGPIO_PASPAR = CONFIG_SYS_PASPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200480#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200481#ifdef CONFIG_SYS_PEHLPAR
482 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200483#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200484#ifdef CONFIG_SYS_PQSPAR
485 MCFGPIO_PQSPAR = CONFIG_SYS_PQSPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200486#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200487#ifdef CONFIG_SYS_PTCPAR
488 MCFGPIO_PTCPAR = CONFIG_SYS_PTCPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200489#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200490#ifdef CONFIG_SYS_PTDPAR
491 MCFGPIO_PTDPAR = CONFIG_SYS_PTDPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200492#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200493#ifdef CONFIG_SYS_PUAPAR
494 MCFGPIO_PUAPAR = CONFIG_SYS_PUAPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200495#endif
496
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200497#ifdef CONFIG_SYS_DDRUA
498 MCFGPIO_DDRUA = CONFIG_SYS_DDRUA;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200499#endif
500
TsiChung Liew012522f2008-10-21 10:03:07 +0000501 /* FlexBus Chipselect */
502 init_fbcs();
Heiko Schocher9acb6262006-04-20 08:42:42 +0200503
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500504#endif /* CONFIG_MONITOR_IS_IN_RAM */
Heiko Schocher9acb6262006-04-20 08:42:42 +0200505
506 /* defer enabling cache until boot (see do_go) */
507 /* icache_enable(); */
wdenkbf9e3b32004-02-12 00:47:09 +0000508}
509
510/*
511 * initialize higher level parts of CPU like timers
512 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500513int cpu_init_r(void)
wdenkbf9e3b32004-02-12 00:47:09 +0000514{
515 return (0);
516}
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500517
518void uart_port_conf(void)
519{
520 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200521 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500522 case 0:
523 MCFGPIO_PUAPAR &= 0xFc;
524 MCFGPIO_PUAPAR |= 0x03;
525 break;
526 case 1:
527 MCFGPIO_PUAPAR &= 0xF3;
528 MCFGPIO_PUAPAR |= 0x0C;
529 break;
530 case 2:
531 MCFGPIO_PASPAR &= 0xFF0F;
532 MCFGPIO_PASPAR |= 0x00A0;
533 break;
534 }
535}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000536
537#if defined(CONFIG_CMD_NET)
538int fecpin_setclear(struct eth_device *dev, int setclear)
539{
540 if (setclear) {
541 MCFGPIO_PASPAR |= 0x0F00;
542 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
543 } else {
544 MCFGPIO_PASPAR &= 0xF0FF;
545 MCFGPIO_PEHLPAR &= ~CONFIG_SYS_PEHLPAR;
546 }
547 return 0;
548}
549#endif /* CONFIG_CMD_NET */
wdenkbf9e3b32004-02-12 00:47:09 +0000550#endif
stroese8c725b92004-12-16 18:09:49 +0000551
552#if defined(CONFIG_M5249)
553/*
554 * Breath some life into the CPU...
555 *
556 * Set up the memory map,
557 * initialize a bunch of registers,
558 * initialize the UPM's
559 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500560void cpu_init_f(void)
stroese8c725b92004-12-16 18:09:49 +0000561{
stroese8c725b92004-12-16 18:09:49 +0000562 /*
563 * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500564 * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins
565 * which is their primary function.
566 * ~Jeremy
stroese8c725b92004-12-16 18:09:49 +0000567 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200568 mbar2_writeLong(MCFSIM_GPIO_FUNC, CONFIG_SYS_GPIO_FUNC);
569 mbar2_writeLong(MCFSIM_GPIO1_FUNC, CONFIG_SYS_GPIO1_FUNC);
570 mbar2_writeLong(MCFSIM_GPIO_EN, CONFIG_SYS_GPIO_EN);
571 mbar2_writeLong(MCFSIM_GPIO1_EN, CONFIG_SYS_GPIO1_EN);
572 mbar2_writeLong(MCFSIM_GPIO_OUT, CONFIG_SYS_GPIO_OUT);
573 mbar2_writeLong(MCFSIM_GPIO1_OUT, CONFIG_SYS_GPIO1_OUT);
stroese8c725b92004-12-16 18:09:49 +0000574
575 /*
576 * dBug Compliance:
577 * You can verify these values by using dBug's 'ird'
578 * (Internal Register Display) command
579 * ~Jeremy
580 *
Wolfgang Denk977b50f2006-05-10 17:43:20 +0200581 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500582 mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */
stroese8c725b92004-12-16 18:09:49 +0000583 mbar_writeByte(MCFSIM_SYPCR, 0x00);
584 mbar_writeByte(MCFSIM_SWIVR, 0x0f);
585 mbar_writeByte(MCFSIM_SWSR, 0x00);
586 mbar_writeLong(MCFSIM_IMR, 0xfffffbff);
587 mbar_writeByte(MCFSIM_SWDICR, 0x00);
588 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
589 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
590 mbar_writeByte(MCFSIM_I2CICR, 0x00);
591 mbar_writeByte(MCFSIM_UART1ICR, 0x00);
592 mbar_writeByte(MCFSIM_UART2ICR, 0x00);
593 mbar_writeByte(MCFSIM_ICR6, 0x00);
594 mbar_writeByte(MCFSIM_ICR7, 0x00);
595 mbar_writeByte(MCFSIM_ICR8, 0x00);
596 mbar_writeByte(MCFSIM_ICR9, 0x00);
597 mbar_writeByte(MCFSIM_QSPIICR, 0x00);
598
599 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
Wolfgang Denk977b50f2006-05-10 17:43:20 +0200600 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
stroese8c725b92004-12-16 18:09:49 +0000601 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500602 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */
stroese8c725b92004-12-16 18:09:49 +0000603
604 /* Setup interrupt priorities for gpio7 */
605 /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */
606
607 /* IDE Config registers */
608 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020);
609 mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000);
610
TsiChung Liew012522f2008-10-21 10:03:07 +0000611 /* FlexBus Chipselect */
612 init_fbcs();
stroese8c725b92004-12-16 18:09:49 +0000613
614 /* enable instruction cache now */
615 icache_enable();
616}
617
618/*
619 * initialize higher level parts of CPU like timers
620 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500621int cpu_init_r(void)
stroese8c725b92004-12-16 18:09:49 +0000622{
623 return (0);
624}
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500625
626void uart_port_conf(void)
627{
628 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200629 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500630 case 0:
631 break;
632 case 1:
633 break;
634 }
635}
636#endif /* #if defined(CONFIG_M5249) */