]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.h
index 2b0e4c956cde296a7be50fbbaeba5692119630c0..f8d5444c38d3a6c86700f99fc6b28da007842fb2 100644 (file)
@@ -1,7 +1,9 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+  Provides some data struct used by EHCI controller driver.\r
+\r
+Copyright (c) 2006 - 2010, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -9,32 +11,19 @@ http://opensource.org/licenses/bsd-license.php
 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
-    Ehci.h\r
-\r
-Abstract:\r
-\r
-\r
-Revision History\r
-\r
 **/\r
 \r
 #ifndef _EFI_EHCI_H_\r
 #define _EFI_EHCI_H_\r
 \r
-//\r
-// The package level header files this module uses\r
-//\r
-#include <PiDxe.h>\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
+\r
+#include <Uefi.h>\r
+\r
 #include <Protocol/Usb2HostController.h>\r
 #include <Protocol/PciIo.h>\r
-//\r
-// The Library classes this module consumes\r
-//\r
+\r
+#include <Guid/EventGroup.h>\r
+\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -42,9 +31,9 @@ Revision History
 #include <Library/UefiLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
-\r
-#include <IndustryStandard/Pci22.h>\r
+#include <IndustryStandard/Pci.h>\r
 \r
 typedef struct _USB2_HC_DEV  USB2_HC_DEV;\r
 \r
@@ -53,21 +42,39 @@ typedef struct _USB2_HC_DEV  USB2_HC_DEV;
 #include "EhciUrb.h"\r
 #include "EhciSched.h"\r
 #include "EhciDebug.h"\r
+#include "ComponentName.h"\r
 \r
-enum {\r
-  USB2_HC_DEV_SIGNATURE     = EFI_SIGNATURE_32 ('e', 'h', 'c', 'i'),\r
-  EHC_STALL_1_MICROSECOND   = 1,\r
-  EHC_STALL_1_MILLISECOND   = 1000 * EHC_STALL_1_MICROSECOND,\r
-  EHC_STALL_1_SECOND        = 1000 * EHC_STALL_1_MILLISECOND,\r
+//\r
+// EHC timeout experience values\r
+//\r
 \r
-  EHC_SET_PORT_RESET_TIME   = 50 * EHC_STALL_1_MILLISECOND,\r
-  EHC_CLEAR_PORT_RESET_TIME = EHC_STALL_1_MILLISECOND,\r
-  EHC_GENERIC_TIME          = 10 * EHC_STALL_1_MILLISECOND,\r
-  EHC_SYNC_POLL_TIME        = 20 * EHC_STALL_1_MICROSECOND,\r
-  EHC_ASYNC_POLL_TIME       = 50 * 10000UL,                 // The unit of time is 100us\r
+#define EHC_1_MICROSECOND            1\r
+#define EHC_1_MILLISECOND            (1000 * EHC_1_MICROSECOND)\r
+#define EHC_1_SECOND                 (1000 * EHC_1_MILLISECOND)\r
 \r
-  EHC_TPL                   = TPL_NOTIFY\r
-};\r
+//\r
+// EHCI register operation timeout, set by experience\r
+//\r
+#define EHC_RESET_TIMEOUT            (1 * EHC_1_SECOND)\r
+#define EHC_GENERIC_TIMEOUT          (10 * EHC_1_MILLISECOND)\r
+\r
+//\r
+// Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]\r
+//\r
+#define EHC_ROOT_PORT_RECOVERY_STALL (20 * EHC_1_MILLISECOND)\r
+\r
+//\r
+// Sync and Async transfer polling interval, set by experience,\r
+// and the unit of Async is 100us, means 50ms as interval.\r
+//\r
+#define EHC_SYNC_POLL_INTERVAL       (1 * EHC_1_MILLISECOND)\r
+#define EHC_ASYNC_POLL_INTERVAL      (50 * 10000U)\r
+\r
+//\r
+// EHC raises TPL to TPL_NOTIFY to serialize all its operations\r
+// to protect shared data structures.\r
+//\r
+#define  EHC_TPL                TPL_NOTIFY\r
 \r
 //\r
 //Iterate through the doule linked list. NOT delete safe\r
@@ -83,7 +90,7 @@ enum {
   for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r
       Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r
 \r
-#define EFI_LIST_CONTAINER(Entry, Type, Field) _CR(Entry, Type, Field)\r
+#define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)\r
 \r
 \r
 #define EHC_LOW_32BIT(Addr64)     ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))\r
@@ -93,13 +100,15 @@ enum {
 #define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \\r
           (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))\r
 \r
-#define EHC_FROM_THIS(a)   CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)\r
+#define USB2_HC_DEV_SIGNATURE  SIGNATURE_32 ('e', 'h', 'c', 'i')\r
+#define EHC_FROM_THIS(a)       CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)\r
 \r
 struct _USB2_HC_DEV {\r
   UINTN                     Signature;\r
   EFI_USB2_HC_PROTOCOL      Usb2Hc;\r
 \r
   EFI_PCI_IO_PROTOCOL       *PciIo;\r
+  UINT64                    OriginalPciAttributes;\r
   USBHC_MEM_POOL            *MemPool;\r
 \r
   //\r
@@ -114,6 +123,12 @@ struct _USB2_HC_DEV {
   EHC_QTD                  *ShortReadStop;\r
   EFI_EVENT                 PollTimer;\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
   // Asynchronous(bulk and control) transfer schedule data:\r
   // ReclaimHead is used as the head of the asynchronous transfer\r
@@ -124,8 +139,8 @@ struct _USB2_HC_DEV {
   //\r
   // Peroidic (interrupt) transfer schedule data:\r
   //\r
-  VOID                      *PeriodFrame;     // Mapped as common buffer\r
-  VOID                      *PeriodFrameHost;\r
+  VOID                      *PeriodFrame;     // the buffer pointed by this pointer is used to store pci bus address of the QH descriptor.\r
+  VOID                      *PeriodFrameHost; // the buffer pointed by this pointer is used to store host memory address of the QH descriptor.\r
   VOID                      *PeriodFrameMap;\r
 \r
   EHC_QH                    *PeriodOne;\r
@@ -137,7 +152,6 @@ struct _USB2_HC_DEV {
   UINT32                    HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET\r
   UINT32                    HcCapParams;    // Cache of HC capability parameter, HCCPARAMS\r
   UINT32                    CapLen;         // Capability length\r
-  UINT32                    High32bitAddr;\r
 \r
   //\r
   // Misc\r
@@ -146,7 +160,73 @@ struct _USB2_HC_DEV {
 };\r
 \r
 \r
-extern EFI_DRIVER_BINDING_PROTOCOL     gEhciDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL     gEhciComponentName;\r
+extern EFI_DRIVER_BINDING_PROTOCOL      gEhciDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL      gEhciComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL     gEhciComponentName2;\r
+\r
+/**\r
+  Test to see if this driver supports ControllerHandle. Any\r
+  ControllerHandle that has Usb2HcProtocol installed will\r
+  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
+EhcDriverBindingSupported (\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 EHCI Driver.\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          supports this device.\r
+  @return EFI_UNSUPPORTED      do not support this device.\r
+  @return EFI_DEVICE_ERROR     cannot be started due to device Error.\r
+  @return EFI_OUT_OF_RESOURCES cannot allocate resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EhcDriverBindingStart (\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 stoping 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          Success.\r
+  @return EFI_DEVICE_ERROR     Fail.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EhcDriverBindingStop (\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
+\r