drivers/pci/controller/pcie-apple.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pcie-apple.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pcie-apple.c- Extension
.c- Size
- 24051 bytes
- Lines
- 899
- 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.
- 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/bitfield.hlinux/gpio/consumer.hlinux/kernel.hlinux/iopoll.hlinux/irqchip/chained_irq.hlinux/irqchip/irq-msi-lib.hlinux/irqdomain.hlinux/list.hlinux/module.hlinux/msi.hlinux/of_irq.hlinux/pci-ecam.hpci-host-common.h
Detected Declarations
struct hw_infostruct apple_pciestruct apple_pcie_portfunction rmw_setfunction rmw_clearfunction apple_msi_compose_msgfunction apple_msi_domain_allocfunction apple_msi_domain_freefunction apple_port_irq_maskfunction apple_port_irq_unmaskfunction hwirq_is_intxfunction apple_port_irq_ackfunction apple_port_irq_set_typefunction apple_port_irq_domain_allocfunction apple_port_irq_domain_freefunction apple_port_irq_handlerfunction apple_pcie_port_setup_irqfunction apple_pcie_port_irqfunction apple_pcie_port_register_irqsfunction apple_pcie_setup_refclkfunction apple_pcie_rid2sid_writefunction apple_pcie_setup_portfunction apple_msi_initfunction list_for_each_entryfunction apple_pcie_enable_devicefunction apple_pcie_disable_devicefunction for_each_set_bitfunction apple_pcie_initfunction for_each_available_child_of_node_scopedfunction apple_pcie_probe
Annotated Snippet
struct hw_info {
u32 phy_lane_ctl;
u32 port_msiaddr;
u32 port_msiaddr_hi;
u32 port_refclk;
u32 port_perst;
u32 port_rid2sid;
u32 port_msimap;
u32 max_rid2sid;
};
static const struct hw_info t8103_hw = {
.phy_lane_ctl = PHY_LANE_CTL,
.port_msiaddr = PORT_MSIADDR,
.port_msiaddr_hi = 0,
.port_refclk = PORT_REFCLK,
.port_perst = PORT_PERST,
.port_rid2sid = PORT_RID2SID,
.port_msimap = 0,
.max_rid2sid = 64,
};
static const struct hw_info t602x_hw = {
.phy_lane_ctl = 0,
.port_msiaddr = PORT_T602X_MSIADDR,
.port_msiaddr_hi = PORT_T602X_MSIADDR_HI,
.port_refclk = 0,
.port_perst = PORT_T602X_PERST,
.port_rid2sid = PORT_T602X_RID2SID,
.port_msimap = PORT_T602X_MSIMAP,
/* 16 on t602x, guess for autodetect on future HW */
.max_rid2sid = 512,
};
struct apple_pcie {
struct mutex lock;
struct device *dev;
void __iomem *base;
const struct hw_info *hw;
unsigned long *bitmap;
struct list_head ports;
struct completion event;
struct irq_fwspec fwspec;
u32 nvecs;
};
struct apple_pcie_port {
raw_spinlock_t lock;
struct apple_pcie *pcie;
struct device_node *np;
void __iomem *base;
void __iomem *phy;
struct irq_domain *domain;
struct list_head entry;
unsigned long *sid_map;
int sid_map_sz;
int idx;
};
static void rmw_set(u32 set, void __iomem *addr)
{
writel_relaxed(readl_relaxed(addr) | set, addr);
}
static void rmw_clear(u32 clr, void __iomem *addr)
{
writel_relaxed(readl_relaxed(addr) & ~clr, addr);
}
static void apple_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
{
msg->address_hi = upper_32_bits(DOORBELL_ADDR);
msg->address_lo = lower_32_bits(DOORBELL_ADDR);
msg->data = data->hwirq;
}
static struct irq_chip apple_msi_bottom_chip = {
.name = "MSI",
.irq_mask = irq_chip_mask_parent,
.irq_unmask = irq_chip_unmask_parent,
.irq_eoi = irq_chip_eoi_parent,
.irq_set_affinity = irq_chip_set_affinity_parent,
.irq_set_type = irq_chip_set_type_parent,
.irq_compose_msi_msg = apple_msi_compose_msg,
};
static int apple_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs, void *args)
{
struct apple_pcie *pcie = domain->host_data;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/gpio/consumer.h`, `linux/kernel.h`, `linux/iopoll.h`, `linux/irqchip/chained_irq.h`, `linux/irqchip/irq-msi-lib.h`, `linux/irqdomain.h`, `linux/list.h`.
- Detected declarations: `struct hw_info`, `struct apple_pcie`, `struct apple_pcie_port`, `function rmw_set`, `function rmw_clear`, `function apple_msi_compose_msg`, `function apple_msi_domain_alloc`, `function apple_msi_domain_free`, `function apple_port_irq_mask`, `function apple_port_irq_unmask`.
- 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.