Skip to contentSkip to conversation

USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

PATCH New Allen Martin 5 participants 10 messages Dec 22, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

This allows systems to pause autoboot with USB keyboard. Tested on tegra2 seaboard.

---
 README               |    5 +++++
 arch/arm/lib/board.c |    9 +++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
README +5 -0
index 882483b..40e8481 100644
@@ -1132,6 +1132,11 @@ The following options need to be configured:
 		CONFIG_USB_EHCI_TXFIFO_THRESH enables setting of the
 		txfilltuning field in the EHCI controller on reset.
 
+		CONFIG_USB_INIT causes USB to be initialized
+		automatically before the main command loop.  This is
+		useful if you have a USB keyboard and you want to use
+		it to stop autoboot.
+
 - USB Device:
 		Define the below if you wish to use the USB console.
 		Once firmware is rebuilt from a serial console issue the
arch/arm/lib/board.c +9 -0
index 3d78274..6787048 100644
@@ -64,6 +64,10 @@
 #include "../drivers/net/lan91c96.h"
 #endif
 
+#ifdef CONFIG_USB_INIT
+#include <usb.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
@@ -548,6 +552,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	api_init();
 #endif
 
+#ifdef CONFIG_USB_INIT
+	/* this needs to be before console init for USB kbd to work as stdin */
+	usb_init();
+#endif
+
 	console_init_r();	/* fully init console as a device */
 
 #if defined(CONFIG_ARCH_MISC_INIT)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

Quoted 4 lines

This allows systems to pause autoboot with USB keyboard. Tested on tegra2 seaboard.

Can't you just add "usb reset" to preboot env?

M

Quoted 48 lines
---
 README               |    5 +++++
 arch/arm/lib/board.c |    9 +++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
README +5 -0
index 882483b..40e8481 100644
@@ -1132,6 +1132,11 @@ The following options need to be configured:
 		CONFIG_USB_EHCI_TXFIFO_THRESH enables setting of the
 		txfilltuning field in the EHCI controller on reset.
 
+		CONFIG_USB_INIT causes USB to be initialized
+		automatically before the main command loop.  This is
+		useful if you have a USB keyboard and you want to use
+		it to stop autoboot.
+
 - USB Device:
 		Define the below if you wish to use the USB console.
 		Once firmware is rebuilt from a serial console issue the
arch/arm/lib/board.c +9 -0
index 3d78274..6787048 100644
@@ -64,6 +64,10 @@
 #include "../drivers/net/lan91c96.h"
 #endif
 
+#ifdef CONFIG_USB_INIT
+#include <usb.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
@@ -548,6 +552,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	api_init();
 #endif
 
+#ifdef CONFIG_USB_INIT
+	/* this needs to be before console init for USB kbd to work as stdin */
+	usb_init();
+#endif
+
 	console_init_r();	/* fully init console as a device */
 
 #if defined(CONFIG_ARCH_MISC_INIT)
#2 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

Quoted 6 lines
Quoted 4 lines

This allows systems to pause autoboot with USB keyboard. Tested on tegra2 seaboard.

Can't you just add "usb reset" to preboot env?

The point is to be able to use USB keyboard to stop autoboot on systems where USB keyboard is the primary (or only) input device. This needs to happen before BOOTCOMMAND gets parsed.

-Allen
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

#3 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

--
Curious about my work on the Debian powerpcspe port? I'm keeping a blog here: http://pureperl.blogspot.com/

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines

This allows systems to pause autoboot with USB keyboard. Tested on tegra2 seaboard.

Can't you just add "usb reset" to preboot env?

The point is to be able to use USB keyboard to stop autoboot on systems where USB keyboard is the primary (or only) input device. This needs to happen before BOOTCOMMAND gets parsed.

I think the "preboot" environment variable already *is* run before starting the autoboot timer?

Cheers,
Kyle Moffett

#4 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

Quoted 9 lines

--
Curious about my work on the Debian powerpcspe port? I'm keeping a blog here: http://pureperl.blogspot.com/

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

This allows systems to pause autoboot with USB keyboard. Tested on tegra2 seaboard.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Can't you just add "usb reset" to preboot env?

The point is to be able to use USB keyboard to stop autoboot on systems where USB keyboard is the primary (or only) input device. This needs to happen before BOOTCOMMAND gets parsed.

