drivers/pci/controller/dwc/pcie-keembay.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/dwc/pcie-keembay.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/dwc/pcie-keembay.c- Extension
.c- Size
- 11977 bytes
- Lines
- 482
- 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/bitfield.hlinux/bits.hlinux/clk.hlinux/delay.hlinux/err.hlinux/gpio/consumer.hlinux/init.hlinux/iopoll.hlinux/irqchip/chained_irq.hlinux/kernel.hlinux/mod_devicetable.hlinux/pci.hlinux/platform_device.hlinux/property.hpcie-designware.h
Detected Declarations
struct keembay_pciestruct keembay_pcie_of_datafunction keembay_ep_reset_assertfunction keembay_ep_reset_deassertfunction keembay_pcie_ltssm_setfunction keembay_pcie_link_upfunction keembay_pcie_start_linkfunction keembay_pcie_stop_linkfunction keembay_pcie_disable_clockfunction keembay_pcie_probe_clocksfunction keembay_pcie_pll_initfunction keembay_pcie_msi_irq_handlerfunction keembay_pcie_setup_msi_irqfunction keembay_pcie_ep_initfunction keembay_pcie_ep_raise_irqfunction keembay_pcie_get_featuresfunction keembay_pcie_add_pcie_portfunction keembay_pcie_probe
Annotated Snippet
struct keembay_pcie {
struct dw_pcie pci;
void __iomem *apb_base;
enum dw_pcie_device_mode mode;
struct clk *clk_master;
struct clk *clk_aux;
struct gpio_desc *reset;
};
struct keembay_pcie_of_data {
enum dw_pcie_device_mode mode;
};
static void keembay_ep_reset_assert(struct keembay_pcie *pcie)
{
gpiod_set_value_cansleep(pcie->reset, 1);
usleep_range(PERST_DELAY_US, PERST_DELAY_US + 500);
}
static void keembay_ep_reset_deassert(struct keembay_pcie *pcie)
{
/*
* Ensure that PERST# is asserted for a minimum of 100ms.
*
* For more details, refer to PCI Express Card Electromechanical
* Specification Revision 1.1, Table-2.4.
*/
msleep(100);
gpiod_set_value_cansleep(pcie->reset, 0);
usleep_range(PERST_DELAY_US, PERST_DELAY_US + 500);
}
static void keembay_pcie_ltssm_set(struct keembay_pcie *pcie, bool enable)
{
u32 val;
val = readl(pcie->apb_base + PCIE_REGS_PCIE_APP_CNTRL);
if (enable)
val |= APP_LTSSM_ENABLE;
else
val &= ~APP_LTSSM_ENABLE;
writel(val, pcie->apb_base + PCIE_REGS_PCIE_APP_CNTRL);
}
static bool keembay_pcie_link_up(struct dw_pcie *pci)
{
struct keembay_pcie *pcie = dev_get_drvdata(pci->dev);
u32 val;
val = readl(pcie->apb_base + PCIE_REGS_PCIE_SII_PM_STATE);
return (val & PCIE_REGS_PCIE_SII_LINK_UP) == PCIE_REGS_PCIE_SII_LINK_UP;
}
static int keembay_pcie_start_link(struct dw_pcie *pci)
{
struct keembay_pcie *pcie = dev_get_drvdata(pci->dev);
u32 val;
int ret;
if (pcie->mode == DW_PCIE_EP_TYPE)
return 0;
keembay_pcie_ltssm_set(pcie, false);
ret = readl_poll_timeout(pcie->apb_base + PCIE_REGS_PCIE_PHY_STAT,
val, val & PHY0_MPLLA_STATE, 20,
500 * USEC_PER_MSEC);
if (ret) {
dev_err(pci->dev, "MPLLA is not locked\n");
return ret;
}
keembay_pcie_ltssm_set(pcie, true);
return 0;
}
static void keembay_pcie_stop_link(struct dw_pcie *pci)
{
struct keembay_pcie *pcie = dev_get_drvdata(pci->dev);
keembay_pcie_ltssm_set(pcie, false);
}
static const struct dw_pcie_ops keembay_pcie_ops = {
.link_up = keembay_pcie_link_up,
.start_link = keembay_pcie_start_link,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/clk.h`, `linux/delay.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/init.h`, `linux/iopoll.h`.
- Detected declarations: `struct keembay_pcie`, `struct keembay_pcie_of_data`, `function keembay_ep_reset_assert`, `function keembay_ep_reset_deassert`, `function keembay_pcie_ltssm_set`, `function keembay_pcie_link_up`, `function keembay_pcie_start_link`, `function keembay_pcie_stop_link`, `function keembay_pcie_disable_clock`, `function keembay_pcie_probe_clocks`.
- 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.