Skip to content

Commit 6ac7217

Browse files
Thippeswamyhkwilczynski
authored andcommitted
PCI: xilinx-xdma: Add Xilinx QDMA Root Port driver
Add support for Xilinx QDMA Soft IP core as Root Port. The Versal Prime devices support QDMA soft IP module in programmable logic. The integrated QDMA Soft IP block has integrated bridge function that can act as PCIe Root Port. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Thippeswamy Havalige <[email protected]> [kwilczynski: removed unused header] Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 899d548 commit 6ac7217

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

drivers/pci/controller/pcie-xilinx-dma-pl.c

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,24 @@
7171

7272
/* Phy Status/Control Register definitions */
7373
#define XILINX_PCIE_DMA_REG_PSCR_LNKUP BIT(11)
74+
#define QDMA_BRIDGE_BASE_OFF 0xcd8
7475

7576
/* Number of MSI IRQs */
7677
#define XILINX_NUM_MSI_IRQS 64
7778

79+
enum xilinx_pl_dma_version {
80+
XDMA,
81+
QDMA,
82+
};
83+
84+
/**
85+
* struct xilinx_pl_dma_variant - PL DMA PCIe variant information
86+
* @version: DMA version
87+
*/
88+
struct xilinx_pl_dma_variant {
89+
enum xilinx_pl_dma_version version;
90+
};
91+
7892
struct xilinx_msi {
7993
struct irq_domain *msi_domain;
8094
unsigned long *bitmap;
@@ -88,6 +102,7 @@ struct xilinx_msi {
88102
* struct pl_dma_pcie - PCIe port information
89103
* @dev: Device pointer
90104
* @reg_base: IO Mapped Register Base
105+
* @cfg_base: IO Mapped Configuration Base
91106
* @irq: Interrupt number
92107
* @cfg: Holds mappings of config space window
93108
* @phys_reg_base: Physical address of reg base
@@ -97,10 +112,12 @@ struct xilinx_msi {
97112
* @msi: MSI information
98113
* @intx_irq: INTx error interrupt number
99114
* @lock: Lock protecting shared register access
115+
* @variant: PL DMA PCIe version check pointer
100116
*/
101117
struct pl_dma_pcie {
102118
struct device *dev;
103119
void __iomem *reg_base;
120+
void __iomem *cfg_base;
104121
int irq;
105122
struct pci_config_window *cfg;
106123
phys_addr_t phys_reg_base;
@@ -110,16 +127,23 @@ struct pl_dma_pcie {
110127
struct xilinx_msi msi;
111128
int intx_irq;
112129
raw_spinlock_t lock;
130+
const struct xilinx_pl_dma_variant *variant;
113131
};
114132

115133
static inline u32 pcie_read(struct pl_dma_pcie *port, u32 reg)
116134
{
135+
if (port->variant->version == QDMA)
136+
return readl(port->reg_base + reg + QDMA_BRIDGE_BASE_OFF);
137+
117138
return readl(port->reg_base + reg);
118139
}
119140

120141
static inline void pcie_write(struct pl_dma_pcie *port, u32 val, u32 reg)
121142
{
122-
writel(val, port->reg_base + reg);
143+
if (port->variant->version == QDMA)
144+
writel(val, port->reg_base + reg + QDMA_BRIDGE_BASE_OFF);
145+
else
146+
writel(val, port->reg_base + reg);
123147
}
124148

125149
static inline bool xilinx_pl_dma_pcie_link_up(struct pl_dma_pcie *port)
@@ -173,6 +197,9 @@ static void __iomem *xilinx_pl_dma_pcie_map_bus(struct pci_bus *bus,
173197
if (!xilinx_pl_dma_pcie_valid_device(bus, devfn))
174198
return NULL;
175199

200+
if (port->variant->version == QDMA)
201+
return port->cfg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
202+
176203
return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
177204
}
178205

@@ -731,6 +758,15 @@ static int xilinx_pl_dma_pcie_parse_dt(struct pl_dma_pcie *port,
731758

732759
port->reg_base = port->cfg->win;
733760

761+
if (port->variant->version == QDMA) {
762+
port->cfg_base = port->cfg->win;
763+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "breg");
764+
port->reg_base = devm_ioremap_resource(dev, res);
765+
if (IS_ERR(port->reg_base))
766+
return PTR_ERR(port->reg_base);
767+
port->phys_reg_base = res->start;
768+
}
769+
734770
err = xilinx_request_msi_irq(port);
735771
if (err) {
736772
pci_ecam_free(port->cfg);
@@ -760,6 +796,8 @@ static int xilinx_pl_dma_pcie_probe(struct platform_device *pdev)
760796
if (!bus)
761797
return -ENODEV;
762798

799+
port->variant = of_device_get_match_data(dev);
800+
763801
err = xilinx_pl_dma_pcie_parse_dt(port, bus->res);
764802
if (err) {
765803
dev_err(dev, "Parsing DT failed\n");
@@ -791,9 +829,22 @@ static int xilinx_pl_dma_pcie_probe(struct platform_device *pdev)
791829
return err;
792830
}
793831

832+
static const struct xilinx_pl_dma_variant xdma_host = {
833+
.version = XDMA,
834+
};
835+
836+
static const struct xilinx_pl_dma_variant qdma_host = {
837+
.version = QDMA,
838+
};
839+
794840
static const struct of_device_id xilinx_pl_dma_pcie_of_match[] = {
795841
{
796842
.compatible = "xlnx,xdma-host-3.00",
843+
.data = &xdma_host,
844+
},
845+
{
846+
.compatible = "xlnx,qdma-host-3.00",
847+
.data = &qdma_host,
797848
},
798849
{}
799850
};

0 commit comments

Comments
 (0)