blob: 5d0e9f06f372c577c7ece92f57e5e251409077d4 [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>
Michael Durrantdfc2b762010-01-20 19:33:02 -06008 * (c) Copyright 2010
9 * Arcturus Networks Inc. <www.arcturusnetworks.com>
Heiko Schocher9acb6262006-04-20 08:42:42 +020010 *
Alison Wang32dbaaf2012-03-26 21:49:04 +000011 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiewa1436a82007-08-16 13:20:50 -050012 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
13 * Hayden Fraser (Hayden.Fraser@freescale.com)
14 *
Matthew Fettkef71d9d92008-02-04 15:38:20 -060015 * MCF5275 additions
16 * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com)
17 *
wdenkbf9e3b32004-02-12 00:47:09 +000018 * See file CREDITS for list of people who contributed to this
19 * project.
20 *
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License as
23 * published by the Free Software Foundation; either version 2 of
24 * the License, or (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Wolfgang Denk977b50f2006-05-10 17:43:20 +020028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wdenkbf9e3b32004-02-12 00:47:09 +000029 * GNU General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 * MA 02111-1307 USA
35 */
36
37#include <common.h>
38#include <watchdog.h>
TsiChungLiew83ec20b2007-08-15 19:21:21 -050039#include <asm/immap.h>
Alison Wang32dbaaf2012-03-26 21:49:04 +000040#include <asm/io.h>
stroese8c725b92004-12-16 18:09:49 +000041
TsiChung Liewf3962d32008-10-21 13:47:54 +000042#if defined(CONFIG_CMD_NET)
43#include <config.h>
44#include <net.h>
45#include <asm/fec.h>
46#endif
47
TsiChung Liew012522f2008-10-21 10:03:07 +000048#ifndef CONFIG_M5272
49/* Only 5272 Flexbus chipselect is different from the rest */
50void init_fbcs(void)
51{
Alison Wang32dbaaf2012-03-26 21:49:04 +000052 fbcs_t *fbcs = (fbcs_t *) (MMAP_FBCS);
TsiChung Liew012522f2008-10-21 10:03:07 +000053
54#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
55 && defined(CONFIG_SYS_CS0_CTRL))
Alison Wang32dbaaf2012-03-26 21:49:04 +000056 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
57 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
58 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
TsiChung Liew012522f2008-10-21 10:03:07 +000059#else
60#warning "Chip Select 0 are not initialized/used"
61#endif
62#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
63 && defined(CONFIG_SYS_CS1_CTRL))
Alison Wang32dbaaf2012-03-26 21:49:04 +000064 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
65 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
66 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
TsiChung Liew012522f2008-10-21 10:03:07 +000067#endif
68#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
69 && defined(CONFIG_SYS_CS2_CTRL))
Alison Wang32dbaaf2012-03-26 21:49:04 +000070 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
71 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
72 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
TsiChung Liew012522f2008-10-21 10:03:07 +000073#endif
74#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
75 && defined(CONFIG_SYS_CS3_CTRL))
Alison Wang32dbaaf2012-03-26 21:49:04 +000076 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
77 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
78 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
TsiChung Liew012522f2008-10-21 10:03:07 +000079#endif
80#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
81 && defined(CONFIG_SYS_CS4_CTRL))
Alison Wang32dbaaf2012-03-26 21:49:04 +000082 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
83 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
84 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
TsiChung Liew012522f2008-10-21 10:03:07 +000085#endif
86#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
87 && defined(CONFIG_SYS_CS5_CTRL))
Alison Wang32dbaaf2012-03-26 21:49:04 +000088 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
89 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
90 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
TsiChung Liew012522f2008-10-21 10:03:07 +000091#endif
92#if (defined(CONFIG_SYS_CS6_BASE) && defined(CONFIG_SYS_CS6_MASK) \
93 && defined(CONFIG_SYS_CS6_CTRL))
Alison Wang32dbaaf2012-03-26 21:49:04 +000094 out_be32(&fbcs->csar6, CONFIG_SYS_CS6_BASE);
95 out_be32(&fbcs->cscr6, CONFIG_SYS_CS6_CTRL);
96 out_be32(&fbcs->csmr6, CONFIG_SYS_CS6_MASK);
TsiChung Liew012522f2008-10-21 10:03:07 +000097#endif
98#if (defined(CONFIG_SYS_CS7_BASE) && defined(CONFIG_SYS_CS7_MASK) \
99 && defined(CONFIG_SYS_CS7_CTRL))
Alison Wang32dbaaf2012-03-26 21:49:04 +0000100 out_be32(&fbcs->csar7, CONFIG_SYS_CS7_BASE);
101 out_be32(&fbcs->cscr7, CONFIG_SYS_CS7_CTRL);
102 out_be32(&fbcs->csmr7, CONFIG_SYS_CS7_MASK);
TsiChung Liew012522f2008-10-21 10:03:07 +0000103#endif
104}
105#endif
106
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000107#if defined(CONFIG_M5208)
108void cpu_init_f(void)
109{
Alison Wang32dbaaf2012-03-26 21:49:04 +0000110 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000111
112#ifndef CONFIG_WATCHDOG
Alison Wang32dbaaf2012-03-26 21:49:04 +0000113 wdog_t *wdg = (wdog_t *) MMAP_WDOG;
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000114
115 /* Disable the watchdog if we aren't using it */
Alison Wang32dbaaf2012-03-26 21:49:04 +0000116 out_be16(&wdg->cr, 0);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000117#endif
118
Alison Wang32dbaaf2012-03-26 21:49:04 +0000119 out_be32(&scm1->mpr, 0x77777777);
120 out_be32(&scm1->pacra, 0);
121 out_be32(&scm1->pacrb, 0);
122 out_be32(&scm1->pacrc, 0);
123 out_be32(&scm1->pacrd, 0);
124 out_be32(&scm1->pacre, 0);
125 out_be32(&scm1->pacrf, 0);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000126
127 /* FlexBus Chipselect */
128 init_fbcs();
129
130 icache_enable();
131}
132
133/* initialize higher level parts of CPU like timers */
134int cpu_init_r(void)
135{
136 return (0);
137}
138
TsiChung Liew52affe02010-03-09 19:17:52 -0600139void uart_port_conf(int port)
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000140{
Alison Wang32dbaaf2012-03-26 21:49:04 +0000141 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000142
143 /* Setup Ports: */
TsiChung Liew52affe02010-03-09 19:17:52 -0600144 switch (port) {
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000145 case 0:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000146 clrbits_be16(&gpio->par_uart, ~GPIO_PAR_UART0_UNMASK);
147 setbits_be16(&gpio->par_uart, GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000148 break;
149 case 1:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000150 clrbits_be16(&gpio->par_uart, ~GPIO_PAR_UART0_UNMASK);
151 setbits_be16(&gpio->par_uart, GPIO_PAR_UART_U1TXD | GPIO_PAR_UART_U1RXD);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000152 break;
153 case 2:
154#ifdef CONFIG_SYS_UART2_PRI_GPIO
Alison Wang32dbaaf2012-03-26 21:49:04 +0000155 clrbits_8(&gpio->par_timer,
156 ~(GPIO_PAR_TMR_TIN0_UNMASK | GPIO_PAR_TMR_TIN1_UNMASK));
157 setbits_8(&gpio->par_timer,
158 GPIO_PAR_TMR_TIN0_U2TXD | GPIO_PAR_TMR_TIN1_U2RXD);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000159#endif
160#ifdef CONFIG_SYS_UART2_ALT1_GPIO
Alison Wang32dbaaf2012-03-26 21:49:04 +0000161 clrbits_8(&gpio->par_feci2c,
162 ~(GPIO_PAR_FECI2C_MDC_UNMASK | GPIO_PAR_FECI2C_MDIO_UNMASK));
163 setbits_8(&gpio->par_feci2c,
164 GPIO_PAR_FECI2C_MDC_U2TXD | GPIO_PAR_FECI2C_MDIO_U2RXD);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000165#endif
166#ifdef CONFIG_SYS_UART2_ALT1_GPIO
Alison Wang32dbaaf2012-03-26 21:49:04 +0000167 clrbits_8(&gpio->par_feci2c,
168 ~(GPIO_PAR_FECI2C_SDA_UNMASK | GPIO_PAR_FECI2C_SCL_UNMASK));
169 setbits_8(&gpio->par_feci2c,
170 GPIO_PAR_FECI2C_SDA_U2TXD | GPIO_PAR_FECI2C_SCL_U2RXD);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000171#endif
172 break;
173 }
174}
175
176#if defined(CONFIG_CMD_NET)
177int fecpin_setclear(struct eth_device *dev, int setclear)
178{
Alison Wang32dbaaf2012-03-26 21:49:04 +0000179 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000180
181 if (setclear) {
Alison Wang32dbaaf2012-03-26 21:49:04 +0000182 setbits_8(&gpio->par_fec,
183 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
184 setbits_8(&gpio->par_feci2c,
185 GPIO_PAR_FECI2C_MDC_MDC | GPIO_PAR_FECI2C_MDIO_MDIO);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000186 } else {
Alison Wang32dbaaf2012-03-26 21:49:04 +0000187 clrbits_8(&gpio->par_fec,
188 ~(GPIO_PAR_FEC_7W_UNMASK & GPIO_PAR_FEC_MII_UNMASK));
189 clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII_UNMASK);
TsiChung Liewbf9a5212009-06-12 11:29:00 +0000190 }
191 return 0;
192}
193#endif /* CONFIG_CMD_NET */
194#endif /* CONFIG_M5208 */
195
TsiChungLiewa1436a82007-08-16 13:20:50 -0500196#if defined(CONFIG_M5253)
197/*
198 * Breath some life into the CPU...
199 *
200 * Set up the memory map,
201 * initialize a bunch of registers,
202 * initialize the UPM's
203 */
204void cpu_init_f(void)
205{
206 mbar_writeByte(MCFSIM_MPARK, 0x40); /* 5249 Internal Core takes priority over DMA */
207 mbar_writeByte(MCFSIM_SYPCR, 0x00);
208 mbar_writeByte(MCFSIM_SWIVR, 0x0f);
209 mbar_writeByte(MCFSIM_SWSR, 0x00);
210 mbar_writeByte(MCFSIM_SWDICR, 0x00);
211 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
212 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
213 mbar_writeByte(MCFSIM_I2CICR, 0x00);
214 mbar_writeByte(MCFSIM_UART1ICR, 0x00);
215 mbar_writeByte(MCFSIM_UART2ICR, 0x00);
216 mbar_writeByte(MCFSIM_ICR6, 0x00);
217 mbar_writeByte(MCFSIM_ICR7, 0x00);
218 mbar_writeByte(MCFSIM_ICR8, 0x00);
219 mbar_writeByte(MCFSIM_ICR9, 0x00);
220 mbar_writeByte(MCFSIM_QSPIICR, 0x00);
221
222 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
223 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
224 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
225
Wolfgang Denk455ae7e2008-12-16 01:02:17 +0100226 /*mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); */ /* Enable a 1 cycle pre-drive cycle on CS1 */
TsiChungLiewa1436a82007-08-16 13:20:50 -0500227
TsiChung Liew012522f2008-10-21 10:03:07 +0000228 /* FlexBus Chipselect */
229 init_fbcs();
TsiChungLiewa1436a82007-08-16 13:20:50 -0500230
TsiChung Lieweec567a2008-08-19 03:01:19 +0600231#ifdef CONFIG_FSL_I2C
TsiChung Liew012522f2008-10-21 10:03:07 +0000232 CONFIG_SYS_I2C_PINMUX_REG =
233 CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200234 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
235#ifdef CONFIG_SYS_I2C2_OFFSET
236 CONFIG_SYS_I2C2_PINMUX_REG &= CONFIG_SYS_I2C2_PINMUX_CLR;
237 CONFIG_SYS_I2C2_PINMUX_REG |= CONFIG_SYS_I2C2_PINMUX_SET;
TsiChung Lieweec567a2008-08-19 03:01:19 +0600238#endif
239#endif
240
TsiChungLiewa1436a82007-08-16 13:20:50 -0500241 /* enable instruction cache now */
242 icache_enable();
243}
244
245/*initialize higher level parts of CPU like timers */
246int cpu_init_r(void)
247{
248 return (0);
249}
250
TsiChung Liew52affe02010-03-09 19:17:52 -0600251void uart_port_conf(int port)
TsiChungLiewa1436a82007-08-16 13:20:50 -0500252{
Alison Wang32dbaaf2012-03-26 21:49:04 +0000253 u32 *par = (u32 *) MMAP_PAR;
TsiChung Liew52affe02010-03-09 19:17:52 -0600254
TsiChungLiewa1436a82007-08-16 13:20:50 -0500255 /* Setup Ports: */
TsiChung Liew52affe02010-03-09 19:17:52 -0600256 switch (port) {
TsiChungLiewa1436a82007-08-16 13:20:50 -0500257 case 1:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000258 clrbits_be32(par, 0x00180000);
259 setbits_be32(par, 0x00180000);
TsiChungLiewa1436a82007-08-16 13:20:50 -0500260 break;
261 case 2:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000262 clrbits_be32(par, 0x00000003);
263 clrbits_be32(par, 0xFFFFFFFC);
TsiChungLiewa1436a82007-08-16 13:20:50 -0500264 break;
265 }
266}
267#endif /* #if defined(CONFIG_M5253) */
268
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500269#if defined(CONFIG_M5271)
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500270void cpu_init_f(void)
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500271{
272#ifndef CONFIG_WATCHDOG
273 /* Disable the watchdog if we aren't using it */
274 mbar_writeShort(MCF_WTM_WCR, 0);
275#endif
276
TsiChung Liew012522f2008-10-21 10:03:07 +0000277 /* FlexBus Chipselect */
278 init_fbcs();
279
Richard Retanubune0db3442009-01-29 14:36:06 -0500280#ifdef CONFIG_SYS_MCF_SYNCR
281 /* Set clockspeed according to board header file */
282 mbar_writeLong(MCF_FMPLL_SYNCR, CONFIG_SYS_MCF_SYNCR);
283#else
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500284 /* Set clockspeed to 100MHz */
Richard Retanubune0db3442009-01-29 14:36:06 -0500285 mbar_writeLong(MCF_FMPLL_SYNCR,
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500286 MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0));
Richard Retanubune0db3442009-01-29 14:36:06 -0500287#endif
Mike Frysinger65f0d122011-10-15 10:10:42 +0000288 while (!(mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK)) ;
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500289}
290
291/*
292 * initialize higher level parts of CPU like timers
293 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500294int cpu_init_r(void)
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500295{
296 return (0);
297}
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500298
TsiChung Liew52affe02010-03-09 19:17:52 -0600299void uart_port_conf(int port)
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500300{
TsiChung Liew52affe02010-03-09 19:17:52 -0600301 u16 temp;
302
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500303 /* Setup Ports: */
TsiChung Liew52affe02010-03-09 19:17:52 -0600304 switch (port) {
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500305 case 0:
TsiChung Liew52affe02010-03-09 19:17:52 -0600306 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xFFF3;
307 temp |= (MCF_GPIO_PAR_UART_U0TXD | MCF_GPIO_PAR_UART_U0RXD);
308 mbar_writeShort(MCF_GPIO_PAR_UART, temp);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500309 break;
310 case 1:
TsiChung Liew52affe02010-03-09 19:17:52 -0600311 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xF0FF;
312 temp |= (MCF_GPIO_PAR_UART_U1RXD_UART1 | MCF_GPIO_PAR_UART_U1TXD_UART1);
313 mbar_writeShort(MCF_GPIO_PAR_UART, temp);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500314 break;
315 case 2:
TsiChung Liew52affe02010-03-09 19:17:52 -0600316 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xCFFF;
317 temp |= (0x3000);
318 mbar_writeShort(MCF_GPIO_PAR_UART, temp);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500319 break;
320 }
321}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000322
323#if defined(CONFIG_CMD_NET)
324int fecpin_setclear(struct eth_device *dev, int setclear)
325{
326 if (setclear) {
327 /* Enable Ethernet pins */
Richard Retanubund1ef25d2009-01-23 10:47:13 -0500328 mbar_writeByte(MCF_GPIO_PAR_FECI2C,
329 (mbar_readByte(MCF_GPIO_PAR_FECI2C) | 0xF0));
TsiChung Liewf3962d32008-10-21 13:47:54 +0000330 } else {
331 }
332
333 return 0;
334}
335#endif /* CONFIG_CMD_NET */
Richard Retanubun59d06122011-03-24 08:58:11 +0000336
337#if defined(CONFIG_CF_QSPI)
338
339/* Configure PIOs for SIN, SOUT, and SCK */
340void cfspi_port_conf(void)
341{
342 mbar_writeByte(MCF_GPIO_PAR_QSPI,
343 MCF_GPIO_PAR_QSPI_SIN_SIN |
344 MCF_GPIO_PAR_QSPI_SOUT_SOUT |
345 MCF_GPIO_PAR_QSPI_SCK_SCK);
346}
347#endif /* CONFIG_CF_QSPI */
348
349#endif /* CONFIG_M5271 */
Zachary P. Landaueacbd312006-01-26 17:35:56 -0500350
stroese8c725b92004-12-16 18:09:49 +0000351#if defined(CONFIG_M5272)
wdenkbf9e3b32004-02-12 00:47:09 +0000352/*
353 * Breath some life into the CPU...
354 *
355 * Set up the memory map,
356 * initialize a bunch of registers,
357 * initialize the UPM's
358 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500359void cpu_init_f(void)
wdenkbf9e3b32004-02-12 00:47:09 +0000360{
361 /* if we come from RAM we assume the CPU is
362 * already initialized.
363 */
364#ifndef CONFIG_MONITOR_IS_IN_RAM
Alison Wang32dbaaf2012-03-26 21:49:04 +0000365 sysctrl_t *sysctrl = (sysctrl_t *) (CONFIG_SYS_MBAR);
366 gpio_t *gpio = (gpio_t *) (MMAP_GPIO);
367 csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS);
wdenkbf9e3b32004-02-12 00:47:09 +0000368
Alison Wang32dbaaf2012-03-26 21:49:04 +0000369 out_be16(&sysctrl->sc_scr, CONFIG_SYS_SCR);
370 out_be16(&sysctrl->sc_spr, CONFIG_SYS_SPR);
wdenkbf9e3b32004-02-12 00:47:09 +0000371
Wolfgang Denk977b50f2006-05-10 17:43:20 +0200372 /* Setup Ports: */
Alison Wang32dbaaf2012-03-26 21:49:04 +0000373 out_be32(&gpio->gpio_pacnt, CONFIG_SYS_PACNT);
374 out_be16(&gpio->gpio_paddr, CONFIG_SYS_PADDR);
375 out_be16(&gpio->gpio_padat, CONFIG_SYS_PADAT);
376 out_be32(&gpio->gpio_pbcnt, CONFIG_SYS_PBCNT);
377 out_be16(&gpio->gpio_pbddr, CONFIG_SYS_PBDDR);
378 out_be16(&gpio->gpio_pbdat, CONFIG_SYS_PBDAT);
379 out_be32(&gpio->gpio_pdcnt, CONFIG_SYS_PDCNT);
wdenkbf9e3b32004-02-12 00:47:09 +0000380
381 /* Memory Controller: */
Alison Wang32dbaaf2012-03-26 21:49:04 +0000382 out_be32(&csctrl->cs_br0, CONFIG_SYS_BR0_PRELIM);
383 out_be32(&csctrl->cs_or0, CONFIG_SYS_OR0_PRELIM);
wdenkbf9e3b32004-02-12 00:47:09 +0000384
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200385#if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM))
Alison Wang32dbaaf2012-03-26 21:49:04 +0000386 out_be32(&csctrl->cs_br1, CONFIG_SYS_BR1_PRELIM);
387 out_be32(&csctrl->cs_or1, CONFIG_SYS_OR1_PRELIM);
wdenkbf9e3b32004-02-12 00:47:09 +0000388#endif
389
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200390#if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
Alison Wang32dbaaf2012-03-26 21:49:04 +0000391 out_be32(&csctrl->cs_br2, CONFIG_SYS_BR2_PRELIM);
392 out_be32(&csctrl->cs_or2, CONFIG_SYS_OR2_PRELIM);
wdenkbf9e3b32004-02-12 00:47:09 +0000393#endif
394
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200395#if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM)
Alison Wang32dbaaf2012-03-26 21:49:04 +0000396 out_be32(&csctrl->cs_br3, CONFIG_SYS_BR3_PRELIM);
397 out_be32(&csctrl->cs_or3, CONFIG_SYS_OR3_PRELIM);
wdenkbf9e3b32004-02-12 00:47:09 +0000398#endif
399
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200400#if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM)
Alison Wang32dbaaf2012-03-26 21:49:04 +0000401 out_be32(&csctrl->cs_br4, CONFIG_SYS_BR4_PRELIM);
402 out_be32(&csctrl->cs_or4, CONFIG_SYS_OR4_PRELIM);
wdenkbf9e3b32004-02-12 00:47:09 +0000403#endif
404
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200405#if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM)
Alison Wang32dbaaf2012-03-26 21:49:04 +0000406 out_be32(&csctrl->cs_br5, CONFIG_SYS_BR5_PRELIM);
407 out_be32(&csctrl->cs_or5, CONFIG_SYS_OR5_PRELIM);
wdenkbf9e3b32004-02-12 00:47:09 +0000408#endif
409
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200410#if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM)
Alison Wang32dbaaf2012-03-26 21:49:04 +0000411 out_be32(&csctrl->cs_br6, CONFIG_SYS_BR6_PRELIM);
412 out_be32(&csctrl->cs_or6, CONFIG_SYS_OR6_PRELIM);
wdenkbf9e3b32004-02-12 00:47:09 +0000413#endif
414
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200415#if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM)
Alison Wang32dbaaf2012-03-26 21:49:04 +0000416 out_be32(&csctrl->cs_br7, CONFIG_SYS_BR7_PRELIM);
417 out_be32(&csctrl->cs_or7, CONFIG_SYS_OR7_PRELIM);
wdenkbf9e3b32004-02-12 00:47:09 +0000418#endif
419
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500420#endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
wdenkbf9e3b32004-02-12 00:47:09 +0000421
Wolfgang Denk977b50f2006-05-10 17:43:20 +0200422 /* enable instruction cache now */
423 icache_enable();
wdenkbf9e3b32004-02-12 00:47:09 +0000424
425}
426
427/*
428 * initialize higher level parts of CPU like timers
429 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500430int cpu_init_r(void)
wdenkbf9e3b32004-02-12 00:47:09 +0000431{
432 return (0);
433}
wdenkbf9e3b32004-02-12 00:47:09 +0000434
TsiChung Liew52affe02010-03-09 19:17:52 -0600435void uart_port_conf(int port)
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500436{
Alison Wang32dbaaf2012-03-26 21:49:04 +0000437 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
wdenkbf9e3b32004-02-12 00:47:09 +0000438
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500439 /* Setup Ports: */
TsiChung Liew52affe02010-03-09 19:17:52 -0600440 switch (port) {
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500441 case 0:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000442 clrbits_be32(&gpio->gpio_pbcnt,
443 GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK);
444 setbits_be32(&gpio->gpio_pbcnt,
445 GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500446 break;
447 case 1:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000448 clrbits_be32(&gpio->gpio_pdcnt,
449 GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK);
450 setbits_be32(&gpio->gpio_pdcnt,
451 GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500452 break;
453 }
454}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000455
456#if defined(CONFIG_CMD_NET)
457int fecpin_setclear(struct eth_device *dev, int setclear)
458{
Alison Wang32dbaaf2012-03-26 21:49:04 +0000459 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
TsiChung Liewf3962d32008-10-21 13:47:54 +0000460
461 if (setclear) {
Alison Wang32dbaaf2012-03-26 21:49:04 +0000462 setbits_be32(&gpio->gpio_pbcnt,
463 GPIO_PBCNT_E_MDC | GPIO_PBCNT_E_RXER |
464 GPIO_PBCNT_E_RXD1 | GPIO_PBCNT_E_RXD2 |
465 GPIO_PBCNT_E_RXD3 | GPIO_PBCNT_E_TXD1 |
466 GPIO_PBCNT_E_TXD2 | GPIO_PBCNT_E_TXD3);
TsiChung Liewf3962d32008-10-21 13:47:54 +0000467 } else {
468 }
469 return 0;
470}
471#endif /* CONFIG_CMD_NET */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500472#endif /* #if defined(CONFIG_M5272) */
473
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600474#if defined(CONFIG_M5275)
475
476/*
477 * Breathe some life into the CPU...
478 *
479 * Set up the memory map,
480 * initialize a bunch of registers,
481 * initialize the UPM's
482 */
483void cpu_init_f(void)
484{
TsiChung Liew012522f2008-10-21 10:03:07 +0000485 /*
486 * if we come from RAM we assume the CPU is
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600487 * already initialized.
488 */
489
490#ifndef CONFIG_MONITOR_IS_IN_RAM
Alison Wang32dbaaf2012-03-26 21:49:04 +0000491 wdog_t *wdog_reg = (wdog_t *) (MMAP_WDOG);
492 gpio_t *gpio_reg = (gpio_t *) (MMAP_GPIO);
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600493
494 /* Kill watchdog so we can initialize the PLL */
Alison Wang32dbaaf2012-03-26 21:49:04 +0000495 out_be16(&wdog_reg->wcr, 0);
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600496
TsiChung Liew012522f2008-10-21 10:03:07 +0000497 /* FlexBus Chipselect */
498 init_fbcs();
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600499#endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
500
501#ifdef CONFIG_FSL_I2C
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200502 CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
503 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600504#endif
505
506 /* enable instruction cache now */
507 icache_enable();
508}
509
510/*
511 * initialize higher level parts of CPU like timers
512 */
513int cpu_init_r(void)
514{
515 return (0);
516}
517
TsiChung Liew52affe02010-03-09 19:17:52 -0600518void uart_port_conf(int port)
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600519{
Alison Wang32dbaaf2012-03-26 21:49:04 +0000520 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600521
522 /* Setup Ports: */
TsiChung Liew52affe02010-03-09 19:17:52 -0600523 switch (port) {
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600524 case 0:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000525 clrbits_be16(&gpio->par_uart, UART0_ENABLE_MASK);
526 setbits_be16(&gpio->par_uart, UART0_ENABLE_MASK);
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600527 break;
528 case 1:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000529 clrbits_be16(&gpio->par_uart, UART1_ENABLE_MASK);
530 setbits_be16(&gpio->par_uart, UART1_ENABLE_MASK);
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600531 break;
532 case 2:
Alison Wang32dbaaf2012-03-26 21:49:04 +0000533 clrbits_be16(&gpio->par_uart, UART2_ENABLE_MASK);
534 setbits_be16(&gpio->par_uart, UART2_ENABLE_MASK);
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600535 break;
536 }
537}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000538
539#if defined(CONFIG_CMD_NET)
540int fecpin_setclear(struct eth_device *dev, int setclear)
541{
542 struct fec_info_s *info = (struct fec_info_s *) dev->priv;
Alison Wang32dbaaf2012-03-26 21:49:04 +0000543 gpio_t *gpio = (gpio_t *)MMAP_GPIO;
TsiChung Liewf3962d32008-10-21 13:47:54 +0000544
545 if (setclear) {
546 /* Enable Ethernet pins */
547 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
Alison Wang32dbaaf2012-03-26 21:49:04 +0000548 setbits_be16(&gpio->par_feci2c, 0x0f00);
549 setbits_8(&gpio->par_fec0hl, 0xc0);
TsiChung Liewf3962d32008-10-21 13:47:54 +0000550 } else {
Alison Wang32dbaaf2012-03-26 21:49:04 +0000551 setbits_be16(&gpio->par_feci2c, 0x00a0);
552 setbits_8(&gpio->par_fec1hl, 0xc0);
TsiChung Liewf3962d32008-10-21 13:47:54 +0000553 }
554 } else {
555 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
Alison Wang32dbaaf2012-03-26 21:49:04 +0000556 clrbits_be16(&gpio->par_feci2c, 0x0f00);
557 clrbits_8(&gpio->par_fec0hl, 0xc0);
TsiChung Liewf3962d32008-10-21 13:47:54 +0000558 } else {
Alison Wang32dbaaf2012-03-26 21:49:04 +0000559 clrbits_be16(&gpio->par_feci2c, 0x00a0);
560 clrbits_8(&gpio->par_fec1hl, 0xc0);
TsiChung Liewf3962d32008-10-21 13:47:54 +0000561 }
562 }
563
564 return 0;
565}
566#endif /* CONFIG_CMD_NET */
Matthew Fettkef71d9d92008-02-04 15:38:20 -0600567#endif /* #if defined(CONFIG_M5275) */
568
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500569#if defined(CONFIG_M5282)
wdenkbf9e3b32004-02-12 00:47:09 +0000570/*
571 * Breath some life into the CPU...
572 *
573 * Set up the memory map,
574 * initialize a bunch of registers,
575 * initialize the UPM's
576 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500577void cpu_init_f(void)
wdenkbf9e3b32004-02-12 00:47:09 +0000578{
Heiko Schocher9acb6262006-04-20 08:42:42 +0200579#ifndef CONFIG_WATCHDOG
580 /* disable watchdog if we aren't using it */
581 MCFWTM_WCR = 0;
582#endif
wdenkbf9e3b32004-02-12 00:47:09 +0000583
Heiko Schocher9acb6262006-04-20 08:42:42 +0200584#ifndef CONFIG_MONITOR_IS_IN_RAM
585 /* Set speed /PLL */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500586 MCFCLOCK_SYNCR =
TsiChung Liew012522f2008-10-21 10:03:07 +0000587 MCFCLOCK_SYNCR_MFD(CONFIG_SYS_MFD) |
588 MCFCLOCK_SYNCR_RFD(CONFIG_SYS_RFD);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500589 while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ;
590
591 MCFGPIO_PBCDPAR = 0xc0;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200592
593 /* Set up the GPIO ports */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200594#ifdef CONFIG_SYS_PEPAR
595 MCFGPIO_PEPAR = CONFIG_SYS_PEPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200596#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200597#ifdef CONFIG_SYS_PFPAR
598 MCFGPIO_PFPAR = CONFIG_SYS_PFPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200599#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200600#ifdef CONFIG_SYS_PJPAR
601 MCFGPIO_PJPAR = CONFIG_SYS_PJPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200602#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200603#ifdef CONFIG_SYS_PSDPAR
604 MCFGPIO_PSDPAR = CONFIG_SYS_PSDPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200605#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200606#ifdef CONFIG_SYS_PASPAR
607 MCFGPIO_PASPAR = CONFIG_SYS_PASPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200608#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200609#ifdef CONFIG_SYS_PEHLPAR
610 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200611#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200612#ifdef CONFIG_SYS_PQSPAR
613 MCFGPIO_PQSPAR = CONFIG_SYS_PQSPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200614#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200615#ifdef CONFIG_SYS_PTCPAR
616 MCFGPIO_PTCPAR = CONFIG_SYS_PTCPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200617#endif
Michael Durrantdfc2b762010-01-20 19:33:02 -0600618#if defined(CONFIG_SYS_PORTTC)
619 MCFGPIO_PORTTC = CONFIG_SYS_PORTTC;
620#endif
621#if defined(CONFIG_SYS_DDRTC)
622 MCFGPIO_DDRTC = CONFIG_SYS_DDRTC;
623#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200624#ifdef CONFIG_SYS_PTDPAR
625 MCFGPIO_PTDPAR = CONFIG_SYS_PTDPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200626#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200627#ifdef CONFIG_SYS_PUAPAR
628 MCFGPIO_PUAPAR = CONFIG_SYS_PUAPAR;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200629#endif
630
Michael Durrantdfc2b762010-01-20 19:33:02 -0600631#if defined(CONFIG_SYS_DDRD)
632 MCFGPIO_DDRD = CONFIG_SYS_DDRD;
633#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200634#ifdef CONFIG_SYS_DDRUA
635 MCFGPIO_DDRUA = CONFIG_SYS_DDRUA;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200636#endif
637
TsiChung Liew012522f2008-10-21 10:03:07 +0000638 /* FlexBus Chipselect */
639 init_fbcs();
Heiko Schocher9acb6262006-04-20 08:42:42 +0200640
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500641#endif /* CONFIG_MONITOR_IS_IN_RAM */
Heiko Schocher9acb6262006-04-20 08:42:42 +0200642
643 /* defer enabling cache until boot (see do_go) */
644 /* icache_enable(); */
wdenkbf9e3b32004-02-12 00:47:09 +0000645}
646
647/*
648 * initialize higher level parts of CPU like timers
649 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500650int cpu_init_r(void)
wdenkbf9e3b32004-02-12 00:47:09 +0000651{
652 return (0);
653}
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500654
TsiChung Liew52affe02010-03-09 19:17:52 -0600655void uart_port_conf(int port)
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500656{
657 /* Setup Ports: */
TsiChung Liew52affe02010-03-09 19:17:52 -0600658 switch (port) {
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500659 case 0:
660 MCFGPIO_PUAPAR &= 0xFc;
661 MCFGPIO_PUAPAR |= 0x03;
662 break;
663 case 1:
664 MCFGPIO_PUAPAR &= 0xF3;
665 MCFGPIO_PUAPAR |= 0x0C;
666 break;
667 case 2:
668 MCFGPIO_PASPAR &= 0xFF0F;
669 MCFGPIO_PASPAR |= 0x00A0;
670 break;
671 }
672}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000673
674#if defined(CONFIG_CMD_NET)
675int fecpin_setclear(struct eth_device *dev, int setclear)
676{
677 if (setclear) {
678 MCFGPIO_PASPAR |= 0x0F00;
679 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
680 } else {
681 MCFGPIO_PASPAR &= 0xF0FF;
682 MCFGPIO_PEHLPAR &= ~CONFIG_SYS_PEHLPAR;
683 }
684 return 0;
685}
686#endif /* CONFIG_CMD_NET */
wdenkbf9e3b32004-02-12 00:47:09 +0000687#endif
stroese8c725b92004-12-16 18:09:49 +0000688
689#if defined(CONFIG_M5249)
690/*
691 * Breath some life into the CPU...
692 *
693 * Set up the memory map,
694 * initialize a bunch of registers,
695 * initialize the UPM's
696 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500697void cpu_init_f(void)
stroese8c725b92004-12-16 18:09:49 +0000698{
stroese8c725b92004-12-16 18:09:49 +0000699 /*
700 * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500701 * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins
702 * which is their primary function.
703 * ~Jeremy
stroese8c725b92004-12-16 18:09:49 +0000704 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200705 mbar2_writeLong(MCFSIM_GPIO_FUNC, CONFIG_SYS_GPIO_FUNC);
706 mbar2_writeLong(MCFSIM_GPIO1_FUNC, CONFIG_SYS_GPIO1_FUNC);
707 mbar2_writeLong(MCFSIM_GPIO_EN, CONFIG_SYS_GPIO_EN);
708 mbar2_writeLong(MCFSIM_GPIO1_EN, CONFIG_SYS_GPIO1_EN);
709 mbar2_writeLong(MCFSIM_GPIO_OUT, CONFIG_SYS_GPIO_OUT);
710 mbar2_writeLong(MCFSIM_GPIO1_OUT, CONFIG_SYS_GPIO1_OUT);
stroese8c725b92004-12-16 18:09:49 +0000711
712 /*
713 * dBug Compliance:
714 * You can verify these values by using dBug's 'ird'
715 * (Internal Register Display) command
716 * ~Jeremy
717 *
Wolfgang Denk977b50f2006-05-10 17:43:20 +0200718 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500719 mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */
stroese8c725b92004-12-16 18:09:49 +0000720 mbar_writeByte(MCFSIM_SYPCR, 0x00);
721 mbar_writeByte(MCFSIM_SWIVR, 0x0f);
722 mbar_writeByte(MCFSIM_SWSR, 0x00);
723 mbar_writeLong(MCFSIM_IMR, 0xfffffbff);
724 mbar_writeByte(MCFSIM_SWDICR, 0x00);
725 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
726 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
727 mbar_writeByte(MCFSIM_I2CICR, 0x00);
728 mbar_writeByte(MCFSIM_UART1ICR, 0x00);
729 mbar_writeByte(MCFSIM_UART2ICR, 0x00);
730 mbar_writeByte(MCFSIM_ICR6, 0x00);
731 mbar_writeByte(MCFSIM_ICR7, 0x00);
732 mbar_writeByte(MCFSIM_ICR8, 0x00);
733 mbar_writeByte(MCFSIM_ICR9, 0x00);
734 mbar_writeByte(MCFSIM_QSPIICR, 0x00);
735
736 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
Wolfgang Denk977b50f2006-05-10 17:43:20 +0200737 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
stroese8c725b92004-12-16 18:09:49 +0000738 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500739 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */
stroese8c725b92004-12-16 18:09:49 +0000740
741 /* Setup interrupt priorities for gpio7 */
742 /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */
743
744 /* IDE Config registers */
745 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020);
746 mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000);
747
TsiChung Liew012522f2008-10-21 10:03:07 +0000748 /* FlexBus Chipselect */
749 init_fbcs();
stroese8c725b92004-12-16 18:09:49 +0000750
751 /* enable instruction cache now */
752 icache_enable();
753}
754
755/*
756 * initialize higher level parts of CPU like timers
757 */
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500758int cpu_init_r(void)
stroese8c725b92004-12-16 18:09:49 +0000759{
760 return (0);
761}
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500762
TsiChung Liew52affe02010-03-09 19:17:52 -0600763void uart_port_conf(int port)
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500764{
TsiChungLiew83ec20b2007-08-15 19:21:21 -0500765}
766#endif /* #if defined(CONFIG_M5249) */