From 188030e196cbb9c3f2486679aae8d5a3671c4453 Mon Sep 17 00:00:00 2001 From: theStack Date: Sat, 5 Sep 2009 02:47:31 +0200 Subject: [PATCH] first adaption of linux ohci irq handler --- ohci.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/ohci.c b/ohci.c index 9e67d12..7e61a8f 100644 --- a/ohci.c +++ b/ohci.c @@ -112,7 +112,55 @@ void ohci_init() void ohci0_irq() { - write32(OHCI0_HC_INT_STATUS, ~0); - printf("ohci_irq\n"); + /* read interrupt status */ + u32 flags = read32(OHCI0_HC_INT_STATUS); + + /* when all bits are set to 1 some problem occured */ + if (flags == 0xffffffff) { + printf("ohci-- Houston, we have a serious problem! :(\n"); + return; + } + + /* only care about interrupts that are enabled */ + flags &= read32(OHCI0_HC_INT_ENABLE); + + /* nothing to do? */ + if (flags == 0) + return; + + printf("OHCI Interrupt occured: "); + /* UnrecoverableError */ + if (flags & OHCI_INTR_UE) { + printf("UnrecoverableError\n"); + /* TODO: well, I don't know... nothing, + * because it won't happen anyway? ;-) */ + } + + /* RootHubStatusChange */ + if (flags & OHCI_INTR_RHSC) { + printf("RootHubStatusChange\n"); + /* TODO: set some next_statechange variable... */ + write32(OHCI0_HC_INT_STATUS, OHCI_INTR_RD | OHCI_INTR_RHSC); + } + /* ResumeDetected */ + else if (flags & OHCI_INTR_RD) { + printf("ResumeDetected\n"); + write32(OHCI0_HC_INT_STATUS, OHCI_INTR_RD); + /* TODO: figure out what the linux kernel does here... */ + } + + /* WritebackDoneHead */ + if (flags & OHCI_INTR_WDH) { + printf("WritebackDoneHead\n"); + /* TODO: figure out what the linux kernel does here... */ + } + + /* TODO: handle any pending URB/ED unlinks... */ + +#define HC_IS_RUNNING() 1 /* dirty, i know... just a temporary solution */ + if (HC_IS_RUNNING()) { + write32(OHCI0_HC_INT_STATUS, flags); + write32(OHCI0_HC_INT_ENABLE, OHCI_INTR_MIE); + } } -- 2.25.1