drivers/usb/dwc3/dwc3-qcom-legacy.c
Source file repositories/reference/linux-study-clean/drivers/usb/dwc3/dwc3-qcom-legacy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/dwc3/dwc3-qcom-legacy.c- Extension
.c- Size
- 22722 bytes
- Lines
- 936
- 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/cleanup.hlinux/io.hlinux/of.hlinux/clk.hlinux/irq.hlinux/of_clk.hlinux/module.hlinux/kernel.hlinux/extcon.hlinux/interconnect.hlinux/of_platform.hlinux/platform_device.hlinux/phy/phy.hlinux/usb/of.hlinux/reset.hlinux/iopoll.hlinux/usb/hcd.hlinux/usb.hcore.h
Detected Declarations
struct dwc3_qcom_portstruct dwc3_qcomfunction dwc3_qcom_setbitsfunction dwc3_qcom_clrbitsfunction dwc3_qcom_vbus_override_enablefunction dwc3_qcom_vbus_notifierfunction dwc3_qcom_host_notifierfunction dwc3_qcom_register_extconfunction dwc3_qcom_interconnect_enablefunction dwc3_qcom_interconnect_disablefunction dwc3_qcom_interconnect_initfunction dwc3_qcom_interconnect_exitfunction dwc3_qcom_is_hostfunction dwc3_qcom_read_usb2_speedfunction dwc3_qcom_enable_wakeup_irqfunction dwc3_qcom_disable_wakeup_irqfunction dwc3_qcom_disable_port_interruptsfunction dwc3_qcom_enable_port_interruptsfunction dwc3_qcom_disable_interruptsfunction dwc3_qcom_enable_interruptsfunction dwc3_qcom_suspendfunction dwc3_qcom_resumefunction qcom_dwc3_resume_irqfunction dwc3_qcom_select_utmi_clkfunction dwc3_qcom_request_irqfunction dwc3_qcom_setup_port_irqfunction dwc3_qcom_find_num_portsfunction dwc3_qcom_setup_irqfunction dwc3_qcom_clk_initfunction dwc3_qcom_of_register_corefunction dwc3_qcom_probefunction dwc3_qcom_removefunction dwc3_qcom_pm_suspendfunction dwc3_qcom_pm_resumefunction dwc3_qcom_runtime_suspendfunction dwc3_qcom_runtime_resume
Annotated Snippet
struct dwc3_qcom_port {
int qusb2_phy_irq;
int dp_hs_phy_irq;
int dm_hs_phy_irq;
int ss_phy_irq;
enum usb_device_speed usb2_speed;
};
struct dwc3_qcom {
struct device *dev;
void __iomem *qscratch_base;
struct platform_device *dwc3;
struct clk **clks;
int num_clocks;
struct reset_control *resets;
struct dwc3_qcom_port ports[DWC3_QCOM_MAX_PORTS];
u8 num_ports;
struct extcon_dev *edev;
struct extcon_dev *host_edev;
struct notifier_block vbus_nb;
struct notifier_block host_nb;
enum usb_dr_mode mode;
bool is_suspended;
bool pm_suspended;
struct icc_path *icc_path_ddr;
struct icc_path *icc_path_apps;
};
static inline void dwc3_qcom_setbits(void __iomem *base, u32 offset, u32 val)
{
u32 reg;
reg = readl(base + offset);
reg |= val;
writel(reg, base + offset);
/* ensure that above write is through */
readl(base + offset);
}
static inline void dwc3_qcom_clrbits(void __iomem *base, u32 offset, u32 val)
{
u32 reg;
reg = readl(base + offset);
reg &= ~val;
writel(reg, base + offset);
/* ensure that above write is through */
readl(base + offset);
}
static void dwc3_qcom_vbus_override_enable(struct dwc3_qcom *qcom, bool enable)
{
if (enable) {
dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_SS_PHY_CTRL,
LANE0_PWR_PRESENT);
dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_HS_PHY_CTRL,
UTMI_OTG_VBUS_VALID | SW_SESSVLD_SEL);
} else {
dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_SS_PHY_CTRL,
LANE0_PWR_PRESENT);
dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_HS_PHY_CTRL,
UTMI_OTG_VBUS_VALID | SW_SESSVLD_SEL);
}
}
static int dwc3_qcom_vbus_notifier(struct notifier_block *nb,
unsigned long event, void *ptr)
{
struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, vbus_nb);
/* enable vbus override for device mode */
dwc3_qcom_vbus_override_enable(qcom, event);
qcom->mode = event ? USB_DR_MODE_PERIPHERAL : USB_DR_MODE_HOST;
return NOTIFY_DONE;
}
static int dwc3_qcom_host_notifier(struct notifier_block *nb,
unsigned long event, void *ptr)
{
struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, host_nb);
/* disable vbus override in host mode */
dwc3_qcom_vbus_override_enable(qcom, !event);
qcom->mode = event ? USB_DR_MODE_HOST : USB_DR_MODE_PERIPHERAL;
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/io.h`, `linux/of.h`, `linux/clk.h`, `linux/irq.h`, `linux/of_clk.h`, `linux/module.h`, `linux/kernel.h`.
- Detected declarations: `struct dwc3_qcom_port`, `struct dwc3_qcom`, `function dwc3_qcom_setbits`, `function dwc3_qcom_clrbits`, `function dwc3_qcom_vbus_override_enable`, `function dwc3_qcom_vbus_notifier`, `function dwc3_qcom_host_notifier`, `function dwc3_qcom_register_extcon`, `function dwc3_qcom_interconnect_enable`, `function dwc3_qcom_interconnect_disable`.
- 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.