From a4e0c5d0185b7d715818f5f2d92488585e4e95f9 Mon Sep 17 00:00:00 2001 From: DizzyOfCRN Date: Tue, 19 Aug 2014 11:24:36 +0000 Subject: [PATCH] Works atleast for the case that controller is not OS owned nor BIOS owned, I couldn't get the BIOS to own it. Tested on two different machines. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49487 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/usb/pciusbhc/xhci/pcixhci_controller.c | 33 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/rom/usb/pciusbhc/xhci/pcixhci_controller.c b/rom/usb/pciusbhc/xhci/pcixhci_controller.c index bc70532ecf..c4558ca4f8 100644 --- a/rom/usb/pciusbhc/xhci/pcixhci_controller.c +++ b/rom/usb/pciusbhc/xhci/pcixhci_controller.c @@ -165,37 +165,42 @@ BOOL PCIXHCI_HCInit(struct PCIXHCIUnit *unit) { OOP_SetAttrs(unit->hc.pcidevice, (struct TagItem *)pciActivateMemAndBusmaster); /* Get the host controller from BIOS if possible */ - IPTR cap_legacy = 0; + IPTR cap_legacy; ULONG usblegsup, timeout; cap_legacy = PCIXHCI_SearchExtendedCap(unit, XHCI_EXT_CAPS_LEGACY, (IPTR) NULL); if(cap_legacy) { usblegsup = READREG32(cap_legacy, XHCI_USBLEGSUP); - mybug_unit(-1, ("usblegsup = %08x\n", usblegsup)); - if( (usblegsup & XHCF_BIOSOWNED) ){ - mybug_unit(-1, ("Controller owned by BIOS\n")); + mybug_unit(-1, ("usblegsup1 = %08x\n", usblegsup)); + + /* Check if not OS owned */ + if( ((!(usblegsup & XHCF_OSOWNED)) || (usblegsup & XHCF_BIOSOWNED)) ){ + WRITEMEM32(cap_legacy, (usblegsup|XHCF_OSOWNED)); + + usblegsup = READREG32(cap_legacy, XHCI_USBLEGSUP); + mybug_unit(-1, ("usblegsup2 = %08x\n", usblegsup)); /* Spec says "no more than a second", we give it a little more */ timeout = 250; - WRITEREG32(cap_legacy, XHCI_USBLEGSUP, (usblegsup | XHCF_OSOWNED) ); - do { + while(1) { usblegsup = READREG32(cap_legacy, XHCI_USBLEGSUP); - if(!(usblegsup & XHCF_BIOSOWNED)) { - mybug_unit(-1, ("BIOS gave up on XHCI. Pwned!\n")); + mybug_unit(-1, ("usblegsup3 = %08x\n", usblegsup)); + if( (usblegsup & XHCF_OSOWNED) && (!(usblegsup & XHCF_BIOSOWNED)) ){ break; } + /* Wait 10ms and check again */ PCIXHCI_Delay(unit, 10); - } while(--timeout); - if(!timeout) { - mybug_unit(-1, ("BIOS didn't release XHCI. Forcing and praying...\n")); - WRITEREG32(cap_legacy, XHCI_USBLEGSUP, (usblegsup & ~XHCF_BIOSOWNED) ); + if(--timeout) { + mybug_unit(-1, ("BIOS didn't release XHCI. Forcing and praying...\n")); + WRITEMEM32(cap_legacy, ((usblegsup|XHCF_OSOWNED)&~XHCF_BIOSOWNED)); + break; + } } - } else { - mybug_unit(-1, ("Controller was not owned by BIOS\n")); + mybug_unit(-1, ("Controller is already owned by the OS\n")); } } -- 2.11.4.GIT