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