8 UhciRHGetRootHubData(IN PVOID uhciExtension
,
11 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
12 PUSBPORT_ROOT_HUB_DATA RootHubData
= rootHubData
;
13 USBPORT_HUB_11_CHARACTERISTICS HubCharacteristics
;
15 DPRINT("UhciRHGetRootHubData: ...\n");
17 HubCharacteristics
.AsUSHORT
= 0;
18 HubCharacteristics
.PowerControlMode
= 1;
19 HubCharacteristics
.NoPowerSwitching
= 1;
20 HubCharacteristics
.OverCurrentProtectionMode
= 1;
22 if (UhciExtension
->HcFlavor
!= UHCI_Piix4
)
23 HubCharacteristics
.NoOverCurrentProtection
= 1;
25 RootHubData
->NumberOfPorts
= UHCI_NUM_ROOT_HUB_PORTS
;
26 RootHubData
->HubCharacteristics
.Usb11HubCharacteristics
= HubCharacteristics
;
27 RootHubData
->PowerOnToPowerGood
= 1;
28 RootHubData
->HubControlCurrent
= 0;
33 UhciRHGetStatus(IN PVOID uhciExtension
,
36 DPRINT("UhciRHGetStatus: ...\n");
37 *Status
= UHCI_RH_STATUS_SUCCESS
;
38 return MP_STATUS_SUCCESS
;
43 UhciRHGetPortStatus(IN PVOID uhciExtension
,
45 IN PUSB_PORT_STATUS_AND_CHANGE PortStatus
)
47 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
48 PUHCI_HW_REGISTERS BaseRegister
;
49 PUSHORT PortControlRegister
;
50 UHCI_PORT_STATUS_CONTROL PortControl
;
52 USB_20_PORT_STATUS portStatus
;
53 USB_20_PORT_CHANGE portChange
;
55 //DPRINT("UhciRHGetPortStatus: ...\n");
59 BaseRegister
= UhciExtension
->BaseRegister
;
60 PortControlRegister
= &BaseRegister
->PortControl
[Port
-1].AsUSHORT
;
61 PortControl
.AsUSHORT
= READ_PORT_USHORT(PortControlRegister
);
63 portStatus
.AsUshort16
= 0;
64 portChange
.AsUshort16
= 0;
66 portStatus
.CurrentConnectStatus
= PortControl
.CurrentConnectStatus
;
67 portStatus
.PortEnabledDisabled
= PortControl
.PortEnabledDisabled
;
69 if (PortControl
.Suspend
== 1 &&
70 PortControl
.PortEnabledDisabled
== 1)
72 portStatus
.Suspend
= 1;
76 portStatus
.Suspend
= 0;
79 //if (UhciExtension->HcFlavor == UHCI_Piix4) // check will work after supporting HcFlavor in usbport.
82 portStatus
.OverCurrent
= PortControl
.Reserved2
& 1;
83 portStatus
.PortPower
= (~PortControl
.Reserved2
& 1);
84 portChange
.OverCurrentIndicatorChange
= (PortControl
.Reserved2
& 2) != 0;
88 portStatus
.OverCurrent
= 0;
89 portStatus
.PortPower
= 1;
90 portChange
.OverCurrentIndicatorChange
= 0;
93 portStatus
.HighSpeedDeviceAttached
= 0;
95 portStatus
.Reset
= PortControl
.PortReset
;
96 portStatus
.LowSpeedDeviceAttached
= PortControl
.LowSpeedDevice
;
97 portChange
.ConnectStatusChange
= PortControl
.ConnectStatusChange
;
99 PortBit
= 1 << (Port
- 1);
101 if (UhciExtension
->ResetPortMask
& PortBit
)
103 portChange
.ConnectStatusChange
= 0;
104 portChange
.PortEnableDisableChange
= 0;
108 portChange
.PortEnableDisableChange
= PortControl
.PortEnableDisableChange
;
111 if (UhciExtension
->SuspendChangePortMask
& PortBit
)
112 portChange
.SuspendChange
= 1;
114 if (UhciExtension
->ResetChangePortMask
& PortBit
)
115 portChange
.ResetChange
= 1;
117 PortStatus
->PortStatus
.Usb20PortStatus
= portStatus
;
118 PortStatus
->PortChange
.Usb20PortChange
= portChange
;
120 //DPRINT("UhciRHGetPortStatus: PortControl.AsUSHORT[%x] - %X, PortStatus - %X\n",
122 // PortControl.AsUSHORT,
123 // PortStatus->AsUlong32);
125 return MP_STATUS_SUCCESS
;
130 UhciRHGetHubStatus(IN PVOID uhciExtension
,
131 IN PUSB_HUB_STATUS_AND_CHANGE HubStatus
)
133 //DPRINT("UhciRHGetHubStatus: ...\n");
134 HubStatus
->AsUlong32
= 0;
135 return MP_STATUS_SUCCESS
;
140 UhciRHPortResetComplete(IN PVOID uhciExtension
,
143 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
145 PUHCI_HW_REGISTERS BaseRegister
;
146 PUSHORT PortControlRegister
;
147 UHCI_PORT_STATUS_CONTROL PortControl
;
150 DPRINT("UhciRHPortResetComplete: ...\n");
152 BaseRegister
= UhciExtension
->BaseRegister
;
154 Port
= *(PUSHORT
)pPort
;
157 PortControlRegister
= &BaseRegister
->PortControl
[Port
- 1].AsUSHORT
;
158 PortControl
.AsUSHORT
= READ_PORT_USHORT(PortControlRegister
);
160 PortControl
.ConnectStatusChange
= 0;
161 PortControl
.PortEnableDisableChange
= 0;
162 PortControl
.PortReset
= 0;
164 WRITE_PORT_USHORT(PortControlRegister
, PortControl
.AsUSHORT
);
166 while (UhciHardwarePresent(UhciExtension
))
168 PortControl
.AsUSHORT
= READ_PORT_USHORT(PortControlRegister
);
170 if (PortControl
.PortReset
== 0)
174 for (ix
= 0; ix
< 10; ++ix
)
176 KeStallExecutionProcessor(50);
178 PortControl
.AsUSHORT
= READ_PORT_USHORT(PortControlRegister
);
180 if (PortControl
.PortEnabledDisabled
== 1)
183 PortControl
.PortEnabledDisabled
= 1;
184 WRITE_PORT_USHORT(PortControlRegister
, PortControl
.AsUSHORT
);
187 PortControl
.ConnectStatusChange
= 1;
188 PortControl
.PortEnableDisableChange
= 1;
189 WRITE_PORT_USHORT(PortControlRegister
, PortControl
.AsUSHORT
);
191 if (UhciExtension
->HcFlavor
== UHCI_VIA
&&
192 UhciExtension
->HcFlavor
== UHCI_VIA_x01
&&
193 UhciExtension
->HcFlavor
== UHCI_VIA_x02
&&
194 UhciExtension
->HcFlavor
== UHCI_VIA_x03
&&
195 UhciExtension
->HcFlavor
== UHCI_VIA_x04
)
197 DPRINT("UhciRHPortResetComplete: Via chip. FIXME\n");
202 UhciExtension
->ResetChangePortMask
|= (1 << (Port
- 1));
203 UhciExtension
->ResetPortMask
&= ~(1 << (Port
- 1));
205 RegPacket
.UsbPortInvalidateRootHub(UhciExtension
);
210 UhciRHSetFeaturePortResetWorker(IN PUHCI_EXTENSION UhciExtension
,
213 PUHCI_HW_REGISTERS BaseRegister
;
214 PUSHORT PortControlRegister
;
215 UHCI_PORT_STATUS_CONTROL PortControl
;
218 DPRINT("UhciRHSetFeaturePortResetWorker: ...\n");
220 BaseRegister
= UhciExtension
->BaseRegister
;
222 Port
= *(PUSHORT
)pPort
;
225 PortControlRegister
= &BaseRegister
->PortControl
[Port
- 1].AsUSHORT
;
226 PortControl
.AsUSHORT
= READ_PORT_USHORT(PortControlRegister
);
228 PortControl
.ConnectStatusChange
= 0;
229 PortControl
.PortEnableDisableChange
= 0;
230 PortControl
.PortReset
= 1;
232 WRITE_PORT_USHORT(PortControlRegister
, PortControl
.AsUSHORT
);
234 RegPacket
.UsbPortRequestAsyncCallback(UhciExtension
,
238 UhciRHPortResetComplete
);
243 UhciRHSetFeaturePortReset(IN PVOID uhciExtension
,
246 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
250 DPRINT("UhciRHSetFeaturePortReset: ...\n");
254 ResetPortMask
= UhciExtension
->ResetPortMask
;
255 PortBit
= 1 << (Port
- 1);
257 if (ResetPortMask
& PortBit
)
258 return MP_STATUS_FAILURE
;
260 UhciExtension
->ResetPortMask
= ResetPortMask
| PortBit
;
262 if (UhciExtension
->HcFlavor
== UHCI_VIA
&&
263 UhciExtension
->HcFlavor
== UHCI_VIA_x01
&&
264 UhciExtension
->HcFlavor
== UHCI_VIA_x02
&&
265 UhciExtension
->HcFlavor
== UHCI_VIA_x03
&&
266 UhciExtension
->HcFlavor
== UHCI_VIA_x04
)
268 DPRINT1("UhciRHSetFeaturePortReset: Via chip. FIXME\n");
269 return MP_STATUS_SUCCESS
;
272 UhciRHSetFeaturePortResetWorker(UhciExtension
, &Port
);
274 return MP_STATUS_SUCCESS
;
279 UhciRHSetFeaturePortPower(IN PVOID uhciExtension
,
282 DPRINT("UhciRHSetFeaturePortPower: ...\n");
284 return MP_STATUS_SUCCESS
;
289 UhciRHPortEnable(IN PVOID uhciExtension
,
293 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
294 PUHCI_HW_REGISTERS BaseRegister
;
295 PUSHORT PortControlRegister
;
296 UHCI_PORT_STATUS_CONTROL PortControl
;
298 DPRINT("UhciRHPortEnable: ...\n");
302 BaseRegister
= UhciExtension
->BaseRegister
;
303 PortControlRegister
= &BaseRegister
->PortControl
[Port
-1].AsUSHORT
;
305 PortControl
.AsUSHORT
= READ_PORT_USHORT(PortControlRegister
);
307 PortControl
.ConnectStatusChange
= 0;
308 PortControl
.PortEnableDisableChange
= 0;
311 PortControl
.PortEnabledDisabled
= 1;
313 PortControl
.PortEnabledDisabled
= 0;
315 WRITE_PORT_USHORT(PortControlRegister
, PortControl
.AsUSHORT
);
317 return MP_STATUS_SUCCESS
;
322 UhciRHSetFeaturePortEnable(IN PVOID uhciExtension
,
325 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
326 DPRINT("UhciRHSetFeaturePortEnable: ...\n");
328 return UhciRHPortEnable(UhciExtension
, Port
, TRUE
);
333 UhciRHSetFeaturePortSuspend(IN PVOID uhciExtension
,
336 DPRINT("UhciRHSetFeaturePortSuspend: UNIMPLEMENTED. FIXME\n");
338 return MP_STATUS_SUCCESS
;
343 UhciRHClearFeaturePortEnable(IN PVOID uhciExtension
,
346 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
347 DPRINT("UhciRHClearFeaturePortEnable: ...\n");
349 return UhciRHPortEnable(UhciExtension
, Port
, FALSE
);
354 UhciRHClearFeaturePortPower(IN PVOID uhciExtension
,
357 DPRINT("UhciRHClearFeaturePortPower: UNIMPLEMENTED. FIXME\n");
359 return MP_STATUS_SUCCESS
;
364 UhciRHClearFeaturePortSuspend(IN PVOID uhciExtension
,
367 DPRINT("UhciRHClearFeaturePortSuspend: UNIMPLEMENTED. FIXME\n");
369 return MP_STATUS_SUCCESS
;
374 UhciRHClearFeaturePortEnableChange(IN PVOID uhciExtension
,
377 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
378 PUHCI_HW_REGISTERS BaseRegister
;
379 PUSHORT PortControlRegister
;
380 UHCI_PORT_STATUS_CONTROL PortControl
;
382 DPRINT("UhciRHClearFeaturePortEnableChange: ...\n");
386 BaseRegister
= UhciExtension
->BaseRegister
;
387 PortControlRegister
= (PUSHORT
)&BaseRegister
->PortControl
[Port
- 1];
388 PortControl
.AsUSHORT
= READ_PORT_USHORT(PortControlRegister
);
390 PortControl
.ConnectStatusChange
= 0;
391 PortControl
.PortEnableDisableChange
= 1;
392 WRITE_PORT_USHORT(PortControlRegister
, PortControl
.AsUSHORT
);
394 return MP_STATUS_SUCCESS
;
399 UhciRHClearFeaturePortConnectChange(IN PVOID uhciExtension
,
402 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
403 PUHCI_HW_REGISTERS BaseRegister
;
404 PUSHORT PortControlRegister
;
405 UHCI_PORT_STATUS_CONTROL PortControl
;
407 DPRINT("UhciRHClearFeaturePortConnectChange: Port - %04X\n", Port
);
411 BaseRegister
= UhciExtension
->BaseRegister
;
412 PortControlRegister
= (PUSHORT
)&BaseRegister
->PortControl
[Port
- 1];
413 PortControl
.AsUSHORT
= READ_PORT_USHORT(PortControlRegister
);
415 if (PortControl
.ConnectStatusChange
== 1)
417 /* WC (Write Clear) bits */
418 PortControl
.PortEnableDisableChange
= 0;
419 PortControl
.ConnectStatusChange
= 1;
420 WRITE_PORT_USHORT(PortControlRegister
, PortControl
.AsUSHORT
);
423 return MP_STATUS_SUCCESS
;
428 UhciRHClearFeaturePortResetChange(IN PVOID uhciExtension
,
431 PUHCI_EXTENSION UhciExtension
= uhciExtension
;
432 DPRINT("UhciRHClearFeaturePortResetChange: ...\n");
434 UhciExtension
->ResetChangePortMask
&= ~(1 << (Port
- 1));
435 return MP_STATUS_SUCCESS
;
440 UhciRHClearFeaturePortSuspendChange(IN PVOID uhciExtension
,
443 DPRINT("UhciRHClearFeaturePortSuspendChange: UNIMPLEMENTED. FIXME\n");
445 return MP_STATUS_SUCCESS
;
450 UhciRHClearFeaturePortOvercurrentChange(IN PVOID uhciExtension
,
453 DPRINT("UhciRHClearFeaturePortOvercurrentChange: UNIMPLEMENTED. FIXME\n");
455 return MP_STATUS_SUCCESS
;
460 UhciRHDisableIrq(IN PVOID uhciExtension
)
468 UhciRHEnableIrq(IN PVOID uhciExtension
)