blob: 3c60b06ae75e25b27b6c34df7073eac5e4bd6d85 [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 *
13 * See file CREDITS for list of people who contributed to this
14 * project.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 */
31#include <common.h>
Olof Johanssondf382622009-09-29 10:22:45 -040032#include <netdev.h>
Tom Rix2c155132009-06-28 12:52:30 -050033#include <twl4030.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010034#include <asm/io.h>
Steve Sakomancd7c5722010-09-19 21:21:07 -070035#include <asm/arch/mmc_host_def.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010036#include <asm/arch/mux.h>
Olof Johanssondf382622009-09-29 10:22:45 -040037#include <asm/arch/mem.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010038#include <asm/arch/sys_proto.h>
Philip Balister5213d242011-09-14 13:32:22 -040039#include <asm/arch/omap_gpmc.h>
Sanjeev Premi84c3b632011-09-08 10:51:01 -040040#include <asm/gpio.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010041#include <asm/mach-types.h>
42#include "overo.h"
43
John Rigby29565322010-12-20 18:27:51 -070044DECLARE_GLOBAL_DATA_PTR;
45
Steve Sakomand64b5b82010-09-20 08:05:14 -070046#define TWL4030_I2C_BUS 0
47#define EXPANSION_EEPROM_I2C_BUS 2
48#define EXPANSION_EEPROM_I2C_ADDRESS 0x51
49
50#define GUMSTIX_SUMMIT 0x01000200
51#define GUMSTIX_TOBI 0x02000200
52#define GUMSTIX_TOBI_DUO 0x03000200
53#define GUMSTIX_PALO35 0x04000200
54#define GUMSTIX_PALO43 0x05000200
55#define GUMSTIX_CHESTNUT43 0x06000200
56#define GUMSTIX_PINTO 0x07000200
57#define GUMSTIX_GALLOP43 0x08000200
58
59#define ETTUS_USRP_E 0x01000300
60
61#define GUMSTIX_NO_EEPROM 0xffffffff
62
63static struct {
64 unsigned int device_vendor;
65 unsigned char revision;
66 unsigned char content;
67 char fab_revision[8];
68 char env_var[16];
69 char env_setting[64];
70} expansion_config;
71
Olof Johanssondf382622009-09-29 10:22:45 -040072#if defined(CONFIG_CMD_NET)
73static void setup_net_chip(void);
74#endif
75
Steve Sakomanba9a11e2010-08-12 21:07:02 -070076/* GPMC definitions for LAN9221 chips on Tobi expansion boards */
77static const u32 gpmc_lan_config[] = {
78 NET_LAN9221_GPMC_CONFIG1,
79 NET_LAN9221_GPMC_CONFIG2,
80 NET_LAN9221_GPMC_CONFIG3,
81 NET_LAN9221_GPMC_CONFIG4,
82 NET_LAN9221_GPMC_CONFIG5,
83 NET_LAN9221_GPMC_CONFIG6,
84 /*CONFIG7- computed as params */
85};
86
Tom Rix58911512009-04-01 22:02:20 -050087/*
Dirk Behme9d0fc812009-01-28 21:39:57 +010088 * Routine: board_init
89 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050090 */
Dirk Behme9d0fc812009-01-28 21:39:57 +010091int board_init(void)
92{
Dirk Behme9d0fc812009-01-28 21:39:57 +010093 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
94 /* board id for Linux */
95 gd->bd->bi_arch_number = MACH_TYPE_OVERO;
96 /* boot param addr */
97 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
98
99 return 0;
100}
101
Tom Rix58911512009-04-01 22:02:20 -0500102/*
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700103 * Routine: get_board_revision
104 * Description: Returns the board revision
105 */
106int get_board_revision(void)
107{
108 int revision;
109
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400110 if (!gpio_request(112, "") &&
111 !gpio_request(113, "") &&
112 !gpio_request(115, "")) {
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700113
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400114 gpio_direction_input(112);
115 gpio_direction_input(113);
116 gpio_direction_input(115);
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700117
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400118 revision = gpio_get_value(115) << 2 |
119 gpio_get_value(113) << 1 |
120 gpio_get_value(112);
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700121 } else {
122 printf("Error: unable to acquire board revision GPIOs\n");
123 revision = -1;
124 }
125
126 return revision;
127}
128
129/*
Steve Sakomana06e1622010-08-24 10:37:29 -0700130 * Routine: get_sdio2_config
131 * Description: Return information about the wifi module connection
132 * Returns 0 if the module connects though a level translator
133 * Returns 1 if the module connects directly
134 */
135int get_sdio2_config(void)
136{
137 int sdio_direct;
138
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400139 if (!gpio_request(130, "") && !gpio_request(139, "")) {
Steve Sakomana06e1622010-08-24 10:37:29 -0700140
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400141 gpio_direction_output(130, 0);
142 gpio_direction_input(139);
Steve Sakomana06e1622010-08-24 10:37:29 -0700143
144 sdio_direct = 1;
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400145 gpio_set_value(130, 0);
146 if (gpio_get_value(139) == 0) {
147 gpio_set_value(130, 1);
148 if (gpio_get_value(139) == 1)
Steve Sakomana06e1622010-08-24 10:37:29 -0700149 sdio_direct = 0;
150 }
151
Joe Hershbergerb5db0a02011-10-12 10:31:44 +0000152 gpio_direction_input(130);
Steve Sakomana06e1622010-08-24 10:37:29 -0700153 } else {
154 printf("Error: unable to acquire sdio2 clk GPIOs\n");
155 sdio_direct = -1;
156 }
157
158 return sdio_direct;
159}
160
161/*
Steve Sakomand64b5b82010-09-20 08:05:14 -0700162 * Routine: get_expansion_id
163 * Description: This function checks for expansion board by checking I2C
164 * bus 2 for the availability of an AT24C01B serial EEPROM.
165 * returns the device_vendor field from the EEPROM
166 */
167unsigned int get_expansion_id(void)
168{
169 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
170
171 /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */
172 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
173 i2c_set_bus_num(TWL4030_I2C_BUS);
174 return GUMSTIX_NO_EEPROM;
175 }
176
177 /* read configuration data */
178 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
179 sizeof(expansion_config));
180
181 i2c_set_bus_num(TWL4030_I2C_BUS);
182
183 return expansion_config.device_vendor;
184}
185
186/*
Dirk Behme9d0fc812009-01-28 21:39:57 +0100187 * Routine: misc_init_r
188 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -0500189 */
Dirk Behme9d0fc812009-01-28 21:39:57 +0100190int misc_init_r(void)
191{
Tom Rix2c155132009-06-28 12:52:30 -0500192 twl4030_power_init();
Grazvydas Ignotasead39d72009-12-10 17:10:21 +0200193 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behme9d0fc812009-01-28 21:39:57 +0100194
Olof Johanssondf382622009-09-29 10:22:45 -0400195#if defined(CONFIG_CMD_NET)
196 setup_net_chip();
197#endif
198
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700199 printf("Board revision: %d\n", get_board_revision());
Steve Sakomana06e1622010-08-24 10:37:29 -0700200
201 switch (get_sdio2_config()) {
202 case 0:
203 printf("Tranceiver detected on mmc2\n");
204 MUX_OVERO_SDIO2_TRANSCEIVER();
205 break;
206 case 1:
207 printf("Direct connection on mmc2\n");
208 MUX_OVERO_SDIO2_DIRECT();
209 break;
210 default:
211 printf("Unable to detect mmc2 connection type\n");
212 }
213
Steve Sakomand64b5b82010-09-20 08:05:14 -0700214 switch (get_expansion_id()) {
215 case GUMSTIX_SUMMIT:
216 printf("Recognized Summit expansion board (rev %d %s)\n",
217 expansion_config.revision,
218 expansion_config.fab_revision);
219 setenv("defaultdisplay", "dvi");
220 break;
221 case GUMSTIX_TOBI:
222 printf("Recognized Tobi expansion board (rev %d %s)\n",
223 expansion_config.revision,
224 expansion_config.fab_revision);
225 setenv("defaultdisplay", "dvi");
226 break;
227 case GUMSTIX_TOBI_DUO:
228 printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
229 expansion_config.revision,
230 expansion_config.fab_revision);
Philip Balister8f7109b2011-10-11 11:23:22 +0000231 /* second lan chip */
232 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4],
233 0x2B000000, GPMC_SIZE_16M);
Steve Sakomand64b5b82010-09-20 08:05:14 -0700234 break;
235 case GUMSTIX_PALO35:
236 printf("Recognized Palo35 expansion board (rev %d %s)\n",
237 expansion_config.revision,
238 expansion_config.fab_revision);
239 setenv("defaultdisplay", "lcd35");
240 break;
241 case GUMSTIX_PALO43:
242 printf("Recognized Palo43 expansion board (rev %d %s)\n",
243 expansion_config.revision,
244 expansion_config.fab_revision);
245 setenv("defaultdisplay", "lcd43");
246 break;
247 case GUMSTIX_CHESTNUT43:
248 printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
249 expansion_config.revision,
250 expansion_config.fab_revision);
251 setenv("defaultdisplay", "lcd43");
252 break;
253 case GUMSTIX_PINTO:
254 printf("Recognized Pinto expansion board (rev %d %s)\n",
255 expansion_config.revision,
256 expansion_config.fab_revision);
257 break;
258 case GUMSTIX_GALLOP43:
259 printf("Recognized Gallop43 expansion board (rev %d %s)\n",
260 expansion_config.revision,
261 expansion_config.fab_revision);
262 setenv("defaultdisplay", "lcd43");
263 break;
264 case ETTUS_USRP_E:
265 printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
266 expansion_config.revision,
267 expansion_config.fab_revision);
268 MUX_USRP_E();
269 setenv("defaultdisplay", "dvi");
270 break;
271 case GUMSTIX_NO_EEPROM:
272 printf("No EEPROM on expansion board\n");
273 break;
274 default:
275 printf("Unrecognized expansion board\n");
276 }
277
278 if (expansion_config.content == 1)
279 setenv(expansion_config.env_var, expansion_config.env_setting);
280
Dirk Behmee6a6a702009-03-12 19:30:50 +0100281 dieid_num_r();
282
Dirk Behme9d0fc812009-01-28 21:39:57 +0100283 return 0;
284}
285
Tom Rix58911512009-04-01 22:02:20 -0500286/*
Dirk Behme9d0fc812009-01-28 21:39:57 +0100287 * Routine: set_muxconf_regs
288 * Description: Setting up the configuration Mux registers specific to the
289 * hardware. Many pins need to be moved from protect to primary
290 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500291 */
Dirk Behme9d0fc812009-01-28 21:39:57 +0100292void set_muxconf_regs(void)
293{
294 MUX_OVERO();
295}
Olof Johanssondf382622009-09-29 10:22:45 -0400296
297#if defined(CONFIG_CMD_NET)
298/*
299 * Routine: setup_net_chip
300 * Description: Setting up the configuration GPMC registers specific to the
301 * Ethernet hardware.
302 */
303static void setup_net_chip(void)
304{
305 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
306
Steve Sakomanba9a11e2010-08-12 21:07:02 -0700307 /* first lan chip */
308 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
309 GPMC_SIZE_16M);
310
Olof Johanssondf382622009-09-29 10:22:45 -0400311 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
312 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
313 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
314 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
315 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
316 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
317 &ctrl_base->gpmc_nadv_ale);
318
319 /* Make GPIO 64 as output pin and send a magic pulse through it */
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400320 if (!gpio_request(64, "")) {
321 gpio_direction_output(64, 0);
322 gpio_set_value(64, 1);
Olof Johanssondf382622009-09-29 10:22:45 -0400323 udelay(1);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400324 gpio_set_value(64, 0);
Olof Johanssondf382622009-09-29 10:22:45 -0400325 udelay(1);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400326 gpio_set_value(64, 1);
Olof Johanssondf382622009-09-29 10:22:45 -0400327 }
328}
329#endif
330
331int board_eth_init(bd_t *bis)
332{
333 int rc = 0;
334#ifdef CONFIG_SMC911X
335 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
336#endif
337 return rc;
338}
Steve Sakomancd7c5722010-09-19 21:21:07 -0700339
340#ifdef CONFIG_GENERIC_MMC
341int board_mmc_init(bd_t *bis)
342{
343 omap_mmc_init(0);
344 return 0;
345}
346#endif