blob: 9c5b8122a6aa9e7b3f0127525f124ca3fceb028a [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>
Simon Glass1d91ba72019-11-14 12:57:37 -070012#include <cpu_func.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050013#include <watchdog.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050014#include <asm/immap.h>
TsiChung Liew4d5414d2010-03-11 15:04:21 -060015#include <asm/processor.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050016#include <asm/rtc.h>
Alison Wang8d8dac92012-03-26 21:49:08 +000017#include <asm/io.h>
Marek Vasuta334ec92012-10-03 13:28:44 +000018#include <linux/compiler.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050019
TsiChung Liew69b17572008-10-21 13:47:54 +000020#if defined(CONFIG_CMD_NET)
21#include <config.h>
22#include <net.h>
23#include <asm/fec.h>
24#endif
25
Alison Wangfdc2fb12012-10-18 19:25:51 +000026void init_fbcs(void)
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050027{
Marek Vasuta334ec92012-10-03 13:28:44 +000028 fbcs_t *fbcs __maybe_unused = (fbcs_t *) MMAP_FBCS;
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050029
Alison Wangfdc2fb12012-10-18 19:25:51 +000030#if !defined(CONFIG_SERIAL_BOOT)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020031#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000032 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
33 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
34 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050035#endif
TsiChung Liew23cf8fd2008-07-23 20:38:53 -050036#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050037
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020038#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050039 /* Latch chipselect */
Alison Wang8d8dac92012-03-26 21:49:08 +000040 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
41 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
42 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050043#endif
44
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020045#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000046 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
47 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
48 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050049#endif
50
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020051#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000052 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
53 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
54 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050055#endif
56
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020057#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000058 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
59 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
60 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050061#endif
62
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020063#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000064 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
65 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
66 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050067#endif
Alison Wangfdc2fb12012-10-18 19:25:51 +000068}
69
Angelo Dureghello71abddd2019-03-13 21:46:52 +010070#ifdef CONFIG_CF_DSPI
71void cfspi_port_conf(void)
72{
73 gpio_t *gpio = (gpio_t *)MMAP_GPIO;
74
75#ifdef CONFIG_MCF5445x
76 out_8(&gpio->par_dspi,
77 GPIO_PAR_DSPI_SIN_SIN |
78 GPIO_PAR_DSPI_SOUT_SOUT |
79 GPIO_PAR_DSPI_SCK_SCK);
80#endif
81
82#ifdef CONFIG_MCF5441x
83 pm_t *pm = (pm_t *)MMAP_PM;
84
85 out_8(&gpio->par_dspi0,
86 GPIO_PAR_DSPI0_SIN_DSPI0SIN | GPIO_PAR_DSPI0_SOUT_DSPI0SOUT |
87 GPIO_PAR_DSPI0_SCK_DSPI0SCK);
88 out_8(&gpio->srcr_dspiow, 3);
89
90 /* DSPI0 */
91 out_8(&pm->pmcr0, 23);
92#endif
93}
94#endif
95
Alison Wangfdc2fb12012-10-18 19:25:51 +000096/*
97 * Breath some life into the CPU...
98 *
99 * Set up the memory map,
100 * initialize a bunch of registers,
101 * initialize the UPM's
102 */
103void cpu_init_f(void)
104{
105 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
106
107#ifdef CONFIG_MCF5441x
108 scm_t *scm = (scm_t *) MMAP_SCM;
109 pm_t *pm = (pm_t *) MMAP_PM;
110
111 /* Disable Switch */
112 *(unsigned long *)(MMAP_L2_SW0 + 0x00000024) = 0;
113
114 /* Disable core watchdog */
115 out_be16(&scm->cwcr, 0);
116 out_8(&gpio->par_fbctl,
117 GPIO_PAR_FBCTL_ALE_FB_ALE | GPIO_PAR_FBCTL_OE_FB_OE |
118 GPIO_PAR_FBCTL_FBCLK | GPIO_PAR_FBCTL_RW |
119 GPIO_PAR_FBCTL_TA_TA);
120 out_8(&gpio->par_be,
121 GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
122 GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
123
124 /* eDMA */
125 out_8(&pm->pmcr0, 17);
126
127 /* INTR0 - INTR2 */
128 out_8(&pm->pmcr0, 18);
129 out_8(&pm->pmcr0, 19);
130 out_8(&pm->pmcr0, 20);
131
132 /* I2C */
133 out_8(&pm->pmcr0, 22);
134 out_8(&pm->pmcr1, 4);
135 out_8(&pm->pmcr1, 7);
136
137 /* DTMR0 - DTMR3*/
138 out_8(&pm->pmcr0, 28);
139 out_8(&pm->pmcr0, 29);
140 out_8(&pm->pmcr0, 30);
141 out_8(&pm->pmcr0, 31);
142
143 /* PIT0 - PIT3 */
144 out_8(&pm->pmcr0, 32);
145 out_8(&pm->pmcr0, 33);
146 out_8(&pm->pmcr0, 34);
147 out_8(&pm->pmcr0, 35);
148
149 /* Edge Port */
150 out_8(&pm->pmcr0, 36);
151 out_8(&pm->pmcr0, 37);
152
153 /* USB OTG */
154 out_8(&pm->pmcr0, 44);
155 /* USB Host */
156 out_8(&pm->pmcr0, 45);
157
158 /* ESDHC */
159 out_8(&pm->pmcr0, 51);
160
161 /* ENET0 - ENET1 */
162 out_8(&pm->pmcr0, 53);
163 out_8(&pm->pmcr0, 54);
164
165 /* NAND */
166 out_8(&pm->pmcr0, 63);
167
168#ifdef CONFIG_SYS_I2C_0
169 out_8(&gpio->par_cani2c, 0xF0);
170 /* I2C0 pull up */
171 out_be16(&gpio->pcr_b, 0x003C);
172 /* I2C0 max speed */
173 out_8(&gpio->srcr_cani2c, 0x03);
174#endif
175#ifdef CONFIG_SYS_I2C_2
176 /* I2C2 */
177 out_8(&gpio->par_ssi0h, 0xA0);
178 /* I2C2, UART7 */
179 out_8(&gpio->par_ssi0h, 0xA8);
180 /* UART7 */
181 out_8(&gpio->par_ssi0l, 0x2);
182 /* UART8, UART9 */
183 out_8(&gpio->par_cani2c, 0xAA);
184 /* UART4, UART0 */
185 out_8(&gpio->par_uart0, 0xAF);
186 /* UART5, UART1 */
187 out_8(&gpio->par_uart1, 0xAF);
188 /* UART6, UART2 */
189 out_8(&gpio->par_uart2, 0xAF);
190 /* I2C2 pull up */
191 out_be16(&gpio->pcr_h, 0xF000);
192#endif
193#ifdef CONFIG_SYS_I2C_5
194 /* I2C5 */
195 out_8(&gpio->par_uart1, 0x0A);
196 /* I2C5 pull up */
197 out_be16(&gpio->pcr_e, 0x0003);
198 out_be16(&gpio->pcr_f, 0xC000);
199#endif
200
201 /* Lowest slew rate for UART0,1,2 */
202 out_8(&gpio->srcr_uart, 0x00);
Angelo Dureghello95a69982018-01-25 22:42:52 +0100203
Yangbo Lu73340382019-06-21 11:42:28 +0800204#ifdef CONFIG_FSL_ESDHC_IMX
Angelo Dureghello95a69982018-01-25 22:42:52 +0100205 /* eSDHC pin as faster speed */
206 out_8(&gpio->srcr_sdhc, 0x03);
207
208 /* All esdhc pins as SD */
209 out_8(&gpio->par_sdhch, 0xff);
210 out_8(&gpio->par_sdhcl, 0xff);
211#endif
Alison Wangfdc2fb12012-10-18 19:25:51 +0000212#endif /* CONFIG_MCF5441x */
213
214#ifdef CONFIG_MCF5445x
215 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
216
217 out_be32(&scm1->mpr, 0x77777777);
218 out_be32(&scm1->pacra, 0);
219 out_be32(&scm1->pacrb, 0);
220 out_be32(&scm1->pacrc, 0);
221 out_be32(&scm1->pacrd, 0);
222 out_be32(&scm1->pacre, 0);
223 out_be32(&scm1->pacrf, 0);
224 out_be32(&scm1->pacrg, 0);
225
226 /* FlexBus */
227 out_8(&gpio->par_be,
228 GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
229 GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
230 out_8(&gpio->par_fbctl,
231 GPIO_PAR_FBCTL_OE | GPIO_PAR_FBCTL_TA_TA |
232 GPIO_PAR_FBCTL_RW_RW | GPIO_PAR_FBCTL_TS_TS);
233
Angelo Dureghello71abddd2019-03-13 21:46:52 +0100234#ifdef CONFIG_CF_SPI
235 cfspi_port_conf();
236#endif
237
Heiko Schocherf2850742012-10-24 13:48:22 +0200238#ifdef CONFIG_SYS_FSL_I2C
Alison Wangfdc2fb12012-10-18 19:25:51 +0000239 out_be16(&gpio->par_feci2c,
240 GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
241#endif
242#endif /* CONFIG_MCF5445x */
243
244 /* FlexBus Chipselect */
245 init_fbcs();
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500246
Angelo Dureghello7211b922017-05-15 00:17:48 +0200247#ifdef CONFIG_SYS_CS0_BASE
TsiChung Liew4d5414d2010-03-11 15:04:21 -0600248 /*
249 * now the flash base address is no longer at 0 (Newer ColdFire family
250 * boot at address 0 instead of 0xFFnn_nnnn). The vector table must
251 * also move to the new location.
252 */
253 if (CONFIG_SYS_CS0_BASE != 0)
254 setvbr(CONFIG_SYS_CS0_BASE);
Angelo Dureghello7211b922017-05-15 00:17:48 +0200255#endif
TsiChung Liew4d5414d2010-03-11 15:04:21 -0600256
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500257 icache_enable();
258}
259
260/*
261 * initialize higher level parts of CPU like timers
262 */
263int cpu_init_r(void)
264{
TsiChung Liew1be9e092008-07-09 15:47:27 -0500265#ifdef CONFIG_MCFRTC
Alison Wang8d8dac92012-03-26 21:49:08 +0000266 rtc_t *rtc = (rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
267 rtcex_t *rtcex = (rtcex_t *)&rtc->extended;
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500268
Alison Wang8d8dac92012-03-26 21:49:08 +0000269 out_be32(&rtcex->gocu, (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xffff);
270 out_be32(&rtcex->gocl, CONFIG_SYS_RTC_OSCILLATOR & 0xffff);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500271#endif
272
273 return (0);
274}
275
TsiChung Liewf9556a72010-03-09 19:17:52 -0600276void uart_port_conf(int port)
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500277{
Alison Wang8d8dac92012-03-26 21:49:08 +0000278 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Alison Wangfdc2fb12012-10-18 19:25:51 +0000279#ifdef CONFIG_MCF5441x
280 pm_t *pm = (pm_t *) MMAP_PM;
281#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500282
283 /* Setup Ports: */
TsiChung Liewf9556a72010-03-09 19:17:52 -0600284 switch (port) {
Alison Wangfdc2fb12012-10-18 19:25:51 +0000285#ifdef CONFIG_MCF5441x
286 case 0:
287 /* UART0 */
288 out_8(&pm->pmcr0, 24);
289 clrbits_8(&gpio->par_uart0,
290 ~(GPIO_PAR_UART0_U0RXD_MASK | GPIO_PAR_UART0_U0TXD_MASK));
291 setbits_8(&gpio->par_uart0,
292 GPIO_PAR_UART0_U0RXD_U0RXD | GPIO_PAR_UART0_U0TXD_U0TXD);
293 break;
294 case 1:
295 /* UART1 */
296 out_8(&pm->pmcr0, 25);
297 clrbits_8(&gpio->par_uart1,
298 ~(GPIO_PAR_UART1_U1RXD_MASK | GPIO_PAR_UART1_U1TXD_MASK));
299 setbits_8(&gpio->par_uart1,
300 GPIO_PAR_UART1_U1RXD_U1RXD | GPIO_PAR_UART1_U1TXD_U1TXD);
301 break;
302 case 2:
303 /* UART2 */
304 out_8(&pm->pmcr0, 26);
305 clrbits_8(&gpio->par_uart2,
306 ~(GPIO_PAR_UART2_U2RXD_MASK | GPIO_PAR_UART2_U2TXD_MASK));
307 setbits_8(&gpio->par_uart2,
308 GPIO_PAR_UART2_U2RXD_U2RXD | GPIO_PAR_UART2_U2TXD_U2TXD);
309 break;
310 case 3:
311 /* UART3 */
312 out_8(&pm->pmcr0, 27);
313 clrbits_8(&gpio->par_dspi0,
314 ~(GPIO_PAR_DSPI0_SIN_MASK | GPIO_PAR_DSPI0_SOUT_MASK));
315 setbits_8(&gpio->par_dspi0,
316 GPIO_PAR_DSPI0_SIN_U3RXD | GPIO_PAR_DSPI0_SOUT_U3TXD);
317 break;
318 case 4:
319 /* UART4 */
320 out_8(&pm->pmcr1, 24);
321 clrbits_8(&gpio->par_uart0,
322 ~(GPIO_PAR_UART0_U0CTS_MASK | GPIO_PAR_UART0_U0RTS_MASK));
323 setbits_8(&gpio->par_uart0,
324 GPIO_PAR_UART0_U0CTS_U4TXD | GPIO_PAR_UART0_U0RTS_U4RXD);
325 break;
326 case 5:
327 /* UART5 */
328 out_8(&pm->pmcr1, 25);
329 clrbits_8(&gpio->par_uart1,
330 ~(GPIO_PAR_UART1_U1CTS_MASK | GPIO_PAR_UART1_U1RTS_MASK));
331 setbits_8(&gpio->par_uart1,
332 GPIO_PAR_UART1_U1CTS_U5TXD | GPIO_PAR_UART1_U1RTS_U5RXD);
333 break;
334 case 6:
335 /* UART6 */
336 out_8(&pm->pmcr1, 26);
337 clrbits_8(&gpio->par_uart2,
338 ~(GPIO_PAR_UART2_U2CTS_MASK | GPIO_PAR_UART2_U2RTS_MASK));
339 setbits_8(&gpio->par_uart2,
340 GPIO_PAR_UART2_U2CTS_U6TXD | GPIO_PAR_UART2_U2RTS_U6RXD);
341 break;
342 case 7:
343 /* UART7 */
344 out_8(&pm->pmcr1, 27);
345 clrbits_8(&gpio->par_ssi0h, ~GPIO_PAR_SSI0H_RXD_MASK);
346 clrbits_8(&gpio->par_ssi0l, ~GPIO_PAR_SSI0L_BCLK_MASK);
347 setbits_8(&gpio->par_ssi0h, GPIO_PAR_SSI0H_FS_U7TXD);
348 setbits_8(&gpio->par_ssi0l, GPIO_PAR_SSI0L_BCLK_U7RXD);
349 break;
350 case 8:
351 /* UART8 */
352 out_8(&pm->pmcr0, 28);
353 clrbits_8(&gpio->par_cani2c,
354 ~(GPIO_PAR_CANI2C_I2C0SCL_MASK | GPIO_PAR_CANI2C_I2C0SDA_MASK));
355 setbits_8(&gpio->par_cani2c,
356 GPIO_PAR_CANI2C_I2C0SCL_U8TXD | GPIO_PAR_CANI2C_I2C0SDA_U8RXD);
357 break;
358 case 9:
359 /* UART9 */
360 out_8(&pm->pmcr1, 29);
361 clrbits_8(&gpio->par_cani2c,
362 ~(GPIO_PAR_CANI2C_CAN1TX_MASK | GPIO_PAR_CANI2C_CAN1RX_MASK));
363 setbits_8(&gpio->par_cani2c,
364 GPIO_PAR_CANI2C_CAN1TX_U9TXD | GPIO_PAR_CANI2C_CAN1RX_U9RXD);
365 break;
366#endif
367#ifdef CONFIG_MCF5445x
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500368 case 0:
Alison Wang8d8dac92012-03-26 21:49:08 +0000369 clrbits_8(&gpio->par_uart,
370 GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
371 setbits_8(&gpio->par_uart,
372 GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500373 break;
374 case 1:
TsiChung Liewf9556a72010-03-09 19:17:52 -0600375#ifdef CONFIG_SYS_UART1_PRI_GPIO
Alison Wang8d8dac92012-03-26 21:49:08 +0000376 clrbits_8(&gpio->par_uart,
377 GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
378 setbits_8(&gpio->par_uart,
379 GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600380#elif defined(CONFIG_SYS_UART1_ALT1_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000381 clrbits_be16(&gpio->par_ssi,
382 ~(GPIO_PAR_SSI_SRXD_UNMASK | GPIO_PAR_SSI_STXD_UNMASK));
383 setbits_be16(&gpio->par_ssi,
384 GPIO_PAR_SSI_SRXD_U1RXD | GPIO_PAR_SSI_STXD_U1TXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600385#endif
386 break;
387 case 2:
388#if defined(CONFIG_SYS_UART2_ALT1_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000389 clrbits_8(&gpio->par_timer,
390 ~(GPIO_PAR_TIMER_T3IN_UNMASK | GPIO_PAR_TIMER_T2IN_UNMASK));
391 setbits_8(&gpio->par_timer,
392 GPIO_PAR_TIMER_T3IN_U2RXD | GPIO_PAR_TIMER_T2IN_U2TXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600393#elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000394 clrbits_8(&gpio->par_timer,
395 ~(GPIO_PAR_FECI2C_SCL_UNMASK | GPIO_PAR_FECI2C_SDA_UNMASK));
396 setbits_8(&gpio->par_timer,
397 GPIO_PAR_FECI2C_SCL_U2TXD | GPIO_PAR_FECI2C_SDA_U2RXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600398#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500399 break;
Alison Wangfdc2fb12012-10-18 19:25:51 +0000400#endif /* CONFIG_MCF5445x */
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500401 }
TsiChung Liew69b17572008-10-21 13:47:54 +0000402}
403
404#if defined(CONFIG_CMD_NET)
405int fecpin_setclear(struct eth_device *dev, int setclear)
406{
Alison Wang8d8dac92012-03-26 21:49:08 +0000407 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Masahiro Yamada35b2eb72013-10-16 13:53:04 +0900408#ifdef CONFIG_MCF5445x
TsiChung Liew69b17572008-10-21 13:47:54 +0000409 struct fec_info_s *info = (struct fec_info_s *)dev->priv;
410
411 if (setclear) {
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100412#ifdef CONFIG_SYS_FEC_NO_SHARED_PHY
413 if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
Alison Wang8d8dac92012-03-26 21:49:08 +0000414 setbits_be16(&gpio->par_feci2c,
415 GPIO_PAR_FECI2C_MDC0_MDC0 |
416 GPIO_PAR_FECI2C_MDIO0_MDIO0);
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100417 else
Alison Wang8d8dac92012-03-26 21:49:08 +0000418 setbits_be16(&gpio->par_feci2c,
419 GPIO_PAR_FECI2C_MDC1_MDC1 |
420 GPIO_PAR_FECI2C_MDIO1_MDIO1);
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100421#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000422 setbits_be16(&gpio->par_feci2c,
423 GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100424#endif
TsiChung Liew69b17572008-10-21 13:47:54 +0000425
426 if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
Alison Wang8d8dac92012-03-26 21:49:08 +0000427 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_RMII_GPIO);
TsiChung Liew69b17572008-10-21 13:47:54 +0000428 else
Alison Wang8d8dac92012-03-26 21:49:08 +0000429 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_RMII_ATA);
TsiChung Liew69b17572008-10-21 13:47:54 +0000430 } else {
Alison Wang8d8dac92012-03-26 21:49:08 +0000431 clrbits_be16(&gpio->par_feci2c,
432 GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
TsiChung Liew69b17572008-10-21 13:47:54 +0000433
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100434 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
435#ifdef CONFIG_SYS_FEC_FULL_MII
Alison Wang8d8dac92012-03-26 21:49:08 +0000436 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_MII);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100437#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000438 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC0_UNMASK);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100439#endif
440 } else {
441#ifdef CONFIG_SYS_FEC_FULL_MII
Alison Wang8d8dac92012-03-26 21:49:08 +0000442 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_MII);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100443#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000444 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC1_UNMASK);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100445#endif
446 }
TsiChung Liew69b17572008-10-21 13:47:54 +0000447 }
Alison Wangfdc2fb12012-10-18 19:25:51 +0000448#endif /* CONFIG_MCF5445x */
449
450#ifdef CONFIG_MCF5441x
451 if (setclear) {
452 out_8(&gpio->par_fec, 0x03);
453 out_8(&gpio->srcr_fec, 0x0F);
454 clrsetbits_8(&gpio->par_simp0h, ~GPIO_PAR_SIMP0H_DAT_MASK,
455 GPIO_PAR_SIMP0H_DAT_GPIO);
456 clrsetbits_8(&gpio->pddr_g, ~GPIO_PDDR_G4_MASK,
457 GPIO_PDDR_G4_OUTPUT);
458 clrbits_8(&gpio->podr_g, ~GPIO_PODR_G4_MASK);
459
460 } else
461 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC_MASK);
462#endif
TsiChung Liewa424ba22009-06-30 14:18:29 +0000463 return 0;
464}
Alison Wangfdc2fb12012-10-18 19:25:51 +0000465#endif
466