TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * (C) Copyright 2000-2003 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 6 | * (C) Copyright 2004-2008 Freescale Semiconductor, Inc. |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 7 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <watchdog.h> |
TsiChungLiew | 97401c3 | 2007-07-05 23:03:28 -0500 | [diff] [blame] | 30 | #include <asm/immap.h> |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 31 | |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 32 | #if defined(CONFIG_CMD_NET) |
| 33 | #include <config.h> |
| 34 | #include <net.h> |
| 35 | #include <asm/fec.h> |
| 36 | #endif |
| 37 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 38 | #ifdef CONFIG_MCF5301x |
| 39 | void cpu_init_f(void) |
| 40 | { |
| 41 | volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1; |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 42 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 43 | volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS; |
| 44 | |
| 45 | /* watchdog is enabled by default - disable the watchdog */ |
| 46 | #ifndef CONFIG_WATCHDOG |
| 47 | /*wdog->cr = 0; */ |
| 48 | #endif |
| 49 | |
| 50 | scm1->mpr = 0x77777777; |
| 51 | scm1->pacra = 0; |
| 52 | scm1->pacrb = 0; |
| 53 | scm1->pacrc = 0; |
| 54 | scm1->pacrd = 0; |
| 55 | scm1->pacre = 0; |
| 56 | scm1->pacrf = 0; |
| 57 | scm1->pacrg = 0; |
| 58 | |
| 59 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \ |
| 60 | && defined(CONFIG_SYS_CS0_CTRL)) |
| 61 | gpio->par_cs |= GPIO_PAR_CS0_CS0; |
| 62 | fbcs->csar0 = CONFIG_SYS_CS0_BASE; |
| 63 | fbcs->cscr0 = CONFIG_SYS_CS0_CTRL; |
| 64 | fbcs->csmr0 = CONFIG_SYS_CS0_MASK; |
| 65 | #endif |
| 66 | |
| 67 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \ |
| 68 | && defined(CONFIG_SYS_CS1_CTRL)) |
| 69 | gpio->par_cs |= GPIO_PAR_CS1_CS1; |
| 70 | fbcs->csar1 = CONFIG_SYS_CS1_BASE; |
| 71 | fbcs->cscr1 = CONFIG_SYS_CS1_CTRL; |
| 72 | fbcs->csmr1 = CONFIG_SYS_CS1_MASK; |
| 73 | #endif |
| 74 | |
| 75 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \ |
| 76 | && defined(CONFIG_SYS_CS2_CTRL)) |
| 77 | fbcs->csar2 = CONFIG_SYS_CS2_BASE; |
| 78 | fbcs->cscr2 = CONFIG_SYS_CS2_CTRL; |
| 79 | fbcs->csmr2 = CONFIG_SYS_CS2_MASK; |
| 80 | #endif |
| 81 | |
| 82 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \ |
| 83 | && defined(CONFIG_SYS_CS3_CTRL)) |
| 84 | fbcs->csar3 = CONFIG_SYS_CS3_BASE; |
| 85 | fbcs->cscr3 = CONFIG_SYS_CS3_CTRL; |
| 86 | fbcs->csmr3 = CONFIG_SYS_CS3_MASK; |
| 87 | #endif |
| 88 | |
| 89 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \ |
| 90 | && defined(CONFIG_SYS_CS4_CTRL)) |
| 91 | gpio->par_cs |= GPIO_PAR_CS4; |
| 92 | fbcs->csar4 = CONFIG_SYS_CS4_BASE; |
| 93 | fbcs->cscr4 = CONFIG_SYS_CS4_CTRL; |
| 94 | fbcs->csmr4 = CONFIG_SYS_CS4_MASK; |
| 95 | #endif |
| 96 | |
| 97 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \ |
| 98 | && defined(CONFIG_SYS_CS5_CTRL)) |
| 99 | gpio->par_cs |= GPIO_PAR_CS5; |
| 100 | fbcs->csar5 = CONFIG_SYS_CS5_BASE; |
| 101 | fbcs->cscr5 = CONFIG_SYS_CS5_CTRL; |
| 102 | fbcs->csmr5 = CONFIG_SYS_CS5_MASK; |
| 103 | #endif |
| 104 | |
| 105 | #ifdef CONFIG_FSL_I2C |
| 106 | gpio->par_feci2c = GPIO_PAR_FECI2C_SDA_SDA | GPIO_PAR_FECI2C_SCL_SCL; |
| 107 | #endif |
| 108 | |
| 109 | icache_enable(); |
| 110 | } |
| 111 | |
| 112 | /* initialize higher level parts of CPU like timers */ |
| 113 | int cpu_init_r(void) |
| 114 | { |
| 115 | #ifdef CONFIG_MCFFEC |
| 116 | volatile ccm_t *ccm = (ccm_t *) MMAP_CCM; |
| 117 | #endif |
| 118 | #ifdef CONFIG_MCFRTC |
| 119 | volatile rtc_t *rtc = (rtc_t *) (CONFIG_SYS_MCFRTC_BASE); |
| 120 | volatile rtcex_t *rtcex = (rtcex_t *) & rtc->extended; |
| 121 | |
| 122 | rtcex->gocu = CONFIG_SYS_RTC_CNT; |
| 123 | rtcex->gocl = CONFIG_SYS_RTC_SETUP; |
| 124 | |
| 125 | #endif |
| 126 | #ifdef CONFIG_MCFFEC |
| 127 | if (CONFIG_SYS_FEC0_MIIBASE != CONFIG_SYS_FEC1_MIIBASE) |
| 128 | ccm->misccr |= CCM_MISCCR_FECM; |
| 129 | else |
| 130 | ccm->misccr &= ~CCM_MISCCR_FECM; |
| 131 | #endif |
| 132 | |
| 133 | return (0); |
| 134 | } |
| 135 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 136 | void uart_port_conf(int port) |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 137 | { |
| 138 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 139 | |
| 140 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 141 | switch (port) { |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 142 | case 0: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 143 | gpio->par_uart &= ~(GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD); |
| 144 | gpio->par_uart |= (GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 145 | break; |
| 146 | case 1: |
| 147 | #ifdef CONFIG_SYS_UART1_ALT1_GPIO |
| 148 | gpio->par_simp1h &= |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 149 | ~(GPIO_PAR_SIMP1H_DATA1_UNMASK | |
| 150 | GPIO_PAR_SIMP1H_VEN1_UNMASK); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 151 | gpio->par_simp1h |= |
| 152 | (GPIO_PAR_SIMP1H_DATA1_U1TXD | GPIO_PAR_SIMP1H_VEN1_U1RXD); |
| 153 | #elif defined(CONFIG_SYS_UART1_ALT2_GPIO) |
| 154 | gpio->par_ssih &= |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 155 | ~(GPIO_PAR_SSIH_RXD_UNMASK | GPIO_PAR_SSIH_TXD_UNMASK); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 156 | gpio->par_ssih |= |
| 157 | (GPIO_PAR_SSIH_RXD_U1RXD | GPIO_PAR_SSIH_TXD_U1TXD); |
| 158 | #endif |
| 159 | break; |
| 160 | case 2: |
| 161 | #ifdef CONFIG_SYS_UART2_PRI_GPIO |
| 162 | gpio->par_uart |= (GPIO_PAR_UART_U2TXD | GPIO_PAR_UART_U2RXD); |
| 163 | #elif defined(CONFIG_SYS_UART2_ALT1_GPIO) |
| 164 | gpio->par_dspih &= |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 165 | ~(GPIO_PAR_DSPIH_SIN_UNMASK | GPIO_PAR_DSPIH_SOUT_UNMASK); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 166 | gpio->par_dspih |= |
| 167 | (GPIO_PAR_DSPIH_SIN_U2RXD | GPIO_PAR_DSPIH_SOUT_U2TXD); |
| 168 | #elif defined(CONFIG_SYS_UART2_ALT2_GPIO) |
| 169 | gpio->par_feci2c &= |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 170 | ~(GPIO_PAR_FECI2C_SDA_UNMASK | GPIO_PAR_FECI2C_SCL_UNMASK); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 171 | gpio->par_feci2c |= |
| 172 | (GPIO_PAR_FECI2C_SDA_U2TXD | GPIO_PAR_FECI2C_SCL_U2RXD); |
| 173 | #endif |
| 174 | break; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | #if defined(CONFIG_CMD_NET) |
| 179 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 180 | { |
| 181 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 182 | struct fec_info_s *info = (struct fec_info_s *)dev->priv; |
| 183 | |
| 184 | if (setclear) { |
| 185 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { |
| 186 | gpio->par_fec |= |
| 187 | GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC; |
| 188 | gpio->par_feci2c |= |
| 189 | GPIO_PAR_FECI2C_MDC0 | GPIO_PAR_FECI2C_MDIO0; |
| 190 | } else { |
| 191 | gpio->par_fec |= |
| 192 | GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC; |
| 193 | gpio->par_feci2c |= |
| 194 | GPIO_PAR_FECI2C_MDC1 | GPIO_PAR_FECI2C_MDIO1; |
| 195 | } |
| 196 | } else { |
| 197 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { |
| 198 | gpio->par_fec &= |
| 199 | ~(GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC); |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 200 | gpio->par_feci2c &= GPIO_PAR_FECI2C_RMII0_UNMASK; |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 201 | } else { |
| 202 | gpio->par_fec &= |
| 203 | ~(GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC); |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 204 | gpio->par_feci2c &= GPIO_PAR_FECI2C_RMII1_UNMASK; |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | return 0; |
| 208 | } |
| 209 | #endif /* CONFIG_CMD_NET */ |
| 210 | #endif /* CONFIG_MCF5301x */ |
| 211 | |
| 212 | #ifdef CONFIG_MCF532x |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 213 | void cpu_init_f(void) |
| 214 | { |
| 215 | volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1; |
| 216 | volatile scm2_t *scm2 = (scm2_t *) MMAP_SCM2; |
| 217 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 218 | volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS; |
| 219 | volatile wdog_t *wdog = (wdog_t *) MMAP_WDOG; |
| 220 | |
| 221 | /* watchdog is enabled by default - disable the watchdog */ |
| 222 | #ifndef CONFIG_WATCHDOG |
| 223 | wdog->cr = 0; |
| 224 | #endif |
| 225 | |
| 226 | scm1->mpr0 = 0x77777777; |
| 227 | scm2->pacra = 0; |
| 228 | scm2->pacrb = 0; |
| 229 | scm2->pacrc = 0; |
| 230 | scm2->pacrd = 0; |
| 231 | scm2->pacre = 0; |
| 232 | scm2->pacrf = 0; |
| 233 | scm2->pacrg = 0; |
| 234 | scm1->pacrh = 0; |
| 235 | |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 236 | /* Port configuration */ |
TsiChungLiew | 2325c9f | 2007-08-05 05:15:18 -0500 | [diff] [blame] | 237 | gpio->par_cs = 0; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 238 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 239 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \ |
| 240 | && defined(CONFIG_SYS_CS0_CTRL)) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 241 | fbcs->csar0 = CONFIG_SYS_CS0_BASE; |
| 242 | fbcs->cscr0 = CONFIG_SYS_CS0_CTRL; |
| 243 | fbcs->csmr0 = CONFIG_SYS_CS0_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 244 | #endif |
| 245 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 246 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \ |
| 247 | && defined(CONFIG_SYS_CS1_CTRL)) |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 248 | /* Latch chipselect */ |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 249 | gpio->par_cs |= GPIO_PAR_CS1; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 250 | fbcs->csar1 = CONFIG_SYS_CS1_BASE; |
| 251 | fbcs->cscr1 = CONFIG_SYS_CS1_CTRL; |
| 252 | fbcs->csmr1 = CONFIG_SYS_CS1_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 253 | #endif |
| 254 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 255 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \ |
| 256 | && defined(CONFIG_SYS_CS2_CTRL)) |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 257 | gpio->par_cs |= GPIO_PAR_CS2; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 258 | fbcs->csar2 = CONFIG_SYS_CS2_BASE; |
| 259 | fbcs->cscr2 = CONFIG_SYS_CS2_CTRL; |
| 260 | fbcs->csmr2 = CONFIG_SYS_CS2_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 261 | #endif |
| 262 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 263 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \ |
| 264 | && defined(CONFIG_SYS_CS3_CTRL)) |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 265 | gpio->par_cs |= GPIO_PAR_CS3; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 266 | fbcs->csar3 = CONFIG_SYS_CS3_BASE; |
| 267 | fbcs->cscr3 = CONFIG_SYS_CS3_CTRL; |
| 268 | fbcs->csmr3 = CONFIG_SYS_CS3_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 269 | #endif |
| 270 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 271 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \ |
| 272 | && defined(CONFIG_SYS_CS4_CTRL)) |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 273 | gpio->par_cs |= GPIO_PAR_CS4; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 274 | fbcs->csar4 = CONFIG_SYS_CS4_BASE; |
| 275 | fbcs->cscr4 = CONFIG_SYS_CS4_CTRL; |
| 276 | fbcs->csmr4 = CONFIG_SYS_CS4_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 277 | #endif |
| 278 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 279 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \ |
| 280 | && defined(CONFIG_SYS_CS5_CTRL)) |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 281 | gpio->par_cs |= GPIO_PAR_CS5; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 282 | fbcs->csar5 = CONFIG_SYS_CS5_BASE; |
| 283 | fbcs->cscr5 = CONFIG_SYS_CS5_CTRL; |
| 284 | fbcs->csmr5 = CONFIG_SYS_CS5_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 285 | #endif |
TsiChung | 6373c0c | 2007-07-10 15:45:43 -0500 | [diff] [blame] | 286 | |
TsiChungLiew | 2325c9f | 2007-08-05 05:15:18 -0500 | [diff] [blame] | 287 | #ifdef CONFIG_FSL_I2C |
| 288 | gpio->par_feci2c = GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA; |
| 289 | #endif |
| 290 | |
TsiChung | 6373c0c | 2007-07-10 15:45:43 -0500 | [diff] [blame] | 291 | icache_enable(); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | /* |
| 295 | * initialize higher level parts of CPU like timers |
| 296 | */ |
| 297 | int cpu_init_r(void) |
| 298 | { |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 299 | return (0); |
| 300 | } |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 301 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 302 | void uart_port_conf(int port) |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 303 | { |
| 304 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 305 | |
| 306 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 307 | switch (port) { |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 308 | case 0: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 309 | gpio->par_uart &= ~(GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0); |
| 310 | gpio->par_uart |= (GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0); |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 311 | break; |
| 312 | case 1: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 313 | gpio->par_uart &= |
| 314 | ~(GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3)); |
| 315 | gpio->par_uart |= |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 316 | (GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3)); |
| 317 | break; |
| 318 | case 2: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 319 | #ifdef CONFIG_SYS_UART2_ALT1_GPIO |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 320 | gpio->par_timer &= 0x0F; |
| 321 | gpio->par_timer |= (GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 322 | #elif defined(CONFIG_SYS_UART2_ALT2_GPIO) |
| 323 | gpio->par_feci2c &= 0xFF00; |
| 324 | gpio->par_feci2c |= (GPIO_PAR_FECI2C_SCL_UTXD2 | GPIO_PAR_FECI2C_SDA_URXD2); |
| 325 | #elif defined(CONFIG_SYS_UART2_ALT3_GPIO) |
| 326 | gpio->par_ssi &= 0xF0FF; |
| 327 | gpio->par_ssi |= (GPIO_PAR_SSI_RXD(2) | GPIO_PAR_SSI_TXD(2)); |
| 328 | #endif |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 329 | break; |
| 330 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | #if defined(CONFIG_CMD_NET) |
| 334 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 335 | { |
| 336 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 337 | |
| 338 | if (setclear) { |
| 339 | gpio->par_fec |= GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC; |
| 340 | gpio->par_feci2c |= |
| 341 | GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO; |
| 342 | } else { |
| 343 | gpio->par_fec &= ~(GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC); |
| 344 | gpio->par_feci2c &= |
| 345 | ~(GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO); |
| 346 | } |
| 347 | return 0; |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 348 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 349 | #endif |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 350 | #endif /* CONFIG_MCF532x */ |