]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/UhciDxe/Uhci.h
eb61554e0e86c3612c6893458d809d1423703c20
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / Uhci.h
1 /** @file
2
3 The definition for UHCI driver model and HC protocol routines.
4
5 Copyright (c) 2004 - 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_UHCI_H_
17 #define _EFI_UHCI_H_
18
19
20 #include <Uefi.h>
21
22 #include <Protocol/Usb2HostController.h>
23 #include <Protocol/UsbHostController.h>
24 #include <Protocol/PciIo.h>
25
26 #include <Guid/EventGroup.h>
27
28 #include <Library/DebugLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/UefiDriverEntryPoint.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/UefiLib.h>
33 #include <Library/BaseLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/PcdLib.h>
36
37 #include <IndustryStandard/Pci.h>
38
39 typedef struct _USB_HC_DEV USB_HC_DEV;
40
41 #include "UsbHcMem.h"
42 #include "UhciQueue.h"
43 #include "UhciReg.h"
44 #include "UhciSched.h"
45 #include "UhciDebug.h"
46 #include "ComponentName.h"
47
48 typedef enum {
49 UHC_1_MICROSECOND = 1,
50 UHC_1_MILLISECOND = 1000 * UHC_1_MICROSECOND,
51 UHC_1_SECOND = 1000 * UHC_1_MILLISECOND,
52
53 //
54 // UHCI register operation timeout, set by experience
55 //
56 UHC_GENERIC_TIMEOUT = UHC_1_SECOND,
57
58 //
59 // Wait for force global resume(FGR) complete, refers to
60 // specification[UHCI11-2.1.1]
61 //
62 UHC_FORCE_GLOBAL_RESUME_STALL = 20 * UHC_1_MILLISECOND,
63
64 //
65 // Wait for roothub port reset and recovery, reset stall
66 // is set by experience, and recovery stall refers to
67 // specification[UHCI11-2.1.1]
68 //
69 UHC_ROOT_PORT_RESET_STALL = 50 * UHC_1_MILLISECOND,
70 UHC_ROOT_PORT_RECOVERY_STALL = 10 * UHC_1_MILLISECOND,
71
72 //
73 // Sync and Async transfer polling interval, set by experience,
74 // and the unit of Async is 100us.
75 //
76 UHC_SYNC_POLL_INTERVAL = 1 * UHC_1_MILLISECOND,
77 UHC_ASYNC_POLL_INTERVAL = 50 * 10000UL
78 }UHC_TIMEOUT_EXPERIENCE_VALUE;
79
80
81 //
82 // UHC raises TPL to TPL_NOTIFY to serialize all its operations
83 // to protect shared data structures.
84 //
85 #define UHCI_TPL TPL_NOTIFY
86
87 #define USB_HC_DEV_SIGNATURE SIGNATURE_32 ('u', 'h', 'c', 'i')
88
89 #pragma pack(1)
90 typedef struct {
91 UINT8 PI;
92 UINT8 SubClassCode;
93 UINT8 BaseCode;
94 } USB_CLASSC;
95 #pragma pack()
96
97 #define UHC_FROM_USB2_HC_PROTO(This) CR(This, USB_HC_DEV, Usb2Hc, USB_HC_DEV_SIGNATURE)
98
99 //
100 // USB_HC_DEV support the UHCI hardware controller. It schedules
101 // the asynchronous interrupt transfer with the same method as
102 // EHCI: a reversed tree structure. For synchronous interrupt,
103 // control and bulk transfer, it uses three static queue head to
104 // schedule them. SyncIntQh is for interrupt transfer. LsCtrlQh is
105 // for LOW speed control transfer, and FsCtrlBulkQh is for FULL
106 // speed control or bulk transfer. This is because FULL speed contrl
107 // or bulk transfer can reclaim the unused bandwidth. Some USB
108 // device requires this bandwidth reclamation capability.
109 //
110 struct _USB_HC_DEV {
111 UINT32 Signature;
112 EFI_USB2_HC_PROTOCOL Usb2Hc;
113 EFI_PCI_IO_PROTOCOL *PciIo;
114 UINT64 OriginalPciAttributes;
115
116 //
117 // Schedule data structures
118 //
119 UINT32 *FrameBase;
120 UINT32 *FrameBasePciMemAddr;
121 UHCI_QH_SW *SyncIntQh;
122 UHCI_QH_SW *CtrlQh;
123 UHCI_QH_SW *BulkQh;
124
125 //
126 // Structures to maintain asynchronus interrupt transfers.
127 // When asynchronous interrutp transfer is unlinked from
128 // the frame list, the hardware may still hold a pointer
129 // to it. To synchronize with hardware, its resoureces are
130 // released in two steps using Recycle and RecycleWait.
131 // Check the asynchronous interrupt management routines.
132 //
133 LIST_ENTRY AsyncIntList;
134 EFI_EVENT AsyncIntMonitor;
135 UHCI_ASYNC_REQUEST *Recycle;
136 UHCI_ASYNC_REQUEST *RecycleWait;
137
138
139 UINTN RootPorts;
140 USBHC_MEM_POOL *MemPool;
141 EFI_UNICODE_STRING_TABLE *CtrlNameTable;
142 VOID *FrameMapping;
143
144 //
145 // ExitBootServicesEvent is used to stop the EHC DMA operation
146 // after exit boot service.
147 //
148 EFI_EVENT ExitBootServiceEvent;
149 };
150
151 extern EFI_DRIVER_BINDING_PROTOCOL gUhciDriverBinding;
152 extern EFI_COMPONENT_NAME_PROTOCOL gUhciComponentName;
153 extern EFI_COMPONENT_NAME2_PROTOCOL gUhciComponentName2;
154
155 /**
156 Test to see if this driver supports ControllerHandle. Any
157 ControllerHandle that has UsbHcProtocol installed will be supported.
158
159 @param This Protocol instance pointer.
160 @param Controller Handle of device to test.
161 @param RemainingDevicePath Not used.
162
163 @return EFI_SUCCESS This driver supports this device.
164 @return EFI_UNSUPPORTED This driver does not support this device.
165
166 **/
167 EFI_STATUS
168 EFIAPI
169 UhciDriverBindingSupported (
170 IN EFI_DRIVER_BINDING_PROTOCOL *This,
171 IN EFI_HANDLE Controller,
172 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
173 );
174
175 /**
176 Starting the Usb UHCI Driver.
177
178 @param This Protocol instance pointer.
179 @param Controller Handle of device to test.
180 @param RemainingDevicePath Not used.
181
182 @retval EFI_SUCCESS This driver supports this device.
183 @retval EFI_UNSUPPORTED This driver does not support this device.
184 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
185 EFI_OUT_OF_RESOURCES- Failed due to resource shortage.
186
187 **/
188 EFI_STATUS
189 EFIAPI
190 UhciDriverBindingStart (
191 IN EFI_DRIVER_BINDING_PROTOCOL *This,
192 IN EFI_HANDLE Controller,
193 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
194 );
195
196 /**
197 Stop this driver on ControllerHandle. Support stoping any child handles
198 created by this driver.
199
200 @param This Protocol instance pointer.
201 @param Controller Handle of device to stop driver on.
202 @param NumberOfChildren Number of Children in the ChildHandleBuffer.
203 @param ChildHandleBuffer List of handles for the children we need to stop.
204
205 @return EFI_SUCCESS
206 @return others
207
208 **/
209 EFI_STATUS
210 EFIAPI
211 UhciDriverBindingStop (
212 IN EFI_DRIVER_BINDING_PROTOCOL *This,
213 IN EFI_HANDLE Controller,
214 IN UINTN NumberOfChildren,
215 IN EFI_HANDLE *ChildHandleBuffer
216 );
217
218 #endif