blob: 687c7e42ec4135873939a4e3ff8fd027a4f6c71f [file] [log] [blame]
TsiChung Liew8e585f02007-06-18 13:50:13 -05001/*
2 *
3 * (C) Copyright 2000-2003
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
TsiChung Liew536e7da2008-10-22 11:38:21 +00006 * (C) Copyright 2004-2008 Freescale Semiconductor, Inc.
TsiChung Liew8e585f02007-06-18 13:50:13 -05007 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28#include <common.h>
29#include <watchdog.h>
TsiChungLiew84a015b2007-07-05 23:03:28 -050030#include <asm/immap.h>
TsiChung Liew8e585f02007-06-18 13:50:13 -050031
TsiChung Liewf3962d32008-10-21 13:47:54 +000032#if defined(CONFIG_CMD_NET)
33#include <config.h>
34#include <net.h>
35#include <asm/fec.h>
36#endif
37
TsiChung Liew536e7da2008-10-22 11:38:21 +000038#ifdef CONFIG_MCF5301x
39void cpu_init_f(void)
40{
41 volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
42 volatile scm2_t *scm2 = (scm2_t *) MMAP_SCM2;
43 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
44 volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
45
46 /* watchdog is enabled by default - disable the watchdog */
47#ifndef CONFIG_WATCHDOG
48 /*wdog->cr = 0; */
49#endif
50
51 scm1->mpr = 0x77777777;
52 scm1->pacra = 0;
53 scm1->pacrb = 0;
54 scm1->pacrc = 0;
55 scm1->pacrd = 0;
56 scm1->pacre = 0;
57 scm1->pacrf = 0;
58 scm1->pacrg = 0;
59
60#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
61 && defined(CONFIG_SYS_CS0_CTRL))
62 gpio->par_cs |= GPIO_PAR_CS0_CS0;
63 fbcs->csar0 = CONFIG_SYS_CS0_BASE;
64 fbcs->cscr0 = CONFIG_SYS_CS0_CTRL;
65 fbcs->csmr0 = CONFIG_SYS_CS0_MASK;
66#endif
67
68#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
69 && defined(CONFIG_SYS_CS1_CTRL))
70 gpio->par_cs |= GPIO_PAR_CS1_CS1;
71 fbcs->csar1 = CONFIG_SYS_CS1_BASE;
72 fbcs->cscr1 = CONFIG_SYS_CS1_CTRL;
73 fbcs->csmr1 = CONFIG_SYS_CS1_MASK;
74#endif
75
76#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
77 && defined(CONFIG_SYS_CS2_CTRL))
78 fbcs->csar2 = CONFIG_SYS_CS2_BASE;
79 fbcs->cscr2 = CONFIG_SYS_CS2_CTRL;
80 fbcs->csmr2 = CONFIG_SYS_CS2_MASK;
81#endif
82
83#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
84 && defined(CONFIG_SYS_CS3_CTRL))
85 fbcs->csar3 = CONFIG_SYS_CS3_BASE;
86 fbcs->cscr3 = CONFIG_SYS_CS3_CTRL;
87 fbcs->csmr3 = CONFIG_SYS_CS3_MASK;
88#endif
89
90#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
91 && defined(CONFIG_SYS_CS4_CTRL))
92 gpio->par_cs |= GPIO_PAR_CS4;
93 fbcs->csar4 = CONFIG_SYS_CS4_BASE;
94 fbcs->cscr4 = CONFIG_SYS_CS4_CTRL;
95 fbcs->csmr4 = CONFIG_SYS_CS4_MASK;
96#endif
97
98#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
99 && defined(CONFIG_SYS_CS5_CTRL))
100 gpio->par_cs |= GPIO_PAR_CS5;
101 fbcs->csar5 = CONFIG_SYS_CS5_BASE;
102 fbcs->cscr5 = CONFIG_SYS_CS5_CTRL;
103 fbcs->csmr5 = CONFIG_SYS_CS5_MASK;
104#endif
105
106#ifdef CONFIG_FSL_I2C
107 gpio->par_feci2c = GPIO_PAR_FECI2C_SDA_SDA | GPIO_PAR_FECI2C_SCL_SCL;
108#endif
109
110 icache_enable();
111}
112
113/* initialize higher level parts of CPU like timers */
114int cpu_init_r(void)
115{
116#ifdef CONFIG_MCFFEC
117 volatile ccm_t *ccm = (ccm_t *) MMAP_CCM;
118#endif
119#ifdef CONFIG_MCFRTC
120 volatile rtc_t *rtc = (rtc_t *) (CONFIG_SYS_MCFRTC_BASE);
121 volatile rtcex_t *rtcex = (rtcex_t *) & rtc->extended;
122
123 rtcex->gocu = CONFIG_SYS_RTC_CNT;
124 rtcex->gocl = CONFIG_SYS_RTC_SETUP;
125
126#endif
127#ifdef CONFIG_MCFFEC
128 if (CONFIG_SYS_FEC0_MIIBASE != CONFIG_SYS_FEC1_MIIBASE)
129 ccm->misccr |= CCM_MISCCR_FECM;
130 else
131 ccm->misccr &= ~CCM_MISCCR_FECM;
132#endif
133
134 return (0);
135}
136
137void uart_port_conf(void)
138{
139 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
140
141 /* Setup Ports: */
142 switch (CONFIG_SYS_UART_PORT) {
143 case 0:
144 gpio->par_uart = (GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
145 break;
146 case 1:
147#ifdef CONFIG_SYS_UART1_ALT1_GPIO
148 gpio->par_simp1h &=
149 ~(GPIO_PAR_SIMP1H_DATA1_MASK | GPIO_PAR_SIMP1H_VEN1_MASK);
150 gpio->par_simp1h |=
151 (GPIO_PAR_SIMP1H_DATA1_U1TXD | GPIO_PAR_SIMP1H_VEN1_U1RXD);
152#elif defined(CONFIG_SYS_UART1_ALT2_GPIO)
153 gpio->par_ssih &=
154 ~(GPIO_PAR_SSIH_RXD_MASK | GPIO_PAR_SSIH_TXD_MASK);
155 gpio->par_ssih |=
156 (GPIO_PAR_SSIH_RXD_U1RXD | GPIO_PAR_SSIH_TXD_U1TXD);
157#endif
158 break;
159 case 2:
160#ifdef CONFIG_SYS_UART2_PRI_GPIO
161 gpio->par_uart |= (GPIO_PAR_UART_U2TXD | GPIO_PAR_UART_U2RXD);
162#elif defined(CONFIG_SYS_UART2_ALT1_GPIO)
163 gpio->par_dspih &=
164 ~(GPIO_PAR_DSPIH_SIN_MASK | GPIO_PAR_DSPIH_SOUT_MASK);
165 gpio->par_dspih |=
166 (GPIO_PAR_DSPIH_SIN_U2RXD | GPIO_PAR_DSPIH_SOUT_U2TXD);
167#elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
168 gpio->par_feci2c &=
169 ~(GPIO_PAR_FECI2C_SDA_MASK | GPIO_PAR_FECI2C_SCL_MASK);
170 gpio->par_feci2c |=
171 (GPIO_PAR_FECI2C_SDA_U2TXD | GPIO_PAR_FECI2C_SCL_U2RXD);
172#endif
173 break;
174 }
175}
176
177#if defined(CONFIG_CMD_NET)
178int fecpin_setclear(struct eth_device *dev, int setclear)
179{
180 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
181 struct fec_info_s *info = (struct fec_info_s *)dev->priv;
182
183 if (setclear) {
184 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
185 gpio->par_fec |=
186 GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC;
187 gpio->par_feci2c |=
188 GPIO_PAR_FECI2C_MDC0 | GPIO_PAR_FECI2C_MDIO0;
189 } else {
190 gpio->par_fec |=
191 GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC;
192 gpio->par_feci2c |=
193 GPIO_PAR_FECI2C_MDC1 | GPIO_PAR_FECI2C_MDIO1;
194 }
195 } else {
196 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
197 gpio->par_fec &=
198 ~(GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC);
199 gpio->par_feci2c &= GPIO_PAR_FECI2C_RMII0_MASK;
200 } else {
201 gpio->par_fec &=
202 ~(GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC);
203 gpio->par_feci2c &= GPIO_PAR_FECI2C_RMII1_MASK;
204 }
205 }
206 return 0;
207}
208#endif /* CONFIG_CMD_NET */
209#endif /* CONFIG_MCF5301x */
210
211#ifdef CONFIG_MCF532x
TsiChung Liew8e585f02007-06-18 13:50:13 -0500212void cpu_init_f(void)
213{
214 volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
215 volatile scm2_t *scm2 = (scm2_t *) MMAP_SCM2;
216 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
217 volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
218 volatile wdog_t *wdog = (wdog_t *) MMAP_WDOG;
219
220 /* watchdog is enabled by default - disable the watchdog */
221#ifndef CONFIG_WATCHDOG
222 wdog->cr = 0;
223#endif
224
225 scm1->mpr0 = 0x77777777;
226 scm2->pacra = 0;
227 scm2->pacrb = 0;
228 scm2->pacrc = 0;
229 scm2->pacrd = 0;
230 scm2->pacre = 0;
231 scm2->pacrf = 0;
232 scm2->pacrg = 0;
233 scm1->pacrh = 0;
234
TsiChung Liew8e585f02007-06-18 13:50:13 -0500235 /* Port configuration */
TsiChungLiewa41de1f2007-08-05 05:15:18 -0500236 gpio->par_cs = 0;
TsiChung Liew8e585f02007-06-18 13:50:13 -0500237
TsiChung Liew536e7da2008-10-22 11:38:21 +0000238#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
239 && defined(CONFIG_SYS_CS0_CTRL))
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200240 fbcs->csar0 = CONFIG_SYS_CS0_BASE;
241 fbcs->cscr0 = CONFIG_SYS_CS0_CTRL;
242 fbcs->csmr0 = CONFIG_SYS_CS0_MASK;
TsiChung Liew8e585f02007-06-18 13:50:13 -0500243#endif
244
TsiChung Liew536e7da2008-10-22 11:38:21 +0000245#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
246 && defined(CONFIG_SYS_CS1_CTRL))
TsiChung Liew8e585f02007-06-18 13:50:13 -0500247 /* Latch chipselect */
Stefan Roese3ba4c2d2007-08-08 09:54:26 +0200248 gpio->par_cs |= GPIO_PAR_CS1;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200249 fbcs->csar1 = CONFIG_SYS_CS1_BASE;
250 fbcs->cscr1 = CONFIG_SYS_CS1_CTRL;
251 fbcs->csmr1 = CONFIG_SYS_CS1_MASK;
TsiChung Liew8e585f02007-06-18 13:50:13 -0500252#endif
253
TsiChung Liew536e7da2008-10-22 11:38:21 +0000254#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
255 && defined(CONFIG_SYS_CS2_CTRL))
Stefan Roese3ba4c2d2007-08-08 09:54:26 +0200256 gpio->par_cs |= GPIO_PAR_CS2;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200257 fbcs->csar2 = CONFIG_SYS_CS2_BASE;
258 fbcs->cscr2 = CONFIG_SYS_CS2_CTRL;
259 fbcs->csmr2 = CONFIG_SYS_CS2_MASK;
TsiChung Liew8e585f02007-06-18 13:50:13 -0500260#endif
261
TsiChung Liew536e7da2008-10-22 11:38:21 +0000262#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
263 && defined(CONFIG_SYS_CS3_CTRL))
Stefan Roese3ba4c2d2007-08-08 09:54:26 +0200264 gpio->par_cs |= GPIO_PAR_CS3;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200265 fbcs->csar3 = CONFIG_SYS_CS3_BASE;
266 fbcs->cscr3 = CONFIG_SYS_CS3_CTRL;
267 fbcs->csmr3 = CONFIG_SYS_CS3_MASK;
TsiChung Liew8e585f02007-06-18 13:50:13 -0500268#endif
269
TsiChung Liew536e7da2008-10-22 11:38:21 +0000270#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
271 && defined(CONFIG_SYS_CS4_CTRL))
Stefan Roese3ba4c2d2007-08-08 09:54:26 +0200272 gpio->par_cs |= GPIO_PAR_CS4;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200273 fbcs->csar4 = CONFIG_SYS_CS4_BASE;
274 fbcs->cscr4 = CONFIG_SYS_CS4_CTRL;
275 fbcs->csmr4 = CONFIG_SYS_CS4_MASK;
TsiChung Liew8e585f02007-06-18 13:50:13 -0500276#endif
277
TsiChung Liew536e7da2008-10-22 11:38:21 +0000278#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
279 && defined(CONFIG_SYS_CS5_CTRL))
Stefan Roese3ba4c2d2007-08-08 09:54:26 +0200280 gpio->par_cs |= GPIO_PAR_CS5;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200281 fbcs->csar5 = CONFIG_SYS_CS5_BASE;
282 fbcs->cscr5 = CONFIG_SYS_CS5_CTRL;
283 fbcs->csmr5 = CONFIG_SYS_CS5_MASK;
TsiChung Liew8e585f02007-06-18 13:50:13 -0500284#endif
TsiChung0dca8742007-07-10 15:45:43 -0500285
TsiChungLiewa41de1f2007-08-05 05:15:18 -0500286#ifdef CONFIG_FSL_I2C
287 gpio->par_feci2c = GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA;
288#endif
289
TsiChung0dca8742007-07-10 15:45:43 -0500290 icache_enable();
TsiChung Liew8e585f02007-06-18 13:50:13 -0500291}
292
293/*
294 * initialize higher level parts of CPU like timers
295 */
296int cpu_init_r(void)
297{
TsiChung Liew8e585f02007-06-18 13:50:13 -0500298 return (0);
299}
TsiChungLiew8d1d66a2007-08-05 03:55:21 -0500300
301void uart_port_conf(void)
302{
303 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
304
305 /* Setup Ports: */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200306 switch (CONFIG_SYS_UART_PORT) {
TsiChungLiew8d1d66a2007-08-05 03:55:21 -0500307 case 0:
308 gpio->par_uart = (GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0);
309 break;
310 case 1:
311 gpio->par_uart =
312 (GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3));
313 break;
314 case 2:
315 gpio->par_timer &= 0x0F;
316 gpio->par_timer |= (GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2);
317 break;
318 }
319}
TsiChung Liewf3962d32008-10-21 13:47:54 +0000320
321#if defined(CONFIG_CMD_NET)
322int fecpin_setclear(struct eth_device *dev, int setclear)
323{
324 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
325
326 if (setclear) {
327 gpio->par_fec |= GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC;
328 gpio->par_feci2c |=
329 GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO;
330 } else {
331 gpio->par_fec &= ~(GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
332 gpio->par_feci2c &=
333 ~(GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO);
334 }
335 return 0;
336}
337#endif
TsiChung Liew536e7da2008-10-22 11:38:21 +0000338#endif /* CONFIG_MCF532x */