[PATCH v3 3/3] usb: dwc3: introduce flatten model driver of i.MX Soc
Xu Yang
xu.yang_2 at nxp.com
Wed Feb 11 02:31:23 PST 2026
On Fri, Feb 06, 2026 at 11:03:42AM -0500, Frank Li wrote:
> On Fri, Feb 06, 2026 at 06:18:51PM +0800, Xu Yang wrote:
> > The i.MX USB glue and DWC3 core are closely coupled. Describe the i.MX
> > USB block in a single block will bring more benefits than a parent-
> > child relation. To support the flatten model devicetree, DWC3 USB core
> > driver already support to directly register and initialize the core in
> > glue layer using one device. And many notification can be received in
> > glue layer timely and proper actions can be executed accordingly.
> >
> > To align with mainstream, introduce a new driver to support flatten dwc3
> > devicetree model for i.MX Soc. Besides this driver disabling wakeup irq
> > when system is active, no other function change in this version compared
> > to dwc3-imx8mp.c
> >
> > Signed-off-by: Xu Yang <xu.yang_2 at nxp.com>
> >
> > ---
> > Changes in v3:
> > - update compatible as nxp,imx8mp-dwc3
> > Changes in v2:
> > - improve commit message
> > - fix code style
> > - add IRQF_NO_AUTOEN
> > - remove pm_runtime_* in dwc3_imx_remove(), dwc3_core_remove()
> > will do that
> > ---
> > drivers/usb/dwc3/Kconfig | 12 ++
> > drivers/usb/dwc3/Makefile | 1 +
> > drivers/usb/dwc3/dwc3-imx.c | 429 ++++++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 442 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> > index 240b15bc52cb..18169727a413 100644
> > --- a/drivers/usb/dwc3/Kconfig
> > +++ b/drivers/usb/dwc3/Kconfig
> > @@ -150,6 +150,18 @@ config USB_DWC3_IMX8MP
> > functionality.
> > Say 'Y' or 'M' if you have one such device.
> >
> > +config USB_DWC3_IMX
> > + tristate "NXP iMX Platform"
> > + depends on OF && COMMON_CLK
> > + depends on (ARCH_MXC && ARM64) || COMPILE_TEST
> > + default USB_DWC3
> > + help
> > + NXP iMX SoC use DesignWare Core IP for USB2/3
> > + functionality.
> > + This driver also handles the wakeup feature outside
> > + of DesignWare Core.
> > + 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 073bef5309b5..f37971197203 100644
> > --- a/drivers/usb/dwc3/Makefile
> > +++ b/drivers/usb/dwc3/Makefile
> > @@ -55,6 +55,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_IMX) += dwc3-imx.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-imx.c b/drivers/usb/dwc3/dwc3-imx.c
> > new file mode 100644
> > index 000000000000..3b154d075bcf
> > --- /dev/null
> > +++ b/drivers/usb/dwc3/dwc3-imx.c
> > @@ -0,0 +1,429 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * dwc3-imx.c - NXP i.MX Soc USB3 Specific Glue layer
> > + *
> > + * Copyright 2026 NXP
> > + */
> > +
> > +#include <linux/clk.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/io.h>
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/pm_runtime.h>
> > +
> > +#include "core.h"
> > +#include "glue.h"
> > +
> > +/* USB wakeup registers */
> > +#define USB_WAKEUP_CTRL 0x00
> > +
> > +/* Global wakeup interrupt enable, also used to clear interrupt */
> > +#define USB_WAKEUP_EN BIT(31)
> > +/* Wakeup from connect or disconnect, only for superspeed */
> > +#define USB_WAKEUP_SS_CONN BIT(5)
> > +/* 0 select vbus_valid, 1 select sessvld */
> > +#define USB_WAKEUP_VBUS_SRC_SESS_VAL BIT(4)
> > +/* Enable signal for wake up from u3 state */
> > +#define USB_WAKEUP_U3_EN BIT(3)
> > +/* Enable signal for wake up from id change */
> > +#define USB_WAKEUP_ID_EN BIT(2)
> > +/* Enable signal for wake up from vbus change */
> > +#define USB_WAKEUP_VBUS_EN BIT(1)
> > +/* Enable signal for wake up from dp/dm change */
> > +#define USB_WAKEUP_DPDM_EN BIT(0)
> > +
> > +#define USB_WAKEUP_EN_MASK GENMASK(5, 0)
> > +
> > +/* USB glue registers */
> > +#define USB_CTRL0 0x00
> > +#define USB_CTRL1 0x04
> > +
> > +#define USB_CTRL0_PORTPWR_EN BIT(12) /* 1 - PPC enabled (default) */
> > +#define USB_CTRL0_USB3_FIXED BIT(22) /* 1 - USB3 permanent attached */
> > +#define USB_CTRL0_USB2_FIXED BIT(23) /* 1 - USB2 permanent attached */
> > +
> > +#define USB_CTRL1_OC_POLARITY BIT(16) /* 0 - HIGH / 1 - LOW */
> > +#define USB_CTRL1_PWR_POLARITY BIT(17) /* 0 - HIGH / 1 - LOW */
> > +
> > +struct dwc3_imx {
> > + struct dwc3 dwc;
> > + struct device *dev;
> > + void __iomem *blkctl_base;
> > + void __iomem *glue_base;
> > + struct clk *hsio_clk;
> > + struct clk *suspend_clk;
> > + int irq;
> > + bool pm_suspended;
> > + bool wakeup_pending;
> > +};
> > +
> > +#define to_dwc3_imx(d) container_of((d), struct dwc3_imx, dwc)
> > +
> > +static void dwc3_imx_configure_glue(struct dwc3_imx *dwc_imx)
> > +{
> > + struct device *dev = dwc_imx->dev;
> > + u32 value;
> > +
> > + if (!dwc_imx->glue_base)
> > + return;
> > +
> > + value = readl(dwc_imx->glue_base + USB_CTRL0);
> > +
> > + if (device_property_read_bool(dev, "fsl,permanently-attached"))
>
> can you parse it at probe and save into dwc3_imx to avoid parse dts every
> resume()?
Sure. Good suggestion!
Thanks,
Xu Yang
More information about the linux-arm-kernel
mailing list