]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/UhciDxe/Uhci.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / Uhci.h
index 27d7497b879288c275a4a30e90bf6eb109c13d74..882f5e55ea1c46d8dbf1ccff220e79df6662bb9a 100644 (file)
@@ -1,37 +1,24 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
-All rights reserved. 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  Uhci.h\r
-\r
-Abstract:\r
-\r
   The definition for UHCI driver model and HC protocol routines.\r
 \r
-Revision History\r
-\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
-#ifndef _UHCI_H\r
-#define _UHCI_H\r
+#ifndef _EFI_UHCI_H_\r
+#define _EFI_UHCI_H_\r
 \r
 \r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
 \r
 #include <Protocol/Usb2HostController.h>\r
 #include <Protocol/UsbHostController.h>\r
 #include <Protocol/PciIo.h>\r
 \r
+#include <Guid/EventGroup.h>\r
+\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -39,8 +26,10 @@ Revision History
 #include <Library/UefiLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
 \r
-#include <IndustryStandard/Pci22.h>\r
+#include <IndustryStandard/Pci.h>\r
 \r
 typedef struct _USB_HC_DEV  USB_HC_DEV;\r
 \r
@@ -49,38 +38,58 @@ typedef struct _USB_HC_DEV  USB_HC_DEV;
 #include "UhciReg.h"\r
 #include "UhciSched.h"\r
 #include "UhciDebug.h"\r
+#include "ComponentName.h"\r
 \r
-enum {\r
-  //\r
-  // Stall times\r
-  //\r
-  STALL_1_MS               = 1000,\r
-  STALL_1_SECOND           = 1000 *STALL_1_MS,\r
+//\r
+// UHC timeout experience values\r
+//\r
 \r
-  UHC_SYN_POLL             = 50,\r
-  FORCE_GLOBAL_RESUME_TIME = 20 *STALL_1_MS,\r
-  ROOT_PORT_REST_TIME      = 50 *STALL_1_MS,\r
-  PORT_RESET_RECOVERY_TIME = 10 *STALL_1_MS,\r
-  INTERRUPT_POLLING_TIME   = 50 * 10000UL,\r
+#define UHC_1_MICROSECOND             1\r
+#define UHC_1_MILLISECOND             (1000 * UHC_1_MICROSECOND)\r
+#define UHC_1_SECOND                  (1000 * UHC_1_MILLISECOND)\r
 \r
-  //\r
-  // UHC raises TPL to TPL_NOTIFY to serialize all its operations\r
-  // to protect shared data structures.\r
-  //\r
-  UHCI_TPL                 = TPL_NOTIFY,\r
+//\r
+// UHCI register operation timeout, set by experience\r
+//\r
+#define UHC_GENERIC_TIMEOUT           UHC_1_SECOND\r
 \r
-  USB_HC_DEV_SIGNATURE     = EFI_SIGNATURE_32 ('u', 'h', 'c', 'i')\r
-};\r
+//\r
+// Wait for force global resume(FGR) complete, refers to\r
+// specification[UHCI11-2.1.1]\r
+//\r
+#define UHC_FORCE_GLOBAL_RESUME_STALL (20 * UHC_1_MILLISECOND)\r
+\r
+//\r
+// Wait for roothub port reset and recovery, reset stall\r
+// is set by experience, and recovery stall refers to\r
+// specification[UHCI11-2.1.1]\r
+//\r
+#define UHC_ROOT_PORT_RESET_STALL     (50 * UHC_1_MILLISECOND)\r
+#define UHC_ROOT_PORT_RECOVERY_STALL  (10 * UHC_1_MILLISECOND)\r
+\r
+//\r
+// Sync and Async transfer polling interval, set by experience,\r
+// and the unit of Async is 100us.\r
+//\r
+#define UHC_SYNC_POLL_INTERVAL        (1 * UHC_1_MILLISECOND)\r
+#define UHC_ASYNC_POLL_INTERVAL       EFI_TIMER_PERIOD_MILLISECONDS(1)\r
+\r
+//\r
+// UHC raises TPL to TPL_NOTIFY to serialize all its operations\r
+// to protect shared data structures.\r
+//\r
+#define  UHCI_TPL                     TPL_NOTIFY\r
+\r
+#define  USB_HC_DEV_SIGNATURE         SIGNATURE_32 ('u', 'h', 'c', 'i')\r
 \r
 #pragma pack(1)\r
 typedef struct {\r
-  UINT8               PI;\r
+  UINT8               ProgInterface;\r
   UINT8               SubClassCode;\r
   UINT8               BaseCode;\r
 } USB_CLASSC;\r
 #pragma pack()\r
 \r
