]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
MdeModulePkg UhciPei: Remove redundant functions
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.c
index 603d367ec5aa85d0d2f6489fb5bb121e8801c5f8..30ad2b2ffeef5304b44b5ca46831a243f3a9fb02 100644 (file)
@@ -1,17 +1,17 @@
-/** @file  \r
+/** @file\r
   The Ehci controller driver.\r
 \r
-  EhciDxe driver is responsible for managing the behavior of EHCI controller. \r
-  It implements the interfaces of monitoring the status of all ports and transferring \r
+  EhciDxe driver is responsible for managing the behavior of EHCI controller.\r
+  It implements the interfaces of monitoring the status of all ports and transferring\r
   Control, Bulk, Interrupt and Isochronous requests to Usb2.0 device.\r
 \r
   Note that EhciDxe driver is enhanced to guarantee that the EHCI controller get attached\r
-  to the EHCI controller before a UHCI or OHCI driver attaches to the companion UHCI or \r
-  OHCI controller.  This way avoids the control transfer on a shared port between EHCI \r
-  and companion host controller when UHCI or OHCI gets attached earlier than EHCI and a \r
+  to the EHCI controller before a UHCI or OHCI driver attaches to the companion UHCI or\r
+  OHCI controller.  This way avoids the control transfer on a shared port between EHCI\r
+  and companion host controller when UHCI or OHCI gets attached earlier than EHCI and a\r
   USB 2.0 device inserts.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -89,7 +89,7 @@ EhcGetCapability (
 \r
   *MaxSpeed       = EFI_USB_SPEED_HIGH;\r
   *PortNumber     = (UINT8) (Ehc->HcStructParams & HCSP_NPORTS);\r
-  *Is64BitCapable = (UINT8) (Ehc->HcCapParams & HCCP_64BIT);\r
+  *Is64BitCapable = (UINT8) Ehc->Support64BitDma;\r
 \r
   DEBUG ((EFI_D_INFO, "EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable));\r
 \r
@@ -1159,10 +1159,6 @@ EhcSyncInterruptTransfer (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (!EHCI_IS_DATAIN (EndPointAddress)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
   if ((*DataToggle != 1) && (*DataToggle != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -1224,6 +1220,7 @@ EhcSyncInterruptTransfer (
     Status = EFI_SUCCESS;\r
   }\r
 \r
+  EhcFreeUrb (Ehc, Urb);\r
 ON_EXIT:\r
   Ehc->PciIo->Flush (Ehc->PciIo);\r
   gBS->RestoreTPL (OldTpl);\r
@@ -1611,7 +1608,7 @@ EhcCreateUsb2Hc (
     gBS->FreePool (Ehc);\r
     return NULL;\r
   }\r
-  \r
+\r
   EhcGetUsbDebugPortInfo (Ehc);\r
 \r
   //\r
@@ -1619,7 +1616,7 @@ EhcCreateUsb2Hc (
   //\r
   Status = gBS->CreateEvent (\r
                   EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
+                  TPL_NOTIFY,\r
                   EhcMonitorAsyncRequests,\r
                   Ehc,\r
                   &Ehc->PollTimer\r
@@ -1754,7 +1751,7 @@ EhcDriverBindingStart (
                     &Supports\r
                     );\r
   if (!EFI_ERROR (Status)) {\r
-    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
     Status = PciIo->Attributes (\r
                       PciIo,\r
                       EfiPciIoAttributeOperationEnable,\r
@@ -1784,12 +1781,12 @@ EhcDriverBindingStart (
     goto CLOSE_PCIIO;\r
   }\r
   //\r
-  // Determine if the device is UHCI or OHCI host controller or not. If yes, then find out the \r
+  // Determine if the device is UHCI or OHCI host controller or not. If yes, then find out the\r
   // companion usb ehci host controller and force EHCI driver get attached to it before\r
   // UHCI or OHCI driver attaches to UHCI or OHCI host controller.\r
   //\r
   if ((UsbClassCReg.ProgInterface == PCI_IF_UHCI || UsbClassCReg.ProgInterface == PCI_IF_OHCI) &&\r
-       (UsbClassCReg.BaseCode == PCI_CLASS_SERIAL) && \r
+       (UsbClassCReg.BaseCode == PCI_CLASS_SERIAL) &&\r
        (UsbClassCReg.SubClassCode == PCI_CLASS_SERIAL_USB)) {\r
     Status = PciIo->GetLocation (\r
                     PciIo,\r
@@ -1838,7 +1835,7 @@ EhcDriverBindingStart (
       }\r
 \r
       if ((UsbClassCReg.ProgInterface == PCI_IF_EHCI) &&\r
-           (UsbClassCReg.BaseCode == PCI_CLASS_SERIAL) && \r
+           (UsbClassCReg.BaseCode == PCI_CLASS_SERIAL) &&\r
            (UsbClassCReg.SubClassCode == PCI_CLASS_SERIAL_USB)) {\r
         Status = Instance->GetLocation (\r
                     Instance,\r
@@ -1881,6 +1878,26 @@ EhcDriverBindingStart (
     goto CLOSE_PCIIO;\r
   }\r
 \r
+  //\r
+  // Enable 64-bit DMA support in the PCI layer if this controller\r
+  // supports it.\r
+  //\r
+  if (EHC_BIT_IS_SET (Ehc->HcCapParams, HCCP_64BIT)) {\r
+    Status = PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationEnable,\r
+                      EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE,\r
+                      NULL\r
+                      );\r
+    if (!EFI_ERROR (Status)) {\r
+      Ehc->Support64BitDma = TRUE;\r
+    } else {\r
+      DEBUG ((EFI_D_WARN,\r
+        "%a: failed to enable 64-bit DMA on 64-bit capable controller @ %p (%r)\n",\r
+        __FUNCTION__, Controller, Status));\r
+    }\r
+  }\r
+\r
   Status = gBS->InstallProtocolInterface (\r
                   &Controller,\r
                   &gEfiUsb2HcProtocolGuid,\r
@@ -2002,7 +2019,7 @@ CLOSE_PCIIO:
 \r
 \r
 /**\r
-  Stop this driver on ControllerHandle. Support stoping any child handles\r
+  Stop this driver on ControllerHandle. Support stopping any child handles\r
   created by this driver.\r
 \r
   @param  This                 Protocol instance pointer.\r
@@ -2081,7 +2098,7 @@ EhcDriverBindingStop (
   }\r
 \r
   //\r
-  // Disable routing of all ports to EHCI controller, so all ports are \r
+  // Disable routing of all ports to EHCI controller, so all ports are\r
   // routed back to the UHCI or OHCI controller.\r
   //\r
   EhcClearOpRegBit (Ehc, EHC_CONFIG_FLAG_OFFSET, CONFIGFLAG_ROUTE_EHC);\r