From f17e655c2219857565705aa5c939fc12b9857efb Mon Sep 17 00:00:00 2001 From: Gerd Zellweger Date: Mon, 8 Dec 2014 18:11:10 +0100 Subject: [PATCH] Fix the USB code that was destroying my shell. Writing random ASCII character in general is not a good idea. Now I write a space/backspace combination which at least does not set my shell to 'garbage output mode'. The whole thing is suboptimal as we don't want USB set-up code in the kernel and we don't want to do waiting using printf. We should really re-write those wait functions to use deferred events... --- include/usb/usb.h | 2 +- kernel/arch/omap44xx/init.c | 10 ++++++---- usr/drivers/usb/usb_manager/usb_manager.c | 3 --- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/usb/usb.h b/include/usb/usb.h index 5e25f9f..9406350 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -122,7 +122,7 @@ typedef struct usb_status usb_status_t; #define USB_DELAY_RECOVERY 10 #define USB_WAIT(ms) \ - for (uint32_t wait_i = 0; wait_i < 4*(ms); wait_i++) {printf("%c", 0xE);}; + for (uint32_t wait_i = 0; wait_i < 2*(ms); wait_i++) { printf("%c", 0x20); printf("%c", 0x08); }; /* diff --git a/kernel/arch/omap44xx/init.c b/kernel/arch/omap44xx/init.c index 2f804c4..7325bae 100644 --- a/kernel/arch/omap44xx/init.c +++ b/kernel/arch/omap44xx/init.c @@ -476,8 +476,9 @@ static void usb_power_on(void) &sysctrl_padconf_core_base, gpio62_mux); /* delay to give the hardware time to reset TODO: propper delay*/ - for (int j = 0; j < 4000; j++) { - printf("%c", 0xE); + for (int j = 0; j < 2000; j++) { + printf("%c", 0x20); + printf("%c", 0x08); } hsusb_init(); @@ -490,8 +491,9 @@ static void usb_power_on(void) /* enable the USB HUB */ omap44xx_gpio_setdataout_wr(&gpio_2_base, (1UL << HSUSB_HUB_RESET)); - for (int j = 0; j < 4000; j++) { - printf("%c", 0xE); + for (int j = 0; j < 2000; j++) { + printf("%c", 0x20); + printf("%c", 0x08); } printf(" > performing softreset on the USB PHY\n"); diff --git a/usr/drivers/usb/usb_manager/usb_manager.c b/usr/drivers/usb/usb_manager/usb_manager.c index 89bfd49..187b8b3 100644 --- a/usr/drivers/usb/usb_manager/usb_manager.c +++ b/usr/drivers/usb/usb_manager/usb_manager.c @@ -346,8 +346,6 @@ static usb_error_t pandaboard_checkup(uintptr_t base, int argc, char *argv[]) /* wait till the request is done */ while (*((volatile uint32_t*) (tmp + 0x00A4)) & (1 << 31)) { - printf("%c", 0xE); - } /* compare the result */ @@ -366,7 +364,6 @@ static usb_error_t pandaboard_checkup(uintptr_t base, int argc, char *argv[]) /* wait till request is done */ while (*((volatile uint32_t*) (tmp + 0x00A4)) & (1 << 31)) { - printf("%c", 0xE); } /* compare the values */ -- 1.7.2.5