drivers/usb/dwc3/dwc3-xilinx.c
Source file repositories/reference/linux-study-clean/drivers/usb/dwc3/dwc3-xilinx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/dwc3/dwc3-xilinx.c- Extension
.c- Size
- 11076 bytes
- Lines
- 448
- 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.
- 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/module.hlinux/kernel.hlinux/slab.hlinux/clk.hlinux/of.hlinux/platform_device.hlinux/dma-mapping.hlinux/gpio/consumer.hlinux/of_platform.hlinux/pm_runtime.hlinux/reset.hlinux/of_address.hlinux/delay.hlinux/firmware/xlnx-zynqmp.hlinux/io.hlinux/phy/phy.h
Detected Declarations
struct dwc3_xlnxfunction dwc3_xlnx_mask_phy_rstfunction dwc3_xlnx_set_coherencyfunction dwc3_xlnx_init_versalfunction dwc3_xlnx_init_zynqmpfunction dwc3_set_swnodefunction dwc3_xlnx_probefunction dwc3_xlnx_removefunction dwc3_xlnx_runtime_suspendfunction dwc3_xlnx_runtime_resumefunction dwc3_xlnx_runtime_idlefunction dwc3_xlnx_suspendfunction dwc3_xlnx_resume
Annotated Snippet
struct dwc3_xlnx {
int num_clocks;
struct clk_bulk_data *clks;
struct device *dev;
void __iomem *regs;
int (*pltfm_init)(struct dwc3_xlnx *data);
struct phy *usb3_phy;
};
static void dwc3_xlnx_mask_phy_rst(struct dwc3_xlnx *priv_data, bool mask)
{
u32 reg;
/*
* Enable or disable ULPI PHY reset from USB Controller.
* This does not actually reset the phy, but just controls
* whether USB controller can or cannot reset ULPI PHY.
*/
reg = readl(priv_data->regs + XLNX_USB_PHY_RST_EN);
if (mask)
reg &= ~XLNX_PHY_RST_MASK;
else
reg |= XLNX_PHY_RST_MASK;
writel(reg, priv_data->regs + XLNX_USB_PHY_RST_EN);
}
static void dwc3_xlnx_set_coherency(struct dwc3_xlnx *priv_data, u32 coherency_offset)
{
struct device *dev = priv_data->dev;
u32 reg;
/*
* This routes the USB DMA traffic to go through FPD path instead
* of reaching DDR directly. This traffic routing is needed to
* make SMMU and CCI work with USB DMA.
*/
if (of_dma_is_coherent(dev->of_node) || device_iommu_mapped(dev)) {
reg = readl(priv_data->regs + coherency_offset);
reg |= XLNX_USB_TRAFFIC_ROUTE_FPD;
writel(reg, priv_data->regs + coherency_offset);
}
}
static int dwc3_xlnx_init_versal(struct dwc3_xlnx *priv_data)
{
struct device *dev = priv_data->dev;
struct reset_control *crst;
int ret;
crst = devm_reset_control_get_exclusive(dev, NULL);
if (IS_ERR(crst))
return dev_err_probe(dev, PTR_ERR(crst), "failed to get reset signal\n");
dwc3_xlnx_mask_phy_rst(priv_data, false);
/* Assert and De-assert reset */
ret = reset_control_assert(crst);
if (ret < 0) {
dev_err_probe(dev, ret, "failed to assert Reset\n");
return ret;
}
ret = reset_control_deassert(crst);
if (ret < 0) {
dev_err_probe(dev, ret, "failed to De-assert Reset\n");
return ret;
}
dwc3_xlnx_mask_phy_rst(priv_data, true);
dwc3_xlnx_set_coherency(priv_data, XLNX_USB2_TRAFFIC_ROUTE_CONFIG);
return 0;
}
static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
{
struct device *dev = priv_data->dev;
struct reset_control *crst, *hibrst, *apbrst;
struct gpio_desc *reset_gpio;
int ret = 0;
priv_data->usb3_phy = devm_phy_optional_get(dev, "usb3-phy");
if (IS_ERR(priv_data->usb3_phy)) {
ret = PTR_ERR(priv_data->usb3_phy);
dev_err_probe(dev, ret,
"failed to get USB3 PHY\n");
goto err;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/slab.h`, `linux/clk.h`, `linux/of.h`, `linux/platform_device.h`, `linux/dma-mapping.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct dwc3_xlnx`, `function dwc3_xlnx_mask_phy_rst`, `function dwc3_xlnx_set_coherency`, `function dwc3_xlnx_init_versal`, `function dwc3_xlnx_init_zynqmp`, `function dwc3_set_swnode`, `function dwc3_xlnx_probe`, `function dwc3_xlnx_remove`, `function dwc3_xlnx_runtime_suspend`, `function dwc3_xlnx_runtime_resume`.
- 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.