[PATCH 2/3] usb: dwc3: add layerscape dwc3 support
Frank Li
Frank.li at nxp.com
Tue Jun 3 07:59:17 PDT 2025
On Tue, Jun 03, 2025 at 01:23:03AM +0000, Thinh Nguyen wrote:
> Hi,
>
> On Mon, Jun 02, 2025, Frank Li wrote:
> > Add layerscape dwc3 support by using flatten dwc3 core library. Layerscape
> > dwc3 need set software managed property snps,gsbuscfg0-reqinfo as 0x2222
> > when dma-coherence set.
> >
> > Signed-off-by: Frank Li <Frank.Li at nxp.com>
> > ---
> > drivers/usb/dwc3/Kconfig | 10 +++++
> > drivers/usb/dwc3/Makefile | 1 +
> > drivers/usb/dwc3/dwc3-layerscape.c | 88 ++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 99 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> > index 310d182e10b50..13a86cf03b94b 100644
> > --- a/drivers/usb/dwc3/Kconfig
> > +++ b/drivers/usb/dwc3/Kconfig
> > @@ -150,6 +150,16 @@ config USB_DWC3_IMX8MP
> > functionality.
> > Say 'Y' or 'M' if you have one such device.
> >
> > +config USB_DWC3_LAYERSCAPE
> > + tristate "NXP Layerscape Platform"
> > + depends on OF && COMMON_CLK
> > + depends on ARCH_LAYERSCAPE || COMPILE_TEST
> > + default USB_DWC3
> > + help
> > + NXP LAYERSCAPE SoC use DesignWare Core IP for USB2/3
> > + functionality.
> > + Say 'Y' or 'M' if you have one such device.
> > +
> > config USB_DWC3_XILINX
> > tristate "Xilinx Platforms"
> > depends on (ARCH_ZYNQMP || COMPILE_TEST) && OF
> > diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
> > index 830e6c9e5fe07..cd635b77902fb 100644
> > --- a/drivers/usb/dwc3/Makefile
> > +++ b/drivers/usb/dwc3/Makefile
> > @@ -54,6 +54,7 @@ obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o
> > obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom.o
> > obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom-legacy.o
> > obj-$(CONFIG_USB_DWC3_IMX8MP) += dwc3-imx8mp.o
> > +obj-$(CONFIG_USB_DWC3_LAYERSCAPE) += dwc3-layerscape.o
> > obj-$(CONFIG_USB_DWC3_XILINX) += dwc3-xilinx.o
> > obj-$(CONFIG_USB_DWC3_OCTEON) += dwc3-octeon.o
> > obj-$(CONFIG_USB_DWC3_RTK) += dwc3-rtk.o
> > diff --git a/drivers/usb/dwc3/dwc3-layerscape.c b/drivers/usb/dwc3/dwc3-layerscape.c
> > new file mode 100644
> > index 0000000000000..d093f178e1e35
> > --- /dev/null
> > +++ b/drivers/usb/dwc3/dwc3-layerscape.c
> > @@ -0,0 +1,88 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (c) 2020 NXP
> > + */
> > +
> > +#include <linux/of.h>
> > +#include <linux/of_address.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/usb/of.h>
> > +
> > +#include "core.h"
> > +#include "glue.h"
> > +
> > +struct dwc3_ls {
> > + struct device *dev;
> > + struct dwc3 dwc;
> > +};
> > +
> > +static int dwc3_ls_probe(struct platform_device *pdev)
> > +{
> > + struct device_node *np = pdev->dev.of_node;
> > + struct dwc3_probe_data probe_data = {};
> > + struct property_entry props[2] = {};
> > + struct device *dev = &pdev->dev;
> > + struct resource *res;
> > + struct dwc3_ls *ls;
> > + int prop_idx = 0;
> > + int ret = 0;
> > +
> > + ls = devm_kzalloc(&pdev->dev, sizeof(*ls), GFP_KERNEL);
> > + if (!ls)
> > + return -ENOMEM;
> > +
> > + ls->dev = &pdev->dev;
> > +
> > + ls->dwc.dev = dev;
> > +
> > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > + if (!res)
> > + dev_err_probe(&pdev->dev, -ENODEV, "missing memory resource\n");
> > +
> > + if (of_dma_is_coherent(np))
> > + props[prop_idx++] = PROPERTY_ENTRY_U16("snps,gsbuscfg0-reqinfo", 0x2222);
> > +
> > + if (prop_idx)
> > + ret = device_create_managed_software_node(dev, props, NULL);
> > +
> > + if (ret)
> > + return dev_err_probe(dev, ret, "fail create software managed property node\n");
> > +
> > + probe_data.dwc = &ls->dwc;
> > + probe_data.res = res;
> > + ret = dwc3_core_probe(&probe_data);
> > + if (ret)
> > + return dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
> > +
> > + return 0;
> > +}
> > +
> > +static void dwc3_ls_remove(struct platform_device *pdev)
> > +{
> > + struct dwc3 *dwc = platform_get_drvdata(pdev);
> > +
> > + dwc3_core_remove(dwc);
> > +}
> > +
> > +static const struct of_device_id of_dwc3_ls_match[] = {
> > + {
> > + .compatible = "fsl,ls1028a-dwc3"
> > + },
> > + {},
> > +};
> > +MODULE_DEVICE_TABLE(of, of_dwc3_ls_match);
> > +
> > +static struct platform_driver dwc3_ls_driver = {
> > + .probe = dwc3_ls_probe,
> > + .remove = dwc3_ls_remove,
> > + .driver = {
> > + .name = "ls-dwc3",
> > + .of_match_table = of_dwc3_ls_match,
> > + },
> > +};
> > +
> > +module_platform_driver(dwc3_ls_driver);
> > +
> > +MODULE_AUTHOR("Frank Li <frank.li at nxp.com>");
> > +MODULE_LICENSE("GPL");
> > +MODULE_DESCRIPTION("Freescale Layerscape USB3 Controller Driver");
> >
> > --
> > 2.34.1
> >
>
> Is this something that can be enhanced in dwc3-generic-plat glue from Ze
> Huang:
Yes, I can base on Zehuang's work with little modify. Please let me know
when his patch merged.
Frank
>
> https://lore.kernel.org/linux-usb/20250526-b4-k1-dwc3-v3-v4-3-63e4e525e5cb@whut.edu.cn/T/#u
>
> Thanks,
> Thinh
More information about the linux-arm-kernel
mailing list