drivers/pci/controller/pcie-mediatek-gen3.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pcie-mediatek-gen3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pcie-mediatek-gen3.c- Extension
.c- Size
- 39326 bytes
- Lines
- 1418
- 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/bitfield.hlinux/clk.hlinux/clk-provider.hlinux/delay.hlinux/iopoll.hlinux/irq.hlinux/irqchip/irq-msi-lib.hlinux/irqchip/chained_irq.hlinux/irqdomain.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/msi.hlinux/of_device.hlinux/of_pci.hlinux/pci.hlinux/pci-pwrctrl.hlinux/phy/phy.hlinux/platform_device.hlinux/pm_domain.hlinux/pm_runtime.hlinux/regmap.hlinux/reset.h../pci.h
Detected Declarations
struct mtk_gen3_pciestruct mtk_gen3_pcie_pdatastruct mtk_msi_setstruct mtk_gen3_pcieenum mtk_gen3_pcie_flagsfunction mtk_pcie_config_tlp_headerfunction mtk_pcie_config_readfunction mtk_pcie_config_writefunction mtk_pcie_set_trans_tablefunction mtk_pcie_enable_msifunction mtk_pcie_devices_power_upfunction en7523_reset_assertfunction mtk_pcie_devices_power_downfunction mtk_pcie_startup_portfunction mtk_compose_msi_msgfunction mtk_msi_bottom_irq_ackfunction mtk_msi_bottom_irq_maskfunction mtk_msi_bottom_irq_unmaskfunction mtk_msi_bottom_domain_allocfunction mtk_msi_bottom_domain_freefunction mtk_intx_maskfunction mtk_intx_unmaskfunction mtk_intx_eoifunction mtk_pcie_intx_mapfunction mtk_pcie_init_irq_domainsfunction mtk_pcie_irq_teardownfunction mtk_pcie_msi_handlerfunction for_each_set_bitfunction mtk_pcie_irq_handlerfunction mtk_pcie_setup_irqfunction mtk_pcie_parse_portfunction mtk_pcie_en7581_power_upfunction mtk_pcie_power_upfunction mtk_pcie_power_downfunction mtk_pcie_get_controller_max_link_speedfunction mtk_pcie_setupfunction mtk_pcie_probefunction mtk_pcie_removefunction mtk_pcie_irq_savefunction mtk_pcie_irq_restorefunction mtk_pcie_turn_off_linkfunction mtk_pcie_suspend_noirqfunction mtk_pcie_resume_noirq
Annotated Snippet
struct mtk_gen3_pcie_pdata {
int (*power_up)(struct mtk_gen3_pcie *pcie);
struct {
const char *id[MAX_NUM_PHY_RESETS];
int num_resets;
} phy_resets;
u8 sys_clk_rdy_time_us;
u32 flags;
};
/**
* struct mtk_msi_set - MSI information for each set
* @base: IO mapped register base
* @msg_addr: MSI message address
* @saved_irq_state: IRQ enable state saved at suspend time
*/
struct mtk_msi_set {
void __iomem *base;
phys_addr_t msg_addr;
u32 saved_irq_state;
};
/**
* struct mtk_gen3_pcie - PCIe port information
* @dev: pointer to PCIe device
* @base: IO mapped register base
* @reg_base: physical register base
* @mac_reset: MAC reset control
* @phy_resets: PHY reset controllers
* @phy: PHY controller block
* @clks: PCIe clocks
* @num_clks: PCIe clocks count for this port
* @max_link_speed: Maximum link speed (PCIe Gen) for this port
* @num_lanes: Number of PCIe lanes for this port
* @irq: PCIe controller interrupt number
* @saved_irq_state: IRQ enable state saved at suspend time
* @irq_lock: lock protecting IRQ register access
* @intx_domain: legacy INTx IRQ domain
* @msi_bottom_domain: MSI IRQ bottom domain
* @msi_sets: MSI sets information
* @lock: lock protecting IRQ bit map
* @msi_irq_in_use: bit map for assigned MSI IRQ
* @soc: pointer to SoC-dependent operations
*/
struct mtk_gen3_pcie {
struct device *dev;
void __iomem *base;
phys_addr_t reg_base;
struct reset_control *mac_reset;
struct reset_control_bulk_data phy_resets[MAX_NUM_PHY_RESETS];
struct phy *phy;
struct clk_bulk_data *clks;
int num_clks;
u8 max_link_speed;
u8 num_lanes;
int irq;
u32 saved_irq_state;
raw_spinlock_t irq_lock;
struct irq_domain *intx_domain;
struct irq_domain *msi_bottom_domain;
struct mtk_msi_set msi_sets[PCIE_MSI_SET_NUM];
struct mutex lock;
DECLARE_BITMAP(msi_irq_in_use, PCIE_MSI_IRQS_NUM);
const struct mtk_gen3_pcie_pdata *soc;
};
/* LTSSM state in PCIE_LTSSM_STATUS_REG bit[28:24] */
static const char *const ltssm_str[] = {
"detect.quiet", /* 0x00 */
"detect.active", /* 0x01 */
"polling.active", /* 0x02 */
"polling.compliance", /* 0x03 */
"polling.configuration", /* 0x04 */
"config.linkwidthstart", /* 0x05 */
"config.linkwidthaccept", /* 0x06 */
"config.lanenumwait", /* 0x07 */
"config.lanenumaccept", /* 0x08 */
"config.complete", /* 0x09 */
"config.idle", /* 0x0A */
"recovery.receiverlock", /* 0x0B */
"recovery.equalization", /* 0x0C */
"recovery.speed", /* 0x0D */
"recovery.receiverconfig", /* 0x0E */
"recovery.idle", /* 0x0F */
"L0", /* 0x10 */
"L0s", /* 0x11 */
"L1.entry", /* 0x12 */
"L1.idle", /* 0x13 */
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/iopoll.h`, `linux/irq.h`, `linux/irqchip/irq-msi-lib.h`, `linux/irqchip/chained_irq.h`.
- Detected declarations: `struct mtk_gen3_pcie`, `struct mtk_gen3_pcie_pdata`, `struct mtk_msi_set`, `struct mtk_gen3_pcie`, `enum mtk_gen3_pcie_flags`, `function mtk_pcie_config_tlp_header`, `function mtk_pcie_config_read`, `function mtk_pcie_config_write`, `function mtk_pcie_set_trans_table`, `function mtk_pcie_enable_msi`.
- 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.