Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Maintainer : Steve Sakoman <steve@sakoman.com> |
| 3 | * |
| 4 | * Derived from Beagle Board, 3430 SDP, and OMAP3EVM code by |
| 5 | * Richard Woodruff <r-woodruff2@ti.com> |
| 6 | * Syed Mohammed Khasim <khasim@ti.com> |
| 7 | * Sunil Kumar <sunilsaini05@gmail.com> |
| 8 | * Shashi Ranjan <shashiranjanmca05@gmail.com> |
| 9 | * |
| 10 | * (C) Copyright 2004-2008 |
| 11 | * Texas Instruments, <www.ti.com> |
| 12 | * |
| 13 | * See file CREDITS for list of people who contributed to this |
| 14 | * project. |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU General Public License as |
| 18 | * published by the Free Software Foundation; either version 2 of |
| 19 | * the License, or (at your option) any later version. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU General Public License |
| 27 | * along with this program; if not, write to the Free Software |
| 28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 29 | * MA 02111-1307 USA |
| 30 | */ |
| 31 | #include <common.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 32 | #include <netdev.h> |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 33 | #include <twl4030.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 34 | #include <asm/io.h> |
Steve Sakoman | b7d8052 | 2010-09-19 21:21:07 -0700 | [diff] [blame] | 35 | #include <asm/arch/mmc_host_def.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 36 | #include <asm/arch/mux.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 37 | #include <asm/arch/mem.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 38 | #include <asm/arch/sys_proto.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 39 | #include <asm/arch/gpio.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 40 | #include <asm/mach-types.h> |
| 41 | #include "overo.h" |
| 42 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 43 | DECLARE_GLOBAL_DATA_PTR; |
| 44 | |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 45 | #define TWL4030_I2C_BUS 0 |
| 46 | #define EXPANSION_EEPROM_I2C_BUS 2 |
| 47 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x51 |
| 48 | |
| 49 | #define GUMSTIX_SUMMIT 0x01000200 |
| 50 | #define GUMSTIX_TOBI 0x02000200 |
| 51 | #define GUMSTIX_TOBI_DUO 0x03000200 |
| 52 | #define GUMSTIX_PALO35 0x04000200 |
| 53 | #define GUMSTIX_PALO43 0x05000200 |
| 54 | #define GUMSTIX_CHESTNUT43 0x06000200 |
| 55 | #define GUMSTIX_PINTO 0x07000200 |
| 56 | #define GUMSTIX_GALLOP43 0x08000200 |
| 57 | |
| 58 | #define ETTUS_USRP_E 0x01000300 |
| 59 | |
| 60 | #define GUMSTIX_NO_EEPROM 0xffffffff |
| 61 | |
| 62 | static struct { |
| 63 | unsigned int device_vendor; |
| 64 | unsigned char revision; |
| 65 | unsigned char content; |
| 66 | char fab_revision[8]; |
| 67 | char env_var[16]; |
| 68 | char env_setting[64]; |
| 69 | } expansion_config; |
| 70 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 71 | #if defined(CONFIG_CMD_NET) |
| 72 | static void setup_net_chip(void); |
| 73 | #endif |
| 74 | |
Steve Sakoman | 0d1d008 | 2010-08-12 21:07:02 -0700 | [diff] [blame] | 75 | /* GPMC definitions for LAN9221 chips on Tobi expansion boards */ |
| 76 | static const u32 gpmc_lan_config[] = { |
| 77 | NET_LAN9221_GPMC_CONFIG1, |
| 78 | NET_LAN9221_GPMC_CONFIG2, |
| 79 | NET_LAN9221_GPMC_CONFIG3, |
| 80 | NET_LAN9221_GPMC_CONFIG4, |
| 81 | NET_LAN9221_GPMC_CONFIG5, |
| 82 | NET_LAN9221_GPMC_CONFIG6, |
| 83 | /*CONFIG7- computed as params */ |
| 84 | }; |
| 85 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 86 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 87 | * Routine: board_init |
| 88 | * Description: Early hardware init. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 89 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 90 | int board_init(void) |
| 91 | { |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 92 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 93 | /* board id for Linux */ |
| 94 | gd->bd->bi_arch_number = MACH_TYPE_OVERO; |
| 95 | /* boot param addr */ |
| 96 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 101 | /* |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 102 | * Routine: get_board_revision |
| 103 | * Description: Returns the board revision |
| 104 | */ |
| 105 | int get_board_revision(void) |
| 106 | { |
| 107 | int revision; |
| 108 | |
| 109 | if (!omap_request_gpio(112) && |
| 110 | !omap_request_gpio(113) && |
| 111 | !omap_request_gpio(115)) { |
| 112 | |
| 113 | omap_set_gpio_direction(112, 1); |
| 114 | omap_set_gpio_direction(113, 1); |
| 115 | omap_set_gpio_direction(115, 1); |
| 116 | |
| 117 | revision = omap_get_gpio_datain(115) << 2 | |
| 118 | omap_get_gpio_datain(113) << 1 | |
| 119 | omap_get_gpio_datain(112); |
| 120 | |
| 121 | omap_free_gpio(112); |
| 122 | omap_free_gpio(113); |
| 123 | omap_free_gpio(115); |
| 124 | } else { |
| 125 | printf("Error: unable to acquire board revision GPIOs\n"); |
| 126 | revision = -1; |
| 127 | } |
| 128 | |
| 129 | return revision; |
| 130 | } |
| 131 | |
| 132 | /* |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 133 | * Routine: get_sdio2_config |
| 134 | * Description: Return information about the wifi module connection |
| 135 | * Returns 0 if the module connects though a level translator |
| 136 | * Returns 1 if the module connects directly |
| 137 | */ |
| 138 | int get_sdio2_config(void) |
| 139 | { |
| 140 | int sdio_direct; |
| 141 | |
| 142 | if (!omap_request_gpio(130) && !omap_request_gpio(139)) { |
| 143 | |
| 144 | omap_set_gpio_direction(130, 0); |
| 145 | omap_set_gpio_direction(139, 1); |
| 146 | |
| 147 | sdio_direct = 1; |
| 148 | omap_set_gpio_dataout(130, 0); |
| 149 | if (omap_get_gpio_datain(139) == 0) { |
| 150 | omap_set_gpio_dataout(130, 1); |
| 151 | if (omap_get_gpio_datain(139) == 1) |
| 152 | sdio_direct = 0; |
| 153 | } |
| 154 | |
| 155 | omap_free_gpio(130); |
| 156 | omap_free_gpio(139); |
| 157 | } else { |
| 158 | printf("Error: unable to acquire sdio2 clk GPIOs\n"); |
| 159 | sdio_direct = -1; |
| 160 | } |
| 161 | |
| 162 | return sdio_direct; |
| 163 | } |
| 164 | |
| 165 | /* |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 166 | * Routine: get_expansion_id |
| 167 | * Description: This function checks for expansion board by checking I2C |
| 168 | * bus 2 for the availability of an AT24C01B serial EEPROM. |
| 169 | * returns the device_vendor field from the EEPROM |
| 170 | */ |
| 171 | unsigned int get_expansion_id(void) |
| 172 | { |
| 173 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 174 | |
| 175 | /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */ |
| 176 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 177 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 178 | return GUMSTIX_NO_EEPROM; |
| 179 | } |
| 180 | |
| 181 | /* read configuration data */ |
| 182 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 183 | sizeof(expansion_config)); |
| 184 | |
| 185 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 186 | |
| 187 | return expansion_config.device_vendor; |
| 188 | } |
| 189 | |
| 190 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 191 | * Routine: misc_init_r |
| 192 | * Description: Configure board specific parts |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 193 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 194 | int misc_init_r(void) |
| 195 | { |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 196 | twl4030_power_init(); |
Grazvydas Ignotas | 17887bf | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 197 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 198 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 199 | #if defined(CONFIG_CMD_NET) |
| 200 | setup_net_chip(); |
| 201 | #endif |
| 202 | |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 203 | printf("Board revision: %d\n", get_board_revision()); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 204 | |
| 205 | switch (get_sdio2_config()) { |
| 206 | case 0: |
| 207 | printf("Tranceiver detected on mmc2\n"); |
| 208 | MUX_OVERO_SDIO2_TRANSCEIVER(); |
| 209 | break; |
| 210 | case 1: |
| 211 | printf("Direct connection on mmc2\n"); |
| 212 | MUX_OVERO_SDIO2_DIRECT(); |
| 213 | break; |
| 214 | default: |
| 215 | printf("Unable to detect mmc2 connection type\n"); |
| 216 | } |
| 217 | |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 218 | switch (get_expansion_id()) { |
| 219 | case GUMSTIX_SUMMIT: |
| 220 | printf("Recognized Summit expansion board (rev %d %s)\n", |
| 221 | expansion_config.revision, |
| 222 | expansion_config.fab_revision); |
| 223 | setenv("defaultdisplay", "dvi"); |
| 224 | break; |
| 225 | case GUMSTIX_TOBI: |
| 226 | printf("Recognized Tobi expansion board (rev %d %s)\n", |
| 227 | expansion_config.revision, |
| 228 | expansion_config.fab_revision); |
| 229 | setenv("defaultdisplay", "dvi"); |
| 230 | break; |
| 231 | case GUMSTIX_TOBI_DUO: |
| 232 | printf("Recognized Tobi Duo expansion board (rev %d %s)\n", |
| 233 | expansion_config.revision, |
| 234 | expansion_config.fab_revision); |
| 235 | break; |
| 236 | case GUMSTIX_PALO35: |
| 237 | printf("Recognized Palo35 expansion board (rev %d %s)\n", |
| 238 | expansion_config.revision, |
| 239 | expansion_config.fab_revision); |
| 240 | setenv("defaultdisplay", "lcd35"); |
| 241 | break; |
| 242 | case GUMSTIX_PALO43: |
| 243 | printf("Recognized Palo43 expansion board (rev %d %s)\n", |
| 244 | expansion_config.revision, |
| 245 | expansion_config.fab_revision); |
| 246 | setenv("defaultdisplay", "lcd43"); |
| 247 | break; |
| 248 | case GUMSTIX_CHESTNUT43: |
| 249 | printf("Recognized Chestnut43 expansion board (rev %d %s)\n", |
| 250 | expansion_config.revision, |
| 251 | expansion_config.fab_revision); |
| 252 | setenv("defaultdisplay", "lcd43"); |
| 253 | break; |
| 254 | case GUMSTIX_PINTO: |
| 255 | printf("Recognized Pinto expansion board (rev %d %s)\n", |
| 256 | expansion_config.revision, |
| 257 | expansion_config.fab_revision); |
| 258 | break; |
| 259 | case GUMSTIX_GALLOP43: |
| 260 | printf("Recognized Gallop43 expansion board (rev %d %s)\n", |
| 261 | expansion_config.revision, |
| 262 | expansion_config.fab_revision); |
| 263 | setenv("defaultdisplay", "lcd43"); |
| 264 | break; |
| 265 | case ETTUS_USRP_E: |
| 266 | printf("Recognized Ettus Research USRP-E (rev %d %s)\n", |
| 267 | expansion_config.revision, |
| 268 | expansion_config.fab_revision); |
| 269 | MUX_USRP_E(); |
| 270 | setenv("defaultdisplay", "dvi"); |
| 271 | break; |
| 272 | case GUMSTIX_NO_EEPROM: |
| 273 | printf("No EEPROM on expansion board\n"); |
| 274 | break; |
| 275 | default: |
| 276 | printf("Unrecognized expansion board\n"); |
| 277 | } |
| 278 | |
| 279 | if (expansion_config.content == 1) |
| 280 | setenv(expansion_config.env_var, expansion_config.env_setting); |
| 281 | |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 282 | dieid_num_r(); |
| 283 | |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 284 | return 0; |
| 285 | } |
| 286 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 287 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 288 | * Routine: set_muxconf_regs |
| 289 | * Description: Setting up the configuration Mux registers specific to the |
| 290 | * hardware. Many pins need to be moved from protect to primary |
| 291 | * mode. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 292 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 293 | void set_muxconf_regs(void) |
| 294 | { |
| 295 | MUX_OVERO(); |
| 296 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 297 | |
| 298 | #if defined(CONFIG_CMD_NET) |
| 299 | /* |
| 300 | * Routine: setup_net_chip |
| 301 | * Description: Setting up the configuration GPMC registers specific to the |
| 302 | * Ethernet hardware. |
| 303 | */ |
| 304 | static void setup_net_chip(void) |
| 305 | { |
| 306 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
| 307 | |
Steve Sakoman | 0d1d008 | 2010-08-12 21:07:02 -0700 | [diff] [blame] | 308 | /* first lan chip */ |
| 309 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000, |
| 310 | GPMC_SIZE_16M); |
| 311 | |
| 312 | /* second lan chip */ |
| 313 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], 0x2B000000, |
| 314 | GPMC_SIZE_16M); |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 315 | |
| 316 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 317 | writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 318 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 319 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 320 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 321 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 322 | &ctrl_base->gpmc_nadv_ale); |
| 323 | |
| 324 | /* Make GPIO 64 as output pin and send a magic pulse through it */ |
| 325 | if (!omap_request_gpio(64)) { |
| 326 | omap_set_gpio_direction(64, 0); |
| 327 | omap_set_gpio_dataout(64, 1); |
| 328 | udelay(1); |
| 329 | omap_set_gpio_dataout(64, 0); |
| 330 | udelay(1); |
| 331 | omap_set_gpio_dataout(64, 1); |
| 332 | } |
| 333 | } |
| 334 | #endif |
| 335 | |
| 336 | int board_eth_init(bd_t *bis) |
| 337 | { |
| 338 | int rc = 0; |
| 339 | #ifdef CONFIG_SMC911X |
| 340 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 341 | #endif |
| 342 | return rc; |
| 343 | } |
Steve Sakoman | b7d8052 | 2010-09-19 21:21:07 -0700 | [diff] [blame] | 344 | |
| 345 | #ifdef CONFIG_GENERIC_MMC |
| 346 | int board_mmc_init(bd_t *bis) |
| 347 | { |
| 348 | omap_mmc_init(0); |
| 349 | return 0; |
| 350 | } |
| 351 | #endif |