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