drivers/pci/controller/pcie-rockchip-host.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pcie-rockchip-host.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pcie-rockchip-host.c- Extension
.c- Size
- 28482 bytes
- Lines
- 1056
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bitrev.hlinux/gpio/consumer.hlinux/interrupt.hlinux/iopoll.hlinux/irq.hlinux/irqchip/chained_irq.hlinux/irqdomain.hlinux/module.hlinux/of.hlinux/of_pci.hlinux/phy/phy.hlinux/platform_device.h../pci.hpcie-rockchip.h
Detected Declarations
function Copyrightfunction rockchip_pcie_clr_bw_intfunction rockchip_pcie_update_txcredit_muifunction rockchip_pcie_valid_devicefunction rockchip_pcie_lane_mapfunction rockchip_pcie_rd_own_conffunction rockchip_pcie_wr_own_conffunction rockchip_pcie_rd_other_conffunction rockchip_pcie_wr_other_conffunction rockchip_pcie_rd_conffunction rockchip_pcie_wr_conffunction rockchip_pcie_set_power_limitfunction rockchip_pcie_host_init_portfunction rockchip_pcie_subsys_irq_handlerfunction rockchip_pcie_client_irq_handlerfunction rockchip_pcie_intx_handlerfunction rockchip_pcie_setup_irqfunction rockchip_pcie_parse_host_dtfunction rockchip_pcie_set_vpciefunction rockchip_pcie_enable_interruptsfunction rockchip_pcie_intx_mapfunction rockchip_pcie_init_irq_domainfunction rockchip_pcie_prog_ob_atufunction rockchip_pcie_prog_ib_atufunction rockchip_pcie_cfg_atufunction rockchip_pcie_wait_l2function rockchip_pcie_suspend_noirqfunction rockchip_pcie_resume_noirqfunction rockchip_pcie_probefunction rockchip_pcie_remove
Annotated Snippet
if (!scale) {
dev_warn(rockchip->dev, "invalid power supply\n");
return;
}
scale--;
power = power / 10;
}
status = rockchip_pcie_read(rockchip, PCIE_RC_CONFIG_CR + PCI_EXP_DEVCAP);
status |= FIELD_PREP(PCI_EXP_DEVCAP_PWR_VAL, power);
status |= FIELD_PREP(PCI_EXP_DEVCAP_PWR_SCL, scale);
rockchip_pcie_write(rockchip, status, PCIE_RC_CONFIG_CR + PCI_EXP_DEVCAP);
}
/**
* rockchip_pcie_host_init_port - Initialize hardware
* @rockchip: PCIe port information
*/
static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
{
struct device *dev = rockchip->dev;
int err, i = MAX_LANE_NUM;
u32 status;
gpiod_set_value_cansleep(rockchip->perst_gpio, 0);
err = rockchip_pcie_init_port(rockchip);
if (err)
return err;
/* Fix the transmitted FTS count desired to exit from L0s. */
status = rockchip_pcie_read(rockchip, PCIE_CORE_CTRL_PLC1);
status = (status & ~PCIE_CORE_CTRL_PLC1_FTS_MASK) |
(PCIE_CORE_CTRL_PLC1_FTS_CNT << PCIE_CORE_CTRL_PLC1_FTS_SHIFT);
rockchip_pcie_write(rockchip, status, PCIE_CORE_CTRL_PLC1);
rockchip_pcie_set_power_limit(rockchip);
/* Set RC's clock architecture as common clock */
status = rockchip_pcie_read(rockchip, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL);
status |= PCI_EXP_LNKSTA_SLC << 16;
rockchip_pcie_write(rockchip, status, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL);
/* Set RC's RCB to 128 */
status = rockchip_pcie_read(rockchip, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL);
status |= PCI_EXP_LNKCTL_RCB;
rockchip_pcie_write(rockchip, status, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL);
/* Enable Gen1 training */
rockchip_pcie_write(rockchip, PCIE_CLIENT_LINK_TRAIN_ENABLE,
PCIE_CLIENT_CONFIG);
msleep(PCIE_T_PVPERL_MS);
gpiod_set_value_cansleep(rockchip->perst_gpio, 1);
msleep(PCIE_RESET_CONFIG_WAIT_MS);
/* 500ms timeout value should be enough for Gen1/2 training */
err = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_BASIC_STATUS1,
status, PCIE_LINK_UP(status), 20,
500 * USEC_PER_MSEC);
if (err) {
dev_err(dev, "PCIe link training gen1 timeout!\n");
goto err_power_off_phy;
}
if (rockchip->link_gen == 2) {
/*
* Enable retrain for gen2. This should be configured only after
* gen1 finished.
*/
status = rockchip_pcie_read(rockchip, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL2);
status &= ~PCI_EXP_LNKCTL2_TLS;
status |= PCI_EXP_LNKCTL2_TLS_5_0GT;
rockchip_pcie_write(rockchip, status, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL2);
status = rockchip_pcie_read(rockchip, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL);
status |= PCI_EXP_LNKCTL_RL;
rockchip_pcie_write(rockchip, status, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL);
err = readl_poll_timeout(rockchip->apb_base + PCIE_CORE_CTRL,
status, PCIE_LINK_IS_GEN2(status), 20,
500 * USEC_PER_MSEC);
if (err)
dev_dbg(dev, "PCIe link training gen2 timeout, fall back to gen1!\n");
}
/* Check the final link width from negotiated lane counter from MGMT */
status = rockchip_pcie_read(rockchip, PCIE_CORE_CTRL);
status = 0x1 << ((status & PCIE_CORE_PL_CONF_LANE_MASK) >>
PCIE_CORE_PL_CONF_LANE_SHIFT);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitrev.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/irq.h`, `linux/irqchip/chained_irq.h`, `linux/irqdomain.h`.
- Detected declarations: `function Copyright`, `function rockchip_pcie_clr_bw_int`, `function rockchip_pcie_update_txcredit_mui`, `function rockchip_pcie_valid_device`, `function rockchip_pcie_lane_map`, `function rockchip_pcie_rd_own_conf`, `function rockchip_pcie_wr_own_conf`, `function rockchip_pcie_rd_other_conf`, `function rockchip_pcie_wr_other_conf`, `function rockchip_pcie_rd_conf`.
- 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.