--- trunk/reactos/drivers/usb/cromwell/host/ohci-hcd.c 2005-07-19 14:06:19 UTC (rev 16643)
+++ trunk/reactos/drivers/usb/cromwell/host/ohci-hcd.c 2005-07-19 14:11:53 UTC (rev 16644)
@@ -391,21 +391,35 @@
static int hc_reset (struct ohci_hcd *ohci)
{
u32 temp;
- u32 ints;
- u32 control;
-
- /* Disable HC interrupts */
- writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
- // acknowledge all pending interrupts
- ints = readl(&ohci->regs->intrstatus);
- writel (ints, &ohci->regs->intrstatus);
+ /* 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) {
- // 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 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);
+
ohci_dbg (ohci, "USB HC reset_hc %s: ctrl = 0x%x ;\n",
hcd_to_bus (&ohci->hcd)->bus_name,
readl (&ohci->regs->control));
@@ -615,27 +629,17 @@
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,
--- trunk/reactos/drivers/usb/cromwell/host/ohci_main.c 2005-07-19 14:06:19 UTC (rev 16643)
+++ trunk/reactos/drivers/usb/cromwell/host/ohci_main.c 2005-07-19 14:11:53 UTC (rev 16644)
@@ -131,14 +131,16 @@
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");