Remove platform specific init code for device mode enable.
The code is different for different silicon vendor.

Cc: Ard Biesheuvel <ard.biesheu...@arm.com>
Cc: Leif Lindholm <l...@nuviainc.com>
Signed-off-by: Vin Xue <vin...@outlook.com>
---
 .../Drivers/UsbDeviceDxe/UsbDeviceDxe.c       | 18 -----
 .../Drivers/UsbDeviceDxe/UsbDeviceDxe.h       |  8 ++-
 .../Drivers/UsbDeviceDxe/UsbDeviceDxe.inf     |  4 --
 .../Drivers/UsbDeviceDxe/UsbDeviceMode.c      | 23 ------
 .../Drivers/UsbDeviceDxe/UsbFuncIo.c          | 71 +------------------
 .../Drivers/UsbDeviceDxe/UsbFuncIo.h          |  2 -
 .../Drivers/UsbDeviceDxe/UsbIoNode.h          |  1 -
 7 files changed, 6 insertions(+), 121 deletions(-)

diff --git a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.c 
b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.c
index 32fcbb1824..cf5b87f5d7 100644
--- a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.c
+++ b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.c
@@ -25,25 +25,7 @@ PlatformSpecificInit (
   VOID
   )
 {
-  UINTN                 XhciPciMmBase;
-  EFI_PHYSICAL_ADDRESS  XhciMemBaseAddress;
 
-  XhciPciMmBase   = MmPciAddress (
-                      0,
-                      0,
-                      PCI_DEVICE_NUMBER_XHCI,
-                      PCI_FUNCTION_NUMBER_XHCI,
-                      0
-                      );
-
-
-  XhciMemBaseAddress = MmioRead32 ((UINTN) (XhciPciMmBase + R_XHCI_MEM_BASE)) 
& B_XHCI_MEM_BASE_BA;
-  DEBUG ((DEBUG_INFO, "XhciPciMmBase=%x, XhciMemBaseAddress=%x\n", 
XhciPciMmBase, XhciMemBaseAddress));
-
-  MmioWrite32 ((UINTN)(XhciMemBaseAddress + R_XHCI_MEM_DUAL_ROLE_CFG0), 
0x1310800);
-
-  PmicUSBSwitchControl (TRUE);//conduction USB switch.
-  return;
 }
 
 
diff --git a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.h 
b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.h
index 2cdf553d37..ea2f2bdc7f 100644
--- a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.h
+++ b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.h
@@ -9,15 +9,15 @@
 #define __USB_DEVICE_DXE_H__
 
 #include <Uefi.h>
+#include <Library/UefiLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DevicePathLib.h>
-#include <Library/DriverLib.h>
 #include <Library/PcdLib.h>
 #include <Library/IoLib.h>
+#include <Protocol/PciIo.h>
 #include <Protocol/EfiUsbFnIo.h>
 #include <Protocol/UsbDeviceModeProtocol.h>
-#include <PlatformBaseAddresses.h>
-#include <ScAccess.h>
+#include <IndustryStandard/Pci.h>
 #include "UsbFuncIo.h"
 #include "UsbDeviceMode.h"
 
@@ -28,6 +28,8 @@
 #define USBFUIO_CONTEXT_FROM_PROTOCOL(a)   CR (a, USB_XDCI_DEV_CONTEXT, 
UsbFunIoProtocol, EFI_USB_DEV_SIGNATURE)
 #define USBUSBD_CONTEXT_FROM_PROTOCOL(a)   CR (a, USB_XDCI_DEV_CONTEXT, 
UsbDevModeProtocol, EFI_USB_DEV_SIGNATURE)
 
+#define R_OTG_BAR0                         0x10        // BAR 0
+#define B_OTG_BAR0_BA                      0xFFE00000  // Base Address
 
 typedef struct _USB_FUIO_EVENT_NODE   USB_FUIO_EVENT_NODE;
 
diff --git a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.inf 
b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.inf
index 92baaa9a0a..a5fbe2336a 100644
--- a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.inf
+++ b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceDxe.inf
@@ -33,20 +33,16 @@
 
 [Packages]
   MdePkg/MdePkg.dec
-  BroxtonSiPkg/BroxtonSiPkg.dec
-  BroxtonPlatformPkg/PlatformPkg.dec
 
 [LibraryClasses]
   BaseMemoryLib
   DebugLib
   DevicePathLib
   MemoryAllocationLib
-  TimerLib
   PcdLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   UefiLib
-  PmicLib
 
 [Protocols]
   gEfiUsbDeviceModeProtocolGuid
diff --git a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceMode.c 
b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceMode.c
index 8e6da670fd..1a0248fa6a 100644
--- a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceMode.c
+++ b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbDeviceMode.c
@@ -9,8 +9,6 @@
 #include <Library/BaseLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/IoLib.h>
-#include <PlatformBaseAddresses.h>
-#include <ScAccess.h>
 #include "XdciUtility.h"
 #include "UsbDeviceMode.h"
 #include "UsbDeviceDxe.h"
