blob: 9deab51d07e8d09370a153312ae7b805a061d2e5 [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>
Simon Glass97589732020-05-10 11:40:02 -060013#include <init.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050014#include <watchdog.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050015#include <asm/immap.h>
TsiChung Liew4d5414d2010-03-11 15:04:21 -060016#include <asm/processor.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050017#include <asm/rtc.h>
Alison Wang8d8dac92012-03-26 21:49:08 +000018#include <asm/io.h>
Marek Vasuta334ec92012-10-03 13:28:44 +000019#include <linux/compiler.h>
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050020
TsiChung Liew69b17572008-10-21 13:47:54 +000021#if defined(CONFIG_CMD_NET)
22#include <config.h>
23#include <net.h>
24#include <asm/fec.h>
25#endif
26
Alison Wangfdc2fb12012-10-18 19:25:51 +000027void init_fbcs(void)
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050028{
Marek Vasuta334ec92012-10-03 13:28:44 +000029 fbcs_t *fbcs __maybe_unused = (fbcs_t *) MMAP_FBCS;
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050030
Alison Wangfdc2fb12012-10-18 19:25:51 +000031#if !defined(CONFIG_SERIAL_BOOT)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020032#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000033 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
34 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
35 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050036#endif
TsiChung Liew23cf8fd2008-07-23 20:38:53 -050037#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050038
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020039#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050040 /* Latch chipselect */
Alison Wang8d8dac92012-03-26 21:49:08 +000041 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
42 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
43 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050044#endif
45
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020046#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000047 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
48 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
49 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050050#endif
51
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020052#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000053 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
54 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
55 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050056#endif
57
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020058#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000059 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
60 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
61 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050062#endif
63
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020064#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
Alison Wang8d8dac92012-03-26 21:49:08 +000065 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
66 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
67 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -050068#endif
Alison Wangfdc2fb12012-10-18 19:25:51 +000069}
70
Angelo Dureghello71abddd2019-03-13 21:46:52 +010071#ifdef CONFIG_CF_DSPI
72void cfspi_port_conf(void)
73{
74 gpio_t *gpio = (gpio_t *)MMAP_GPIO;
75
76#ifdef CONFIG_MCF5445x
77 out_8(&gpio->par_dspi,
78 GPIO_PAR_DSPI_SIN_SIN |
79 GPIO_PAR_DSPI_SOUT_SOUT |
80 GPIO_PAR_DSPI_SCK_SCK);
81#endif
82
83#ifdef CONFIG_MCF5441x
84 pm_t *pm = (pm_t *)MMAP_PM;
85
86 out_8(&gpio->par_dspi0,
87 GPIO_PAR_DSPI0_SIN_DSPI0SIN | GPIO_PAR_DSPI0_SOUT_DSPI0SOUT |
88 GPIO_PAR_DSPI0_SCK_DSPI0SCK);
89 out_8(&gpio->srcr_dspiow, 3);
90
91 /* DSPI0 */
92 out_8(&pm->pmcr0, 23);
93#endif
94}
95#endif
96
Alison Wangfdc2fb12012-10-18 19:25:51 +000097/*
98 * Breath some life into the CPU...
99 *
100 * Set up the memory map,
101 * initialize a bunch of registers,
102 * initialize the UPM's
103 */
104void cpu_init_f(void)
105{
106 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
107
108#ifdef CONFIG_MCF5441x
109 scm_t *scm = (scm_t *) MMAP_SCM;
110 pm_t *pm = (pm_t *) MMAP_PM;
111
112 /* Disable Switch */
113 *(unsigned long *)(MMAP_L2_SW0 + 0x00000024) = 0;
114
115 /* Disable core watchdog */
116 out_be16(&scm->cwcr, 0);
117 out_8(&gpio->par_fbctl,
118 GPIO_PAR_FBCTL_ALE_FB_ALE | GPIO_PAR_FBCTL_OE_FB_OE |
119 GPIO_PAR_FBCTL_FBCLK | GPIO_PAR_FBCTL_RW |
120 GPIO_PAR_FBCTL_TA_TA);
121 out_8(&gpio->par_be,
122 GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
123 GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
124
125 /* eDMA */
126 out_8(&pm->pmcr0, 17);
127
128 /* INTR0 - INTR2 */
129 out_8(&pm->pmcr0, 18);
130 out_8(&pm->pmcr0, 19);
131 out_8(&pm->pmcr0, 20);
132
133 /* I2C */
134 out_8(&pm->pmcr0, 22);
135 out_8(&pm->pmcr1, 4);
136 out_8(&pm->pmcr1, 7);
137
138 /* DTMR0 - DTMR3*/
139 out_8(&pm->pmcr0, 28);
140 out_8(&pm->pmcr0, 29);
141 out_8(&pm->pmcr0, 30);
142 out_8(&pm->pmcr0, 31);
143
144 /* PIT0 - PIT3 */
145 out_8(&pm->pmcr0, 32);
146 out_8(&pm->pmcr0, 33);
147 out_8(&pm->pmcr0, 34);
148 out_8(&pm->pmcr0, 35);
149
150 /* Edge Port */
151 out_8(&pm->pmcr0, 36);
152 out_8(&pm->pmcr0, 37);
153
154 /* USB OTG */
155 out_8(&pm->pmcr0, 44);
156 /* USB Host */
157 out_8(&pm->pmcr0, 45);
158
159 /* ESDHC */
160 out_8(&pm->pmcr0, 51);
161
162 /* ENET0 - ENET1 */
163 out_8(&pm->pmcr0, 53);
164 out_8(&pm->pmcr0, 54);
165
166 /* NAND */
167 out_8(&pm->pmcr0, 63);
168
169#ifdef CONFIG_SYS_I2C_0
170 out_8(&gpio->par_cani2c, 0xF0);
171 /* I2C0 pull up */
172 out_be16(&gpio->pcr_b, 0x003C);
173 /* I2C0 max speed */
174 out_8(&gpio->srcr_cani2c, 0x03);
175#endif
176#ifdef CONFIG_SYS_I2C_2
177 /* I2C2 */
178 out_8(&gpio->par_ssi0h, 0xA0);
179 /* I2C2, UART7 */
180 out_8(&gpio->par_ssi0h, 0xA8);
181 /* UART7 */
182 out_8(&gpio->par_ssi0l, 0x2);
183 /* UART8, UART9 */
184 out_8(&gpio->par_cani2c, 0xAA);
185 /* UART4, UART0 */
186 out_8(&gpio->par_uart0, 0xAF);
187 /* UART5, UART1 */
188 out_8(&gpio->par_uart1, 0xAF);
189 /* UART6, UART2 */
190 out_8(&gpio->par_uart2, 0xAF);
191 /* I2C2 pull up */
192 out_be16(&gpio->pcr_h, 0xF000);
193#endif
194#ifdef CONFIG_SYS_I2C_5
195 /* I2C5 */
196 out_8(&gpio->par_uart1, 0x0A);
197 /* I2C5 pull up */
198 out_be16(&gpio->pcr_e, 0x0003);
199 out_be16(&gpio->pcr_f, 0xC000);
200#endif
201
202 /* Lowest slew rate for UART0,1,2 */
203 out_8(&gpio->srcr_uart, 0x00);
Angelo Dureghello95a69982018-01-25 22:42:52 +0100204
Yangbo Lu73340382019-06-21 11:42:28 +0800205#ifdef CONFIG_FSL_ESDHC_IMX
Angelo Dureghello95a69982018-01-25 22:42:52 +0100206 /* eSDHC pin as faster speed */
207 out_8(&gpio->srcr_sdhc, 0x03);
208
209 /* All esdhc pins as SD */
210 out_8(&gpio->par_sdhch, 0xff);
211 out_8(&gpio->par_sdhcl, 0xff);
212#endif
Alison Wangfdc2fb12012-10-18 19:25:51 +0000213#endif /* CONFIG_MCF5441x */
214
215#ifdef CONFIG_MCF5445x
216 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
217
218 out_be32(&scm1->mpr, 0x77777777);
219 out_be32(&scm1->pacra, 0);
220 out_be32(&scm1->pacrb, 0);
221 out_be32(&scm1->pacrc, 0);
222 out_be32(&scm1->pacrd, 0);
223 out_be32(&scm1->pacre, 0);
224 out_be32(&scm1->pacrf, 0);
225 out_be32(&scm1->pacrg, 0);
226
227 /* FlexBus */
228 out_8(&gpio->par_be,
229 GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
230 GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
231 out_8(&gpio->par_fbctl,
232 GPIO_PAR_FBCTL_OE | GPIO_PAR_FBCTL_TA_TA |
233 GPIO_PAR_FBCTL_RW_RW | GPIO_PAR_FBCTL_TS_TS);
234
Angelo Dureghello71abddd2019-03-13 21:46:52 +0100235#ifdef CONFIG_CF_SPI
236 cfspi_port_conf();
237#endif
238
Heiko Schocherf2850742012-10-24 13:48:22 +0200239#ifdef CONFIG_SYS_FSL_I2C
Alison Wangfdc2fb12012-10-18 19:25:51 +0000240 out_be16(&gpio->par_feci2c,
241 GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
242#endif
243#endif /* CONFIG_MCF5445x */
244
245 /* FlexBus Chipselect */
246 init_fbcs();
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500247
Angelo Dureghello7211b922017-05-15 00:17:48 +0200248#ifdef CONFIG_SYS_CS0_BASE
TsiChung Liew4d5414d2010-03-11 15:04:21 -0600249 /*
250 * now the flash base address is no longer at 0 (Newer ColdFire family
251 * boot at address 0 instead of 0xFFnn_nnnn). The vector table must
252 * also move to the new location.
253 */
254 if (CONFIG_SYS_CS0_BASE != 0)
255 setvbr(CONFIG_SYS_CS0_BASE);
Angelo Dureghello7211b922017-05-15 00:17:48 +0200256#endif
TsiChung Liew4d5414d2010-03-11 15:04:21 -0600257
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500258 icache_enable();
259}
260
261/*
262 * initialize higher level parts of CPU like timers
263 */
264int cpu_init_r(void)
265{
TsiChung Liew1be9e092008-07-09 15:47:27 -0500266#ifdef CONFIG_MCFRTC
Alison Wang8d8dac92012-03-26 21:49:08 +0000267 rtc_t *rtc = (rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
268 rtcex_t *rtcex = (rtcex_t *)&rtc->extended;
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500269
Alison Wang8d8dac92012-03-26 21:49:08 +0000270 out_be32(&rtcex->gocu, (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xffff);
271 out_be32(&rtcex->gocl, CONFIG_SYS_RTC_OSCILLATOR & 0xffff);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500272#endif
273
274 return (0);
275}
276
TsiChung Liewf9556a72010-03-09 19:17:52 -0600277void uart_port_conf(int port)
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500278{
Alison Wang8d8dac92012-03-26 21:49:08 +0000279 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Alison Wangfdc2fb12012-10-18 19:25:51 +0000280#ifdef CONFIG_MCF5441x
281 pm_t *pm = (pm_t *) MMAP_PM;
282#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500283
284 /* Setup Ports: */
TsiChung Liewf9556a72010-03-09 19:17:52 -0600285 switch (port) {
Alison Wangfdc2fb12012-10-18 19:25:51 +0000286#ifdef CONFIG_MCF5441x
287 case 0:
288 /* UART0 */
289 out_8(&pm->pmcr0, 24);
290 clrbits_8(&gpio->par_uart0,
291 ~(GPIO_PAR_UART0_U0RXD_MASK | GPIO_PAR_UART0_U0TXD_MASK));
292 setbits_8(&gpio->par_uart0,
293 GPIO_PAR_UART0_U0RXD_U0RXD | GPIO_PAR_UART0_U0TXD_U0TXD);
294 break;
295 case 1:
296 /* UART1 */
297 out_8(&pm->pmcr0, 25);
298 clrbits_8(&gpio->par_uart1,
299 ~(GPIO_PAR_UART1_U1RXD_MASK | GPIO_PAR_UART1_U1TXD_MASK));
300 setbits_8(&gpio->par_uart1,
301 GPIO_PAR_UART1_U1RXD_U1RXD | GPIO_PAR_UART1_U1TXD_U1TXD);
302 break;
303 case 2:
304 /* UART2 */
305 out_8(&pm->pmcr0, 26);
306 clrbits_8(&gpio->par_uart2,
307 ~(GPIO_PAR_UART2_U2RXD_MASK | GPIO_PAR_UART2_U2TXD_MASK));
308 setbits_8(&gpio->par_uart2,
309 GPIO_PAR_UART2_U2RXD_U2RXD | GPIO_PAR_UART2_U2TXD_U2TXD);
310 break;
311 case 3:
312 /* UART3 */
313 out_8(&pm->pmcr0, 27);
314 clrbits_8(&gpio->par_dspi0,
315 ~(GPIO_PAR_DSPI0_SIN_MASK | GPIO_PAR_DSPI0_SOUT_MASK));
316 setbits_8(&gpio->par_dspi0,
317 GPIO_PAR_DSPI0_SIN_U3RXD | GPIO_PAR_DSPI0_SOUT_U3TXD);
318 break;
319 case 4:
320 /* UART4 */
321 out_8(&pm->pmcr1, 24);
322 clrbits_8(&gpio->par_uart0,
323 ~(GPIO_PAR_UART0_U0CTS_MASK | GPIO_PAR_UART0_U0RTS_MASK));
324 setbits_8(&gpio->par_uart0,
325 GPIO_PAR_UART0_U0CTS_U4TXD | GPIO_PAR_UART0_U0RTS_U4RXD);
326 break;
327 case 5:
328 /* UART5 */
329 out_8(&pm->pmcr1, 25);
330 clrbits_8(&gpio->par_uart1,
331 ~(GPIO_PAR_UART1_U1CTS_MASK | GPIO_PAR_UART1_U1RTS_MASK));
332 setbits_8(&gpio->par_uart1,
333 GPIO_PAR_UART1_U1CTS_U5TXD | GPIO_PAR_UART1_U1RTS_U5RXD);
334 break;
335 case 6:
336 /* UART6 */
337 out_8(&pm->pmcr1, 26);
338 clrbits_8(&gpio->par_uart2,
339 ~(GPIO_PAR_UART2_U2CTS_MASK | GPIO_PAR_UART2_U2RTS_MASK));
340 setbits_8(&gpio->par_uart2,
341 GPIO_PAR_UART2_U2CTS_U6TXD | GPIO_PAR_UART2_U2RTS_U6RXD);
342 break;
343 case 7:
344 /* UART7 */
345 out_8(&pm->pmcr1, 27);
346 clrbits_8(&gpio->par_ssi0h, ~GPIO_PAR_SSI0H_RXD_MASK);
347 clrbits_8(&gpio->par_ssi0l, ~GPIO_PAR_SSI0L_BCLK_MASK);
348 setbits_8(&gpio->par_ssi0h, GPIO_PAR_SSI0H_FS_U7TXD);
349 setbits_8(&gpio->par_ssi0l, GPIO_PAR_SSI0L_BCLK_U7RXD);
350 break;
351 case 8:
352 /* UART8 */
353 out_8(&pm->pmcr0, 28);
354 clrbits_8(&gpio->par_cani2c,
355 ~(GPIO_PAR_CANI2C_I2C0SCL_MASK | GPIO_PAR_CANI2C_I2C0SDA_MASK));
356 setbits_8(&gpio->par_cani2c,
357 GPIO_PAR_CANI2C_I2C0SCL_U8TXD | GPIO_PAR_CANI2C_I2C0SDA_U8RXD);
358 break;
359 case 9:
360 /* UART9 */
361 out_8(&pm->pmcr1, 29);
362 clrbits_8(&gpio->par_cani2c,
363 ~(GPIO_PAR_CANI2C_CAN1TX_MASK | GPIO_PAR_CANI2C_CAN1RX_MASK));
364 setbits_8(&gpio->par_cani2c,
365 GPIO_PAR_CANI2C_CAN1TX_U9TXD | GPIO_PAR_CANI2C_CAN1RX_U9RXD);
366 break;
367#endif
368#ifdef CONFIG_MCF5445x
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500369 case 0:
Alison Wang8d8dac92012-03-26 21:49:08 +0000370 clrbits_8(&gpio->par_uart,
371 GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
372 setbits_8(&gpio->par_uart,
373 GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500374 break;
375 case 1:
TsiChung Liewf9556a72010-03-09 19:17:52 -0600376#ifdef CONFIG_SYS_UART1_PRI_GPIO
Alison Wang8d8dac92012-03-26 21:49:08 +0000377 clrbits_8(&gpio->par_uart,
378 GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
379 setbits_8(&gpio->par_uart,
380 GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600381#elif defined(CONFIG_SYS_UART1_ALT1_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000382 clrbits_be16(&gpio->par_ssi,
383 ~(GPIO_PAR_SSI_SRXD_UNMASK | GPIO_PAR_SSI_STXD_UNMASK));
384 setbits_be16(&gpio->par_ssi,
385 GPIO_PAR_SSI_SRXD_U1RXD | GPIO_PAR_SSI_STXD_U1TXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600386#endif
387 break;
388 case 2:
389#if defined(CONFIG_SYS_UART2_ALT1_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000390 clrbits_8(&gpio->par_timer,
391 ~(GPIO_PAR_TIMER_T3IN_UNMASK | GPIO_PAR_TIMER_T2IN_UNMASK));
392 setbits_8(&gpio->par_timer,
393 GPIO_PAR_TIMER_T3IN_U2RXD | GPIO_PAR_TIMER_T2IN_U2TXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600394#elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
Alison Wang8d8dac92012-03-26 21:49:08 +0000395 clrbits_8(&gpio->par_timer,
396 ~(GPIO_PAR_FECI2C_SCL_UNMASK | GPIO_PAR_FECI2C_SDA_UNMASK));
397 setbits_8(&gpio->par_timer,
398 GPIO_PAR_FECI2C_SCL_U2TXD | GPIO_PAR_FECI2C_SDA_U2RXD);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600399#endif
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500400 break;
Alison Wangfdc2fb12012-10-18 19:25:51 +0000401#endif /* CONFIG_MCF5445x */
TsiChungLiewfc3ca3b62007-08-16 15:05:11 -0500402 }
TsiChung Liew69b17572008-10-21 13:47:54 +0000403}
404
405#if defined(CONFIG_CMD_NET)
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100406int fecpin_setclear(fec_info_t *info, int setclear)
TsiChung Liew69b17572008-10-21 13:47:54 +0000407{
Alison Wang8d8dac92012-03-26 21:49:08 +0000408 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100409 u32 fec0_base;
410
411 if (fec_get_base_addr(0, &fec0_base))
412 return -1;
TsiChung Liew69b17572008-10-21 13:47:54 +0000413
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100414#ifdef CONFIG_MCF5445x
TsiChung Liew69b17572008-10-21 13:47:54 +0000415 if (setclear) {
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100416#ifdef CONFIG_SYS_FEC_NO_SHARED_PHY
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100417 if (info->iobase == fec0_base)
Alison Wang8d8dac92012-03-26 21:49:08 +0000418 setbits_be16(&gpio->par_feci2c,
419 GPIO_PAR_FECI2C_MDC0_MDC0 |
420 GPIO_PAR_FECI2C_MDIO0_MDIO0);
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_MDC1_MDC1 |
424 GPIO_PAR_FECI2C_MDIO1_MDIO1);
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100425#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000426 setbits_be16(&gpio->par_feci2c,
427 GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
Wolfgang Wegner5fe66d72010-03-30 19:19:50 +0100428#endif
TsiChung Liew69b17572008-10-21 13:47:54 +0000429
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100430 if (info->iobase == fec0_base)
Alison Wang8d8dac92012-03-26 21:49:08 +0000431 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_RMII_GPIO);
TsiChung Liew69b17572008-10-21 13:47:54 +0000432 else
Alison Wang8d8dac92012-03-26 21:49:08 +0000433 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_RMII_ATA);
TsiChung Liew69b17572008-10-21 13:47:54 +0000434 } else {
Alison Wang8d8dac92012-03-26 21:49:08 +0000435 clrbits_be16(&gpio->par_feci2c,
436 GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
TsiChung Liew69b17572008-10-21 13:47:54 +0000437
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100438 if (info->iobase == fec0_base) {
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100439#ifdef CONFIG_SYS_FEC_FULL_MII
Alison Wang8d8dac92012-03-26 21:49:08 +0000440 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_MII);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100441#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000442 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC0_UNMASK);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100443#endif
444 } else {
445#ifdef CONFIG_SYS_FEC_FULL_MII
Alison Wang8d8dac92012-03-26 21:49:08 +0000446 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_MII);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100447#else
Alison Wang8d8dac92012-03-26 21:49:08 +0000448 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC1_UNMASK);
Wolfgang Wegnera19e62d2010-03-30 19:19:51 +0100449#endif
450 }
TsiChung Liew69b17572008-10-21 13:47:54 +0000451 }
Alison Wangfdc2fb12012-10-18 19:25:51 +0000452#endif /* CONFIG_MCF5445x */
453
454#ifdef CONFIG_MCF5441x
455 if (setclear) {
456 out_8(&gpio->par_fec, 0x03);
457 out_8(&gpio->srcr_fec, 0x0F);
458 clrsetbits_8(&gpio->par_simp0h, ~GPIO_PAR_SIMP0H_DAT_MASK,
459 GPIO_PAR_SIMP0H_DAT_GPIO);
460 clrsetbits_8(&gpio->pddr_g, ~GPIO_PDDR_G4_MASK,
461 GPIO_PDDR_G4_OUTPUT);
462 clrbits_8(&gpio->podr_g, ~GPIO_PODR_G4_MASK);
463
464 } else
465 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC_MASK);
466#endif
TsiChung Liewa424ba22009-06-30 14:18:29 +0000467 return 0;
468}
Alison Wangfdc2fb12012-10-18 19:25:51 +0000469#endif