1 // SPDX-License-Identifier: GPL-2.0+
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * (C) Copyright 2004-2008, 2012 Freescale Semiconductor, Inc.
8 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
15 #include <asm/immap.h>
18 #if defined(CONFIG_MCFFEC)
24 #ifdef CONFIG_MCF5301x
27 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
28 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
29 fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
31 out_be32(&scm1->mpr, 0x77777777);
32 out_be32(&scm1->pacra, 0);
33 out_be32(&scm1->pacrb, 0);
34 out_be32(&scm1->pacrc, 0);
35 out_be32(&scm1->pacrd, 0);
36 out_be32(&scm1->pacre, 0);
37 out_be32(&scm1->pacrf, 0);
38 out_be32(&scm1->pacrg, 0);
40 #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
41 && defined(CONFIG_SYS_CS0_CTRL))
42 setbits_8(&gpio->par_cs, GPIO_PAR_CS0_CS0);
43 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
44 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
45 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
48 #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
49 && defined(CONFIG_SYS_CS1_CTRL))
50 setbits_8(&gpio->par_cs, GPIO_PAR_CS1_CS1);
51 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
52 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
53 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
56 #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
57 && defined(CONFIG_SYS_CS2_CTRL))
58 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
59 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
60 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
63 #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
64 && defined(CONFIG_SYS_CS3_CTRL))
65 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
66 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
67 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
70 #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
71 && defined(CONFIG_SYS_CS4_CTRL))
72 setbits_8(&gpio->par_cs, GPIO_PAR_CS4);
73 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
74 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
75 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
78 #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
79 && defined(CONFIG_SYS_CS5_CTRL))
80 setbits_8(&gpio->par_cs, GPIO_PAR_CS5);
81 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
82 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
83 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
86 #ifdef CONFIG_SYS_I2C_FSL
87 out_8(&gpio->par_feci2c,
88 GPIO_PAR_FECI2C_SDA_SDA | GPIO_PAR_FECI2C_SCL_SCL);
94 /* initialize higher level parts of CPU like timers */
98 u32 fec_mii_base0, fec_mii_base1;
99 ccm_t *ccm = (ccm_t *) MMAP_CCM;
102 rtc_t *rtc = (rtc_t *) (CONFIG_SYS_MCFRTC_BASE);
103 rtcex_t *rtcex = (rtcex_t *) &rtc->extended;
105 out_be32(&rtcex->gocu, CONFIG_SYS_RTC_CNT);
106 out_be32(&rtcex->gocl, CONFIG_SYS_RTC_SETUP);
110 fec_get_mii_base(0, &fec_mii_base0);
111 fec_get_mii_base(1, &fec_mii_base1);
113 if (fec_mii_base0 != fec_mii_base1)
114 setbits_be16(&ccm->misccr, CCM_MISCCR_FECM);
116 clrbits_be16(&ccm->misccr, CCM_MISCCR_FECM);
122 void uart_port_conf(int port)
124 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
129 clrbits_8(&gpio->par_uart,
130 GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
131 setbits_8(&gpio->par_uart,
132 GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
135 #ifdef CONFIG_SYS_UART1_ALT1_GPIO
136 clrbits_8(&gpio->par_simp1h,
137 GPIO_PAR_SIMP1H_DATA1_UNMASK |
138 GPIO_PAR_SIMP1H_VEN1_UNMASK);
139 setbits_8(&gpio->par_simp1h,
140 GPIO_PAR_SIMP1H_DATA1_U1TXD |
141 GPIO_PAR_SIMP1H_VEN1_U1RXD);
142 #elif defined(CONFIG_SYS_UART1_ALT2_GPIO)
143 clrbits_8(&gpio->par_ssih,
144 GPIO_PAR_SSIH_RXD_UNMASK |
145 GPIO_PAR_SSIH_TXD_UNMASK);
146 setbits_8(&gpio->par_ssih,
147 GPIO_PAR_SSIH_RXD_U1RXD |
148 GPIO_PAR_SSIH_TXD_U1TXD);
152 #ifdef CONFIG_SYS_UART2_PRI_GPIO
153 setbits_8(&gpio->par_uart,
154 GPIO_PAR_UART_U2TXD |
155 GPIO_PAR_UART_U2RXD);
156 #elif defined(CONFIG_SYS_UART2_ALT1_GPIO)
157 clrbits_8(&gpio->par_dspih,
158 GPIO_PAR_DSPIH_SIN_UNMASK |
159 GPIO_PAR_DSPIH_SOUT_UNMASK);
160 setbits_8(&gpio->par_dspih,
161 GPIO_PAR_DSPIH_SIN_U2RXD |
162 GPIO_PAR_DSPIH_SOUT_U2TXD);
163 #elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
164 clrbits_8(&gpio->par_feci2c,
165 GPIO_PAR_FECI2C_SDA_UNMASK |
166 GPIO_PAR_FECI2C_SCL_UNMASK);
167 setbits_8(&gpio->par_feci2c,
168 GPIO_PAR_FECI2C_SDA_U2TXD |
169 GPIO_PAR_FECI2C_SCL_U2RXD);
175 #if defined(CONFIG_CMD_NET)
176 int fecpin_setclear(fec_info_t *info, int setclear)
178 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
181 if (fec_get_base_addr(0, &fec0_base))
185 if (info->iobase == fec0_base) {
186 setbits_8(&gpio->par_fec,
187 GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC);
188 setbits_8(&gpio->par_feci2c,
189 GPIO_PAR_FECI2C_MDC0 | GPIO_PAR_FECI2C_MDIO0);
191 setbits_8(&gpio->par_fec,
192 GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC);
193 setbits_8(&gpio->par_feci2c,
194 GPIO_PAR_FECI2C_MDC1 | GPIO_PAR_FECI2C_MDIO1);
197 if (info->iobase == fec0_base) {
198 clrbits_8(&gpio->par_fec,
199 GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC);
200 clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII0_UNMASK);
202 clrbits_8(&gpio->par_fec,
203 GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC);
204 clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII1_UNMASK);
209 #endif /* CONFIG_CMD_NET */
210 #endif /* CONFIG_MCF5301x */
212 #ifdef CONFIG_MCF532x
213 void cpu_init_f(void)
215 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
216 scm2_t *scm2 = (scm2_t *) MMAP_SCM2;
217 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
218 fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
219 #ifndef CONFIG_WATCHDOG
220 wdog_t *wdog = (wdog_t *) MMAP_WDOG;
222 /* watchdog is enabled by default - disable the watchdog */
223 out_be16(&wdog->cr, 0);
226 out_be32(&scm1->mpr0, 0x77777777);
227 out_be32(&scm2->pacra, 0);
228 out_be32(&scm2->pacrb, 0);
229 out_be32(&scm2->pacrc, 0);
230 out_be32(&scm2->pacrd, 0);
231 out_be32(&scm2->pacre, 0);
232 out_be32(&scm2->pacrf, 0);
233 out_be32(&scm2->pacrg, 0);
234 out_be32(&scm1->pacrh, 0);
236 /* Port configuration */
237 out_8(&gpio->par_cs, 0);
239 #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
240 && defined(CONFIG_SYS_CS0_CTRL))
241 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
242 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
243 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
246 #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
247 && defined(CONFIG_SYS_CS1_CTRL))
248 /* Latch chipselect */
249 setbits_8(&gpio->par_cs, GPIO_PAR_CS1);
250 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
251 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
252 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
255 #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
256 && defined(CONFIG_SYS_CS2_CTRL))
257 setbits_8(&gpio->par_cs, GPIO_PAR_CS2);
258 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
259 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
260 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
263 #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
264 && defined(CONFIG_SYS_CS3_CTRL))
265 setbits_8(&gpio->par_cs, GPIO_PAR_CS3);
266 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
267 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
268 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
271 #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
272 && defined(CONFIG_SYS_CS4_CTRL))
273 setbits_8(&gpio->par_cs, GPIO_PAR_CS4);
274 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
275 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
276 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
279 #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
280 && defined(CONFIG_SYS_CS5_CTRL))
281 setbits_8(&gpio->par_cs, GPIO_PAR_CS5);
282 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
283 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
284 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
287 #ifdef CONFIG_SYS_I2C_FSL
288 out_8(&gpio->par_feci2c,
289 GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
296 * initialize higher level parts of CPU like timers
303 void uart_port_conf(int port)
305 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
310 clrbits_be16(&gpio->par_uart,
311 GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0);
312 setbits_be16(&gpio->par_uart,
313 GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0);
316 clrbits_be16(&gpio->par_uart,
317 GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3));
318 setbits_be16(&gpio->par_uart,
319 GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3));
322 #ifdef CONFIG_SYS_UART2_ALT1_GPIO
323 clrbits_8(&gpio->par_timer, 0xf0);
324 setbits_8(&gpio->par_timer,
325 GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2);
326 #elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
327 clrbits_8(&gpio->par_feci2c, 0x00ff);
328 setbits_8(&gpio->par_feci2c,
329 GPIO_PAR_FECI2C_SCL_UTXD2 | GPIO_PAR_FECI2C_SDA_URXD2);
330 #elif defined(CONFIG_SYS_UART2_ALT3_GPIO)
331 clrbits_be16(&gpio->par_ssi, 0x0f00);
332 setbits_be16(&gpio->par_ssi,
333 GPIO_PAR_SSI_RXD(2) | GPIO_PAR_SSI_TXD(2));
339 #if defined(CONFIG_CMD_NET)
340 int fecpin_setclear(fec_info_t *info, int setclear)
342 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
345 setbits_8(&gpio->par_fec,
346 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
347 setbits_8(&gpio->par_feci2c,
348 GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO);
350 clrbits_8(&gpio->par_fec,
351 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
352 clrbits_8(&gpio->par_feci2c,
353 GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO);
358 #endif /* CONFIG_MCF532x */