From 3666a86b4f779f93a780c76a926b4eb46951da00 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Fri, 18 Sep 2009 21:41:13 +0200 Subject: [PATCH] some roothub stuff added. TD transfer without errors, w00t! --- main.c | 2 -- usb/host/ohci.c | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index d69bb40..bbb7d39 100644 --- a/main.c +++ b/main.c @@ -121,8 +121,6 @@ int main(void) printf("bye, world!\n"); */ - (void) usb_add_device(); - while(1) { // just to get sure we are still in this loop //_CPU_ISR_Enable() // don't know why this is needed... diff --git a/usb/host/ohci.c b/usb/host/ohci.c index 5e41bb6..801720d 100644 --- a/usb/host/ohci.c +++ b/usb/host/ohci.c @@ -393,11 +393,45 @@ void hcdi_irq() if (flags & OHCI_INTR_RHSC) { printf("RootHubStatusChange\n"); /* TODO: set some next_statechange variable... */ + u32 port1 = read32(OHCI0_HC_RH_PORT_STATUS_1); + u32 port2 = read32(OHCI0_HC_RH_PORT_STATUS_2); printf("OHCI0_HC_RH_DESCRIPTOR_A:\t0x%08X\n", read32(OHCI0_HC_RH_DESCRIPTOR_A)); printf("OHCI0_HC_RH_DESCRIPTOR_B:\t0x%08X\n", read32(OHCI0_HC_RH_DESCRIPTOR_B)); printf("OHCI0_HC_RH_STATUS:\t\t0x%08X\n", read32(OHCI0_HC_RH_STATUS)); - printf("OHCI0_HC_RH_PORT_STATUS_1:\t0x%08X\n", read32(OHCI0_HC_RH_PORT_STATUS_1)); - printf("OHCI0_HC_RH_PORT_STATUS_2:\t0x%08X\n", read32(OHCI0_HC_RH_PORT_STATUS_2)); + printf("OHCI0_HC_RH_PORT_STATUS_1:\t0x%08X\n", port1); + printf("OHCI0_HC_RH_PORT_STATUS_2:\t0x%08X\n", port2); + + if((port1 & RH_PS_CCS) && (port1 & RH_PS_CSC)) { + wait_ms(100); + + /* clear CSC flag, set PES and start port reset (PRS) */ + write32(OHCI0_HC_RH_PORT_STATUS_1, port1 | RH_PS_CSC | RH_PS_PES | RH_PS_PRS); + + /* spin until port reset is complete */ + port1 = read32(OHCI0_HC_RH_PORT_STATUS_1); + while(!(port1 & RH_PS_PRSC)) { + udelay(2); + port1 = read32(OHCI0_HC_RH_PORT_STATUS_1); + } + + (void) usb_add_device(); + } + if((port2 & RH_PS_CCS) && (port2 & RH_PS_CSC)) { + wait_ms(100); + + /* clear CSC flag, set PES and start port reset (PRS) */ + write32(OHCI0_HC_RH_PORT_STATUS_2, port2 | RH_PS_CSC | RH_PS_PES | RH_PS_PRS); + + /* spin until port reset is complete */ + port2 = read32(OHCI0_HC_RH_PORT_STATUS_2); + while(!(port2 & RH_PS_PRSC)) { + udelay(2); + port2 = read32(OHCI0_HC_RH_PORT_STATUS_2); + } + + (void) usb_add_device(); + } + write32(OHCI0_HC_INT_STATUS, OHCI_INTR_RD | OHCI_INTR_RHSC); } /* ResumeDetected */ -- 2.25.1