drivers/usb/dwc2/core_intr.c
Source file repositories/reference/linux-study-clean/drivers/usb/dwc2/core_intr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/dwc2/core_intr.c- Extension
.c- Size
- 24856 bytes
- Lines
- 910
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/moduleparam.hlinux/spinlock.hlinux/interrupt.hlinux/dma-mapping.hlinux/io.hlinux/slab.hlinux/usb.hlinux/usb/hcd.hlinux/usb/ch11.hcore.hhcd.h
Detected Declarations
function Copyrightfunction dwc2_handle_usb_port_intrfunction dwc2_handle_mode_mismatch_intrfunction dwc2_handle_otg_intrfunction dwc2_handle_conn_id_status_change_intrfunction dwc2_handle_session_req_intrfunction dwc2_wakeup_from_lpm_l1function dwc2_handle_wakeup_detected_intrfunction dwc2_handle_disconnect_intrfunction dwc2_handle_usb_suspend_intrfunction dwc2_handle_lpm_intrfunction dwc2_read_common_intrfunction dwc_handle_gpwrdn_disc_detfunction dwc2_handle_gpwrdn_intrfunction dwc2_handle_common_intr
Annotated Snippet
if (dwc2_is_device_mode(hsotg)) {
if (hsotg->params.eusb2_disc) {
/* Clear the Gate hclk. */
pcgctl = dwc2_readl(hsotg, PCGCTL);
pcgctl &= ~PCGCTL_GATEHCLK;
dwc2_writel(hsotg, pcgctl, PCGCTL);
udelay(5);
/* Clear Phy Clock bit. */
pcgctl = dwc2_readl(hsotg, PCGCTL);
pcgctl &= ~PCGCTL_STOPPCLK;
dwc2_writel(hsotg, pcgctl, PCGCTL);
udelay(5);
}
dwc2_hsotg_disconnect(hsotg);
}
if (hsotg->op_state == OTG_STATE_B_HOST) {
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
} else {
/*
* If not B_HOST and Device HNP still set, HNP did
* not succeed!
*/
if (gotgctl & GOTGCTL_DEVHNPEN) {
dev_dbg(hsotg->dev, "Session End Detected\n");
dev_err(hsotg->dev,
"Device Not Connected/Responding!\n");
}
/*
* If Session End Detected the B-Cable has been
* disconnected
*/
/* Reset to a clean state */
hsotg->lx_state = DWC2_L3;
}
gotgctl = dwc2_readl(hsotg, GOTGCTL);
gotgctl &= ~GOTGCTL_DEVHNPEN;
dwc2_writel(hsotg, gotgctl, GOTGCTL);
}
if (gotgint & GOTGINT_SES_REQ_SUC_STS_CHNG) {
dev_dbg(hsotg->dev,
" ++OTG Interrupt: Session Request Success Status Change++\n");
gotgctl = dwc2_readl(hsotg, GOTGCTL);
if (gotgctl & GOTGCTL_SESREQSCS) {
if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS &&
hsotg->params.i2c_enable) {
hsotg->srp_success = 1;
} else {
/* Clear Session Request */
gotgctl = dwc2_readl(hsotg, GOTGCTL);
gotgctl &= ~GOTGCTL_SESREQ;
dwc2_writel(hsotg, gotgctl, GOTGCTL);
}
}
}
if (gotgint & GOTGINT_HST_NEG_SUC_STS_CHNG) {
/*
* Print statements during the HNP interrupt handling
* can cause it to fail
*/
gotgctl = dwc2_readl(hsotg, GOTGCTL);
/*
* WA for 3.00a- HW is not setting cur_mode, even sometimes
* this does not help
*/
if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a)
udelay(100);
if (gotgctl & GOTGCTL_HSTNEGSCS) {
if (dwc2_is_host_mode(hsotg)) {
hsotg->op_state = OTG_STATE_B_HOST;
/*
* Need to disable SOF interrupt immediately.
* When switching from device to host, the PCD
* interrupt handler won't handle the interrupt
* if host mode is already set. The HCD
* interrupt handler won't get called if the
* HCD state is HALT. This means that the
* interrupt does not get handled and Linux
* complains loudly.
*/
gintmsk = dwc2_readl(hsotg, GINTMSK);
gintmsk &= ~GINTSTS_SOF;
dwc2_writel(hsotg, gintmsk, GINTMSK);
/*
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/dma-mapping.h`, `linux/io.h`, `linux/slab.h`.
- Detected declarations: `function Copyright`, `function dwc2_handle_usb_port_intr`, `function dwc2_handle_mode_mismatch_intr`, `function dwc2_handle_otg_intr`, `function dwc2_handle_conn_id_status_change_intr`, `function dwc2_handle_session_req_intr`, `function dwc2_wakeup_from_lpm_l1`, `function dwc2_handle_wakeup_detected_intr`, `function dwc2_handle_disconnect_intr`, `function dwc2_handle_usb_suspend_intr`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.