Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * (C) Copyright 2000-2003 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 7 | * (C) Copyright 2004-2007, 2012 Freescale Semiconductor, Inc. |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 8 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
Simon Glass | 1d91ba7 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 12 | #include <cpu_func.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 13 | #include <init.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 14 | #include <watchdog.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 15 | #include <asm/immap.h> |
TsiChung Liew | 4d5414d | 2010-03-11 15:04:21 -0600 | [diff] [blame] | 16 | #include <asm/processor.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 17 | #include <asm/rtc.h> |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 18 | #include <asm/io.h> |
Marek Vasut | a334ec9 | 2012-10-03 13:28:44 +0000 | [diff] [blame] | 19 | #include <linux/compiler.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 20 | |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 21 | #if defined(CONFIG_CMD_NET) |
| 22 | #include <config.h> |
| 23 | #include <net.h> |
| 24 | #include <asm/fec.h> |
| 25 | #endif |
| 26 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 27 | void init_fbcs(void) |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 28 | { |
Marek Vasut | a334ec9 | 2012-10-03 13:28:44 +0000 | [diff] [blame] | 29 | fbcs_t *fbcs __maybe_unused = (fbcs_t *) MMAP_FBCS; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 30 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 31 | #if !defined(CONFIG_SERIAL_BOOT) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 32 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL)) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 36 | #endif |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 37 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 38 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 39 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL)) |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 40 | /* Latch chipselect */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 44 | #endif |
| 45 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL)) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 50 | #endif |
| 51 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL)) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 56 | #endif |
| 57 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 58 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL)) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 62 | #endif |
| 63 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 64 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL)) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 68 | #endif |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Angelo Dureghello | 71abddd | 2019-03-13 21:46:52 +0100 | [diff] [blame] | 71 | #ifdef CONFIG_CF_DSPI |
| 72 | void 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 Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 97 | /* |
| 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 | */ |
| 104 | void 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 Dureghello | 95a6998 | 2018-01-25 22:42:52 +0100 | [diff] [blame] | 204 | |
Yangbo Lu | 7334038 | 2019-06-21 11:42:28 +0800 | [diff] [blame] | 205 | #ifdef CONFIG_FSL_ESDHC_IMX |
Angelo Dureghello | 95a6998 | 2018-01-25 22:42:52 +0100 | [diff] [blame] | 206 | /* 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 Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 213 | #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 Dureghello | 71abddd | 2019-03-13 21:46:52 +0100 | [diff] [blame] | 235 | #ifdef CONFIG_CF_SPI |
| 236 | cfspi_port_conf(); |
| 237 | #endif |
| 238 | |
Heiko Schocher | f285074 | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 239 | #ifdef CONFIG_SYS_FSL_I2C |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 240 | 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(); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 247 | |
Angelo Dureghello | 7211b92 | 2017-05-15 00:17:48 +0200 | [diff] [blame] | 248 | #ifdef CONFIG_SYS_CS0_BASE |
TsiChung Liew | 4d5414d | 2010-03-11 15:04:21 -0600 | [diff] [blame] | 249 | /* |
| 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 Dureghello | 7211b92 | 2017-05-15 00:17:48 +0200 | [diff] [blame] | 256 | #endif |
TsiChung Liew | 4d5414d | 2010-03-11 15:04:21 -0600 | [diff] [blame] | 257 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 258 | icache_enable(); |
| 259 | } |
| 260 | |
| 261 | /* |
| 262 | * initialize higher level parts of CPU like timers |
| 263 | */ |
| 264 | int cpu_init_r(void) |
| 265 | { |
TsiChung Liew | 1be9e09 | 2008-07-09 15:47:27 -0500 | [diff] [blame] | 266 | #ifdef CONFIG_MCFRTC |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 267 | rtc_t *rtc = (rtc_t *)(CONFIG_SYS_MCFRTC_BASE); |
| 268 | rtcex_t *rtcex = (rtcex_t *)&rtc->extended; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 269 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 270 | out_be32(&rtcex->gocu, (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xffff); |
| 271 | out_be32(&rtcex->gocl, CONFIG_SYS_RTC_OSCILLATOR & 0xffff); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 272 | #endif |
| 273 | |
| 274 | return (0); |
| 275 | } |
| 276 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 277 | void uart_port_conf(int port) |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 278 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 279 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 280 | #ifdef CONFIG_MCF5441x |
| 281 | pm_t *pm = (pm_t *) MMAP_PM; |
| 282 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 283 | |
| 284 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 285 | switch (port) { |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 286 | #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 |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 369 | case 0: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 374 | break; |
| 375 | case 1: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 376 | #ifdef CONFIG_SYS_UART1_PRI_GPIO |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 381 | #elif defined(CONFIG_SYS_UART1_ALT1_GPIO) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 386 | #endif |
| 387 | break; |
| 388 | case 2: |
| 389 | #if defined(CONFIG_SYS_UART2_ALT1_GPIO) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 394 | #elif defined(CONFIG_SYS_UART2_ALT2_GPIO) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 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); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 399 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 400 | break; |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 401 | #endif /* CONFIG_MCF5445x */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 402 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | #if defined(CONFIG_CMD_NET) |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame] | 406 | int fecpin_setclear(fec_info_t *info, int setclear) |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 407 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 408 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame] | 409 | u32 fec0_base; |
| 410 | |
| 411 | if (fec_get_base_addr(0, &fec0_base)) |
| 412 | return -1; |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 413 | |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame] | 414 | #ifdef CONFIG_MCF5445x |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 415 | if (setclear) { |
Wolfgang Wegner | 5fe66d7 | 2010-03-30 19:19:50 +0100 | [diff] [blame] | 416 | #ifdef CONFIG_SYS_FEC_NO_SHARED_PHY |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame] | 417 | if (info->iobase == fec0_base) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 418 | setbits_be16(&gpio->par_feci2c, |
| 419 | GPIO_PAR_FECI2C_MDC0_MDC0 | |
| 420 | GPIO_PAR_FECI2C_MDIO0_MDIO0); |
Wolfgang Wegner | 5fe66d7 | 2010-03-30 19:19:50 +0100 | [diff] [blame] | 421 | else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 422 | setbits_be16(&gpio->par_feci2c, |
| 423 | GPIO_PAR_FECI2C_MDC1_MDC1 | |
| 424 | GPIO_PAR_FECI2C_MDIO1_MDIO1); |
Wolfgang Wegner | 5fe66d7 | 2010-03-30 19:19:50 +0100 | [diff] [blame] | 425 | #else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 426 | setbits_be16(&gpio->par_feci2c, |
| 427 | GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0); |
Wolfgang Wegner | 5fe66d7 | 2010-03-30 19:19:50 +0100 | [diff] [blame] | 428 | #endif |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 429 | |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame] | 430 | if (info->iobase == fec0_base) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 431 | setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_RMII_GPIO); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 432 | else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 433 | setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_RMII_ATA); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 434 | } else { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 435 | clrbits_be16(&gpio->par_feci2c, |
| 436 | GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 437 | |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame] | 438 | if (info->iobase == fec0_base) { |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 439 | #ifdef CONFIG_SYS_FEC_FULL_MII |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 440 | setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_MII); |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 441 | #else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 442 | clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC0_UNMASK); |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 443 | #endif |
| 444 | } else { |
| 445 | #ifdef CONFIG_SYS_FEC_FULL_MII |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 446 | setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_MII); |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 447 | #else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 448 | clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC1_UNMASK); |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 449 | #endif |
| 450 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 451 | } |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 452 | #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 Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 467 | return 0; |
| 468 | } |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 469 | #endif |