drivers/pci/controller/dwc/pcie-kirin.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/dwc/pcie-kirin.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/dwc/pcie-kirin.c- Extension
.c- Size
- 18776 bytes
- Lines
- 768
- 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.
- 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/compiler.hlinux/delay.hlinux/err.hlinux/gpio/consumer.hlinux/interrupt.hlinux/mfd/syscon.hlinux/of.hlinux/of_pci.hlinux/phy/phy.hlinux/pci.hlinux/pci_regs.hlinux/platform_device.hlinux/regmap.hlinux/resource.hlinux/types.hpcie-designware.h
Detected Declarations
struct kirin_pciestruct hi3660_pcie_phystruct kirin_pcie_dataenum pcie_kirin_phy_typefunction kirin_apb_phy_writelfunction kirin_apb_phy_readlfunction hi3660_pcie_phy_get_clkfunction hi3660_pcie_phy_get_resourcefunction hi3660_pcie_phy_startfunction hi3660_pcie_phy_oe_enablefunction hi3660_pcie_phy_clk_ctrlfunction hi3660_pcie_phy_power_onfunction hi3660_pcie_phy_initfunction hi3660_pcie_phy_power_offfunction kirin_pcie_get_gpio_enablefunction kirin_pcie_parse_portfunction for_each_available_child_of_node_scopedfunction kirin_pcie_get_resourcefunction kirin_pcie_sideband_dbi_w_modefunction kirin_pcie_sideband_dbi_r_modefunction kirin_pcie_rd_own_conffunction kirin_pcie_wr_own_conffunction kirin_pcie_add_busfunction kirin_pcie_read_dbifunction kirin_pcie_write_dbifunction kirin_pcie_link_upfunction kirin_pcie_start_linkfunction kirin_pcie_host_initfunction kirin_pcie_power_offfunction kirin_pcie_power_onfunction kirin_pcie_removefunction kirin_pcie_probe
Annotated Snippet
struct kirin_pcie {
enum pcie_kirin_phy_type type;
struct dw_pcie *pci;
struct regmap *apb;
struct phy *phy;
void *phy_priv; /* only for PCIE_KIRIN_INTERNAL_PHY */
/* DWC PERST# */
struct gpio_desc *id_dwc_perst_gpio;
/* Per-slot PERST# */
int num_slots;
struct gpio_desc *id_reset_gpio[MAX_PCI_SLOTS];
const char *reset_names[MAX_PCI_SLOTS];
/* Per-slot clkreq */
int n_gpio_clkreq;
struct gpio_desc *id_clkreq_gpio[MAX_PCI_SLOTS];
const char *clkreq_names[MAX_PCI_SLOTS];
};
/*
* Kirin 960 PHY. Can't be split into a PHY driver without changing the
* DT schema.
*/
#define REF_CLK_FREQ 100000000
/* PHY info located in APB */
#define PCIE_APB_PHY_CTRL0 0x0
#define PCIE_APB_PHY_CTRL1 0x4
#define PCIE_APB_PHY_STATUS0 0x400
#define PIPE_CLK_STABLE BIT(19)
#define PHY_REF_PAD_BIT BIT(8)
#define PHY_PWR_DOWN_BIT BIT(22)
#define PHY_RST_ACK_BIT BIT(16)
/* peri_crg ctrl */
#define CRGCTRL_PCIE_ASSERT_OFFSET 0x88
#define CRGCTRL_PCIE_ASSERT_BIT 0x8c000000
/* Time for delay */
#define REF_2_PERST_MIN 21000
#define REF_2_PERST_MAX 25000
#define PERST_2_ACCESS_MIN 10000
#define PERST_2_ACCESS_MAX 12000
#define PIPE_CLK_WAIT_MIN 550
#define PIPE_CLK_WAIT_MAX 600
#define TIME_CMOS_MIN 100
#define TIME_CMOS_MAX 105
#define TIME_PHY_PD_MIN 10
#define TIME_PHY_PD_MAX 11
struct hi3660_pcie_phy {
struct device *dev;
void __iomem *base;
struct regmap *crgctrl;
struct regmap *sysctrl;
struct clk *apb_sys_clk;
struct clk *apb_phy_clk;
struct clk *phy_ref_clk;
struct clk *aclk;
struct clk *aux_clk;
};
/* Registers in PCIePHY */
static inline void kirin_apb_phy_writel(struct hi3660_pcie_phy *hi3660_pcie_phy,
u32 val, u32 reg)
{
writel(val, hi3660_pcie_phy->base + reg);
}
static inline u32 kirin_apb_phy_readl(struct hi3660_pcie_phy *hi3660_pcie_phy,
u32 reg)
{
return readl(hi3660_pcie_phy->base + reg);
}
static int hi3660_pcie_phy_get_clk(struct hi3660_pcie_phy *phy)
{
struct device *dev = phy->dev;
phy->phy_ref_clk = devm_clk_get(dev, "pcie_phy_ref");
if (IS_ERR(phy->phy_ref_clk))
return PTR_ERR(phy->phy_ref_clk);
phy->aux_clk = devm_clk_get(dev, "pcie_aux");
if (IS_ERR(phy->aux_clk))
return PTR_ERR(phy->aux_clk);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/compiler.h`, `linux/delay.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`, `linux/mfd/syscon.h`, `linux/of.h`.
- Detected declarations: `struct kirin_pcie`, `struct hi3660_pcie_phy`, `struct kirin_pcie_data`, `enum pcie_kirin_phy_type`, `function kirin_apb_phy_writel`, `function kirin_apb_phy_readl`, `function hi3660_pcie_phy_get_clk`, `function hi3660_pcie_phy_get_resource`, `function hi3660_pcie_phy_start`, `function hi3660_pcie_phy_oe_enable`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source implementation candidate.
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.