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