drivers/usb/dwc3/dwc3-imx.c
Source file repositories/reference/linux-study-clean/drivers/usb/dwc3/dwc3-imx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/dwc3/dwc3-imx.c- Extension
.c- Size
- 11449 bytes
- Lines
- 449
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.hcore.hglue.h
Detected Declarations
struct dwc3_imxfunction dwc3_imx_get_propertyfunction dwc3_imx_configure_gluefunction dwc3_imx_wakeup_enablefunction dwc3_imx_wakeup_disablefunction dwc3_imx_interruptfunction dwc3_imx_pre_set_rolefunction dwc3_imx_probefunction dwc3_imx_removefunction dwc3_imx_suspendfunction dwc3_imx_resumefunction dwc3_imx_runtime_suspendfunction dwc3_imx_runtime_resumefunction dwc3_imx_runtime_idlefunction dwc3_imx_pm_suspendfunction dwc3_imx_pm_resumefunction dwc3_imx_completefunction dwc3_imx_prepare
Annotated Snippet
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;
unsigned permanent_attached:1;
unsigned disable_pwr_ctrl:1;
unsigned overcur_active_low:1;
unsigned power_active_low:1;
};
#define to_dwc3_imx(d) container_of((d), struct dwc3_imx, dwc)
static void dwc3_imx_get_property(struct dwc3_imx *dwc_imx)
{
struct device *dev = dwc_imx->dev;
dwc_imx->permanent_attached =
device_property_read_bool(dev, "fsl,permanently-attached");
dwc_imx->disable_pwr_ctrl =
device_property_read_bool(dev, "fsl,disable-port-power-control");
dwc_imx->overcur_active_low =
device_property_read_bool(dev, "fsl,over-current-active-low");
dwc_imx->power_active_low =
device_property_read_bool(dev, "fsl,power-active-low");
}
static void dwc3_imx_configure_glue(struct dwc3_imx *dwc_imx)
{
u32 value;
if (!dwc_imx->glue_base)
return;
value = readl(dwc_imx->glue_base + USB_CTRL0);
if (dwc_imx->permanent_attached)
value |= USB_CTRL0_USB2_FIXED | USB_CTRL0_USB3_FIXED;
else
value &= ~(USB_CTRL0_USB2_FIXED | USB_CTRL0_USB3_FIXED);
if (dwc_imx->disable_pwr_ctrl)
value &= ~USB_CTRL0_PORTPWR_EN;
else
value |= USB_CTRL0_PORTPWR_EN;
writel(value, dwc_imx->glue_base + USB_CTRL0);
value = readl(dwc_imx->glue_base + USB_CTRL1);
if (dwc_imx->overcur_active_low)
value |= USB_CTRL1_OC_POLARITY;
else
value &= ~USB_CTRL1_OC_POLARITY;
if (dwc_imx->power_active_low)
value |= USB_CTRL1_PWR_POLARITY;
else
value &= ~USB_CTRL1_PWR_POLARITY;
writel(value, dwc_imx->glue_base + USB_CTRL1);
}
static void dwc3_imx_wakeup_enable(struct dwc3_imx *dwc_imx, pm_message_t msg)
{
struct dwc3 *dwc = &dwc_imx->dwc;
u32 val;
val = readl(dwc_imx->blkctl_base + USB_WAKEUP_CTRL);
if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST && dwc->xhci) {
val |= USB_WAKEUP_EN | USB_WAKEUP_DPDM_EN;
if (PMSG_IS_AUTO(msg))
val |= USB_WAKEUP_SS_CONN | USB_WAKEUP_U3_EN;
} else {
val |= USB_WAKEUP_EN | USB_WAKEUP_VBUS_EN |
USB_WAKEUP_VBUS_SRC_SESS_VAL;
}
writel(val, dwc_imx->blkctl_base + USB_WAKEUP_CTRL);
}
static void dwc3_imx_wakeup_disable(struct dwc3_imx *dwc_imx)
{
u32 val;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct dwc3_imx`, `function dwc3_imx_get_property`, `function dwc3_imx_configure_glue`, `function dwc3_imx_wakeup_enable`, `function dwc3_imx_wakeup_disable`, `function dwc3_imx_interrupt`, `function dwc3_imx_pre_set_role`, `function dwc3_imx_probe`, `function dwc3_imx_remove`, `function dwc3_imx_suspend`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.