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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 13 | * SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 14 | */ |
| 15 | #include <common.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 16 | #include <netdev.h> |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 17 | #include <twl4030.h> |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 18 | #include <linux/mtd/nand.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 19 | #include <asm/io.h> |
Steve Sakoman | b7d8052 | 2010-09-19 21:21:07 -0700 | [diff] [blame] | 20 | #include <asm/arch/mmc_host_def.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 21 | #include <asm/arch/mux.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 22 | #include <asm/arch/mem.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 23 | #include <asm/arch/sys_proto.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 24 | #include <asm/gpio.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 25 | #include <asm/mach-types.h> |
| 26 | #include "overo.h" |
| 27 | |
Stefan Herbrechtsmeier | 0c87e68 | 2014-09-16 17:51:09 +0200 | [diff] [blame^] | 28 | #ifdef CONFIG_USB_EHCI |
| 29 | #include <usb.h> |
| 30 | #include <asm/ehci-omap.h> |
| 31 | #endif |
| 32 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 35 | #define TWL4030_I2C_BUS 0 |
| 36 | #define EXPANSION_EEPROM_I2C_BUS 2 |
| 37 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x51 |
| 38 | |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 39 | #define GUMSTIX_EMPTY_EEPROM 0x0 |
| 40 | |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 41 | #define GUMSTIX_SUMMIT 0x01000200 |
| 42 | #define GUMSTIX_TOBI 0x02000200 |
| 43 | #define GUMSTIX_TOBI_DUO 0x03000200 |
| 44 | #define GUMSTIX_PALO35 0x04000200 |
| 45 | #define GUMSTIX_PALO43 0x05000200 |
| 46 | #define GUMSTIX_CHESTNUT43 0x06000200 |
| 47 | #define GUMSTIX_PINTO 0x07000200 |
| 48 | #define GUMSTIX_GALLOP43 0x08000200 |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 49 | #define GUMSTIX_ALTO35 0x09000200 |
| 50 | #define GUMSTIX_STAGECOACH 0x0A000200 |
| 51 | #define GUMSTIX_THUMBO 0x0B000200 |
| 52 | #define GUMSTIX_TURTLECORE 0x0C000200 |
| 53 | #define GUMSTIX_ARBOR43C 0x0D000200 |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 54 | |
| 55 | #define ETTUS_USRP_E 0x01000300 |
| 56 | |
| 57 | #define GUMSTIX_NO_EEPROM 0xffffffff |
| 58 | |
| 59 | static struct { |
| 60 | unsigned int device_vendor; |
| 61 | unsigned char revision; |
| 62 | unsigned char content; |
| 63 | char fab_revision[8]; |
| 64 | char env_var[16]; |
| 65 | char env_setting[64]; |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 66 | } expansion_config = {0x0}; |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 67 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 68 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 69 | * Routine: board_init |
| 70 | * Description: Early hardware init. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 71 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 72 | int board_init(void) |
| 73 | { |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 74 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 75 | /* board id for Linux */ |
| 76 | gd->bd->bi_arch_number = MACH_TYPE_OVERO; |
| 77 | /* boot param addr */ |
| 78 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 83 | /* |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 84 | * Routine: get_board_revision |
| 85 | * Description: Returns the board revision |
| 86 | */ |
| 87 | int get_board_revision(void) |
| 88 | { |
| 89 | int revision; |
| 90 | |
Heiko Schocher | f53f2b8 | 2013-10-22 11:03:18 +0200 | [diff] [blame] | 91 | #ifdef CONFIG_SYS_I2C_OMAP34XX |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 92 | unsigned char data; |
| 93 | |
| 94 | /* board revisions <= R2410 connect 4030 irq_1 to gpio112 */ |
| 95 | /* these boards should return a revision number of 0 */ |
| 96 | /* the code below forces a 4030 RTC irq to ensure that gpio112 is low */ |
| 97 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 98 | data = 0x01; |
| 99 | i2c_write(0x4B, 0x29, 1, &data, 1); |
| 100 | data = 0x0c; |
| 101 | i2c_write(0x4B, 0x2b, 1, &data, 1); |
| 102 | i2c_read(0x4B, 0x2a, 1, &data, 1); |
| 103 | #endif |
| 104 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 105 | if (!gpio_request(112, "") && |
| 106 | !gpio_request(113, "") && |
| 107 | !gpio_request(115, "")) { |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 108 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 109 | gpio_direction_input(112); |
| 110 | gpio_direction_input(113); |
| 111 | gpio_direction_input(115); |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 112 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 113 | revision = gpio_get_value(115) << 2 | |
| 114 | gpio_get_value(113) << 1 | |
| 115 | gpio_get_value(112); |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 116 | } else { |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 117 | puts("Error: unable to acquire board revision GPIOs\n"); |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 118 | revision = -1; |
| 119 | } |
| 120 | |
| 121 | return revision; |
| 122 | } |
| 123 | |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 124 | #ifdef CONFIG_SPL_BUILD |
| 125 | /* |
| 126 | * Routine: get_board_mem_timings |
| 127 | * Description: If we use SPL then there is no x-loader nor config header |
| 128 | * so we have to setup the DDR timings ourself on both banks. |
| 129 | */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 130 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 131 | { |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 132 | timings->mr = MICRON_V_MR_165; |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 133 | switch (get_board_revision()) { |
| 134 | case REVISION_0: /* Micron 1286MB/256MB, 1/2 banks of 128MB */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 135 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 136 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 137 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 138 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 139 | break; |
| 140 | case REVISION_1: /* Micron 256MB/512MB, 1/2 banks of 256MB */ |
Ash Charles | 9517fbb4 | 2014-05-21 14:04:52 -0700 | [diff] [blame] | 141 | case REVISION_4: |
Ash Charles | aeaa403 | 2013-07-24 12:22:35 -0700 | [diff] [blame] | 142 | timings->mcfg = MICRON_V_MCFG_200(256 << 20); |
| 143 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 144 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 145 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 146 | break; |
| 147 | case REVISION_2: /* Hynix 256MB/512MB, 1/2 banks of 256MB */ |
Ash Charles | aeaa403 | 2013-07-24 12:22:35 -0700 | [diff] [blame] | 148 | timings->mcfg = HYNIX_V_MCFG_200(256 << 20); |
| 149 | timings->ctrla = HYNIX_V_ACTIMA_200; |
| 150 | timings->ctrlb = HYNIX_V_ACTIMB_200; |
| 151 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 152 | break; |
Steve Sakoman | 9f32a9e | 2013-07-24 12:22:34 -0700 | [diff] [blame] | 153 | case REVISION_3: /* Micron 512MB/1024MB, 1/2 banks of 512MB */ |
| 154 | timings->mcfg = MCFG(512 << 20, 15); |
| 155 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 156 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 157 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
| 158 | break; |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 159 | default: |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 160 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 161 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 162 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 163 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | #endif |
| 167 | |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 168 | /* |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 169 | * Routine: get_sdio2_config |
| 170 | * Description: Return information about the wifi module connection |
| 171 | * Returns 0 if the module connects though a level translator |
| 172 | * Returns 1 if the module connects directly |
| 173 | */ |
| 174 | int get_sdio2_config(void) |
| 175 | { |
| 176 | int sdio_direct; |
| 177 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 178 | if (!gpio_request(130, "") && !gpio_request(139, "")) { |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 179 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 180 | gpio_direction_output(130, 0); |
| 181 | gpio_direction_input(139); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 182 | |
| 183 | sdio_direct = 1; |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 184 | gpio_set_value(130, 0); |
| 185 | if (gpio_get_value(139) == 0) { |
| 186 | gpio_set_value(130, 1); |
| 187 | if (gpio_get_value(139) == 1) |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 188 | sdio_direct = 0; |
| 189 | } |
| 190 | |
Joe Hershberger | 9b124d3 | 2011-10-12 10:31:44 +0000 | [diff] [blame] | 191 | gpio_direction_input(130); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 192 | } else { |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 193 | puts("Error: unable to acquire sdio2 clk GPIOs\n"); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 194 | sdio_direct = -1; |
| 195 | } |
| 196 | |
| 197 | return sdio_direct; |
| 198 | } |
| 199 | |
| 200 | /* |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 201 | * Routine: get_expansion_id |
| 202 | * Description: This function checks for expansion board by checking I2C |
| 203 | * bus 2 for the availability of an AT24C01B serial EEPROM. |
| 204 | * returns the device_vendor field from the EEPROM |
| 205 | */ |
| 206 | unsigned int get_expansion_id(void) |
| 207 | { |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 208 | if (expansion_config.device_vendor != 0x0) |
| 209 | return expansion_config.device_vendor; |
| 210 | |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 211 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 212 | |
| 213 | /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */ |
| 214 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 215 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 216 | return GUMSTIX_NO_EEPROM; |
| 217 | } |
| 218 | |
| 219 | /* read configuration data */ |
| 220 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 221 | sizeof(expansion_config)); |
| 222 | |
| 223 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 224 | |
| 225 | return expansion_config.device_vendor; |
| 226 | } |
| 227 | |
| 228 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 229 | * Routine: misc_init_r |
| 230 | * Description: Configure board specific parts |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 231 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 232 | int misc_init_r(void) |
| 233 | { |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 234 | unsigned int expansion_id; |
| 235 | |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 236 | twl4030_power_init(); |
Grazvydas Ignotas | 17887bf | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 237 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 238 | |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 239 | printf("Board revision: %d\n", get_board_revision()); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 240 | |
| 241 | switch (get_sdio2_config()) { |
| 242 | case 0: |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 243 | puts("Tranceiver detected on mmc2\n"); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 244 | MUX_OVERO_SDIO2_TRANSCEIVER(); |
| 245 | break; |
| 246 | case 1: |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 247 | puts("Direct connection on mmc2\n"); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 248 | MUX_OVERO_SDIO2_DIRECT(); |
| 249 | break; |
| 250 | default: |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 251 | puts("Unable to detect mmc2 connection type\n"); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 254 | expansion_id = get_expansion_id(); |
| 255 | switch (expansion_id) { |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 256 | case GUMSTIX_SUMMIT: |
| 257 | printf("Recognized Summit expansion board (rev %d %s)\n", |
| 258 | expansion_config.revision, |
| 259 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 260 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 261 | setenv("defaultdisplay", "dvi"); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 262 | setenv("expansionname", "summit"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 263 | break; |
| 264 | case GUMSTIX_TOBI: |
| 265 | printf("Recognized Tobi expansion board (rev %d %s)\n", |
| 266 | expansion_config.revision, |
| 267 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 268 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 269 | setenv("defaultdisplay", "dvi"); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 270 | setenv("expansionname", "tobi"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 271 | break; |
| 272 | case GUMSTIX_TOBI_DUO: |
| 273 | printf("Recognized Tobi Duo expansion board (rev %d %s)\n", |
| 274 | expansion_config.revision, |
| 275 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 276 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 277 | break; |
| 278 | case GUMSTIX_PALO35: |
| 279 | printf("Recognized Palo35 expansion board (rev %d %s)\n", |
| 280 | expansion_config.revision, |
| 281 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 282 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 283 | setenv("defaultdisplay", "lcd35"); |
| 284 | break; |
| 285 | case GUMSTIX_PALO43: |
| 286 | printf("Recognized Palo43 expansion board (rev %d %s)\n", |
| 287 | expansion_config.revision, |
| 288 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 289 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 290 | setenv("defaultdisplay", "lcd43"); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 291 | setenv("expansionname", "palo43"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 292 | break; |
| 293 | case GUMSTIX_CHESTNUT43: |
| 294 | printf("Recognized Chestnut43 expansion board (rev %d %s)\n", |
| 295 | expansion_config.revision, |
| 296 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 297 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 298 | setenv("defaultdisplay", "lcd43"); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 299 | setenv("expansionname", "chestnut43"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 300 | break; |
| 301 | case GUMSTIX_PINTO: |
| 302 | printf("Recognized Pinto expansion board (rev %d %s)\n", |
| 303 | expansion_config.revision, |
| 304 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 305 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 306 | break; |
| 307 | case GUMSTIX_GALLOP43: |
| 308 | printf("Recognized Gallop43 expansion board (rev %d %s)\n", |
| 309 | expansion_config.revision, |
| 310 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 311 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 312 | setenv("defaultdisplay", "lcd43"); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 313 | setenv("expansionname", "gallop43"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 314 | break; |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 315 | case GUMSTIX_ALTO35: |
| 316 | printf("Recognized Alto35 expansion board (rev %d %s)\n", |
| 317 | expansion_config.revision, |
| 318 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 319 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 320 | MUX_ALTO35(); |
| 321 | setenv("defaultdisplay", "lcd35"); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 322 | setenv("expansionname", "alto35"); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 323 | break; |
| 324 | case GUMSTIX_STAGECOACH: |
| 325 | printf("Recognized Stagecoach expansion board (rev %d %s)\n", |
| 326 | expansion_config.revision, |
| 327 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 328 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 329 | break; |
| 330 | case GUMSTIX_THUMBO: |
| 331 | printf("Recognized Thumbo expansion board (rev %d %s)\n", |
| 332 | expansion_config.revision, |
| 333 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 334 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 335 | break; |
| 336 | case GUMSTIX_TURTLECORE: |
| 337 | printf("Recognized Turtlecore expansion board (rev %d %s)\n", |
| 338 | expansion_config.revision, |
| 339 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 340 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 341 | break; |
| 342 | case GUMSTIX_ARBOR43C: |
| 343 | printf("Recognized Arbor43C expansion board (rev %d %s)\n", |
| 344 | expansion_config.revision, |
| 345 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 346 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 347 | MUX_ARBOR43C(); |
| 348 | setenv("defaultdisplay", "lcd43"); |
| 349 | break; |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 350 | case ETTUS_USRP_E: |
| 351 | printf("Recognized Ettus Research USRP-E (rev %d %s)\n", |
| 352 | expansion_config.revision, |
| 353 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 354 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 355 | MUX_USRP_E(); |
| 356 | setenv("defaultdisplay", "dvi"); |
| 357 | break; |
| 358 | case GUMSTIX_NO_EEPROM: |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 359 | case GUMSTIX_EMPTY_EEPROM: |
| 360 | puts("No or empty EEPROM on expansion board\n"); |
| 361 | MUX_GUMSTIX(); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 362 | setenv("expansionname", "tobi"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 363 | break; |
| 364 | default: |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 365 | printf("Unrecognized expansion board 0x%08x\n", expansion_id); |
| 366 | break; |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | if (expansion_config.content == 1) |
| 370 | setenv(expansion_config.env_var, expansion_config.env_setting); |
| 371 | |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 372 | dieid_num_r(); |
| 373 | |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 374 | if (get_cpu_family() == CPU_OMAP34XX) |
| 375 | setenv("boardname", "overo"); |
| 376 | else |
| 377 | setenv("boardname", "overo-storm"); |
| 378 | |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 379 | return 0; |
| 380 | } |
| 381 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 382 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 383 | * Routine: set_muxconf_regs |
| 384 | * Description: Setting up the configuration Mux registers specific to the |
| 385 | * hardware. Many pins need to be moved from protect to primary |
| 386 | * mode. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 387 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 388 | void set_muxconf_regs(void) |
| 389 | { |
| 390 | MUX_OVERO(); |
| 391 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 392 | |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 393 | #if defined(CONFIG_CMD_NET) && !defined(CONFIG_SPL_BUILD) |
| 394 | /* GPMC definitions for LAN9221 chips on Tobi expansion boards */ |
| 395 | static const u32 gpmc_lan_config[] = { |
| 396 | NET_LAN9221_GPMC_CONFIG1, |
| 397 | NET_LAN9221_GPMC_CONFIG2, |
| 398 | NET_LAN9221_GPMC_CONFIG3, |
| 399 | NET_LAN9221_GPMC_CONFIG4, |
| 400 | NET_LAN9221_GPMC_CONFIG5, |
| 401 | NET_LAN9221_GPMC_CONFIG6, |
| 402 | /*CONFIG7- computed as params */ |
| 403 | }; |
| 404 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 405 | /* |
| 406 | * Routine: setup_net_chip |
| 407 | * Description: Setting up the configuration GPMC registers specific to the |
| 408 | * Ethernet hardware. |
| 409 | */ |
| 410 | static void setup_net_chip(void) |
| 411 | { |
| 412 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
| 413 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 414 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 415 | writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 416 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 417 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 418 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 419 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 420 | &ctrl_base->gpmc_nadv_ale); |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 421 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 422 | |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 423 | /* |
| 424 | * Routine: reset_net_chip |
| 425 | * Description: Reset the Ethernet hardware. |
| 426 | */ |
| 427 | static void reset_net_chip(void) |
| 428 | { |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 429 | /* Make GPIO 64 as output pin and send a magic pulse through it */ |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 430 | if (!gpio_request(64, "")) { |
| 431 | gpio_direction_output(64, 0); |
| 432 | gpio_set_value(64, 1); |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 433 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 434 | gpio_set_value(64, 0); |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 435 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 436 | gpio_set_value(64, 1); |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 437 | } |
| 438 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 439 | |
| 440 | int board_eth_init(bd_t *bis) |
| 441 | { |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 442 | unsigned int expansion_id; |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 443 | int rc = 0; |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 444 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 445 | #ifdef CONFIG_SMC911X |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 446 | expansion_id = get_expansion_id(); |
| 447 | switch (expansion_id) { |
| 448 | case GUMSTIX_TOBI_DUO: |
| 449 | /* second lan chip */ |
| 450 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], |
| 451 | 0x2B000000, GPMC_SIZE_16M); |
| 452 | /* no break */ |
| 453 | case GUMSTIX_TOBI: |
| 454 | case GUMSTIX_CHESTNUT43: |
| 455 | case GUMSTIX_STAGECOACH: |
| 456 | case GUMSTIX_NO_EEPROM: |
| 457 | case GUMSTIX_EMPTY_EEPROM: |
| 458 | /* first lan chip */ |
| 459 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], |
| 460 | 0x2C000000, GPMC_SIZE_16M); |
| 461 | |
| 462 | setup_net_chip(); |
| 463 | reset_net_chip(); |
| 464 | |
| 465 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 466 | break; |
| 467 | default: |
| 468 | break; |
| 469 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 470 | #endif |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 471 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 472 | return rc; |
| 473 | } |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 474 | #endif |
Steve Sakoman | b7d8052 | 2010-09-19 21:21:07 -0700 | [diff] [blame] | 475 | |
Andreas Müller | 785f1f0 | 2012-01-04 15:26:25 +0000 | [diff] [blame] | 476 | #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD) |
Steve Sakoman | b7d8052 | 2010-09-19 21:21:07 -0700 | [diff] [blame] | 477 | int board_mmc_init(bd_t *bis) |
| 478 | { |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 479 | return omap_mmc_init(0, 0, 0, -1, -1); |
Steve Sakoman | b7d8052 | 2010-09-19 21:21:07 -0700 | [diff] [blame] | 480 | } |
| 481 | #endif |
Stefan Herbrechtsmeier | 0c87e68 | 2014-09-16 17:51:09 +0200 | [diff] [blame^] | 482 | |
| 483 | #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD) |
| 484 | static struct omap_usbhs_board_data usbhs_bdata = { |
| 485 | .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED, |
| 486 | .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, |
| 487 | .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED |
| 488 | }; |
| 489 | |
| 490 | #define GUMSTIX_GPIO_USBH_CPEN 168 |
| 491 | int ehci_hcd_init(int index, enum usb_init_type init, |
| 492 | struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
| 493 | { |
| 494 | /* Enable USB power */ |
| 495 | if (!gpio_request(GUMSTIX_GPIO_USBH_CPEN, "usbh_cpen")) |
| 496 | gpio_direction_output(GUMSTIX_GPIO_USBH_CPEN, 1); |
| 497 | |
| 498 | return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor); |
| 499 | } |
| 500 | |
| 501 | int ehci_hcd_stop(void) |
| 502 | { |
| 503 | /* Disable USB power */ |
| 504 | gpio_set_value(GUMSTIX_GPIO_USBH_CPEN, 0); |
| 505 | gpio_free(GUMSTIX_GPIO_USBH_CPEN); |
| 506 | |
| 507 | return omap_ehci_hcd_stop(); |
| 508 | } |
| 509 | |
| 510 | #endif /* CONFIG_USB_EHCI */ |