// Host Controller must be Halt when Reset it\r
//\r
if (!EhcIsHalt (Ehc)) {\r
- Status = EhcHaltHC (Ehc, EHC_GENERIC_TIME);\r
+ Status = EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
\r
if (EFI_ERROR (Status)) {\r
Status = EFI_DEVICE_ERROR;\r
EhcAckAllInterrupt (Ehc);\r
EhcFreeSched (Ehc);\r
\r
- Status = EhcResetHC (Ehc, EHC_STALL_1_SECOND);\r
+ Status = EhcResetHC (Ehc, EHC_RESET_TIMEOUT);\r
\r
if (EFI_ERROR (Status)) {\r
goto ON_EXIT;\r
\r
switch (State) {\r
case EfiUsbHcStateHalt:\r
- Status = EhcHaltHC (Ehc, EHC_GENERIC_TIME);\r
+ Status = EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
break;\r
\r
case EfiUsbHcStateOperational:\r
break;\r
}\r
\r
- Status = EhcRunHC (Ehc, EHC_GENERIC_TIME);\r
+ //\r
+ // Software must not write a one to this field unless the host controller\r
+ // is in the Halted state. Doing so will yield undefined results.\r
+ // refers to Spec[EHCI1.0-2.3.1]\r
+ //\r
+ if (!EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT)) {\r
+ Status = EFI_DEVICE_ERROR;\r
+ break;\r
+ }\r
+\r
+ Status = EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);\r
break;\r
\r
case EfiUsbHcStateSuspend:\r
// Make sure Host Controller not halt before reset it\r
//\r
if (EhcIsHalt (Ehc)) {\r
- Status = EhcRunHC (Ehc, EHC_GENERIC_TIME);\r
+ Status = EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);\r
\r
if (EFI_ERROR (Status)) {\r
EHC_DEBUG (("EhcSetRootHubPortFeature :failed to start HC - %r\n", Status));\r
\r
--*/\r
{\r
- return EfiLibInstallAllDriverProtocols (\r
+ return EfiLibInstallDriverBindingComponentName2 (\r
ImageHandle,\r
SystemTable,\r
&gEhciDriverBinding,\r
ImageHandle,\r
&gEhciComponentName,\r
- NULL,\r
- NULL\r
+ &gEhciComponentName2\r
);\r
}\r
\r
/**\r
Create and initialize a USB2_HC_DEV\r
\r
- @param PciIo The PciIo on this device\r
+ @param PciIo The PciIo on this device\r
+ @param OriginalPciAttributes Original PCI attributes\r
\r
@return The allocated and initialized USB2_HC_DEV structure\r
@return if created, otherwise NULL.\r
STATIC\r
USB2_HC_DEV *\r
EhcCreateUsb2Hc (\r
- IN EFI_PCI_IO_PROTOCOL *PciIo\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN UINT64 OriginalPciAttributes\r
)\r
{\r
USB2_HC_DEV *Ehc;\r
Ehc->Usb2Hc.MajorRevision = 0x1;\r
Ehc->Usb2Hc.MinorRevision = 0x1;\r
\r
- Ehc->PciIo = PciIo;\r
+ Ehc->PciIo = PciIo;\r
+ Ehc->OriginalPciAttributes = OriginalPciAttributes;\r
\r
InitializeListHead (&Ehc->AsyncIntTransfers);\r
\r
EFI_STATUS Status;\r
USB2_HC_DEV *Ehc;\r
EFI_PCI_IO_PROTOCOL *PciIo;\r
+ UINT64 Supports;\r
+ UINT64 OriginalPciAttributes;\r
+ BOOLEAN PciAttributesSaved;\r
\r
//\r
// Open the PciIo Protocol, then enable the USB host controller\r
return EFI_DEVICE_ERROR;\r
}\r
\r
+ PciAttributesSaved = FALSE;\r
+ //\r
+ // Save original PCI attributes\r
+ //\r
Status = PciIo->Attributes (\r
PciIo,\r
- EfiPciIoAttributeOperationEnable,\r
- EFI_PCI_DEVICE_ENABLE,\r
- NULL\r
+ EfiPciIoAttributeOperationGet,\r
+ 0,\r
+ &OriginalPciAttributes\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto CLOSE_PCIIO;\r
+ }\r
+ PciAttributesSaved = TRUE;\r
+\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSupported,\r
+ 0,\r
+ &Supports\r
);\r
+ if (!EFI_ERROR (Status)) {\r
+ Supports &= EFI_PCI_DEVICE_ENABLE;\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationEnable,\r
+ Supports,\r
+ NULL\r
+ );\r
+ }\r
\r
if (EFI_ERROR (Status)) {\r
EHC_ERROR (("EhcDriverBindingStart: failed to enable controller\n"));\r
//\r
// Create then install USB2_HC_PROTOCOL\r
//\r
- Ehc = EhcCreateUsb2Hc (PciIo);\r
+ Ehc = EhcCreateUsb2Hc (PciIo, OriginalPciAttributes);\r
\r
if (Ehc == NULL) {\r
EHC_ERROR (("EhcDriverBindingStart: failed to create USB2_HC\n"));\r
// Robustnesss improvement such as for UoL\r
//\r
EhcClearLegacySupport (Ehc);\r
- EhcResetHC (Ehc, EHC_STALL_1_SECOND);\r
+ EhcResetHC (Ehc, EHC_RESET_TIMEOUT);\r
\r
Status = EhcInitHC (Ehc);\r
\r
//\r
// Start the asynchronous interrupt monitor\r
//\r
- Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_TIME);\r
+ Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_INTERVAL);\r
\r
if (EFI_ERROR (Status)) {\r
EHC_ERROR (("EhcDriverBindingStart: failed to start async interrupt monitor\n"));\r
\r
- EhcHaltHC (Ehc, EHC_GENERIC_TIME);\r
+ EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
goto UNINSTALL_USBHC;\r
}\r
\r
// Install the component name protocol, don't fail the start\r
// because of something for display.\r
//\r
- AddUnicodeString (\r
+ AddUnicodeString2 (\r
"eng",\r
gEhciComponentName.SupportedLanguages,\r
&Ehc->ControllerNameTable,\r
- L"Enhanced Host Controller (USB 2.0)"\r
+ L"Enhanced Host Controller (USB 2.0)",\r
+ TRUE\r
+ );\r
+ AddUnicodeString2 (\r
+ "en",\r
+ gEhciComponentName2.SupportedLanguages,\r
+ &Ehc->ControllerNameTable,\r
+ L"Enhanced Host Controller (USB 2.0)",\r
+ FALSE\r
);\r
\r
+\r
EHC_DEBUG (("EhcDriverBindingStart: EHCI started for controller @ %x\n", Controller));\r
return EFI_SUCCESS;\r
\r
gBS->FreePool (Ehc);\r
\r
CLOSE_PCIIO:\r
+ if (PciAttributesSaved == TRUE) {\r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
+ PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ OriginalPciAttributes,\r
+ NULL\r
+ );\r
+ }\r
+\r
gBS->CloseProtocol (\r
Controller,\r
&gEfiPciIoProtocolGuid,\r
// Stop AsyncRequest Polling timer then stop the EHCI driver\r
// and uninstall the EHCI protocl.\r
//\r
- gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_TIME);\r
- EhcHaltHC (Ehc, EHC_GENERIC_TIME);\r
+ gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_INTERVAL);\r
+ EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
\r
Status = gBS->UninstallProtocolInterface (\r
Controller,\r
}\r
\r
//\r
- // Disable the USB Host Controller\r
+ // Restore original PCI attributes\r
//\r
PciIo->Attributes (\r
- PciIo,\r
- EfiPciIoAttributeOperationDisable,\r
- EFI_PCI_DEVICE_ENABLE,\r
- NULL\r
- );\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ Ehc->OriginalPciAttributes,\r
+ NULL\r
+ );\r
\r
gBS->CloseProtocol (\r
Controller,\r
Controller\r
);\r
\r
- gBS->FreePool (Ehc);\r
- return Status;\r
+ FreePool (Ehc);\r
+\r
+ return EFI_SUCCESS;\r
}\r
\r
EFI_DRIVER_BINDING_PROTOCOL\r