blob: 134510b00f9f4b9d68e8c6c905cab8632f95b587 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -05002/*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Alison Wang8d8dac92012-03-26 21:49:08 +00007 * (C) Copyright 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -05008 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -05009 */
10
11#include <common.h>
12#include <watchdog.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050013#include <asm/immap.h>
TsiChung Liew4d5414d2010-03-11 15:04:21 -060014#include <asm/processor.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050015#include <asm/rtc.h>
Alison Wang8d8dac92012-03-26 21:49:08 +000016#include <asm/io.h>
Marek Vasuta334ec92012-10-03 13:28:44 +000017#include <linux/compiler.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050018
TsiChung Liew69b17572008-10-21 13:47:54 +000019#if defined(CONFIG_CMD_NET)
20#include <config.h>
21#include <net.h>
22#include <asm/fec.h>
23#endif
24
Alison Wangfdc2fb12012-10-18 19:25:51 +000025void init_fbcs(void)
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050026{
Marek Vasuta334ec92012-10-03 13:28:44 +000027 fbcs_t *fbcs __maybe_unused = (fbcs_t *) MMAP_FBCS;
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050028
Alison Wangfdc2fb12012-10-18 19:25:51 +000029#if !defined(CONFIG_SERIAL_BOOT)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020030#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000031 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
32 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
33 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050034#endif
TsiChung Liew23cf8fd2008-07-23 20:38:53 -050035#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050036
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020037#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050038 /* Latch chipselect */
Alison Wang8d8dac92012-03-26 21:49:08 +000039 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
40 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
41 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050042#endif
43
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020044#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000045 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
46 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
47 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050048#endif
49
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020050#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000051 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
52 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
53 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050054#endif
55
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020056#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000057 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
58 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
59 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050060#endif
61
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020062#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000063 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
64 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
65 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050066#endif
Alison Wangfdc2fb12012-10-18 19:25:51 +000067}
68
Angelo Dureghello71abddd2019-03-13 21:46:52 +010069#ifdef CONFIG_CF_DSPI
70void cfspi_port_conf(void)
71{
72 gpio_t *gpio = (gpio_t *)MMAP_GPIO;
73
74#ifdef CONFIG_MCF5445x
75 out_8(&gpio->par_dspi,
76 GPIO_PAR_DSPI_SIN_SIN |
77 GPIO_PAR_DSPI_SOUT_SOUT |
78 GPIO_PAR_DSPI_SCK_SCK);
79#endif
80
81#ifdef CONFIG_MCF5441x
82 pm_t *pm = (pm_t *)MMAP_PM;
83
84 out_8(&gpio->par_dspi0,
85 GPIO_PAR_DSPI0_SIN_DSPI0SIN | GPIO_PAR_DSPI0_SOUT_DSPI0SOUT |
86 GPIO_PAR_DSPI0_SCK_DSPI0SCK);
87 out_8(&gpio->srcr_dspiow, 3);
88
89 /* DSPI0 */
90 out_8(&pm->pmcr0, 23);
91#endif
92}
93#endif
94
Alison Wangfdc2fb12012-10-18 19:25:51 +000095/*
96 * Breath some life into the CPU...
97 *
98 * Set up the memory map,
99 * initialize a bunch of registers,
100 * initialize the UPM's
101 */
102void cpu_init_f(void)
103{
104 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
105
106#ifdef CONFIG_MCF5441x
107 scm_t *scm = (scm_t *) MMAP_SCM;
108 pm_t *pm = (pm_t *) MMAP_PM;
109
110 /* Disable Switch */
111 *(unsigned long *)(MMAP_L2_SW0 + 0x00000024) = 0;
112
113 /* Disable core watchdog */
114 out_be16(&scm->cwcr, 0);
115 out_8(&gpio->par_fbctl,
116 GPIO_PAR_FBCTL_ALE_FB_ALE | GPIO_PAR_FBCTL_OE_FB_OE |
117 GPIO_PAR_FBCTL_FBCLK | GPIO_PAR_FBCTL_RW |
118 GPIO_PAR_FBCTL_TA_TA);
119 out_8(&gpio->par_be,
120 GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
121 GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
122
123 /* eDMA */
124 out_8(&pm->pmcr0, 17);
125
126 /* INTR0 - INTR2 */
127 out_8(&pm->pmcr0, 18);
128 out_8(&pm->pmcr0, 19);
129 out_8(&pm->pmcr0, 20);
130
131 /* I2C */
132 out_8(&pm->pmcr0, 22);
133 out_8(&pm->pmcr1, 4);
134 out_8(&pm->pmcr1, 7);
135
136 /* DTMR0 - DTMR3*/
137 out_8(&pm->pmcr0, 28);
138 out_8(&pm->pmcr0, 29);
139 out_8(&pm->pmcr0, 30);
140 out_8(&pm->pmcr0, 31);
141
142 /* PIT0 - PIT3 */
143 out_8(&pm->pmcr0, 32);
144 out_8(&pm->pmcr0, 33);
145 out_8(&pm->pmcr0, 34);
146 out_8(&pm->pmcr0, 35);
147
148 /* Edge Port */
149 out_8(&pm->pmcr0, 36);
150 out_8(&pm->pmcr0, 37);
151
152 /* USB OTG */
153 out_8(&pm->pmcr0, 44);
154 /* USB Host */
155 out_8(&pm->pmcr0, 45);
156
157 /* ESDHC */
158 out_8(&pm->pmcr0, 51);
159
160 /* ENET0 - ENET1 */
161 out_8(&pm->pmcr0, 53);
162 out_8(&pm->pmcr0, 54);
163
164 /* NAND */
165 out_8(&pm->pmcr0, 63);
166
167#ifdef CONFIG_SYS_I2C_0
168 out_8(&gpio->par_cani2c, 0xF0);
169 /* I2C0 pull up */
170 out_be16(&gpio->pcr_b, 0x003C);
171 /* I2C0 max speed */
172 out_8(&gpio->srcr_cani2c, 0x03);
173#endif
174#ifdef CONFIG_SYS_I2C_2
175 /* I2C2 */
176 out_8(&gpio->par_ssi0h, 0xA0);
177 /* I2C2, UART7 */
178 out_8(&gpio->par_ssi0h, 0xA8);
179 /* UART7 */
180 out_8(&gpio->par_ssi0l, 0x2);
181 /* UART8, UART9 */
182 out_8(&gpio->par_cani2c, 0xAA);
183 /* UART4, UART0 */
184 out_8(&gpio->par_uart0, 0xAF);
185 /* UART5, UART1 */
186 out_8(&gpio->par_uart1, 0xAF);
187 /* UART6, UART2 */
188 out_8(&gpio->par_uart2, 0xAF);
189 /* I2C2 pull up */
190 out_be16(&gpio->pcr_h, 0xF000);
191#endif
192#ifdef CONFIG_SYS_I2C_5
193 /* I2C5 */
194 out_8(&gpio->par_uart1, 0x0A);
195 /* I2C5 pull up */
196 out_be16(&gpio->pcr_e, 0x0003);
197 out_be16(&gpio->pcr_f, 0xC000);
198#endif
199
200 /* Lowest slew rate for UART0,1,2 */
201 out_8(&gpio->srcr_uart, 0x00);
Angelo Dureghello95a69982018-01-25 22:42:52 +0100202
Yangbo Lu73340382019-06-21 11:42:28 +0800203#ifdef CONFIG_FSL_ESDHC_IMX
Angelo Dureghello95a69982018-01-25 22:42:52 +0100204 /* eSDHC pin as faster speed */
205 out_8(&gpio->srcr_sdhc, 0x03);
206
207 /* All esdhc pins as SD */
208 out_8(&gpio->par_sdhch, 0xff);
209 out_8(&gpio->par_sdhcl, 0xff);
210#endif
Alison Wangfdc2fb12012-10-18 19:25:51 +0000211#endif /* CONFIG_MCF5441x */
212
213#ifdef CONFIG_MCF5445x
214 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
215
216 out_be32(&scm1->mpr, 0x77777777);
217 out_be32(&scm1->pacra, 0);
218 out_be32(&scm1->pacrb, 0);
219 out_be32(&scm1->pacrc, 0);
220 out_be32(&scm1->pacrd, 0);
221 out_be32(&scm1->pacre, 0);
222 out_be32(&scm1->pacrf, 0);
223 out_be32(&scm1->pacrg, 0);
224
225 /* FlexBus */
226 out_8(&gpio->par_be,
227 GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
228 GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
229 out_8(&gpio->par_fbctl,
230 GPIO_PAR_FBCTL_OE | GPIO_PAR_FBCTL_TA_TA |
231 GPIO_PAR_FBCTL_RW_RW | GPIO_PAR_FBCTL_TS_TS);
232
Angelo Dureghello71abddd2019-03-13 21:46:52 +0100233#ifdef CONFIG_CF_SPI
234 cfspi_port_conf();
235#endif
236
Heiko Schocherf2850742012-10-24 13:48:22 +0200237#ifdef CONFIG_SYS_FSL_I2C
Alison Wangfdc2fb12012-10-18 19:25:51 +0000238 out_be16(&gpio->par_feci2c,
239 GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
240#endif
241#endif /* CONFIG_MCF5445x */
242
243 /* FlexBus Chipselect */
244 init_fbcs();
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500245
Angelo Dureghello7211b922017-05-15 00:17:48 +0200246#ifdef CONFIG_SYS_CS0_BASE
TsiChung Liew4d5414d2010-03-11 15:04:21 -0600247 /*
248 * now the flash base address is no longer at 0 (Newer ColdFire family
249 * boot at address 0 instead of 0xFFnn_nnnn). The vector table must
250 * also move to the new location.
251 */
252 if (CONFIG_SYS_CS0_BASE != 0)
253 setvbr(CONFIG_SYS_CS0_BASE);
Angelo Dureghello7211b922017-05-15 00:17:48 +0200254#endif
TsiChung Liew4d5414d2010-03-11 15:04:21 -0600255
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500256 icache_enable();
257}
258
259/*
260 * initialize higher level parts of CPU like timers
261 */
262int cpu_init_r(void)
263{
TsiChung Liew1be9e092008-07-09 15:47:27 -0500264#ifdef CONFIG_MCFRTC
Alison Wang8d8dac92012-03-26 21:49:08 +0000265 rtc_t *rtc = (rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
266 rtcex_t *rtcex = (rtcex_t *)&rtc->extended;
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500267
Alison Wang8d8dac92012-03-26 21:49:08 +0000268 out_be32(&rtcex->gocu, (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xffff);
269 out_be32(&rtcex->gocl, CONFIG_SYS_RTC_OSCILLATOR & 0xffff);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500270#endif
271
272 return (0);
273}
274
TsiChung Liewf9556a72010-03-09 19:17:52 -0600275void uart_port_conf(int port)
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500276{
Alison Wang8d8dac92012-03-26 21:49:08 +0000277 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Alison Wangfdc2fb12012-10-18 19:25:51 +0000278#ifdef CONFIG_MCF5441x
279 pm_t *pm = (pm_t *) MMAP_PM;
280#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500281
282 /* Setup Ports: */
TsiChung Liewf9556a72010-03-09 19:17:52 -0600283 switch (port) {
Alison Wangfdc2fb12012-10-18 19:25:51 +0000284#ifdef CONFIG_MCF5441x
285 case 0:
286 /* UART0 */
287 out_8(&pm->pmcr0, 24);
288 clrbits_8(&gpio->par_uart0,
289 ~(GPIO_PAR_UART0_U0RXD_MASK | GPIO_PAR_UART0_U0TXD_MASK));
290 setbits_8(&gpio->par_uart0,
291 GPIO_PAR_UART0_U0RXD_U0RXD | GPIO_PAR_UART0_U0TXD_U0TXD);
292 break;
293 case 1:
294 /* UART1 */
295 out_8(&pm->pmcr0, 25);
296 clrbits_8(&gpio->par_uart1,
297 ~(GPIO_PAR_UART1_U1RXD_MASK | GPIO_PAR_UART1_U1TXD_MASK));
298 setbits_8(&gpio->par_uart1,
299 GPIO_PAR_UART1_U1RXD_U1RXD | GPIO_PAR_UART1_U1TXD_U1TXD);
300 break;
301 case 2:
302 /* UART2 */
303 out_8(&pm->pmcr0, 26);
304 clrbits_8(&gpio->par_uart2,
305 ~(GPIO_PAR_UART2_U2RXD_MASK | GPIO_PAR_UART2_U2TXD_MASK));
306 setbits_8(&gpio->par_uart2,
307 GPIO_PAR_UART2_U2RXD_U2RXD | GPIO_PAR_UART2_U2TXD_U2TXD);
308 break;
309 case 3:
310 /* UART3 */
311 out_8(&pm->pmcr0, 27);
312 clrbits_8(&gpio->par_dspi0,
313 ~(GPIO_PAR_DSPI0_SIN_MASK | GPIO_PAR_DSPI0_SOUT_MASK));
314 setbits_8(&gpio->par_dspi0,
315 GPIO_PAR_DSPI0_SIN_U3RXD | GPIO_PAR_DSPI0_SOUT_U3TXD);
316 break;
317 case 4:
318 /* UART4 */
319 out_8(&pm->pmcr1, 24);
320 clrbits_8(&gpio->par_uart0,
321 ~(GPIO_PAR_UART0_U0CTS_MASK | GPIO_PAR_UART0_U0RTS_MASK));
322 setbits_8(&gpio->par_uart0,
323 GPIO_PAR_UART0_U0CTS_U4TXD | GPIO_PAR_UART0_U0RTS_U4RXD);
324 break;
325 case 5:
326 /* UART5 */
327 out_8(&pm->pmcr1, 25);
328 clrbits_8(&gpio->par_uart1,
329 ~(GPIO_PAR_UART1_U1CTS_MASK | GPIO_PAR_UART1_U1RTS_MASK));
330 setbits_8(&gpio->par_uart1,
331 GPIO_PAR_UART1_U1CTS_U5TXD | GPIO_PAR_UART1_U1RTS_U5RXD);
332 break;
333 case 6:
334 /* UART6 */
335 out_8(&pm->pmcr1, 26);
336 clrbits_8(&gpio->par_uart2,
337 ~(GPIO_PAR_UART2_U2CTS_MASK | GPIO_PAR_UART2_U2RTS_MASK));
338 setbits_8(&gpio->par_uart2,
339 GPIO_PAR_UART2_U2CTS_U6TXD | GPIO_PAR_UART2_U2RTS_U6RXD);
340 break;
341 case 7:
342 /* UART7 */
343 out_8(&pm->pmcr1, 27);
344 clrbits_8(&gpio->par_ssi0h, ~GPIO_PAR_SSI0H_RXD_MASK);
345 clrbits_8(&gpio->par_ssi0l, ~GPIO_PAR_SSI0L_BCLK_MASK);
346 setbits_8(&gpio->par_ssi0h, GPIO_PAR_SSI0H_FS_U7TXD);
347 setbits_8(&gpio->par_ssi0l, GPIO_PAR_SSI0L_BCLK_U7RXD);
348 break;
349 case 8:
350 /* UART8 */
351 out_8(&pm->pmcr0, 28);
352 clrbits_8(&gpio->par_cani2c,
353 ~(GPIO_PAR_CANI2C_I2C0SCL_MASK | GPIO_PAR_CANI2C_I2C0SDA_MASK));
354 setbits_8(&gpio->par_cani2c,
355 GPIO_PAR_CANI2C_I2C0SCL_U8TXD | GPIO_PAR_CANI2C_I2C0SDA_U8RXD);
356 break;
357 case 9:
358 /* UART9 */
359 out_8(&pm->pmcr1, 29);
360 clrbits_8(&gpio->par_cani2c,
361 ~(GPIO_PAR_CANI2C_CAN1TX_MASK | GPIO_PAR_CANI2C_CAN1RX_MASK));
362 setbits_8(&gpio->par_cani2c,
363 GPIO_PAR_CANI2C_CAN1TX_U9TXD | GPIO_PAR_CANI2C_CAN1RX_U9RXD);
364 break;
365#endif
366#ifdef CONFIG_MCF5445x
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500367 case 0:
Alison Wang8d8dac92012-03-26 21:49:08 +0000368 clrbits_8(&gpio->par_uart,
369 GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
370 setbits_8(&gpio->par_uart,
371 GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500372 break;
373 case 1:
TsiChung Liewf9556a72010-03-09 19:17:52 -0600374#ifdef CONFIG_SYS_UART1_PRI_GPIO
Alison Wang8d8dac92012-03-26 21:49:08 +0000375 clrbits_8(&gpio->par_uart,
376 GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
377 setbits_8(&gpio->par_uart,
378 GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600379#elif defined(CONFIG_SYS_UART1_ALT1_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000380 clrbits_be16(&gpio->par_ssi,
381 ~(GPIO_PAR_SSI_SRXD_UNMASK | GPIO_PAR_SSI_STXD_UNMASK));
382 setbits_be16(&gpio->par_ssi,
383 GPIO_PAR_SSI_SRXD_U1RXD | GPIO_PAR_SSI_STXD_U1TXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600384#endif
385 break;
386 case 2:
387#if defined(CONFIG_SYS_UART2_ALT1_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000388 clrbits_8(&gpio->par_timer,
389 ~(GPIO_PAR_TIMER_T3IN_UNMASK | GPIO_PAR_TIMER_T2IN_UNMASK));
390 setbits_8(&gpio->par_timer,
391 GPIO_PAR_TIMER_T3IN_U2RXD | GPIO_PAR_TIMER_T2IN_U2TXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600392#elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000393 clrbits_8(&gpio->par_timer,
394 ~(GPIO_PAR_FECI2C_SCL_UNMASK | GPIO_PAR_FECI2C_SDA_UNMASK));
395 setbits_8(&gpio->par_timer,
396 GPIO_PAR_FECI2C_SCL_U2TXD | GPIO_PAR_FECI2C_SDA_U2RXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600397#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500398 break;
Alison Wangfdc2fb12012-10-18 19:25:51 +0000399#endif /* CONFIG_MCF5445x */
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500400 }
TsiChung Liew69b17572008-10-21 13:47:54 +0000401}
402
403#if defined(CONFIG_CMD_NET)
404int fecpin_setclear(struct eth_device *dev, int setclear)
405{
Alison Wang8d8dac92012-03-26 21:49:08 +0000406 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Masahiro Yamada35b2eb72013-10-16 13:53:04 +0900407#ifdef CONFIG_MCF5445x
TsiChung Liew69b17572008-10-21 13:47:54 +0000408 struct fec_info_s *info = (struct fec_info_s *)dev->priv;
409
410 if (setclear) {
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100411#ifdef CONFIG_SYS_FEC_NO_SHARED_PHY
412 if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
Alison Wang8d8dac92012-03-26 21:49:08 +0000413 setbits_be16(&gpio->par_feci2c,
414 GPIO_PAR_FECI2C_MDC0_MDC0 |
415 GPIO_PAR_FECI2C_MDIO0_MDIO0);
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100416 else
Alison Wang8d8dac92012-03-26 21:49:08 +0000417 setbits_be16(&gpio->par_feci2c,
418 GPIO_PAR_FECI2C_MDC1_MDC1 |
419 GPIO_PAR_FECI2C_MDIO1_MDIO1);
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100420#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000421 setbits_be16(&gpio->par_feci2c,
422 GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100423#endif
TsiChung Liew69b17572008-10-21 13:47:54 +0000424
425 if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
Alison Wang8d8dac92012-03-26 21:49:08 +0000426 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_RMII_GPIO);
TsiChung Liew69b17572008-10-21 13:47:54 +0000427 else
Alison Wang8d8dac92012-03-26 21:49:08 +0000428 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_RMII_ATA);
TsiChung Liew69b17572008-10-21 13:47:54 +0000429 } else {
Alison Wang8d8dac92012-03-26 21:49:08 +0000430 clrbits_be16(&gpio->par_feci2c,
431 GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
TsiChung Liew69b17572008-10-21 13:47:54 +0000432
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100433 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
434#ifdef CONFIG_SYS_FEC_FULL_MII
Alison Wang8d8dac92012-03-26 21:49:08 +0000435 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_MII);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100436#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000437 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC0_UNMASK);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100438#endif
439 } else {
440#ifdef CONFIG_SYS_FEC_FULL_MII
Alison Wang8d8dac92012-03-26 21:49:08 +0000441 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_MII);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100442#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000443 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC1_UNMASK);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100444#endif
445 }
TsiChung Liew69b17572008-10-21 13:47:54 +0000446 }
Alison Wangfdc2fb12012-10-18 19:25:51 +0000447#endif /* CONFIG_MCF5445x */
448
449#ifdef CONFIG_MCF5441x
450 if (setclear) {
451 out_8(&gpio->par_fec, 0x03);
452 out_8(&gpio->srcr_fec, 0x0F);
453 clrsetbits_8(&gpio->par_simp0h, ~GPIO_PAR_SIMP0H_DAT_MASK,
454 GPIO_PAR_SIMP0H_DAT_GPIO);
455 clrsetbits_8(&gpio->pddr_g, ~GPIO_PDDR_G4_MASK,
456 GPIO_PDDR_G4_OUTPUT);
457 clrbits_8(&gpio->podr_g, ~GPIO_PODR_G4_MASK);
458
459 } else
460 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC_MASK);
461#endif
TsiChung Liewa424ba22009-06-30 14:18:29 +0000462 return 0;
463}
Alison Wangfdc2fb12012-10-18 19:25:51 +0000464#endif
465