Skip to content

Commit 51f1ffc

Browse files
Bharat Kumar Gogadabjorn-helgaas
authored andcommitted
PCI: xilinx-cpm: Add support for Versal CPM5 Root Port
The Xilinx Versal Premium series has CPM5 block which supports Root Port functioning at Gen5 speed. Xilinx Versal CPM5 has a few changes from the existing CPM block: - CPM5 has dedicated register space for control and status registers. - CPM5 legacy interrupt handling needs additional register bit to enable and handle legacy interrupts. Add support for the new CPM5 features. [bhelgaas: compare variant->version with CPM5 explicitly] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bharat Kumar Gogada <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 49f4070 commit 51f1ffc

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

drivers/pci/controller/pcie-xilinx-cpm.c

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#define XILINX_CPM_PCIE_MISC_IR_ENABLE 0x00000348
3636
#define XILINX_CPM_PCIE_MISC_IR_LOCAL BIT(1)
3737

38+
#define XILINX_CPM_PCIE_IR_STATUS 0x000002A0
39+
#define XILINX_CPM_PCIE_IR_ENABLE 0x000002A8
40+
#define XILINX_CPM_PCIE_IR_LOCAL BIT(0)
41+
3842
/* Interrupt registers definitions */
3943
#define XILINX_CPM_PCIE_INTR_LINK_DOWN 0
4044
#define XILINX_CPM_PCIE_INTR_HOT_RESET 3
@@ -98,6 +102,19 @@
98102
/* Phy Status/Control Register definitions */
99103
#define XILINX_CPM_PCIE_REG_PSCR_LNKUP BIT(11)
100104

105+
enum xilinx_cpm_version {
106+
CPM,
107+
CPM5,
108+
};
109+
110+
/**
111+
* struct xilinx_cpm_variant - CPM variant information
112+
* @version: CPM version
113+
*/
114+
struct xilinx_cpm_variant {
115+
enum xilinx_cpm_version version;
116+
};
117+
101118
/**
102119
* struct xilinx_cpm_pcie - PCIe port information
103120
* @dev: Device pointer
@@ -109,6 +126,7 @@
109126
* @intx_irq: legacy interrupt number
110127
* @irq: Error interrupt number
111128
* @lock: lock protecting shared register access
129+
* @variant: CPM version check pointer
112130
*/
113131
struct xilinx_cpm_pcie {
114132
struct device *dev;
@@ -120,6 +138,7 @@ struct xilinx_cpm_pcie {
120138
int intx_irq;
121139
int irq;
122140
raw_spinlock_t lock;
141+
const struct xilinx_cpm_variant *variant;
123142
};
124143

125144
static u32 pcie_read(struct xilinx_cpm_pcie *port, u32 reg)
@@ -285,6 +304,13 @@ static void xilinx_cpm_pcie_event_flow(struct irq_desc *desc)
285304
generic_handle_domain_irq(port->cpm_domain, i);
286305
pcie_write(port, val, XILINX_CPM_PCIE_REG_IDR);
287306

307+
if (port->variant->version == CPM5) {
308+
val = readl_relaxed(port->cpm_base + XILINX_CPM_PCIE_IR_STATUS);
309+
if (val)
310+
writel_relaxed(val, port->cpm_base +
311+
XILINX_CPM_PCIE_IR_STATUS);
312+
}
313+
288314
/*
289315
* XILINX_CPM_PCIE_MISC_IR_STATUS register is mapped to
290316
* CPM SLCR block.
@@ -484,6 +510,12 @@ static void xilinx_cpm_pcie_init_port(struct xilinx_cpm_pcie *port)
484510
*/
485511
writel(XILINX_CPM_PCIE_MISC_IR_LOCAL,
486512
port->cpm_base + XILINX_CPM_PCIE_MISC_IR_ENABLE);
513+
514+
if (port->variant->version == CPM5) {
515+
writel(XILINX_CPM_PCIE_IR_LOCAL,
516+
port->cpm_base + XILINX_CPM_PCIE_IR_ENABLE);
517+
}
518+
487519
/* Enable the Bridge enable bit */
488520
pcie_write(port, pcie_read(port, XILINX_CPM_PCIE_REG_RPSC) |
489521
XILINX_CPM_PCIE_REG_RPSC_BEN,
@@ -518,7 +550,14 @@ static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,
518550
if (IS_ERR(port->cfg))
519551
return PTR_ERR(port->cfg);
520552

521-
port->reg_base = port->cfg->win;
553+
if (port->variant->version == CPM5) {
554+
port->reg_base = devm_platform_ioremap_resource_byname(pdev,
555+
"cpm_csr");
556+
if (IS_ERR(port->reg_base))
557+
return PTR_ERR(port->reg_base);
558+
} else {
559+
port->reg_base = port->cfg->win;
560+
}
522561

523562
return 0;
524563
}
@@ -559,6 +598,8 @@ static int xilinx_cpm_pcie_probe(struct platform_device *pdev)
559598
if (!bus)
560599
return -ENODEV;
561600

601+
port->variant = of_device_get_match_data(dev);
602+
562603
err = xilinx_cpm_pcie_parse_dt(port, bus->res);
563604
if (err) {
564605
dev_err(dev, "Parsing DT failed\n");
@@ -591,8 +632,23 @@ static int xilinx_cpm_pcie_probe(struct platform_device *pdev)
591632
return err;
592633
}
593634

635+
static const struct xilinx_cpm_variant cpm_host = {
636+
.version = CPM,
637+
};
638+
639+
static const struct xilinx_cpm_variant cpm5_host = {
640+
.version = CPM5,
641+
};
642+
594643
static const struct of_device_id xilinx_cpm_pcie_of_match[] = {
595-
{ .compatible = "xlnx,versal-cpm-host-1.00", },
644+
{
645+
.compatible = "xlnx,versal-cpm-host-1.00",
646+
.data = &cpm_host,
647+
},
648+
{
649+
.compatible = "xlnx,versal-cpm5-host",
650+
.data = &cpm5_host,
651+
},
596652
{}
597653
};
598654

0 commit comments

Comments
 (0)