]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/UhciDxe/UhciReg.h
clean up the un-suitable ';' location when declaring the functions.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / UhciReg.h
1 /** @file
2
3 The definition for UHCI register operation routines.
4
5 Copyright (c) 2007 - 2008, 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_REG_H_
17 #define _EFI_UHCI_REG_H_
18
19 #define BIT(a) (1 << (a))
20
21 typedef enum {
22 UHCI_FRAME_NUM = 1024,
23
24 //
25 // Register offset and PCI related staff
26 //
27 CLASSC_OFFSET = 0x09,
28 USBBASE_OFFSET = 0x20,
29 USB_BAR_INDEX = 4,
30 PCI_CLASSC_PI_UHCI = 0x00,
31
32 USBCMD_OFFSET = 0,
33 USBSTS_OFFSET = 2,
34 USBINTR_OFFSET = 4,
35 USBPORTSC_OFFSET = 0x10,
36 USB_FRAME_NO_OFFSET = 6,
37 USB_FRAME_BASE_OFFSET = 8,
38 USB_EMULATION_OFFSET = 0xC0,
39
40 //
41 // Packet IDs
42 //
43 SETUP_PACKET_ID = 0x2D,
44 INPUT_PACKET_ID = 0x69,
45 OUTPUT_PACKET_ID = 0xE1,
46 ERROR_PACKET_ID = 0x55,
47
48 //
49 // USB port status and control bit definition.
50 //
51 USBPORTSC_CCS = BIT(0), // Current Connect Status
52 USBPORTSC_CSC = BIT(1), // Connect Status Change
53 USBPORTSC_PED = BIT(2), // Port Enable / Disable
54 USBPORTSC_PEDC = BIT(3), // Port Enable / Disable Change
55 USBPORTSC_LSL = BIT(4), // Line Status Low BIT
56 USBPORTSC_LSH = BIT(5), // Line Status High BIT
57 USBPORTSC_RD = BIT(6), // Resume Detect
58 USBPORTSC_LSDA = BIT(8), // Low Speed Device Attached
59 USBPORTSC_PR = BIT(9), // Port Reset
60 USBPORTSC_SUSP = BIT(12), // Suspend
61
62 //
63 // UHCI Spec said it must implement 2 ports each host at least,
64 // and if more, check whether the bit7 of PORTSC is always 1.
65 // So here assume the max of port number each host is 16.
66 //
67 USB_MAX_ROOTHUB_PORT = 0x0F,
68
69 //
70 // Command register bit definitions
71 //
72 USBCMD_RS = BIT(0), // Run/Stop
73 USBCMD_HCRESET = BIT(1), // Host reset
74 USBCMD_GRESET = BIT(2), // Global reset
75 USBCMD_EGSM = BIT(3), // Global Suspend Mode
76 USBCMD_FGR = BIT(4), // Force Global Resume
77 USBCMD_SWDBG = BIT(5), // SW Debug mode
78 USBCMD_CF = BIT(6), // Config Flag (sw only)
79 USBCMD_MAXP = BIT(7), // Max Packet (0 = 32, 1 = 64)
80
81 //
82 // USB Status register bit definitions
83 //
84 USBSTS_USBINT = BIT(0), // Interrupt due to IOC
85 USBSTS_ERROR = BIT(1), // Interrupt due to error
86 USBSTS_RD = BIT(2), // Resume Detect
87 USBSTS_HSE = BIT(3), // Host System Error
88 USBSTS_HCPE = BIT(4), // Host Controller Process Error
89 USBSTS_HCH = BIT(5), // HC Halted
90
91 USBTD_ACTIVE = BIT(7), // TD is still active
92 USBTD_STALLED = BIT(6), // TD is stalled
93 USBTD_BUFFERR = BIT(5), // Buffer underflow or overflow
94 USBTD_BABBLE = BIT(4), // Babble condition
95 USBTD_NAK = BIT(3), // NAK is received
96 USBTD_CRC = BIT(2), // CRC/Time out error
97 USBTD_BITSTUFF = BIT(1) // Bit stuff error
98 }UHCI_REGISTER_OFFSET;
99
100
101 /**
102 Read a UHCI register.
103
104 @param PciIo The EFI_PCI_IO_PROTOCOL to use.
105 @param Offset Register offset to USB_BAR_INDEX.
106
107 @return Content of register.
108
109 **/
110 UINT16
111 UhciReadReg (
112 IN EFI_PCI_IO_PROTOCOL *PciIo,
113 IN UINT32 Offset
114 );
115
116
117
118 /**
119 Write data to UHCI register.
120
121 @param PciIo The EFI_PCI_IO_PROTOCOL to use.
122 @param Offset Register offset to USB_BAR_INDEX.
123 @param Data Data to write.
124
125 @return None.
126
127 **/
128 VOID
129 UhciWriteReg (
130 IN EFI_PCI_IO_PROTOCOL *PciIo,
131 IN UINT32 Offset,
132 IN UINT16 Data
133 );
134
135
136
137 /**
138 Set a bit of the UHCI Register.
139
140 @param PciIo The EFI_PCI_IO_PROTOCOL to use.
141 @param Offset Register offset to USB_BAR_INDEX.
142 @param Bit The bit to set.
143
144 @return None.
145
146 **/
147 VOID
148 UhciSetRegBit (
149 IN EFI_PCI_IO_PROTOCOL *PciIo,
150 IN UINT32 Offset,
151 IN UINT16 Bit
152 );
153
154
155
156 /**
157 Clear a bit of the UHCI Register.
158
159 @param PciIo The PCI_IO protocol to access the PCI.
160 @param Offset Register offset to USB_BAR_INDEX.
161 @param Bit The bit to clear.
162
163 @return None.
164
165 **/
166 VOID
167 UhciClearRegBit (
168 IN EFI_PCI_IO_PROTOCOL *PciIo,
169 IN UINT32 Offset,
170 IN UINT16 Bit
171 );
172
173
174 /**
175 Clear all the interrutp status bits, these bits
176 are Write-Clean.
177
178 @param Uhc The UHCI device.
179
180 @return None.
181
182 **/
183 VOID
184 UhciAckAllInterrupt (
185 IN USB_HC_DEV *Uhc
186 );
187
188
189 /**
190 Stop the host controller.
191
192 @param Uhc The UHCI device.
193 @param Timeout Max time allowed.
194
195 @retval EFI_SUCCESS The host controller is stopped.
196 @retval EFI_TIMEOUT Failed to stop the host controller.
197
198 **/
199 EFI_STATUS
200 UhciStopHc (
201 IN USB_HC_DEV *Uhc,
202 IN UINTN Timeout
203 );
204
205
206
207 /**
208 Check whether the host controller operates well.
209
210 @param PciIo The PCI_IO protocol to use.
211
212 @retval TRUE Host controller is working.
213 @retval FALSE Host controller is halted or system error.
214
215 **/
216 BOOLEAN
217 UhciIsHcWorking (
218 IN EFI_PCI_IO_PROTOCOL *PciIo
219 );
220
221
222 /**
223 Set the UHCI frame list base address. It can't use
224 UhciWriteReg which access memory in UINT16.
225
226 @param PciIo The EFI_PCI_IO_PROTOCOL to use.
227 @param Addr Address to set.
228
229 @return None.
230
231 **/
232 VOID
233 UhciSetFrameListBaseAddr (
234 IN EFI_PCI_IO_PROTOCOL *PciIo,
235 IN VOID *Addr
236 );
237
238
239 /**
240 Disable USB Emulation.
241
242 @param PciIo The EFI_PCI_IO_PROTOCOL protocol to use.
243
244 @return None.
245
246 **/
247 VOID
248 UhciTurnOffUsbEmulation (
249 IN EFI_PCI_IO_PROTOCOL *PciIo
250 );
251 #endif