1 // SPDX-License-Identifier: GPL-2.0+
3 * Maintainer : Steve Sakoman <steve@sakoman.com>
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>
11 * (C) Copyright 2004-2008
12 * Texas Instruments, <www.ti.com>
20 #include <linux/mtd/rawnand.h>
22 #include <asm/arch/mmc_host_def.h>
23 #include <asm/arch/mux.h>
24 #include <asm/arch/mem.h>
25 #include <asm/arch/sys_proto.h>
27 #include <asm/mach-types.h>
30 #ifdef CONFIG_USB_EHCI_HCD
32 #include <asm/ehci-omap.h>
35 #define TWL4030_I2C_BUS 0
36 #define EXPANSION_EEPROM_I2C_BUS 2
37 #define EXPANSION_EEPROM_I2C_ADDRESS 0x51
39 #define GUMSTIX_EMPTY_EEPROM 0x0
41 #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
49 #define GUMSTIX_ALTO35 0x09000200
50 #define GUMSTIX_STAGECOACH 0x0A000200
51 #define GUMSTIX_THUMBO 0x0B000200
52 #define GUMSTIX_TURTLECORE 0x0C000200
53 #define GUMSTIX_ARBOR43C 0x0D000200
55 #define ETTUS_USRP_E 0x01000300
57 #define GUMSTIX_NO_EEPROM 0xffffffff
60 unsigned int device_vendor;
61 unsigned char revision;
62 unsigned char content;
66 } expansion_config = {0x0};
68 static const struct ns16550_platdata overo_serial = {
69 .base = OMAP34XX_UART3,
71 .clock = V_NS16550_CLK,
72 .fcr = UART_FCR_DEFVAL,
75 U_BOOT_DEVICE(overo_uart) = {
81 * Routine: get_sdio2_config
82 * Description: Return information about the wifi module connection
83 * Returns 0 if the module connects though a level translator
84 * Returns 1 if the module connects directly
86 int get_sdio2_config(void)
90 if (!gpio_request(130, "") && !gpio_request(139, "")) {
92 gpio_direction_output(130, 0);
93 gpio_direction_input(139);
96 gpio_set_value(130, 0);
97 if (gpio_get_value(139) == 0) {
98 gpio_set_value(130, 1);
99 if (gpio_get_value(139) == 1)
103 gpio_direction_input(130);
105 puts("Error: unable to acquire sdio2 clk GPIOs\n");
113 * Routine: get_expansion_id
114 * Description: This function checks for expansion board by checking I2C
115 * bus 2 for the availability of an AT24C01B serial EEPROM.
116 * returns the device_vendor field from the EEPROM
118 unsigned int get_expansion_id(void)
120 if (expansion_config.device_vendor != 0x0)
121 return expansion_config.device_vendor;
123 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
125 /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */
126 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
127 i2c_set_bus_num(TWL4030_I2C_BUS);
128 return GUMSTIX_NO_EEPROM;
131 /* read configuration data */
132 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
133 sizeof(expansion_config));
135 i2c_set_bus_num(TWL4030_I2C_BUS);
137 return expansion_config.device_vendor;
141 * Routine: misc_init_r
142 * Description: Configure board specific parts
144 int misc_init_r(void)
146 unsigned int expansion_id;
148 twl4030_power_init();
149 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
151 printf("Board revision: %d\n", get_board_revision());
153 switch (get_sdio2_config()) {
155 puts("Tranceiver detected on mmc2\n");
156 MUX_OVERO_SDIO2_TRANSCEIVER();
159 puts("Direct connection on mmc2\n");
160 MUX_OVERO_SDIO2_DIRECT();
163 puts("Unable to detect mmc2 connection type\n");
166 expansion_id = get_expansion_id();
167 switch (expansion_id) {
169 printf("Recognized Summit expansion board (rev %d %s)\n",
170 expansion_config.revision,
171 expansion_config.fab_revision);
173 env_set("defaultdisplay", "dvi");
174 env_set("expansionname", "summit");
177 printf("Recognized Tobi expansion board (rev %d %s)\n",
178 expansion_config.revision,
179 expansion_config.fab_revision);
181 env_set("defaultdisplay", "dvi");
182 env_set("expansionname", "tobi");
184 case GUMSTIX_TOBI_DUO:
185 printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
186 expansion_config.revision,
187 expansion_config.fab_revision);
189 env_set("expansionname", "tobiduo");
192 printf("Recognized Palo35 expansion board (rev %d %s)\n",
193 expansion_config.revision,
194 expansion_config.fab_revision);
196 env_set("defaultdisplay", "lcd35");
197 env_set("expansionname", "palo35");
200 printf("Recognized Palo43 expansion board (rev %d %s)\n",
201 expansion_config.revision,
202 expansion_config.fab_revision);
204 env_set("defaultdisplay", "lcd43");
205 env_set("expansionname", "palo43");
207 case GUMSTIX_CHESTNUT43:
208 printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
209 expansion_config.revision,
210 expansion_config.fab_revision);
212 env_set("defaultdisplay", "lcd43");
213 env_set("expansionname", "chestnut43");
216 printf("Recognized Pinto expansion board (rev %d %s)\n",
217 expansion_config.revision,
218 expansion_config.fab_revision);
221 case GUMSTIX_GALLOP43:
222 printf("Recognized Gallop43 expansion board (rev %d %s)\n",
223 expansion_config.revision,
224 expansion_config.fab_revision);
226 env_set("defaultdisplay", "lcd43");
227 env_set("expansionname", "gallop43");
230 printf("Recognized Alto35 expansion board (rev %d %s)\n",
231 expansion_config.revision,
232 expansion_config.fab_revision);
235 env_set("defaultdisplay", "lcd35");
236 env_set("expansionname", "alto35");
238 case GUMSTIX_STAGECOACH:
239 printf("Recognized Stagecoach expansion board (rev %d %s)\n",
240 expansion_config.revision,
241 expansion_config.fab_revision);
245 printf("Recognized Thumbo expansion board (rev %d %s)\n",
246 expansion_config.revision,
247 expansion_config.fab_revision);
250 case GUMSTIX_TURTLECORE:
251 printf("Recognized Turtlecore expansion board (rev %d %s)\n",
252 expansion_config.revision,
253 expansion_config.fab_revision);
256 case GUMSTIX_ARBOR43C:
257 printf("Recognized Arbor43C expansion board (rev %d %s)\n",
258 expansion_config.revision,
259 expansion_config.fab_revision);
262 env_set("defaultdisplay", "lcd43");
263 env_set("expansionname", "arbor43c");
266 printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
267 expansion_config.revision,
268 expansion_config.fab_revision);
271 env_set("defaultdisplay", "dvi");
273 case GUMSTIX_NO_EEPROM:
274 case GUMSTIX_EMPTY_EEPROM:
275 puts("No or empty EEPROM on expansion board\n");
277 env_set("expansionname", "tobi");
280 printf("Unrecognized expansion board 0x%08x\n", expansion_id);
284 if (expansion_config.content == 1)
285 env_set(expansion_config.env_var, expansion_config.env_setting);
287 omap_die_id_display();
289 if (get_cpu_family() == CPU_OMAP34XX)
290 env_set("boardname", "overo");
292 env_set("boardname", "overo-storm");
297 #if defined(CONFIG_CMD_NET)
298 /* GPMC definitions for LAN9221 chips on Tobi expansion boards */
299 static const u32 gpmc_lan_config[] = {
300 NET_LAN9221_GPMC_CONFIG1,
301 NET_LAN9221_GPMC_CONFIG2,
302 NET_LAN9221_GPMC_CONFIG3,
303 NET_LAN9221_GPMC_CONFIG4,
304 NET_LAN9221_GPMC_CONFIG5,
305 NET_LAN9221_GPMC_CONFIG6,
306 /*CONFIG7- computed as params */
310 * Routine: setup_net_chip
311 * Description: Setting up the configuration GPMC registers specific to the
314 static void setup_net_chip(void)
316 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
318 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
319 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
320 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
321 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
322 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
323 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
324 &ctrl_base->gpmc_nadv_ale);
328 * Routine: reset_net_chip
329 * Description: Reset the Ethernet hardware.
331 static void reset_net_chip(void)
333 /* Make GPIO 64 as output pin and send a magic pulse through it */
334 if (!gpio_request(64, "")) {
335 gpio_direction_output(64, 0);
336 gpio_set_value(64, 1);
338 gpio_set_value(64, 0);
340 gpio_set_value(64, 1);
344 int board_eth_init(bd_t *bis)
346 unsigned int expansion_id;
349 #ifdef CONFIG_SMC911X
350 expansion_id = get_expansion_id();
351 switch (expansion_id) {
352 case GUMSTIX_TOBI_DUO:
353 /* second lan chip */
354 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4],
355 0x2B000000, GPMC_SIZE_16M);
358 case GUMSTIX_CHESTNUT43:
359 case GUMSTIX_STAGECOACH:
360 case GUMSTIX_NO_EEPROM:
361 case GUMSTIX_EMPTY_EEPROM:
363 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
364 0x2C000000, GPMC_SIZE_16M);
369 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
380 #if defined(CONFIG_USB_EHCI_HCD)
381 static struct omap_usbhs_board_data usbhs_bdata = {
382 .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
383 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
384 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
387 #define GUMSTIX_GPIO_USBH_CPEN 168
388 int ehci_hcd_init(int index, enum usb_init_type init,
389 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
391 /* Enable USB power */
392 if (!gpio_request(GUMSTIX_GPIO_USBH_CPEN, "usbh_cpen"))
393 gpio_direction_output(GUMSTIX_GPIO_USBH_CPEN, 1);
395 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
398 int ehci_hcd_stop(void)
400 /* Disable USB power */
401 gpio_set_value(GUMSTIX_GPIO_USBH_CPEN, 0);
402 gpio_free(GUMSTIX_GPIO_USBH_CPEN);
404 return omap_ehci_hcd_stop();
407 #endif /* CONFIG_USB_EHCI_HCD */