wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Josef Baumgartner <josef.baumgartner@telex.de> |
| 4 | * |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 5 | * MCF5282 additionals |
| 6 | * (C) Copyright 2005 |
| 7 | * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de> |
Michael Durrant | a4991f2 | 2010-01-20 19:33:02 -0600 | [diff] [blame] | 8 | * (c) Copyright 2010 |
| 9 | * Arcturus Networks Inc. <www.arcturusnetworks.com> |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 10 | * |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 11 | * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. |
| 12 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
| 13 | * Hayden Fraser (Hayden.Fraser@freescale.com) |
| 14 | * |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 15 | * MCF5275 additions |
| 16 | * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com) |
| 17 | * |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 18 | * See file CREDITS for list of people who contributed to this |
| 19 | * project. |
| 20 | * |
| 21 | * This program is free software; you can redistribute it and/or |
| 22 | * modify it under the terms of the GNU General Public License as |
| 23 | * published by the Free Software Foundation; either version 2 of |
| 24 | * the License, or (at your option) any later version. |
| 25 | * |
| 26 | * This program is distributed in the hope that it will be useful, |
| 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 29 | * GNU General Public License for more details. |
| 30 | * |
| 31 | * You should have received a copy of the GNU General Public License |
| 32 | * along with this program; if not, write to the Free Software |
| 33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 34 | * MA 02111-1307 USA |
| 35 | */ |
| 36 | |
| 37 | #include <common.h> |
| 38 | #include <watchdog.h> |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 39 | #include <asm/immap.h> |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 40 | |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 41 | #if defined(CONFIG_CMD_NET) |
| 42 | #include <config.h> |
| 43 | #include <net.h> |
| 44 | #include <asm/fec.h> |
| 45 | #endif |
| 46 | |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 47 | #ifndef CONFIG_M5272 |
| 48 | /* Only 5272 Flexbus chipselect is different from the rest */ |
| 49 | void init_fbcs(void) |
| 50 | { |
| 51 | volatile fbcs_t *fbcs = (fbcs_t *) (MMAP_FBCS); |
| 52 | |
| 53 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \ |
| 54 | && defined(CONFIG_SYS_CS0_CTRL)) |
| 55 | fbcs->csar0 = CONFIG_SYS_CS0_BASE; |
| 56 | fbcs->cscr0 = CONFIG_SYS_CS0_CTRL; |
| 57 | fbcs->csmr0 = CONFIG_SYS_CS0_MASK; |
| 58 | #else |
| 59 | #warning "Chip Select 0 are not initialized/used" |
| 60 | #endif |
| 61 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \ |
| 62 | && defined(CONFIG_SYS_CS1_CTRL)) |
| 63 | fbcs->csar1 = CONFIG_SYS_CS1_BASE; |
| 64 | fbcs->cscr1 = CONFIG_SYS_CS1_CTRL; |
| 65 | fbcs->csmr1 = CONFIG_SYS_CS1_MASK; |
| 66 | #endif |
| 67 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \ |
| 68 | && defined(CONFIG_SYS_CS2_CTRL)) |
| 69 | fbcs->csar2 = CONFIG_SYS_CS2_BASE; |
| 70 | fbcs->cscr2 = CONFIG_SYS_CS2_CTRL; |
| 71 | fbcs->csmr2 = CONFIG_SYS_CS2_MASK; |
| 72 | #endif |
| 73 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \ |
| 74 | && defined(CONFIG_SYS_CS3_CTRL)) |
| 75 | fbcs->csar3 = CONFIG_SYS_CS3_BASE; |
| 76 | fbcs->cscr3 = CONFIG_SYS_CS3_CTRL; |
| 77 | fbcs->csmr3 = CONFIG_SYS_CS3_MASK; |
| 78 | #endif |
| 79 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \ |
| 80 | && defined(CONFIG_SYS_CS4_CTRL)) |
| 81 | fbcs->csar4 = CONFIG_SYS_CS4_BASE; |
| 82 | fbcs->cscr4 = CONFIG_SYS_CS4_CTRL; |
| 83 | fbcs->csmr4 = CONFIG_SYS_CS4_MASK; |
| 84 | #endif |
| 85 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \ |
| 86 | && defined(CONFIG_SYS_CS5_CTRL)) |
| 87 | fbcs->csar5 = CONFIG_SYS_CS5_BASE; |
| 88 | fbcs->cscr5 = CONFIG_SYS_CS5_CTRL; |
| 89 | fbcs->csmr5 = CONFIG_SYS_CS5_MASK; |
| 90 | #endif |
| 91 | #if (defined(CONFIG_SYS_CS6_BASE) && defined(CONFIG_SYS_CS6_MASK) \ |
| 92 | && defined(CONFIG_SYS_CS6_CTRL)) |
| 93 | fbcs->csar6 = CONFIG_SYS_CS6_BASE; |
| 94 | fbcs->cscr6 = CONFIG_SYS_CS6_CTRL; |
| 95 | fbcs->csmr6 = CONFIG_SYS_CS6_MASK; |
| 96 | #endif |
| 97 | #if (defined(CONFIG_SYS_CS7_BASE) && defined(CONFIG_SYS_CS7_MASK) \ |
| 98 | && defined(CONFIG_SYS_CS7_CTRL)) |
| 99 | fbcs->csar7 = CONFIG_SYS_CS7_BASE; |
| 100 | fbcs->cscr7 = CONFIG_SYS_CS7_CTRL; |
| 101 | fbcs->csmr7 = CONFIG_SYS_CS7_MASK; |
| 102 | #endif |
| 103 | } |
| 104 | #endif |
| 105 | |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 106 | #if defined(CONFIG_M5208) |
| 107 | void cpu_init_f(void) |
| 108 | { |
| 109 | volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1; |
| 110 | |
| 111 | #ifndef CONFIG_WATCHDOG |
| 112 | volatile wdog_t *wdg = (wdog_t *) MMAP_WDOG; |
| 113 | |
| 114 | /* Disable the watchdog if we aren't using it */ |
| 115 | wdg->cr = 0; |
| 116 | #endif |
| 117 | |
| 118 | scm1->mpr = 0x77777777; |
| 119 | scm1->pacra = 0; |
| 120 | scm1->pacrb = 0; |
| 121 | scm1->pacrc = 0; |
| 122 | scm1->pacrd = 0; |
| 123 | scm1->pacre = 0; |
| 124 | scm1->pacrf = 0; |
| 125 | |
| 126 | /* FlexBus Chipselect */ |
| 127 | init_fbcs(); |
| 128 | |
| 129 | icache_enable(); |
| 130 | } |
| 131 | |
| 132 | /* initialize higher level parts of CPU like timers */ |
| 133 | int cpu_init_r(void) |
| 134 | { |
| 135 | return (0); |
| 136 | } |
| 137 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 138 | void uart_port_conf(int port) |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 139 | { |
| 140 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 141 | |
| 142 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 143 | switch (port) { |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 144 | case 0: |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 145 | gpio->par_uart &= GPIO_PAR_UART0_UNMASK; |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 146 | gpio->par_uart |= (GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD); |
| 147 | break; |
| 148 | case 1: |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 149 | gpio->par_uart &= GPIO_PAR_UART0_UNMASK; |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 150 | gpio->par_uart |= (GPIO_PAR_UART_U1TXD | GPIO_PAR_UART_U1RXD); |
| 151 | break; |
| 152 | case 2: |
| 153 | #ifdef CONFIG_SYS_UART2_PRI_GPIO |
| 154 | gpio->par_timer &= |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 155 | (GPIO_PAR_TMR_TIN0_UNMASK | GPIO_PAR_TMR_TIN1_UNMASK); |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 156 | gpio->par_timer |= |
| 157 | (GPIO_PAR_TMR_TIN0_U2TXD | GPIO_PAR_TMR_TIN1_U2RXD); |
| 158 | #endif |
| 159 | #ifdef CONFIG_SYS_UART2_ALT1_GPIO |
| 160 | gpio->par_feci2c &= |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 161 | (GPIO_PAR_FECI2C_MDC_UNMASK | GPIO_PAR_FECI2C_MDIO_UNMASK); |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 162 | gpio->par_feci2c |= |
| 163 | (GPIO_PAR_FECI2C_MDC_U2TXD | GPIO_PAR_FECI2C_MDIO_U2RXD); |
| 164 | #endif |
| 165 | #ifdef CONFIG_SYS_UART2_ALT1_GPIO |
| 166 | gpio->par_feci2c &= |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 167 | (GPIO_PAR_FECI2C_SDA_UNMASK | GPIO_PAR_FECI2C_SCL_UNMASK); |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 168 | gpio->par_feci2c |= |
| 169 | (GPIO_PAR_FECI2C_SDA_U2TXD | GPIO_PAR_FECI2C_SCL_U2RXD); |
| 170 | #endif |
| 171 | break; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | #if defined(CONFIG_CMD_NET) |
| 176 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 177 | { |
| 178 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 179 | |
| 180 | if (setclear) { |
| 181 | gpio->par_fec |= |
| 182 | GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC; |
| 183 | gpio->par_feci2c |= |
| 184 | GPIO_PAR_FECI2C_MDC_MDC | GPIO_PAR_FECI2C_MDIO_MDIO; |
| 185 | } else { |
| 186 | gpio->par_fec &= |
TsiChung Liew | bbb8ddc | 2010-03-09 18:32:16 -0600 | [diff] [blame] | 187 | (GPIO_PAR_FEC_7W_UNMASK & GPIO_PAR_FEC_MII_UNMASK); |
| 188 | gpio->par_feci2c &= GPIO_PAR_FECI2C_RMII_UNMASK; |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 189 | } |
| 190 | return 0; |
| 191 | } |
| 192 | #endif /* CONFIG_CMD_NET */ |
| 193 | #endif /* CONFIG_M5208 */ |
| 194 | |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 195 | #if defined(CONFIG_M5253) |
| 196 | /* |
| 197 | * Breath some life into the CPU... |
| 198 | * |
| 199 | * Set up the memory map, |
| 200 | * initialize a bunch of registers, |
| 201 | * initialize the UPM's |
| 202 | */ |
| 203 | void cpu_init_f(void) |
| 204 | { |
| 205 | mbar_writeByte(MCFSIM_MPARK, 0x40); /* 5249 Internal Core takes priority over DMA */ |
| 206 | mbar_writeByte(MCFSIM_SYPCR, 0x00); |
| 207 | mbar_writeByte(MCFSIM_SWIVR, 0x0f); |
| 208 | mbar_writeByte(MCFSIM_SWSR, 0x00); |
| 209 | mbar_writeByte(MCFSIM_SWDICR, 0x00); |
| 210 | mbar_writeByte(MCFSIM_TIMER1ICR, 0x00); |
| 211 | mbar_writeByte(MCFSIM_TIMER2ICR, 0x88); |
| 212 | mbar_writeByte(MCFSIM_I2CICR, 0x00); |
| 213 | mbar_writeByte(MCFSIM_UART1ICR, 0x00); |
| 214 | mbar_writeByte(MCFSIM_UART2ICR, 0x00); |
| 215 | mbar_writeByte(MCFSIM_ICR6, 0x00); |
| 216 | mbar_writeByte(MCFSIM_ICR7, 0x00); |
| 217 | mbar_writeByte(MCFSIM_ICR8, 0x00); |
| 218 | mbar_writeByte(MCFSIM_ICR9, 0x00); |
| 219 | mbar_writeByte(MCFSIM_QSPIICR, 0x00); |
| 220 | |
| 221 | mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080); |
| 222 | mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */ |
| 223 | mbar2_writeByte(MCFSIM_SPURVEC, 0x00); |
| 224 | |
Wolfgang Denk | 55334c7 | 2008-12-16 01:02:17 +0100 | [diff] [blame] | 225 | /*mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); */ /* Enable a 1 cycle pre-drive cycle on CS1 */ |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 226 | |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 227 | /* FlexBus Chipselect */ |
| 228 | init_fbcs(); |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 229 | |
TsiChung Liew | 0c1e325 | 2008-08-19 03:01:19 +0600 | [diff] [blame] | 230 | #ifdef CONFIG_FSL_I2C |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 231 | CONFIG_SYS_I2C_PINMUX_REG = |
| 232 | CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 233 | CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET; |
| 234 | #ifdef CONFIG_SYS_I2C2_OFFSET |
| 235 | CONFIG_SYS_I2C2_PINMUX_REG &= CONFIG_SYS_I2C2_PINMUX_CLR; |
| 236 | CONFIG_SYS_I2C2_PINMUX_REG |= CONFIG_SYS_I2C2_PINMUX_SET; |
TsiChung Liew | 0c1e325 | 2008-08-19 03:01:19 +0600 | [diff] [blame] | 237 | #endif |
| 238 | #endif |
| 239 | |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 240 | /* enable instruction cache now */ |
| 241 | icache_enable(); |
| 242 | } |
| 243 | |
| 244 | /*initialize higher level parts of CPU like timers */ |
| 245 | int cpu_init_r(void) |
| 246 | { |
| 247 | return (0); |
| 248 | } |
| 249 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 250 | void uart_port_conf(int port) |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 251 | { |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 252 | volatile u32 *par = (u32 *) MMAP_PAR; |
| 253 | |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 254 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 255 | switch (port) { |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 256 | case 1: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 257 | *par &= 0xFFE7FFFF; |
| 258 | *par |= 0x00180000; |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 259 | break; |
| 260 | case 2: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 261 | *par &= 0xFFFFFFFC; |
| 262 | *par &= 0x00000003; |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 263 | break; |
| 264 | } |
| 265 | } |
| 266 | #endif /* #if defined(CONFIG_M5253) */ |
| 267 | |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 268 | #if defined(CONFIG_M5271) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 269 | void cpu_init_f(void) |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 270 | { |
| 271 | #ifndef CONFIG_WATCHDOG |
| 272 | /* Disable the watchdog if we aren't using it */ |
| 273 | mbar_writeShort(MCF_WTM_WCR, 0); |
| 274 | #endif |
| 275 | |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 276 | /* FlexBus Chipselect */ |
| 277 | init_fbcs(); |
| 278 | |
Richard Retanubun | fbb5521 | 2009-01-29 14:36:06 -0500 | [diff] [blame] | 279 | #ifdef CONFIG_SYS_MCF_SYNCR |
| 280 | /* Set clockspeed according to board header file */ |
| 281 | mbar_writeLong(MCF_FMPLL_SYNCR, CONFIG_SYS_MCF_SYNCR); |
| 282 | #else |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 283 | /* Set clockspeed to 100MHz */ |
Richard Retanubun | fbb5521 | 2009-01-29 14:36:06 -0500 | [diff] [blame] | 284 | mbar_writeLong(MCF_FMPLL_SYNCR, |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 285 | MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0)); |
Richard Retanubun | fbb5521 | 2009-01-29 14:36:06 -0500 | [diff] [blame] | 286 | #endif |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 287 | while (!mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK) ; |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | /* |
| 291 | * initialize higher level parts of CPU like timers |
| 292 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 293 | int cpu_init_r(void) |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 294 | { |
| 295 | return (0); |
| 296 | } |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 297 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 298 | void uart_port_conf(int port) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 299 | { |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 300 | u16 temp; |
| 301 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 302 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 303 | switch (port) { |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 304 | case 0: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 305 | temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xFFF3; |
| 306 | temp |= (MCF_GPIO_PAR_UART_U0TXD | MCF_GPIO_PAR_UART_U0RXD); |
| 307 | mbar_writeShort(MCF_GPIO_PAR_UART, temp); |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 308 | break; |
| 309 | case 1: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 310 | temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xF0FF; |
| 311 | temp |= (MCF_GPIO_PAR_UART_U1RXD_UART1 | MCF_GPIO_PAR_UART_U1TXD_UART1); |
| 312 | mbar_writeShort(MCF_GPIO_PAR_UART, temp); |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 313 | break; |
| 314 | case 2: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 315 | temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xCFFF; |
| 316 | temp |= (0x3000); |
| 317 | mbar_writeShort(MCF_GPIO_PAR_UART, temp); |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 318 | break; |
| 319 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | #if defined(CONFIG_CMD_NET) |
| 323 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 324 | { |
| 325 | if (setclear) { |
| 326 | /* Enable Ethernet pins */ |
Richard Retanubun | 0ad94fd | 2009-01-23 10:47:13 -0500 | [diff] [blame] | 327 | mbar_writeByte(MCF_GPIO_PAR_FECI2C, |
| 328 | (mbar_readByte(MCF_GPIO_PAR_FECI2C) | 0xF0)); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 329 | } else { |
| 330 | } |
| 331 | |
| 332 | return 0; |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 333 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 334 | #endif /* CONFIG_CMD_NET */ |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 335 | #endif |
| 336 | |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 337 | #if defined(CONFIG_M5272) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 338 | /* |
| 339 | * Breath some life into the CPU... |
| 340 | * |
| 341 | * Set up the memory map, |
| 342 | * initialize a bunch of registers, |
| 343 | * initialize the UPM's |
| 344 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 345 | void cpu_init_f(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 346 | { |
| 347 | /* if we come from RAM we assume the CPU is |
| 348 | * already initialized. |
| 349 | */ |
| 350 | #ifndef CONFIG_MONITOR_IS_IN_RAM |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 351 | volatile sysctrl_t *sysctrl = (sysctrl_t *) (CONFIG_SYS_MBAR); |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 352 | volatile gpio_t *gpio = (gpio_t *) (MMAP_GPIO); |
| 353 | volatile csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 354 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 355 | sysctrl->sc_scr = CONFIG_SYS_SCR; |
| 356 | sysctrl->sc_spr = CONFIG_SYS_SPR; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 357 | |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 358 | /* Setup Ports: */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 359 | gpio->gpio_pacnt = CONFIG_SYS_PACNT; |
| 360 | gpio->gpio_paddr = CONFIG_SYS_PADDR; |
| 361 | gpio->gpio_padat = CONFIG_SYS_PADAT; |
| 362 | gpio->gpio_pbcnt = CONFIG_SYS_PBCNT; |
| 363 | gpio->gpio_pbddr = CONFIG_SYS_PBDDR; |
| 364 | gpio->gpio_pbdat = CONFIG_SYS_PBDAT; |
| 365 | gpio->gpio_pdcnt = CONFIG_SYS_PDCNT; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 366 | |
| 367 | /* Memory Controller: */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 368 | csctrl->cs_br0 = CONFIG_SYS_BR0_PRELIM; |
| 369 | csctrl->cs_or0 = CONFIG_SYS_OR0_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 370 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 371 | #if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM)) |
| 372 | csctrl->cs_br1 = CONFIG_SYS_BR1_PRELIM; |
| 373 | csctrl->cs_or1 = CONFIG_SYS_OR1_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 374 | #endif |
| 375 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 376 | #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM) |
| 377 | csctrl->cs_br2 = CONFIG_SYS_BR2_PRELIM; |
| 378 | csctrl->cs_or2 = CONFIG_SYS_OR2_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 379 | #endif |
| 380 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 381 | #if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM) |
| 382 | csctrl->cs_br3 = CONFIG_SYS_BR3_PRELIM; |
| 383 | csctrl->cs_or3 = CONFIG_SYS_OR3_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 384 | #endif |
| 385 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 386 | #if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM) |
| 387 | csctrl->cs_br4 = CONFIG_SYS_BR4_PRELIM; |
| 388 | csctrl->cs_or4 = CONFIG_SYS_OR4_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 389 | #endif |
| 390 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 391 | #if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM) |
| 392 | csctrl->cs_br5 = CONFIG_SYS_BR5_PRELIM; |
| 393 | csctrl->cs_or5 = CONFIG_SYS_OR5_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 394 | #endif |
| 395 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 396 | #if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM) |
| 397 | csctrl->cs_br6 = CONFIG_SYS_BR6_PRELIM; |
| 398 | csctrl->cs_or6 = CONFIG_SYS_OR6_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 399 | #endif |
| 400 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 401 | #if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM) |
| 402 | csctrl->cs_br7 = CONFIG_SYS_BR7_PRELIM; |
| 403 | csctrl->cs_or7 = CONFIG_SYS_OR7_PRELIM; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 404 | #endif |
| 405 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 406 | #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 407 | |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 408 | /* enable instruction cache now */ |
| 409 | icache_enable(); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 410 | |
| 411 | } |
| 412 | |
| 413 | /* |
| 414 | * initialize higher level parts of CPU like timers |
| 415 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 416 | int cpu_init_r(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 417 | { |
| 418 | return (0); |
| 419 | } |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 420 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 421 | void uart_port_conf(int port) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 422 | { |
| 423 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 424 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 425 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 426 | switch (port) { |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 427 | case 0: |
| 428 | gpio->gpio_pbcnt &= ~(GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK); |
| 429 | gpio->gpio_pbcnt |= (GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD); |
| 430 | break; |
| 431 | case 1: |
| 432 | gpio->gpio_pdcnt &= ~(GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK); |
| 433 | gpio->gpio_pdcnt |= (GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD); |
| 434 | break; |
| 435 | } |
| 436 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 437 | |
| 438 | #if defined(CONFIG_CMD_NET) |
| 439 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 440 | { |
| 441 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 442 | |
| 443 | if (setclear) { |
| 444 | gpio->gpio_pbcnt |= GPIO_PBCNT_E_MDC | GPIO_PBCNT_E_RXER | |
| 445 | GPIO_PBCNT_E_RXD1 | GPIO_PBCNT_E_RXD2 | |
| 446 | GPIO_PBCNT_E_RXD3 | GPIO_PBCNT_E_TXD1 | |
| 447 | GPIO_PBCNT_E_TXD2 | GPIO_PBCNT_E_TXD3; |
| 448 | } else { |
| 449 | } |
| 450 | return 0; |
| 451 | } |
| 452 | #endif /* CONFIG_CMD_NET */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 453 | #endif /* #if defined(CONFIG_M5272) */ |
| 454 | |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 455 | #if defined(CONFIG_M5275) |
| 456 | |
| 457 | /* |
| 458 | * Breathe some life into the CPU... |
| 459 | * |
| 460 | * Set up the memory map, |
| 461 | * initialize a bunch of registers, |
| 462 | * initialize the UPM's |
| 463 | */ |
| 464 | void cpu_init_f(void) |
| 465 | { |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 466 | /* |
| 467 | * if we come from RAM we assume the CPU is |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 468 | * already initialized. |
| 469 | */ |
| 470 | |
| 471 | #ifndef CONFIG_MONITOR_IS_IN_RAM |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 472 | volatile wdog_t *wdog_reg = (wdog_t *) (MMAP_WDOG); |
| 473 | volatile gpio_t *gpio_reg = (gpio_t *) (MMAP_GPIO); |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 474 | |
| 475 | /* Kill watchdog so we can initialize the PLL */ |
| 476 | wdog_reg->wcr = 0; |
| 477 | |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 478 | /* FlexBus Chipselect */ |
| 479 | init_fbcs(); |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 480 | #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */ |
| 481 | |
| 482 | #ifdef CONFIG_FSL_I2C |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 483 | CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR; |
| 484 | CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET; |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 485 | #endif |
| 486 | |
| 487 | /* enable instruction cache now */ |
| 488 | icache_enable(); |
| 489 | } |
| 490 | |
| 491 | /* |
| 492 | * initialize higher level parts of CPU like timers |
| 493 | */ |
| 494 | int cpu_init_r(void) |
| 495 | { |
| 496 | return (0); |
| 497 | } |
| 498 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 499 | void uart_port_conf(int port) |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 500 | { |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 501 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 502 | |
| 503 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 504 | switch (port) { |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 505 | case 0: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 506 | gpio->par_uart &= ~UART0_ENABLE_MASK; |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 507 | gpio->par_uart |= UART0_ENABLE_MASK; |
| 508 | break; |
| 509 | case 1: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 510 | gpio->par_uart &= ~UART1_ENABLE_MASK; |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 511 | gpio->par_uart |= UART1_ENABLE_MASK; |
| 512 | break; |
| 513 | case 2: |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 514 | gpio->par_uart &= ~UART2_ENABLE_MASK; |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 515 | gpio->par_uart |= UART2_ENABLE_MASK; |
| 516 | break; |
| 517 | } |
| 518 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 519 | |
| 520 | #if defined(CONFIG_CMD_NET) |
| 521 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 522 | { |
| 523 | struct fec_info_s *info = (struct fec_info_s *) dev->priv; |
| 524 | volatile gpio_t *gpio = (gpio_t *)MMAP_GPIO; |
| 525 | |
| 526 | if (setclear) { |
| 527 | /* Enable Ethernet pins */ |
| 528 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { |
| 529 | gpio->par_feci2c |= 0x0F00; |
| 530 | gpio->par_fec0hl |= 0xC0; |
| 531 | } else { |
| 532 | gpio->par_feci2c |= 0x00A0; |
| 533 | gpio->par_fec1hl |= 0xC0; |
| 534 | } |
| 535 | } else { |
| 536 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { |
| 537 | gpio->par_feci2c &= ~0x0F00; |
| 538 | gpio->par_fec0hl &= ~0xC0; |
| 539 | } else { |
| 540 | gpio->par_feci2c &= ~0x00A0; |
| 541 | gpio->par_fec1hl &= ~0xC0; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | return 0; |
| 546 | } |
| 547 | #endif /* CONFIG_CMD_NET */ |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 548 | #endif /* #if defined(CONFIG_M5275) */ |
| 549 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 550 | #if defined(CONFIG_M5282) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 551 | /* |
| 552 | * Breath some life into the CPU... |
| 553 | * |
| 554 | * Set up the memory map, |
| 555 | * initialize a bunch of registers, |
| 556 | * initialize the UPM's |
| 557 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 558 | void cpu_init_f(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 559 | { |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 560 | #ifndef CONFIG_WATCHDOG |
| 561 | /* disable watchdog if we aren't using it */ |
| 562 | MCFWTM_WCR = 0; |
| 563 | #endif |
| 564 | |
| 565 | #ifndef CONFIG_MONITOR_IS_IN_RAM |
| 566 | /* Set speed /PLL */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 567 | MCFCLOCK_SYNCR = |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 568 | MCFCLOCK_SYNCR_MFD(CONFIG_SYS_MFD) | |
| 569 | MCFCLOCK_SYNCR_RFD(CONFIG_SYS_RFD); |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 570 | while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ; |
| 571 | |
| 572 | MCFGPIO_PBCDPAR = 0xc0; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 573 | |
| 574 | /* Set up the GPIO ports */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 575 | #ifdef CONFIG_SYS_PEPAR |
| 576 | MCFGPIO_PEPAR = CONFIG_SYS_PEPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 577 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 578 | #ifdef CONFIG_SYS_PFPAR |
| 579 | MCFGPIO_PFPAR = CONFIG_SYS_PFPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 580 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 581 | #ifdef CONFIG_SYS_PJPAR |
| 582 | MCFGPIO_PJPAR = CONFIG_SYS_PJPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 583 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 584 | #ifdef CONFIG_SYS_PSDPAR |
| 585 | MCFGPIO_PSDPAR = CONFIG_SYS_PSDPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 586 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 587 | #ifdef CONFIG_SYS_PASPAR |
| 588 | MCFGPIO_PASPAR = CONFIG_SYS_PASPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 589 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 590 | #ifdef CONFIG_SYS_PEHLPAR |
| 591 | MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 592 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 593 | #ifdef CONFIG_SYS_PQSPAR |
| 594 | MCFGPIO_PQSPAR = CONFIG_SYS_PQSPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 595 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 596 | #ifdef CONFIG_SYS_PTCPAR |
| 597 | MCFGPIO_PTCPAR = CONFIG_SYS_PTCPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 598 | #endif |
Michael Durrant | a4991f2 | 2010-01-20 19:33:02 -0600 | [diff] [blame] | 599 | #if defined(CONFIG_SYS_PORTTC) |
| 600 | MCFGPIO_PORTTC = CONFIG_SYS_PORTTC; |
| 601 | #endif |
| 602 | #if defined(CONFIG_SYS_DDRTC) |
| 603 | MCFGPIO_DDRTC = CONFIG_SYS_DDRTC; |
| 604 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 605 | #ifdef CONFIG_SYS_PTDPAR |
| 606 | MCFGPIO_PTDPAR = CONFIG_SYS_PTDPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 607 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 608 | #ifdef CONFIG_SYS_PUAPAR |
| 609 | MCFGPIO_PUAPAR = CONFIG_SYS_PUAPAR; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 610 | #endif |
| 611 | |
Michael Durrant | a4991f2 | 2010-01-20 19:33:02 -0600 | [diff] [blame] | 612 | #if defined(CONFIG_SYS_DDRD) |
| 613 | MCFGPIO_DDRD = CONFIG_SYS_DDRD; |
| 614 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 615 | #ifdef CONFIG_SYS_DDRUA |
| 616 | MCFGPIO_DDRUA = CONFIG_SYS_DDRUA; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 617 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 618 | |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 619 | /* FlexBus Chipselect */ |
| 620 | init_fbcs(); |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 621 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 622 | #endif /* CONFIG_MONITOR_IS_IN_RAM */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 623 | |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 624 | /* defer enabling cache until boot (see do_go) */ |
| 625 | /* icache_enable(); */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | /* |
| 629 | * initialize higher level parts of CPU like timers |
| 630 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 631 | int cpu_init_r(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 632 | { |
| 633 | return (0); |
| 634 | } |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 635 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 636 | void uart_port_conf(int port) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 637 | { |
| 638 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 639 | switch (port) { |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 640 | case 0: |
| 641 | MCFGPIO_PUAPAR &= 0xFc; |
| 642 | MCFGPIO_PUAPAR |= 0x03; |
| 643 | break; |
| 644 | case 1: |
| 645 | MCFGPIO_PUAPAR &= 0xF3; |
| 646 | MCFGPIO_PUAPAR |= 0x0C; |
| 647 | break; |
| 648 | case 2: |
| 649 | MCFGPIO_PASPAR &= 0xFF0F; |
| 650 | MCFGPIO_PASPAR |= 0x00A0; |
| 651 | break; |
| 652 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | #if defined(CONFIG_CMD_NET) |
| 656 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 657 | { |
| 658 | if (setclear) { |
| 659 | MCFGPIO_PASPAR |= 0x0F00; |
| 660 | MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR; |
| 661 | } else { |
| 662 | MCFGPIO_PASPAR &= 0xF0FF; |
| 663 | MCFGPIO_PEHLPAR &= ~CONFIG_SYS_PEHLPAR; |
| 664 | } |
| 665 | return 0; |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 666 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 667 | #endif /* CONFIG_CMD_NET */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 668 | #endif |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 669 | |
| 670 | #if defined(CONFIG_M5249) |
| 671 | /* |
| 672 | * Breath some life into the CPU... |
| 673 | * |
| 674 | * Set up the memory map, |
| 675 | * initialize a bunch of registers, |
| 676 | * initialize the UPM's |
| 677 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 678 | void cpu_init_f(void) |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 679 | { |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 680 | /* |
| 681 | * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 682 | * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins |
| 683 | * which is their primary function. |
| 684 | * ~Jeremy |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 685 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 686 | mbar2_writeLong(MCFSIM_GPIO_FUNC, CONFIG_SYS_GPIO_FUNC); |
| 687 | mbar2_writeLong(MCFSIM_GPIO1_FUNC, CONFIG_SYS_GPIO1_FUNC); |
| 688 | mbar2_writeLong(MCFSIM_GPIO_EN, CONFIG_SYS_GPIO_EN); |
| 689 | mbar2_writeLong(MCFSIM_GPIO1_EN, CONFIG_SYS_GPIO1_EN); |
| 690 | mbar2_writeLong(MCFSIM_GPIO_OUT, CONFIG_SYS_GPIO_OUT); |
| 691 | mbar2_writeLong(MCFSIM_GPIO1_OUT, CONFIG_SYS_GPIO1_OUT); |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 692 | |
| 693 | /* |
| 694 | * dBug Compliance: |
| 695 | * You can verify these values by using dBug's 'ird' |
| 696 | * (Internal Register Display) command |
| 697 | * ~Jeremy |
| 698 | * |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 699 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 700 | mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 701 | mbar_writeByte(MCFSIM_SYPCR, 0x00); |
| 702 | mbar_writeByte(MCFSIM_SWIVR, 0x0f); |
| 703 | mbar_writeByte(MCFSIM_SWSR, 0x00); |
| 704 | mbar_writeLong(MCFSIM_IMR, 0xfffffbff); |
| 705 | mbar_writeByte(MCFSIM_SWDICR, 0x00); |
| 706 | mbar_writeByte(MCFSIM_TIMER1ICR, 0x00); |
| 707 | mbar_writeByte(MCFSIM_TIMER2ICR, 0x88); |
| 708 | mbar_writeByte(MCFSIM_I2CICR, 0x00); |
| 709 | mbar_writeByte(MCFSIM_UART1ICR, 0x00); |
| 710 | mbar_writeByte(MCFSIM_UART2ICR, 0x00); |
| 711 | mbar_writeByte(MCFSIM_ICR6, 0x00); |
| 712 | mbar_writeByte(MCFSIM_ICR7, 0x00); |
| 713 | mbar_writeByte(MCFSIM_ICR8, 0x00); |
| 714 | mbar_writeByte(MCFSIM_ICR9, 0x00); |
| 715 | mbar_writeByte(MCFSIM_QSPIICR, 0x00); |
| 716 | |
| 717 | mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080); |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 718 | mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 719 | mbar2_writeByte(MCFSIM_SPURVEC, 0x00); |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 720 | mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */ |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 721 | |
| 722 | /* Setup interrupt priorities for gpio7 */ |
| 723 | /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */ |
| 724 | |
| 725 | /* IDE Config registers */ |
| 726 | mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); |
| 727 | mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000); |
| 728 | |
TsiChung Liew | 7f1a046 | 2008-10-21 10:03:07 +0000 | [diff] [blame] | 729 | /* FlexBus Chipselect */ |
| 730 | init_fbcs(); |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 731 | |
| 732 | /* enable instruction cache now */ |
| 733 | icache_enable(); |
| 734 | } |
| 735 | |
| 736 | /* |
| 737 | * initialize higher level parts of CPU like timers |
| 738 | */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 739 | int cpu_init_r(void) |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 740 | { |
| 741 | return (0); |
| 742 | } |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 743 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 744 | void uart_port_conf(int port) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 745 | { |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 746 | } |
| 747 | #endif /* #if defined(CONFIG_M5249) */ |