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