drivers/usb/cdns3/drd.c
Source file repositories/reference/linux-study-clean/drivers/usb/cdns3/drd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/cdns3/drd.c- Extension
.c- Size
- 12478 bytes
- Lines
- 513
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/interrupt.hlinux/delay.hlinux/iopoll.hlinux/usb/otg.hdrd.hcore.h
Detected Declarations
function Copyrightfunction cdns_get_idfunction cdns_get_vbusfunction cdns_clear_vbusfunction cdns_set_vbusfunction cdns_is_hostfunction cdns_is_devicefunction cdns_otg_disable_irqfunction cdns_otg_enable_irqfunction cdns_drd_host_onfunction cdns_drd_host_offfunction cdns_drd_gadget_onfunction cdns_drd_gadget_offfunction cdns_init_otg_modefunction cdns_drd_update_modefunction cdns_drd_thread_irqfunction cdns_drd_irqfunction cdns_drd_initfunction cdns_drd_exitfunction cdns_power_is_lostexport cdns_clear_vbusexport cdns_set_vbusexport cdns_drd_gadget_onexport cdns_drd_gadget_offexport cdns_power_is_lost
Annotated Snippet
if (cdns->version == CDNS3_CONTROLLER_V1) {
/*
* Enable work around feature built into the
* controller to address issue with RX Sensitivity
* est (EL_17) for USB2 PHY. The issue only occures
* for 0x0002450D controller version.
*/
if (cdns->phyrst_a_enable) {
reg = readl(&cdns->otg_v1_regs->phyrst_cfg);
reg |= PHYRST_CFG_PHYRST_A_ENABLE;
writel(reg, &cdns->otg_v1_regs->phyrst_cfg);
}
}
/*
* Hardware specification says: "ID_VALUE must be valid within
* 50ms after idpullup is set to '1" so driver must wait
* 50ms before reading this pin.
*/
usleep_range(50000, 60000);
break;
default:
dev_err(cdns->dev, "Unsupported mode of operation %d\n", mode);
return -EINVAL;
}
return 0;
}
int cdns_get_id(struct cdns *cdns)
{
int id;
id = readl(&cdns->otg_regs->sts) & OTGSTS_ID_VALUE;
dev_dbg(cdns->dev, "OTG ID: %d", id);
return id;
}
int cdns_get_vbus(struct cdns *cdns)
{
int vbus;
vbus = !!(readl(&cdns->otg_regs->sts) & OTGSTS_VBUS_VALID);
dev_dbg(cdns->dev, "OTG VBUS: %d", vbus);
return vbus;
}
void cdns_clear_vbus(struct cdns *cdns)
{
u32 reg;
if (cdns->version != CDNSP_CONTROLLER_V2)
return;
reg = readl(&cdns->otg_cdnsp_regs->override);
reg |= OVERRIDE_SESS_VLD_SEL;
writel(reg, &cdns->otg_cdnsp_regs->override);
}
EXPORT_SYMBOL_GPL(cdns_clear_vbus);
void cdns_set_vbus(struct cdns *cdns)
{
u32 reg;
if (cdns->version != CDNSP_CONTROLLER_V2)
return;
reg = readl(&cdns->otg_cdnsp_regs->override);
reg &= ~OVERRIDE_SESS_VLD_SEL;
writel(reg, &cdns->otg_cdnsp_regs->override);
}
EXPORT_SYMBOL_GPL(cdns_set_vbus);
bool cdns_is_host(struct cdns *cdns)
{
if (cdns->dr_mode == USB_DR_MODE_HOST)
return true;
else if (cdns_get_id(cdns) == CDNS3_ID_HOST)
return true;
return false;
}
bool cdns_is_device(struct cdns *cdns)
{
if (cdns->dr_mode == USB_DR_MODE_PERIPHERAL)
return true;
else if (cdns->dr_mode == USB_DR_MODE_OTG)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/iopoll.h`, `linux/usb/otg.h`, `drd.h`, `core.h`.
- Detected declarations: `function Copyright`, `function cdns_get_id`, `function cdns_get_vbus`, `function cdns_clear_vbus`, `function cdns_set_vbus`, `function cdns_is_host`, `function cdns_is_device`, `function cdns_otg_disable_irq`, `function cdns_otg_enable_irq`, `function cdns_drd_host_on`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration 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.