Merge branch 'master' of git://git.denx.de/u-boot-arm
[oweals/u-boot.git] / board / ti / beagle / beagle.c
index 624ff70d86402dd97bddae2f529391d3c53a0054..e26b38793474bf073c455d472eabf26c22a67c9f 100644 (file)
 #include "beagle.h"
 #include <command.h>
 
+#ifdef CONFIG_USB_EHCI
+#include <usb.h>
+#include <asm/ehci-omap.h>
+#endif
+
 #define pr_debug(fmt, args...) debug(fmt, ##args)
 
 #define TWL4030_I2C_BUS                        0
@@ -246,6 +251,39 @@ void beagle_display_init(void)
        }
 }
 
+/*
+ * Enable DVI power
+ */
+static void beagle_dvi_pup(void)
+{
+       uchar val;
+
+       switch (get_board_revision()) {
+       case REVISION_AXBX:
+       case REVISION_CX:
+       case REVISION_C4:
+       case REVISION_XM_A:
+               gpio_request(170, "");
+               gpio_direction_output(170, 0);
+               gpio_set_value(170, 1);
+               break;
+       case REVISION_XM_B:
+       case REVISION_XM_C:
+       default:
+               #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
+               #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
+
+               i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
+               val |= 4;
+               i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
+
+               i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
+               val |= 4;
+               i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
+               break;
+       }
+}
+
 /*
  * Routine: misc_init_r
  * Description: Configure board specific parts
@@ -417,6 +455,8 @@ int misc_init_r(void)
                GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
 
        dieid_num_r();
+
+       beagle_dvi_pup();
        beagle_display_init();
        omap3_dss_enable();
 
@@ -446,62 +486,24 @@ int board_mmc_init(bd_t *bis)
 /* Call usb_stop() before starting the kernel */
 void show_boot_progress(int val)
 {
-       if(val == 15)
+       if (val == BOOTSTAGE_ID_RUN_OS)
                usb_stop();
 }
-#endif /* CONFIG_USB_EHCI */
 
-#ifndef CONFIG_SPL_BUILD
-/*
- * This command returns the status of the user button on beagle xM
- * Input - none
- * Returns -   1 if button is held down
- *             0 if button is not held down
- */
-int do_userbutton(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-       int     button = 0;
-       int     gpio;
-
-       /*
-        * pass address parameter as argv[0] (aka command name),
-        * and all remaining args
-        */
-       switch (get_board_revision()) {
-       case REVISION_AXBX:
-       case REVISION_CX:
-       case REVISION_C4:
-               gpio = 7;
-               break;
-       case REVISION_XM_A:
-       case REVISION_XM_B:
-       case REVISION_XM_C:
-       default:
-               gpio = 4;
-               break;
-       }
-       gpio_request(gpio, "");
-       gpio_direction_input(gpio);
-       printf("The user button is currently ");
-       if (gpio_get_value(gpio))
-       {
-               button = 1;
-               printf("PRESSED.\n");
-       }
-       else
-       {
-               button = 0;
-               printf("NOT pressed.\n");
-       }
+static struct omap_usbhs_board_data usbhs_bdata = {
+       .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
+       .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
+       .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
+};
 
-       return !button;
+int ehci_hcd_init(void)
+{
+       return omap_ehci_hcd_init(&usbhs_bdata);
 }
 
-/* -------------------------------------------------------------------- */
+int ehci_hcd_stop(void)
+{
+       return omap_ehci_hcd_stop();
+}
 
-U_BOOT_CMD(
-       userbutton, CONFIG_SYS_MAXARGS, 1,      do_userbutton,
-       "Return the status of the BeagleBoard USER button",
-       ""
-);
-#endif
+#endif /* CONFIG_USB_EHCI */