drivers/usb/dwc2/core.c
Source file repositories/reference/linux-study-clean/drivers/usb/dwc2/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/dwc2/core.c- Extension
.c- Size
- 34903 bytes
- Lines
- 1219
- 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.
- 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/delay.hlinux/io.hlinux/slab.hlinux/usb.hlinux/usb/hcd.hlinux/usb/ch11.hcore.hhcd.h
Detected Declarations
function Copyrightfunction dwc2_restore_global_registersfunction dwc2_exit_partial_power_downfunction dwc2_enter_partial_power_downfunction dwc2_restore_essential_regsfunction dwc2_hib_restore_commonfunction dwc2_wait_for_modefunction dwc2_iddig_filter_enabledfunction dwc2_enter_hibernationfunction dwc2_exit_hibernationfunction dwc2_core_resetfunction setfunction dwc2_force_modefunction dwc2_clear_force_modefunction dwc2_force_dr_modefunction dwc2_enable_acgfunction dwc2_dump_host_registersfunction dwc2_dump_global_registersfunction dwc2_flush_tx_fifofunction dwc2_flush_rx_fifofunction dwc2_is_controller_alivefunction dwc2_enable_global_interruptsfunction dwc2_disable_global_interruptsfunction dwc2_op_modefunction dwc2_hw_is_otgfunction dwc2_hw_is_hostfunction dwc2_hw_is_devicefunction dwc2_hsotg_wait_bit_setfunction dwc2_hsotg_wait_bit_clearfunction dwc2_init_fs_ls_pclk_selfunction dwc2_set_clock_switch_timerfunction dwc2_fs_phy_initfunction core_initfunction dwc2_hs_phy_initfunction dwc2_set_turnaround_timefunction dwc2_phy_init
Annotated Snippet
if (dwc2_is_host_mode(hsotg) == host_mode) {
dev_vdbg(hsotg->dev, "%s mode set\n",
host_mode ? "Host" : "Device");
break;
}
end = ktime_get();
ms = ktime_to_ms(ktime_sub(end, start));
if (ms >= (s64)timeout) {
dev_warn(hsotg->dev, "%s: Couldn't set %s mode\n",
__func__, host_mode ? "host" : "device");
break;
}
usleep_range(1000, 2000);
}
}
/**
* dwc2_iddig_filter_enabled() - Returns true if the IDDIG debounce
* filter is enabled.
*
* @hsotg: Programming view of DWC_otg controller
*/
static bool dwc2_iddig_filter_enabled(struct dwc2_hsotg *hsotg)
{
u32 gsnpsid;
u32 ghwcfg4;
if (!dwc2_hw_is_otg(hsotg))
return false;
/* Check if core configuration includes the IDDIG filter. */
ghwcfg4 = dwc2_readl(hsotg, GHWCFG4);
if (!(ghwcfg4 & GHWCFG4_IDDIG_FILT_EN))
return false;
/*
* Check if the IDDIG debounce filter is bypassed. Available
* in core version >= 3.10a.
*/
gsnpsid = dwc2_readl(hsotg, GSNPSID);
if (gsnpsid >= DWC2_CORE_REV_3_10a) {
u32 gotgctl = dwc2_readl(hsotg, GOTGCTL);
if (gotgctl & GOTGCTL_DBNCE_FLTR_BYPASS)
return false;
}
return true;
}
/*
* dwc2_enter_hibernation() - Common function to enter hibernation.
*
* @hsotg: Programming view of the DWC_otg controller
* @is_host: True if core is in host mode.
*
* Return: 0 if successful, negative error code otherwise
*/
int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg, int is_host)
{
if (is_host)
return dwc2_host_enter_hibernation(hsotg);
else
return dwc2_gadget_enter_hibernation(hsotg);
}
/*
* dwc2_exit_hibernation() - Common function to exit from hibernation.
*
* @hsotg: Programming view of the DWC_otg controller
* @rem_wakeup: Remote-wakeup, enabled in case of remote-wakeup.
* @reset: Enabled in case of restore with reset.
* @is_host: True if core is in host mode.
*
* Return: 0 if successful, negative error code otherwise
*/
int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup,
int reset, int is_host)
{
if (is_host)
return dwc2_host_exit_hibernation(hsotg, rem_wakeup, reset);
else
return dwc2_gadget_exit_hibernation(hsotg, rem_wakeup, reset);
}
/*
* Do core a soft reset of the core. Be careful with this because it
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/dma-mapping.h`, `linux/delay.h`, `linux/io.h`.
- Detected declarations: `function Copyright`, `function dwc2_restore_global_registers`, `function dwc2_exit_partial_power_down`, `function dwc2_enter_partial_power_down`, `function dwc2_restore_essential_regs`, `function dwc2_hib_restore_common`, `function dwc2_wait_for_mode`, `function dwc2_iddig_filter_enabled`, `function dwc2_enter_hibernation`, `function dwc2_exit_hibernation`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
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.