I think the "preboot" environment variable already *is* run before starting the autoboot timer?

Yep.

M

#5 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Can't you just add "usb reset" to preboot env?

The point is to be able to use USB keyboard to stop autoboot on systems where USB keyboard is the primary (or only) input device. This needs to happen before BOOTCOMMAND gets parsed.

I think the "preboot" environment variable already *is* run before starting the autoboot timer?

Yep.

I also had to stick it before console init because console makes decisions about the input device based on what's been registered when it initializes (at least with iomux turned on, I didn't try it without).

Maybe a better fix is to have console reevaluate things when the usb keyboard driver registers itself? I'm open to suggestions.

-Allen
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

#6 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

The point is to be able to use USB keyboard to stop autoboot on systems where USB keyboard is the primary (or only) input device. This needs to happen before BOOTCOMMAND gets parsed.

I think the "preboot" environment variable already *is* run before starting the autoboot timer?

Yep.

Quoted 6 lines

I also had to stick it before console init because console makes decisions about the input device based on what's been registered when it initializes (at least with iomux turned on, I didn't try it without).

Maybe a better fix is to have console reevaluate things when the usb keyboard driver registers itself? I'm open to suggestions.

I don't fully grok how console/stdin gets assigned, but is this possibly the problem? (from drv_usb_kbd_init()):

                /* Check if this is the standard input device. */
                if (strcmp(stdinname, DEVNAME))
                        return 1;

                /* Reassign the console */
                if (overwrite_console())
                        return 1;

                error = console_assign(stdin, DEVNAME);

This seems incompatible with iomux, shouldn't these decisions be made in the console driver? In my case, stdin is set to "serial,tegra-kbc,usbkbd" so this strcmp won't match.

-Allen
nvpublic

#7 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

Dear Allen Martin,

Quoted 14 lines · In message <[email protected]>…

I don't fully grok how console/stdin gets assigned, but is this possibly the problem? (from drv_usb_kbd_init()):

                /* Check if this is the standard input device. */
                if (strcmp(stdinname, DEVNAME))
                        return 1;

                /* Reassign the console */
                if (overwrite_console())
                        return 1;

                error = console_assign(stdin, DEVNAME);
Quoted 3 lines

This seems incompatible with iomux, shouldn't these decisions be made in the console driver? In my case, stdin is set to "serial,tegra-kbc,usbkbd" so this strcmp won't match.

Indeed, this code predates the iomux implementation, and nobody noticed yet that it needs fixing.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
They're usually so busy thinking about what  happens  next  that  the
only  time they ever find out what is happening now is when they come
to look back on it.                 - Terry Pratchett, _Wyrd Sisters_
#8 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

In reply to Allen Martin

Dear Allen Martin,

Quoted 8 lines · In message <[email protected]> you wrote:

This allows systems to pause autoboot with USB keyboard. Tested on tegra2 seaboard.

---
 README               |    5 +++++
 arch/arm/lib/board.c |    9 +++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

This modification is in no way ARM specific, so if we accept it, it must be applied to all supported architectures.

Where exacly is this feature nneded? You don;t enable it in any of the board configurations...

Also, should we then not auto-enable this if CONFIG_USB_KEYBOARD is set?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I can type faster than I can move a  mouse,  so  I  find  menu-driven
drawing packages time consuming and frustrating.      - W. R. Stevens
#9 lore raw

PATCH 1/1 USB: add CONFIG_USB_INIT to autoinitialize USB before main_loop

Hi Wolfgang,

Quoted 12 lines · Wolfgang Denk

Dear Allen Martin,

Quoted 8 lines · In message <[email protected]> you wrote:

This allows systems to pause autoboot with USB keyboard. Tested on tegra2 seaboard.

---
 README               |    5 +++++
 arch/arm/lib/board.c |    9 +++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
Quoted 8 lines

This modification is in no way ARM specific, so if we accept it, it must be applied to all supported architectures.

Where exacly is this feature nneded? You don;t enable it in any of the board configurations...

Also, should we then not auto-enable this if CONFIG_USB_KEYBOARD is set?

Right, IMHO, there is no need for a new config option - just make the USB init depend on CONFIG_USB_KEYBOARD.

Signature · 2 lines
Regards,
Igor.