public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Vin Xue <vinxue@outlook.com>
To: devel@edk2.groups.io
Cc: Vin Xue <vinxue@outlook.com>,
	Ard Biesheuvel <ard.biesheuvel@arm.com>,
	Leif Lindholm <leif@nuviainc.com>
Subject: [edk2-platforms PATCH 3/5] Silicon/Synopsys/DesignWare: Remove platform specific init code.
Date: Fri, 17 Jul 2020 18:02:01 +0800	[thread overview]
Message-ID: <SL2PR03MB444219511377B5B974B2225EC57C0@SL2PR03MB4442.apcprd03.prod.outlook.com> (raw)
In-Reply-To: <20200717100203.724-1-vinxue@outlook.com>

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

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Signed-off-by: Vin Xue <vinxue@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


  parent reply	other threads:[~2020-07-17 10:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200717100203.724-1-vinxue@outlook.com>
2020-07-17 10:02 ` [edk2-platforms PATCH 2/5] Silicon/Synopsys/DesignWare: Replace BSD License with BSD+Patent License Vin Xue
2020-07-17 10:02 ` Vin Xue [this message]
2020-07-17 10:02 ` [edk2-platforms PATCH 4/5] Silicon/Synopsys/DesignWare: Support build against DesignWare.dsc Vin Xue
2020-07-17 10:02 ` [edk2-platforms PATCH 5/5] Silicon/Synopsys/DesignWare: Basic support for USB SuperSpeedPlus Vin Xue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SL2PR03MB444219511377B5B974B2225EC57C0@SL2PR03MB4442.apcprd03.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox