]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/overo/overo.c
Merge branch 'master' of git://git.denx.de/u-boot-imx
[people/ms/u-boot.git] / board / overo / overo.c
CommitLineData
9d0fc811
DB
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 *
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>
df382626 32#include <netdev.h>
2c155130 33#include <twl4030.h>
9d0fc811 34#include <asm/io.h>
cd7c5726 35#include <asm/arch/mmc_host_def.h>
9d0fc811 36#include <asm/arch/mux.h>
df382626 37#include <asm/arch/mem.h>
9d0fc811 38#include <asm/arch/sys_proto.h>
df382626 39#include <asm/arch/gpio.h>
9d0fc811
DB
40#include <asm/mach-types.h>
41#include "overo.h"
42
d64b5b89
SS
43#define TWL4030_I2C_BUS 0
44#define EXPANSION_EEPROM_I2C_BUS 2
45#define EXPANSION_EEPROM_I2C_ADDRESS 0x51
46
47#define GUMSTIX_SUMMIT 0x01000200
48#define GUMSTIX_TOBI 0x02000200
49#define GUMSTIX_TOBI_DUO 0x03000200
50#define GUMSTIX_PALO35 0x04000200
51#define GUMSTIX_PALO43 0x05000200
52#define GUMSTIX_CHESTNUT43 0x06000200
53#define GUMSTIX_PINTO 0x07000200
54#define GUMSTIX_GALLOP43 0x08000200
55
56#define ETTUS_USRP_E 0x01000300
57
58#define GUMSTIX_NO_EEPROM 0xffffffff
59
60static 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];
67} expansion_config;
68
df382626
OJ
69#if defined(CONFIG_CMD_NET)
70static void setup_net_chip(void);
71#endif
72
ba9a11e4
SS
73/* GPMC definitions for LAN9221 chips on Tobi expansion boards */
74static const u32 gpmc_lan_config[] = {
75 NET_LAN9221_GPMC_CONFIG1,
76 NET_LAN9221_GPMC_CONFIG2,
77 NET_LAN9221_GPMC_CONFIG3,
78 NET_LAN9221_GPMC_CONFIG4,
79 NET_LAN9221_GPMC_CONFIG5,
80 NET_LAN9221_GPMC_CONFIG6,
81 /*CONFIG7- computed as params */
82};
83
58911517 84/*
9d0fc811
DB
85 * Routine: board_init
86 * Description: Early hardware init.
58911517 87 */
9d0fc811
DB
88int board_init(void)
89{
90 DECLARE_GLOBAL_DATA_PTR;
91
92 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
93 /* board id for Linux */
94 gd->bd->bi_arch_number = MACH_TYPE_OVERO;
95 /* boot param addr */
96 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
97
98 return 0;
99}
100
c2d5b341
SS
101/*
102 * Routine: get_board_revision
103 * Description: Returns the board revision
104 */
105int get_board_revision(void)
106{
107 int revision;
108
109 if (!omap_request_gpio(112) &&
110 !omap_request_gpio(113) &&
111 !omap_request_gpio(115)) {
112
113 omap_set_gpio_direction(112, 1);
114 omap_set_gpio_direction(113, 1);
115 omap_set_gpio_direction(115, 1);
116
117 revision = omap_get_gpio_datain(115) << 2 |
118 omap_get_gpio_datain(113) << 1 |
119 omap_get_gpio_datain(112);
120
121 omap_free_gpio(112);
122 omap_free_gpio(113);
123 omap_free_gpio(115);
124 } else {
125 printf("Error: unable to acquire board revision GPIOs\n");
126 revision = -1;
127 }
128
129 return revision;
130}
131
a06e1629
SS
132/*
133 * Routine: get_sdio2_config
134 * Description: Return information about the wifi module connection
135 * Returns 0 if the module connects though a level translator
136 * Returns 1 if the module connects directly
137 */
138int get_sdio2_config(void)
139{
140 int sdio_direct;
141
142 if (!omap_request_gpio(130) && !omap_request_gpio(139)) {
143
144 omap_set_gpio_direction(130, 0);
145 omap_set_gpio_direction(139, 1);
146
147 sdio_direct = 1;
148 omap_set_gpio_dataout(130, 0);
149 if (omap_get_gpio_datain(139) == 0) {
150 omap_set_gpio_dataout(130, 1);
151 if (omap_get_gpio_datain(139) == 1)
152 sdio_direct = 0;
153 }
154
155 omap_free_gpio(130);
156 omap_free_gpio(139);
157 } else {
158 printf("Error: unable to acquire sdio2 clk GPIOs\n");
159 sdio_direct = -1;
160 }
161
162 return sdio_direct;
163}
164
d64b5b89
SS
165/*
166 * Routine: get_expansion_id
167 * Description: This function checks for expansion board by checking I2C
168 * bus 2 for the availability of an AT24C01B serial EEPROM.
169 * returns the device_vendor field from the EEPROM
170 */
171unsigned int get_expansion_id(void)
172{
173 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
174
175 /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */
176 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
177 i2c_set_bus_num(TWL4030_I2C_BUS);
178 return GUMSTIX_NO_EEPROM;
179 }
180
181 /* read configuration data */
182 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
183 sizeof(expansion_config));
184
185 i2c_set_bus_num(TWL4030_I2C_BUS);
186
187 return expansion_config.device_vendor;
188}
189
58911517 190/*
9d0fc811
DB
191 * Routine: misc_init_r
192 * Description: Configure board specific parts
58911517 193 */
9d0fc811
DB
194int misc_init_r(void)
195{
2c155130 196 twl4030_power_init();
ead39d7a 197 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
9d0fc811 198
df382626
OJ
199#if defined(CONFIG_CMD_NET)
200 setup_net_chip();
201#endif
202
c2d5b341 203 printf("Board revision: %d\n", get_board_revision());
a06e1629
SS
204
205 switch (get_sdio2_config()) {
206 case 0:
207 printf("Tranceiver detected on mmc2\n");
208 MUX_OVERO_SDIO2_TRANSCEIVER();
209 break;
210 case 1:
211 printf("Direct connection on mmc2\n");
212 MUX_OVERO_SDIO2_DIRECT();
213 break;
214 default:
215 printf("Unable to detect mmc2 connection type\n");
216 }
217
d64b5b89
SS
218 switch (get_expansion_id()) {
219 case GUMSTIX_SUMMIT:
220 printf("Recognized Summit expansion board (rev %d %s)\n",
221 expansion_config.revision,
222 expansion_config.fab_revision);
223 setenv("defaultdisplay", "dvi");
224 break;
225 case GUMSTIX_TOBI:
226 printf("Recognized Tobi expansion board (rev %d %s)\n",
227 expansion_config.revision,
228 expansion_config.fab_revision);
229 setenv("defaultdisplay", "dvi");
230 break;
231 case GUMSTIX_TOBI_DUO:
232 printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
233 expansion_config.revision,
234 expansion_config.fab_revision);
235 break;
236 case GUMSTIX_PALO35:
237 printf("Recognized Palo35 expansion board (rev %d %s)\n",
238 expansion_config.revision,
239 expansion_config.fab_revision);
240 setenv("defaultdisplay", "lcd35");
241 break;
242 case GUMSTIX_PALO43:
243 printf("Recognized Palo43 expansion board (rev %d %s)\n",
244 expansion_config.revision,
245 expansion_config.fab_revision);
246 setenv("defaultdisplay", "lcd43");
247 break;
248 case GUMSTIX_CHESTNUT43:
249 printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
250 expansion_config.revision,
251 expansion_config.fab_revision);
252 setenv("defaultdisplay", "lcd43");
253 break;
254 case GUMSTIX_PINTO:
255 printf("Recognized Pinto expansion board (rev %d %s)\n",
256 expansion_config.revision,
257 expansion_config.fab_revision);
258 break;
259 case GUMSTIX_GALLOP43:
260 printf("Recognized Gallop43 expansion board (rev %d %s)\n",
261 expansion_config.revision,
262 expansion_config.fab_revision);
263 setenv("defaultdisplay", "lcd43");
264 break;
265 case ETTUS_USRP_E:
266 printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
267 expansion_config.revision,
268 expansion_config.fab_revision);
269 MUX_USRP_E();
270 setenv("defaultdisplay", "dvi");
271 break;
272 case GUMSTIX_NO_EEPROM:
273 printf("No EEPROM on expansion board\n");
274 break;
275 default:
276 printf("Unrecognized expansion board\n");
277 }
278
279 if (expansion_config.content == 1)
280 setenv(expansion_config.env_var, expansion_config.env_setting);
281
e6a6a704
DB
282 dieid_num_r();
283
9d0fc811
DB
284 return 0;
285}
286
58911517 287/*
9d0fc811
DB
288 * Routine: set_muxconf_regs
289 * Description: Setting up the configuration Mux registers specific to the
290 * hardware. Many pins need to be moved from protect to primary
291 * mode.
58911517 292 */
9d0fc811
DB
293void set_muxconf_regs(void)
294{
295 MUX_OVERO();
296}
df382626
OJ
297
298#if defined(CONFIG_CMD_NET)
299/*
300 * Routine: setup_net_chip
301 * Description: Setting up the configuration GPMC registers specific to the
302 * Ethernet hardware.
303 */
304static void setup_net_chip(void)
305{
306 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
307
ba9a11e4
SS
308 /* first lan chip */
309 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
310 GPMC_SIZE_16M);
311
312 /* second lan chip */
313 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], 0x2B000000,
314 GPMC_SIZE_16M);
df382626
OJ
315
316 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
317 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
318 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
319 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
320 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
321 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
322 &ctrl_base->gpmc_nadv_ale);
323
324 /* Make GPIO 64 as output pin and send a magic pulse through it */
325 if (!omap_request_gpio(64)) {
326 omap_set_gpio_direction(64, 0);
327 omap_set_gpio_dataout(64, 1);
328 udelay(1);
329 omap_set_gpio_dataout(64, 0);
330 udelay(1);
331 omap_set_gpio_dataout(64, 1);
332 }
333}
334#endif
335
336int board_eth_init(bd_t *bis)
337{
338 int rc = 0;
339#ifdef CONFIG_SMC911X
340 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
341#endif
342 return rc;
343}
cd7c5726
SS
344
345#ifdef CONFIG_GENERIC_MMC
346int board_mmc_init(bd_t *bis)
347{
348 omap_mmc_init(0);
349 return 0;
350}
351#endif