From 4e94521b41d20fca6c57c110b2641f5a06142b67 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 19 Jul 2005 14:11:53 +0000 Subject: [PATCH] usb stack "upgrade", fixes issues with timing, host controller reset, new devices discovery, other small things (better to see diff :) ). svn path=/trunk/; revision=16644 --- reactos/drivers/usb/cromwell/host/ohci-hcd.c | 52 ++++++++++--------- reactos/drivers/usb/cromwell/host/ohci_main.c | 8 +-- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/reactos/drivers/usb/cromwell/host/ohci-hcd.c b/reactos/drivers/usb/cromwell/host/ohci-hcd.c index ecaacddc653..ef1a8b5cad7 100644 --- a/reactos/drivers/usb/cromwell/host/ohci-hcd.c +++ b/reactos/drivers/usb/cromwell/host/ohci-hcd.c @@ -391,20 +391,34 @@ static int ohci_get_frame (struct usb_hcd *hcd) static int hc_reset (struct ohci_hcd *ohci) { u32 temp; - u32 ints; - u32 control; - + + /* SMM owns the HC? not for long! + * On PA-RISC, PDC can leave IR set incorrectly; ignore it there. + */ +#ifndef __hppa__ + if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { + ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n"); + + /* this timeout is arbitrary. we make it long, so systems + * depending on usb keyboards may be usable even if the + * BIOS/SMM code seems pretty broken. + */ + temp = 500; /* arbitrary: five seconds */ + + writel (OHCI_INTR_OC, &ohci->regs->intrenable); + writel (OHCI_OCR, &ohci->regs->cmdstatus); + while (readl (&ohci->regs->control) & OHCI_CTRL_IR) { + wait_ms (10); + if (--temp == 0) { + ohci_err (ohci, "USB HC TakeOver failed!\n"); + return -1; + } + } + } +#endif + /* Disable HC interrupts */ writel (OHCI_INTR_MIE, &ohci->regs->intrdisable); - // acknowledge all pending interrupts - ints = readl(&ohci->regs->intrstatus); - writel (ints, &ohci->regs->intrstatus); - - if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { - // takeover without negotiation - there is noone to negotiate with - control = readl (&ohci->regs->control) & ~OHCI_CTRL_IR; - writel (control, &ohci->regs->control); - } ohci_dbg (ohci, "USB HC reset_hc %s: ctrl = 0x%x ;\n", hcd_to_bus (&ohci->hcd)->bus_name, @@ -615,27 +629,17 @@ int ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs) static void ohci_stop (struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); - struct ohci_regs *regs = ohci->regs; - int ints; ohci_dbg (ohci, "stop %s controller%s\n", hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS), ohci->disabled ? " (disabled)" : "" ); - ohci_dump (ohci, 1); + //ohci_dump (ohci, 1); if (!ohci->disabled) hc_reset (ohci); - - // Disable all interrupts - writel (OHCI_INTR_MIE, ®s->intrdisable); - // acknowledge all pending interrupts - ints = readl(®s->intrstatus); - writel (ints, ®s->intrstatus); - // flush register writes - (void) readl (&ohci->regs->control); - remove_debug_files (ohci); + //remove_debug_files (ohci); ohci_mem_cleanup (ohci); if (ohci->hcca) { pci_free_consistent (ohci->hcd.pdev, sizeof *ohci->hcca, diff --git a/reactos/drivers/usb/cromwell/host/ohci_main.c b/reactos/drivers/usb/cromwell/host/ohci_main.c index 407aacf3064..3a7150997da 100644 --- a/reactos/drivers/usb/cromwell/host/ohci_main.c +++ b/reactos/drivers/usb/cromwell/host/ohci_main.c @@ -131,14 +131,16 @@ InitLinuxWrapper(PDEVICE_OBJECT DeviceObject) NTSTATUS Status; POHCI_DEVICE_EXTENSION DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - // Fill generic linux structs + // Allocate and fill generic linux structs dev = ExAllocatePoolWithTag(PagedPool, sizeof(struct pci_dev), USB_OHCI_TAG); - - init_wrapper(dev); dev->irq = DeviceExtension->InterruptVector; dev->dev_ext = (PVOID)DeviceExtension; + dev->dev.dev_ext = (PVOID)DeviceExtension; dev->slot_name = ExAllocatePoolWithTag(NonPagedPool, 128, USB_OHCI_TAG); // 128 max len for slot name + // Init wrapper + init_wrapper(dev); + strcpy(dev->dev.name, "OpenHCI PCI-USB Controller"); strcpy(dev->slot_name, "OHCD PCI Slot");