drivers/pci/controller/dwc/pcie-designware.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/dwc/pcie-designware.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/dwc/pcie-designware.c- Extension
.c- Size
- 37617 bytes
- Lines
- 1349
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/align.hlinux/bitops.hlinux/clk.hlinux/delay.hlinux/dma/edma.hlinux/gpio/consumer.hlinux/ioport.hlinux/of.hlinux/of_address.hlinux/pcie-dwc.hlinux/platform_device.hlinux/sizes.hlinux/types.h../../pci.hpcie-designware.h
Detected Declarations
function dw_pcie_get_clocksfunction dw_pcie_get_resetsfunction dw_pcie_get_resourcesfunction dw_pcie_version_detectfunction dw_pcie_find_capabilityfunction dw_pcie_find_ext_capabilityfunction dw_pcie_remove_capabilityfunction dw_pcie_remove_ext_capabilityfunction __dw_pcie_find_vsec_capabilityfunction dw_pcie_find_vsec_capabilityfunction dw_pcie_find_rasdes_capabilityfunction dw_pcie_find_ptm_capabilityfunction dw_pcie_readfunction dw_pcie_writefunction dw_pcie_read_dbifunction dw_pcie_write_dbifunction dw_pcie_write_dbi2function dw_pcie_readl_atufunction dw_pcie_writel_atufunction dw_pcie_readl_atu_obfunction dw_pcie_writel_atu_obfunction dw_pcie_enable_ecrcfunction dw_pcie_prog_outbound_atufunction dw_pcie_readl_atu_ibfunction dw_pcie_writel_atu_ibfunction dw_pcie_prog_inbound_atufunction dw_pcie_prog_ep_inbound_atufunction dw_pcie_disable_atufunction dw_pcie_wait_for_linkfunction dw_pcie_link_upfunction dw_pcie_upconfig_setupfunction dw_pcie_link_set_max_speedfunction dw_pcie_link_get_max_link_widthfunction dw_pcie_link_set_max_link_widthfunction dw_pcie_iatu_detectfunction dw_pcie_readl_dmafunction dw_pcie_edma_irq_vectorfunction dw_pcie_edma_init_datafunction dw_pcie_edma_find_mffunction dw_pcie_edma_find_channelsfunction dw_pcie_edma_find_chipfunction dw_pcie_edma_irq_verifyfunction dw_pcie_edma_ll_allocfunction dw_pcie_edma_detectfunction dw_pcie_edma_removefunction dw_pcie_hide_unsupported_l1ssfunction dw_pcie_setupfunction dw_pcie_parent_bus_offset
Annotated Snippet
if (res) {
pci->dbi_base2 = devm_pci_remap_cfg_resource(pci->dev, res);
if (IS_ERR(pci->dbi_base2))
return PTR_ERR(pci->dbi_base2);
} else {
pci->dbi_base2 = pci->dbi_base + SZ_4K;
}
}
/* For non-unrolled iATU/eDMA platforms this range will be ignored */
if (!pci->atu_base) {
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "atu");
if (res) {
pci->atu_size = resource_size(res);
pci->atu_base = devm_ioremap_resource(pci->dev, res);
if (IS_ERR(pci->atu_base))
return PTR_ERR(pci->atu_base);
pci->atu_phys_addr = res->start;
} else {
pci->atu_base = pci->dbi_base + DEFAULT_DBI_ATU_OFFSET;
}
}
/* Set a default value suitable for at most 8 in and 8 out windows */
if (!pci->atu_size)
pci->atu_size = SZ_4K;
/* eDMA region can be mapped to a custom base address */
if (!pci->edma.reg_base) {
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma");
if (res) {
pci->edma.reg_base = devm_ioremap_resource(pci->dev, res);
if (IS_ERR(pci->edma.reg_base))
return PTR_ERR(pci->edma.reg_base);
} else if (pci->atu_size >= 2 * DEFAULT_DBI_DMA_OFFSET) {
pci->edma.reg_base = pci->atu_base + DEFAULT_DBI_DMA_OFFSET;
}
}
/* ELBI is an optional resource */
if (!pci->elbi_base) {
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
if (res) {
pci->elbi_base = devm_ioremap_resource(pci->dev, res);
if (IS_ERR(pci->elbi_base))
return PTR_ERR(pci->elbi_base);
}
}
/* LLDD is supposed to manually switch the clocks and resets state */
if (dw_pcie_cap_is(pci, REQ_RES)) {
ret = dw_pcie_get_clocks(pci);
if (ret)
return ret;
ret = dw_pcie_get_resets(pci);
if (ret)
return ret;
}
if (pci->max_link_speed < 1)
pci->max_link_speed = of_pci_get_max_link_speed(np);
of_property_read_u32(np, "num-lanes", &pci->num_lanes);
if (of_property_read_bool(np, "snps,enable-cdm-check"))
dw_pcie_cap_set(pci, CDM_CHECK);
return 0;
}
void dw_pcie_version_detect(struct dw_pcie *pci)
{
u32 ver;
/* The content of the CSR is zero on DWC PCIe older than v4.70a */
ver = dw_pcie_readl_dbi(pci, PCIE_VERSION_NUMBER);
if (!ver)
return;
if (pci->version && pci->version != ver)
dev_warn(pci->dev, "Versions don't match (%08x != %08x)\n",
pci->version, ver);
else
pci->version = ver;
ver = dw_pcie_readl_dbi(pci, PCIE_VERSION_TYPE);
if (pci->type && pci->type != ver)
dev_warn(pci->dev, "Types don't match (%08x != %08x)\n",
Annotation
- Immediate include surface: `linux/align.h`, `linux/bitops.h`, `linux/clk.h`, `linux/delay.h`, `linux/dma/edma.h`, `linux/gpio/consumer.h`, `linux/ioport.h`, `linux/of.h`.
- Detected declarations: `function dw_pcie_get_clocks`, `function dw_pcie_get_resets`, `function dw_pcie_get_resources`, `function dw_pcie_version_detect`, `function dw_pcie_find_capability`, `function dw_pcie_find_ext_capability`, `function dw_pcie_remove_capability`, `function dw_pcie_remove_ext_capability`, `function __dw_pcie_find_vsec_capability`, `function dw_pcie_find_vsec_capability`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration 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.