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