TianoCore EDK2 master
Loading...
Searching...
No Matches
EhciReg.h
Go to the documentation of this file.
1
10#ifndef _EFI_EHCI_REG_H_
11#define _EFI_EHCI_REG_H_
12
13//
14// EHCI register offset
15//
16
17//
18// Capability register offset
19//
20#define EHC_CAPLENGTH_OFFSET 0 // Capability register length offset
21#define EHC_HCSPARAMS_OFFSET 0x04 // Structural Parameters 04-07h
22#define EHC_HCCPARAMS_OFFSET 0x08 // Capability parameters offset
23
24//
25// Capability register bit definition
26//
27#define HCSP_NPORTS 0x0F // Number of root hub port
28#define HCSP_PPC 0x10 // Port Power Control
29#define HCCP_64BIT 0x01 // 64-bit addressing capability
30
31//
32// Operational register offset
33//
34#define EHC_USBCMD_OFFSET 0x0 // USB command register offset
35#define EHC_USBSTS_OFFSET 0x04 // Statue register offset
36#define EHC_USBINTR_OFFSET 0x08 // USB interrutp offset
37#define EHC_FRINDEX_OFFSET 0x0C // Frame index offset
38#define EHC_CTRLDSSEG_OFFSET 0x10 // Control data structure segment offset
39#define EHC_FRAME_BASE_OFFSET 0x14 // Frame list base address offset
40#define EHC_ASYNC_HEAD_OFFSET 0x18 // Next asynchronous list address offset
41#define EHC_CONFIG_FLAG_OFFSET 0x40 // Configure flag register offset
42#define EHC_PORT_STAT_OFFSET 0x44 // Port status/control offset
43
44#define EHC_FRAME_LEN 1024
45
46//
47// Register bit definition
48//
49#define CONFIGFLAG_ROUTE_EHC 0x01 // Route port to EHC
50
51#define USBCMD_RUN 0x01 // Run/stop
52#define USBCMD_RESET 0x02 // Start the host controller reset
53#define USBCMD_ENABLE_PERIOD 0x10 // Enable periodic schedule
54#define USBCMD_ENABLE_ASYNC 0x20 // Enable asynchronous schedule
55#define USBCMD_IAAD 0x40 // Interrupt on async advance doorbell
56
57#define USBSTS_IAA 0x20 // Interrupt on async advance
58#define USBSTS_PERIOD_ENABLED 0x4000 // Periodic schedule status
59#define USBSTS_ASYNC_ENABLED 0x8000 // Asynchronous schedule status
60#define USBSTS_HALT 0x1000 // Host controller halted
61#define USBSTS_SYS_ERROR 0x10 // Host system error
62#define USBSTS_INTACK_MASK 0x003F // Mask for the interrupt ACK, the WC
63 // (write clean) bits in USBSTS register
64
65#define PORTSC_CONN 0x01 // Current Connect Status
66#define PORTSC_CONN_CHANGE 0x02 // Connect Status Change
67#define PORTSC_ENABLED 0x04 // Port Enable / Disable
68#define PORTSC_ENABLE_CHANGE 0x08 // Port Enable / Disable Change
69#define PORTSC_OVERCUR 0x10 // Over current Active
70#define PORTSC_OVERCUR_CHANGE 0x20 // Over current Change
71#define PORSTSC_RESUME 0x40 // Force Port Resume
72#define PORTSC_SUSPEND 0x80 // Port Suspend State
73#define PORTSC_RESET 0x100 // Port Reset
74#define PORTSC_LINESTATE_K 0x400 // Line Status K-state
75#define PORTSC_LINESTATE_J 0x800 // Line Status J-state
76#define PORTSC_POWER 0x1000 // Port Power
77#define PORTSC_OWNER 0x2000 // Port Owner
78#define PORTSC_CHANGE_MASK 0x2A // Mask of the port change bits,
79 // they are WC (write clean)
80//
81// PCI Configuration Registers
82//
83#define EHC_BAR_INDEX 0 // how many bytes away from USB_BASE to 0x10
84
85//
86// Debug port capability id
87//
88#define EHC_DEBUG_PORT_CAP_ID 0x0A
89
90#define EHC_LINK_TERMINATED(Link) (((Link) & 0x01) != 0)
91
92#define EHC_ADDR(High, QhHw32) \
93 ((VOID *) (UINTN) (LShiftU64 ((High), 32) | ((QhHw32) & 0xFFFFFFF0)))
94
95#define EHCI_IS_DATAIN(EndpointAddr) EHC_BIT_IS_SET((EndpointAddr), 0x80)
96
97//
98// Structure to map the hardware port states to the
99// UEFI's port states.
100//
101typedef struct {
102 UINT16 HwState;
103 UINT16 UefiState;
105
106//
107// Ehci Data and Ctrl Structures
108//
109#pragma pack(1)
110typedef struct {
111 UINT8 ProgInterface;
112 UINT8 SubClassCode;
113 UINT8 BaseCode;
114} USB_CLASSC;
115#pragma pack()
116
126UINT32
128 IN USB2_HC_DEV *Ehc,
129 IN UINT32 Offset
130 );
131
151BOOLEAN
153 IN CONST USB2_HC_DEV *Ehc,
154 IN CONST UINT8 *PortNumber OPTIONAL
155 );
156
166UINT32
168 IN USB2_HC_DEV *Ehc,
169 IN UINT32 Offset
170 );
171
180VOID
182 IN USB2_HC_DEV *Ehc,
183 IN UINT32 Offset,
184 IN UINT32 Data
185 );
186
195VOID
197 IN USB2_HC_DEV *Ehc,
198 IN UINT32 Offset,
199 IN UINT32 Bit
200 );
201
210VOID
212 IN USB2_HC_DEV *Ehc,
213 IN UINT32 Offset,
214 IN UINT32 Bit
215 );
216
224VOID
226 IN USB2_HC_DEV *Ehc
227 );
228
242 IN USB2_HC_DEV *Ehc,
243 IN UINT32 Timeout
244 );
245
252VOID
254 IN USB2_HC_DEV *Ehc
255 );
256
266BOOLEAN
267EhcIsHalt (
268 IN USB2_HC_DEV *Ehc
269 );
270
280BOOLEAN
282 IN USB2_HC_DEV *Ehc
283 );
284
297 IN USB2_HC_DEV *Ehc,
298 IN UINT32 Timeout
299 );
300
312EhcHaltHC (
313 IN USB2_HC_DEV *Ehc,
314 IN UINT32 Timeout
315 );
316
328EhcRunHC (
329 IN USB2_HC_DEV *Ehc,
330 IN UINT32 Timeout
331 );
332
349EhcInitHC (
350 IN USB2_HC_DEV *Ehc
351 );
352
353#endif
VOID EhcClearOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
Definition: EhciReg.c:238
EFI_STATUS EhcResetHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
Definition: EhciReg.c:477
VOID EhcWriteOpReg(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Data)
Definition: EhciReg.c:183
EFI_STATUS EhcInitHC(IN USB2_HC_DEV *Ehc)
Definition: EhciReg.c:562
EFI_STATUS EhcSetAndWaitDoorBell(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
Definition: EhciReg.c:343
VOID EhcSetOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
Definition: EhciReg.c:216
BOOLEAN EhcIsHalt(IN USB2_HC_DEV *Ehc)
Definition: EhciReg.c:442
EFI_STATUS EhcHaltHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
Definition: EhciReg.c:511
VOID EhcClearLegacySupport(IN USB2_HC_DEV *Ehc)
Definition: EhciReg.c:295
UINT32 EhcReadCapRegister(IN USB2_HC_DEV *Ehc, IN UINT32 Offset)
Definition: EhciReg.c:23
BOOLEAN EhcIsSysError(IN USB2_HC_DEV *Ehc)
Definition: EhciReg.c:459
EFI_STATUS EhcRunHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
Definition: EhciReg.c:534
UINT32 EhcReadOpReg(IN USB2_HC_DEV *Ehc, IN UINT32 Offset)
Definition: EhciReg.c:147
VOID EhcAckAllInterrupt(IN USB2_HC_DEV *Ehc)
Definition: EhciReg.c:376
BOOLEAN EhcIsDebugPortInUse(IN CONST USB2_HC_DEV *Ehc, IN CONST UINT8 *PortNumber OPTIONAL)
Definition: EhciReg.c:104
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29