public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] MdeModulePkg/Ehci: don't clear port status bits during init
@ 2016-11-30  5:15 Feng Tian
  2016-11-30  5:32 ` Zeng, Star
  0 siblings, 1 reply; 2+ messages in thread
From: Feng Tian @ 2016-11-30  5:15 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Mike Turner

Port status bits are clear in original code, so no enumeration
takes place.
Changing this to prevent the status bits from being cleared
allows enumeration to proceed normally.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Mike Turner <Michael.Turner@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Mike Turner <Michael.Turner@microsoft.com>
Signed-off-by: Feng Tian <feng.tian@intel.com>
---
 MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c | 10 +++++++++-
 MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c | 18 +++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
index 88a66ae..3a6ed02 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
@@ -591,6 +591,7 @@ EhcInitHC (
 {
   EFI_STATUS              Status;
   UINT32                  Index;
+  UINT32                  RegVal;
 
   // This ASSERT crashes the BeagleBoard. There is some issue in the USB stack.
   // This ASSERT needs to be removed so the BeagleBoard will boot. When we fix
@@ -626,7 +627,14 @@ EhcInitHC (
   //
   if (Ehc->HcStructParams & HCSP_PPC) {
     for (Index = 0; Index < (UINT8) (Ehc->HcStructParams & HCSP_NPORTS); Index++) {
-      EhcSetOpRegBit (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * Index)), PORTSC_POWER);
+      //
+      // Do not clear port status bits on initialization.  Otherwise devices will
+      // not enumerate properly at startup.
+      //
+      RegVal  = EhcReadOpReg(Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * Index)));
+      RegVal &= ~PORTSC_CHANGE_MASK;
+      RegVal |= PORTSC_POWER;
+      EhcWriteOpReg (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * Index)), RegVal);
     }
   }
 
diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
index 09769ea..31647ff 100644
--- a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
+++ b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
@@ -2,7 +2,7 @@
 PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid
 which is used to enable recovery function from USB Drivers.
 
-Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
   
 This program and the accompanying materials
 are licensed and made available under the terms and conditions
@@ -411,12 +411,20 @@ EhcPowerOnAllPorts (
   IN PEI_USB2_HC_DEV          *Ehc
   )
 {
-  UINT8 PortNumber;
-  UINT8 Index;
-
+  UINT8     PortNumber;
+  UINT8     Index;
+  UINT32    RegVal;
+  
   PortNumber = (UINT8)(Ehc->HcStructParams & HCSP_NPORTS);
   for (Index = 0; Index < PortNumber; Index++) {
-    EhcSetOpRegBit (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, PORTSC_POWER);
+    //
+    // Do not clear port status bits on initialization.  Otherwise devices will
+    // not enumerate properly at startup.
+    //
+    RegVal  = EhcReadOpReg(Ehc, EHC_PORT_STAT_OFFSET + 4 * Index);
+    RegVal &= ~PORTSC_CHANGE_MASK;
+    RegVal |= PORTSC_POWER;
+    EhcWriteOpReg (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, RegVal);
   }
 }
 
-- 
2.7.1.windows.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] MdeModulePkg/Ehci: don't clear port status bits during init
  2016-11-30  5:15 [patch] MdeModulePkg/Ehci: don't clear port status bits during init Feng Tian
@ 2016-11-30  5:32 ` Zeng, Star
  0 siblings, 0 replies; 2+ messages in thread
From: Zeng, Star @ 2016-11-30  5:32 UTC (permalink / raw)
  To: Tian, Feng, edk2-devel@lists.01.org; +Cc: Mike Turner, Zeng, Star

Reviewed-by: Star Zeng <star.zeng@intel.com>

-----Original Message-----
From: Tian, Feng 
Sent: Wednesday, November 30, 2016 1:16 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Mike Turner <Michael.Turner@microsoft.com>
Subject: [patch] MdeModulePkg/Ehci: don't clear port status bits during init

Port status bits are clear in original code, so no enumeration takes place.
Changing this to prevent the status bits from being cleared allows enumeration to proceed normally.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Mike Turner <Michael.Turner@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Mike Turner <Michael.Turner@microsoft.com>
Signed-off-by: Feng Tian <feng.tian@intel.com>
---
 MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c | 10 +++++++++-  MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c | 18 +++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
index 88a66ae..3a6ed02 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
@@ -591,6 +591,7 @@ EhcInitHC (
 {
   EFI_STATUS              Status;
   UINT32                  Index;
+  UINT32                  RegVal;
 
   // This ASSERT crashes the BeagleBoard. There is some issue in the USB stack.
   // This ASSERT needs to be removed so the BeagleBoard will boot. When we fix @@ -626,7 +627,14 @@ EhcInitHC (
   //
   if (Ehc->HcStructParams & HCSP_PPC) {
     for (Index = 0; Index < (UINT8) (Ehc->HcStructParams & HCSP_NPORTS); Index++) {
-      EhcSetOpRegBit (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * Index)), PORTSC_POWER);
+      //
+      // Do not clear port status bits on initialization.  Otherwise devices will
+      // not enumerate properly at startup.
+      //
+      RegVal  = EhcReadOpReg(Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * Index)));
+      RegVal &= ~PORTSC_CHANGE_MASK;
+      RegVal |= PORTSC_POWER;
+      EhcWriteOpReg (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * 
+ Index)), RegVal);
     }
   }
 
diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
index 09769ea..31647ff 100644
--- a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
+++ b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
@@ -2,7 +2,7 @@
 PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid  which is used to enable recovery function from USB Drivers.
 
-Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
   
 This program and the accompanying materials  are licensed and made available under the terms and conditions @@ -411,12 +411,20 @@ EhcPowerOnAllPorts (
   IN PEI_USB2_HC_DEV          *Ehc
   )
 {
-  UINT8 PortNumber;
-  UINT8 Index;
-
+  UINT8     PortNumber;
+  UINT8     Index;
+  UINT32    RegVal;
+  
   PortNumber = (UINT8)(Ehc->HcStructParams & HCSP_NPORTS);
   for (Index = 0; Index < PortNumber; Index++) {
-    EhcSetOpRegBit (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, PORTSC_POWER);
+    //
+    // Do not clear port status bits on initialization.  Otherwise devices will
+    // not enumerate properly at startup.
+    //
+    RegVal  = EhcReadOpReg(Ehc, EHC_PORT_STAT_OFFSET + 4 * Index);
+    RegVal &= ~PORTSC_CHANGE_MASK;
+    RegVal |= PORTSC_POWER;
+    EhcWriteOpReg (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, RegVal);
   }
 }
 
--
2.7.1.windows.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-30  5:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-30  5:15 [patch] MdeModulePkg/Ehci: don't clear port status bits during init Feng Tian
2016-11-30  5:32 ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox