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