* Re: [PATCH edk2-platforms 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver
2020-06-02 13:47 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
@ 2020-06-02 8:43 ` Ard Biesheuvel
0 siblings, 0 replies; 14+ messages in thread
From: Ard Biesheuvel @ 2020-06-02 8:43 UTC (permalink / raw)
To: Meenakshi Aggarwal, leif, michael.d.kinney, devel
Cc: v.sethi, Meenakshi Aggarwal
Hello Meenakshi,
On 6/2/20 3:47 PM, Meenakshi Aggarwal wrote:
> From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
>
> Add support of DWC3 controller driver which performs
> DWC3 controller initialization and register itself as
> NonDiscoverableMmioDevice
>
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
> Silicon/NXP/NxpQoriqLs.dec | 5 +
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 41 ++++
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 +++++++++++++
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 212 ++++++++++++++++++++
> 4 files changed, 396 insertions(+)
>
> diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
> index d4d3057af509..72c1744fc934 100644
> --- a/Silicon/NXP/NxpQoriqLs.dec
> +++ b/Silicon/NXP/NxpQoriqLs.dec
> @@ -36,6 +36,11 @@ [PcdsFixedAtBuild.common]
> gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x0|UINT32|0x00000502
> gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x0|UINT32|0x00000503
>
> + # Pcds for USB
> + gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr|0x0|UINT64|0x00000510
> + gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
> + gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
> +
> [PcdsDynamic.common]
> gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
> gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
> diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> new file mode 100644
> index 000000000000..b8c3be4bfb49
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> @@ -0,0 +1,41 @@
> +# UsbHcd.inf
> +#
> +# Copyright 2017, 2020 NXP
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#
> +
> +[Defines]
> + INF_VERSION = 0x0001001A
0x0001001A (or simply 1.27 works fine as well)
> + BASE_NAME = UsbHcdDxe
> + FILE_GUID = 196e7c2a-37b2-4b85-8683-718588952449
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + ENTRY_POINT = InitializeUsbHcd
> +
> +[Sources.common]
> + UsbHcd.c
> +
Include the .h file here as well
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + Silicon/NXP/NxpQoriqLs.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + IoLib
> + MemoryAllocationLib
> + NonDiscoverableDeviceRegistrationLib
> + UefiBootServicesTableLib
> + UefiDriverEntryPoint
> +
> +[FixedPcd]
> + gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController
> + gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr
> + gNxpQoriqLsTokenSpaceGuid.PcdUsbSize
> +
> +[Depex]
> + TRUE
> diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
> new file mode 100644
> index 000000000000..cd9f9ad80125
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
> @@ -0,0 +1,138 @@
> +/** @file
> +
> + Copyright 2017, 2020 NXP
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef USB_HCD_H_
> +#define USB_HCD_H_
> +
> +#include <Base.h>
> +
> +/* Global constants */
> +#define DWC3_GSNPSID_MASK 0xffff0000
> +#define DWC3_SYNOPSYS_ID 0x55330000
> +#define DWC3_RELEASE_MASK 0xffff
> +#define DWC3_REG_OFFSET 0xC100
> +#define DWC3_RELEASE_190a 0x190a
> +
> +/* Global Configuration Register */
> +#define DWC3_GCTL_U2RSTECN BIT16
> +#define DWC3_GCTL_PRTCAPDIR(N) ((N) << 12)
> +#define DWC3_GCTL_PRTCAP_HOST 1
> +#define DWC3_GCTL_PRTCAP_OTG 3
> +#define DWC3_GCTL_CORESOFTRESET BIT11
> +#define DWC3_GCTL_SCALEDOWN(N) ((N) << 4)
> +#define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3)
> +#define DWC3_GCTL_DISSCRAMBLE BIT3
> +#define DWC3_GCTL_DSBLCLKGTNG BIT0
> +
> +/* Global HWPARAMS1 Register */
> +#define DWC3_GHWPARAMS1_EN_PWROPT(N) (((N) & (3 << 24)) >> 24)
> +#define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1
> +
> +/* Global USB2 PHY Configuration Register */
> +#define DWC3_GUSB2PHYCFG_PHYSOFTRST BIT31
> +
> +/* Global USB3 PIPE Control Register */
> +#define DWC3_GUSB3PIPECTL_PHYSOFTRST BIT31
> +
> +/* Global Frame Length Adjustment Register */
> +#define GFLADJ_30MHZ_REG_SEL BIT7
> +#define GFLADJ_30MHZ(N) ((N) & 0x3f)
> +#define GFLADJ_30MHZ_DEFAULT 0x20
> +
> +/* Default to the FSL XHCI defines */
> +#define USB3_ENABLE_BEAT_BURST 0xF
> +#define USB3_ENABLE_BEAT_BURST_MASK 0xFF
> +#define USB3_SET_BEAT_BURST_LIMIT 0xF00
> +
> +typedef struct {
> + UINT32 GEvntAdrLo;
> + UINT32 GEvntAdrHi;
> + UINT32 GEvntSiz;
> + UINT32 GEvntCount;
> +} G_EVENT_BUFFER;
> +
> +typedef struct {
> + UINT32 DDepCmdPar2;
> + UINT32 DDepCmdPar1;
> + UINT32 DDepCmdPar0;
> + UINT32 DDepCmd;
> +} D_PHYSICAL_EP;
> +
> +typedef struct {
> + UINT32 GSBusCfg0;
> + UINT32 GSBusCfg1;
> + UINT32 GTxThrCfg;
> + UINT32 GRxThrCfg;
> + UINT32 GCtl;
> + UINT32 Res1;
> + UINT32 GSts;
> + UINT32 Res2;
> + UINT32 GSnpsId;
> + UINT32 GGpio;
> + UINT32 GUid;
> + UINT32 GUctl;
> + UINT64 GBusErrAddr;
> + UINT64 GPrtbImap;
> + UINT32 GHwParams0;
> + UINT32 GHwParams1;
> + UINT32 GHwParams2;
> + UINT32 GHwParams3;
> + UINT32 GHwParams4;
> + UINT32 GHwParams5;
> + UINT32 GHwParams6;
> + UINT32 GHwParams7;
> + UINT32 GDbgFifoSpace;
> + UINT32 GDbgLtssm;
> + UINT32 GDbgLnmcc;
> + UINT32 GDbgBmu;
> + UINT32 GDbgLspMux;
> + UINT32 GDbgLsp;
> + UINT32 GDbgEpInfo0;
> + UINT32 GDbgEpInfo1;
> + UINT64 GPrtbImapHs;
> + UINT64 GPrtbImapFs;
> + UINT32 Res3[28];
> + UINT32 GUsb2PhyCfg[16];
> + UINT32 GUsb2I2cCtl[16];
> + UINT32 GUsb2PhyAcc[16];
> + UINT32 GUsb3PipeCtl[16];
> + UINT32 GTxFifoSiz[32];
> + UINT32 GRxFifoSiz[32];
> + G_EVENT_BUFFER GEvntBuf[32];
> + UINT32 GHwParams8;
> + UINT32 Res4[11];
> + UINT32 GFLAdj;
> + UINT32 Res5[51];
> + UINT32 DCfg;
> + UINT32 DCtl;
> + UINT32 DEvten;
> + UINT32 DSts;
> + UINT32 DGCmdPar;
> + UINT32 DGCmd;
> + UINT32 Res6[2];
> + UINT32 DAlepena;
> + UINT32 Res7[55];
> + D_PHYSICAL_EP DPhyEpCmd[32];
> + UINT32 Res8[128];
> + UINT32 OCfg;
> + UINT32 OCtl;
> + UINT32 OEvt;
> + UINT32 OEvtEn;
> + UINT32 OSts;
> + UINT32 Res9[3];
> + UINT32 AdpCfg;
> + UINT32 AdpCtl;
> + UINT32 AdpEvt;
> + UINT32 AdpEvten;
> + UINT32 BcCfg;
> + UINT32 Res10;
> + UINT32 BcEvt;
> + UINT32 BcEvten;
> +} DWC3;
> +
> +#endif
> diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
> new file mode 100644
> index 000000000000..40b027c639b1
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
> @@ -0,0 +1,212 @@
> +/** @file
> +
> + Copyright 2017, 2020 NXP
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/NonDiscoverableDeviceRegistrationLib.h>
> +
> +#include "UsbHcd.h"
> +
> +STATIC
> +VOID
> +XhciSetBeatBurstLength (
> + IN UINTN UsbReg
> + )
> +{
> + DWC3 *Dwc3Reg;
> +
> + Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
> +
> + MmioAndThenOr32 ((UINTN)&Dwc3Reg->GSBusCfg0, ~USB3_ENABLE_BEAT_BURST_MASK,
> + USB3_ENABLE_BEAT_BURST);
Indentation (align with the ( on the previous line, or with the 'i' in
MmioAndThenOr32)
> + MmioOr32 ((UINTN)&Dwc3Reg->GSBusCfg1, USB3_SET_BEAT_BURST_LIMIT);
> +
> + return;
No return needed from functions returning VOID
> +}
> +
> +STATIC
> +VOID
> +Dwc3SetFladj (
> + IN DWC3 *Dwc3Reg,
> + IN UINT32 Val
> + )
> +{
> + MmioOr32 ((UINTN)&Dwc3Reg->GFLAdj, GFLADJ_30MHZ_REG_SEL |
> + GFLADJ_30MHZ(Val));
Indentation
> +}
> +
STATIC?
> +VOID
> +Dwc3SetMode (
> + IN DWC3 *Dwc3Reg,
> + IN UINT32 Mode
> + )
> +{
> + MmioAndThenOr32 ((UINTN)&Dwc3Reg->GCtl,
> + ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)),
> + DWC3_GCTL_PRTCAPDIR(Mode));
Indentation
> +}
> +
> +STATIC
> +VOID
> +Dwc3CoreSoftReset (
> + IN DWC3 *Dwc3Reg
> + )
> +{
> + MmioOr32 ((UINTN)&Dwc3Reg->GCtl, DWC3_GCTL_CORESOFTRESET);
Are you sure you don't need a MemoryFence() here?
> + MmioOr32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST);
> + MmioOr32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, DWC3_GUSB2PHYCFG_PHYSOFTRST);
.. or maybe here?
> + MmioAnd32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], ~DWC3_GUSB3PIPECTL_PHYSOFTRST);
> + MmioAnd32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, ~DWC3_GUSB2PHYCFG_PHYSOFTRST);
> + MmioAnd32 ((UINTN)&Dwc3Reg->GCtl, ~DWC3_GCTL_CORESOFTRESET);
> +
> + return;
Drop the return
> +}
> +
> +STATIC
> +EFI_STATUS
> +Dwc3CoreInit (
> + IN DWC3 *Dwc3Reg
> + )
> +{
> + UINT32 Revision;
> + UINT32 Reg;
> + UINTN Dwc3Hwparams1;
> +
> + Revision = MmioRead32 ((UINTN)&Dwc3Reg->GSnpsId);
> + //
> + // This should read as 0x5533, ascii of U3(DWC_usb3) followed by revision number
> + //
> + if ((Revision & DWC3_GSNPSID_MASK) != DWC3_SYNOPSYS_ID) {
> + DEBUG ((DEBUG_ERROR,"This is not a DesignWare USB3 DRD Core.\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + Dwc3CoreSoftReset (Dwc3Reg);
> +
> + Reg = MmioRead32 ((UINTN)&Dwc3Reg->GCtl);
> + Reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
> + Reg &= ~DWC3_GCTL_DISSCRAMBLE;
> +
> + Dwc3Hwparams1 = MmioRead32 ((UINTN)&Dwc3Reg->GHwParams1);
> +
> + if (DWC3_GHWPARAMS1_EN_PWROPT(Dwc3Hwparams1) == DWC3_GHWPARAMS1_EN_PWROPT_CLK) {
> + Reg &= ~DWC3_GCTL_DSBLCLKGTNG;
> + } else {
> + DEBUG ((DEBUG_ERROR,"No power optimization available.\n"));
If this 'error' condition requires no handling whatsoever, shouldn't it
be a DEBUG_WARN instead?
> + }
> +
> + if ((Revision & DWC3_RELEASE_MASK) < DWC3_RELEASE_190a) {
> + Reg |= DWC3_GCTL_U2RSTECN;
> + }
> +
> + MmioWrite32 ((UINTN)&Dwc3Reg->GCtl, Reg);
> +
> + return EFI_SUCCESS;
> +}
> +
> +STATIC
> +EFI_STATUS
> +XhciCoreInit (
> + IN UINTN UsbReg
> + )
> +{
> + EFI_STATUS Status;
> + DWC3 *Dwc3Reg;
> +
> + Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
> +
> + Status = Dwc3CoreInit (Dwc3Reg);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "Dwc3CoreInit Failed for controller 0x%x (0x%x) \n",
> + UsbReg, Status));
Indentation
> + return Status;
> + }
> +
> + Dwc3SetMode (Dwc3Reg, DWC3_GCTL_PRTCAP_HOST);
> +
> + Dwc3SetFladj (Dwc3Reg, GFLADJ_30MHZ_DEFAULT);
> +
> + return Status;
> +}
> +
> +STATIC
> +EFI_STATUS
> +EFIAPI
> +InitializeUsbController (
> + IN UINTN UsbReg
> + )
> +{
> + EFI_STATUS Status;
> +
> + Status = XhciCoreInit (UsbReg);
> +
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + //
> + // Change beat burst and outstanding pipelined transfers requests
> + //
> + XhciSetBeatBurstLength (UsbReg);
> +
> + return Status;
> +}
> +
> +/**
> + The Entry Point of module. It follows the standard UEFI driver model.
> +
> + @param[in] ImageHandle The firmware allocated handle for the EFI image.
> + @param[in] SystemTable A pointer to the EFI System Table.
> +
> + @retval EFI_SUCCESS The entry point is executed successfully.
> + @retval other Some error occurs when executing this entry point.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InitializeUsbHcd (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 NumUsbController;
> + UINT32 ControllerAddr;
> + UINT32 Index;
> +
> + Status = EFI_SUCCESS;
> + NumUsbController = PcdGet32 (PcdNumUsbController);
> +
> + for (Index = 0; Index < NumUsbController; Index++) {
> + ControllerAddr = PcdGet64 (PcdUsbBaseAddr) +
> + (Index * PcdGet32 (PcdUsbSize));
> +
> + Status = InitializeUsbController (ControllerAddr);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "USB Controller initialization Failed for %d (0x%x)\n",
> + ControllerAddr, Status));
Indentation
Also, use %r for status codes.
> + continue;
> + }
> +
> + Status = RegisterNonDiscoverableMmioDevice (
> + NonDiscoverableDeviceTypeXhci,
> + NonDiscoverableDeviceDmaTypeNonCoherent,
> + NULL,
> + NULL,
> + 1,
> + ControllerAddr, PcdGet32 (PcdUsbSize)
> + );
> +
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "Failed to register USB device (0x%x) with error 0x%x \n",
> + ControllerAddr, Status));
Indentation
Also, use %r for status codes.
> + }
> + }
> +
> + return Status;
> +}
>
It would be better for this registration to occur in an EndOfDxe event
notification callback - that way, the USB controller will not be
connected recursively unless required for booting if the boot manager
decides not to call EfiBootManagerConnectAll()
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH edk2-platforms 0/2] Add USB driver support
@ 2020-06-02 13:47 Meenakshi Aggarwal
2020-06-02 13:47 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-02 13:47 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
This patchset implement USB driver for DWC3 controller and enable
USB for LX2160A Platform.
Meenakshi Aggarwal (2):
Silicon/NXP: Add DWC3 USB controller initialization driver
Platform/NXP:LX2160: Enable support of USB controller
Silicon/NXP/NxpQoriqLs.dec | 5 +
Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 +
Silicon/NXP/NxpQoriqLs.dsc.inc | 12 ++
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 12 ++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 41 ++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 +++++++++++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 212 ++++++++++++++++++++
8 files changed, 425 insertions(+)
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
--
1.9.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH edk2-platforms 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver
2020-06-02 13:47 [PATCH edk2-platforms 0/2] Add USB driver support Meenakshi Aggarwal
@ 2020-06-02 13:47 ` Meenakshi Aggarwal
2020-06-02 8:43 ` Ard Biesheuvel
2020-06-02 13:47 ` [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of USB controller Meenakshi Aggarwal
2020-06-03 16:00 ` [PATCH edk2-platforms V2 0/2] Add USB driver support Meenakshi Aggarwal
2 siblings, 1 reply; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-02 13:47 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Add support of DWC3 controller driver which performs
DWC3 controller initialization and register itself as
NonDiscoverableMmioDevice
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
Silicon/NXP/NxpQoriqLs.dec | 5 +
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 41 ++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 +++++++++++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 212 ++++++++++++++++++++
4 files changed, 396 insertions(+)
diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
index d4d3057af509..72c1744fc934 100644
--- a/Silicon/NXP/NxpQoriqLs.dec
+++ b/Silicon/NXP/NxpQoriqLs.dec
@@ -36,6 +36,11 @@ [PcdsFixedAtBuild.common]
gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x0|UINT32|0x00000502
gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x0|UINT32|0x00000503
+ # Pcds for USB
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr|0x0|UINT64|0x00000510
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
+
[PcdsDynamic.common]
gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
new file mode 100644
index 000000000000..b8c3be4bfb49
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
@@ -0,0 +1,41 @@
+# UsbHcd.inf
+#
+# Copyright 2017, 2020 NXP
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = UsbHcdDxe
+ FILE_GUID = 196e7c2a-37b2-4b85-8683-718588952449
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeUsbHcd
+
+[Sources.common]
+ UsbHcd.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ Silicon/NXP/NxpQoriqLs.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ IoLib
+ MemoryAllocationLib
+ NonDiscoverableDeviceRegistrationLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+
+[FixedPcd]
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize
+
+[Depex]
+ TRUE
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
new file mode 100644
index 000000000000..cd9f9ad80125
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
@@ -0,0 +1,138 @@
+/** @file
+
+ Copyright 2017, 2020 NXP
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef USB_HCD_H_
+#define USB_HCD_H_
+
+#include <Base.h>
+
+/* Global constants */
+#define DWC3_GSNPSID_MASK 0xffff0000
+#define DWC3_SYNOPSYS_ID 0x55330000
+#define DWC3_RELEASE_MASK 0xffff
+#define DWC3_REG_OFFSET 0xC100
+#define DWC3_RELEASE_190a 0x190a
+
+/* Global Configuration Register */
+#define DWC3_GCTL_U2RSTECN BIT16
+#define DWC3_GCTL_PRTCAPDIR(N) ((N) << 12)
+#define DWC3_GCTL_PRTCAP_HOST 1
+#define DWC3_GCTL_PRTCAP_OTG 3
+#define DWC3_GCTL_CORESOFTRESET BIT11
+#define DWC3_GCTL_SCALEDOWN(N) ((N) << 4)
+#define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3)
+#define DWC3_GCTL_DISSCRAMBLE BIT3
+#define DWC3_GCTL_DSBLCLKGTNG BIT0
+
+/* Global HWPARAMS1 Register */
+#define DWC3_GHWPARAMS1_EN_PWROPT(N) (((N) & (3 << 24)) >> 24)
+#define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1
+
+/* Global USB2 PHY Configuration Register */
+#define DWC3_GUSB2PHYCFG_PHYSOFTRST BIT31
+
+/* Global USB3 PIPE Control Register */
+#define DWC3_GUSB3PIPECTL_PHYSOFTRST BIT31
+
+/* Global Frame Length Adjustment Register */
+#define GFLADJ_30MHZ_REG_SEL BIT7
+#define GFLADJ_30MHZ(N) ((N) & 0x3f)
+#define GFLADJ_30MHZ_DEFAULT 0x20
+
+/* Default to the FSL XHCI defines */
+#define USB3_ENABLE_BEAT_BURST 0xF
+#define USB3_ENABLE_BEAT_BURST_MASK 0xFF
+#define USB3_SET_BEAT_BURST_LIMIT 0xF00
+
+typedef struct {
+ UINT32 GEvntAdrLo;
+ UINT32 GEvntAdrHi;
+ UINT32 GEvntSiz;
+ UINT32 GEvntCount;
+} G_EVENT_BUFFER;
+
+typedef struct {
+ UINT32 DDepCmdPar2;
+ UINT32 DDepCmdPar1;
+ UINT32 DDepCmdPar0;
+ UINT32 DDepCmd;
+} D_PHYSICAL_EP;
+
+typedef struct {
+ UINT32 GSBusCfg0;
+ UINT32 GSBusCfg1;
+ UINT32 GTxThrCfg;
+ UINT32 GRxThrCfg;
+ UINT32 GCtl;
+ UINT32 Res1;
+ UINT32 GSts;
+ UINT32 Res2;
+ UINT32 GSnpsId;
+ UINT32 GGpio;
+ UINT32 GUid;
+ UINT32 GUctl;
+ UINT64 GBusErrAddr;
+ UINT64 GPrtbImap;
+ UINT32 GHwParams0;
+ UINT32 GHwParams1;
+ UINT32 GHwParams2;
+ UINT32 GHwParams3;
+ UINT32 GHwParams4;
+ UINT32 GHwParams5;
+ UINT32 GHwParams6;
+ UINT32 GHwParams7;
+ UINT32 GDbgFifoSpace;
+ UINT32 GDbgLtssm;
+ UINT32 GDbgLnmcc;
+ UINT32 GDbgBmu;
+ UINT32 GDbgLspMux;
+ UINT32 GDbgLsp;
+ UINT32 GDbgEpInfo0;
+ UINT32 GDbgEpInfo1;
+ UINT64 GPrtbImapHs;
+ UINT64 GPrtbImapFs;
+ UINT32 Res3[28];
+ UINT32 GUsb2PhyCfg[16];
+ UINT32 GUsb2I2cCtl[16];
+ UINT32 GUsb2PhyAcc[16];
+ UINT32 GUsb3PipeCtl[16];
+ UINT32 GTxFifoSiz[32];
+ UINT32 GRxFifoSiz[32];
+ G_EVENT_BUFFER GEvntBuf[32];
+ UINT32 GHwParams8;
+ UINT32 Res4[11];
+ UINT32 GFLAdj;
+ UINT32 Res5[51];
+ UINT32 DCfg;
+ UINT32 DCtl;
+ UINT32 DEvten;
+ UINT32 DSts;
+ UINT32 DGCmdPar;
+ UINT32 DGCmd;
+ UINT32 Res6[2];
+ UINT32 DAlepena;
+ UINT32 Res7[55];
+ D_PHYSICAL_EP DPhyEpCmd[32];
+ UINT32 Res8[128];
+ UINT32 OCfg;
+ UINT32 OCtl;
+ UINT32 OEvt;
+ UINT32 OEvtEn;
+ UINT32 OSts;
+ UINT32 Res9[3];
+ UINT32 AdpCfg;
+ UINT32 AdpCtl;
+ UINT32 AdpEvt;
+ UINT32 AdpEvten;
+ UINT32 BcCfg;
+ UINT32 Res10;
+ UINT32 BcEvt;
+ UINT32 BcEvten;
+} DWC3;
+
+#endif
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
new file mode 100644
index 000000000000..40b027c639b1
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
@@ -0,0 +1,212 @@
+/** @file
+
+ Copyright 2017, 2020 NXP
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
+
+#include "UsbHcd.h"
+
+STATIC
+VOID
+XhciSetBeatBurstLength (
+ IN UINTN UsbReg
+ )
+{
+ DWC3 *Dwc3Reg;
+
+ Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
+
+ MmioAndThenOr32 ((UINTN)&Dwc3Reg->GSBusCfg0, ~USB3_ENABLE_BEAT_BURST_MASK,
+ USB3_ENABLE_BEAT_BURST);
+ MmioOr32 ((UINTN)&Dwc3Reg->GSBusCfg1, USB3_SET_BEAT_BURST_LIMIT);
+
+ return;
+}
+
+STATIC
+VOID
+Dwc3SetFladj (
+ IN DWC3 *Dwc3Reg,
+ IN UINT32 Val
+ )
+{
+ MmioOr32 ((UINTN)&Dwc3Reg->GFLAdj, GFLADJ_30MHZ_REG_SEL |
+ GFLADJ_30MHZ(Val));
+}
+
+VOID
+Dwc3SetMode (
+ IN DWC3 *Dwc3Reg,
+ IN UINT32 Mode
+ )
+{
+ MmioAndThenOr32 ((UINTN)&Dwc3Reg->GCtl,
+ ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)),
+ DWC3_GCTL_PRTCAPDIR(Mode));
+}
+
+STATIC
+VOID
+Dwc3CoreSoftReset (
+ IN DWC3 *Dwc3Reg
+ )
+{
+ MmioOr32 ((UINTN)&Dwc3Reg->GCtl, DWC3_GCTL_CORESOFTRESET);
+ MmioOr32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST);
+ MmioOr32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, DWC3_GUSB2PHYCFG_PHYSOFTRST);
+ MmioAnd32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], ~DWC3_GUSB3PIPECTL_PHYSOFTRST);
+ MmioAnd32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, ~DWC3_GUSB2PHYCFG_PHYSOFTRST);
+ MmioAnd32 ((UINTN)&Dwc3Reg->GCtl, ~DWC3_GCTL_CORESOFTRESET);
+
+ return;
+}
+
+STATIC
+EFI_STATUS
+Dwc3CoreInit (
+ IN DWC3 *Dwc3Reg
+ )
+{
+ UINT32 Revision;
+ UINT32 Reg;
+ UINTN Dwc3Hwparams1;
+
+ Revision = MmioRead32 ((UINTN)&Dwc3Reg->GSnpsId);
+ //
+ // This should read as 0x5533, ascii of U3(DWC_usb3) followed by revision number
+ //
+ if ((Revision & DWC3_GSNPSID_MASK) != DWC3_SYNOPSYS_ID) {
+ DEBUG ((DEBUG_ERROR,"This is not a DesignWare USB3 DRD Core.\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ Dwc3CoreSoftReset (Dwc3Reg);
+
+ Reg = MmioRead32 ((UINTN)&Dwc3Reg->GCtl);
+ Reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
+ Reg &= ~DWC3_GCTL_DISSCRAMBLE;
+
+ Dwc3Hwparams1 = MmioRead32 ((UINTN)&Dwc3Reg->GHwParams1);
+
+ if (DWC3_GHWPARAMS1_EN_PWROPT(Dwc3Hwparams1) == DWC3_GHWPARAMS1_EN_PWROPT_CLK) {
+ Reg &= ~DWC3_GCTL_DSBLCLKGTNG;
+ } else {
+ DEBUG ((DEBUG_ERROR,"No power optimization available.\n"));
+ }
+
+ if ((Revision & DWC3_RELEASE_MASK) < DWC3_RELEASE_190a) {
+ Reg |= DWC3_GCTL_U2RSTECN;
+ }
+
+ MmioWrite32 ((UINTN)&Dwc3Reg->GCtl, Reg);
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+XhciCoreInit (
+ IN UINTN UsbReg
+ )
+{
+ EFI_STATUS Status;
+ DWC3 *Dwc3Reg;
+
+ Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
+
+ Status = Dwc3CoreInit (Dwc3Reg);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Dwc3CoreInit Failed for controller 0x%x (0x%x) \n",
+ UsbReg, Status));
+ return Status;
+ }
+
+ Dwc3SetMode (Dwc3Reg, DWC3_GCTL_PRTCAP_HOST);
+
+ Dwc3SetFladj (Dwc3Reg, GFLADJ_30MHZ_DEFAULT);
+
+ return Status;
+}
+
+STATIC
+EFI_STATUS
+EFIAPI
+InitializeUsbController (
+ IN UINTN UsbReg
+ )
+{
+ EFI_STATUS Status;
+
+ Status = XhciCoreInit (UsbReg);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Change beat burst and outstanding pipelined transfers requests
+ //
+ XhciSetBeatBurstLength (UsbReg);
+
+ return Status;
+}
+
+/**
+ The Entry Point of module. It follows the standard UEFI driver model.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeUsbHcd (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ UINT32 NumUsbController;
+ UINT32 ControllerAddr;
+ UINT32 Index;
+
+ Status = EFI_SUCCESS;
+ NumUsbController = PcdGet32 (PcdNumUsbController);
+
+ for (Index = 0; Index < NumUsbController; Index++) {
+ ControllerAddr = PcdGet64 (PcdUsbBaseAddr) +
+ (Index * PcdGet32 (PcdUsbSize));
+
+ Status = InitializeUsbController (ControllerAddr);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "USB Controller initialization Failed for %d (0x%x)\n",
+ ControllerAddr, Status));
+ continue;
+ }
+
+ Status = RegisterNonDiscoverableMmioDevice (
+ NonDiscoverableDeviceTypeXhci,
+ NonDiscoverableDeviceDmaTypeNonCoherent,
+ NULL,
+ NULL,
+ 1,
+ ControllerAddr, PcdGet32 (PcdUsbSize)
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to register USB device (0x%x) with error 0x%x \n",
+ ControllerAddr, Status));
+ }
+ }
+
+ return Status;
+}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of USB controller
2020-06-02 13:47 [PATCH edk2-platforms 0/2] Add USB driver support Meenakshi Aggarwal
2020-06-02 13:47 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
@ 2020-06-02 13:47 ` Meenakshi Aggarwal
2020-06-03 16:00 ` [PATCH edk2-platforms V2 0/2] Add USB driver support Meenakshi Aggarwal
2 siblings, 0 replies; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-02 13:47 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Enable support of USB drives on lx2160 RDB board.
LX2160 has DWC3 controller
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 ++++
Silicon/NXP/NxpQoriqLs.dsc.inc | 12 ++++++++++++
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 12 ++++++++++++
4 files changed, 29 insertions(+)
diff --git a/Silicon/NXP/LX2160A/LX2160A.dsc.inc b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
index af22b4dd973c..55dd3b5442eb 100644
--- a/Silicon/NXP/LX2160A/LX2160A.dsc.inc
+++ b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
@@ -36,6 +36,10 @@ [PcdsFixedAtBuild.common]
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x21C0000
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr|0x3100000
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x10000
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|2
+
[PcdsFeatureFlag]
gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|TRUE
diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc b/Silicon/NXP/NxpQoriqLs.dsc.inc
index ee639d552483..1f0f272da6c7 100644
--- a/Silicon/NXP/NxpQoriqLs.dsc.inc
+++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
@@ -366,6 +366,18 @@ [Components.common]
FatPkg/EnhancedFatDxe/Fat.inf
#
+ # USB
+ #
+
+ MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+ MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+ MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+ MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+ MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+
+ #
# Bds
#
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
index 9b3e0386c13e..ec27a1a219a5 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
@@ -43,4 +43,5 @@ [Components.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
}
+ Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
##
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
index eec1c0774a86..6c42faa8c3e2 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
@@ -120,6 +120,18 @@ [FV.FvMain]
INF FatPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+ INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+
+ #
+ # USB Support
+ #
+ INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+ INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+ INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+ INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+ INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+ INF Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
#
# UEFI application (Shell Embedded Boot Loader)
#
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH edk2-platforms V2 0/2] Add USB driver support
2020-06-02 13:47 [PATCH edk2-platforms 0/2] Add USB driver support Meenakshi Aggarwal
2020-06-02 13:47 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
2020-06-02 13:47 ` [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of USB controller Meenakshi Aggarwal
@ 2020-06-03 16:00 ` Meenakshi Aggarwal
2020-06-03 16:00 ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
` (2 more replies)
2 siblings, 3 replies; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-03 16:00 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
This patchset implement USB driver for DWC3 controller and enable
USB for LX2160A Platform.
Changes in v2:
- Indentation changes
- Incorporated review comments
- create EndOfDxe event and initialize USB in EndOfDxe
callback function.
Meenakshi Aggarwal (2):
Silicon/NXP: Add DWC3 USB controller initialization driver
Platform/NXP:LX2160: Enable support of USB controller
Silicon/NXP/NxpQoriqLs.dec | 5 +
Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 +
Silicon/NXP/NxpQoriqLs.dsc.inc | 12 +
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +-
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 45 ++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 ++++++++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 281 ++++++++++++++++++++
8 files changed, 501 insertions(+), 3 deletions(-)
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
--
1.9.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver
2020-06-03 16:00 ` [PATCH edk2-platforms V2 0/2] Add USB driver support Meenakshi Aggarwal
@ 2020-06-03 16:00 ` Meenakshi Aggarwal
2020-06-12 10:29 ` Ard Biesheuvel
2020-06-03 16:00 ` [PATCH edk2-platforms V2 2/2] Platform/NXP:LX2160: Enable support of USB controller Meenakshi Aggarwal
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 0/2] Add USB driver support Meenakshi Aggarwal
2 siblings, 1 reply; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-03 16:00 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Add support of DWC3 controller driver which performs
DWC3 controller initialization and register itself as
NonDiscoverableMmioDevice
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
Silicon/NXP/NxpQoriqLs.dec | 5 +
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 45 ++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 ++++++++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 281 ++++++++++++++++++++
4 files changed, 469 insertions(+)
diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
index d4d3057af509..72c1744fc934 100644
--- a/Silicon/NXP/NxpQoriqLs.dec
+++ b/Silicon/NXP/NxpQoriqLs.dec
@@ -36,6 +36,11 @@ [PcdsFixedAtBuild.common]
gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x0|UINT32|0x00000502
gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x0|UINT32|0x00000503
+ # Pcds for USB
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr|0x0|UINT64|0x00000510
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
+
[PcdsDynamic.common]
gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
new file mode 100644
index 000000000000..ea7532b4324b
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
@@ -0,0 +1,45 @@
+# UsbHcd.inf
+#
+# Copyright 2017, 2020 NXP
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = UsbHcdDxe
+ FILE_GUID = 196e7c2a-37b2-4b85-8683-718588952449
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeUsbHcd
+
+[Sources.common]
+ UsbHcd.c
+ UsbHcd.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ Silicon/NXP/NxpQoriqLs.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ IoLib
+ MemoryAllocationLib
+ NonDiscoverableDeviceRegistrationLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+
+[FixedPcd]
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize
+
+[Guids]
+ gEfiEndOfDxeEventGroupGuid
+
+[Depex]
+ TRUE
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
new file mode 100644
index 000000000000..cd9f9ad80125
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
@@ -0,0 +1,138 @@
+/** @file
+
+ Copyright 2017, 2020 NXP
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef USB_HCD_H_
+#define USB_HCD_H_
+
+#include <Base.h>
+
+/* Global constants */
+#define DWC3_GSNPSID_MASK 0xffff0000
+#define DWC3_SYNOPSYS_ID 0x55330000
+#define DWC3_RELEASE_MASK 0xffff
+#define DWC3_REG_OFFSET 0xC100
+#define DWC3_RELEASE_190a 0x190a
+
+/* Global Configuration Register */
+#define DWC3_GCTL_U2RSTECN BIT16
+#define DWC3_GCTL_PRTCAPDIR(N) ((N) << 12)
+#define DWC3_GCTL_PRTCAP_HOST 1
+#define DWC3_GCTL_PRTCAP_OTG 3
+#define DWC3_GCTL_CORESOFTRESET BIT11
+#define DWC3_GCTL_SCALEDOWN(N) ((N) << 4)
+#define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3)
+#define DWC3_GCTL_DISSCRAMBLE BIT3
+#define DWC3_GCTL_DSBLCLKGTNG BIT0
+
+/* Global HWPARAMS1 Register */
+#define DWC3_GHWPARAMS1_EN_PWROPT(N) (((N) & (3 << 24)) >> 24)
+#define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1
+
+/* Global USB2 PHY Configuration Register */
+#define DWC3_GUSB2PHYCFG_PHYSOFTRST BIT31
+
+/* Global USB3 PIPE Control Register */
+#define DWC3_GUSB3PIPECTL_PHYSOFTRST BIT31
+
+/* Global Frame Length Adjustment Register */
+#define GFLADJ_30MHZ_REG_SEL BIT7
+#define GFLADJ_30MHZ(N) ((N) & 0x3f)
+#define GFLADJ_30MHZ_DEFAULT 0x20
+
+/* Default to the FSL XHCI defines */
+#define USB3_ENABLE_BEAT_BURST 0xF
+#define USB3_ENABLE_BEAT_BURST_MASK 0xFF
+#define USB3_SET_BEAT_BURST_LIMIT 0xF00
+
+typedef struct {
+ UINT32 GEvntAdrLo;
+ UINT32 GEvntAdrHi;
+ UINT32 GEvntSiz;
+ UINT32 GEvntCount;
+} G_EVENT_BUFFER;
+
+typedef struct {
+ UINT32 DDepCmdPar2;
+ UINT32 DDepCmdPar1;
+ UINT32 DDepCmdPar0;
+ UINT32 DDepCmd;
+} D_PHYSICAL_EP;
+
+typedef struct {
+ UINT32 GSBusCfg0;
+ UINT32 GSBusCfg1;
+ UINT32 GTxThrCfg;
+ UINT32 GRxThrCfg;
+ UINT32 GCtl;
+ UINT32 Res1;
+ UINT32 GSts;
+ UINT32 Res2;
+ UINT32 GSnpsId;
+ UINT32 GGpio;
+ UINT32 GUid;
+ UINT32 GUctl;
+ UINT64 GBusErrAddr;
+ UINT64 GPrtbImap;
+ UINT32 GHwParams0;
+ UINT32 GHwParams1;
+ UINT32 GHwParams2;
+ UINT32 GHwParams3;
+ UINT32 GHwParams4;
+ UINT32 GHwParams5;
+ UINT32 GHwParams6;
+ UINT32 GHwParams7;
+ UINT32 GDbgFifoSpace;
+ UINT32 GDbgLtssm;
+ UINT32 GDbgLnmcc;
+ UINT32 GDbgBmu;
+ UINT32 GDbgLspMux;
+ UINT32 GDbgLsp;
+ UINT32 GDbgEpInfo0;
+ UINT32 GDbgEpInfo1;
+ UINT64 GPrtbImapHs;
+ UINT64 GPrtbImapFs;
+ UINT32 Res3[28];
+ UINT32 GUsb2PhyCfg[16];
+ UINT32 GUsb2I2cCtl[16];
+ UINT32 GUsb2PhyAcc[16];
+ UINT32 GUsb3PipeCtl[16];
+ UINT32 GTxFifoSiz[32];
+ UINT32 GRxFifoSiz[32];
+ G_EVENT_BUFFER GEvntBuf[32];
+ UINT32 GHwParams8;
+ UINT32 Res4[11];
+ UINT32 GFLAdj;
+ UINT32 Res5[51];
+ UINT32 DCfg;
+ UINT32 DCtl;
+ UINT32 DEvten;
+ UINT32 DSts;
+ UINT32 DGCmdPar;
+ UINT32 DGCmd;
+ UINT32 Res6[2];
+ UINT32 DAlepena;
+ UINT32 Res7[55];
+ D_PHYSICAL_EP DPhyEpCmd[32];
+ UINT32 Res8[128];
+ UINT32 OCfg;
+ UINT32 OCtl;
+ UINT32 OEvt;
+ UINT32 OEvtEn;
+ UINT32 OSts;
+ UINT32 Res9[3];
+ UINT32 AdpCfg;
+ UINT32 AdpCtl;
+ UINT32 AdpEvt;
+ UINT32 AdpEvten;
+ UINT32 BcCfg;
+ UINT32 Res10;
+ UINT32 BcEvt;
+ UINT32 BcEvten;
+} DWC3;
+
+#endif
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
new file mode 100644
index 000000000000..515853b86253
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
@@ -0,0 +1,281 @@
+/** @file
+
+ Copyright 2017, 2020 NXP
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include "UsbHcd.h"
+
+STATIC
+VOID
+XhciSetBeatBurstLength (
+ IN UINTN UsbReg
+ )
+{
+ DWC3 *Dwc3Reg;
+
+ Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
+
+ MmioAndThenOr32 ((UINTN)&Dwc3Reg->GSBusCfg0, ~USB3_ENABLE_BEAT_BURST_MASK,
+ USB3_ENABLE_BEAT_BURST);
+
+ MmioOr32 ((UINTN)&Dwc3Reg->GSBusCfg1, USB3_SET_BEAT_BURST_LIMIT);
+}
+
+STATIC
+VOID
+Dwc3SetFladj (
+ IN DWC3 *Dwc3Reg,
+ IN UINT32 Val
+ )
+{
+ MmioOr32 ((UINTN)&Dwc3Reg->GFLAdj, GFLADJ_30MHZ_REG_SEL |
+ GFLADJ_30MHZ (Val));
+}
+
+STATIC
+VOID
+Dwc3SetMode (
+ IN DWC3 *Dwc3Reg,
+ IN UINT32 Mode
+ )
+{
+ MmioAndThenOr32 ((UINTN)&Dwc3Reg->GCtl,
+ ~(DWC3_GCTL_PRTCAPDIR (DWC3_GCTL_PRTCAP_OTG)),
+ DWC3_GCTL_PRTCAPDIR (Mode));
+}
+
+/**
+ This function issues phy reset and core soft reset
+
+ @param Dwc3Reg Pointer to DWC3 register.
+
+**/
+STATIC
+VOID
+Dwc3CoreSoftReset (
+ IN DWC3 *Dwc3Reg
+ )
+{
+ //
+ // Put core in reset before resetting PHY
+ //
+ MmioOr32 ((UINTN)&Dwc3Reg->GCtl, DWC3_GCTL_CORESOFTRESET);
+
+ //
+ // Assert USB2 PHY reset
+ //
+ MmioOr32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST);
+
+ //
+ // Assert USB3 PHY reset
+ //
+ MmioOr32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, DWC3_GUSB2PHYCFG_PHYSOFTRST);
+
+ MemoryFence ();
+
+ //
+ // Clear USB3 PHY reset
+ //
+ MmioAnd32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], ~DWC3_GUSB3PIPECTL_PHYSOFTRST);
+
+ //
+ // Clear USB2 PHY reset
+ //
+ MmioAnd32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, ~DWC3_GUSB2PHYCFG_PHYSOFTRST);
+
+ MemoryFence ();
+
+ //
+ // Take core out of reset, PHYs are stable now
+ //
+ MmioAnd32 ((UINTN)&Dwc3Reg->GCtl, ~DWC3_GCTL_CORESOFTRESET);
+}
+
+/**
+ This function performs low-level initialization of DWC3 Core
+
+ @param Dwc3Reg Pointer to DWC3 register.
+
+**/
+STATIC
+EFI_STATUS
+Dwc3CoreInit (
+ IN DWC3 *Dwc3Reg
+ )
+{
+ UINT32 Revision;
+ UINT32 Reg;
+ UINTN Dwc3Hwparams1;
+
+ Revision = MmioRead32 ((UINTN)&Dwc3Reg->GSnpsId);
+ //
+ // This should read as 0x5533, ascii of U3(DWC_usb3) followed by revision num
+ //
+ if ((Revision & DWC3_GSNPSID_MASK) != DWC3_SYNOPSYS_ID) {
+ DEBUG ((DEBUG_ERROR,"This is not a DesignWare USB3 DRD Core.\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ Dwc3CoreSoftReset (Dwc3Reg);
+
+ Reg = MmioRead32 ((UINTN)&Dwc3Reg->GCtl);
+ Reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
+ Reg &= ~DWC3_GCTL_DISSCRAMBLE;
+
+ Dwc3Hwparams1 = MmioRead32 ((UINTN)&Dwc3Reg->GHwParams1);
+
+ if (DWC3_GHWPARAMS1_EN_PWROPT (Dwc3Hwparams1) ==
+ DWC3_GHWPARAMS1_EN_PWROPT_CLK) {
+ Reg &= ~DWC3_GCTL_DSBLCLKGTNG;
+ } else {
+ DEBUG ((DEBUG_WARN,"No power optimization available.\n"));
+ }
+
+ if ((Revision & DWC3_RELEASE_MASK) < DWC3_RELEASE_190a) {
+ Reg |= DWC3_GCTL_U2RSTECN;
+ }
+
+ MmioWrite32 ((UINTN)&Dwc3Reg->GCtl, Reg);
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+XhciCoreInit (
+ IN UINTN UsbReg
+ )
+{
+ EFI_STATUS Status;
+ DWC3 *Dwc3Reg;
+
+ Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
+
+ Status = Dwc3CoreInit (Dwc3Reg);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Dwc3CoreInit Failed for controller 0x%x (0x%r) \n",
+ UsbReg, Status));
+
+ return Status;
+ }
+
+ Dwc3SetMode (Dwc3Reg, DWC3_GCTL_PRTCAP_HOST);
+
+ Dwc3SetFladj (Dwc3Reg, GFLADJ_30MHZ_DEFAULT);
+
+ return Status;
+}
+
+STATIC
+EFI_STATUS
+EFIAPI
+InitializeUsbController (
+ IN UINTN UsbReg
+ )
+{
+ EFI_STATUS Status;
+
+ Status = XhciCoreInit (UsbReg);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Change beat burst and outstanding pipelined transfers requests
+ //
+ XhciSetBeatBurstLength (UsbReg);
+
+ return Status;
+}
+
+/**
+ This function gets registered as a callback to perform USB controller intialization
+
+ @param Event Event whose notification function is being invoked.
+ @param Context Pointer to the notification function's context.
+
+**/
+VOID
+EFIAPI
+UsbEndOfDxeCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ UINT32 NumUsbController;
+ UINT32 ControllerAddr;
+ UINT32 Index;
+
+ gBS->CloseEvent (Event);
+
+ NumUsbController = PcdGet32 (PcdNumUsbController);
+
+ for (Index = 0; Index < NumUsbController; Index++) {
+ ControllerAddr = PcdGet64 (PcdUsbBaseAddr) +
+ (Index * PcdGet32 (PcdUsbSize));
+
+ Status = InitializeUsbController (ControllerAddr);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "USB Controller init Failed for %d (0x%r)\n",
+ ControllerAddr, Status));
+ continue;
+ }
+
+ Status = RegisterNonDiscoverableMmioDevice (
+ NonDiscoverableDeviceTypeXhci,
+ NonDiscoverableDeviceDmaTypeNonCoherent,
+ NULL,
+ NULL,
+ 1,
+ ControllerAddr, PcdGet32 (PcdUsbSize)
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to register USB device 0x%x, error 0x%r \n",
+ ControllerAddr, Status));
+ }
+ }
+}
+
+/**
+ The Entry Point of module. It follows the standard UEFI driver model.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeUsbHcd (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT EndOfDxeEvent;
+
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ UsbEndOfDxeCallback,
+ NULL,
+ &gEfiEndOfDxeEventGroupGuid,
+ &EndOfDxeEvent
+ );
+
+ return Status;
+}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH edk2-platforms V2 2/2] Platform/NXP:LX2160: Enable support of USB controller
2020-06-03 16:00 ` [PATCH edk2-platforms V2 0/2] Add USB driver support Meenakshi Aggarwal
2020-06-03 16:00 ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
@ 2020-06-03 16:00 ` Meenakshi Aggarwal
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 0/2] Add USB driver support Meenakshi Aggarwal
2 siblings, 0 replies; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-03 16:00 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Enable support of USB drives on lx2160 RDB board.
LX2160 has DWC3 controller
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 ++++
Silicon/NXP/NxpQoriqLs.dsc.inc | 12 ++++++++++++
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +++++++++++++++---
4 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/Silicon/NXP/LX2160A/LX2160A.dsc.inc b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
index af22b4dd973c..55dd3b5442eb 100644
--- a/Silicon/NXP/LX2160A/LX2160A.dsc.inc
+++ b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
@@ -36,6 +36,10 @@ [PcdsFixedAtBuild.common]
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x21C0000
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr|0x3100000
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x10000
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|2
+
[PcdsFeatureFlag]
gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|TRUE
diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc b/Silicon/NXP/NxpQoriqLs.dsc.inc
index ee639d552483..1f0f272da6c7 100644
--- a/Silicon/NXP/NxpQoriqLs.dsc.inc
+++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
@@ -366,6 +366,18 @@ [Components.common]
FatPkg/EnhancedFatDxe/Fat.inf
#
+ # USB
+ #
+
+ MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+ MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+ MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+ MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+ MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+
+ #
# Bds
#
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
index 9b3e0386c13e..ec27a1a219a5 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
@@ -43,4 +43,5 @@ [Components.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
}
+ Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
##
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
index eec1c0774a86..5cb809e8b3a0 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
@@ -23,10 +23,10 @@
[FD.LX2160ARDB_EFI]
BaseAddress = 0x82000000|gArmTokenSpaceGuid.PcdFdBaseAddress #The base address of the FLASH Device.
-Size = 0x00140000|gArmTokenSpaceGuid.PcdFdSize #The size in bytes of the FLASH Device
+Size = 0x00160000|gArmTokenSpaceGuid.PcdFdSize #The size in bytes of the FLASH Device
ErasePolarity = 1
BlockSize = 0x10000
-NumBlocks = 0x14
+NumBlocks = 0x16
################################################################################
#
@@ -43,7 +43,7 @@ [FD.LX2160ARDB_EFI]
# RegionType <FV, DATA, or FILE>
#
################################################################################
-0x00000000|0x00140000
+0x00000000|0x00160000
gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
FV = FVMAIN_COMPACT
@@ -120,6 +120,18 @@ [FV.FvMain]
INF FatPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+ INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+
+ #
+ # USB Support
+ #
+ INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+ INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+ INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+ INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+ INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+ INF Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
#
# UEFI application (Shell Embedded Boot Loader)
#
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver
2020-06-03 16:00 ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
@ 2020-06-12 10:29 ` Ard Biesheuvel
0 siblings, 0 replies; 14+ messages in thread
From: Ard Biesheuvel @ 2020-06-12 10:29 UTC (permalink / raw)
To: Meenakshi Aggarwal, leif, michael.d.kinney, devel
Cc: v.sethi, Meenakshi Aggarwal
On 6/3/20 6:00 PM, Meenakshi Aggarwal wrote:
> From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
>
> Add support of DWC3 controller driver which performs
> DWC3 controller initialization and register itself as
> NonDiscoverableMmioDevice
>
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
> Silicon/NXP/NxpQoriqLs.dec | 5 +
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 45 ++++
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 ++++++++++
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 281 ++++++++++++++++++++
> 4 files changed, 469 insertions(+)
>
> diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
> index d4d3057af509..72c1744fc934 100644
> --- a/Silicon/NXP/NxpQoriqLs.dec
> +++ b/Silicon/NXP/NxpQoriqLs.dec
> @@ -36,6 +36,11 @@ [PcdsFixedAtBuild.common]
> gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x0|UINT32|0x00000502
> gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x0|UINT32|0x00000503
>
> + # Pcds for USB
> + gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr|0x0|UINT64|0x00000510
> + gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
> + gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
> +
> [PcdsDynamic.common]
> gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
> gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
> diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> new file mode 100644
> index 000000000000..ea7532b4324b
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> @@ -0,0 +1,45 @@
> +# UsbHcd.inf
> +#
> +# Copyright 2017, 2020 NXP
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#
> +
> +[Defines]
> + INF_VERSION = 0x0001001A
> + BASE_NAME = UsbHcdDxe
> + FILE_GUID = 196e7c2a-37b2-4b85-8683-718588952449
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + ENTRY_POINT = InitializeUsbHcd
> +
> +[Sources.common]
> + UsbHcd.c
> + UsbHcd.h
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + Silicon/NXP/NxpQoriqLs.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + IoLib
> + MemoryAllocationLib
> + NonDiscoverableDeviceRegistrationLib
> + UefiBootServicesTableLib
> + UefiDriverEntryPoint
> +
> +[FixedPcd]
> + gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController
> + gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr
> + gNxpQoriqLsTokenSpaceGuid.PcdUsbSize
> +
> +[Guids]
> + gEfiEndOfDxeEventGroupGuid
> +
> +[Depex]
> + TRUE
> diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
> new file mode 100644
> index 000000000000..cd9f9ad80125
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
> @@ -0,0 +1,138 @@
> +/** @file
> +
> + Copyright 2017, 2020 NXP
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef USB_HCD_H_
> +#define USB_HCD_H_
> +
> +#include <Base.h>
> +
> +/* Global constants */
> +#define DWC3_GSNPSID_MASK 0xffff0000
> +#define DWC3_SYNOPSYS_ID 0x55330000
> +#define DWC3_RELEASE_MASK 0xffff
> +#define DWC3_REG_OFFSET 0xC100
> +#define DWC3_RELEASE_190a 0x190a
> +
> +/* Global Configuration Register */
> +#define DWC3_GCTL_U2RSTECN BIT16
> +#define DWC3_GCTL_PRTCAPDIR(N) ((N) << 12)
> +#define DWC3_GCTL_PRTCAP_HOST 1
> +#define DWC3_GCTL_PRTCAP_OTG 3
> +#define DWC3_GCTL_CORESOFTRESET BIT11
> +#define DWC3_GCTL_SCALEDOWN(N) ((N) << 4)
> +#define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3)
> +#define DWC3_GCTL_DISSCRAMBLE BIT3
> +#define DWC3_GCTL_DSBLCLKGTNG BIT0
> +
> +/* Global HWPARAMS1 Register */
> +#define DWC3_GHWPARAMS1_EN_PWROPT(N) (((N) & (3 << 24)) >> 24)
> +#define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1
> +
> +/* Global USB2 PHY Configuration Register */
> +#define DWC3_GUSB2PHYCFG_PHYSOFTRST BIT31
> +
> +/* Global USB3 PIPE Control Register */
> +#define DWC3_GUSB3PIPECTL_PHYSOFTRST BIT31
> +
> +/* Global Frame Length Adjustment Register */
> +#define GFLADJ_30MHZ_REG_SEL BIT7
> +#define GFLADJ_30MHZ(N) ((N) & 0x3f)
> +#define GFLADJ_30MHZ_DEFAULT 0x20
> +
> +/* Default to the FSL XHCI defines */
> +#define USB3_ENABLE_BEAT_BURST 0xF
> +#define USB3_ENABLE_BEAT_BURST_MASK 0xFF
> +#define USB3_SET_BEAT_BURST_LIMIT 0xF00
> +
> +typedef struct {
> + UINT32 GEvntAdrLo;
> + UINT32 GEvntAdrHi;
> + UINT32 GEvntSiz;
> + UINT32 GEvntCount;
> +} G_EVENT_BUFFER;
> +
> +typedef struct {
> + UINT32 DDepCmdPar2;
> + UINT32 DDepCmdPar1;
> + UINT32 DDepCmdPar0;
> + UINT32 DDepCmd;
> +} D_PHYSICAL_EP;
> +
> +typedef struct {
> + UINT32 GSBusCfg0;
> + UINT32 GSBusCfg1;
> + UINT32 GTxThrCfg;
> + UINT32 GRxThrCfg;
> + UINT32 GCtl;
> + UINT32 Res1;
> + UINT32 GSts;
> + UINT32 Res2;
> + UINT32 GSnpsId;
> + UINT32 GGpio;
> + UINT32 GUid;
> + UINT32 GUctl;
> + UINT64 GBusErrAddr;
> + UINT64 GPrtbImap;
> + UINT32 GHwParams0;
> + UINT32 GHwParams1;
> + UINT32 GHwParams2;
> + UINT32 GHwParams3;
> + UINT32 GHwParams4;
> + UINT32 GHwParams5;
> + UINT32 GHwParams6;
> + UINT32 GHwParams7;
> + UINT32 GDbgFifoSpace;
> + UINT32 GDbgLtssm;
> + UINT32 GDbgLnmcc;
> + UINT32 GDbgBmu;
> + UINT32 GDbgLspMux;
> + UINT32 GDbgLsp;
> + UINT32 GDbgEpInfo0;
> + UINT32 GDbgEpInfo1;
> + UINT64 GPrtbImapHs;
> + UINT64 GPrtbImapFs;
> + UINT32 Res3[28];
> + UINT32 GUsb2PhyCfg[16];
> + UINT32 GUsb2I2cCtl[16];
> + UINT32 GUsb2PhyAcc[16];
> + UINT32 GUsb3PipeCtl[16];
> + UINT32 GTxFifoSiz[32];
> + UINT32 GRxFifoSiz[32];
> + G_EVENT_BUFFER GEvntBuf[32];
> + UINT32 GHwParams8;
> + UINT32 Res4[11];
> + UINT32 GFLAdj;
> + UINT32 Res5[51];
> + UINT32 DCfg;
> + UINT32 DCtl;
> + UINT32 DEvten;
> + UINT32 DSts;
> + UINT32 DGCmdPar;
> + UINT32 DGCmd;
> + UINT32 Res6[2];
> + UINT32 DAlepena;
> + UINT32 Res7[55];
> + D_PHYSICAL_EP DPhyEpCmd[32];
> + UINT32 Res8[128];
> + UINT32 OCfg;
> + UINT32 OCtl;
> + UINT32 OEvt;
> + UINT32 OEvtEn;
> + UINT32 OSts;
> + UINT32 Res9[3];
> + UINT32 AdpCfg;
> + UINT32 AdpCtl;
> + UINT32 AdpEvt;
> + UINT32 AdpEvten;
> + UINT32 BcCfg;
> + UINT32 Res10;
> + UINT32 BcEvt;
> + UINT32 BcEvten;
> +} DWC3;
> +
> +#endif
> diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
> new file mode 100644
> index 000000000000..515853b86253
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
> @@ -0,0 +1,281 @@
> +/** @file
> +
> + Copyright 2017, 2020 NXP
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/NonDiscoverableDeviceRegistrationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +#include "UsbHcd.h"
> +
> +STATIC
> +VOID
> +XhciSetBeatBurstLength (
> + IN UINTN UsbReg
> + )
> +{
> + DWC3 *Dwc3Reg;
> +
> + Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
> +
> + MmioAndThenOr32 ((UINTN)&Dwc3Reg->GSBusCfg0, ~USB3_ENABLE_BEAT_BURST_MASK,
> + USB3_ENABLE_BEAT_BURST);
> +
> + MmioOr32 ((UINTN)&Dwc3Reg->GSBusCfg1, USB3_SET_BEAT_BURST_LIMIT);
> +}
> +
> +STATIC
> +VOID
> +Dwc3SetFladj (
> + IN DWC3 *Dwc3Reg,
> + IN UINT32 Val
> + )
> +{
> + MmioOr32 ((UINTN)&Dwc3Reg->GFLAdj, GFLADJ_30MHZ_REG_SEL |
> + GFLADJ_30MHZ (Val));
> +}
> +
> +STATIC
> +VOID
> +Dwc3SetMode (
> + IN DWC3 *Dwc3Reg,
> + IN UINT32 Mode
> + )
> +{
> + MmioAndThenOr32 ((UINTN)&Dwc3Reg->GCtl,
> + ~(DWC3_GCTL_PRTCAPDIR (DWC3_GCTL_PRTCAP_OTG)),
> + DWC3_GCTL_PRTCAPDIR (Mode));
> +}
> +
> +/**
> + This function issues phy reset and core soft reset
> +
> + @param Dwc3Reg Pointer to DWC3 register.
> +
> +**/
> +STATIC
> +VOID
> +Dwc3CoreSoftReset (
> + IN DWC3 *Dwc3Reg
> + )
> +{
> + //
> + // Put core in reset before resetting PHY
> + //
> + MmioOr32 ((UINTN)&Dwc3Reg->GCtl, DWC3_GCTL_CORESOFTRESET);
> +
> + //
> + // Assert USB2 PHY reset
> + //
> + MmioOr32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST);
> +
> + //
> + // Assert USB3 PHY reset
> + //
> + MmioOr32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, DWC3_GUSB2PHYCFG_PHYSOFTRST);
> +
> + MemoryFence ();
> +
> + //
> + // Clear USB3 PHY reset
> + //
> + MmioAnd32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], ~DWC3_GUSB3PIPECTL_PHYSOFTRST);
> +
> + //
> + // Clear USB2 PHY reset
> + //
> + MmioAnd32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, ~DWC3_GUSB2PHYCFG_PHYSOFTRST);
> +
> + MemoryFence ();
> +
> + //
> + // Take core out of reset, PHYs are stable now
> + //
> + MmioAnd32 ((UINTN)&Dwc3Reg->GCtl, ~DWC3_GCTL_CORESOFTRESET);
> +}
> +
> +/**
> + This function performs low-level initialization of DWC3 Core
> +
> + @param Dwc3Reg Pointer to DWC3 register.
> +
> +**/
> +STATIC
> +EFI_STATUS
> +Dwc3CoreInit (
> + IN DWC3 *Dwc3Reg
> + )
> +{
> + UINT32 Revision;
> + UINT32 Reg;
> + UINTN Dwc3Hwparams1;
> +
> + Revision = MmioRead32 ((UINTN)&Dwc3Reg->GSnpsId);
> + //
> + // This should read as 0x5533, ascii of U3(DWC_usb3) followed by revision num
> + //
> + if ((Revision & DWC3_GSNPSID_MASK) != DWC3_SYNOPSYS_ID) {
> + DEBUG ((DEBUG_ERROR,"This is not a DesignWare USB3 DRD Core.\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + Dwc3CoreSoftReset (Dwc3Reg);
> +
> + Reg = MmioRead32 ((UINTN)&Dwc3Reg->GCtl);
> + Reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
> + Reg &= ~DWC3_GCTL_DISSCRAMBLE;
> +
> + Dwc3Hwparams1 = MmioRead32 ((UINTN)&Dwc3Reg->GHwParams1);
> +
> + if (DWC3_GHWPARAMS1_EN_PWROPT (Dwc3Hwparams1) ==
> + DWC3_GHWPARAMS1_EN_PWROPT_CLK) {
> + Reg &= ~DWC3_GCTL_DSBLCLKGTNG;
> + } else {
> + DEBUG ((DEBUG_WARN,"No power optimization available.\n"));
> + }
> +
> + if ((Revision & DWC3_RELEASE_MASK) < DWC3_RELEASE_190a) {
> + Reg |= DWC3_GCTL_U2RSTECN;
> + }
> +
> + MmioWrite32 ((UINTN)&Dwc3Reg->GCtl, Reg);
> +
> + return EFI_SUCCESS;
> +}
> +
> +STATIC
> +EFI_STATUS
> +XhciCoreInit (
> + IN UINTN UsbReg
> + )
> +{
> + EFI_STATUS Status;
> + DWC3 *Dwc3Reg;
> +
> + Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
> +
> + Status = Dwc3CoreInit (Dwc3Reg);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "Dwc3CoreInit Failed for controller 0x%x (0x%r) \n",
> + UsbReg, Status));
> +
> + return Status;
> + }
> +
> + Dwc3SetMode (Dwc3Reg, DWC3_GCTL_PRTCAP_HOST);
> +
> + Dwc3SetFladj (Dwc3Reg, GFLADJ_30MHZ_DEFAULT);
> +
> + return Status;
> +}
> +
> +STATIC
> +EFI_STATUS
> +EFIAPI
> +InitializeUsbController (
> + IN UINTN UsbReg
> + )
> +{
> + EFI_STATUS Status;
> +
> + Status = XhciCoreInit (UsbReg);
> +
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + //
> + // Change beat burst and outstanding pipelined transfers requests
> + //
> + XhciSetBeatBurstLength (UsbReg);
> +
> + return Status;
> +}
> +
> +/**
> + This function gets registered as a callback to perform USB controller intialization
> +
> + @param Event Event whose notification function is being invoked.
> + @param Context Pointer to the notification function's context.
> +
> +**/
> +VOID
> +EFIAPI
> +UsbEndOfDxeCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 NumUsbController;
> + UINT32 ControllerAddr;
> + UINT32 Index;
> +
> + gBS->CloseEvent (Event);
> +
> + NumUsbController = PcdGet32 (PcdNumUsbController);
> +
> + for (Index = 0; Index < NumUsbController; Index++) {
> + ControllerAddr = PcdGet64 (PcdUsbBaseAddr) +
> + (Index * PcdGet32 (PcdUsbSize));
> +
> + Status = InitializeUsbController (ControllerAddr);
Is this call required for the USB controller to work correctly under the
OS? If not, this call should be passed to
RegisterNonDiscoverableMmioDevice() as the init function, so that it is
only called if the BDS connects this controller.
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "USB Controller init Failed for %d (0x%r)\n",
> + ControllerAddr, Status));
> + continue;
> + }
> +
> + Status = RegisterNonDiscoverableMmioDevice (
> + NonDiscoverableDeviceTypeXhci,
> + NonDiscoverableDeviceDmaTypeNonCoherent,
> + NULL,
> + NULL,
> + 1,
> + ControllerAddr, PcdGet32 (PcdUsbSize)
> + );
> +
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "Failed to register USB device 0x%x, error 0x%r \n",
> + ControllerAddr, Status));
> + }
> + }
> +}
> +
> +/**
> + The Entry Point of module. It follows the standard UEFI driver model.
> +
> + @param[in] ImageHandle The firmware allocated handle for the EFI image.
> + @param[in] SystemTable A pointer to the EFI System Table.
> +
> + @retval EFI_SUCCESS The entry point is executed successfully.
> + @retval other Some error occurs when executing this entry point.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InitializeUsbHcd (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + EFI_STATUS Status;
> + EFI_EVENT EndOfDxeEvent;
> +
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + UsbEndOfDxeCallback,
> + NULL,
> + &gEfiEndOfDxeEventGroupGuid,
> + &EndOfDxeEvent
> + );
> +
> + return Status;
> +}
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [edk2-platforms] [PATCH v3 0/2] Add USB driver support
2020-06-03 16:00 ` [PATCH edk2-platforms V2 0/2] Add USB driver support Meenakshi Aggarwal
2020-06-03 16:00 ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
2020-06-03 16:00 ` [PATCH edk2-platforms V2 2/2] Platform/NXP:LX2160: Enable support of USB controller Meenakshi Aggarwal
@ 2020-07-09 20:03 ` Meenakshi Aggarwal
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
` (3 more replies)
2 siblings, 4 replies; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-07-09 20:03 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
This patchset implement USB driver for DWC3 controller and enable
USB for LX2160A Platform.
Changes in v2:
- Indentation changes
- Incorporated review comments
- create EndOfDxe event and initialize USB in EndOfDxe
callback function.
Changes in v3:
- Passing Usb initialization function as init function
of RegisterNonDiscoverableMmioDevice()
Meenakshi Aggarwal (2):
Silicon/NXP: Add DWC3 USB controller initialization driver
Platform/NXP:LX2160: Enable support of USB controller
Silicon/NXP/NxpQoriqLs.dec | 5 +
Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 +
Silicon/NXP/NxpQoriqLs.dsc.inc | 12 +
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +-
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 45 ++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 ++++++++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 275 ++++++++++++++++++++
8 files changed, 495 insertions(+), 3 deletions(-)
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
--
1.9.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [edk2-platforms] [PATCH v3 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 0/2] Add USB driver support Meenakshi Aggarwal
@ 2020-07-09 20:03 ` Meenakshi Aggarwal
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 2/2] Platform/NXP:LX2160: Enable support of USB controller Meenakshi Aggarwal
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-07-09 20:03 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Add support of DWC3 controller driver which performs
DWC3 controller initialization and register itself as
NonDiscoverableMmioDevice
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
Silicon/NXP/NxpQoriqLs.dec | 5 +
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 45 ++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 ++++++++++
Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 275 ++++++++++++++++++++
4 files changed, 463 insertions(+)
diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
index d4d3057af509..72c1744fc934 100644
--- a/Silicon/NXP/NxpQoriqLs.dec
+++ b/Silicon/NXP/NxpQoriqLs.dec
@@ -36,6 +36,11 @@ [PcdsFixedAtBuild.common]
gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x0|UINT32|0x00000502
gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x0|UINT32|0x00000503
+ # Pcds for USB
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr|0x0|UINT64|0x00000510
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
+
[PcdsDynamic.common]
gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
new file mode 100644
index 000000000000..ea7532b4324b
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
@@ -0,0 +1,45 @@
+# UsbHcd.inf
+#
+# Copyright 2017, 2020 NXP
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = UsbHcdDxe
+ FILE_GUID = 196e7c2a-37b2-4b85-8683-718588952449
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeUsbHcd
+
+[Sources.common]
+ UsbHcd.c
+ UsbHcd.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ Silicon/NXP/NxpQoriqLs.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ IoLib
+ MemoryAllocationLib
+ NonDiscoverableDeviceRegistrationLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+
+[FixedPcd]
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize
+
+[Guids]
+ gEfiEndOfDxeEventGroupGuid
+
+[Depex]
+ TRUE
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
new file mode 100644
index 000000000000..cd9f9ad80125
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
@@ -0,0 +1,138 @@
+/** @file
+
+ Copyright 2017, 2020 NXP
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef USB_HCD_H_
+#define USB_HCD_H_
+
+#include <Base.h>
+
+/* Global constants */
+#define DWC3_GSNPSID_MASK 0xffff0000
+#define DWC3_SYNOPSYS_ID 0x55330000
+#define DWC3_RELEASE_MASK 0xffff
+#define DWC3_REG_OFFSET 0xC100
+#define DWC3_RELEASE_190a 0x190a
+
+/* Global Configuration Register */
+#define DWC3_GCTL_U2RSTECN BIT16
+#define DWC3_GCTL_PRTCAPDIR(N) ((N) << 12)
+#define DWC3_GCTL_PRTCAP_HOST 1
+#define DWC3_GCTL_PRTCAP_OTG 3
+#define DWC3_GCTL_CORESOFTRESET BIT11
+#define DWC3_GCTL_SCALEDOWN(N) ((N) << 4)
+#define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3)
+#define DWC3_GCTL_DISSCRAMBLE BIT3
+#define DWC3_GCTL_DSBLCLKGTNG BIT0
+
+/* Global HWPARAMS1 Register */
+#define DWC3_GHWPARAMS1_EN_PWROPT(N) (((N) & (3 << 24)) >> 24)
+#define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1
+
+/* Global USB2 PHY Configuration Register */
+#define DWC3_GUSB2PHYCFG_PHYSOFTRST BIT31
+
+/* Global USB3 PIPE Control Register */
+#define DWC3_GUSB3PIPECTL_PHYSOFTRST BIT31
+
+/* Global Frame Length Adjustment Register */
+#define GFLADJ_30MHZ_REG_SEL BIT7
+#define GFLADJ_30MHZ(N) ((N) & 0x3f)
+#define GFLADJ_30MHZ_DEFAULT 0x20
+
+/* Default to the FSL XHCI defines */
+#define USB3_ENABLE_BEAT_BURST 0xF
+#define USB3_ENABLE_BEAT_BURST_MASK 0xFF
+#define USB3_SET_BEAT_BURST_LIMIT 0xF00
+
+typedef struct {
+ UINT32 GEvntAdrLo;
+ UINT32 GEvntAdrHi;
+ UINT32 GEvntSiz;
+ UINT32 GEvntCount;
+} G_EVENT_BUFFER;
+
+typedef struct {
+ UINT32 DDepCmdPar2;
+ UINT32 DDepCmdPar1;
+ UINT32 DDepCmdPar0;
+ UINT32 DDepCmd;
+} D_PHYSICAL_EP;
+
+typedef struct {
+ UINT32 GSBusCfg0;
+ UINT32 GSBusCfg1;
+ UINT32 GTxThrCfg;
+ UINT32 GRxThrCfg;
+ UINT32 GCtl;
+ UINT32 Res1;
+ UINT32 GSts;
+ UINT32 Res2;
+ UINT32 GSnpsId;
+ UINT32 GGpio;
+ UINT32 GUid;
+ UINT32 GUctl;
+ UINT64 GBusErrAddr;
+ UINT64 GPrtbImap;
+ UINT32 GHwParams0;
+ UINT32 GHwParams1;
+ UINT32 GHwParams2;
+ UINT32 GHwParams3;
+ UINT32 GHwParams4;
+ UINT32 GHwParams5;
+ UINT32 GHwParams6;
+ UINT32 GHwParams7;
+ UINT32 GDbgFifoSpace;
+ UINT32 GDbgLtssm;
+ UINT32 GDbgLnmcc;
+ UINT32 GDbgBmu;
+ UINT32 GDbgLspMux;
+ UINT32 GDbgLsp;
+ UINT32 GDbgEpInfo0;
+ UINT32 GDbgEpInfo1;
+ UINT64 GPrtbImapHs;
+ UINT64 GPrtbImapFs;
+ UINT32 Res3[28];
+ UINT32 GUsb2PhyCfg[16];
+ UINT32 GUsb2I2cCtl[16];
+ UINT32 GUsb2PhyAcc[16];
+ UINT32 GUsb3PipeCtl[16];
+ UINT32 GTxFifoSiz[32];
+ UINT32 GRxFifoSiz[32];
+ G_EVENT_BUFFER GEvntBuf[32];
+ UINT32 GHwParams8;
+ UINT32 Res4[11];
+ UINT32 GFLAdj;
+ UINT32 Res5[51];
+ UINT32 DCfg;
+ UINT32 DCtl;
+ UINT32 DEvten;
+ UINT32 DSts;
+ UINT32 DGCmdPar;
+ UINT32 DGCmd;
+ UINT32 Res6[2];
+ UINT32 DAlepena;
+ UINT32 Res7[55];
+ D_PHYSICAL_EP DPhyEpCmd[32];
+ UINT32 Res8[128];
+ UINT32 OCfg;
+ UINT32 OCtl;
+ UINT32 OEvt;
+ UINT32 OEvtEn;
+ UINT32 OSts;
+ UINT32 Res9[3];
+ UINT32 AdpCfg;
+ UINT32 AdpCtl;
+ UINT32 AdpEvt;
+ UINT32 AdpEvten;
+ UINT32 BcCfg;
+ UINT32 Res10;
+ UINT32 BcEvt;
+ UINT32 BcEvten;
+} DWC3;
+
+#endif
diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
new file mode 100644
index 000000000000..8efb5c4f16c6
--- /dev/null
+++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
@@ -0,0 +1,275 @@
+/** @file
+
+ Copyright 2017, 2020 NXP
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include "UsbHcd.h"
+
+STATIC
+VOID
+XhciSetBeatBurstLength (
+ IN UINTN UsbReg
+ )
+{
+ DWC3 *Dwc3Reg;
+
+ Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
+
+ MmioAndThenOr32 ((UINTN)&Dwc3Reg->GSBusCfg0, ~USB3_ENABLE_BEAT_BURST_MASK,
+ USB3_ENABLE_BEAT_BURST);
+
+ MmioOr32 ((UINTN)&Dwc3Reg->GSBusCfg1, USB3_SET_BEAT_BURST_LIMIT);
+}
+
+STATIC
+VOID
+Dwc3SetFladj (
+ IN DWC3 *Dwc3Reg,
+ IN UINT32 Val
+ )
+{
+ MmioOr32 ((UINTN)&Dwc3Reg->GFLAdj, GFLADJ_30MHZ_REG_SEL |
+ GFLADJ_30MHZ (Val));
+}
+
+STATIC
+VOID
+Dwc3SetMode (
+ IN DWC3 *Dwc3Reg,
+ IN UINT32 Mode
+ )
+{
+ MmioAndThenOr32 ((UINTN)&Dwc3Reg->GCtl,
+ ~(DWC3_GCTL_PRTCAPDIR (DWC3_GCTL_PRTCAP_OTG)),
+ DWC3_GCTL_PRTCAPDIR (Mode));
+}
+
+/**
+ This function issues phy reset and core soft reset
+
+ @param Dwc3Reg Pointer to DWC3 register.
+
+**/
+STATIC
+VOID
+Dwc3CoreSoftReset (
+ IN DWC3 *Dwc3Reg
+ )
+{
+ //
+ // Put core in reset before resetting PHY
+ //
+ MmioOr32 ((UINTN)&Dwc3Reg->GCtl, DWC3_GCTL_CORESOFTRESET);
+
+ //
+ // Assert USB2 PHY reset
+ //
+ MmioOr32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST);
+
+ //
+ // Assert USB3 PHY reset
+ //
+ MmioOr32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, DWC3_GUSB2PHYCFG_PHYSOFTRST);
+
+ MemoryFence ();
+
+ //
+ // Clear USB3 PHY reset
+ //
+ MmioAnd32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], ~DWC3_GUSB3PIPECTL_PHYSOFTRST);
+
+ //
+ // Clear USB2 PHY reset
+ //
+ MmioAnd32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, ~DWC3_GUSB2PHYCFG_PHYSOFTRST);
+
+ MemoryFence ();
+
+ //
+ // Take core out of reset, PHYs are stable now
+ //
+ MmioAnd32 ((UINTN)&Dwc3Reg->GCtl, ~DWC3_GCTL_CORESOFTRESET);
+}
+
+/**
+ This function performs low-level initialization of DWC3 Core
+
+ @param Dwc3Reg Pointer to DWC3 register.
+
+**/
+STATIC
+EFI_STATUS
+Dwc3CoreInit (
+ IN DWC3 *Dwc3Reg
+ )
+{
+ UINT32 Revision;
+ UINT32 Reg;
+ UINTN Dwc3Hwparams1;
+
+ Revision = MmioRead32 ((UINTN)&Dwc3Reg->GSnpsId);
+ //
+ // This should read as 0x5533, ascii of U3(DWC_usb3) followed by revision num
+ //
+ if ((Revision & DWC3_GSNPSID_MASK) != DWC3_SYNOPSYS_ID) {
+ DEBUG ((DEBUG_ERROR,"This is not a DesignWare USB3 DRD Core.\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ Dwc3CoreSoftReset (Dwc3Reg);
+
+ Reg = MmioRead32 ((UINTN)&Dwc3Reg->GCtl);
+ Reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
+ Reg &= ~DWC3_GCTL_DISSCRAMBLE;
+
+ Dwc3Hwparams1 = MmioRead32 ((UINTN)&Dwc3Reg->GHwParams1);
+
+ if (DWC3_GHWPARAMS1_EN_PWROPT (Dwc3Hwparams1) ==
+ DWC3_GHWPARAMS1_EN_PWROPT_CLK) {
+ Reg &= ~DWC3_GCTL_DSBLCLKGTNG;
+ } else {
+ DEBUG ((DEBUG_WARN,"No power optimization available.\n"));
+ }
+
+ if ((Revision & DWC3_RELEASE_MASK) < DWC3_RELEASE_190a) {
+ Reg |= DWC3_GCTL_U2RSTECN;
+ }
+
+ MmioWrite32 ((UINTN)&Dwc3Reg->GCtl, Reg);
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+XhciCoreInit (
+ IN UINTN UsbReg
+ )
+{
+ EFI_STATUS Status;
+ DWC3 *Dwc3Reg;
+
+ Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
+
+ Status = Dwc3CoreInit (Dwc3Reg);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Dwc3CoreInit Failed for controller 0x%x (0x%r) \n",
+ UsbReg, Status));
+
+ return Status;
+ }
+
+ Dwc3SetMode (Dwc3Reg, DWC3_GCTL_PRTCAP_HOST);
+
+ Dwc3SetFladj (Dwc3Reg, GFLADJ_30MHZ_DEFAULT);
+
+ return Status;
+}
+
+NON_DISCOVERABLE_DEVICE_INIT
+EFIAPI
+InitializeUsbController (
+ IN UINTN UsbReg
+ )
+{
+ EFI_STATUS Status;
+
+ Status = XhciCoreInit (UsbReg);
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "USB Controller init Failed for %d (0x%r)\n",
+ UsbReg, Status));
+ return (VOID *)EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Change beat burst and outstanding pipelined transfers requests
+ //
+ XhciSetBeatBurstLength (UsbReg);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function gets registered as a callback to perform USB controller intialization
+
+ @param Event Event whose notification function is being invoked.
+ @param Context Pointer to the notification function's context.
+
+**/
+VOID
+EFIAPI
+UsbEndOfDxeCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ UINT32 NumUsbController;
+ UINT32 ControllerAddr;
+ UINT32 Index;
+
+ gBS->CloseEvent (Event);
+
+ NumUsbController = PcdGet32 (PcdNumUsbController);
+
+ for (Index = 0; Index < NumUsbController; Index++) {
+ ControllerAddr = PcdGet64 (PcdUsbBaseAddr) +
+ (Index * PcdGet32 (PcdUsbSize));
+
+ Status = RegisterNonDiscoverableMmioDevice (
+ NonDiscoverableDeviceTypeXhci,
+ NonDiscoverableDeviceDmaTypeNonCoherent,
+ InitializeUsbController (ControllerAddr),
+ NULL,
+ 1,
+ ControllerAddr, PcdGet32 (PcdUsbSize)
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to register USB device 0x%x, error 0x%r \n",
+ ControllerAddr, Status));
+ }
+ }
+}
+
+/**
+ The Entry Point of module. It follows the standard UEFI driver model.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeUsbHcd (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT EndOfDxeEvent;
+
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ UsbEndOfDxeCallback,
+ NULL,
+ &gEfiEndOfDxeEventGroupGuid,
+ &EndOfDxeEvent
+ );
+
+ return Status;
+}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [edk2-platforms] [PATCH v3 2/2] Platform/NXP:LX2160: Enable support of USB controller
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 0/2] Add USB driver support Meenakshi Aggarwal
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
@ 2020-07-09 20:03 ` Meenakshi Aggarwal
[not found] ` <VI1PR04MB45920207F1DCBCDC64B8918CE87B0@VI1PR04MB4592.eurprd04.prod.outlook.com>
2020-07-24 16:47 ` Leif Lindholm
3 siblings, 0 replies; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-07-09 20:03 UTC (permalink / raw)
To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal
From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
- Enable support of USB drives on lx2160 RDB board.
- LX2160 has DWC3 controller
- Increase FD size to accomodate USB driver.
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 ++++
Silicon/NXP/NxpQoriqLs.dsc.inc | 12 ++++++++++++
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +++++++++++++++---
4 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/Silicon/NXP/LX2160A/LX2160A.dsc.inc b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
index af22b4dd973c..55dd3b5442eb 100644
--- a/Silicon/NXP/LX2160A/LX2160A.dsc.inc
+++ b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
@@ -36,6 +36,10 @@ [PcdsFixedAtBuild.common]
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x21C0000
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr|0x3100000
+ gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x10000
+ gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|2
+
[PcdsFeatureFlag]
gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|TRUE
diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc b/Silicon/NXP/NxpQoriqLs.dsc.inc
index ee639d552483..1f0f272da6c7 100644
--- a/Silicon/NXP/NxpQoriqLs.dsc.inc
+++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
@@ -366,6 +366,18 @@ [Components.common]
FatPkg/EnhancedFatDxe/Fat.inf
#
+ # USB
+ #
+
+ MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+ MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+ MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+ MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+ MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+
+ #
# Bds
#
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
index 9b3e0386c13e..ec27a1a219a5 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
@@ -43,4 +43,5 @@ [Components.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
}
+ Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
##
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
index eec1c0774a86..5cb809e8b3a0 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
@@ -23,10 +23,10 @@
[FD.LX2160ARDB_EFI]
BaseAddress = 0x82000000|gArmTokenSpaceGuid.PcdFdBaseAddress #The base address of the FLASH Device.
-Size = 0x00140000|gArmTokenSpaceGuid.PcdFdSize #The size in bytes of the FLASH Device
+Size = 0x00160000|gArmTokenSpaceGuid.PcdFdSize #The size in bytes of the FLASH Device
ErasePolarity = 1
BlockSize = 0x10000
-NumBlocks = 0x14
+NumBlocks = 0x16
################################################################################
#
@@ -43,7 +43,7 @@ [FD.LX2160ARDB_EFI]
# RegionType <FV, DATA, or FILE>
#
################################################################################
-0x00000000|0x00140000
+0x00000000|0x00160000
gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
FV = FVMAIN_COMPACT
@@ -120,6 +120,18 @@ [FV.FvMain]
INF FatPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+ INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+
+ #
+ # USB Support
+ #
+ INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+ INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+ INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+ INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+ INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+ INF Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
#
# UEFI application (Shell Embedded Boot Loader)
#
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [edk2-platforms] [PATCH v3 0/2] Add USB driver support
[not found] ` <VI1PR04MB45920207F1DCBCDC64B8918CE87B0@VI1PR04MB4592.eurprd04.prod.outlook.com>
@ 2020-07-20 6:26 ` Meenakshi Aggarwal
0 siblings, 0 replies; 14+ messages in thread
From: Meenakshi Aggarwal @ 2020-07-20 6:26 UTC (permalink / raw)
To: ard.biesheuvel@arm.com
Cc: Varun Sethi, Meenakshi Aggarwal (OSS), leif@nuviainc.com,
michael.d.kinney@intel.com, devel@edk2.groups.io
Hi Ard,
Any further comments on these patches?
Thanks,
Meenakshi
> -----Original Message-----
> From: Meenakshi Aggarwal <meenakshi.aggarwal@oss.nxp.com>
> Sent: Friday, July 10, 2020 1:34 AM
> To: ard.biesheuvel@arm.com; leif@nuviainc.com;
> michael.d.kinney@intel.com; devel@edk2.groups.io
> Cc: Varun Sethi <V.Sethi@nxp.com>; Meenakshi Aggarwal (OSS)
> <meenakshi.aggarwal@oss.nxp.com>
> Subject: [edk2-platforms] [PATCH v3 0/2] Add USB driver support
>
> This patchset implement USB driver for DWC3 controller and enable USB for
> LX2160A Platform.
>
> Changes in v2:
> - Indentation changes
> - Incorporated review comments
> - create EndOfDxe event and initialize USB in EndOfDxe
> callback function.
>
> Changes in v3:
> - Passing Usb initialization function as init function
> of RegisterNonDiscoverableMmioDevice()
>
> Meenakshi Aggarwal (2):
> Silicon/NXP: Add DWC3 USB controller initialization driver
> Platform/NXP:LX2160: Enable support of USB controller
>
> Silicon/NXP/NxpQoriqLs.dec | 5 +
> Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 +
> Silicon/NXP/NxpQoriqLs.dsc.inc | 12 +
> Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
> Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +-
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 45 ++++
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 ++++++++++
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 275
> ++++++++++++++++++++
> 8 files changed, 495 insertions(+), 3 deletions(-) create mode 100644
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
> create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
>
> --
> 1.9.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [edk2-platforms] [PATCH v3 0/2] Add USB driver support
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 0/2] Add USB driver support Meenakshi Aggarwal
` (2 preceding siblings ...)
[not found] ` <VI1PR04MB45920207F1DCBCDC64B8918CE87B0@VI1PR04MB4592.eurprd04.prod.outlook.com>
@ 2020-07-24 16:47 ` Leif Lindholm
2020-07-27 5:29 ` Meenakshi Aggarwal (OSS)
3 siblings, 1 reply; 14+ messages in thread
From: Leif Lindholm @ 2020-07-24 16:47 UTC (permalink / raw)
To: Meenakshi Aggarwal; +Cc: ard.biesheuvel, michael.d.kinney, devel, v.sethi
On Fri, Jul 10, 2020 at 01:33:54 +0530, Meenakshi Aggarwal wrote:
> This patchset implement USB driver for DWC3 controller and enable
> USB for LX2160A Platform.
>
> Changes in v2:
> - Indentation changes
> - Incorporated review comments
> - create EndOfDxe event and initialize USB in EndOfDxe
> callback function.
>
> Changes in v3:
> - Passing Usb initialization function as init function
> of RegisterNonDiscoverableMmioDevice()
>
> Meenakshi Aggarwal (2):
> Silicon/NXP: Add DWC3 USB controller initialization driver
> Platform/NXP:LX2160: Enable support of USB controller
For series:
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
However, in future, please rebase patches onto current master before
sumitting later revisions. This set conflicted with 7c552c1a2611
("Platform/NXP: LX2160aRdbPkg: Enable PlatformDxe driver") which was
pushed on 3 July.
Pushed (together with SATA series previously reviewed) as:
b972f17b329a..7de21b6aa3e0
> Silicon/NXP/NxpQoriqLs.dec | 5 +
> Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 +
> Silicon/NXP/NxpQoriqLs.dsc.inc | 12 +
> Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
> Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +-
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 45 ++++
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 ++++++++++
> Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 275 ++++++++++++++++++++
> 8 files changed, 495 insertions(+), 3 deletions(-)
> create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
> create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
>
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [edk2-platforms] [PATCH v3 0/2] Add USB driver support
2020-07-24 16:47 ` Leif Lindholm
@ 2020-07-27 5:29 ` Meenakshi Aggarwal (OSS)
0 siblings, 0 replies; 14+ messages in thread
From: Meenakshi Aggarwal (OSS) @ 2020-07-27 5:29 UTC (permalink / raw)
To: Leif Lindholm, Meenakshi Aggarwal (OSS)
Cc: ard.biesheuvel@arm.com, michael.d.kinney@intel.com,
devel@edk2.groups.io, Varun Sethi
Thanks Leif,
We will take care of same in future patches.
> -----Original Message-----
> From: Leif Lindholm <leif@nuviainc.com>
> Sent: Friday, July 24, 2020 10:17 PM
> To: Meenakshi Aggarwal (OSS) <meenakshi.aggarwal@oss.nxp.com>
> Cc: ard.biesheuvel@arm.com; michael.d.kinney@intel.com;
> devel@edk2.groups.io; Varun Sethi <V.Sethi@nxp.com>
> Subject: Re: [edk2-platforms] [PATCH v3 0/2] Add USB driver support
>
> On Fri, Jul 10, 2020 at 01:33:54 +0530, Meenakshi Aggarwal wrote:
> > This patchset implement USB driver for DWC3 controller and enable USB
> > for LX2160A Platform.
> >
> > Changes in v2:
> > - Indentation changes
> > - Incorporated review comments
> > - create EndOfDxe event and initialize USB in EndOfDxe
> > callback function.
> >
> > Changes in v3:
> > - Passing Usb initialization function as init function
> > of RegisterNonDiscoverableMmioDevice()
> >
> > Meenakshi Aggarwal (2):
> > Silicon/NXP: Add DWC3 USB controller initialization driver
> > Platform/NXP:LX2160: Enable support of USB controller
>
> For series:
> Reviewed-by: Leif Lindholm <leif@nuviainc.com>
>
> However, in future, please rebase patches onto current master before
> sumitting later revisions. This set conflicted with 7c552c1a2611
> ("Platform/NXP: LX2160aRdbPkg: Enable PlatformDxe driver") which was
> pushed on 3 July.
>
> Pushed (together with SATA series previously reviewed) as:
> b972f17b329a..7de21b6aa3e0
>
> > Silicon/NXP/NxpQoriqLs.dec | 5 +
> > Silicon/NXP/LX2160A/LX2160A.dsc.inc | 4 +
> > Silicon/NXP/NxpQoriqLs.dsc.inc | 12 +
> > Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 +
> > Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +-
> > Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 45 ++++
> > Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 138 ++++++++++
> > Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 275
> ++++++++++++++++++++
> > 8 files changed, 495 insertions(+), 3 deletions(-) create mode
> > 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> > create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
> > create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
> >
> > --
> > 1.9.1
> >
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-07-27 5:29 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-02 13:47 [PATCH edk2-platforms 0/2] Add USB driver support Meenakshi Aggarwal
2020-06-02 13:47 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
2020-06-02 8:43 ` Ard Biesheuvel
2020-06-02 13:47 ` [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of USB controller Meenakshi Aggarwal
2020-06-03 16:00 ` [PATCH edk2-platforms V2 0/2] Add USB driver support Meenakshi Aggarwal
2020-06-03 16:00 ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
2020-06-12 10:29 ` Ard Biesheuvel
2020-06-03 16:00 ` [PATCH edk2-platforms V2 2/2] Platform/NXP:LX2160: Enable support of USB controller Meenakshi Aggarwal
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 0/2] Add USB driver support Meenakshi Aggarwal
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 1/2] Silicon/NXP: Add DWC3 USB controller initialization driver Meenakshi Aggarwal
2020-07-09 20:03 ` [edk2-platforms] [PATCH v3 2/2] Platform/NXP:LX2160: Enable support of USB controller Meenakshi Aggarwal
[not found] ` <VI1PR04MB45920207F1DCBCDC64B8918CE87B0@VI1PR04MB4592.eurprd04.prod.outlook.com>
2020-07-20 6:26 ` [edk2-platforms] [PATCH v3 0/2] Add USB driver support Meenakshi Aggarwal
2020-07-24 16:47 ` Leif Lindholm
2020-07-27 5:29 ` Meenakshi Aggarwal (OSS)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox