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-2007, 2012 Freescale Semiconductor, Inc.
8 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
15 #include <asm/immap.h>
16 #include <asm/processor.h>
19 #include <linux/compiler.h>
21 #if defined(CONFIG_CMD_NET)
29 fbcs_t *fbcs __maybe_unused = (fbcs_t *) MMAP_FBCS;
31 #if !defined(CONFIG_SERIAL_BOOT)
32 #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
33 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);
39 #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
40 /* Latch chipselect */
41 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);
46 #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
47 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);
52 #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
53 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);
58 #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
59 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);
64 #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
65 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);
72 void cfspi_port_conf(void)
74 gpio_t *gpio = (gpio_t *)MMAP_GPIO;
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);
83 #ifdef CONFIG_MCF5441x
84 pm_t *pm = (pm_t *)MMAP_PM;
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);
92 out_8(&pm->pmcr0, 23);
98 * Breath some life into the CPU...
100 * Set up the memory map,
101 * initialize a bunch of registers,
102 * initialize the UPM's
104 void cpu_init_f(void)
106 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
108 #ifdef CONFIG_MCF5441x
109 scm_t *scm = (scm_t *) MMAP_SCM;
110 pm_t *pm = (pm_t *) MMAP_PM;
113 *(unsigned long *)(MMAP_L2_SW0 + 0x00000024) = 0;
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);
122 GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
123 GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
126 out_8(&pm->pmcr0, 17);
129 out_8(&pm->pmcr0, 18);
130 out_8(&pm->pmcr0, 19);
131 out_8(&pm->pmcr0, 20);
134 out_8(&pm->pmcr0, 22);
135 out_8(&pm->pmcr1, 4);
136 out_8(&pm->pmcr1, 7);
139 out_8(&pm->pmcr0, 28);
140 out_8(&pm->pmcr0, 29);
141 out_8(&pm->pmcr0, 30);
142 out_8(&pm->pmcr0, 31);
145 out_8(&pm->pmcr0, 32);
146 out_8(&pm->pmcr0, 33);
147 out_8(&pm->pmcr0, 34);
148 out_8(&pm->pmcr0, 35);
151 out_8(&pm->pmcr0, 36);
152 out_8(&pm->pmcr0, 37);
155 out_8(&pm->pmcr0, 44);
157 out_8(&pm->pmcr0, 45);
160 out_8(&pm->pmcr0, 51);
163 out_8(&pm->pmcr0, 53);
164 out_8(&pm->pmcr0, 54);
167 out_8(&pm->pmcr0, 63);
169 #ifdef CONFIG_SYS_I2C_0
170 out_8(&gpio->par_cani2c, 0xF0);
172 out_be16(&gpio->pcr_b, 0x003C);
174 out_8(&gpio->srcr_cani2c, 0x03);
176 #ifdef CONFIG_SYS_I2C_2
178 out_8(&gpio->par_ssi0h, 0xA0);
180 out_8(&gpio->par_ssi0h, 0xA8);
182 out_8(&gpio->par_ssi0l, 0x2);
184 out_8(&gpio->par_cani2c, 0xAA);
186 out_8(&gpio->par_uart0, 0xAF);
188 out_8(&gpio->par_uart1, 0xAF);
190 out_8(&gpio->par_uart2, 0xAF);
192 out_be16(&gpio->pcr_h, 0xF000);
194 #ifdef CONFIG_SYS_I2C_5
196 out_8(&gpio->par_uart1, 0x0A);
198 out_be16(&gpio->pcr_e, 0x0003);
199 out_be16(&gpio->pcr_f, 0xC000);
202 /* Lowest slew rate for UART0,1,2 */
203 out_8(&gpio->srcr_uart, 0x00);
205 #ifdef CONFIG_FSL_ESDHC_IMX
206 /* eSDHC pin as faster speed */
207 out_8(&gpio->srcr_sdhc, 0x03);
209 /* All esdhc pins as SD */
210 out_8(&gpio->par_sdhch, 0xff);
211 out_8(&gpio->par_sdhcl, 0xff);
213 #endif /* CONFIG_MCF5441x */
215 #ifdef CONFIG_MCF5445x
216 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
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);
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);
239 #ifdef CONFIG_SYS_FSL_I2C
240 out_be16(&gpio->par_feci2c,
241 GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
243 #endif /* CONFIG_MCF5445x */
245 /* FlexBus Chipselect */
248 #ifdef CONFIG_SYS_CS0_BASE
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.
254 if (CONFIG_SYS_CS0_BASE != 0)
255 setvbr(CONFIG_SYS_CS0_BASE);
262 * initialize higher level parts of CPU like timers
267 rtc_t *rtc = (rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
268 rtcex_t *rtcex = (rtcex_t *)&rtc->extended;
270 out_be32(&rtcex->gocu, (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xffff);
271 out_be32(&rtcex->gocl, CONFIG_SYS_RTC_OSCILLATOR & 0xffff);
277 void uart_port_conf(int port)
279 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
280 #ifdef CONFIG_MCF5441x
281 pm_t *pm = (pm_t *) MMAP_PM;
286 #ifdef CONFIG_MCF5441x
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
368 #ifdef CONFIG_MCF5445x
370 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);
376 #ifdef CONFIG_SYS_UART1_PRI_GPIO
377 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);
381 #elif defined(CONFIG_SYS_UART1_ALT1_GPIO)
382 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);
389 #if defined(CONFIG_SYS_UART2_ALT1_GPIO)
390 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);
394 #elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
395 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);
401 #endif /* CONFIG_MCF5445x */
405 #if defined(CONFIG_CMD_NET)
406 int fecpin_setclear(fec_info_t *info, int setclear)
408 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
411 if (fec_get_base_addr(0, &fec0_base))
414 #ifdef CONFIG_MCF5445x
416 #ifdef CONFIG_SYS_FEC_NO_SHARED_PHY
417 if (info->iobase == fec0_base)
418 setbits_be16(&gpio->par_feci2c,
419 GPIO_PAR_FECI2C_MDC0_MDC0 |
420 GPIO_PAR_FECI2C_MDIO0_MDIO0);
422 setbits_be16(&gpio->par_feci2c,
423 GPIO_PAR_FECI2C_MDC1_MDC1 |
424 GPIO_PAR_FECI2C_MDIO1_MDIO1);
426 setbits_be16(&gpio->par_feci2c,
427 GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
430 if (info->iobase == fec0_base)
431 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_RMII_GPIO);
433 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_RMII_ATA);
435 clrbits_be16(&gpio->par_feci2c,
436 GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
438 if (info->iobase == fec0_base) {
439 #ifdef CONFIG_SYS_FEC_FULL_MII
440 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_MII);
442 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC0_UNMASK);
445 #ifdef CONFIG_SYS_FEC_FULL_MII
446 setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_MII);
448 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC1_UNMASK);
452 #endif /* CONFIG_MCF5445x */
454 #ifdef CONFIG_MCF5441x
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);
465 clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC_MASK);