summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus/Pci/EhciDxe
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-10-25 07:59:45 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-10-25 07:59:45 +0000
commit68246fa809e4a8ab61ce7bbfdd1a0b31d03e83fb (patch)
tree0725e1e638d299d3e103eebbe622bd740bb5ef43 /MdeModulePkg/Bus/Pci/EhciDxe
parentc9a0a0fcf18a9b99fb3522ad0a775fffc32c0e71 (diff)
downloadedk2-platforms-68246fa809e4a8ab61ce7bbfdd1a0b31d03e83fb.tar.xz
Save original PCI attributes in start() function and restore it in Stop() for those PCI device drivers.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4212 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Bus/Pci/EhciDxe')
-rw-r--r--MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c71
-rw-r--r--MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h5
2 files changed, 48 insertions, 28 deletions
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
index 488c963952..32ae6b6cdc 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
@@ -133,7 +133,7 @@ EhcReset (
goto ON_EXIT;
}
}
-
+
//
// Clean up the asynchronous transfers, currently only
// interrupt supports asynchronous operation.
@@ -262,9 +262,9 @@ EhcSetState (
//
// Software must not write a one to this field unless the host controller
- // is in the Halted state. Doing so will yield undefined results.
+ // is in the Halted state. Doing so will yield undefined results.
// refers to Spec[EHCI1.0-2.3.1]
- //
+ //
if (!EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT)) {
Status = EFI_DEVICE_ERROR;
break;
@@ -454,7 +454,7 @@ EhcSetRootHubPortFeature (
break;
}
}
-
+
//
// Set one to PortReset bit must also set zero to PortEnable bit
//
@@ -1395,7 +1395,8 @@ ON_EXIT:
/**
Create and initialize a USB2_HC_DEV
- @param PciIo The PciIo on this device
+ @param PciIo The PciIo on this device
+ @param OriginalPciAttributes Original PCI attributes
@return The allocated and initialized USB2_HC_DEV structure
@return if created, otherwise NULL.
@@ -1404,7 +1405,8 @@ ON_EXIT:
STATIC
USB2_HC_DEV *
EhcCreateUsb2Hc (
- IN EFI_PCI_IO_PROTOCOL *PciIo
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT64 OriginalPciAttributes
)
{
USB2_HC_DEV *Ehc;
@@ -1437,7 +1439,8 @@ EhcCreateUsb2Hc (
Ehc->Usb2Hc.MajorRevision = 0x1;
Ehc->Usb2Hc.MinorRevision = 0x1;
- Ehc->PciIo = PciIo;
+ Ehc->PciIo = PciIo;
+ Ehc->OriginalPciAttributes = OriginalPciAttributes;
InitializeListHead (&Ehc->AsyncIntTransfers);
@@ -1492,6 +1495,7 @@ EhcDriverBindingStart (
USB2_HC_DEV *Ehc;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 Supports;
+ UINT64 OriginalPciAttributes;
//
// Open the PciIo Protocol, then enable the USB host controller
@@ -1510,6 +1514,20 @@ EhcDriverBindingStart (
return EFI_DEVICE_ERROR;
}
+ //
+ // Save original PCI attributes
+ //
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationGet,
+ 0,
+ &OriginalPciAttributes
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
Status = PciIo->Attributes (
PciIo,
EfiPciIoAttributeOperationSupported,
@@ -1534,7 +1552,7 @@ EhcDriverBindingStart (
//
// Create then install USB2_HC_PROTOCOL
//
- Ehc = EhcCreateUsb2Hc (PciIo);
+ Ehc = EhcCreateUsb2Hc (PciIo, OriginalPciAttributes);
if (Ehc == NULL) {
EHC_ERROR (("EhcDriverBindingStart: failed to create USB2_HC\n"));
@@ -1616,6 +1634,16 @@ FREE_POOL:
gBS->FreePool (Ehc);
CLOSE_PCIIO:
+ //
+ // Restore original PCI attributes
+ //
+ PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationSet,
+ OriginalPciAttributes,
+ NULL
+ );
+
gBS->CloseProtocol (
Controller,
&gEfiPciIoProtocolGuid,
@@ -1653,7 +1681,6 @@ EhcDriverBindingStop (
EFI_USB2_HC_PROTOCOL *Usb2Hc;
EFI_PCI_IO_PROTOCOL *PciIo;
USB2_HC_DEV *Ehc;
- UINT64 Supports;
//
// Test whether the Controller handler passed in is a valid
@@ -1704,23 +1731,14 @@ EhcDriverBindingStop (
}
//
- // Disable the USB Host Controller
+ // Restore original PCI attributes
//
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationSupported,
- 0,
- &Supports
- );
- if (!EFI_ERROR (Status)) {
- Supports &= EFI_PCI_DEVICE_ENABLE;
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationDisable,
- Supports,
- NULL
- );
- }
+ PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationSet,
+ Ehc->OriginalPciAttributes,
+ NULL
+ );
gBS->CloseProtocol (
Controller,
@@ -1729,7 +1747,8 @@ EhcDriverBindingStop (
Controller
);
- gBS->FreePool (Ehc);
+ FreePool (Ehc);
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
index 7104914e93..50a3f1c698 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
@@ -65,11 +65,11 @@ enum {
EHC_ROOT_PORT_RECOVERY_STALL = 20 * EHC_1_MILLISECOND,
//
- // Sync and Async transfer polling interval, set by experience,
+ // Sync and Async transfer polling interval, set by experience,
// and the unit of Async is 100us, means 50ms as interval.
//
EHC_SYNC_POLL_INTERVAL = 20 * EHC_1_MICROSECOND,
- EHC_ASYNC_POLL_INTERVAL = 50 * 10000U,
+ EHC_ASYNC_POLL_INTERVAL = 50 * 10000U,
//
// EHC raises TPL to TPL_NOTIFY to serialize all its operations
@@ -111,6 +111,7 @@ struct _USB2_HC_DEV {
EFI_USB2_HC_PROTOCOL Usb2Hc;
EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT64 OriginalPciAttributes;
USBHC_MEM_POOL *MemPool;
//