TsiChung Liew | 8e585f0 | 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 | * |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 6 | * (C) Copyright 2004-2008, 2012 Freescale Semiconductor, Inc. |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 7 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
| 8 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <watchdog.h> |
TsiChungLiew | 84a015b | 2007-07-05 23:03:28 -0500 | [diff] [blame] | 14 | #include <asm/immap.h> |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 15 | #include <asm/io.h> |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 16 | |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 17 | #if defined(CONFIG_CMD_NET) |
| 18 | #include <config.h> |
| 19 | #include <net.h> |
| 20 | #include <asm/fec.h> |
| 21 | #endif |
| 22 | |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 23 | #ifdef CONFIG_MCF5301x |
| 24 | void cpu_init_f(void) |
| 25 | { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 26 | scm1_t *scm1 = (scm1_t *) MMAP_SCM1; |
| 27 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 28 | fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS; |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 29 | |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 30 | out_be32(&scm1->mpr, 0x77777777); |
| 31 | out_be32(&scm1->pacra, 0); |
| 32 | out_be32(&scm1->pacrb, 0); |
| 33 | out_be32(&scm1->pacrc, 0); |
| 34 | out_be32(&scm1->pacrd, 0); |
| 35 | out_be32(&scm1->pacre, 0); |
| 36 | out_be32(&scm1->pacrf, 0); |
| 37 | out_be32(&scm1->pacrg, 0); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 38 | |
| 39 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \ |
| 40 | && defined(CONFIG_SYS_CS0_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 41 | setbits_8(&gpio->par_cs, GPIO_PAR_CS0_CS0); |
| 42 | out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE); |
| 43 | out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL); |
| 44 | out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 45 | #endif |
| 46 | |
| 47 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \ |
| 48 | && defined(CONFIG_SYS_CS1_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 49 | setbits_8(&gpio->par_cs, GPIO_PAR_CS1_CS1); |
| 50 | out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE); |
| 51 | out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL); |
| 52 | out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 53 | #endif |
| 54 | |
| 55 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \ |
| 56 | && defined(CONFIG_SYS_CS2_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 57 | out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE); |
| 58 | out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL); |
| 59 | out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 60 | #endif |
| 61 | |
| 62 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \ |
| 63 | && defined(CONFIG_SYS_CS3_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 64 | out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE); |
| 65 | out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL); |
| 66 | out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 67 | #endif |
| 68 | |
| 69 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \ |
| 70 | && defined(CONFIG_SYS_CS4_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 71 | setbits_8(&gpio->par_cs, GPIO_PAR_CS4); |
| 72 | out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE); |
| 73 | out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL); |
| 74 | out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 75 | #endif |
| 76 | |
| 77 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \ |
| 78 | && defined(CONFIG_SYS_CS5_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 79 | setbits_8(&gpio->par_cs, GPIO_PAR_CS5); |
| 80 | out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE); |
| 81 | out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL); |
| 82 | out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 83 | #endif |
| 84 | |
Heiko Schocher | 00f792e | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 85 | #ifdef CONFIG_SYS_I2C_FSL |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 86 | out_8(&gpio->par_feci2c, |
| 87 | GPIO_PAR_FECI2C_SDA_SDA | GPIO_PAR_FECI2C_SCL_SCL); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 88 | #endif |
| 89 | |
| 90 | icache_enable(); |
| 91 | } |
| 92 | |
| 93 | /* initialize higher level parts of CPU like timers */ |
| 94 | int cpu_init_r(void) |
| 95 | { |
| 96 | #ifdef CONFIG_MCFFEC |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 97 | ccm_t *ccm = (ccm_t *) MMAP_CCM; |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 98 | #endif |
| 99 | #ifdef CONFIG_MCFRTC |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 100 | rtc_t *rtc = (rtc_t *) (CONFIG_SYS_MCFRTC_BASE); |
| 101 | rtcex_t *rtcex = (rtcex_t *) &rtc->extended; |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 102 | |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 103 | out_be32(&rtcex->gocu, CONFIG_SYS_RTC_CNT); |
| 104 | out_be32(&rtcex->gocl, CONFIG_SYS_RTC_SETUP); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 105 | |
| 106 | #endif |
| 107 | #ifdef CONFIG_MCFFEC |
| 108 | if (CONFIG_SYS_FEC0_MIIBASE != CONFIG_SYS_FEC1_MIIBASE) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 109 | setbits_be16(&ccm->misccr, CCM_MISCCR_FECM); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 110 | else |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 111 | clrbits_be16(&ccm->misccr, CCM_MISCCR_FECM); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 112 | #endif |
| 113 | |
| 114 | return (0); |
| 115 | } |
| 116 | |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 117 | void uart_port_conf(int port) |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 118 | { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 119 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 120 | |
| 121 | /* Setup Ports: */ |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 122 | switch (port) { |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 123 | case 0: |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 124 | clrbits_8(&gpio->par_uart, |
| 125 | GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD); |
| 126 | setbits_8(&gpio->par_uart, |
| 127 | GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 128 | break; |
| 129 | case 1: |
| 130 | #ifdef CONFIG_SYS_UART1_ALT1_GPIO |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 131 | clrbits_8(&gpio->par_simp1h, |
| 132 | GPIO_PAR_SIMP1H_DATA1_UNMASK | |
| 133 | GPIO_PAR_SIMP1H_VEN1_UNMASK); |
| 134 | setbits_8(&gpio->par_simp1h, |
| 135 | GPIO_PAR_SIMP1H_DATA1_U1TXD | |
| 136 | GPIO_PAR_SIMP1H_VEN1_U1RXD); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 137 | #elif defined(CONFIG_SYS_UART1_ALT2_GPIO) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 138 | clrbits_8(&gpio->par_ssih, |
| 139 | GPIO_PAR_SSIH_RXD_UNMASK | |
| 140 | GPIO_PAR_SSIH_TXD_UNMASK); |
| 141 | setbits_8(&gpio->par_ssih, |
| 142 | GPIO_PAR_SSIH_RXD_U1RXD | |
| 143 | GPIO_PAR_SSIH_TXD_U1TXD); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 144 | #endif |
| 145 | break; |
| 146 | case 2: |
| 147 | #ifdef CONFIG_SYS_UART2_PRI_GPIO |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 148 | setbits_8(&gpio->par_uart, |
| 149 | GPIO_PAR_UART_U2TXD | |
| 150 | GPIO_PAR_UART_U2RXD); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 151 | #elif defined(CONFIG_SYS_UART2_ALT1_GPIO) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 152 | clrbits_8(&gpio->par_dspih, |
| 153 | GPIO_PAR_DSPIH_SIN_UNMASK | |
| 154 | GPIO_PAR_DSPIH_SOUT_UNMASK); |
| 155 | setbits_8(&gpio->par_dspih, |
| 156 | GPIO_PAR_DSPIH_SIN_U2RXD | |
| 157 | GPIO_PAR_DSPIH_SOUT_U2TXD); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 158 | #elif defined(CONFIG_SYS_UART2_ALT2_GPIO) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 159 | clrbits_8(&gpio->par_feci2c, |
| 160 | GPIO_PAR_FECI2C_SDA_UNMASK | |
| 161 | GPIO_PAR_FECI2C_SCL_UNMASK); |
| 162 | setbits_8(&gpio->par_feci2c, |
| 163 | GPIO_PAR_FECI2C_SDA_U2TXD | |
| 164 | GPIO_PAR_FECI2C_SCL_U2RXD); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 165 | #endif |
| 166 | break; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | #if defined(CONFIG_CMD_NET) |
| 171 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 172 | { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 173 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 174 | struct fec_info_s *info = (struct fec_info_s *)dev->priv; |
| 175 | |
| 176 | if (setclear) { |
| 177 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 178 | setbits_8(&gpio->par_fec, |
| 179 | GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC); |
| 180 | setbits_8(&gpio->par_feci2c, |
| 181 | GPIO_PAR_FECI2C_MDC0 | GPIO_PAR_FECI2C_MDIO0); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 182 | } else { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 183 | setbits_8(&gpio->par_fec, |
| 184 | GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC); |
| 185 | setbits_8(&gpio->par_feci2c, |
| 186 | GPIO_PAR_FECI2C_MDC1 | GPIO_PAR_FECI2C_MDIO1); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 187 | } |
| 188 | } else { |
| 189 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 190 | clrbits_8(&gpio->par_fec, |
| 191 | GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC); |
| 192 | clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII0_UNMASK); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 193 | } else { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 194 | clrbits_8(&gpio->par_fec, |
| 195 | GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC); |
| 196 | clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII1_UNMASK); |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | return 0; |
| 200 | } |
| 201 | #endif /* CONFIG_CMD_NET */ |
| 202 | #endif /* CONFIG_MCF5301x */ |
| 203 | |
| 204 | #ifdef CONFIG_MCF532x |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 205 | void cpu_init_f(void) |
| 206 | { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 207 | scm1_t *scm1 = (scm1_t *) MMAP_SCM1; |
| 208 | scm2_t *scm2 = (scm2_t *) MMAP_SCM2; |
| 209 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 210 | fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS; |
Simon Glass | ddc9437 | 2014-06-07 22:07:58 -0600 | [diff] [blame] | 211 | #ifndef CONFIG_WATCHDOG |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 212 | wdog_t *wdog = (wdog_t *) MMAP_WDOG; |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 213 | |
| 214 | /* watchdog is enabled by default - disable the watchdog */ |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 215 | out_be16(&wdog->cr, 0); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 216 | #endif |
| 217 | |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 218 | out_be32(&scm1->mpr0, 0x77777777); |
| 219 | out_be32(&scm2->pacra, 0); |
| 220 | out_be32(&scm2->pacrb, 0); |
| 221 | out_be32(&scm2->pacrc, 0); |
| 222 | out_be32(&scm2->pacrd, 0); |
| 223 | out_be32(&scm2->pacre, 0); |
| 224 | out_be32(&scm2->pacrf, 0); |
| 225 | out_be32(&scm2->pacrg, 0); |
| 226 | out_be32(&scm1->pacrh, 0); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 227 | |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 228 | /* Port configuration */ |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 229 | out_8(&gpio->par_cs, 0); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 230 | |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 231 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \ |
| 232 | && defined(CONFIG_SYS_CS0_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 233 | out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE); |
| 234 | out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL); |
| 235 | out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 236 | #endif |
| 237 | |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 238 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \ |
| 239 | && defined(CONFIG_SYS_CS1_CTRL)) |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 240 | /* Latch chipselect */ |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 241 | setbits_8(&gpio->par_cs, GPIO_PAR_CS1); |
| 242 | out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE); |
| 243 | out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL); |
| 244 | out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 245 | #endif |
| 246 | |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 247 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \ |
| 248 | && defined(CONFIG_SYS_CS2_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 249 | setbits_8(&gpio->par_cs, GPIO_PAR_CS2); |
| 250 | out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE); |
| 251 | out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL); |
| 252 | out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 253 | #endif |
| 254 | |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 255 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \ |
| 256 | && defined(CONFIG_SYS_CS3_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 257 | setbits_8(&gpio->par_cs, GPIO_PAR_CS3); |
| 258 | out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE); |
| 259 | out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL); |
| 260 | out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 261 | #endif |
| 262 | |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 263 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \ |
| 264 | && defined(CONFIG_SYS_CS4_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 265 | setbits_8(&gpio->par_cs, GPIO_PAR_CS4); |
| 266 | out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE); |
| 267 | out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL); |
| 268 | out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 269 | #endif |
| 270 | |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 271 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \ |
| 272 | && defined(CONFIG_SYS_CS5_CTRL)) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 273 | setbits_8(&gpio->par_cs, GPIO_PAR_CS5); |
| 274 | out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE); |
| 275 | out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL); |
| 276 | out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 277 | #endif |
TsiChung | 0dca874 | 2007-07-10 15:45:43 -0500 | [diff] [blame] | 278 | |
Heiko Schocher | 00f792e | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 279 | #ifdef CONFIG_SYS_I2C_FSL |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 280 | out_8(&gpio->par_feci2c, |
| 281 | GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA); |
TsiChungLiew | a41de1f | 2007-08-05 05:15:18 -0500 | [diff] [blame] | 282 | #endif |
| 283 | |
TsiChung | 0dca874 | 2007-07-10 15:45:43 -0500 | [diff] [blame] | 284 | icache_enable(); |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | /* |
| 288 | * initialize higher level parts of CPU like timers |
| 289 | */ |
| 290 | int cpu_init_r(void) |
| 291 | { |
TsiChung Liew | 8e585f0 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 292 | return (0); |
| 293 | } |
TsiChungLiew | 8d1d66a | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 294 | |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 295 | void uart_port_conf(int port) |
TsiChungLiew | 8d1d66a | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 296 | { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 297 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChungLiew | 8d1d66a | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 298 | |
| 299 | /* Setup Ports: */ |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 300 | switch (port) { |
TsiChungLiew | 8d1d66a | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 301 | case 0: |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 302 | clrbits_be16(&gpio->par_uart, |
| 303 | GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0); |
| 304 | setbits_be16(&gpio->par_uart, |
| 305 | GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0); |
TsiChungLiew | 8d1d66a | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 306 | break; |
| 307 | case 1: |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 308 | clrbits_be16(&gpio->par_uart, |
| 309 | GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3)); |
| 310 | setbits_be16(&gpio->par_uart, |
| 311 | GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3)); |
TsiChungLiew | 8d1d66a | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 312 | break; |
| 313 | case 2: |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 314 | #ifdef CONFIG_SYS_UART2_ALT1_GPIO |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 315 | clrbits_8(&gpio->par_timer, 0xf0); |
| 316 | setbits_8(&gpio->par_timer, |
| 317 | GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2); |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 318 | #elif defined(CONFIG_SYS_UART2_ALT2_GPIO) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 319 | clrbits_8(&gpio->par_feci2c, 0x00ff); |
| 320 | setbits_8(&gpio->par_feci2c, |
| 321 | GPIO_PAR_FECI2C_SCL_UTXD2 | GPIO_PAR_FECI2C_SDA_URXD2); |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 322 | #elif defined(CONFIG_SYS_UART2_ALT3_GPIO) |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 323 | clrbits_be16(&gpio->par_ssi, 0x0f00); |
| 324 | setbits_be16(&gpio->par_ssi, |
| 325 | GPIO_PAR_SSI_RXD(2) | GPIO_PAR_SSI_TXD(2)); |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 326 | #endif |
TsiChungLiew | 8d1d66a | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 327 | break; |
| 328 | } |
| 329 | } |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 330 | |
| 331 | #if defined(CONFIG_CMD_NET) |
| 332 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 333 | { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 334 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 335 | |
| 336 | if (setclear) { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 337 | setbits_8(&gpio->par_fec, |
| 338 | GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC); |
| 339 | setbits_8(&gpio->par_feci2c, |
| 340 | GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO); |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 341 | } else { |
Alison Wang | aa0d99f | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 342 | clrbits_8(&gpio->par_fec, |
| 343 | GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC); |
| 344 | clrbits_8(&gpio->par_feci2c, |
| 345 | GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO); |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 346 | } |
| 347 | return 0; |
| 348 | } |
| 349 | #endif |
TsiChung Liew | 536e7da | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 350 | #endif /* CONFIG_MCF532x */ |