2 * (C) Copyright 2004-2011
3 * Texas Instruments, <www.ti.com>
9 * Derived from Beagle Board and 3430 SDP code by
14 * See file CREDITS for list of people who contributed to this
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #ifdef CONFIG_STATUS_LED
34 #include <status_led.h>
37 #include <linux/mtd/nand.h>
39 #include <asm/arch/mmc_host_def.h>
40 #include <asm/arch/mux.h>
41 #include <asm/arch/mem.h>
42 #include <asm/arch/sys_proto.h>
44 #include <asm/mach-types.h>
45 #include <asm/omap_musb.h>
46 #include <asm/errno.h>
47 #include <linux/usb/ch9.h>
48 #include <linux/usb/gadget.h>
49 #include <linux/usb/musb.h>
53 #ifdef CONFIG_USB_EHCI
55 #include <asm/ehci-omap.h>
58 #define TWL4030_I2C_BUS 0
59 #define EXPANSION_EEPROM_I2C_BUS 1
60 #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
62 #define TINCANTOOLS_ZIPPY 0x01000100
63 #define TINCANTOOLS_ZIPPY2 0x02000100
64 #define TINCANTOOLS_TRAINER 0x04000100
65 #define TINCANTOOLS_SHOWDOG 0x03000100
66 #define KBADC_BEAGLEFPGA 0x01000600
67 #define LW_BEAGLETOUCH 0x01000700
68 #define BRAINMUX_LCDOG 0x01000800
69 #define BRAINMUX_LCDOGTOUCH 0x02000800
70 #define BBTOYS_WIFI 0x01000B00
71 #define BBTOYS_VGA 0x02000B00
72 #define BBTOYS_LCD 0x03000B00
73 #define BCT_BRETTL3 0x01000F00
74 #define BCT_BRETTL4 0x02000F00
75 #define BEAGLE_NO_EEPROM 0xffffffff
77 DECLARE_GLOBAL_DATA_PTR;
80 unsigned int device_vendor;
81 unsigned char revision;
82 unsigned char content;
90 * Description: Early hardware init.
94 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
95 /* board id for Linux */
96 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
98 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
100 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
101 status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
108 * Routine: get_board_revision
109 * Description: Detect if we are running on a Beagle revision Ax/Bx,
110 * C1/2/3, C4 or xM. This can be done by reading
111 * the level of GPIO173, GPIO172 and GPIO171. This should
113 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
114 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
115 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
116 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
118 static int get_board_revision(void)
122 if (!gpio_request(171, "") &&
123 !gpio_request(172, "") &&
124 !gpio_request(173, "")) {
126 gpio_direction_input(171);
127 gpio_direction_input(172);
128 gpio_direction_input(173);
130 revision = gpio_get_value(173) << 2 |
131 gpio_get_value(172) << 1 |
134 printf("Error: unable to acquire board revision GPIOs\n");
141 #ifdef CONFIG_SPL_BUILD
143 * Routine: get_board_mem_timings
144 * Description: If we use SPL then there is no x-loader nor config header
145 * so we have to setup the DDR timings ourself on both banks.
147 void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
153 * We need to identify what PoP memory is on the board so that
154 * we know what timings to use. If we can't identify it then
155 * we know it's an xM. To map the ID values please see nand_ids.c
157 identify_nand_chip(&pop_mfr, &pop_id);
159 *mr = MICRON_V_MR_165;
160 switch (get_board_revision()) {
162 if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) {
164 *mcfg = NUMONYX_V_MCFG_165(512 << 20);
165 *ctrla = NUMONYX_V_ACTIMA_165;
166 *ctrlb = NUMONYX_V_ACTIMB_165;
167 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
169 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) {
170 /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/
171 *mcfg = MICRON_V_MCFG_165(128 << 20);
172 *ctrla = MICRON_V_ACTIMA_165;
173 *ctrlb = MICRON_V_ACTIMB_165;
174 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
176 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) {
177 /* Beagleboard Rev C5, 256MB DDR */
178 *mcfg = MICRON_V_MCFG_200(256 << 20);
179 *ctrla = MICRON_V_ACTIMA_200;
180 *ctrlb = MICRON_V_ACTIMB_200;
181 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
189 *mcfg = MICRON_V_MCFG_200(256 << 20);
190 *ctrla = MICRON_V_ACTIMA_200;
191 *ctrlb = MICRON_V_ACTIMB_200;
192 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
195 *mcfg = NUMONYX_V_MCFG_165(512 << 20);
196 *ctrla = NUMONYX_V_ACTIMA_165;
197 *ctrlb = NUMONYX_V_ACTIMB_165;
198 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
202 /* Assume 128MB and Micron/165MHz timings to be safe */
203 *mcfg = MICRON_V_MCFG_165(128 << 20);
204 *ctrla = MICRON_V_ACTIMA_165;
205 *ctrlb = MICRON_V_ACTIMB_165;
206 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
212 * Routine: get_expansion_id
213 * Description: This function checks for expansion board by checking I2C
214 * bus 1 for the availability of an AT24C01B serial EEPROM.
215 * returns the device_vendor field from the EEPROM
217 static unsigned int get_expansion_id(void)
219 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
221 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
222 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
223 i2c_set_bus_num(TWL4030_I2C_BUS);
224 return BEAGLE_NO_EEPROM;
227 /* read configuration data */
228 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
229 sizeof(expansion_config));
231 i2c_set_bus_num(TWL4030_I2C_BUS);
233 return expansion_config.device_vendor;
236 #ifdef CONFIG_VIDEO_OMAP3
238 * Configure DSS to display background color on DVID
239 * Configure VENC to display color bar on S-Video
241 static void beagle_display_init(void)
243 omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH);
244 switch (get_board_revision()) {
248 omap3_dss_panel_config(&dvid_cfg);
254 omap3_dss_panel_config(&dvid_cfg_xm);
262 static void beagle_dvi_pup(void)
266 switch (get_board_revision()) {
271 gpio_request(170, "");
272 gpio_direction_output(170, 0);
273 gpio_set_value(170, 1);
278 #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
279 #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
281 i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
283 i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
285 i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
287 i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
293 #ifdef CONFIG_USB_MUSB_OMAP2PLUS
294 static struct musb_hdrc_config musb_config = {
301 static struct omap_musb_board_data musb_board_data = {
302 .interface_type = MUSB_INTERFACE_ULPI,
305 static struct musb_hdrc_platform_data musb_plat = {
306 #if defined(CONFIG_MUSB_HOST)
308 #elif defined(CONFIG_MUSB_GADGET)
309 .mode = MUSB_PERIPHERAL,
311 #error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET"
313 .config = &musb_config,
315 .platform_ops = &omap2430_ops,
316 .board_data = &musb_board_data,
321 * Routine: misc_init_r
322 * Description: Configure board specific parts
324 int misc_init_r(void)
326 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
327 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
328 struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
330 /* Enable i2c2 pullup resisters */
331 writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
333 switch (get_board_revision()) {
335 printf("Beagle Rev Ax/Bx\n");
336 setenv("beaglerev", "AxBx");
339 printf("Beagle Rev C1/C2/C3\n");
340 setenv("beaglerev", "Cx");
344 printf("Beagle Rev C4\n");
345 setenv("beaglerev", "C4");
347 /* Set VAUX2 to 1.8V for EHCI PHY */
348 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
349 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
350 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
351 TWL4030_PM_RECEIVER_DEV_GRP_P1);
354 printf("Beagle xM Rev A\n");
355 setenv("beaglerev", "xMA");
357 /* Set VAUX2 to 1.8V for EHCI PHY */
358 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
359 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
360 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
361 TWL4030_PM_RECEIVER_DEV_GRP_P1);
364 printf("Beagle xM Rev B\n");
365 setenv("beaglerev", "xMB");
367 /* Set VAUX2 to 1.8V for EHCI PHY */
368 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
369 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
370 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
371 TWL4030_PM_RECEIVER_DEV_GRP_P1);
374 printf("Beagle xM Rev C\n");
375 setenv("beaglerev", "xMC");
377 /* Set VAUX2 to 1.8V for EHCI PHY */
378 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
379 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
380 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
381 TWL4030_PM_RECEIVER_DEV_GRP_P1);
384 printf("Beagle unknown 0x%02x\n", get_board_revision());
386 /* Set VAUX2 to 1.8V for EHCI PHY */
387 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
388 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
389 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
390 TWL4030_PM_RECEIVER_DEV_GRP_P1);
393 switch (get_expansion_id()) {
394 case TINCANTOOLS_ZIPPY:
395 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
396 expansion_config.revision,
397 expansion_config.fab_revision);
398 MUX_TINCANTOOLS_ZIPPY();
399 setenv("buddy", "zippy");
401 case TINCANTOOLS_ZIPPY2:
402 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
403 expansion_config.revision,
404 expansion_config.fab_revision);
405 MUX_TINCANTOOLS_ZIPPY();
406 setenv("buddy", "zippy2");
408 case TINCANTOOLS_TRAINER:
409 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
410 expansion_config.revision,
411 expansion_config.fab_revision);
412 MUX_TINCANTOOLS_ZIPPY();
413 MUX_TINCANTOOLS_TRAINER();
414 setenv("buddy", "trainer");
416 case TINCANTOOLS_SHOWDOG:
417 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
418 expansion_config.revision,
419 expansion_config.fab_revision);
420 /* Place holder for DSS2 definition for showdog lcd */
421 setenv("defaultdisplay", "showdoglcd");
422 setenv("buddy", "showdog");
424 case KBADC_BEAGLEFPGA:
425 printf("Recognized KBADC Beagle FPGA board\n");
426 MUX_KBADC_BEAGLEFPGA();
427 setenv("buddy", "beaglefpga");
430 printf("Recognized Liquidware BeagleTouch board\n");
431 setenv("buddy", "beagletouch");
434 printf("Recognized Brainmux LCDog board\n");
435 setenv("buddy", "lcdog");
437 case BRAINMUX_LCDOGTOUCH:
438 printf("Recognized Brainmux LCDog Touch board\n");
439 setenv("buddy", "lcdogtouch");
442 printf("Recognized BeagleBoardToys WiFi board\n");
444 setenv("buddy", "bbtoys-wifi");
447 printf("Recognized BeagleBoardToys VGA board\n");
450 printf("Recognized BeagleBoardToys LCD board\n");
453 printf("Recognized bct electronic GmbH brettl3 board\n");
456 printf("Recognized bct electronic GmbH brettl4 board\n");
458 case BEAGLE_NO_EEPROM:
459 printf("No EEPROM on expansion board\n");
460 setenv("buddy", "none");
463 printf("Unrecognized expansion board: %x\n",
464 expansion_config.device_vendor);
465 setenv("buddy", "unknown");
468 if (expansion_config.content == 1)
469 setenv(expansion_config.env_var, expansion_config.env_setting);
471 twl4030_power_init();
472 switch (get_board_revision()) {
475 twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
478 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
482 /* Set GPIO states before they are made outputs */
483 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
484 &gpio6_base->setdataout);
485 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
486 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
488 /* Configure GPIOs to output */
489 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
490 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
491 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
495 #ifdef CONFIG_VIDEO_OMAP3
497 beagle_display_init();
501 #ifdef CONFIG_USB_MUSB_OMAP2PLUS
502 musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
509 * Routine: set_muxconf_regs
510 * Description: Setting up the configuration Mux registers specific to the
511 * hardware. Many pins need to be moved from protect to primary
514 void set_muxconf_regs(void)
519 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
520 int board_mmc_init(bd_t *bis)
522 omap_mmc_init(0, 0, 0);
527 #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
528 /* Call usb_stop() before starting the kernel */
529 void show_boot_progress(int val)
531 if (val == BOOTSTAGE_ID_RUN_OS)
535 static struct omap_usbhs_board_data usbhs_bdata = {
536 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
537 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
538 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
541 int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
543 return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
546 int ehci_hcd_stop(int index)
548 return omap_ehci_hcd_stop();
551 #endif /* CONFIG_USB_EHCI */
553 #if defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)
554 int board_eth_init(bd_t *bis)
556 return usb_eth_initialize(bis);