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> |
| 12 | #include <watchdog.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 13 | #include <asm/immap.h> |
TsiChung Liew | 4d5414d | 2010-03-11 15:04:21 -0600 | [diff] [blame] | 14 | #include <asm/processor.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 15 | #include <asm/rtc.h> |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 16 | #include <asm/io.h> |
Marek Vasut | a334ec9 | 2012-10-03 13:28:44 +0000 | [diff] [blame] | 17 | #include <linux/compiler.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 18 | |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 19 | #if defined(CONFIG_CMD_NET) |
| 20 | #include <config.h> |
| 21 | #include <net.h> |
| 22 | #include <asm/fec.h> |
| 23 | #endif |
| 24 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 25 | void init_fbcs(void) |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 26 | { |
Marek Vasut | a334ec9 | 2012-10-03 13:28:44 +0000 | [diff] [blame] | 27 | fbcs_t *fbcs __maybe_unused = (fbcs_t *) MMAP_FBCS; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 28 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 29 | #if !defined(CONFIG_SERIAL_BOOT) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 30 | #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] | 31 | out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE); |
| 32 | out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL); |
| 33 | out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 34 | #endif |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 35 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 36 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 37 | #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] | 38 | /* Latch chipselect */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 39 | out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE); |
| 40 | out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL); |
| 41 | out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 42 | #endif |
| 43 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 44 | #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] | 45 | out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE); |
| 46 | out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL); |
| 47 | out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 48 | #endif |
| 49 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 50 | #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] | 51 | out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE); |
| 52 | out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL); |
| 53 | out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 54 | #endif |
| 55 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | #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] | 57 | out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE); |
| 58 | out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL); |
| 59 | out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 60 | #endif |
| 61 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 62 | #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] | 63 | out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE); |
| 64 | out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL); |
| 65 | out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 66 | #endif |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /* |
| 70 | * Breath some life into the CPU... |
| 71 | * |
| 72 | * Set up the memory map, |
| 73 | * initialize a bunch of registers, |
| 74 | * initialize the UPM's |
| 75 | */ |
| 76 | void cpu_init_f(void) |
| 77 | { |
| 78 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 79 | |
| 80 | #ifdef CONFIG_MCF5441x |
| 81 | scm_t *scm = (scm_t *) MMAP_SCM; |
| 82 | pm_t *pm = (pm_t *) MMAP_PM; |
| 83 | |
| 84 | /* Disable Switch */ |
| 85 | *(unsigned long *)(MMAP_L2_SW0 + 0x00000024) = 0; |
| 86 | |
| 87 | /* Disable core watchdog */ |
| 88 | out_be16(&scm->cwcr, 0); |
| 89 | out_8(&gpio->par_fbctl, |
| 90 | GPIO_PAR_FBCTL_ALE_FB_ALE | GPIO_PAR_FBCTL_OE_FB_OE | |
| 91 | GPIO_PAR_FBCTL_FBCLK | GPIO_PAR_FBCTL_RW | |
| 92 | GPIO_PAR_FBCTL_TA_TA); |
| 93 | out_8(&gpio->par_be, |
| 94 | GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 | |
| 95 | GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0); |
| 96 | |
| 97 | /* eDMA */ |
| 98 | out_8(&pm->pmcr0, 17); |
| 99 | |
| 100 | /* INTR0 - INTR2 */ |
| 101 | out_8(&pm->pmcr0, 18); |
| 102 | out_8(&pm->pmcr0, 19); |
| 103 | out_8(&pm->pmcr0, 20); |
| 104 | |
| 105 | /* I2C */ |
| 106 | out_8(&pm->pmcr0, 22); |
| 107 | out_8(&pm->pmcr1, 4); |
| 108 | out_8(&pm->pmcr1, 7); |
| 109 | |
| 110 | /* DTMR0 - DTMR3*/ |
| 111 | out_8(&pm->pmcr0, 28); |
| 112 | out_8(&pm->pmcr0, 29); |
| 113 | out_8(&pm->pmcr0, 30); |
| 114 | out_8(&pm->pmcr0, 31); |
| 115 | |
| 116 | /* PIT0 - PIT3 */ |
| 117 | out_8(&pm->pmcr0, 32); |
| 118 | out_8(&pm->pmcr0, 33); |
| 119 | out_8(&pm->pmcr0, 34); |
| 120 | out_8(&pm->pmcr0, 35); |
| 121 | |
| 122 | /* Edge Port */ |
| 123 | out_8(&pm->pmcr0, 36); |
| 124 | out_8(&pm->pmcr0, 37); |
| 125 | |
| 126 | /* USB OTG */ |
| 127 | out_8(&pm->pmcr0, 44); |
| 128 | /* USB Host */ |
| 129 | out_8(&pm->pmcr0, 45); |
| 130 | |
| 131 | /* ESDHC */ |
| 132 | out_8(&pm->pmcr0, 51); |
| 133 | |
| 134 | /* ENET0 - ENET1 */ |
| 135 | out_8(&pm->pmcr0, 53); |
| 136 | out_8(&pm->pmcr0, 54); |
| 137 | |
| 138 | /* NAND */ |
| 139 | out_8(&pm->pmcr0, 63); |
| 140 | |
| 141 | #ifdef CONFIG_SYS_I2C_0 |
| 142 | out_8(&gpio->par_cani2c, 0xF0); |
| 143 | /* I2C0 pull up */ |
| 144 | out_be16(&gpio->pcr_b, 0x003C); |
| 145 | /* I2C0 max speed */ |
| 146 | out_8(&gpio->srcr_cani2c, 0x03); |
| 147 | #endif |
| 148 | #ifdef CONFIG_SYS_I2C_2 |
| 149 | /* I2C2 */ |
| 150 | out_8(&gpio->par_ssi0h, 0xA0); |
| 151 | /* I2C2, UART7 */ |
| 152 | out_8(&gpio->par_ssi0h, 0xA8); |
| 153 | /* UART7 */ |
| 154 | out_8(&gpio->par_ssi0l, 0x2); |
| 155 | /* UART8, UART9 */ |
| 156 | out_8(&gpio->par_cani2c, 0xAA); |
| 157 | /* UART4, UART0 */ |
| 158 | out_8(&gpio->par_uart0, 0xAF); |
| 159 | /* UART5, UART1 */ |
| 160 | out_8(&gpio->par_uart1, 0xAF); |
| 161 | /* UART6, UART2 */ |
| 162 | out_8(&gpio->par_uart2, 0xAF); |
| 163 | /* I2C2 pull up */ |
| 164 | out_be16(&gpio->pcr_h, 0xF000); |
| 165 | #endif |
| 166 | #ifdef CONFIG_SYS_I2C_5 |
| 167 | /* I2C5 */ |
| 168 | out_8(&gpio->par_uart1, 0x0A); |
| 169 | /* I2C5 pull up */ |
| 170 | out_be16(&gpio->pcr_e, 0x0003); |
| 171 | out_be16(&gpio->pcr_f, 0xC000); |
| 172 | #endif |
| 173 | |
| 174 | /* Lowest slew rate for UART0,1,2 */ |
| 175 | out_8(&gpio->srcr_uart, 0x00); |
Angelo Dureghello | 95a6998 | 2018-01-25 22:42:52 +0100 | [diff] [blame] | 176 | |
| 177 | #ifdef CONFIG_FSL_ESDHC |
| 178 | /* eSDHC pin as faster speed */ |
| 179 | out_8(&gpio->srcr_sdhc, 0x03); |
| 180 | |
| 181 | /* All esdhc pins as SD */ |
| 182 | out_8(&gpio->par_sdhch, 0xff); |
| 183 | out_8(&gpio->par_sdhcl, 0xff); |
| 184 | #endif |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 185 | #endif /* CONFIG_MCF5441x */ |
| 186 | |
| 187 | #ifdef CONFIG_MCF5445x |
| 188 | scm1_t *scm1 = (scm1_t *) MMAP_SCM1; |
| 189 | |
| 190 | out_be32(&scm1->mpr, 0x77777777); |
| 191 | out_be32(&scm1->pacra, 0); |
| 192 | out_be32(&scm1->pacrb, 0); |
| 193 | out_be32(&scm1->pacrc, 0); |
| 194 | out_be32(&scm1->pacrd, 0); |
| 195 | out_be32(&scm1->pacre, 0); |
| 196 | out_be32(&scm1->pacrf, 0); |
| 197 | out_be32(&scm1->pacrg, 0); |
| 198 | |
| 199 | /* FlexBus */ |
| 200 | out_8(&gpio->par_be, |
| 201 | GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 | |
| 202 | GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0); |
| 203 | out_8(&gpio->par_fbctl, |
| 204 | GPIO_PAR_FBCTL_OE | GPIO_PAR_FBCTL_TA_TA | |
| 205 | GPIO_PAR_FBCTL_RW_RW | GPIO_PAR_FBCTL_TS_TS); |
| 206 | |
Heiko Schocher | f285074 | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 207 | #ifdef CONFIG_SYS_FSL_I2C |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 208 | out_be16(&gpio->par_feci2c, |
| 209 | GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA); |
| 210 | #endif |
| 211 | #endif /* CONFIG_MCF5445x */ |
| 212 | |
| 213 | /* FlexBus Chipselect */ |
| 214 | init_fbcs(); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 215 | |
Angelo Dureghello | 7211b92 | 2017-05-15 00:17:48 +0200 | [diff] [blame] | 216 | #ifdef CONFIG_SYS_CS0_BASE |
TsiChung Liew | 4d5414d | 2010-03-11 15:04:21 -0600 | [diff] [blame] | 217 | /* |
| 218 | * now the flash base address is no longer at 0 (Newer ColdFire family |
| 219 | * boot at address 0 instead of 0xFFnn_nnnn). The vector table must |
| 220 | * also move to the new location. |
| 221 | */ |
| 222 | if (CONFIG_SYS_CS0_BASE != 0) |
| 223 | setvbr(CONFIG_SYS_CS0_BASE); |
Angelo Dureghello | 7211b92 | 2017-05-15 00:17:48 +0200 | [diff] [blame] | 224 | #endif |
TsiChung Liew | 4d5414d | 2010-03-11 15:04:21 -0600 | [diff] [blame] | 225 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 226 | icache_enable(); |
| 227 | } |
| 228 | |
| 229 | /* |
| 230 | * initialize higher level parts of CPU like timers |
| 231 | */ |
| 232 | int cpu_init_r(void) |
| 233 | { |
TsiChung Liew | 1be9e09 | 2008-07-09 15:47:27 -0500 | [diff] [blame] | 234 | #ifdef CONFIG_MCFRTC |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 235 | rtc_t *rtc = (rtc_t *)(CONFIG_SYS_MCFRTC_BASE); |
| 236 | rtcex_t *rtcex = (rtcex_t *)&rtc->extended; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 237 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 238 | out_be32(&rtcex->gocu, (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xffff); |
| 239 | out_be32(&rtcex->gocl, CONFIG_SYS_RTC_OSCILLATOR & 0xffff); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 240 | #endif |
| 241 | |
| 242 | return (0); |
| 243 | } |
| 244 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 245 | void uart_port_conf(int port) |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 246 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 247 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 248 | #ifdef CONFIG_MCF5441x |
| 249 | pm_t *pm = (pm_t *) MMAP_PM; |
| 250 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 251 | |
| 252 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 253 | switch (port) { |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 254 | #ifdef CONFIG_MCF5441x |
| 255 | case 0: |
| 256 | /* UART0 */ |
| 257 | out_8(&pm->pmcr0, 24); |
| 258 | clrbits_8(&gpio->par_uart0, |
| 259 | ~(GPIO_PAR_UART0_U0RXD_MASK | GPIO_PAR_UART0_U0TXD_MASK)); |
| 260 | setbits_8(&gpio->par_uart0, |
| 261 | GPIO_PAR_UART0_U0RXD_U0RXD | GPIO_PAR_UART0_U0TXD_U0TXD); |
| 262 | break; |
| 263 | case 1: |
| 264 | /* UART1 */ |
| 265 | out_8(&pm->pmcr0, 25); |
| 266 | clrbits_8(&gpio->par_uart1, |
| 267 | ~(GPIO_PAR_UART1_U1RXD_MASK | GPIO_PAR_UART1_U1TXD_MASK)); |
| 268 | setbits_8(&gpio->par_uart1, |
| 269 | GPIO_PAR_UART1_U1RXD_U1RXD | GPIO_PAR_UART1_U1TXD_U1TXD); |
| 270 | break; |
| 271 | case 2: |
| 272 | /* UART2 */ |
| 273 | out_8(&pm->pmcr0, 26); |
| 274 | clrbits_8(&gpio->par_uart2, |
| 275 | ~(GPIO_PAR_UART2_U2RXD_MASK | GPIO_PAR_UART2_U2TXD_MASK)); |
| 276 | setbits_8(&gpio->par_uart2, |
| 277 | GPIO_PAR_UART2_U2RXD_U2RXD | GPIO_PAR_UART2_U2TXD_U2TXD); |
| 278 | break; |
| 279 | case 3: |
| 280 | /* UART3 */ |
| 281 | out_8(&pm->pmcr0, 27); |
| 282 | clrbits_8(&gpio->par_dspi0, |
| 283 | ~(GPIO_PAR_DSPI0_SIN_MASK | GPIO_PAR_DSPI0_SOUT_MASK)); |
| 284 | setbits_8(&gpio->par_dspi0, |
| 285 | GPIO_PAR_DSPI0_SIN_U3RXD | GPIO_PAR_DSPI0_SOUT_U3TXD); |
| 286 | break; |
| 287 | case 4: |
| 288 | /* UART4 */ |
| 289 | out_8(&pm->pmcr1, 24); |
| 290 | clrbits_8(&gpio->par_uart0, |
| 291 | ~(GPIO_PAR_UART0_U0CTS_MASK | GPIO_PAR_UART0_U0RTS_MASK)); |
| 292 | setbits_8(&gpio->par_uart0, |
| 293 | GPIO_PAR_UART0_U0CTS_U4TXD | GPIO_PAR_UART0_U0RTS_U4RXD); |
| 294 | break; |
| 295 | case 5: |
| 296 | /* UART5 */ |
| 297 | out_8(&pm->pmcr1, 25); |
| 298 | clrbits_8(&gpio->par_uart1, |
| 299 | ~(GPIO_PAR_UART1_U1CTS_MASK | GPIO_PAR_UART1_U1RTS_MASK)); |
| 300 | setbits_8(&gpio->par_uart1, |
| 301 | GPIO_PAR_UART1_U1CTS_U5TXD | GPIO_PAR_UART1_U1RTS_U5RXD); |
| 302 | break; |
| 303 | case 6: |
| 304 | /* UART6 */ |
| 305 | out_8(&pm->pmcr1, 26); |
| 306 | clrbits_8(&gpio->par_uart2, |
| 307 | ~(GPIO_PAR_UART2_U2CTS_MASK | GPIO_PAR_UART2_U2RTS_MASK)); |
| 308 | setbits_8(&gpio->par_uart2, |
| 309 | GPIO_PAR_UART2_U2CTS_U6TXD | GPIO_PAR_UART2_U2RTS_U6RXD); |
| 310 | break; |
| 311 | case 7: |
| 312 | /* UART7 */ |
| 313 | out_8(&pm->pmcr1, 27); |
| 314 | clrbits_8(&gpio->par_ssi0h, ~GPIO_PAR_SSI0H_RXD_MASK); |
| 315 | clrbits_8(&gpio->par_ssi0l, ~GPIO_PAR_SSI0L_BCLK_MASK); |
| 316 | setbits_8(&gpio->par_ssi0h, GPIO_PAR_SSI0H_FS_U7TXD); |
| 317 | setbits_8(&gpio->par_ssi0l, GPIO_PAR_SSI0L_BCLK_U7RXD); |
| 318 | break; |
| 319 | case 8: |
| 320 | /* UART8 */ |
| 321 | out_8(&pm->pmcr0, 28); |
| 322 | clrbits_8(&gpio->par_cani2c, |
| 323 | ~(GPIO_PAR_CANI2C_I2C0SCL_MASK | GPIO_PAR_CANI2C_I2C0SDA_MASK)); |
| 324 | setbits_8(&gpio->par_cani2c, |
| 325 | GPIO_PAR_CANI2C_I2C0SCL_U8TXD | GPIO_PAR_CANI2C_I2C0SDA_U8RXD); |
| 326 | break; |
| 327 | case 9: |
| 328 | /* UART9 */ |
| 329 | out_8(&pm->pmcr1, 29); |
| 330 | clrbits_8(&gpio->par_cani2c, |
| 331 | ~(GPIO_PAR_CANI2C_CAN1TX_MASK | GPIO_PAR_CANI2C_CAN1RX_MASK)); |
| 332 | setbits_8(&gpio->par_cani2c, |
| 333 | GPIO_PAR_CANI2C_CAN1TX_U9TXD | GPIO_PAR_CANI2C_CAN1RX_U9RXD); |
| 334 | break; |
| 335 | #endif |
| 336 | #ifdef CONFIG_MCF5445x |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 337 | case 0: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 338 | clrbits_8(&gpio->par_uart, |
| 339 | GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD); |
| 340 | setbits_8(&gpio->par_uart, |
| 341 | GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 342 | break; |
| 343 | case 1: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 344 | #ifdef CONFIG_SYS_UART1_PRI_GPIO |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 345 | clrbits_8(&gpio->par_uart, |
| 346 | GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD); |
| 347 | setbits_8(&gpio->par_uart, |
| 348 | GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 349 | #elif defined(CONFIG_SYS_UART1_ALT1_GPIO) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 350 | clrbits_be16(&gpio->par_ssi, |
| 351 | ~(GPIO_PAR_SSI_SRXD_UNMASK | GPIO_PAR_SSI_STXD_UNMASK)); |
| 352 | setbits_be16(&gpio->par_ssi, |
| 353 | GPIO_PAR_SSI_SRXD_U1RXD | GPIO_PAR_SSI_STXD_U1TXD); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 354 | #endif |
| 355 | break; |
| 356 | case 2: |
| 357 | #if defined(CONFIG_SYS_UART2_ALT1_GPIO) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 358 | clrbits_8(&gpio->par_timer, |
| 359 | ~(GPIO_PAR_TIMER_T3IN_UNMASK | GPIO_PAR_TIMER_T2IN_UNMASK)); |
| 360 | setbits_8(&gpio->par_timer, |
| 361 | GPIO_PAR_TIMER_T3IN_U2RXD | GPIO_PAR_TIMER_T2IN_U2TXD); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 362 | #elif defined(CONFIG_SYS_UART2_ALT2_GPIO) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 363 | clrbits_8(&gpio->par_timer, |
| 364 | ~(GPIO_PAR_FECI2C_SCL_UNMASK | GPIO_PAR_FECI2C_SDA_UNMASK)); |
| 365 | setbits_8(&gpio->par_timer, |
| 366 | GPIO_PAR_FECI2C_SCL_U2TXD | GPIO_PAR_FECI2C_SDA_U2RXD); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 367 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 368 | break; |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 369 | #endif /* CONFIG_MCF5445x */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 370 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | #if defined(CONFIG_CMD_NET) |
| 374 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 375 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 376 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
Masahiro Yamada | 35b2eb7 | 2013-10-16 13:53:04 +0900 | [diff] [blame] | 377 | #ifdef CONFIG_MCF5445x |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 378 | struct fec_info_s *info = (struct fec_info_s *)dev->priv; |
| 379 | |
| 380 | if (setclear) { |
Wolfgang Wegner | 5fe66d7 | 2010-03-30 19:19:50 +0100 | [diff] [blame] | 381 | #ifdef CONFIG_SYS_FEC_NO_SHARED_PHY |
| 382 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 383 | setbits_be16(&gpio->par_feci2c, |
| 384 | GPIO_PAR_FECI2C_MDC0_MDC0 | |
| 385 | GPIO_PAR_FECI2C_MDIO0_MDIO0); |
Wolfgang Wegner | 5fe66d7 | 2010-03-30 19:19:50 +0100 | [diff] [blame] | 386 | else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 387 | setbits_be16(&gpio->par_feci2c, |
| 388 | GPIO_PAR_FECI2C_MDC1_MDC1 | |
| 389 | GPIO_PAR_FECI2C_MDIO1_MDIO1); |
Wolfgang Wegner | 5fe66d7 | 2010-03-30 19:19:50 +0100 | [diff] [blame] | 390 | #else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 391 | setbits_be16(&gpio->par_feci2c, |
| 392 | GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0); |
Wolfgang Wegner | 5fe66d7 | 2010-03-30 19:19:50 +0100 | [diff] [blame] | 393 | #endif |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 394 | |
| 395 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 396 | setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_RMII_GPIO); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 397 | else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 398 | setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_RMII_ATA); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 399 | } else { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 400 | clrbits_be16(&gpio->par_feci2c, |
| 401 | GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 402 | |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 403 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { |
| 404 | #ifdef CONFIG_SYS_FEC_FULL_MII |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 405 | setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_MII); |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 406 | #else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 407 | clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC0_UNMASK); |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 408 | #endif |
| 409 | } else { |
| 410 | #ifdef CONFIG_SYS_FEC_FULL_MII |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 411 | setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_MII); |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 412 | #else |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 413 | clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC1_UNMASK); |
Wolfgang Wegner | a19e62d | 2010-03-30 19:19:51 +0100 | [diff] [blame] | 414 | #endif |
| 415 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 416 | } |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 417 | #endif /* CONFIG_MCF5445x */ |
| 418 | |
| 419 | #ifdef CONFIG_MCF5441x |
| 420 | if (setclear) { |
| 421 | out_8(&gpio->par_fec, 0x03); |
| 422 | out_8(&gpio->srcr_fec, 0x0F); |
| 423 | clrsetbits_8(&gpio->par_simp0h, ~GPIO_PAR_SIMP0H_DAT_MASK, |
| 424 | GPIO_PAR_SIMP0H_DAT_GPIO); |
| 425 | clrsetbits_8(&gpio->pddr_g, ~GPIO_PDDR_G4_MASK, |
| 426 | GPIO_PDDR_G4_OUTPUT); |
| 427 | clrbits_8(&gpio->podr_g, ~GPIO_PODR_G4_MASK); |
| 428 | |
| 429 | } else |
| 430 | clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC_MASK); |
| 431 | #endif |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 432 | return 0; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 433 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 434 | #endif |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 435 | |
| 436 | #ifdef CONFIG_CF_DSPI |
| 437 | void cfspi_port_conf(void) |
| 438 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 439 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 440 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 441 | #ifdef CONFIG_MCF5445x |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 442 | out_8(&gpio->par_dspi, |
| 443 | GPIO_PAR_DSPI_SIN_SIN | |
| 444 | GPIO_PAR_DSPI_SOUT_SOUT | |
| 445 | GPIO_PAR_DSPI_SCK_SCK); |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 446 | #endif |
| 447 | |
| 448 | #ifdef CONFIG_MCF5441x |
| 449 | pm_t *pm = (pm_t *) MMAP_PM; |
| 450 | |
| 451 | out_8(&gpio->par_dspi0, |
| 452 | GPIO_PAR_DSPI0_SIN_DSPI0SIN | GPIO_PAR_DSPI0_SOUT_DSPI0SOUT | |
| 453 | GPIO_PAR_DSPI0_SCK_DSPI0SCK); |
| 454 | out_8(&gpio->srcr_dspiow, 3); |
| 455 | |
| 456 | /* DSPI0 */ |
| 457 | out_8(&pm->pmcr0, 23); |
| 458 | #endif |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | int cfspi_claim_bus(uint bus, uint cs) |
| 462 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 463 | dspi_t *dspi = (dspi_t *) MMAP_DSPI; |
| 464 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 465 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 466 | if ((in_be32(&dspi->sr) & DSPI_SR_TXRXS) != DSPI_SR_TXRXS) |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 467 | return -1; |
| 468 | |
| 469 | /* Clear FIFO and resume transfer */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 470 | clrbits_be32(&dspi->mcr, DSPI_MCR_CTXF | DSPI_MCR_CRXF); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 471 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 472 | #ifdef CONFIG_MCF5445x |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 473 | switch (cs) { |
| 474 | case 0: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 475 | clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0); |
| 476 | setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 477 | break; |
| 478 | case 1: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 479 | clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1); |
| 480 | setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 481 | break; |
| 482 | case 2: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 483 | clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2); |
| 484 | setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 485 | break; |
Wolfgang Wegner | acf782f | 2010-03-30 19:20:31 +0100 | [diff] [blame] | 486 | case 3: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 487 | clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK); |
| 488 | setbits_8(&gpio->par_dma, GPIO_PAR_DMA_DACK0_PCS3); |
Wolfgang Wegner | acf782f | 2010-03-30 19:20:31 +0100 | [diff] [blame] | 489 | break; |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 490 | case 5: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 491 | clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5); |
| 492 | setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 493 | break; |
| 494 | } |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 495 | #endif |
| 496 | |
| 497 | #ifdef CONFIG_MCF5441x |
| 498 | switch (cs) { |
| 499 | case 0: |
| 500 | clrbits_8(&gpio->par_dspi0, ~GPIO_PAR_DSPI0_PCS0_MASK); |
| 501 | setbits_8(&gpio->par_dspi0, GPIO_PAR_DSPI0_PCS0_DSPI0PCS0); |
| 502 | break; |
| 503 | case 1: |
| 504 | clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1); |
| 505 | setbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1); |
| 506 | break; |
| 507 | } |
| 508 | #endif |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 509 | |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | void cfspi_release_bus(uint bus, uint cs) |
| 514 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 515 | dspi_t *dspi = (dspi_t *) MMAP_DSPI; |
| 516 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 517 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 518 | /* Clear FIFO */ |
| 519 | clrbits_be32(&dspi->mcr, DSPI_MCR_CTXF | DSPI_MCR_CRXF); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 520 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 521 | #ifdef CONFIG_MCF5445x |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 522 | switch (cs) { |
| 523 | case 0: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 524 | clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 525 | break; |
| 526 | case 1: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 527 | clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 528 | break; |
| 529 | case 2: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 530 | clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 531 | break; |
Wolfgang Wegner | acf782f | 2010-03-30 19:20:31 +0100 | [diff] [blame] | 532 | case 3: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 533 | clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK); |
Wolfgang Wegner | acf782f | 2010-03-30 19:20:31 +0100 | [diff] [blame] | 534 | break; |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 535 | case 5: |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 536 | clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5); |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 537 | break; |
| 538 | } |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 539 | #endif |
| 540 | |
| 541 | #ifdef CONFIG_MCF5441x |
| 542 | if (cs == 1) |
| 543 | clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1); |
| 544 | #endif |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 545 | } |
Angelo Dureghello | 95a6998 | 2018-01-25 22:42:52 +0100 | [diff] [blame] | 546 | |
TsiChung Liew | a424ba2 | 2009-06-30 14:18:29 +0000 | [diff] [blame] | 547 | #endif |