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+
20 #include <linux/mtd/nand.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
32 #include <asm/ehci-omap.h>
35 DECLARE_GLOBAL_DATA_PTR
;
37 #define TWL4030_I2C_BUS 0
38 #define EXPANSION_EEPROM_I2C_BUS 2
39 #define EXPANSION_EEPROM_I2C_ADDRESS 0x51
41 #define GUMSTIX_EMPTY_EEPROM 0x0
43 #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
51 #define GUMSTIX_ALTO35 0x09000200
52 #define GUMSTIX_STAGECOACH 0x0A000200
53 #define GUMSTIX_THUMBO 0x0B000200
54 #define GUMSTIX_TURTLECORE 0x0C000200
55 #define GUMSTIX_ARBOR43C 0x0D000200
57 #define ETTUS_USRP_E 0x01000300
59 #define GUMSTIX_NO_EEPROM 0xffffffff
62 unsigned int device_vendor
;
63 unsigned char revision
;
64 unsigned char content
;
68 } expansion_config
= {0x0};
70 static const struct ns16550_platdata overo_serial
= {
76 U_BOOT_DEVICE(overo_uart
) = {
83 * Description: Early hardware init.
87 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
88 /* board id for Linux */
89 gd
->bd
->bi_arch_number
= MACH_TYPE_OVERO
;
91 gd
->bd
->bi_boot_params
= (OMAP34XX_SDRC_CS0
+ 0x100);
97 * Routine: get_board_revision
98 * Description: Returns the board revision
100 int get_board_revision(void)
104 #ifdef CONFIG_SYS_I2C_OMAP34XX
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
);
112 i2c_write(0x4B, 0x29, 1, &data
, 1);
114 i2c_write(0x4B, 0x2b, 1, &data
, 1);
115 i2c_read(0x4B, 0x2a, 1, &data
, 1);
118 if (!gpio_request(112, "") &&
119 !gpio_request(113, "") &&
120 !gpio_request(115, "")) {
122 gpio_direction_input(112);
123 gpio_direction_input(113);
124 gpio_direction_input(115);
126 revision
= gpio_get_value(115) << 2 |
127 gpio_get_value(113) << 1 |
130 puts("Error: unable to acquire board revision GPIOs\n");
137 #ifdef CONFIG_SPL_BUILD
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.
143 void get_board_mem_timings(struct board_sdrc_timings
*timings
)
145 timings
->mr
= MICRON_V_MR_165
;
146 switch (get_board_revision()) {
147 case REVISION_0
: /* Micron 1286MB/256MB, 1/2 banks of 128MB */
148 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
;
153 case REVISION_1
: /* Micron 256MB/512MB, 1/2 banks of 256MB */
155 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
;
160 case REVISION_2
: /* Hynix 256MB/512MB, 1/2 banks of 256MB */
161 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
;
166 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
;
173 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
;
182 * 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
187 int get_sdio2_config(void)
191 if (!gpio_request(130, "") && !gpio_request(139, "")) {
193 gpio_direction_output(130, 0);
194 gpio_direction_input(139);
197 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)
204 gpio_direction_input(130);
206 puts("Error: unable to acquire sdio2 clk GPIOs\n");
214 * 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
219 unsigned int get_expansion_id(void)
221 if (expansion_config
.device_vendor
!= 0x0)
222 return expansion_config
.device_vendor
;
224 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS
);
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
;
232 /* read configuration data */
233 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS
, 0, 1, (u8
*)&expansion_config
,
234 sizeof(expansion_config
));
236 i2c_set_bus_num(TWL4030_I2C_BUS
);
238 return expansion_config
.device_vendor
;
242 * Routine: misc_init_r
243 * Description: Configure board specific parts
245 int misc_init_r(void)
247 unsigned int expansion_id
;
249 twl4030_power_init();
250 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON
| TWL4030_LED_LEDEN_LEDBON
);
252 printf("Board revision: %d\n", get_board_revision());
254 switch (get_sdio2_config()) {
256 puts("Tranceiver detected on mmc2\n");
257 MUX_OVERO_SDIO2_TRANSCEIVER();
260 puts("Direct connection on mmc2\n");
261 MUX_OVERO_SDIO2_DIRECT();
264 puts("Unable to detect mmc2 connection type\n");
267 expansion_id
= get_expansion_id();
268 switch (expansion_id
) {
270 printf("Recognized Summit expansion board (rev %d %s)\n",
271 expansion_config
.revision
,
272 expansion_config
.fab_revision
);
274 setenv("defaultdisplay", "dvi");
275 setenv("expansionname", "summit");
278 printf("Recognized Tobi expansion board (rev %d %s)\n",
279 expansion_config
.revision
,
280 expansion_config
.fab_revision
);
282 setenv("defaultdisplay", "dvi");
283 setenv("expansionname", "tobi");
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
);
290 setenv("expansionname", "tobiduo");
293 printf("Recognized Palo35 expansion board (rev %d %s)\n",
294 expansion_config
.revision
,
295 expansion_config
.fab_revision
);
297 setenv("defaultdisplay", "lcd35");
298 setenv("expansionname", "palo35");
301 printf("Recognized Palo43 expansion board (rev %d %s)\n",
302 expansion_config
.revision
,
303 expansion_config
.fab_revision
);
305 setenv("defaultdisplay", "lcd43");
306 setenv("expansionname", "palo43");
308 case GUMSTIX_CHESTNUT43
:
309 printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
310 expansion_config
.revision
,
311 expansion_config
.fab_revision
);
313 setenv("defaultdisplay", "lcd43");
314 setenv("expansionname", "chestnut43");
317 printf("Recognized Pinto expansion board (rev %d %s)\n",
318 expansion_config
.revision
,
319 expansion_config
.fab_revision
);
322 case GUMSTIX_GALLOP43
:
323 printf("Recognized Gallop43 expansion board (rev %d %s)\n",
324 expansion_config
.revision
,
325 expansion_config
.fab_revision
);
327 setenv("defaultdisplay", "lcd43");
328 setenv("expansionname", "gallop43");
331 printf("Recognized Alto35 expansion board (rev %d %s)\n",
332 expansion_config
.revision
,
333 expansion_config
.fab_revision
);
336 setenv("defaultdisplay", "lcd35");
337 setenv("expansionname", "alto35");
339 case GUMSTIX_STAGECOACH
:
340 printf("Recognized Stagecoach expansion board (rev %d %s)\n",
341 expansion_config
.revision
,
342 expansion_config
.fab_revision
);
346 printf("Recognized Thumbo expansion board (rev %d %s)\n",
347 expansion_config
.revision
,
348 expansion_config
.fab_revision
);
351 case GUMSTIX_TURTLECORE
:
352 printf("Recognized Turtlecore expansion board (rev %d %s)\n",
353 expansion_config
.revision
,
354 expansion_config
.fab_revision
);
357 case GUMSTIX_ARBOR43C
:
358 printf("Recognized Arbor43C expansion board (rev %d %s)\n",
359 expansion_config
.revision
,
360 expansion_config
.fab_revision
);
363 setenv("defaultdisplay", "lcd43");
364 setenv("expansionname", "arbor43c");
367 printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
368 expansion_config
.revision
,
369 expansion_config
.fab_revision
);
372 setenv("defaultdisplay", "dvi");
374 case GUMSTIX_NO_EEPROM
:
375 case GUMSTIX_EMPTY_EEPROM
:
376 puts("No or empty EEPROM on expansion board\n");
378 setenv("expansionname", "tobi");
381 printf("Unrecognized expansion board 0x%08x\n", expansion_id
);
385 if (expansion_config
.content
== 1)
386 setenv(expansion_config
.env_var
, expansion_config
.env_setting
);
390 if (get_cpu_family() == CPU_OMAP34XX
)
391 setenv("boardname", "overo");
393 setenv("boardname", "overo-storm");
399 * Routine: set_muxconf_regs
400 * Description: Setting up the configuration Mux registers specific to the
401 * hardware. Many pins need to be moved from protect to primary
404 void set_muxconf_regs(void)
409 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_SPL_BUILD)
410 /* GPMC definitions for LAN9221 chips on Tobi expansion boards */
411 static const u32 gpmc_lan_config
[] = {
412 NET_LAN9221_GPMC_CONFIG1
,
413 NET_LAN9221_GPMC_CONFIG2
,
414 NET_LAN9221_GPMC_CONFIG3
,
415 NET_LAN9221_GPMC_CONFIG4
,
416 NET_LAN9221_GPMC_CONFIG5
,
417 NET_LAN9221_GPMC_CONFIG6
,
418 /*CONFIG7- computed as params */
422 * Routine: setup_net_chip
423 * Description: Setting up the configuration GPMC registers specific to the
426 static void setup_net_chip(void)
428 struct ctrl
*ctrl_base
= (struct ctrl
*)OMAP34XX_CTRL_BASE
;
430 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
431 writew(readw(&ctrl_base
->gpmc_nwe
) | 0x0E00, &ctrl_base
->gpmc_nwe
);
432 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
433 writew(readw(&ctrl_base
->gpmc_noe
) | 0x0E00, &ctrl_base
->gpmc_noe
);
434 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
435 writew(readw(&ctrl_base
->gpmc_nadv_ale
) | 0x0E00,
436 &ctrl_base
->gpmc_nadv_ale
);
440 * Routine: reset_net_chip
441 * Description: Reset the Ethernet hardware.
443 static void reset_net_chip(void)
445 /* Make GPIO 64 as output pin and send a magic pulse through it */
446 if (!gpio_request(64, "")) {
447 gpio_direction_output(64, 0);
448 gpio_set_value(64, 1);
450 gpio_set_value(64, 0);
452 gpio_set_value(64, 1);
456 int board_eth_init(bd_t
*bis
)
458 unsigned int expansion_id
;
461 #ifdef CONFIG_SMC911X
462 expansion_id
= get_expansion_id();
463 switch (expansion_id
) {
464 case GUMSTIX_TOBI_DUO
:
465 /* second lan chip */
466 enable_gpmc_cs_config(gpmc_lan_config
, &gpmc_cfg
->cs
[4],
467 0x2B000000, GPMC_SIZE_16M
);
470 case GUMSTIX_CHESTNUT43
:
471 case GUMSTIX_STAGECOACH
:
472 case GUMSTIX_NO_EEPROM
:
473 case GUMSTIX_EMPTY_EEPROM
:
475 enable_gpmc_cs_config(gpmc_lan_config
, &gpmc_cfg
->cs
[5],
476 0x2C000000, GPMC_SIZE_16M
);
481 rc
= smc911x_initialize(0, CONFIG_SMC911X_BASE
);
492 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
493 int board_mmc_init(bd_t
*bis
)
495 return omap_mmc_init(0, 0, 0, -1, -1);
499 #if defined(CONFIG_GENERIC_MMC)
500 void board_mmc_power_init(void)
502 twl4030_power_mmc_init(0);
506 #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
507 static struct omap_usbhs_board_data usbhs_bdata
= {
508 .port_mode
[0] = OMAP_USBHS_PORT_MODE_UNUSED
,
509 .port_mode
[1] = OMAP_EHCI_PORT_MODE_PHY
,
510 .port_mode
[2] = OMAP_USBHS_PORT_MODE_UNUSED
513 #define GUMSTIX_GPIO_USBH_CPEN 168
514 int ehci_hcd_init(int index
, enum usb_init_type init
,
515 struct ehci_hccr
**hccr
, struct ehci_hcor
**hcor
)
517 /* Enable USB power */
518 if (!gpio_request(GUMSTIX_GPIO_USBH_CPEN
, "usbh_cpen"))
519 gpio_direction_output(GUMSTIX_GPIO_USBH_CPEN
, 1);
521 return omap_ehci_hcd_init(index
, &usbhs_bdata
, hccr
, hcor
);
524 int ehci_hcd_stop(void)
526 /* Disable USB power */
527 gpio_set_value(GUMSTIX_GPIO_USBH_CPEN
, 0);
528 gpio_free(GUMSTIX_GPIO_USBH_CPEN
);
530 return omap_ehci_hcd_stop();
533 #endif /* CONFIG_USB_EHCI */