blob: b64cfaa539b8250cf16108992a6cef9d03e8c3f9 [file] [log] [blame]
Dirk Behme9d0fc812009-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 Denk1a459662013-07-08 09:37:19 +020013 * SPDX-License-Identifier: GPL-2.0+
Dirk Behme9d0fc812009-01-28 21:39:57 +010014 */
15#include <common.h>
Simon Glassb3f4ca12014-10-22 21:37:15 -060016#include <dm.h>
17#include <ns16550.h>
Olof Johanssondf382622009-09-29 10:22:45 -040018#include <netdev.h>
Tom Rix2c155132009-06-28 12:52:30 -050019#include <twl4030.h>
Andreas Müller137703b2012-01-04 15:26:25 +000020#include <linux/mtd/nand.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010021#include <asm/io.h>
Steve Sakomancd7c5722010-09-19 21:21:07 -070022#include <asm/arch/mmc_host_def.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010023#include <asm/arch/mux.h>
Olof Johanssondf382622009-09-29 10:22:45 -040024#include <asm/arch/mem.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010025#include <asm/arch/sys_proto.h>
Sanjeev Premi84c3b632011-09-08 10:51:01 -040026#include <asm/gpio.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010027#include <asm/mach-types.h>
28#include "overo.h"
29
Stefan Herbrechtsmeierf5c30c12014-09-16 17:51:09 +020030#ifdef CONFIG_USB_EHCI
31#include <usb.h>
32#include <asm/ehci-omap.h>
33#endif
34
John Rigby29565322010-12-20 18:27:51 -070035DECLARE_GLOBAL_DATA_PTR;
36
Steve Sakomand64b5b82010-09-20 08:05:14 -070037#define TWL4030_I2C_BUS 0
38#define EXPANSION_EEPROM_I2C_BUS 2
39#define EXPANSION_EEPROM_I2C_ADDRESS 0x51
40
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +020041#define GUMSTIX_EMPTY_EEPROM 0x0
42
Steve Sakomand64b5b82010-09-20 08:05:14 -070043#define GUMSTIX_SUMMIT 0x01000200
44#define GUMSTIX_TOBI 0x02000200
45#define GUMSTIX_TOBI_DUO 0x03000200
46#define GUMSTIX_PALO35 0x04000200
47#define GUMSTIX_PALO43 0x05000200
48#define GUMSTIX_CHESTNUT43 0x06000200
49#define GUMSTIX_PINTO 0x07000200
50#define GUMSTIX_GALLOP43 0x08000200
Ash Charlesea5940e2014-05-21 14:04:53 -070051#define GUMSTIX_ALTO35 0x09000200
52#define GUMSTIX_STAGECOACH 0x0A000200
53#define GUMSTIX_THUMBO 0x0B000200
54#define GUMSTIX_TURTLECORE 0x0C000200
55#define GUMSTIX_ARBOR43C 0x0D000200
Steve Sakomand64b5b82010-09-20 08:05:14 -070056
57#define ETTUS_USRP_E 0x01000300
58
59#define GUMSTIX_NO_EEPROM 0xffffffff
60
61static struct {
62 unsigned int device_vendor;
63 unsigned char revision;
64 unsigned char content;
65 char fab_revision[8];
66 char env_var[16];
67 char env_setting[64];
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +020068} expansion_config = {0x0};
Steve Sakomanba9a11e2010-08-12 21:07:02 -070069
Simon Glassb3f4ca12014-10-22 21:37:15 -060070static const struct ns16550_platdata overo_serial = {
71 OMAP34XX_UART3,
72 2,
73 V_NS16550_CLK
74};
75
76U_BOOT_DEVICE(overo_uart) = {
77 "serial_omap",
78 &overo_serial
79};
80
Tom Rix58911512009-04-01 22:02:20 -050081/*
Dirk Behme9d0fc812009-01-28 21:39:57 +010082 * Routine: board_init
83 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050084 */
Dirk Behme9d0fc812009-01-28 21:39:57 +010085int board_init(void)
86{
Dirk Behme9d0fc812009-01-28 21:39:57 +010087 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
88 /* board id for Linux */
89 gd->bd->bi_arch_number = MACH_TYPE_OVERO;
90 /* boot param addr */
91 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
92
93 return 0;
94}
95
Tom Rix58911512009-04-01 22:02:20 -050096/*
Steve Sakomanc2d5b342010-08-12 15:13:02 -070097 * Routine: get_board_revision
98 * Description: Returns the board revision
99 */
100int get_board_revision(void)
101{
102 int revision;
103
Heiko Schocher6789e842013-10-22 11:03:18 +0200104#ifdef CONFIG_SYS_I2C_OMAP34XX
Andreas Müller137703b2012-01-04 15:26:25 +0000105 unsigned char data;
106
107 /* board revisions <= R2410 connect 4030 irq_1 to gpio112 */
108 /* these boards should return a revision number of 0 */
109 /* the code below forces a 4030 RTC irq to ensure that gpio112 is low */
110 i2c_set_bus_num(TWL4030_I2C_BUS);
111 data = 0x01;
112 i2c_write(0x4B, 0x29, 1, &data, 1);
113 data = 0x0c;
114 i2c_write(0x4B, 0x2b, 1, &data, 1);
115 i2c_read(0x4B, 0x2a, 1, &data, 1);
116#endif
117
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400118 if (!gpio_request(112, "") &&
119 !gpio_request(113, "") &&
120 !gpio_request(115, "")) {
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700121
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400122 gpio_direction_input(112);
123 gpio_direction_input(113);
124 gpio_direction_input(115);
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700125
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400126 revision = gpio_get_value(115) << 2 |
127 gpio_get_value(113) << 1 |
128 gpio_get_value(112);
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700129 } else {
Andreas Müllerbae485d2012-01-04 15:26:20 +0000130 puts("Error: unable to acquire board revision GPIOs\n");
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700131 revision = -1;
132 }
133
134 return revision;
135}
136
Andreas Müller137703b2012-01-04 15:26:25 +0000137#ifdef CONFIG_SPL_BUILD
138/*
139 * Routine: get_board_mem_timings
140 * Description: If we use SPL then there is no x-loader nor config header
141 * so we have to setup the DDR timings ourself on both banks.
142 */
Peter Barada8c4445d2012-11-13 07:40:28 +0000143void get_board_mem_timings(struct board_sdrc_timings *timings)
Andreas Müller137703b2012-01-04 15:26:25 +0000144{
Peter Barada8c4445d2012-11-13 07:40:28 +0000145 timings->mr = MICRON_V_MR_165;
Andreas Müller137703b2012-01-04 15:26:25 +0000146 switch (get_board_revision()) {
147 case REVISION_0: /* Micron 1286MB/256MB, 1/2 banks of 128MB */
Peter Barada8c4445d2012-11-13 07:40:28 +0000148 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
149 timings->ctrla = MICRON_V_ACTIMA_165;
150 timings->ctrlb = MICRON_V_ACTIMB_165;
151 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Andreas Müller137703b2012-01-04 15:26:25 +0000152 break;
153 case REVISION_1: /* Micron 256MB/512MB, 1/2 banks of 256MB */
Ash Charlesbe4cc452014-05-21 14:04:52 -0700154 case REVISION_4:
Ash Charles802b3c72013-07-24 12:22:35 -0700155 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
156 timings->ctrla = MICRON_V_ACTIMA_200;
157 timings->ctrlb = MICRON_V_ACTIMB_200;
158 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
Andreas Müller137703b2012-01-04 15:26:25 +0000159 break;
160 case REVISION_2: /* Hynix 256MB/512MB, 1/2 banks of 256MB */
Ash Charles802b3c72013-07-24 12:22:35 -0700161 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
162 timings->ctrla = HYNIX_V_ACTIMA_200;
163 timings->ctrlb = HYNIX_V_ACTIMB_200;
164 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
Andreas Müller137703b2012-01-04 15:26:25 +0000165 break;
Steve Sakoman49720a42013-07-24 12:22:34 -0700166 case REVISION_3: /* Micron 512MB/1024MB, 1/2 banks of 512MB */
167 timings->mcfg = MCFG(512 << 20, 15);
168 timings->ctrla = MICRON_V_ACTIMA_200;
169 timings->ctrlb = MICRON_V_ACTIMB_200;
170 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
171 break;
Andreas Müller137703b2012-01-04 15:26:25 +0000172 default:
Peter Barada8c4445d2012-11-13 07:40:28 +0000173 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
174 timings->ctrla = MICRON_V_ACTIMA_165;
175 timings->ctrlb = MICRON_V_ACTIMB_165;
176 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Andreas Müller137703b2012-01-04 15:26:25 +0000177 }
178}
179#endif
180
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700181/*
Steve Sakomana06e1622010-08-24 10:37:29 -0700182 * Routine: get_sdio2_config
183 * Description: Return information about the wifi module connection
184 * Returns 0 if the module connects though a level translator
185 * Returns 1 if the module connects directly
186 */
187int get_sdio2_config(void)
188{
189 int sdio_direct;
190
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400191 if (!gpio_request(130, "") && !gpio_request(139, "")) {
Steve Sakomana06e1622010-08-24 10:37:29 -0700192
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400193 gpio_direction_output(130, 0);
194 gpio_direction_input(139);
Steve Sakomana06e1622010-08-24 10:37:29 -0700195
196 sdio_direct = 1;
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400197 gpio_set_value(130, 0);
198 if (gpio_get_value(139) == 0) {
199 gpio_set_value(130, 1);
200 if (gpio_get_value(139) == 1)
Steve Sakomana06e1622010-08-24 10:37:29 -0700201 sdio_direct = 0;
202 }
203
Joe Hershbergerb5db0a02011-10-12 10:31:44 +0000204 gpio_direction_input(130);
Steve Sakomana06e1622010-08-24 10:37:29 -0700205 } else {
Andreas Müllerbae485d2012-01-04 15:26:20 +0000206 puts("Error: unable to acquire sdio2 clk GPIOs\n");
Steve Sakomana06e1622010-08-24 10:37:29 -0700207 sdio_direct = -1;
208 }
209
210 return sdio_direct;
211}
212
213/*
Steve Sakomand64b5b82010-09-20 08:05:14 -0700214 * Routine: get_expansion_id
215 * Description: This function checks for expansion board by checking I2C
216 * bus 2 for the availability of an AT24C01B serial EEPROM.
217 * returns the device_vendor field from the EEPROM
218 */
219unsigned int get_expansion_id(void)
220{
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200221 if (expansion_config.device_vendor != 0x0)
222 return expansion_config.device_vendor;
223
Steve Sakomand64b5b82010-09-20 08:05:14 -0700224 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
225
226 /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */
227 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
228 i2c_set_bus_num(TWL4030_I2C_BUS);
229 return GUMSTIX_NO_EEPROM;
230 }
231
232 /* read configuration data */
233 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
234 sizeof(expansion_config));
235
236 i2c_set_bus_num(TWL4030_I2C_BUS);
237
238 return expansion_config.device_vendor;
239}
240
241/*
Dirk Behme9d0fc812009-01-28 21:39:57 +0100242 * Routine: misc_init_r
243 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -0500244 */
Dirk Behme9d0fc812009-01-28 21:39:57 +0100245int misc_init_r(void)
246{
Ash Charlesea5940e2014-05-21 14:04:53 -0700247 unsigned int expansion_id;
248
Tom Rix2c155132009-06-28 12:52:30 -0500249 twl4030_power_init();
Grazvydas Ignotasead39d72009-12-10 17:10:21 +0200250 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behme9d0fc812009-01-28 21:39:57 +0100251
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700252 printf("Board revision: %d\n", get_board_revision());
Steve Sakomana06e1622010-08-24 10:37:29 -0700253
254 switch (get_sdio2_config()) {
255 case 0:
Andreas Müllerbae485d2012-01-04 15:26:20 +0000256 puts("Tranceiver detected on mmc2\n");
Steve Sakomana06e1622010-08-24 10:37:29 -0700257 MUX_OVERO_SDIO2_TRANSCEIVER();
258 break;
259 case 1:
Andreas Müllerbae485d2012-01-04 15:26:20 +0000260 puts("Direct connection on mmc2\n");
Steve Sakomana06e1622010-08-24 10:37:29 -0700261 MUX_OVERO_SDIO2_DIRECT();
262 break;
263 default:
Andreas Müllerbae485d2012-01-04 15:26:20 +0000264 puts("Unable to detect mmc2 connection type\n");
Steve Sakomana06e1622010-08-24 10:37:29 -0700265 }
266
Ash Charlesea5940e2014-05-21 14:04:53 -0700267 expansion_id = get_expansion_id();
268 switch (expansion_id) {
Steve Sakomand64b5b82010-09-20 08:05:14 -0700269 case GUMSTIX_SUMMIT:
270 printf("Recognized Summit expansion board (rev %d %s)\n",
271 expansion_config.revision,
272 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200273 MUX_GUMSTIX();
Steve Sakomand64b5b82010-09-20 08:05:14 -0700274 setenv("defaultdisplay", "dvi");
Ash Charles12cc5432014-06-10 12:02:36 -0700275 setenv("expansionname", "summit");
Steve Sakomand64b5b82010-09-20 08:05:14 -0700276 break;
277 case GUMSTIX_TOBI:
278 printf("Recognized Tobi expansion board (rev %d %s)\n",
279 expansion_config.revision,
280 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200281 MUX_GUMSTIX();
Steve Sakomand64b5b82010-09-20 08:05:14 -0700282 setenv("defaultdisplay", "dvi");
Ash Charles12cc5432014-06-10 12:02:36 -0700283 setenv("expansionname", "tobi");
Steve Sakomand64b5b82010-09-20 08:05:14 -0700284 break;
285 case GUMSTIX_TOBI_DUO:
286 printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
287 expansion_config.revision,
288 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200289 MUX_GUMSTIX();
Arun Bharadwaj72c7be92015-04-28 16:17:51 -0700290 setenv("expansionname", "tobiduo");
Steve Sakomand64b5b82010-09-20 08:05:14 -0700291 break;
292 case GUMSTIX_PALO35:
293 printf("Recognized Palo35 expansion board (rev %d %s)\n",
294 expansion_config.revision,
295 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200296 MUX_GUMSTIX();
Steve Sakomand64b5b82010-09-20 08:05:14 -0700297 setenv("defaultdisplay", "lcd35");
298 break;
299 case GUMSTIX_PALO43:
300 printf("Recognized Palo43 expansion board (rev %d %s)\n",
301 expansion_config.revision,
302 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200303 MUX_GUMSTIX();
Steve Sakomand64b5b82010-09-20 08:05:14 -0700304 setenv("defaultdisplay", "lcd43");
Ash Charles12cc5432014-06-10 12:02:36 -0700305 setenv("expansionname", "palo43");
Steve Sakomand64b5b82010-09-20 08:05:14 -0700306 break;
307 case GUMSTIX_CHESTNUT43:
308 printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
309 expansion_config.revision,
310 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200311 MUX_GUMSTIX();
Steve Sakomand64b5b82010-09-20 08:05:14 -0700312 setenv("defaultdisplay", "lcd43");
Ash Charles12cc5432014-06-10 12:02:36 -0700313 setenv("expansionname", "chestnut43");
Steve Sakomand64b5b82010-09-20 08:05:14 -0700314 break;
315 case GUMSTIX_PINTO:
316 printf("Recognized Pinto expansion board (rev %d %s)\n",
317 expansion_config.revision,
318 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200319 MUX_GUMSTIX();
Steve Sakomand64b5b82010-09-20 08:05:14 -0700320 break;
321 case GUMSTIX_GALLOP43:
322 printf("Recognized Gallop43 expansion board (rev %d %s)\n",
323 expansion_config.revision,
324 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200325 MUX_GUMSTIX();
Steve Sakomand64b5b82010-09-20 08:05:14 -0700326 setenv("defaultdisplay", "lcd43");
Ash Charles12cc5432014-06-10 12:02:36 -0700327 setenv("expansionname", "gallop43");
Steve Sakomand64b5b82010-09-20 08:05:14 -0700328 break;
Ash Charlesea5940e2014-05-21 14:04:53 -0700329 case GUMSTIX_ALTO35:
330 printf("Recognized Alto35 expansion board (rev %d %s)\n",
331 expansion_config.revision,
332 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200333 MUX_GUMSTIX();
Ash Charlesea5940e2014-05-21 14:04:53 -0700334 MUX_ALTO35();
335 setenv("defaultdisplay", "lcd35");
Ash Charles12cc5432014-06-10 12:02:36 -0700336 setenv("expansionname", "alto35");
Ash Charlesea5940e2014-05-21 14:04:53 -0700337 break;
338 case GUMSTIX_STAGECOACH:
339 printf("Recognized Stagecoach expansion board (rev %d %s)\n",
340 expansion_config.revision,
341 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200342 MUX_GUMSTIX();
Ash Charlesea5940e2014-05-21 14:04:53 -0700343 break;
344 case GUMSTIX_THUMBO:
345 printf("Recognized Thumbo expansion board (rev %d %s)\n",
346 expansion_config.revision,
347 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200348 MUX_GUMSTIX();
Ash Charlesea5940e2014-05-21 14:04:53 -0700349 break;
350 case GUMSTIX_TURTLECORE:
351 printf("Recognized Turtlecore expansion board (rev %d %s)\n",
352 expansion_config.revision,
353 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200354 MUX_GUMSTIX();
Ash Charlesea5940e2014-05-21 14:04:53 -0700355 break;
356 case GUMSTIX_ARBOR43C:
357 printf("Recognized Arbor43C expansion board (rev %d %s)\n",
358 expansion_config.revision,
359 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200360 MUX_GUMSTIX();
Ash Charlesea5940e2014-05-21 14:04:53 -0700361 MUX_ARBOR43C();
362 setenv("defaultdisplay", "lcd43");
Ash Charlesda9ed5a2015-04-28 16:17:50 -0700363 setenv("expansionname", "arbor43c");
Ash Charlesea5940e2014-05-21 14:04:53 -0700364 break;
Steve Sakomand64b5b82010-09-20 08:05:14 -0700365 case ETTUS_USRP_E:
366 printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
367 expansion_config.revision,
368 expansion_config.fab_revision);
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200369 MUX_GUMSTIX();
Steve Sakomand64b5b82010-09-20 08:05:14 -0700370 MUX_USRP_E();
371 setenv("defaultdisplay", "dvi");
372 break;
373 case GUMSTIX_NO_EEPROM:
Stefan Herbrechtsmeier4ed914a2014-09-16 17:51:08 +0200374 case GUMSTIX_EMPTY_EEPROM:
375 puts("No or empty EEPROM on expansion board\n");
376 MUX_GUMSTIX();
Ash Charles12cc5432014-06-10 12:02:36 -0700377 setenv("expansionname", "tobi");
Steve Sakomand64b5b82010-09-20 08:05:14 -0700378 break;
379 default:
Ash Charlesea5940e2014-05-21 14:04:53 -0700380 printf("Unrecognized expansion board 0x%08x\n", expansion_id);
381 break;
Steve Sakomand64b5b82010-09-20 08:05:14 -0700382 }
383
384 if (expansion_config.content == 1)
385 setenv(expansion_config.env_var, expansion_config.env_setting);
386
Dirk Behmee6a6a702009-03-12 19:30:50 +0100387 dieid_num_r();
388
Ash Charles12cc5432014-06-10 12:02:36 -0700389 if (get_cpu_family() == CPU_OMAP34XX)
390 setenv("boardname", "overo");
391 else
392 setenv("boardname", "overo-storm");
393
Dirk Behme9d0fc812009-01-28 21:39:57 +0100394 return 0;
395}
396
Tom Rix58911512009-04-01 22:02:20 -0500397/*
Dirk Behme9d0fc812009-01-28 21:39:57 +0100398 * Routine: set_muxconf_regs
399 * Description: Setting up the configuration Mux registers specific to the
400 * hardware. Many pins need to be moved from protect to primary
401 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500402 */
Dirk Behme9d0fc812009-01-28 21:39:57 +0100403void set_muxconf_regs(void)
404{
405 MUX_OVERO();
406}
Olof Johanssondf382622009-09-29 10:22:45 -0400407
Stefan Herbrechtsmeier113429a2014-09-16 17:51:07 +0200408#if defined(CONFIG_CMD_NET) && !defined(CONFIG_SPL_BUILD)
409/* GPMC definitions for LAN9221 chips on Tobi expansion boards */
410static const u32 gpmc_lan_config[] = {
411 NET_LAN9221_GPMC_CONFIG1,
412 NET_LAN9221_GPMC_CONFIG2,
413 NET_LAN9221_GPMC_CONFIG3,
414 NET_LAN9221_GPMC_CONFIG4,
415 NET_LAN9221_GPMC_CONFIG5,
416 NET_LAN9221_GPMC_CONFIG6,
417 /*CONFIG7- computed as params */
418};
419
Olof Johanssondf382622009-09-29 10:22:45 -0400420/*
421 * Routine: setup_net_chip
422 * Description: Setting up the configuration GPMC registers specific to the
423 * Ethernet hardware.
424 */
425static void setup_net_chip(void)
426{
427 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
428
Olof Johanssondf382622009-09-29 10:22:45 -0400429 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
430 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
431 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
432 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
433 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
434 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
435 &ctrl_base->gpmc_nadv_ale);
Stefan Herbrechtsmeier113429a2014-09-16 17:51:07 +0200436}
Olof Johanssondf382622009-09-29 10:22:45 -0400437
Stefan Herbrechtsmeier113429a2014-09-16 17:51:07 +0200438/*
439 * Routine: reset_net_chip
440 * Description: Reset the Ethernet hardware.
441 */
442static void reset_net_chip(void)
443{
Olof Johanssondf382622009-09-29 10:22:45 -0400444 /* Make GPIO 64 as output pin and send a magic pulse through it */
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400445 if (!gpio_request(64, "")) {
446 gpio_direction_output(64, 0);
447 gpio_set_value(64, 1);
Olof Johanssondf382622009-09-29 10:22:45 -0400448 udelay(1);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400449 gpio_set_value(64, 0);
Olof Johanssondf382622009-09-29 10:22:45 -0400450 udelay(1);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400451 gpio_set_value(64, 1);
Olof Johanssondf382622009-09-29 10:22:45 -0400452 }
453}
Olof Johanssondf382622009-09-29 10:22:45 -0400454
455int board_eth_init(bd_t *bis)
456{
Stefan Herbrechtsmeier113429a2014-09-16 17:51:07 +0200457 unsigned int expansion_id;
Olof Johanssondf382622009-09-29 10:22:45 -0400458 int rc = 0;
Stefan Herbrechtsmeier113429a2014-09-16 17:51:07 +0200459
Olof Johanssondf382622009-09-29 10:22:45 -0400460#ifdef CONFIG_SMC911X
Stefan Herbrechtsmeier113429a2014-09-16 17:51:07 +0200461 expansion_id = get_expansion_id();
462 switch (expansion_id) {
463 case GUMSTIX_TOBI_DUO:
464 /* second lan chip */
465 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4],
466 0x2B000000, GPMC_SIZE_16M);
467 /* no break */
468 case GUMSTIX_TOBI:
469 case GUMSTIX_CHESTNUT43:
470 case GUMSTIX_STAGECOACH:
471 case GUMSTIX_NO_EEPROM:
472 case GUMSTIX_EMPTY_EEPROM:
473 /* first lan chip */
474 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
475 0x2C000000, GPMC_SIZE_16M);
476
477 setup_net_chip();
478 reset_net_chip();
479
480 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
481 break;
482 default:
483 break;
484 }
Olof Johanssondf382622009-09-29 10:22:45 -0400485#endif
Stefan Herbrechtsmeier113429a2014-09-16 17:51:07 +0200486
Olof Johanssondf382622009-09-29 10:22:45 -0400487 return rc;
488}
Stefan Herbrechtsmeier113429a2014-09-16 17:51:07 +0200489#endif
Steve Sakomancd7c5722010-09-19 21:21:07 -0700490
Andreas Müller137703b2012-01-04 15:26:25 +0000491#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Steve Sakomancd7c5722010-09-19 21:21:07 -0700492int board_mmc_init(bd_t *bis)
493{
Nikita Kiryanove3913f52012-12-03 02:19:47 +0000494 return omap_mmc_init(0, 0, 0, -1, -1);
Steve Sakomancd7c5722010-09-19 21:21:07 -0700495}
496#endif
Stefan Herbrechtsmeierf5c30c12014-09-16 17:51:09 +0200497
Paul Kocialkowskiaac54502014-11-08 20:55:47 +0100498#if defined(CONFIG_GENERIC_MMC)
499void board_mmc_power_init(void)
500{
501 twl4030_power_mmc_init(0);
502}
503#endif
504
Stefan Herbrechtsmeierf5c30c12014-09-16 17:51:09 +0200505#if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
506static struct omap_usbhs_board_data usbhs_bdata = {
507 .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
508 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
509 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
510};
511
512#define GUMSTIX_GPIO_USBH_CPEN 168
513int ehci_hcd_init(int index, enum usb_init_type init,
514 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
515{
516 /* Enable USB power */
517 if (!gpio_request(GUMSTIX_GPIO_USBH_CPEN, "usbh_cpen"))
518 gpio_direction_output(GUMSTIX_GPIO_USBH_CPEN, 1);
519
520 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
521}
522
523int ehci_hcd_stop(void)
524{
525 /* Disable USB power */
526 gpio_set_value(GUMSTIX_GPIO_USBH_CPEN, 0);
527 gpio_free(GUMSTIX_GPIO_USBH_CPEN);
528
529 return omap_ehci_hcd_stop();
530}
531
532#endif /* CONFIG_USB_EHCI */