3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
29 #include <Protocol/Usb2HostController.h>
30 #include <Protocol/PciIo.h>
32 #include <Library/DebugLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/BaseLib.h>
38 #include <Library/MemoryAllocationLib.h>
41 #include <IndustryStandard/Pci22.h>
43 typedef struct _USB2_HC_DEV USB2_HC_DEV
;
48 #include "EhciSched.h"
49 #include "EhciDebug.h"
52 EHC_1_MICROSECOND
= 1,
53 EHC_1_MILLISECOND
= 1000 * EHC_1_MICROSECOND
,
54 EHC_1_SECOND
= 1000 * EHC_1_MILLISECOND
,
57 // EHCI register operation timeout, set by experience
59 EHC_RESET_TIMEOUT
= 1 * EHC_1_SECOND
,
60 EHC_GENERIC_TIMEOUT
= 10 * EHC_1_MILLISECOND
,
63 // Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]
65 EHC_ROOT_PORT_RECOVERY_STALL
= 20 * EHC_1_MILLISECOND
,
68 // Sync and Async transfer polling interval, set by experience,
69 // and the unit of Async is 100us, means 50ms as interval.
71 EHC_SYNC_POLL_INTERVAL
= 20 * EHC_1_MICROSECOND
,
72 EHC_ASYNC_POLL_INTERVAL
= 50 * 10000U,
75 // EHC raises TPL to TPL_NOTIFY to serialize all its operations
76 // to protect shared data structures.
80 USB2_HC_DEV_SIGNATURE
= EFI_SIGNATURE_32 ('e', 'h', 'c', 'i')
84 //Iterate through the doule linked list. NOT delete safe
86 #define EFI_LIST_FOR_EACH(Entry, ListHead) \
87 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
90 //Iterate through the doule linked list. This is delete-safe.
91 //Don't touch NextEntry
93 #define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
94 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
95 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
97 #define EFI_LIST_CONTAINER(Entry, Type, Field) _CR(Entry, Type, Field)
100 #define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))
101 #define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
102 #define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
104 #define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \
105 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))
107 #define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
109 struct _USB2_HC_DEV
{
111 EFI_USB2_HC_PROTOCOL Usb2Hc
;
113 EFI_PCI_IO_PROTOCOL
*PciIo
;
114 USBHC_MEM_POOL
*MemPool
;
117 // Schedule data shared between asynchronous and periodic
119 // ShortReadStop, as its name indicates, is used to terminate
120 // the short read except the control transfer. EHCI follows
121 // the alternative next QTD point when a short read happens.
122 // For control transfer, even the short read happens, try the
125 EHC_QTD
*ShortReadStop
;
129 // Asynchronous(bulk and control) transfer schedule data:
130 // ReclaimHead is used as the head of the asynchronous transfer
131 // list. It acts as the reclamation header.
136 // Peroidic (interrupt) transfer schedule data:
138 VOID
*PeriodFrame
; // Mapped as common buffer
139 VOID
*PeriodFrameHost
;
140 VOID
*PeriodFrameMap
;
143 LIST_ENTRY AsyncIntTransfers
;
146 // EHCI configuration data
148 UINT32 HcStructParams
; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET
149 UINT32 HcCapParams
; // Cache of HC capability parameter, HCCPARAMS
150 UINT32 CapLen
; // Capability length
151 UINT32 High32bitAddr
;
156 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
160 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding
;
161 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName
;
162 extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2
;