-#define UHC_FROM_USB_HC_PROTO(This)   CR(This, USB_HC_DEV, UsbHc, USB_HC_DEV_SIGNATURE)\r
 #define UHC_FROM_USB2_HC_PROTO(This)  CR(This, USB_HC_DEV, Usb2Hc, USB_HC_DEV_SIGNATURE)\r
 \r
 //\r
@@ -96,14 +105,16 @@ typedef struct {
 //\r
 struct _USB_HC_DEV {\r
   UINT32                    Signature;\r
-  EFI_USB_HC_PROTOCOL       UsbHc;\r
   EFI_USB2_HC_PROTOCOL      Usb2Hc;\r
   EFI_PCI_IO_PROTOCOL       *PciIo;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINT64                    OriginalPciAttributes;\r
 \r
   //\r
   // Schedule data structures\r
   //\r
-  UINT32                    *FrameBase;\r
+  UINT32                    *FrameBase; // the buffer pointed by this pointer is used to store pci bus address of the QH descriptor.\r
+  UINT32                    *FrameBaseHostAddr; // the buffer pointed by this pointer is used to store host memory address of the QH descriptor.\r
   UHCI_QH_SW                *SyncIntQh;\r
   UHCI_QH_SW                *CtrlQh;\r
   UHCI_QH_SW                *BulkQh;\r
@@ -126,9 +137,79 @@ struct _USB_HC_DEV {
   USBHC_MEM_POOL            *MemPool;\r
   EFI_UNICODE_STRING_TABLE  *CtrlNameTable;\r
   VOID                      *FrameMapping;\r
+\r
+  //\r
+  // ExitBootServicesEvent is used to stop the EHC DMA operation\r
+  // after exit boot service.\r
+  //\r
+  EFI_EVENT                 ExitBootServiceEvent;\r
 };\r
 \r
-extern EFI_DRIVER_BINDING_PROTOCOL  gUhciDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gUhciComponentName;\r
+extern EFI_DRIVER_BINDING_PROTOCOL   gUhciDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL   gUhciComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL  gUhciComponentName2;\r
+\r
+/**\r
+  Test to see if this driver supports ControllerHandle. Any\r
+  ControllerHandle that has UsbHcProtocol installed will be supported.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  Controller           Handle of device to test.\r
+  @param  RemainingDevicePath  Not used.\r
+\r
+  @return EFI_SUCCESS          This driver supports this device.\r
+  @return EFI_UNSUPPORTED      This driver does not support this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UhciDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN EFI_HANDLE                      Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  );\r
+\r
+/**\r
+  Starting the Usb UHCI Driver.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  Controller           Handle of device to test.\r
+  @param  RemainingDevicePath  Not used.\r
+\r
+  @retval EFI_SUCCESS          This driver supports this device.\r
+  @retval EFI_UNSUPPORTED      This driver does not support this device.\r
+  @retval EFI_DEVICE_ERROR     This driver cannot be started due to device Error.\r
+                               EFI_OUT_OF_RESOURCES- Failed due to resource shortage.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UhciDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN EFI_HANDLE                      Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  );\r
+\r
+/**\r
+  Stop this driver on ControllerHandle. Support stopping any child handles\r
+  created by this driver.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  Controller           Handle of device to stop driver on.\r
+  @param  NumberOfChildren     Number of Children in the ChildHandleBuffer.\r
+  @param  ChildHandleBuffer    List of handles for the children we need to stop.\r
+\r
+  @return EFI_SUCCESS\r
+  @return others\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UhciDriverBindingStop (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN EFI_HANDLE                      Controller,\r
+  IN UINTN                           NumberOfChildren,\r
+  IN EFI_HANDLE                      *ChildHandleBuffer\r
+  );\r
 \r
 #endif\r