3 * (C) Copyright 2000-2003
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * (C) Copyright 2004-2008, 2012 Freescale Semiconductor, Inc.
7 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
9 * SPDX-License-Identifier: GPL-2.0+
14 #include <asm/immap.h>
17 #if defined(CONFIG_CMD_NET)
23 #ifdef CONFIG_MCF5301x
26 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
27 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
28 fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
30 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);
39 #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
40 && defined(CONFIG_SYS_CS0_CTRL))
41 setbits_8(&gpio->par_cs, GPIO_PAR_CS0_CS0);
42 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
43 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
44 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
47 #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
48 && defined(CONFIG_SYS_CS1_CTRL))
49 setbits_8(&gpio->par_cs, GPIO_PAR_CS1_CS1);
50 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
51 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
52 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
55 #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
56 && defined(CONFIG_SYS_CS2_CTRL))
57 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
58 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
59 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
62 #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
63 && defined(CONFIG_SYS_CS3_CTRL))
64 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
65 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
66 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
69 #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
70 && defined(CONFIG_SYS_CS4_CTRL))
71 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);
77 #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
78 && defined(CONFIG_SYS_CS5_CTRL))
79 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);
85 #ifdef CONFIG_SYS_I2C_FSL
86 out_8(&gpio->par_feci2c,
87 GPIO_PAR_FECI2C_SDA_SDA | GPIO_PAR_FECI2C_SCL_SCL);
93 /* initialize higher level parts of CPU like timers */
97 ccm_t *ccm = (ccm_t *) MMAP_CCM;
100 rtc_t *rtc = (rtc_t *) (CONFIG_SYS_MCFRTC_BASE);
101 rtcex_t *rtcex = (rtcex_t *) &rtc->extended;
103 out_be32(&rtcex->gocu, CONFIG_SYS_RTC_CNT);
104 out_be32(&rtcex->gocl, CONFIG_SYS_RTC_SETUP);
108 if (CONFIG_SYS_FEC0_MIIBASE != CONFIG_SYS_FEC1_MIIBASE)
109 setbits_be16(&ccm->misccr, CCM_MISCCR_FECM);
111 clrbits_be16(&ccm->misccr, CCM_MISCCR_FECM);
117 void uart_port_conf(int port)
119 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
124 clrbits_8(&gpio->par_uart,
125 GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
126 setbits_8(&gpio->par_uart,
127 GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
130 #ifdef CONFIG_SYS_UART1_ALT1_GPIO
131 clrbits_8(&gpio->par_simp1h,
132 GPIO_PAR_SIMP1H_DATA1_UNMASK |
133 GPIO_PAR_SIMP1H_VEN1_UNMASK);
134 setbits_8(&gpio->par_simp1h,
135 GPIO_PAR_SIMP1H_DATA1_U1TXD |
136 GPIO_PAR_SIMP1H_VEN1_U1RXD);
137 #elif defined(CONFIG_SYS_UART1_ALT2_GPIO)
138 clrbits_8(&gpio->par_ssih,
139 GPIO_PAR_SSIH_RXD_UNMASK |
140 GPIO_PAR_SSIH_TXD_UNMASK);
141 setbits_8(&gpio->par_ssih,
142 GPIO_PAR_SSIH_RXD_U1RXD |
143 GPIO_PAR_SSIH_TXD_U1TXD);
147 #ifdef CONFIG_SYS_UART2_PRI_GPIO
148 setbits_8(&gpio->par_uart,
149 GPIO_PAR_UART_U2TXD |
150 GPIO_PAR_UART_U2RXD);
151 #elif defined(CONFIG_SYS_UART2_ALT1_GPIO)
152 clrbits_8(&gpio->par_dspih,
153 GPIO_PAR_DSPIH_SIN_UNMASK |
154 GPIO_PAR_DSPIH_SOUT_UNMASK);
155 setbits_8(&gpio->par_dspih,
156 GPIO_PAR_DSPIH_SIN_U2RXD |
157 GPIO_PAR_DSPIH_SOUT_U2TXD);
158 #elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
159 clrbits_8(&gpio->par_feci2c,
160 GPIO_PAR_FECI2C_SDA_UNMASK |
161 GPIO_PAR_FECI2C_SCL_UNMASK);
162 setbits_8(&gpio->par_feci2c,
163 GPIO_PAR_FECI2C_SDA_U2TXD |
164 GPIO_PAR_FECI2C_SCL_U2RXD);
170 #if defined(CONFIG_CMD_NET)
171 int fecpin_setclear(struct eth_device *dev, int setclear)
173 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
174 struct fec_info_s *info = (struct fec_info_s *)dev->priv;
177 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
178 setbits_8(&gpio->par_fec,
179 GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC);
180 setbits_8(&gpio->par_feci2c,
181 GPIO_PAR_FECI2C_MDC0 | GPIO_PAR_FECI2C_MDIO0);
183 setbits_8(&gpio->par_fec,
184 GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC);
185 setbits_8(&gpio->par_feci2c,
186 GPIO_PAR_FECI2C_MDC1 | GPIO_PAR_FECI2C_MDIO1);
189 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
190 clrbits_8(&gpio->par_fec,
191 GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC);
192 clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII0_UNMASK);
194 clrbits_8(&gpio->par_fec,
195 GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC);
196 clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII1_UNMASK);
201 #endif /* CONFIG_CMD_NET */
202 #endif /* CONFIG_MCF5301x */
204 #ifdef CONFIG_MCF532x
205 void cpu_init_f(void)
207 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
208 scm2_t *scm2 = (scm2_t *) MMAP_SCM2;
209 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
210 fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
211 #ifndef CONFIG_WATCHDOG
212 wdog_t *wdog = (wdog_t *) MMAP_WDOG;
214 /* watchdog is enabled by default - disable the watchdog */
215 out_be16(&wdog->cr, 0);
218 out_be32(&scm1->mpr0, 0x77777777);
219 out_be32(&scm2->pacra, 0);
220 out_be32(&scm2->pacrb, 0);
221 out_be32(&scm2->pacrc, 0);
222 out_be32(&scm2->pacrd, 0);
223 out_be32(&scm2->pacre, 0);
224 out_be32(&scm2->pacrf, 0);
225 out_be32(&scm2->pacrg, 0);
226 out_be32(&scm1->pacrh, 0);
228 /* Port configuration */
229 out_8(&gpio->par_cs, 0);
231 #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
232 && defined(CONFIG_SYS_CS0_CTRL))
233 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
234 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
235 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
238 #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
239 && defined(CONFIG_SYS_CS1_CTRL))
240 /* Latch chipselect */
241 setbits_8(&gpio->par_cs, GPIO_PAR_CS1);
242 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
243 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
244 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
247 #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
248 && defined(CONFIG_SYS_CS2_CTRL))
249 setbits_8(&gpio->par_cs, GPIO_PAR_CS2);
250 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
251 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
252 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
255 #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
256 && defined(CONFIG_SYS_CS3_CTRL))
257 setbits_8(&gpio->par_cs, GPIO_PAR_CS3);
258 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
259 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
260 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
263 #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
264 && defined(CONFIG_SYS_CS4_CTRL))
265 setbits_8(&gpio->par_cs, GPIO_PAR_CS4);
266 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
267 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
268 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
271 #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
272 && defined(CONFIG_SYS_CS5_CTRL))
273 setbits_8(&gpio->par_cs, GPIO_PAR_CS5);
274 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
275 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
276 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
279 #ifdef CONFIG_SYS_I2C_FSL
280 out_8(&gpio->par_feci2c,
281 GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
288 * initialize higher level parts of CPU like timers
295 void uart_port_conf(int port)
297 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
302 clrbits_be16(&gpio->par_uart,
303 GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0);
304 setbits_be16(&gpio->par_uart,
305 GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0);
308 clrbits_be16(&gpio->par_uart,
309 GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3));
310 setbits_be16(&gpio->par_uart,
311 GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3));
314 #ifdef CONFIG_SYS_UART2_ALT1_GPIO
315 clrbits_8(&gpio->par_timer, 0xf0);
316 setbits_8(&gpio->par_timer,
317 GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2);
318 #elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
319 clrbits_8(&gpio->par_feci2c, 0x00ff);
320 setbits_8(&gpio->par_feci2c,
321 GPIO_PAR_FECI2C_SCL_UTXD2 | GPIO_PAR_FECI2C_SDA_URXD2);
322 #elif defined(CONFIG_SYS_UART2_ALT3_GPIO)
323 clrbits_be16(&gpio->par_ssi, 0x0f00);
324 setbits_be16(&gpio->par_ssi,
325 GPIO_PAR_SSI_RXD(2) | GPIO_PAR_SSI_TXD(2));
331 #if defined(CONFIG_CMD_NET)
332 int fecpin_setclear(struct eth_device *dev, int setclear)
334 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
337 setbits_8(&gpio->par_fec,
338 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
339 setbits_8(&gpio->par_feci2c,
340 GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO);
342 clrbits_8(&gpio->par_fec,
343 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
344 clrbits_8(&gpio->par_feci2c,
345 GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO);
350 #endif /* CONFIG_MCF532x */