drivers/pci/controller/pcie-mediatek.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pcie-mediatek.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pcie-mediatek.c- Extension
.c- Size
- 34874 bytes
- Lines
- 1291
- 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/clk.hlinux/delay.hlinux/iopoll.hlinux/irq.hlinux/irqchip/chained_irq.hlinux/irqchip/irq-msi-lib.hlinux/irqdomain.hlinux/kernel.hlinux/mfd/syscon.hlinux/msi.hlinux/module.hlinux/of_address.hlinux/of_pci.hlinux/of_platform.hlinux/pci.hlinux/phy/phy.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/reset.h../pci.h
Detected Declarations
struct mtk_pcie_portstruct mtk_pcie_socstruct mtk_pcie_portstruct mtk_pcieenum mtk_pcie_quirksfunction mtk_pcie_subsys_powerdownfunction mtk_pcie_port_freefunction mtk_pcie_put_resourcesfunction list_for_each_entry_safefunction mtk_pcie_check_cfg_cpldfunction mtk_pcie_hw_rd_cfgfunction mtk_pcie_hw_wr_cfgfunction mtk_pcie_config_readfunction mtk_pcie_config_writefunction mtk_compose_msi_msgfunction mtk_msi_ack_irqfunction mtk_pcie_irq_domain_allocfunction mtk_pcie_irq_domain_freefunction mtk_pcie_allocate_msi_domainsfunction mtk_pcie_enable_msifunction mtk_pcie_irq_teardownfunction list_for_each_entry_safefunction mtk_pcie_intx_mapfunction mtk_pcie_init_irq_domainfunction mtk_pcie_intr_handlerfunction for_each_set_bit_fromfunction mtk_pcie_setup_irqfunction mtk_pcie_startup_port_v2function mtk_pcie_startup_portfunction mtk_pcie_startup_port_an7583function mtk_pcie_enable_portfunction mtk_pcie_parse_portfunction mtk_pcie_subsys_powerupfunction mtk_pcie_setupfunction for_each_available_child_of_node_scopedfunction mtk_pcie_probefunction mtk_pcie_free_resourcesfunction mtk_pcie_removefunction mtk_pcie_suspend_noirqfunction list_for_each_entryfunction mtk_pcie_resume_noirq
Annotated Snippet
struct mtk_pcie_soc {
unsigned int device_id;
struct pci_ops *ops;
int (*startup)(struct mtk_pcie_port *port);
int (*setup_irq)(struct mtk_pcie_port *port, struct device_node *node);
enum mtk_pcie_quirks quirks;
};
/**
* struct mtk_pcie_port - PCIe port information
* @base: IO mapped register base
* @list: port list
* @pcie: pointer to PCIe host info
* @reset: pointer to port reset control
* @sys_ck: pointer to transaction/data link layer clock
* @ahb_ck: pointer to AHB slave interface operating clock for CSR access
* and RC initiated MMIO access
* @axi_ck: pointer to application layer MMIO channel operating clock
* @aux_ck: pointer to pe2_mac_bridge and pe2_mac_core operating clock
* when pcie_mac_ck/pcie_pipe_ck is turned off
* @obff_ck: pointer to OBFF functional block operating clock
* @pipe_ck: pointer to LTSSM and PHY/MAC layer operating clock
* @phy: pointer to PHY control block
* @slot: port slot
* @irq: GIC irq
* @irq_domain: legacy INTx IRQ domain
* @inner_domain: inner IRQ domain
* @lock: protect the msi_irq_in_use bitmap
* @msi_irq_in_use: bit map for assigned MSI IRQ
*/
struct mtk_pcie_port {
void __iomem *base;
struct list_head list;
struct mtk_pcie *pcie;
struct reset_control *reset;
struct clk *sys_ck;
struct clk *ahb_ck;
struct clk *axi_ck;
struct clk *aux_ck;
struct clk *obff_ck;
struct clk *pipe_ck;
struct phy *phy;
u32 slot;
int irq;
struct irq_domain *irq_domain;
struct irq_domain *inner_domain;
struct mutex lock;
DECLARE_BITMAP(msi_irq_in_use, MTK_MSI_IRQS_NUM);
};
/**
* struct mtk_pcie - PCIe host information
* @dev: pointer to PCIe device
* @base: IO mapped register base
* @cfg: IO mapped register map for PCIe config
* @free_ck: free-run reference clock
* @ports: pointer to PCIe port information
* @soc: pointer to SoC-dependent operations
*/
struct mtk_pcie {
struct device *dev;
void __iomem *base;
struct regmap *cfg;
struct clk *free_ck;
struct list_head ports;
const struct mtk_pcie_soc *soc;
};
static void mtk_pcie_subsys_powerdown(struct mtk_pcie *pcie)
{
struct device *dev = pcie->dev;
clk_disable_unprepare(pcie->free_ck);
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
}
static void mtk_pcie_port_free(struct mtk_pcie_port *port)
{
struct mtk_pcie *pcie = port->pcie;
struct device *dev = pcie->dev;
devm_iounmap(dev, port->base);
list_del(&port->list);
devm_kfree(dev, port);
}
static void mtk_pcie_put_resources(struct mtk_pcie *pcie)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/iopoll.h`, `linux/irq.h`, `linux/irqchip/chained_irq.h`, `linux/irqchip/irq-msi-lib.h`, `linux/irqdomain.h`, `linux/kernel.h`.
- Detected declarations: `struct mtk_pcie_port`, `struct mtk_pcie_soc`, `struct mtk_pcie_port`, `struct mtk_pcie`, `enum mtk_pcie_quirks`, `function mtk_pcie_subsys_powerdown`, `function mtk_pcie_port_free`, `function mtk_pcie_put_resources`, `function list_for_each_entry_safe`, `function mtk_pcie_check_cfg_cpld`.
- 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.