drivers/pci/controller/pci-xgene.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pci-xgene.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pci-xgene.c- Extension
.c- Size
- 16964 bytes
- Lines
- 666
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/clk.hlinux/delay.hlinux/io.hlinux/jiffies.hlinux/memblock.hlinux/init.hlinux/irqdomain.hlinux/of.hlinux/of_address.hlinux/of_pci.hlinux/pci.hlinux/pci-acpi.hlinux/pci-ecam.hlinux/platform_device.hlinux/slab.h../pci.h
Detected Declarations
struct xgene_pciefunction xgene_pcie_readlfunction xgene_pcie_writelfunction pcie_bar_low_valfunction xgene_pcie_set_rtdid_regfunction xgene_pcie_hide_rc_barsfunction xgene_pcie_config_read32function xgene_get_csr_resourcefunction xgene_pcie_ecam_initfunction xgene_v1_pcie_ecam_initfunction xgene_v2_pcie_ecam_initfunction xgene_pcie_set_ib_maskfunction xgene_pcie_linkupfunction xgene_pcie_init_portfunction xgene_pcie_map_regfunction xgene_pcie_setup_ob_regfunction xgene_pcie_setup_cfg_regfunction xgene_pcie_map_rangesfunction resource_list_for_each_entryfunction xgene_pcie_setup_pimsfunction xgene_pcie_select_ib_regfunction xgene_pcie_setup_ib_regfunction xgene_pcie_parse_map_dma_rangesfunction xgene_pcie_clear_configfunction xgene_pcie_setupfunction xgene_check_pcie_msi_readyfunction xgene_pcie_probe
Annotated Snippet
struct xgene_pcie {
struct device_node *node;
struct device *dev;
struct clk *clk;
void __iomem *csr_base;
void __iomem *cfg_base;
unsigned long cfg_addr;
bool link_up;
u32 version;
};
static u32 xgene_pcie_readl(struct xgene_pcie *port, u32 reg)
{
return readl(port->csr_base + reg);
}
static void xgene_pcie_writel(struct xgene_pcie *port, u32 reg, u32 val)
{
writel(val, port->csr_base + reg);
}
static inline u32 pcie_bar_low_val(u32 addr, u32 flags)
{
return (addr & PCI_BASE_ADDRESS_MEM_MASK) | flags;
}
static inline struct xgene_pcie *pcie_bus_to_port(struct pci_bus *bus)
{
struct pci_config_window *cfg;
if (acpi_disabled)
return (struct xgene_pcie *)(bus->sysdata);
cfg = bus->sysdata;
return (struct xgene_pcie *)(cfg->priv);
}
/*
* When the address bit [17:16] is 2'b01, the Configuration access will be
* treated as Type 1 and it will be forwarded to external PCIe device.
*/
static void __iomem *xgene_pcie_get_cfg_base(struct pci_bus *bus)
{
struct xgene_pcie *port = pcie_bus_to_port(bus);
if (bus->number >= (bus->primary + 1))
return port->cfg_base + AXI_EP_CFG_ACCESS;
return port->cfg_base;
}
/*
* For Configuration request, RTDID register is used as Bus Number,
* Device Number and Function number of the header fields.
*/
static void xgene_pcie_set_rtdid_reg(struct pci_bus *bus, uint devfn)
{
struct xgene_pcie *port = pcie_bus_to_port(bus);
unsigned int b, d, f;
u32 rtdid_val = 0;
b = bus->number;
d = PCI_SLOT(devfn);
f = PCI_FUNC(devfn);
if (!pci_is_root_bus(bus))
rtdid_val = (b << 8) | (d << 3) | f;
xgene_pcie_writel(port, RTDID, rtdid_val);
/* read the register back to ensure flush */
xgene_pcie_readl(port, RTDID);
}
/*
* X-Gene PCIe port uses BAR0-BAR1 of RC's configuration space as
* the translation from PCI bus to native BUS. Entire DDR region
* is mapped into PCIe space using these registers, so it can be
* reached by DMA from EP devices. The BAR0/1 of bridge should be
* hidden during enumeration to avoid the sizing and resource allocation
* by PCIe core.
*/
static bool xgene_pcie_hide_rc_bars(struct pci_bus *bus, int offset)
{
if (pci_is_root_bus(bus) && ((offset == PCI_BASE_ADDRESS_0) ||
(offset == PCI_BASE_ADDRESS_1)))
return true;
return false;
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/io.h`, `linux/jiffies.h`, `linux/memblock.h`, `linux/init.h`, `linux/irqdomain.h`, `linux/of.h`.
- Detected declarations: `struct xgene_pcie`, `function xgene_pcie_readl`, `function xgene_pcie_writel`, `function pcie_bar_low_val`, `function xgene_pcie_set_rtdid_reg`, `function xgene_pcie_hide_rc_bars`, `function xgene_pcie_config_read32`, `function xgene_get_csr_resource`, `function xgene_pcie_ecam_init`, `function xgene_v1_pcie_ecam_init`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source 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.