@@ -50,28 +48,7 @@ BOOLEAN mXdciRun = FALSE;
 STATIC VOID
 XhciSwitchSwid(BOOLEAN enable)
 {
-  UINTN                             XhciPciMmBase;
-  EFI_PHYSICAL_ADDRESS              XhciMemBaseAddress;
-  UINT32                            DualRoleCfg0;
-  UINT32                            DualRoleCfg1;
-
-  XhciPciMmBase = MmPciAddress (0, 0, PCI_DEVICE_NUMBER_XHCI, 
PCI_FUNCTION_NUMBER_XHCI, 0);
-  XhciMemBaseAddress = MmioRead32 ((UINTN) (XhciPciMmBase + R_XHCI_MEM_BASE)) 
& B_XHCI_MEM_BASE_BA;
-  DEBUG ((DEBUG_INFO, "XhciPciMmBase=%x, XhciMemBaseAddress=%x\n", 
XhciPciMmBase, XhciMemBaseAddress));
-
-  DualRoleCfg0 = MmioRead32 ((UINTN)(XhciMemBaseAddress + 
R_XHCI_MEM_DUAL_ROLE_CFG0));
-  if (enable) {
-    DualRoleCfg0 = DualRoleCfg0 | (1 << 24) | (1 << 21) | (1 << 20);
-    DEBUG ((DEBUG_INFO, "DualRoleCfg0 : Set SW ID : 0x%x \n", DualRoleCfg0));
-  }
-  else {
-    DualRoleCfg0 = DualRoleCfg0 & ~(1 << 24) & ~(1 << 21) & ~(1 << 20);
-    DEBUG ((DEBUG_INFO, "DualRoleCfg0 : Clear SW ID : 0x%x \n", DualRoleCfg0));
-  }
-  MmioWrite32 ((UINTN)(XhciMemBaseAddress + R_XHCI_MEM_DUAL_ROLE_CFG0), 
DualRoleCfg0);
 
-  DualRoleCfg1 = MmioRead32 ((UINTN)(XhciMemBaseAddress + 
R_XHCI_MEM_DUAL_ROLE_CFG1));
-  DEBUG ((DEBUG_INFO, "DualRoleCfg1 : 0x%x \n", DualRoleCfg1));
 }
 
 VOID
diff --git a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbFuncIo.c 
b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbFuncIo.c
index 566e23ec69..d4eea39e6d 100644
--- a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbFuncIo.c
+++ b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbFuncIo.c
@@ -107,76 +107,7 @@ DetectPort (
   OUT EFI_USBFN_PORT_TYPE    *PortType
   )
 {
-  USB_XDCI_DEV_CONTEXT  *UsbFuncIoDevPtr;
-  EFI_STATUS            Status;
-  UINT8                 Value8;
-
-  DEBUG ((USB_FUIO_DEBUG_INFO, "DetectPort - Entry\n"));
-
-  UsbFuncIoDevPtr = USBFUIO_CONTEXT_FROM_PROTOCOL (This);
-
-  //
-  // USBSRCDETRSLT Bit[5:2]
-  // Result of USB HW Source Detection algorithm
-  // Power-Domain: VRTC
-  // Result of USB HW Source Detection algorithm :
-  // 0000 = Not determined
-  // 0001 = SDP Attached
-  // 0010 = DCP Attached
-  // 0011 = CDP Attached
-  // 0100 = ACA Attached
-  // 0101 = SE1 Attached
-  // 0110 = MHL Attached
-  // 0111 = Floating D+/D- Attached
-  // 1000 = Other Attached
-  // 1001 = DCP detected by ext. USB PHY
-  // 1010-1111 = Rsvd
-  // Reset: 0000B
-  //
-
-  Value8 =PmicRead8 (0x5E, 0X29);
-  if ((Value8 & 0x03) != 0x02) {
-    *PortType = EfiUsbUnknownPort;
-    Status = EFI_NOT_READY;
-    goto out;
-  }
-
-  Value8 = Value8 >> 2 & 0x0f;
-  Status = EFI_SUCCESS;
-  switch (Value8) {
-    case 1:
-      *PortType = EfiUsbStandardDownstreamPort;
-      break;
-    case 2:
-      *PortType = EfiUsbDedicatedChargingPort;
-      break;
-    case 3:
-      *PortType = EfiUsbChargingDownstreamPort;
-      break;
-
-    case 4:
-    case 5:
-    case 6:
-    case 7:
-    case 8:
-    case 9:
-      *PortType = EfiUsbUnknownPort;
-      break;
-    case 0:
-    case 10:
-    case 11:
-    case 12:
-    case 13:
-    case 14:
-    case 15:
-      *PortType = EfiUsbUnknownPort;
-      Status = EFI_NOT_READY;
-     break;
-  }
-
-out:
-  DEBUG ((USB_FUIO_DEBUG_INFO, "DetectPort - Exit\n"));
-  return EFI_SUCCESS;
+  return EFI_UNSUPPORTED;
 }
 
 
diff --git a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbFuncIo.h 
b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbFuncIo.h
index 6bfd17fa69..3a95b931c2 100644
--- a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbFuncIo.h
+++ b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbFuncIo.h
@@ -11,10 +11,8 @@
 #include <Uefi.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DevicePathLib.h>
-#include <Library/DriverLib.h>
 #include <Library/PcdLib.h>
 #include <Protocol/EfiUsbFnIo.h>
-#include <Library/PmicLib.h>
 #include <Library/UsbDeviceLib.h>
 #include <Library/PrintLib.h>
 #include "UsbIoNode.h"
diff --git a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbIoNode.h 
b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbIoNode.h
index 850653f9d6..0b416ec7a7 100644
--- a/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbIoNode.h
+++ b/Silicon/Synopsys/DesignWare/Drivers/UsbDeviceDxe/UsbIoNode.h
@@ -11,7 +11,6 @@
 #include <Uefi.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DevicePathLib.h>
-#include <Library/DriverLib.h>
 
 #define  USB_DEBUG_MEM_NODE_INFO  EFI_D_INIT
 #define  USB_DEBUG_MEM_NODE_ERROR EFI_D_ERROR
-- 
2.27.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62764): https://edk2.groups.io/g/devel/message/62764
Mute This Topic: https://groups.io/mt/75608950/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to