blob: 62a45f96314d210886f08bf9228fb776b64d51a3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChung Liewf6afe722007-06-18 13:50:13 -05002/*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Alison Wang35d23df2012-03-26 21:49:05 +00007 * (C) Copyright 2004-2008, 2012 Freescale Semiconductor, Inc.
TsiChung Liewf6afe722007-06-18 13:50:13 -05008 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChung Liewf6afe722007-06-18 13:50:13 -05009 */
10
Simon Glass1d91ba72019-11-14 12:57:37 -070011#include <cpu_func.h>
Simon Glass97589732020-05-10 11:40:02 -060012#include <init.h>
TsiChung Liewf6afe722007-06-18 13:50:13 -050013#include <watchdog.h>
TsiChungLiew97401c32007-07-05 23:03:28 -050014#include <asm/immap.h>
Alison Wang35d23df2012-03-26 21:49:05 +000015#include <asm/io.h>
TsiChung Liewf6afe722007-06-18 13:50:13 -050016
Angelo Durgehello8ff47f72019-11-15 23:54:16 +010017#if defined(CONFIG_MCFFEC)
TsiChung Liew69b17572008-10-21 13:47:54 +000018#include <config.h>
19#include <net.h>
20#include <asm/fec.h>
21#endif
22
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000023#ifdef CONFIG_MCF5301x
24void cpu_init_f(void)
25{
Alison Wang35d23df2012-03-26 21:49:05 +000026 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
27 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
28 fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000029
Alison Wang35d23df2012-03-26 21:49:05 +000030 out_be32(&scm1->mpr, 0x77777777);
31 out_be32(&scm1->pacra, 0);
32 out_be32(&scm1->pacrb, 0);
33 out_be32(&scm1->pacrc, 0);
34 out_be32(&scm1->pacrd, 0);
35 out_be32(&scm1->pacre, 0);
36 out_be32(&scm1->pacrf, 0);
37 out_be32(&scm1->pacrg, 0);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000038
Tom Rini6a5dccc2022-11-16 13:10:41 -050039#if (defined(CFG_SYS_CS0_BASE) && defined(CFG_SYS_CS0_MASK) \
40 && defined(CFG_SYS_CS0_CTRL))
Alison Wang35d23df2012-03-26 21:49:05 +000041 setbits_8(&gpio->par_cs, GPIO_PAR_CS0_CS0);
Tom Rini6a5dccc2022-11-16 13:10:41 -050042 out_be32(&fbcs->csar0, CFG_SYS_CS0_BASE);
43 out_be32(&fbcs->cscr0, CFG_SYS_CS0_CTRL);
44 out_be32(&fbcs->csmr0, CFG_SYS_CS0_MASK);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000045#endif
46
Tom Rini6a5dccc2022-11-16 13:10:41 -050047#if (defined(CFG_SYS_CS1_BASE) && defined(CFG_SYS_CS1_MASK) \
48 && defined(CFG_SYS_CS1_CTRL))
Alison Wang35d23df2012-03-26 21:49:05 +000049 setbits_8(&gpio->par_cs, GPIO_PAR_CS1_CS1);
Tom Rini6a5dccc2022-11-16 13:10:41 -050050 out_be32(&fbcs->csar1, CFG_SYS_CS1_BASE);
51 out_be32(&fbcs->cscr1, CFG_SYS_CS1_CTRL);
52 out_be32(&fbcs->csmr1, CFG_SYS_CS1_MASK);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000053#endif
54
Tom Rini6a5dccc2022-11-16 13:10:41 -050055#if (defined(CFG_SYS_CS2_BASE) && defined(CFG_SYS_CS2_MASK) \
56 && defined(CFG_SYS_CS2_CTRL))
57 out_be32(&fbcs->csar2, CFG_SYS_CS2_BASE);
58 out_be32(&fbcs->cscr2, CFG_SYS_CS2_CTRL);
59 out_be32(&fbcs->csmr2, CFG_SYS_CS2_MASK);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000060#endif
61
Tom Rini6a5dccc2022-11-16 13:10:41 -050062#if (defined(CFG_SYS_CS3_BASE) && defined(CFG_SYS_CS3_MASK) \
63 && defined(CFG_SYS_CS3_CTRL))
64 out_be32(&fbcs->csar3, CFG_SYS_CS3_BASE);
65 out_be32(&fbcs->cscr3, CFG_SYS_CS3_CTRL);
66 out_be32(&fbcs->csmr3, CFG_SYS_CS3_MASK);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000067#endif
68
69#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
70 && defined(CONFIG_SYS_CS4_CTRL))
Alison Wang35d23df2012-03-26 21:49:05 +000071 setbits_8(&gpio->par_cs, GPIO_PAR_CS4);
72 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
73 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
74 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000075#endif
76
77#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
78 && defined(CONFIG_SYS_CS5_CTRL))
Alison Wang35d23df2012-03-26 21:49:05 +000079 setbits_8(&gpio->par_cs, GPIO_PAR_CS5);
80 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
81 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
82 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000083#endif
84
Heiko Schocherf2850742012-10-24 13:48:22 +020085#ifdef CONFIG_SYS_I2C_FSL
Alison Wang35d23df2012-03-26 21:49:05 +000086 out_8(&gpio->par_feci2c,
87 GPIO_PAR_FECI2C_SDA_SDA | GPIO_PAR_FECI2C_SCL_SCL);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000088#endif
89
90 icache_enable();
91}
92
93/* initialize higher level parts of CPU like timers */
94int cpu_init_r(void)
95{
96#ifdef CONFIG_MCFFEC
Angelo Durgehello8ff47f72019-11-15 23:54:16 +010097 u32 fec_mii_base0, fec_mii_base1;
Alison Wang35d23df2012-03-26 21:49:05 +000098 ccm_t *ccm = (ccm_t *) MMAP_CCM;
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000099#endif
100#ifdef CONFIG_MCFRTC
Alison Wang35d23df2012-03-26 21:49:05 +0000101 rtc_t *rtc = (rtc_t *) (CONFIG_SYS_MCFRTC_BASE);
102 rtcex_t *rtcex = (rtcex_t *) &rtc->extended;
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000103
Tom Rini6a5dccc2022-11-16 13:10:41 -0500104 out_be32(&rtcex->gocu, CFG_SYS_RTC_CNT);
105 out_be32(&rtcex->gocl, CFG_SYS_RTC_SETUP);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000106
107#endif
108#ifdef CONFIG_MCFFEC
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100109 fec_get_mii_base(0, &fec_mii_base0);
110 fec_get_mii_base(1, &fec_mii_base1);
111
112 if (fec_mii_base0 != fec_mii_base1)
Alison Wang35d23df2012-03-26 21:49:05 +0000113 setbits_be16(&ccm->misccr, CCM_MISCCR_FECM);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000114 else
Alison Wang35d23df2012-03-26 21:49:05 +0000115 clrbits_be16(&ccm->misccr, CCM_MISCCR_FECM);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000116#endif
117
118 return (0);
119}
120
TsiChung Liewf9556a72010-03-09 19:17:52 -0600121void uart_port_conf(int port)
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000122{
Alison Wang35d23df2012-03-26 21:49:05 +0000123 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000124
125 /* Setup Ports: */
TsiChung Liewf9556a72010-03-09 19:17:52 -0600126 switch (port) {
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000127 case 0:
Alison Wang35d23df2012-03-26 21:49:05 +0000128 clrbits_8(&gpio->par_uart,
129 GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
130 setbits_8(&gpio->par_uart,
131 GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000132 break;
133 case 1:
134#ifdef CONFIG_SYS_UART1_ALT1_GPIO
Alison Wang35d23df2012-03-26 21:49:05 +0000135 clrbits_8(&gpio->par_simp1h,
136 GPIO_PAR_SIMP1H_DATA1_UNMASK |
137 GPIO_PAR_SIMP1H_VEN1_UNMASK);
138 setbits_8(&gpio->par_simp1h,
139 GPIO_PAR_SIMP1H_DATA1_U1TXD |
140 GPIO_PAR_SIMP1H_VEN1_U1RXD);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000141#elif defined(CONFIG_SYS_UART1_ALT2_GPIO)
Alison Wang35d23df2012-03-26 21:49:05 +0000142 clrbits_8(&gpio->par_ssih,
143 GPIO_PAR_SSIH_RXD_UNMASK |
144 GPIO_PAR_SSIH_TXD_UNMASK);
145 setbits_8(&gpio->par_ssih,
146 GPIO_PAR_SSIH_RXD_U1RXD |
147 GPIO_PAR_SSIH_TXD_U1TXD);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000148#endif
149 break;
150 case 2:
151#ifdef CONFIG_SYS_UART2_PRI_GPIO
Alison Wang35d23df2012-03-26 21:49:05 +0000152 setbits_8(&gpio->par_uart,
153 GPIO_PAR_UART_U2TXD |
154 GPIO_PAR_UART_U2RXD);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000155#elif defined(CONFIG_SYS_UART2_ALT1_GPIO)
Alison Wang35d23df2012-03-26 21:49:05 +0000156 clrbits_8(&gpio->par_dspih,
157 GPIO_PAR_DSPIH_SIN_UNMASK |
158 GPIO_PAR_DSPIH_SOUT_UNMASK);
159 setbits_8(&gpio->par_dspih,
160 GPIO_PAR_DSPIH_SIN_U2RXD |
161 GPIO_PAR_DSPIH_SOUT_U2TXD);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000162#elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
Alison Wang35d23df2012-03-26 21:49:05 +0000163 clrbits_8(&gpio->par_feci2c,
164 GPIO_PAR_FECI2C_SDA_UNMASK |
165 GPIO_PAR_FECI2C_SCL_UNMASK);
166 setbits_8(&gpio->par_feci2c,
167 GPIO_PAR_FECI2C_SDA_U2TXD |
168 GPIO_PAR_FECI2C_SCL_U2RXD);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000169#endif
170 break;
171 }
172}
173
174#if defined(CONFIG_CMD_NET)
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100175int fecpin_setclear(fec_info_t *info, int setclear)
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000176{
Alison Wang35d23df2012-03-26 21:49:05 +0000177 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100178 u32 fec0_base;
179
180 if (fec_get_base_addr(0, &fec0_base))
181 return -1;
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000182
183 if (setclear) {
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100184 if (info->iobase == fec0_base) {
Alison Wang35d23df2012-03-26 21:49:05 +0000185 setbits_8(&gpio->par_fec,
186 GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC);
187 setbits_8(&gpio->par_feci2c,
188 GPIO_PAR_FECI2C_MDC0 | GPIO_PAR_FECI2C_MDIO0);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000189 } else {
Alison Wang35d23df2012-03-26 21:49:05 +0000190 setbits_8(&gpio->par_fec,
191 GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC);
192 setbits_8(&gpio->par_feci2c,
193 GPIO_PAR_FECI2C_MDC1 | GPIO_PAR_FECI2C_MDIO1);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000194 }
195 } else {
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100196 if (info->iobase == fec0_base) {
Alison Wang35d23df2012-03-26 21:49:05 +0000197 clrbits_8(&gpio->par_fec,
198 GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC);
199 clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII0_UNMASK);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000200 } else {
Alison Wang35d23df2012-03-26 21:49:05 +0000201 clrbits_8(&gpio->par_fec,
202 GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC);
203 clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII1_UNMASK);
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000204 }
205 }
206 return 0;
207}
208#endif /* CONFIG_CMD_NET */
209#endif /* CONFIG_MCF5301x */
210
211#ifdef CONFIG_MCF532x
TsiChung Liewf6afe722007-06-18 13:50:13 -0500212void cpu_init_f(void)
213{
Alison Wang35d23df2012-03-26 21:49:05 +0000214 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
215 scm2_t *scm2 = (scm2_t *) MMAP_SCM2;
216 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
217 fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
Simon Glass660031e2014-06-07 22:07:58 -0600218#ifndef CONFIG_WATCHDOG
Alison Wang35d23df2012-03-26 21:49:05 +0000219 wdog_t *wdog = (wdog_t *) MMAP_WDOG;
TsiChung Liewf6afe722007-06-18 13:50:13 -0500220
221 /* watchdog is enabled by default - disable the watchdog */
Alison Wang35d23df2012-03-26 21:49:05 +0000222 out_be16(&wdog->cr, 0);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500223#endif
224
Alison Wang35d23df2012-03-26 21:49:05 +0000225 out_be32(&scm1->mpr0, 0x77777777);
226 out_be32(&scm2->pacra, 0);
227 out_be32(&scm2->pacrb, 0);
228 out_be32(&scm2->pacrc, 0);
229 out_be32(&scm2->pacrd, 0);
230 out_be32(&scm2->pacre, 0);
231 out_be32(&scm2->pacrf, 0);
232 out_be32(&scm2->pacrg, 0);
233 out_be32(&scm1->pacrh, 0);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500234
TsiChung Liewf6afe722007-06-18 13:50:13 -0500235 /* Port configuration */
Alison Wang35d23df2012-03-26 21:49:05 +0000236 out_8(&gpio->par_cs, 0);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500237
Tom Rini6a5dccc2022-11-16 13:10:41 -0500238#if (defined(CFG_SYS_CS0_BASE) && defined(CFG_SYS_CS0_MASK) \
239 && defined(CFG_SYS_CS0_CTRL))
240 out_be32(&fbcs->csar0, CFG_SYS_CS0_BASE);
241 out_be32(&fbcs->cscr0, CFG_SYS_CS0_CTRL);
242 out_be32(&fbcs->csmr0, CFG_SYS_CS0_MASK);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500243#endif
244
Tom Rini6a5dccc2022-11-16 13:10:41 -0500245#if (defined(CFG_SYS_CS1_BASE) && defined(CFG_SYS_CS1_MASK) \
246 && defined(CFG_SYS_CS1_CTRL))
TsiChung Liewf6afe722007-06-18 13:50:13 -0500247 /* Latch chipselect */
Alison Wang35d23df2012-03-26 21:49:05 +0000248 setbits_8(&gpio->par_cs, GPIO_PAR_CS1);
Tom Rini6a5dccc2022-11-16 13:10:41 -0500249 out_be32(&fbcs->csar1, CFG_SYS_CS1_BASE);
250 out_be32(&fbcs->cscr1, CFG_SYS_CS1_CTRL);
251 out_be32(&fbcs->csmr1, CFG_SYS_CS1_MASK);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500252#endif
253
Tom Rini6a5dccc2022-11-16 13:10:41 -0500254#if (defined(CFG_SYS_CS2_BASE) && defined(CFG_SYS_CS2_MASK) \
255 && defined(CFG_SYS_CS2_CTRL))
Alison Wang35d23df2012-03-26 21:49:05 +0000256 setbits_8(&gpio->par_cs, GPIO_PAR_CS2);
Tom Rini6a5dccc2022-11-16 13:10:41 -0500257 out_be32(&fbcs->csar2, CFG_SYS_CS2_BASE);
258 out_be32(&fbcs->cscr2, CFG_SYS_CS2_CTRL);
259 out_be32(&fbcs->csmr2, CFG_SYS_CS2_MASK);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500260#endif
261
Tom Rini6a5dccc2022-11-16 13:10:41 -0500262#if (defined(CFG_SYS_CS3_BASE) && defined(CFG_SYS_CS3_MASK) \
263 && defined(CFG_SYS_CS3_CTRL))
Alison Wang35d23df2012-03-26 21:49:05 +0000264 setbits_8(&gpio->par_cs, GPIO_PAR_CS3);
Tom Rini6a5dccc2022-11-16 13:10:41 -0500265 out_be32(&fbcs->csar3, CFG_SYS_CS3_BASE);
266 out_be32(&fbcs->cscr3, CFG_SYS_CS3_CTRL);
267 out_be32(&fbcs->csmr3, CFG_SYS_CS3_MASK);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500268#endif
269
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000270#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
271 && defined(CONFIG_SYS_CS4_CTRL))
Alison Wang35d23df2012-03-26 21:49:05 +0000272 setbits_8(&gpio->par_cs, GPIO_PAR_CS4);
273 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
274 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
275 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500276#endif
277
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000278#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
279 && defined(CONFIG_SYS_CS5_CTRL))
Alison Wang35d23df2012-03-26 21:49:05 +0000280 setbits_8(&gpio->par_cs, GPIO_PAR_CS5);
281 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
282 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
283 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500284#endif
TsiChung6373c0c2007-07-10 15:45:43 -0500285
Heiko Schocherf2850742012-10-24 13:48:22 +0200286#ifdef CONFIG_SYS_I2C_FSL
Alison Wang35d23df2012-03-26 21:49:05 +0000287 out_8(&gpio->par_feci2c,
288 GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
TsiChungLiew2325c9f2007-08-05 05:15:18 -0500289#endif
290
TsiChung6373c0c2007-07-10 15:45:43 -0500291 icache_enable();
TsiChung Liewf6afe722007-06-18 13:50:13 -0500292}
293
294/*
295 * initialize higher level parts of CPU like timers
296 */
297int cpu_init_r(void)
298{
TsiChung Liewf6afe722007-06-18 13:50:13 -0500299 return (0);
300}
TsiChungLiew74634c82007-08-05 03:55:21 -0500301
TsiChung Liewf9556a72010-03-09 19:17:52 -0600302void uart_port_conf(int port)
TsiChungLiew74634c82007-08-05 03:55:21 -0500303{
Alison Wang35d23df2012-03-26 21:49:05 +0000304 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
TsiChungLiew74634c82007-08-05 03:55:21 -0500305
306 /* Setup Ports: */
TsiChung Liewf9556a72010-03-09 19:17:52 -0600307 switch (port) {
TsiChungLiew74634c82007-08-05 03:55:21 -0500308 case 0:
Alison Wang35d23df2012-03-26 21:49:05 +0000309 clrbits_be16(&gpio->par_uart,
310 GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0);
311 setbits_be16(&gpio->par_uart,
312 GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0);
TsiChungLiew74634c82007-08-05 03:55:21 -0500313 break;
314 case 1:
Alison Wang35d23df2012-03-26 21:49:05 +0000315 clrbits_be16(&gpio->par_uart,
316 GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3));
317 setbits_be16(&gpio->par_uart,
318 GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3));
TsiChungLiew74634c82007-08-05 03:55:21 -0500319 break;
320 case 2:
TsiChung Liewf9556a72010-03-09 19:17:52 -0600321#ifdef CONFIG_SYS_UART2_ALT1_GPIO
Alison Wang35d23df2012-03-26 21:49:05 +0000322 clrbits_8(&gpio->par_timer, 0xf0);
323 setbits_8(&gpio->par_timer,
324 GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2);
TsiChung Liewf9556a72010-03-09 19:17:52 -0600325#elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
Alison Wang35d23df2012-03-26 21:49:05 +0000326 clrbits_8(&gpio->par_feci2c, 0x00ff);
327 setbits_8(&gpio->par_feci2c,
328 GPIO_PAR_FECI2C_SCL_UTXD2 | GPIO_PAR_FECI2C_SDA_URXD2);
Tom Rini6a5dccc2022-11-16 13:10:41 -0500329#elif defined(CFG_SYS_UART2_ALT3_GPIO)
Alison Wang35d23df2012-03-26 21:49:05 +0000330 clrbits_be16(&gpio->par_ssi, 0x0f00);
331 setbits_be16(&gpio->par_ssi,
332 GPIO_PAR_SSI_RXD(2) | GPIO_PAR_SSI_TXD(2));
TsiChung Liewf9556a72010-03-09 19:17:52 -0600333#endif
TsiChungLiew74634c82007-08-05 03:55:21 -0500334 break;
335 }
TsiChung Liew69b17572008-10-21 13:47:54 +0000336}
337
338#if defined(CONFIG_CMD_NET)
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100339int fecpin_setclear(fec_info_t *info, int setclear)
TsiChung Liew69b17572008-10-21 13:47:54 +0000340{
Alison Wang35d23df2012-03-26 21:49:05 +0000341 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
TsiChung Liew69b17572008-10-21 13:47:54 +0000342
343 if (setclear) {
Alison Wang35d23df2012-03-26 21:49:05 +0000344 setbits_8(&gpio->par_fec,
345 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
346 setbits_8(&gpio->par_feci2c,
347 GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO);
TsiChung Liew69b17572008-10-21 13:47:54 +0000348 } else {
Alison Wang35d23df2012-03-26 21:49:05 +0000349 clrbits_8(&gpio->par_fec,
350 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
351 clrbits_8(&gpio->par_feci2c,
352 GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO);
TsiChung Liew69b17572008-10-21 13:47:54 +0000353 }
354 return 0;
TsiChungLiew74634c82007-08-05 03:55:21 -0500355}
TsiChung Liew69b17572008-10-21 13:47:54 +0000356#endif
TsiChung Liewe7e4fc82008-10-22 11:38:21 +0000357#endif /* CONFIG_MCF532x */