2 * Maintainer : Steve Sakoman <steve@sakoman.com>
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>
10 * (C) Copyright 2004-2008
11 * Texas Instruments, <www.ti.com>
13 * SPDX-License-Identifier: GPL-2.0+
18 #include <linux/mtd/nand.h>
20 #include <asm/arch/mmc_host_def.h>
21 #include <asm/arch/mux.h>
22 #include <asm/arch/mem.h>
23 #include <asm/arch/sys_proto.h>
25 #include <asm/mach-types.h>
28 #ifdef CONFIG_USB_EHCI
30 #include <asm/ehci-omap.h>
33 DECLARE_GLOBAL_DATA_PTR;
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};
70 * Description: Early hardware init.
74 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
75 /* board id for Linux */
76 gd->bd->bi_arch_number = MACH_TYPE_OVERO;
78 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
84 * Routine: get_board_revision
85 * Description: Returns the board revision
87 int get_board_revision(void)
91 #ifdef CONFIG_SYS_I2C_OMAP34XX
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);
99 i2c_write(0x4B, 0x29, 1, &data, 1);
101 i2c_write(0x4B, 0x2b, 1, &data, 1);
102 i2c_read(0x4B, 0x2a, 1, &data, 1);
105 if (!gpio_request(112, "") &&
106 !gpio_request(113, "") &&
107 !gpio_request(115, "")) {
109 gpio_direction_input(112);
110 gpio_direction_input(113);
111 gpio_direction_input(115);
113 revision = gpio_get_value(115) << 2 |
114 gpio_get_value(113) << 1 |
117 puts("Error: unable to acquire board revision GPIOs\n");
124 #ifdef CONFIG_SPL_BUILD
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.
130 void get_board_mem_timings(struct board_sdrc_timings *timings)
132 timings->mr = MICRON_V_MR_165;
133 switch (get_board_revision()) {
134 case REVISION_0: /* Micron 1286MB/256MB, 1/2 banks of 128MB */
135 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;
140 case REVISION_1: /* Micron 256MB/512MB, 1/2 banks of 256MB */
142 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;
147 case REVISION_2: /* Hynix 256MB/512MB, 1/2 banks of 256MB */
148 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;
153 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;
160 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;
169 * 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
174 int get_sdio2_config(void)
178 if (!gpio_request(130, "") && !gpio_request(139, "")) {
180 gpio_direction_output(130, 0);
181 gpio_direction_input(139);
184 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)
191 gpio_direction_input(130);
193 puts("Error: unable to acquire sdio2 clk GPIOs\n");
201 * 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
206 unsigned int get_expansion_id(void)
208 if (expansion_config.device_vendor != 0x0)
209 return expansion_config.device_vendor;
211 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
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;
219 /* read configuration data */
220 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
221 sizeof(expansion_config));
223 i2c_set_bus_num(TWL4030_I2C_BUS);
225 return expansion_config.device_vendor;
229 * Routine: misc_init_r
230 * Description: Configure board specific parts
232 int misc_init_r(void)
234 unsigned int expansion_id;
236 twl4030_power_init();
237 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
239 printf("Board revision: %d\n", get_board_revision());
241 switch (get_sdio2_config()) {
243 puts("Tranceiver detected on mmc2\n");
244 MUX_OVERO_SDIO2_TRANSCEIVER();
247 puts("Direct connection on mmc2\n");
248 MUX_OVERO_SDIO2_DIRECT();
251 puts("Unable to detect mmc2 connection type\n");
254 expansion_id = get_expansion_id();
255 switch (expansion_id) {
257 printf("Recognized Summit expansion board (rev %d %s)\n",
258 expansion_config.revision,
259 expansion_config.fab_revision);
261 setenv("defaultdisplay", "dvi");
262 setenv("expansionname", "summit");
265 printf("Recognized Tobi expansion board (rev %d %s)\n",
266 expansion_config.revision,
267 expansion_config.fab_revision);
269 setenv("defaultdisplay", "dvi");
270 setenv("expansionname", "tobi");
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);
279 printf("Recognized Palo35 expansion board (rev %d %s)\n",
280 expansion_config.revision,
281 expansion_config.fab_revision);
283 setenv("defaultdisplay", "lcd35");
286 printf("Recognized Palo43 expansion board (rev %d %s)\n",
287 expansion_config.revision,
288 expansion_config.fab_revision);
290 setenv("defaultdisplay", "lcd43");
291 setenv("expansionname", "palo43");
293 case GUMSTIX_CHESTNUT43:
294 printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
295 expansion_config.revision,
296 expansion_config.fab_revision);
298 setenv("defaultdisplay", "lcd43");
299 setenv("expansionname", "chestnut43");
302 printf("Recognized Pinto expansion board (rev %d %s)\n",
303 expansion_config.revision,
304 expansion_config.fab_revision);
307 case GUMSTIX_GALLOP43:
308 printf("Recognized Gallop43 expansion board (rev %d %s)\n",
309 expansion_config.revision,
310 expansion_config.fab_revision);
312 setenv("defaultdisplay", "lcd43");
313 setenv("expansionname", "gallop43");
316 printf("Recognized Alto35 expansion board (rev %d %s)\n",
317 expansion_config.revision,
318 expansion_config.fab_revision);
321 setenv("defaultdisplay", "lcd35");
322 setenv("expansionname", "alto35");
324 case GUMSTIX_STAGECOACH:
325 printf("Recognized Stagecoach expansion board (rev %d %s)\n",
326 expansion_config.revision,
327 expansion_config.fab_revision);
331 printf("Recognized Thumbo expansion board (rev %d %s)\n",
332 expansion_config.revision,
333 expansion_config.fab_revision);
336 case GUMSTIX_TURTLECORE:
337 printf("Recognized Turtlecore expansion board (rev %d %s)\n",
338 expansion_config.revision,
339 expansion_config.fab_revision);
342 case GUMSTIX_ARBOR43C:
343 printf("Recognized Arbor43C expansion board (rev %d %s)\n",
344 expansion_config.revision,
345 expansion_config.fab_revision);
348 setenv("defaultdisplay", "lcd43");
351 printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
352 expansion_config.revision,
353 expansion_config.fab_revision);
356 setenv("defaultdisplay", "dvi");
358 case GUMSTIX_NO_EEPROM:
359 case GUMSTIX_EMPTY_EEPROM:
360 puts("No or empty EEPROM on expansion board\n");
362 setenv("expansionname", "tobi");
365 printf("Unrecognized expansion board 0x%08x\n", expansion_id);
369 if (expansion_config.content == 1)
370 setenv(expansion_config.env_var, expansion_config.env_setting);
374 if (get_cpu_family() == CPU_OMAP34XX)
375 setenv("boardname", "overo");
377 setenv("boardname", "overo-storm");
383 * 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
388 void set_muxconf_regs(void)
393 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_SPL_BUILD)
394 /* GPMC definitions for LAN9221 chips on Tobi expansion boards */
395 static 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 */
406 * Routine: setup_net_chip
407 * Description: Setting up the configuration GPMC registers specific to the
410 static void setup_net_chip(void)
412 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
414 /* 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);
424 * Routine: reset_net_chip
425 * Description: Reset the Ethernet hardware.
427 static void reset_net_chip(void)
429 /* Make GPIO 64 as output pin and send a magic pulse through it */
430 if (!gpio_request(64, "")) {
431 gpio_direction_output(64, 0);
432 gpio_set_value(64, 1);
434 gpio_set_value(64, 0);
436 gpio_set_value(64, 1);
440 int board_eth_init(bd_t *bis)
442 unsigned int expansion_id;
445 #ifdef CONFIG_SMC911X
446 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);
454 case GUMSTIX_CHESTNUT43:
455 case GUMSTIX_STAGECOACH:
456 case GUMSTIX_NO_EEPROM:
457 case GUMSTIX_EMPTY_EEPROM:
459 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
460 0x2C000000, GPMC_SIZE_16M);
465 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
476 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
477 int board_mmc_init(bd_t *bis)
479 return omap_mmc_init(0, 0, 0, -1, -1);
483 #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
484 static 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
490 #define GUMSTIX_GPIO_USBH_CPEN 168
491 int ehci_hcd_init(int index, enum usb_init_type init,
492 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
494 /* Enable USB power */
495 if (!gpio_request(GUMSTIX_GPIO_USBH_CPEN, "usbh_cpen"))
496 gpio_direction_output(GUMSTIX_GPIO_USBH_CPEN, 1);
498 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
501 int ehci_hcd_stop(void)
503 /* Disable USB power */
504 gpio_set_value(GUMSTIX_GPIO_USBH_CPEN, 0);
505 gpio_free(GUMSTIX_GPIO_USBH_CPEN);
507 return omap_ehci_hcd_stop();
510 #endif /* CONFIG_USB_EHCI */