Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Maintainer : Steve Sakoman <steve@sakoman.com> |
| 4 | * |
| 5 | * Derived from Beagle Board, 3430 SDP, and OMAP3EVM code by |
| 6 | * Richard Woodruff <r-woodruff2@ti.com> |
| 7 | * Syed Mohammed Khasim <khasim@ti.com> |
| 8 | * Sunil Kumar <sunilsaini05@gmail.com> |
| 9 | * Shashi Ranjan <shashiranjanmca05@gmail.com> |
| 10 | * |
| 11 | * (C) Copyright 2004-2008 |
| 12 | * Texas Instruments, <www.ti.com> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 13 | */ |
| 14 | #include <common.h> |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 15 | #include <dm.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 16 | #include <env.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 17 | #include <malloc.h> |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 18 | #include <ns16550.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 19 | #include <netdev.h> |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 20 | #include <twl4030.h> |
Masahiro Yamada | 2b7a873 | 2017-11-30 13:45:24 +0900 | [diff] [blame] | 21 | #include <linux/mtd/rawnand.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 22 | #include <asm/io.h> |
Steve Sakoman | b7d8052 | 2010-09-19 21:21:07 -0700 | [diff] [blame] | 23 | #include <asm/arch/mmc_host_def.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 24 | #include <asm/arch/mux.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 25 | #include <asm/arch/mem.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 26 | #include <asm/arch/sys_proto.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 27 | #include <asm/gpio.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 28 | #include <asm/mach-types.h> |
| 29 | #include "overo.h" |
| 30 | |
Tom Rini | ceed5d2 | 2017-05-12 22:33:27 -0400 | [diff] [blame] | 31 | #ifdef CONFIG_USB_EHCI_HCD |
Stefan Herbrechtsmeier | 0c87e68 | 2014-09-16 17:51:09 +0200 | [diff] [blame] | 32 | #include <usb.h> |
| 33 | #include <asm/ehci-omap.h> |
| 34 | #endif |
| 35 | |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 36 | #define TWL4030_I2C_BUS 0 |
| 37 | #define EXPANSION_EEPROM_I2C_BUS 2 |
| 38 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x51 |
| 39 | |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 40 | #define GUMSTIX_EMPTY_EEPROM 0x0 |
| 41 | |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 42 | #define GUMSTIX_SUMMIT 0x01000200 |
| 43 | #define GUMSTIX_TOBI 0x02000200 |
| 44 | #define GUMSTIX_TOBI_DUO 0x03000200 |
| 45 | #define GUMSTIX_PALO35 0x04000200 |
| 46 | #define GUMSTIX_PALO43 0x05000200 |
| 47 | #define GUMSTIX_CHESTNUT43 0x06000200 |
| 48 | #define GUMSTIX_PINTO 0x07000200 |
| 49 | #define GUMSTIX_GALLOP43 0x08000200 |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 50 | #define GUMSTIX_ALTO35 0x09000200 |
| 51 | #define GUMSTIX_STAGECOACH 0x0A000200 |
| 52 | #define GUMSTIX_THUMBO 0x0B000200 |
| 53 | #define GUMSTIX_TURTLECORE 0x0C000200 |
| 54 | #define GUMSTIX_ARBOR43C 0x0D000200 |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 55 | |
| 56 | #define ETTUS_USRP_E 0x01000300 |
| 57 | |
| 58 | #define GUMSTIX_NO_EEPROM 0xffffffff |
| 59 | |
| 60 | static struct { |
| 61 | unsigned int device_vendor; |
| 62 | unsigned char revision; |
| 63 | unsigned char content; |
| 64 | char fab_revision[8]; |
| 65 | char env_var[16]; |
| 66 | char env_setting[64]; |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 67 | } expansion_config = {0x0}; |
Steve Sakoman | 0d1d008 | 2010-08-12 21:07:02 -0700 | [diff] [blame] | 68 | |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 69 | static const struct ns16550_platdata overo_serial = { |
Adam Ford | d1e22fa | 2016-03-07 21:08:49 -0600 | [diff] [blame] | 70 | .base = OMAP34XX_UART3, |
| 71 | .reg_shift = 2, |
Heiko Schocher | 06f108e | 2017-01-18 08:05:49 +0100 | [diff] [blame] | 72 | .clock = V_NS16550_CLK, |
| 73 | .fcr = UART_FCR_DEFVAL, |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | U_BOOT_DEVICE(overo_uart) = { |
Thomas Chou | 52ac443 | 2015-11-19 21:48:12 +0800 | [diff] [blame] | 77 | "ns16550_serial", |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 78 | &overo_serial |
| 79 | }; |
| 80 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 81 | /* |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 82 | * Routine: get_sdio2_config |
| 83 | * Description: Return information about the wifi module connection |
| 84 | * Returns 0 if the module connects though a level translator |
| 85 | * Returns 1 if the module connects directly |
| 86 | */ |
| 87 | int get_sdio2_config(void) |
| 88 | { |
| 89 | int sdio_direct; |
| 90 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 91 | if (!gpio_request(130, "") && !gpio_request(139, "")) { |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 92 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 93 | gpio_direction_output(130, 0); |
| 94 | gpio_direction_input(139); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 95 | |
| 96 | sdio_direct = 1; |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 97 | gpio_set_value(130, 0); |
| 98 | if (gpio_get_value(139) == 0) { |
| 99 | gpio_set_value(130, 1); |
| 100 | if (gpio_get_value(139) == 1) |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 101 | sdio_direct = 0; |
| 102 | } |
| 103 | |
Joe Hershberger | 9b124d3 | 2011-10-12 10:31:44 +0000 | [diff] [blame] | 104 | gpio_direction_input(130); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 105 | } else { |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 106 | puts("Error: unable to acquire sdio2 clk GPIOs\n"); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 107 | sdio_direct = -1; |
| 108 | } |
| 109 | |
| 110 | return sdio_direct; |
| 111 | } |
| 112 | |
| 113 | /* |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 114 | * Routine: get_expansion_id |
| 115 | * Description: This function checks for expansion board by checking I2C |
| 116 | * bus 2 for the availability of an AT24C01B serial EEPROM. |
| 117 | * returns the device_vendor field from the EEPROM |
| 118 | */ |
| 119 | unsigned int get_expansion_id(void) |
| 120 | { |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 121 | if (expansion_config.device_vendor != 0x0) |
| 122 | return expansion_config.device_vendor; |
| 123 | |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 124 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 125 | |
| 126 | /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */ |
| 127 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 128 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 129 | return GUMSTIX_NO_EEPROM; |
| 130 | } |
| 131 | |
| 132 | /* read configuration data */ |
| 133 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 134 | sizeof(expansion_config)); |
| 135 | |
| 136 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 137 | |
| 138 | return expansion_config.device_vendor; |
| 139 | } |
| 140 | |
| 141 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 142 | * Routine: misc_init_r |
| 143 | * Description: Configure board specific parts |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 144 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 145 | int misc_init_r(void) |
| 146 | { |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 147 | unsigned int expansion_id; |
| 148 | |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 149 | twl4030_power_init(); |
Grazvydas Ignotas | 17887bf | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 150 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 151 | |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 152 | printf("Board revision: %d\n", get_board_revision()); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 153 | |
| 154 | switch (get_sdio2_config()) { |
| 155 | case 0: |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 156 | puts("Tranceiver detected on mmc2\n"); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 157 | MUX_OVERO_SDIO2_TRANSCEIVER(); |
| 158 | break; |
| 159 | case 1: |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 160 | puts("Direct connection on mmc2\n"); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 161 | MUX_OVERO_SDIO2_DIRECT(); |
| 162 | break; |
| 163 | default: |
Andreas Müller | b958a5d | 2012-01-04 15:26:20 +0000 | [diff] [blame] | 164 | puts("Unable to detect mmc2 connection type\n"); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 167 | expansion_id = get_expansion_id(); |
| 168 | switch (expansion_id) { |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 169 | case GUMSTIX_SUMMIT: |
| 170 | printf("Recognized Summit expansion board (rev %d %s)\n", |
| 171 | expansion_config.revision, |
| 172 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 173 | MUX_GUMSTIX(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 174 | env_set("defaultdisplay", "dvi"); |
| 175 | env_set("expansionname", "summit"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 176 | break; |
| 177 | case GUMSTIX_TOBI: |
| 178 | printf("Recognized Tobi expansion board (rev %d %s)\n", |
| 179 | expansion_config.revision, |
| 180 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 181 | MUX_GUMSTIX(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 182 | env_set("defaultdisplay", "dvi"); |
| 183 | env_set("expansionname", "tobi"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 184 | break; |
| 185 | case GUMSTIX_TOBI_DUO: |
| 186 | printf("Recognized Tobi Duo expansion board (rev %d %s)\n", |
| 187 | expansion_config.revision, |
| 188 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 189 | MUX_GUMSTIX(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 190 | env_set("expansionname", "tobiduo"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 191 | break; |
| 192 | case GUMSTIX_PALO35: |
| 193 | printf("Recognized Palo35 expansion board (rev %d %s)\n", |
| 194 | expansion_config.revision, |
| 195 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 196 | MUX_GUMSTIX(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 197 | env_set("defaultdisplay", "lcd35"); |
| 198 | env_set("expansionname", "palo35"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 199 | break; |
| 200 | case GUMSTIX_PALO43: |
| 201 | printf("Recognized Palo43 expansion board (rev %d %s)\n", |
| 202 | expansion_config.revision, |
| 203 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 204 | MUX_GUMSTIX(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 205 | env_set("defaultdisplay", "lcd43"); |
| 206 | env_set("expansionname", "palo43"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 207 | break; |
| 208 | case GUMSTIX_CHESTNUT43: |
| 209 | printf("Recognized Chestnut43 expansion board (rev %d %s)\n", |
| 210 | expansion_config.revision, |
| 211 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 212 | MUX_GUMSTIX(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 213 | env_set("defaultdisplay", "lcd43"); |
| 214 | env_set("expansionname", "chestnut43"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 215 | break; |
| 216 | case GUMSTIX_PINTO: |
| 217 | printf("Recognized Pinto expansion board (rev %d %s)\n", |
| 218 | expansion_config.revision, |
| 219 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 220 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 221 | break; |
| 222 | case GUMSTIX_GALLOP43: |
| 223 | printf("Recognized Gallop43 expansion board (rev %d %s)\n", |
| 224 | expansion_config.revision, |
| 225 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 226 | MUX_GUMSTIX(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 227 | env_set("defaultdisplay", "lcd43"); |
| 228 | env_set("expansionname", "gallop43"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 229 | break; |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 230 | case GUMSTIX_ALTO35: |
| 231 | printf("Recognized Alto35 expansion board (rev %d %s)\n", |
| 232 | expansion_config.revision, |
| 233 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 234 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 235 | MUX_ALTO35(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 236 | env_set("defaultdisplay", "lcd35"); |
| 237 | env_set("expansionname", "alto35"); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 238 | break; |
| 239 | case GUMSTIX_STAGECOACH: |
| 240 | printf("Recognized Stagecoach expansion board (rev %d %s)\n", |
| 241 | expansion_config.revision, |
| 242 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 243 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 244 | break; |
| 245 | case GUMSTIX_THUMBO: |
| 246 | printf("Recognized Thumbo expansion board (rev %d %s)\n", |
| 247 | expansion_config.revision, |
| 248 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 249 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 250 | break; |
| 251 | case GUMSTIX_TURTLECORE: |
| 252 | printf("Recognized Turtlecore expansion board (rev %d %s)\n", |
| 253 | expansion_config.revision, |
| 254 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 255 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 256 | break; |
| 257 | case GUMSTIX_ARBOR43C: |
| 258 | printf("Recognized Arbor43C expansion board (rev %d %s)\n", |
| 259 | expansion_config.revision, |
| 260 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 261 | MUX_GUMSTIX(); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 262 | MUX_ARBOR43C(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 263 | env_set("defaultdisplay", "lcd43"); |
| 264 | env_set("expansionname", "arbor43c"); |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 265 | break; |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 266 | case ETTUS_USRP_E: |
| 267 | printf("Recognized Ettus Research USRP-E (rev %d %s)\n", |
| 268 | expansion_config.revision, |
| 269 | expansion_config.fab_revision); |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 270 | MUX_GUMSTIX(); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 271 | MUX_USRP_E(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 272 | env_set("defaultdisplay", "dvi"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 273 | break; |
| 274 | case GUMSTIX_NO_EEPROM: |
Stefan Herbrechtsmeier | e2f29a1 | 2014-09-16 17:51:08 +0200 | [diff] [blame] | 275 | case GUMSTIX_EMPTY_EEPROM: |
| 276 | puts("No or empty EEPROM on expansion board\n"); |
| 277 | MUX_GUMSTIX(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 278 | env_set("expansionname", "tobi"); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 279 | break; |
| 280 | default: |
Ash Charles | 7baad0f | 2014-05-21 14:04:53 -0700 | [diff] [blame] | 281 | printf("Unrecognized expansion board 0x%08x\n", expansion_id); |
| 282 | break; |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | if (expansion_config.content == 1) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 286 | env_set(expansion_config.env_var, expansion_config.env_setting); |
Steve Sakoman | 0b88063 | 2010-09-20 08:05:14 -0700 | [diff] [blame] | 287 | |
Paul Kocialkowski | 6bc318e | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 288 | omap_die_id_display(); |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 289 | |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 290 | if (get_cpu_family() == CPU_OMAP34XX) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 291 | env_set("boardname", "overo"); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 292 | else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 293 | env_set("boardname", "overo-storm"); |
Ash Charles | 1bfdde6 | 2014-06-10 12:02:36 -0700 | [diff] [blame] | 294 | |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 295 | return 0; |
| 296 | } |
| 297 | |
Arun Bharadwaj | 9a0475c | 2015-04-28 16:55:29 -0700 | [diff] [blame] | 298 | #if defined(CONFIG_CMD_NET) |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 299 | /* GPMC definitions for LAN9221 chips on Tobi expansion boards */ |
| 300 | static const u32 gpmc_lan_config[] = { |
| 301 | NET_LAN9221_GPMC_CONFIG1, |
| 302 | NET_LAN9221_GPMC_CONFIG2, |
| 303 | NET_LAN9221_GPMC_CONFIG3, |
| 304 | NET_LAN9221_GPMC_CONFIG4, |
| 305 | NET_LAN9221_GPMC_CONFIG5, |
| 306 | NET_LAN9221_GPMC_CONFIG6, |
| 307 | /*CONFIG7- computed as params */ |
| 308 | }; |
| 309 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 310 | /* |
| 311 | * Routine: setup_net_chip |
| 312 | * Description: Setting up the configuration GPMC registers specific to the |
| 313 | * Ethernet hardware. |
| 314 | */ |
| 315 | static void setup_net_chip(void) |
| 316 | { |
| 317 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
| 318 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 319 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 320 | writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 321 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 322 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 323 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 324 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 325 | &ctrl_base->gpmc_nadv_ale); |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 326 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 327 | |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 328 | /* |
| 329 | * Routine: reset_net_chip |
| 330 | * Description: Reset the Ethernet hardware. |
| 331 | */ |
| 332 | static void reset_net_chip(void) |
| 333 | { |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 334 | /* 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] | 335 | if (!gpio_request(64, "")) { |
| 336 | gpio_direction_output(64, 0); |
| 337 | gpio_set_value(64, 1); |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 338 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 339 | gpio_set_value(64, 0); |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 340 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 341 | gpio_set_value(64, 1); |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 342 | } |
| 343 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 344 | |
| 345 | int board_eth_init(bd_t *bis) |
| 346 | { |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 347 | unsigned int expansion_id; |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 348 | int rc = 0; |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 349 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 350 | #ifdef CONFIG_SMC911X |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 351 | expansion_id = get_expansion_id(); |
| 352 | switch (expansion_id) { |
| 353 | case GUMSTIX_TOBI_DUO: |
| 354 | /* second lan chip */ |
| 355 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], |
| 356 | 0x2B000000, GPMC_SIZE_16M); |
| 357 | /* no break */ |
| 358 | case GUMSTIX_TOBI: |
| 359 | case GUMSTIX_CHESTNUT43: |
| 360 | case GUMSTIX_STAGECOACH: |
| 361 | case GUMSTIX_NO_EEPROM: |
| 362 | case GUMSTIX_EMPTY_EEPROM: |
| 363 | /* first lan chip */ |
| 364 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], |
| 365 | 0x2C000000, GPMC_SIZE_16M); |
| 366 | |
| 367 | setup_net_chip(); |
| 368 | reset_net_chip(); |
| 369 | |
| 370 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 371 | break; |
| 372 | default: |
| 373 | break; |
| 374 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 375 | #endif |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 376 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 377 | return rc; |
| 378 | } |
Stefan Herbrechtsmeier | 59f72d2 | 2014-09-16 17:51:07 +0200 | [diff] [blame] | 379 | #endif |
Steve Sakoman | b7d8052 | 2010-09-19 21:21:07 -0700 | [diff] [blame] | 380 | |
Tom Rini | ceed5d2 | 2017-05-12 22:33:27 -0400 | [diff] [blame] | 381 | #if defined(CONFIG_USB_EHCI_HCD) |
Stefan Herbrechtsmeier | 0c87e68 | 2014-09-16 17:51:09 +0200 | [diff] [blame] | 382 | static struct omap_usbhs_board_data usbhs_bdata = { |
| 383 | .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED, |
| 384 | .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, |
| 385 | .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED |
| 386 | }; |
| 387 | |
| 388 | #define GUMSTIX_GPIO_USBH_CPEN 168 |
| 389 | int ehci_hcd_init(int index, enum usb_init_type init, |
| 390 | struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
| 391 | { |
| 392 | /* Enable USB power */ |
| 393 | if (!gpio_request(GUMSTIX_GPIO_USBH_CPEN, "usbh_cpen")) |
| 394 | gpio_direction_output(GUMSTIX_GPIO_USBH_CPEN, 1); |
| 395 | |
| 396 | return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor); |
| 397 | } |
| 398 | |
| 399 | int ehci_hcd_stop(void) |
| 400 | { |
| 401 | /* Disable USB power */ |
| 402 | gpio_set_value(GUMSTIX_GPIO_USBH_CPEN, 0); |
| 403 | gpio_free(GUMSTIX_GPIO_USBH_CPEN); |
| 404 | |
| 405 | return omap_ehci_hcd_stop(); |
| 406 | } |
| 407 | |
Tom Rini | ceed5d2 | 2017-05-12 22:33:27 -0400 | [diff] [blame] | 408 | #endif /* CONFIG_USB_EHCI_HCD */ |