don't init USB unconditionally
authorGrazvydas Ignotas <notasas@gmail.com>
Thu, 17 Jun 2010 21:33:32 +0000 (00:33 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Thu, 17 Jun 2010 21:33:32 +0000 (00:33 +0300)
Since USB init takes time, and only few users will use this feature,
start it only when selected from menu or newly introduced 'usbinit'
command is issued.

board/pandora/menu.c
common/stdio.c

index 38cad6d..bd5a8d8 100644 (file)
@@ -70,6 +70,7 @@ static int menu_do_poweroff(struct menu_item *item)
 
 static int menu_do_usb_serial(struct menu_item *item)
 {
+       do_cmd("usbinit");
        printf("Switched to USB serial.\n");
 
        setenv("stdout", "usbtty");
@@ -242,7 +243,7 @@ U_BOOT_CMD(
        ""
 );
 
-/* helper */
+/* helpers */
 static int do_ssource(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
        ulong addr;
@@ -261,3 +262,20 @@ U_BOOT_CMD(
        "run script from memory (no header)",
        "<addr>"
 );
+
+static int do_usbinit(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+       extern int drv_usbtty_init(void);
+       static int usbinit_done;
+       if (!usbinit_done) {
+               usbinit_done = 1;
+               return !drv_usbtty_init();
+       }
+       return 0;
+}
+
+U_BOOT_CMD(
+       usbinit, 1, 0, do_usbinit,
+       "initialize USB",
+       ""
+);
index 870ddfd..bf84a58 100644 (file)
@@ -239,8 +239,11 @@ int stdio_init (void)
        serial_stdio_init ();
 #endif
 #ifdef CONFIG_USB_TTY
+/* HACK, we only want it to start when selected from menu */
+#ifndef CONFIG_OMAP3_PANDORA
        drv_usbtty_init ();
 #endif
+#endif
 #ifdef CONFIG_NETCONSOLE
        drv_nc_init ();
 #endif