blob: 66146eead5f751650366e14f900a015a6c75c282 [file] [log] [blame]
Dirk Behme220faba2009-01-28 21:39:57 +01001/*
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 Denkd79de1d2013-07-08 09:37:19 +020013 * SPDX-License-Identifier: GPL-2.0+
Dirk Behme220faba2009-01-28 21:39:57 +010014 */
15#include <common.h>
Olof Johansson4963f922009-09-29 10:22:45 -040016#include <netdev.h>
Tom Rix0f2a8042009-06-28 12:52:30 -050017#include <twl4030.h>
Andreas Müller785f1f02012-01-04 15:26:25 +000018#include <linux/mtd/nand.h>
Dirk Behme220faba2009-01-28 21:39:57 +010019#include <asm/io.h>
Steve Sakomanb7d80522010-09-19 21:21:07 -070020#include <asm/arch/mmc_host_def.h>
Dirk Behme220faba2009-01-28 21:39:57 +010021#include <asm/arch/mux.h>
Olof Johansson4963f922009-09-29 10:22:45 -040022#include <asm/arch/mem.h>
Dirk Behme220faba2009-01-28 21:39:57 +010023#include <asm/arch/sys_proto.h>
Sanjeev Premi7b3dc822011-09-08 10:51:01 -040024#include <asm/gpio.h>
Dirk Behme220faba2009-01-28 21:39:57 +010025#include <asm/mach-types.h>
26#include "overo.h"
27
Stefan Herbrechtsmeier0c87e682014-09-16 17:51:09 +020028#ifdef CONFIG_USB_EHCI
29#include <usb.h>
30#include <asm/ehci-omap.h>
31#endif
32
John Rigby0d21ed02010-12-20 18:27:51 -070033DECLARE_GLOBAL_DATA_PTR;
34
Steve Sakoman0b880632010-09-20 08:05:14 -070035#define TWL4030_I2C_BUS 0
36#define EXPANSION_EEPROM_I2C_BUS 2
37#define EXPANSION_EEPROM_I2C_ADDRESS 0x51
38
Stefan Herbrechtsmeiere2f29a12014-09-16 17:51:08 +020039#define GUMSTIX_EMPTY_EEPROM 0x0
40
Steve Sakoman0b880632010-09-20 08:05:14 -070041#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 Charles7baad0f2014-05-21 14:04:53 -070049#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 Sakoman0b880632010-09-20 08:05:14 -070054
55#define ETTUS_USRP_E 0x01000300
56
57#define GUMSTIX_NO_EEPROM 0xffffffff
58
59static 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +020066} expansion_config = {0x0};
Steve Sakoman0b880632010-09-20 08:05:14 -070067
Tom Rix558bb832009-04-01 22:02:20 -050068/*
Dirk Behme220faba2009-01-28 21:39:57 +010069 * Routine: board_init
70 * Description: Early hardware init.
Tom Rix558bb832009-04-01 22:02:20 -050071 */
Dirk Behme220faba2009-01-28 21:39:57 +010072int board_init(void)
73{
Dirk Behme220faba2009-01-28 21:39:57 +010074 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 Rix558bb832009-04-01 22:02:20 -050083/*
Steve Sakoman5ddc70b2010-08-12 15:13:02 -070084 * Routine: get_board_revision
85 * Description: Returns the board revision
86 */
87int get_board_revision(void)
88{
89 int revision;
90
Heiko Schocherf53f2b82013-10-22 11:03:18 +020091#ifdef CONFIG_SYS_I2C_OMAP34XX
Andreas Müller785f1f02012-01-04 15:26:25 +000092 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 Premi7b3dc822011-09-08 10:51:01 -0400105 if (!gpio_request(112, "") &&
106 !gpio_request(113, "") &&
107 !gpio_request(115, "")) {
Steve Sakoman5ddc70b2010-08-12 15:13:02 -0700108
Sanjeev Premi7b3dc822011-09-08 10:51:01 -0400109 gpio_direction_input(112);
110 gpio_direction_input(113);
111 gpio_direction_input(115);
Steve Sakoman5ddc70b2010-08-12 15:13:02 -0700112
Sanjeev Premi7b3dc822011-09-08 10:51:01 -0400113 revision = gpio_get_value(115) << 2 |
114 gpio_get_value(113) << 1 |
115 gpio_get_value(112);
Steve Sakoman5ddc70b2010-08-12 15:13:02 -0700116 } else {
Andreas Müllerb958a5d2012-01-04 15:26:20 +0000117 puts("Error: unable to acquire board revision GPIOs\n");
Steve Sakoman5ddc70b2010-08-12 15:13:02 -0700118 revision = -1;
119 }
120
121 return revision;
122}
123
Andreas Müller785f1f02012-01-04 15:26:25 +0000124#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 Baradaedb5c2f2012-11-13 07:40:28 +0000130void get_board_mem_timings(struct board_sdrc_timings *timings)
Andreas Müller785f1f02012-01-04 15:26:25 +0000131{
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000132 timings->mr = MICRON_V_MR_165;
Andreas Müller785f1f02012-01-04 15:26:25 +0000133 switch (get_board_revision()) {
134 case REVISION_0: /* Micron 1286MB/256MB, 1/2 banks of 128MB */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000135 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üller785f1f02012-01-04 15:26:25 +0000139 break;
140 case REVISION_1: /* Micron 256MB/512MB, 1/2 banks of 256MB */
Ash Charles9517fbb42014-05-21 14:04:52 -0700141 case REVISION_4:
Ash Charlesaeaa4032013-07-24 12:22:35 -0700142 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üller785f1f02012-01-04 15:26:25 +0000146 break;
147 case REVISION_2: /* Hynix 256MB/512MB, 1/2 banks of 256MB */
Ash Charlesaeaa4032013-07-24 12:22:35 -0700148 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üller785f1f02012-01-04 15:26:25 +0000152 break;
Steve Sakoman9f32a9e2013-07-24 12:22:34 -0700153 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üller785f1f02012-01-04 15:26:25 +0000159 default:
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000160 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üller785f1f02012-01-04 15:26:25 +0000164 }
165}
166#endif
167
Steve Sakoman5ddc70b2010-08-12 15:13:02 -0700168/*
Steve Sakoman541ce992010-08-24 10:37:29 -0700169 * 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 */
174int get_sdio2_config(void)
175{
176 int sdio_direct;
177
Sanjeev Premi7b3dc822011-09-08 10:51:01 -0400178 if (!gpio_request(130, "") && !gpio_request(139, "")) {
Steve Sakoman541ce992010-08-24 10:37:29 -0700179
Sanjeev Premi7b3dc822011-09-08 10:51:01 -0400180 gpio_direction_output(130, 0);
181 gpio_direction_input(139);
Steve Sakoman541ce992010-08-24 10:37:29 -0700182
183 sdio_direct = 1;
Sanjeev Premi7b3dc822011-09-08 10:51:01 -0400184 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 Sakoman541ce992010-08-24 10:37:29 -0700188 sdio_direct = 0;
189 }
190
Joe Hershberger9b124d32011-10-12 10:31:44 +0000191 gpio_direction_input(130);
Steve Sakoman541ce992010-08-24 10:37:29 -0700192 } else {
Andreas Müllerb958a5d2012-01-04 15:26:20 +0000193 puts("Error: unable to acquire sdio2 clk GPIOs\n");
Steve Sakoman541ce992010-08-24 10:37:29 -0700194 sdio_direct = -1;
195 }
196
197 return sdio_direct;
198}
199
200/*
Steve Sakoman0b880632010-09-20 08:05:14 -0700201 * 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 */
206unsigned int get_expansion_id(void)
207{
Stefan Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200208 if (expansion_config.device_vendor != 0x0)
209 return expansion_config.device_vendor;
210
Steve Sakoman0b880632010-09-20 08:05:14 -0700211 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 Behme220faba2009-01-28 21:39:57 +0100229 * Routine: misc_init_r
230 * Description: Configure board specific parts
Tom Rix558bb832009-04-01 22:02:20 -0500231 */
Dirk Behme220faba2009-01-28 21:39:57 +0100232int misc_init_r(void)
233{
Ash Charles7baad0f2014-05-21 14:04:53 -0700234 unsigned int expansion_id;
235
Tom Rix0f2a8042009-06-28 12:52:30 -0500236 twl4030_power_init();
Grazvydas Ignotas17887bf2009-12-10 17:10:21 +0200237 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behme220faba2009-01-28 21:39:57 +0100238
Steve Sakoman5ddc70b2010-08-12 15:13:02 -0700239 printf("Board revision: %d\n", get_board_revision());
Steve Sakoman541ce992010-08-24 10:37:29 -0700240
241 switch (get_sdio2_config()) {
242 case 0:
Andreas Müllerb958a5d2012-01-04 15:26:20 +0000243 puts("Tranceiver detected on mmc2\n");
Steve Sakoman541ce992010-08-24 10:37:29 -0700244 MUX_OVERO_SDIO2_TRANSCEIVER();
245 break;
246 case 1:
Andreas Müllerb958a5d2012-01-04 15:26:20 +0000247 puts("Direct connection on mmc2\n");
Steve Sakoman541ce992010-08-24 10:37:29 -0700248 MUX_OVERO_SDIO2_DIRECT();
249 break;
250 default:
Andreas Müllerb958a5d2012-01-04 15:26:20 +0000251 puts("Unable to detect mmc2 connection type\n");
Steve Sakoman541ce992010-08-24 10:37:29 -0700252 }
253
Ash Charles7baad0f2014-05-21 14:04:53 -0700254 expansion_id = get_expansion_id();
255 switch (expansion_id) {
Steve Sakoman0b880632010-09-20 08:05:14 -0700256 case GUMSTIX_SUMMIT:
257 printf("Recognized Summit expansion board (rev %d %s)\n",
258 expansion_config.revision,
259 expansion_config.fab_revision);
Stefan Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200260 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700261 setenv("defaultdisplay", "dvi");
Ash Charles1bfdde62014-06-10 12:02:36 -0700262 setenv("expansionname", "summit");
Steve Sakoman0b880632010-09-20 08:05:14 -0700263 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200268 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700269 setenv("defaultdisplay", "dvi");
Ash Charles1bfdde62014-06-10 12:02:36 -0700270 setenv("expansionname", "tobi");
Steve Sakoman0b880632010-09-20 08:05:14 -0700271 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200276 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700277 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200282 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700283 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200289 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700290 setenv("defaultdisplay", "lcd43");
Ash Charles1bfdde62014-06-10 12:02:36 -0700291 setenv("expansionname", "palo43");
Steve Sakoman0b880632010-09-20 08:05:14 -0700292 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200297 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700298 setenv("defaultdisplay", "lcd43");
Ash Charles1bfdde62014-06-10 12:02:36 -0700299 setenv("expansionname", "chestnut43");
Steve Sakoman0b880632010-09-20 08:05:14 -0700300 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200305 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700306 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200311 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700312 setenv("defaultdisplay", "lcd43");
Ash Charles1bfdde62014-06-10 12:02:36 -0700313 setenv("expansionname", "gallop43");
Steve Sakoman0b880632010-09-20 08:05:14 -0700314 break;
Ash Charles7baad0f2014-05-21 14:04:53 -0700315 case GUMSTIX_ALTO35:
316 printf("Recognized Alto35 expansion board (rev %d %s)\n",
317 expansion_config.revision,
318 expansion_config.fab_revision);
Stefan Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200319 MUX_GUMSTIX();
Ash Charles7baad0f2014-05-21 14:04:53 -0700320 MUX_ALTO35();
321 setenv("defaultdisplay", "lcd35");
Ash Charles1bfdde62014-06-10 12:02:36 -0700322 setenv("expansionname", "alto35");
Ash Charles7baad0f2014-05-21 14:04:53 -0700323 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200328 MUX_GUMSTIX();
Ash Charles7baad0f2014-05-21 14:04:53 -0700329 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200334 MUX_GUMSTIX();
Ash Charles7baad0f2014-05-21 14:04:53 -0700335 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200340 MUX_GUMSTIX();
Ash Charles7baad0f2014-05-21 14:04:53 -0700341 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200346 MUX_GUMSTIX();
Ash Charles7baad0f2014-05-21 14:04:53 -0700347 MUX_ARBOR43C();
348 setenv("defaultdisplay", "lcd43");
349 break;
Steve Sakoman0b880632010-09-20 08:05:14 -0700350 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 Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200354 MUX_GUMSTIX();
Steve Sakoman0b880632010-09-20 08:05:14 -0700355 MUX_USRP_E();
356 setenv("defaultdisplay", "dvi");
357 break;
358 case GUMSTIX_NO_EEPROM:
Stefan Herbrechtsmeiere2f29a12014-09-16 17:51:08 +0200359 case GUMSTIX_EMPTY_EEPROM:
360 puts("No or empty EEPROM on expansion board\n");
361 MUX_GUMSTIX();
Ash Charles1bfdde62014-06-10 12:02:36 -0700362 setenv("expansionname", "tobi");
Steve Sakoman0b880632010-09-20 08:05:14 -0700363 break;
364 default:
Ash Charles7baad0f2014-05-21 14:04:53 -0700365 printf("Unrecognized expansion board 0x%08x\n", expansion_id);
366 break;
Steve Sakoman0b880632010-09-20 08:05:14 -0700367 }
368
369 if (expansion_config.content == 1)
370 setenv(expansion_config.env_var, expansion_config.env_setting);
371
Dirk Behme12dbcf62009-03-12 19:30:50 +0100372 dieid_num_r();
373
Ash Charles1bfdde62014-06-10 12:02:36 -0700374 if (get_cpu_family() == CPU_OMAP34XX)
375 setenv("boardname", "overo");
376 else
377 setenv("boardname", "overo-storm");
378
Dirk Behme220faba2009-01-28 21:39:57 +0100379 return 0;
380}
381
Tom Rix558bb832009-04-01 22:02:20 -0500382/*
Dirk Behme220faba2009-01-28 21:39:57 +0100383 * 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 Rix558bb832009-04-01 22:02:20 -0500387 */
Dirk Behme220faba2009-01-28 21:39:57 +0100388void set_muxconf_regs(void)
389{
390 MUX_OVERO();
391}
Olof Johansson4963f922009-09-29 10:22:45 -0400392
Stefan Herbrechtsmeier59f72d22014-09-16 17:51:07 +0200393#if defined(CONFIG_CMD_NET) && !defined(CONFIG_SPL_BUILD)
394/* GPMC definitions for LAN9221 chips on Tobi expansion boards */
395static 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 Johansson4963f922009-09-29 10:22:45 -0400405/*
406 * Routine: setup_net_chip
407 * Description: Setting up the configuration GPMC registers specific to the
408 * Ethernet hardware.
409 */
410static void setup_net_chip(void)
411{
412 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
413
Olof Johansson4963f922009-09-29 10:22:45 -0400414 /* 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 Herbrechtsmeier59f72d22014-09-16 17:51:07 +0200421}
Olof Johansson4963f922009-09-29 10:22:45 -0400422
Stefan Herbrechtsmeier59f72d22014-09-16 17:51:07 +0200423/*
424 * Routine: reset_net_chip
425 * Description: Reset the Ethernet hardware.
426 */
427static void reset_net_chip(void)
428{
Olof Johansson4963f922009-09-29 10:22:45 -0400429 /* Make GPIO 64 as output pin and send a magic pulse through it */
Sanjeev Premi7b3dc822011-09-08 10:51:01 -0400430 if (!gpio_request(64, "")) {
431 gpio_direction_output(64, 0);
432 gpio_set_value(64, 1);
Olof Johansson4963f922009-09-29 10:22:45 -0400433 udelay(1);
Sanjeev Premi7b3dc822011-09-08 10:51:01 -0400434 gpio_set_value(64, 0);
Olof Johansson4963f922009-09-29 10:22:45 -0400435 udelay(1);
Sanjeev Premi7b3dc822011-09-08 10:51:01 -0400436 gpio_set_value(64, 1);
Olof Johansson4963f922009-09-29 10:22:45 -0400437 }
438}
Olof Johansson4963f922009-09-29 10:22:45 -0400439
440int board_eth_init(bd_t *bis)
441{
Stefan Herbrechtsmeier59f72d22014-09-16 17:51:07 +0200442 unsigned int expansion_id;
Olof Johansson4963f922009-09-29 10:22:45 -0400443 int rc = 0;
Stefan Herbrechtsmeier59f72d22014-09-16 17:51:07 +0200444
Olof Johansson4963f922009-09-29 10:22:45 -0400445#ifdef CONFIG_SMC911X
Stefan Herbrechtsmeier59f72d22014-09-16 17:51:07 +0200446 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 Johansson4963f922009-09-29 10:22:45 -0400470#endif
Stefan Herbrechtsmeier59f72d22014-09-16 17:51:07 +0200471
Olof Johansson4963f922009-09-29 10:22:45 -0400472 return rc;
473}
Stefan Herbrechtsmeier59f72d22014-09-16 17:51:07 +0200474#endif
Steve Sakomanb7d80522010-09-19 21:21:07 -0700475
Andreas Müller785f1f02012-01-04 15:26:25 +0000476#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Steve Sakomanb7d80522010-09-19 21:21:07 -0700477int board_mmc_init(bd_t *bis)
478{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000479 return omap_mmc_init(0, 0, 0, -1, -1);
Steve Sakomanb7d80522010-09-19 21:21:07 -0700480}
481#endif
Stefan Herbrechtsmeier0c87e682014-09-16 17:51:09 +0200482
483#if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
484static 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
491int 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
501int 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 */