]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
IntelSiliconPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.h
CommitLineData
913cb9dc 1/** @file\r
2\r
78c2ffb5 3 Provides some data struct used by EHCI controller driver.\r
4\r
d1102dba 5Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 6This program and the accompanying materials\r
913cb9dc 7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
913cb9dc 14**/\r
15\r
16#ifndef _EFI_EHCI_H_\r
17#define _EFI_EHCI_H_\r
18\r
ed7748fe 19\r
60c93673 20#include <Uefi.h>\r
ed7748fe 21\r
913cb9dc 22#include <Protocol/Usb2HostController.h>\r
23#include <Protocol/PciIo.h>\r
ed7748fe 24\r
0428a6cb 25#include <Guid/EventGroup.h>\r
26\r
913cb9dc 27#include <Library/DebugLib.h>\r
28#include <Library/BaseMemoryLib.h>\r
29#include <Library/UefiDriverEntryPoint.h>\r
30#include <Library/UefiBootServicesTableLib.h>\r
31#include <Library/UefiLib.h>\r
32#include <Library/BaseLib.h>\r
33#include <Library/MemoryAllocationLib.h>\r
dd4047a5 34#include <Library/PcdLib.h>\r
37623a5c 35#include <Library/ReportStatusCodeLib.h>\r
913cb9dc 36\r
a261044c 37#include <IndustryStandard/Pci.h>\r
913cb9dc 38\r
39typedef struct _USB2_HC_DEV USB2_HC_DEV;\r
40\r
41#include "UsbHcMem.h"\r
42#include "EhciReg.h"\r
43#include "EhciUrb.h"\r
44#include "EhciSched.h"\r
45#include "EhciDebug.h"\r
aa79b0b3 46#include "ComponentName.h"\r
913cb9dc 47\r
1ccdbf2a 48//\r
49// EHC timeout experience values\r
50//\r
51\r
52#define EHC_1_MICROSECOND 1\r
53#define EHC_1_MILLISECOND (1000 * EHC_1_MICROSECOND)\r
54#define EHC_1_SECOND (1000 * EHC_1_MILLISECOND)\r
55\r
56//\r
57// EHCI register operation timeout, set by experience\r
58//\r
59#define EHC_RESET_TIMEOUT (1 * EHC_1_SECOND)\r
60#define EHC_GENERIC_TIMEOUT (10 * EHC_1_MILLISECOND)\r
78c2ffb5 61\r
1ccdbf2a 62//\r
63// Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]\r
64//\r
65#define EHC_ROOT_PORT_RECOVERY_STALL (20 * EHC_1_MILLISECOND)\r
66\r
67//\r
68// Sync and Async transfer polling interval, set by experience,\r
d525ec10 69// and the unit of Async is 100us, means 1ms as interval.\r
1ccdbf2a 70//\r
71#define EHC_SYNC_POLL_INTERVAL (1 * EHC_1_MILLISECOND)\r
d525ec10 72#define EHC_ASYNC_POLL_INTERVAL EFI_TIMER_PERIOD_MILLISECONDS(1)\r
41e8ff27 73\r
09943f5e 74//\r
75// EHCI debug port control status register bit definition\r
76//\r
77#define USB_DEBUG_PORT_IN_USE BIT10\r
78#define USB_DEBUG_PORT_ENABLE BIT28\r
79#define USB_DEBUG_PORT_OWNER BIT30\r
b48ec0e8
LE
80#define USB_DEBUG_PORT_IN_USE_MASK (USB_DEBUG_PORT_IN_USE | \\r
81 USB_DEBUG_PORT_OWNER)\r
09943f5e 82\r
597f4ee2 83//\r
84// EHC raises TPL to TPL_NOTIFY to serialize all its operations\r
85// to protect shared data structures.\r
86//\r
09943f5e 87#define EHC_TPL TPL_NOTIFY\r
41e8ff27 88\r
913cb9dc 89//\r
ed356b9e 90//Iterate through the double linked list. NOT delete safe\r
913cb9dc 91//\r
92#define EFI_LIST_FOR_EACH(Entry, ListHead) \\r
93 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r
94\r
95//\r
ed356b9e 96//Iterate through the double linked list. This is delete-safe.\r
913cb9dc 97//Don't touch NextEntry\r
98//\r
99#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \\r
100 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r
101 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r
102\r
50d7ebad 103#define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)\r
913cb9dc 104\r
105\r
106#define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))\r
107#define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))\r
108#define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r
109\r
110#define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \\r
111 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))\r
112\r
597f4ee2 113#define USB2_HC_DEV_SIGNATURE SIGNATURE_32 ('e', 'h', 'c', 'i')\r
114#define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)\r
913cb9dc 115\r
c52fa98c 116struct _USB2_HC_DEV {\r
913cb9dc 117 UINTN Signature;\r
118 EFI_USB2_HC_PROTOCOL Usb2Hc;\r
119\r
120 EFI_PCI_IO_PROTOCOL *PciIo;\r
37623a5c 121 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
68246fa8 122 UINT64 OriginalPciAttributes;\r
913cb9dc 123 USBHC_MEM_POOL *MemPool;\r
124\r
125 //\r
126 // Schedule data shared between asynchronous and periodic\r
127 // transfers:\r
128 // ShortReadStop, as its name indicates, is used to terminate\r
129 // the short read except the control transfer. EHCI follows\r
130 // the alternative next QTD point when a short read happens.\r
131 // For control transfer, even the short read happens, try the\r
132 // status stage.\r
133 //\r
134 EHC_QTD *ShortReadStop;\r
135 EFI_EVENT PollTimer;\r
136\r
0428a6cb 137 //\r
d1102dba 138 // ExitBootServicesEvent is used to stop the EHC DMA operation\r
0428a6cb 139 // after exit boot service.\r
140 //\r
141 EFI_EVENT ExitBootServiceEvent;\r
142\r
913cb9dc 143 //\r
144 // Asynchronous(bulk and control) transfer schedule data:\r
145 // ReclaimHead is used as the head of the asynchronous transfer\r
146 // list. It acts as the reclamation header.\r
147 //\r
148 EHC_QH *ReclaimHead;\r
149\r
150 //\r
ed356b9e 151 // Periodic (interrupt) transfer schedule data:\r
913cb9dc 152 //\r
592b87a4 153 VOID *PeriodFrame; // the buffer pointed by this pointer is used to store pci bus address of the QH descriptor.\r
154 VOID *PeriodFrameHost; // the buffer pointed by this pointer is used to store host memory address of the QH descriptor.\r
913cb9dc 155 VOID *PeriodFrameMap;\r
156\r
157 EHC_QH *PeriodOne;\r
158 LIST_ENTRY AsyncIntTransfers;\r
159\r
160 //\r
161 // EHCI configuration data\r
162 //\r
163 UINT32 HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET\r
164 UINT32 HcCapParams; // Cache of HC capability parameter, HCCPARAMS\r
165 UINT32 CapLen; // Capability length\r
913cb9dc 166\r
167 //\r
168 // Misc\r
169 //\r
170 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
09943f5e 171\r
172 //\r
173 // EHCI debug port info\r
174 //\r
175 UINT16 DebugPortOffset; // The offset of debug port mmio register\r
176 UINT8 DebugPortBarNum; // The bar number of debug port mmio register\r
177 UINT8 DebugPortNum; // The port number of usb debug port\r
167c3fb4
AB
178\r
179 BOOLEAN Support64BitDma; // Whether 64 bit DMA may be used with this device\r
c52fa98c 180};\r
913cb9dc 181\r
182\r
f527bce3 183extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;\r
184extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;\r
185extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;\r
913cb9dc 186\r
aa79b0b3 187/**\r
188 Test to see if this driver supports ControllerHandle. Any\r
189 ControllerHandle that has Usb2HcProtocol installed will\r
190 be supported.\r
191\r
192 @param This Protocol instance pointer.\r
193 @param Controller Handle of device to test.\r
194 @param RemainingDevicePath Not used.\r
195\r
196 @return EFI_SUCCESS This driver supports this device.\r
197 @return EFI_UNSUPPORTED This driver does not support this device.\r
198\r
199**/\r
200EFI_STATUS\r
201EFIAPI\r
202EhcDriverBindingSupported (\r
203 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
204 IN EFI_HANDLE Controller,\r
205 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
206 );\r
207\r
208/**\r
209 Starting the Usb EHCI Driver.\r
210\r
211 @param This Protocol instance pointer.\r
212 @param Controller Handle of device to test.\r
213 @param RemainingDevicePath Not used.\r
214\r
215 @return EFI_SUCCESS supports this device.\r
216 @return EFI_UNSUPPORTED do not support this device.\r
217 @return EFI_DEVICE_ERROR cannot be started due to device Error.\r
218 @return EFI_OUT_OF_RESOURCES cannot allocate resources.\r
219\r
220**/\r
221EFI_STATUS\r
222EFIAPI\r
223EhcDriverBindingStart (\r
224 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
225 IN EFI_HANDLE Controller,\r
226 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
227 );\r
228\r
229/**\r
ed356b9e 230 Stop this driver on ControllerHandle. Support stopping any child handles\r
aa79b0b3 231 created by this driver.\r
232\r
233 @param This Protocol instance pointer.\r
234 @param Controller Handle of device to stop driver on.\r
235 @param NumberOfChildren Number of Children in the ChildHandleBuffer.\r
236 @param ChildHandleBuffer List of handles for the children we need to stop.\r
237\r
238 @return EFI_SUCCESS Success.\r
239 @return EFI_DEVICE_ERROR Fail.\r
240\r
241**/\r
242EFI_STATUS\r
243EFIAPI\r
244EhcDriverBindingStop (\r
245 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
246 IN EFI_HANDLE Controller,\r
247 IN UINTN NumberOfChildren,\r
248 IN EFI_HANDLE *ChildHandleBuffer\r
249 );\r
250\r
913cb9dc 251#endif\r
aa79b0b3 252\r