drivers/pci/controller/pcie-xilinx-nwl.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pcie-xilinx-nwl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pcie-xilinx-nwl.c- Extension
.c- Size
- 24469 bytes
- Lines
- 920
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/clk.hlinux/delay.hlinux/interrupt.hlinux/irq.hlinux/irqchip/irq-msi-lib.hlinux/irqdomain.hlinux/kernel.hlinux/init.hlinux/msi.hlinux/of_address.hlinux/of_pci.hlinux/of_platform.hlinux/pci.hlinux/pci-ecam.hlinux/phy/phy.hlinux/platform_device.hlinux/irqchip/chained_irq.h../pci.h
Detected Declarations
struct nwl_msistruct nwl_pciefunction nwl_bridge_readlfunction nwl_bridge_writelfunction nwl_pcie_link_upfunction nwl_phy_link_upfunction nwl_wait_for_linkfunction nwl_pcie_valid_devicefunction nwl_pcie_misc_handlerfunction nwl_pcie_leg_handlerfunction nwl_pcie_handle_msi_irqfunction nwl_pcie_msi_handler_highfunction nwl_pcie_msi_handler_lowfunction nwl_mask_intx_irqfunction nwl_unmask_intx_irqfunction nwl_intx_mapfunction nwl_compose_msi_msgfunction nwl_irq_domain_allocfunction nwl_irq_domain_freefunction nwl_pcie_init_msi_irq_domainfunction nwl_pcie_phy_power_offfunction nwl_pcie_phy_exitfunction nwl_pcie_phy_enablefunction nwl_pcie_phy_disablefunction nwl_pcie_init_irq_domainfunction nwl_pcie_enable_msifunction nwl_pcie_bridge_initfunction nwl_pcie_parse_dtfunction nwl_pcie_probefunction nwl_pcie_remove
Annotated Snippet
struct nwl_msi { /* MSI information */
DECLARE_BITMAP(bitmap, INT_PCI_MSI_NR);
struct irq_domain *dev_domain;
struct mutex lock; /* protect bitmap variable */
int irq_msi0;
int irq_msi1;
};
struct nwl_pcie {
struct device *dev;
void __iomem *breg_base;
void __iomem *pcireg_base;
void __iomem *ecam_base;
struct phy *phy[4];
phys_addr_t phys_breg_base; /* Physical Bridge Register Base */
phys_addr_t phys_pcie_reg_base; /* Physical PCIe Controller Base */
phys_addr_t phys_ecam_base; /* Physical Configuration Base */
u32 breg_size;
u32 pcie_reg_size;
u32 ecam_size;
int irq_intx;
int irq_misc;
struct nwl_msi msi;
struct irq_domain *intx_irq_domain;
struct clk *clk;
raw_spinlock_t leg_mask_lock;
};
static inline u32 nwl_bridge_readl(struct nwl_pcie *pcie, u32 off)
{
return readl(pcie->breg_base + off);
}
static inline void nwl_bridge_writel(struct nwl_pcie *pcie, u32 val, u32 off)
{
writel(val, pcie->breg_base + off);
}
static bool nwl_pcie_link_up(struct nwl_pcie *pcie)
{
if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PCIE_PHY_LINKUP_BIT)
return true;
return false;
}
static bool nwl_phy_link_up(struct nwl_pcie *pcie)
{
if (readl(pcie->pcireg_base + PS_LINKUP_OFFSET) & PHY_RDY_LINKUP_BIT)
return true;
return false;
}
static int nwl_wait_for_link(struct nwl_pcie *pcie)
{
struct device *dev = pcie->dev;
int retries;
/* check if the link is up or not */
for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) {
if (nwl_phy_link_up(pcie))
return 0;
usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX);
}
dev_err(dev, "PHY link never came up\n");
return -ETIMEDOUT;
}
static bool nwl_pcie_valid_device(struct pci_bus *bus, unsigned int devfn)
{
struct nwl_pcie *pcie = bus->sysdata;
/* Check link before accessing downstream ports */
if (!pci_is_root_bus(bus)) {
if (!nwl_pcie_link_up(pcie))
return false;
} else if (devfn > 0)
/* Only one device down on each root port */
return false;
return true;
}
/**
* nwl_pcie_map_bus - Get configuration base
*
* @bus: Bus structure of current bus
* @devfn: Device/function
* @where: Offset from base
*
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/irqchip/irq-msi-lib.h`, `linux/irqdomain.h`, `linux/kernel.h`, `linux/init.h`.
- Detected declarations: `struct nwl_msi`, `struct nwl_pcie`, `function nwl_bridge_readl`, `function nwl_bridge_writel`, `function nwl_pcie_link_up`, `function nwl_phy_link_up`, `function nwl_wait_for_link`, `function nwl_pcie_valid_device`, `function nwl_pcie_misc_handler`, `function nwl_pcie_leg_handler`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.