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> |
Simon Glass | 1d91ba7 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 12 | #include <cpu_func.h> |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 13 | #include <watchdog.h> |
TsiChungLiew | 97401c3 | 2007-07-05 23:03:28 -0500 | [diff] [blame] | 14 | #include <asm/immap.h> |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 15 | #include <asm/io.h> |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 16 | |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame^] | 17 | #if defined(CONFIG_MCFFEC) |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 18 | #include <config.h> |
| 19 | #include <net.h> |
| 20 | #include <asm/fec.h> |
| 21 | #endif |
| 22 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 23 | #ifdef CONFIG_MCF5301x |
| 24 | void cpu_init_f(void) |
| 25 | { |
Alison Wang | 35d23df | 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 | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 29 | |
Alison Wang | 35d23df | 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 | e7e4fc8 | 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 | 35d23df | 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 | e7e4fc8 | 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 | 35d23df | 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 | e7e4fc8 | 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 | 35d23df | 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 | e7e4fc8 | 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 | 35d23df | 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 | e7e4fc8 | 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 | 35d23df | 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 | e7e4fc8 | 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 | 35d23df | 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 | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 83 | #endif |
| 84 | |
Heiko Schocher | f285074 | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 85 | #ifdef CONFIG_SYS_I2C_FSL |
Alison Wang | 35d23df | 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 | e7e4fc8 | 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 |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame^] | 97 | u32 fec_mii_base0, fec_mii_base1; |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 98 | ccm_t *ccm = (ccm_t *) MMAP_CCM; |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 99 | #endif |
| 100 | #ifdef CONFIG_MCFRTC |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 101 | rtc_t *rtc = (rtc_t *) (CONFIG_SYS_MCFRTC_BASE); |
| 102 | rtcex_t *rtcex = (rtcex_t *) &rtc->extended; |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 103 | |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 104 | out_be32(&rtcex->gocu, CONFIG_SYS_RTC_CNT); |
| 105 | out_be32(&rtcex->gocl, CONFIG_SYS_RTC_SETUP); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 106 | |
| 107 | #endif |
| 108 | #ifdef CONFIG_MCFFEC |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame^] | 109 | fec_get_mii_base(0, &fec_mii_base0); |
| 110 | fec_get_mii_base(1, &fec_mii_base1); |
| 111 | |
| 112 | if (fec_mii_base0 != fec_mii_base1) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 113 | setbits_be16(&ccm->misccr, CCM_MISCCR_FECM); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 114 | else |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 115 | clrbits_be16(&ccm->misccr, CCM_MISCCR_FECM); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 116 | #endif |
| 117 | |
| 118 | return (0); |
| 119 | } |
| 120 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 121 | void uart_port_conf(int port) |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 122 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 123 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 124 | |
| 125 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 126 | switch (port) { |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 127 | case 0: |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 128 | clrbits_8(&gpio->par_uart, |
| 129 | GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD); |
| 130 | setbits_8(&gpio->par_uart, |
| 131 | GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 132 | break; |
| 133 | case 1: |
| 134 | #ifdef CONFIG_SYS_UART1_ALT1_GPIO |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 135 | clrbits_8(&gpio->par_simp1h, |
| 136 | GPIO_PAR_SIMP1H_DATA1_UNMASK | |
| 137 | GPIO_PAR_SIMP1H_VEN1_UNMASK); |
| 138 | setbits_8(&gpio->par_simp1h, |
| 139 | GPIO_PAR_SIMP1H_DATA1_U1TXD | |
| 140 | GPIO_PAR_SIMP1H_VEN1_U1RXD); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 141 | #elif defined(CONFIG_SYS_UART1_ALT2_GPIO) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 142 | clrbits_8(&gpio->par_ssih, |
| 143 | GPIO_PAR_SSIH_RXD_UNMASK | |
| 144 | GPIO_PAR_SSIH_TXD_UNMASK); |
| 145 | setbits_8(&gpio->par_ssih, |
| 146 | GPIO_PAR_SSIH_RXD_U1RXD | |
| 147 | GPIO_PAR_SSIH_TXD_U1TXD); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 148 | #endif |
| 149 | break; |
| 150 | case 2: |
| 151 | #ifdef CONFIG_SYS_UART2_PRI_GPIO |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 152 | setbits_8(&gpio->par_uart, |
| 153 | GPIO_PAR_UART_U2TXD | |
| 154 | GPIO_PAR_UART_U2RXD); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 155 | #elif defined(CONFIG_SYS_UART2_ALT1_GPIO) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 156 | clrbits_8(&gpio->par_dspih, |
| 157 | GPIO_PAR_DSPIH_SIN_UNMASK | |
| 158 | GPIO_PAR_DSPIH_SOUT_UNMASK); |
| 159 | setbits_8(&gpio->par_dspih, |
| 160 | GPIO_PAR_DSPIH_SIN_U2RXD | |
| 161 | GPIO_PAR_DSPIH_SOUT_U2TXD); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 162 | #elif defined(CONFIG_SYS_UART2_ALT2_GPIO) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 163 | clrbits_8(&gpio->par_feci2c, |
| 164 | GPIO_PAR_FECI2C_SDA_UNMASK | |
| 165 | GPIO_PAR_FECI2C_SCL_UNMASK); |
| 166 | setbits_8(&gpio->par_feci2c, |
| 167 | GPIO_PAR_FECI2C_SDA_U2TXD | |
| 168 | GPIO_PAR_FECI2C_SCL_U2RXD); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 169 | #endif |
| 170 | break; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | #if defined(CONFIG_CMD_NET) |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame^] | 175 | int fecpin_setclear(fec_info_t *info, int setclear) |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 176 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 177 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame^] | 178 | u32 fec0_base; |
| 179 | |
| 180 | if (fec_get_base_addr(0, &fec0_base)) |
| 181 | return -1; |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 182 | |
| 183 | if (setclear) { |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame^] | 184 | if (info->iobase == fec0_base) { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 185 | setbits_8(&gpio->par_fec, |
| 186 | GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC); |
| 187 | setbits_8(&gpio->par_feci2c, |
| 188 | GPIO_PAR_FECI2C_MDC0 | GPIO_PAR_FECI2C_MDIO0); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 189 | } else { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 190 | setbits_8(&gpio->par_fec, |
| 191 | GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC); |
| 192 | setbits_8(&gpio->par_feci2c, |
| 193 | GPIO_PAR_FECI2C_MDC1 | GPIO_PAR_FECI2C_MDIO1); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 194 | } |
| 195 | } else { |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame^] | 196 | if (info->iobase == fec0_base) { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 197 | clrbits_8(&gpio->par_fec, |
| 198 | GPIO_PAR_FEC0_7W_FEC | GPIO_PAR_FEC0_RMII_FEC); |
| 199 | clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII0_UNMASK); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 200 | } else { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 201 | clrbits_8(&gpio->par_fec, |
| 202 | GPIO_PAR_FEC1_7W_FEC | GPIO_PAR_FEC1_RMII_FEC); |
| 203 | clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII1_UNMASK); |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | return 0; |
| 207 | } |
| 208 | #endif /* CONFIG_CMD_NET */ |
| 209 | #endif /* CONFIG_MCF5301x */ |
| 210 | |
| 211 | #ifdef CONFIG_MCF532x |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 212 | void cpu_init_f(void) |
| 213 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 214 | scm1_t *scm1 = (scm1_t *) MMAP_SCM1; |
| 215 | scm2_t *scm2 = (scm2_t *) MMAP_SCM2; |
| 216 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 217 | fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS; |
Simon Glass | 660031e | 2014-06-07 22:07:58 -0600 | [diff] [blame] | 218 | #ifndef CONFIG_WATCHDOG |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 219 | wdog_t *wdog = (wdog_t *) MMAP_WDOG; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 220 | |
| 221 | /* watchdog is enabled by default - disable the watchdog */ |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 222 | out_be16(&wdog->cr, 0); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 223 | #endif |
| 224 | |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 225 | out_be32(&scm1->mpr0, 0x77777777); |
| 226 | out_be32(&scm2->pacra, 0); |
| 227 | out_be32(&scm2->pacrb, 0); |
| 228 | out_be32(&scm2->pacrc, 0); |
| 229 | out_be32(&scm2->pacrd, 0); |
| 230 | out_be32(&scm2->pacre, 0); |
| 231 | out_be32(&scm2->pacrf, 0); |
| 232 | out_be32(&scm2->pacrg, 0); |
| 233 | out_be32(&scm1->pacrh, 0); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 234 | |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 235 | /* Port configuration */ |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 236 | out_8(&gpio->par_cs, 0); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 237 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 238 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \ |
| 239 | && defined(CONFIG_SYS_CS0_CTRL)) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 240 | out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE); |
| 241 | out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL); |
| 242 | out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 243 | #endif |
| 244 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 245 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \ |
| 246 | && defined(CONFIG_SYS_CS1_CTRL)) |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 247 | /* Latch chipselect */ |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 248 | setbits_8(&gpio->par_cs, GPIO_PAR_CS1); |
| 249 | out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE); |
| 250 | out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL); |
| 251 | out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_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_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \ |
| 255 | && defined(CONFIG_SYS_CS2_CTRL)) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 256 | setbits_8(&gpio->par_cs, GPIO_PAR_CS2); |
| 257 | out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE); |
| 258 | out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL); |
| 259 | out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_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_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \ |
| 263 | && defined(CONFIG_SYS_CS3_CTRL)) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 264 | setbits_8(&gpio->par_cs, GPIO_PAR_CS3); |
| 265 | out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE); |
| 266 | out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL); |
| 267 | out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_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_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \ |
| 271 | && defined(CONFIG_SYS_CS4_CTRL)) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 272 | setbits_8(&gpio->par_cs, GPIO_PAR_CS4); |
| 273 | out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE); |
| 274 | out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL); |
| 275 | out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 276 | #endif |
| 277 | |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 278 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \ |
| 279 | && defined(CONFIG_SYS_CS5_CTRL)) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 280 | setbits_8(&gpio->par_cs, GPIO_PAR_CS5); |
| 281 | out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE); |
| 282 | out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL); |
| 283 | out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 284 | #endif |
TsiChung | 6373c0c | 2007-07-10 15:45:43 -0500 | [diff] [blame] | 285 | |
Heiko Schocher | f285074 | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 286 | #ifdef CONFIG_SYS_I2C_FSL |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 287 | out_8(&gpio->par_feci2c, |
| 288 | GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA); |
TsiChungLiew | 2325c9f | 2007-08-05 05:15:18 -0500 | [diff] [blame] | 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 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 304 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 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: |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 309 | clrbits_be16(&gpio->par_uart, |
| 310 | GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0); |
| 311 | setbits_be16(&gpio->par_uart, |
| 312 | GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0); |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 313 | break; |
| 314 | case 1: |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 315 | clrbits_be16(&gpio->par_uart, |
| 316 | GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3)); |
| 317 | setbits_be16(&gpio->par_uart, |
| 318 | GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3)); |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 319 | break; |
| 320 | case 2: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 321 | #ifdef CONFIG_SYS_UART2_ALT1_GPIO |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 322 | clrbits_8(&gpio->par_timer, 0xf0); |
| 323 | setbits_8(&gpio->par_timer, |
| 324 | GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 325 | #elif defined(CONFIG_SYS_UART2_ALT2_GPIO) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 326 | clrbits_8(&gpio->par_feci2c, 0x00ff); |
| 327 | setbits_8(&gpio->par_feci2c, |
| 328 | GPIO_PAR_FECI2C_SCL_UTXD2 | GPIO_PAR_FECI2C_SDA_URXD2); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 329 | #elif defined(CONFIG_SYS_UART2_ALT3_GPIO) |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 330 | clrbits_be16(&gpio->par_ssi, 0x0f00); |
| 331 | setbits_be16(&gpio->par_ssi, |
| 332 | GPIO_PAR_SSI_RXD(2) | GPIO_PAR_SSI_TXD(2)); |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 333 | #endif |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 334 | break; |
| 335 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | #if defined(CONFIG_CMD_NET) |
Angelo Durgehello | 8ff47f7 | 2019-11-15 23:54:16 +0100 | [diff] [blame^] | 339 | int fecpin_setclear(fec_info_t *info, int setclear) |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 340 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 341 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 342 | |
| 343 | if (setclear) { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 344 | setbits_8(&gpio->par_fec, |
| 345 | GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC); |
| 346 | setbits_8(&gpio->par_feci2c, |
| 347 | GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 348 | } else { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 349 | clrbits_8(&gpio->par_fec, |
| 350 | GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC); |
| 351 | clrbits_8(&gpio->par_feci2c, |
| 352 | GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 353 | } |
| 354 | return 0; |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 355 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 356 | #endif |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 357 | #endif /* CONFIG_MCF532x */ |