xref: /linux/drivers/pci/controller/pcie-xilinx.c (revision ca220141fa8ebae09765a242076b2b77338106b0)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * PCIe host controller driver for Xilinx AXI PCIe Bridge
4  *
5  * Copyright (c) 2012 - 2014 Xilinx, Inc.
6  *
7  * Based on the Tegra PCIe driver
8  *
9  * Bits taken from Synopsys DesignWare Host controller driver and
10  * ARM PCI Host generic driver.
11  */
12 
13 #include <linux/interrupt.h>
14 #include <linux/irq.h>
15 #include <linux/irqchip/irq-msi-lib.h>
16 #include <linux/irqdomain.h>
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/msi.h>
20 #include <linux/of_address.h>
21 #include <linux/of_pci.h>
22 #include <linux/of_platform.h>
23 #include <linux/of_irq.h>
24 #include <linux/pci.h>
25 #include <linux/pci-ecam.h>
26 #include <linux/platform_device.h>
27 
28 #include "../pci.h"
29 
30 /* Register definitions */
31 #define XILINX_PCIE_REG_BIR		0x00000130
32 #define XILINX_PCIE_REG_IDR		0x00000138
33 #define XILINX_PCIE_REG_IMR		0x0000013c
34 #define XILINX_PCIE_REG_PSCR		0x00000144
35 #define XILINX_PCIE_REG_RPSC		0x00000148
36 #define XILINX_PCIE_REG_MSIBASE1	0x0000014c
37 #define XILINX_PCIE_REG_MSIBASE2	0x00000150
38 #define XILINX_PCIE_REG_RPEFR		0x00000154
39 #define XILINX_PCIE_REG_RPIFR1		0x00000158
40 #define XILINX_PCIE_REG_RPIFR2		0x0000015c
41 
42 /* Interrupt registers definitions */
43 #define XILINX_PCIE_INTR_LINK_DOWN	BIT(0)
44 #define XILINX_PCIE_INTR_ECRC_ERR	BIT(1)
45 #define XILINX_PCIE_INTR_STR_ERR	BIT(2)
46 #define XILINX_PCIE_INTR_HOT_RESET	BIT(3)
47 #define XILINX_PCIE_INTR_CFG_TIMEOUT	BIT(8)
48 #define XILINX_PCIE_INTR_CORRECTABLE	BIT(9)
49 #define XILINX_PCIE_INTR_NONFATAL	BIT(10)
50 #define XILINX_PCIE_INTR_FATAL		BIT(11)
51 #define XILINX_PCIE_INTR_INTX		BIT(16)
52 #define XILINX_PCIE_INTR_MSI		BIT(17)
53 #define XILINX_PCIE_INTR_SLV_UNSUPP	BIT(20)
54 #define XILINX_PCIE_INTR_SLV_UNEXP	BIT(21)
55 #define XILINX_PCIE_INTR_SLV_COMPL	BIT(22)
56 #define XILINX_PCIE_INTR_SLV_ERRP	BIT(23)
57 #define XILINX_PCIE_INTR_SLV_CMPABT	BIT(24)
58 #define XILINX_PCIE_INTR_SLV_ILLBUR	BIT(25)
59 #define XILINX_PCIE_INTR_MST_DECERR	BIT(26)
60 #define XILINX_PCIE_INTR_MST_SLVERR	BIT(27)
61 #define XILINX_PCIE_INTR_MST_ERRP	BIT(28)
62 #define XILINX_PCIE_IMR_ALL_MASK	0x1FF30FED
63 #define XILINX_PCIE_IMR_ENABLE_MASK	0x1FF30F0D
64 #define XILINX_PCIE_IDR_ALL_MASK	0xFFFFFFFF
65 
66 /* Root Port Error FIFO Read Register definitions */
67 #define XILINX_PCIE_RPEFR_ERR_VALID	BIT(18)
68 #define XILINX_PCIE_RPEFR_REQ_ID	GENMASK(15, 0)
69 #define XILINX_PCIE_RPEFR_ALL_MASK	0xFFFFFFFF
70 
71 /* Root Port Interrupt FIFO Read Register 1 definitions */
72 #define XILINX_PCIE_RPIFR1_INTR_VALID	BIT(31)
73 #define XILINX_PCIE_RPIFR1_MSI_INTR	BIT(30)
74 #define XILINX_PCIE_RPIFR1_INTR_MASK	GENMASK(28, 27)
75 #define XILINX_PCIE_RPIFR1_ALL_MASK	0xFFFFFFFF
76 #define XILINX_PCIE_RPIFR1_INTR_SHIFT	27
77 
78 /* Bridge Info Register definitions */
79 #define XILINX_PCIE_BIR_ECAM_SZ_MASK	GENMASK(18, 16)
80 #define XILINX_PCIE_BIR_ECAM_SZ_SHIFT	16
81 
82 /* Root Port Interrupt FIFO Read Register 2 definitions */
83 #define XILINX_PCIE_RPIFR2_MSG_DATA	GENMASK(15, 0)
84 
85 /* Root Port Status/control Register definitions */
86 #define XILINX_PCIE_REG_RPSC_BEN	BIT(0)
87 
88 /* Phy Status/Control Register definitions */
89 #define XILINX_PCIE_REG_PSCR_LNKUP	BIT(11)
90 
91 /* Number of MSI IRQs */
92 #define XILINX_NUM_MSI_IRQS		128
93 
94 /**
95  * struct xilinx_pcie - PCIe port information
96  * @dev: Device pointer
97  * @reg_base: IO Mapped Register Base
98  * @msi_map: Bitmap of allocated MSIs
99  * @map_lock: Mutex protecting the MSI allocation
100  * @msi_domain: MSI IRQ domain pointer
101  * @leg_domain: Legacy IRQ domain pointer
102  * @resources: Bus Resources
103  */
104 struct xilinx_pcie {
105 	struct device *dev;
106 	void __iomem *reg_base;
107 	unsigned long msi_map[BITS_TO_LONGS(XILINX_NUM_MSI_IRQS)];
108 	struct mutex map_lock;
109 	struct irq_domain *msi_domain;
110 	struct irq_domain *leg_domain;
111 	struct list_head resources;
112 };
113 
114 static inline u32 pcie_read(struct xilinx_pcie *pcie, u32 reg)
115 {
116 	return readl(pcie->reg_base + reg);
117 }
118 
119 static inline void pcie_write(struct xilinx_pcie *pcie, u32 val, u32 reg)
120 {
121 	writel(val, pcie->reg_base + reg);
122 }
123 
124 static inline bool xilinx_pcie_link_up(struct xilinx_pcie *pcie)
125 {
126 	return (pcie_read(pcie, XILINX_PCIE_REG_PSCR) &
127 		XILINX_PCIE_REG_PSCR_LNKUP) ? 1 : 0;
128 }
129 
130 /**
131  * xilinx_pcie_clear_err_interrupts - Clear Error Interrupts
132  * @pcie: PCIe port information
133  */
134 static void xilinx_pcie_clear_err_interrupts(struct xilinx_pcie *pcie)
135 {
136 	struct device *dev = pcie->dev;
137 	unsigned long val = pcie_read(pcie, XILINX_PCIE_REG_RPEFR);
138 
139 	if (val & XILINX_PCIE_RPEFR_ERR_VALID) {
140 		dev_dbg(dev, "Requester ID %lu\n",
141 			val & XILINX_PCIE_RPEFR_REQ_ID);
142 		pcie_write(pcie, XILINX_PCIE_RPEFR_ALL_MASK,
143 			   XILINX_PCIE_REG_RPEFR);
144 	}
145 }
146 
147 /**
148  * xilinx_pcie_valid_device - Check if a valid device is present on bus
149  * @bus: PCI Bus structure
150  * @devfn: device/function
151  *
152  * Return: 'true' on success and 'false' if invalid device is found
153  */
154 static bool xilinx_pcie_valid_device(struct pci_bus *bus, unsigned int devfn)
155 {
156 	struct xilinx_pcie *pcie = bus->sysdata;
157 
158 	/* Check if link is up when trying to access downstream pcie ports */
159 	if (!pci_is_root_bus(bus)) {
160 		if (!xilinx_pcie_link_up(pcie))
161 			return false;
162 	} else if (devfn > 0) {
163 		/* Only one device down on each root port */
164 		return false;
165 	}
166 	return true;
167 }
168 
169 /**
170  * xilinx_pcie_map_bus - Get configuration base
171  * @bus: PCI Bus structure
172  * @devfn: Device/function
173  * @where: Offset from base
174  *
175  * Return: Base address of the configuration space needed to be
176  *	   accessed.
177  */
178 static void __iomem *xilinx_pcie_map_bus(struct pci_bus *bus,
179 					 unsigned int devfn, int where)
180 {
181 	struct xilinx_pcie *pcie = bus->sysdata;
182 
183 	if (!xilinx_pcie_valid_device(bus, devfn))
184 		return NULL;
185 
186 	return pcie->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
187 }
188 
189 /* PCIe operations */
190 static struct pci_ops xilinx_pcie_ops = {
191 	.map_bus = xilinx_pcie_map_bus,
192 	.read	= pci_generic_config_read,
193 	.write	= pci_generic_config_write,
194 };
195 
196 /* MSI functions */
197 
198 static void xilinx_msi_top_irq_ack(struct irq_data *d)
199 {
200 	/*
201 	 * xilinx_pcie_intr_handler() will have performed the Ack.
202 	 * Eventually, this should be fixed and the Ack be moved in
203 	 * the respective callbacks for INTx and MSI.
204 	 */
205 }
206 
207 static void xilinx_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
208 {
209 	struct xilinx_pcie *pcie = irq_data_get_irq_chip_data(data);
210 	phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K);
211 
212 	msg->address_lo = lower_32_bits(pa);
213 	msg->address_hi = upper_32_bits(pa);
214 	msg->data = data->hwirq;
215 }
216 
217 static struct irq_chip xilinx_msi_bottom_chip = {
218 	.name			= "Xilinx MSI",
219 	.irq_compose_msi_msg	= xilinx_compose_msi_msg,
220 };
221 
222 static int xilinx_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
223 				  unsigned int nr_irqs, void *args)
224 {
225 	struct xilinx_pcie *pcie = domain->host_data;
226 	int hwirq, i;
227 
228 	mutex_lock(&pcie->map_lock);
229 
230 	hwirq = bitmap_find_free_region(pcie->msi_map, XILINX_NUM_MSI_IRQS, order_base_2(nr_irqs));
231 
232 	mutex_unlock(&pcie->map_lock);
233 
234 	if (hwirq < 0)
235 		return -ENOSPC;
236 
237 	for (i = 0; i < nr_irqs; i++)
238 		irq_domain_set_info(domain, virq + i, hwirq + i,
239 				    &xilinx_msi_bottom_chip, domain->host_data,
240 				    handle_edge_irq, NULL, NULL);
241 
242 	return 0;
243 }
244 
245 static void xilinx_msi_domain_free(struct irq_domain *domain, unsigned int virq,
246 				  unsigned int nr_irqs)
247 {
248 	struct irq_data *d = irq_domain_get_irq_data(domain, virq);
249 	struct xilinx_pcie *pcie = domain->host_data;
250 
251 	mutex_lock(&pcie->map_lock);
252 
253 	bitmap_release_region(pcie->msi_map, d->hwirq, order_base_2(nr_irqs));
254 
255 	mutex_unlock(&pcie->map_lock);
256 }
257 
258 static const struct irq_domain_ops xilinx_msi_domain_ops = {
259 	.alloc	= xilinx_msi_domain_alloc,
260 	.free	= xilinx_msi_domain_free,
261 };
262 
263 static bool xilinx_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
264 				     struct irq_domain *real_parent, struct msi_domain_info *info)
265 {
266 	struct irq_chip *chip = info->chip;
267 
268 	if (!msi_lib_init_dev_msi_info(dev, domain, real_parent, info))
269 		return false;
270 
271 	chip->irq_ack = xilinx_msi_top_irq_ack;
272 	return true;
273 }
274 
275 #define XILINX_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS	| \
276 				   MSI_FLAG_USE_DEF_CHIP_OPS	| \
277 				   MSI_FLAG_NO_AFFINITY)
278 
279 static const struct msi_parent_ops xilinx_msi_parent_ops = {
280 	.required_flags		= XILINX_MSI_FLAGS_REQUIRED,
281 	.supported_flags	= MSI_GENERIC_FLAGS_MASK,
282 	.bus_select_token	= DOMAIN_BUS_PCI_MSI,
283 	.prefix			= "xilinx-",
284 	.init_dev_msi_info	= xilinx_init_dev_msi_info,
285 };
286 
287 static int xilinx_allocate_msi_domains(struct xilinx_pcie *pcie)
288 {
289 	struct irq_domain_info info = {
290 		.fwnode		= dev_fwnode(pcie->dev),
291 		.ops		= &xilinx_msi_domain_ops,
292 		.host_data	= pcie,
293 		.size		= XILINX_NUM_MSI_IRQS,
294 	};
295 
296 	pcie->msi_domain = msi_create_parent_irq_domain(&info, &xilinx_msi_parent_ops);
297 	if (!pcie->msi_domain) {
298 		dev_err(pcie->dev, "failed to create MSI domain\n");
299 		return -ENOMEM;
300 	}
301 
302 	return 0;
303 }
304 
305 static void xilinx_free_irq_domains(struct xilinx_pcie *pcie)
306 {
307 	irq_domain_remove(pcie->msi_domain);
308 	irq_domain_remove(pcie->leg_domain);
309 }
310 
311 /* INTx Functions */
312 
313 /**
314  * xilinx_pcie_intx_map - Set the handler for the INTx and mark IRQ as valid
315  * @domain: IRQ domain
316  * @irq: Virtual IRQ number
317  * @hwirq: HW interrupt number
318  *
319  * Return: Always returns 0.
320  */
321 static int xilinx_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
322 				irq_hw_number_t hwirq)
323 {
324 	irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
325 	irq_set_chip_data(irq, domain->host_data);
326 
327 	return 0;
328 }
329 
330 /* INTx IRQ Domain operations */
331 static const struct irq_domain_ops intx_domain_ops = {
332 	.map = xilinx_pcie_intx_map,
333 	.xlate = pci_irqd_intx_xlate,
334 };
335 
336 /* PCIe HW Functions */
337 
338 /**
339  * xilinx_pcie_intr_handler - Interrupt Service Handler
340  * @irq: IRQ number
341  * @data: PCIe port information
342  *
343  * Return: IRQ_HANDLED on success and IRQ_NONE on failure
344  */
345 static irqreturn_t xilinx_pcie_intr_handler(int irq, void *data)
346 {
347 	struct xilinx_pcie *pcie = (struct xilinx_pcie *)data;
348 	struct device *dev = pcie->dev;
349 	u32 val, mask, status;
350 
351 	/* Read interrupt decode and mask registers */
352 	val = pcie_read(pcie, XILINX_PCIE_REG_IDR);
353 	mask = pcie_read(pcie, XILINX_PCIE_REG_IMR);
354 
355 	status = val & mask;
356 	if (!status)
357 		return IRQ_NONE;
358 
359 	if (status & XILINX_PCIE_INTR_LINK_DOWN)
360 		dev_warn(dev, "Link Down\n");
361 
362 	if (status & XILINX_PCIE_INTR_ECRC_ERR)
363 		dev_warn(dev, "ECRC failed\n");
364 
365 	if (status & XILINX_PCIE_INTR_STR_ERR)
366 		dev_warn(dev, "Streaming error\n");
367 
368 	if (status & XILINX_PCIE_INTR_HOT_RESET)
369 		dev_info(dev, "Hot reset\n");
370 
371 	if (status & XILINX_PCIE_INTR_CFG_TIMEOUT)
372 		dev_warn(dev, "ECAM access timeout\n");
373 
374 	if (status & XILINX_PCIE_INTR_CORRECTABLE) {
375 		dev_warn(dev, "Correctable error message\n");
376 		xilinx_pcie_clear_err_interrupts(pcie);
377 	}
378 
379 	if (status & XILINX_PCIE_INTR_NONFATAL) {
380 		dev_warn(dev, "Non fatal error message\n");
381 		xilinx_pcie_clear_err_interrupts(pcie);
382 	}
383 
384 	if (status & XILINX_PCIE_INTR_FATAL) {
385 		dev_warn(dev, "Fatal error message\n");
386 		xilinx_pcie_clear_err_interrupts(pcie);
387 	}
388 
389 	if (status & (XILINX_PCIE_INTR_INTX | XILINX_PCIE_INTR_MSI)) {
390 		struct irq_domain *domain;
391 
392 		val = pcie_read(pcie, XILINX_PCIE_REG_RPIFR1);
393 
394 		/* Check whether interrupt valid */
395 		if (!(val & XILINX_PCIE_RPIFR1_INTR_VALID)) {
396 			dev_warn(dev, "RP Intr FIFO1 read error\n");
397 			goto error;
398 		}
399 
400 		/* Decode the IRQ number */
401 		if (val & XILINX_PCIE_RPIFR1_MSI_INTR) {
402 			val = pcie_read(pcie, XILINX_PCIE_REG_RPIFR2) &
403 				XILINX_PCIE_RPIFR2_MSG_DATA;
404 			domain = pcie->msi_domain;
405 		} else {
406 			val = (val & XILINX_PCIE_RPIFR1_INTR_MASK) >>
407 				XILINX_PCIE_RPIFR1_INTR_SHIFT;
408 			domain = pcie->leg_domain;
409 		}
410 
411 		/* Clear interrupt FIFO register 1 */
412 		pcie_write(pcie, XILINX_PCIE_RPIFR1_ALL_MASK,
413 			   XILINX_PCIE_REG_RPIFR1);
414 
415 		generic_handle_domain_irq(domain, val);
416 	}
417 
418 	if (status & XILINX_PCIE_INTR_SLV_UNSUPP)
419 		dev_warn(dev, "Slave unsupported request\n");
420 
421 	if (status & XILINX_PCIE_INTR_SLV_UNEXP)
422 		dev_warn(dev, "Slave unexpected completion\n");
423 
424 	if (status & XILINX_PCIE_INTR_SLV_COMPL)
425 		dev_warn(dev, "Slave completion timeout\n");
426 
427 	if (status & XILINX_PCIE_INTR_SLV_ERRP)
428 		dev_warn(dev, "Slave Error Poison\n");
429 
430 	if (status & XILINX_PCIE_INTR_SLV_CMPABT)
431 		dev_warn(dev, "Slave Completer Abort\n");
432 
433 	if (status & XILINX_PCIE_INTR_SLV_ILLBUR)
434 		dev_warn(dev, "Slave Illegal Burst\n");
435 
436 	if (status & XILINX_PCIE_INTR_MST_DECERR)
437 		dev_warn(dev, "Master decode error\n");
438 
439 	if (status & XILINX_PCIE_INTR_MST_SLVERR)
440 		dev_warn(dev, "Master slave error\n");
441 
442 	if (status & XILINX_PCIE_INTR_MST_ERRP)
443 		dev_warn(dev, "Master error poison\n");
444 
445 error:
446 	/* Clear the Interrupt Decode register */
447 	pcie_write(pcie, status, XILINX_PCIE_REG_IDR);
448 
449 	return IRQ_HANDLED;
450 }
451 
452 /**
453  * xilinx_pcie_init_irq_domain - Initialize IRQ domain
454  * @pcie: PCIe port information
455  *
456  * Return: '0' on success and error value on failure
457  */
458 static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie)
459 {
460 	struct device *dev = pcie->dev;
461 	struct device_node *pcie_intc_node;
462 	int ret;
463 
464 	/* Setup INTx */
465 	pcie_intc_node = of_get_next_child(dev->of_node, NULL);
466 	if (!pcie_intc_node) {
467 		dev_err(dev, "No PCIe Intc node found\n");
468 		return -ENODEV;
469 	}
470 
471 	pcie->leg_domain = irq_domain_create_linear(of_fwnode_handle(pcie_intc_node), PCI_NUM_INTX,
472 						    &intx_domain_ops, pcie);
473 	of_node_put(pcie_intc_node);
474 	if (!pcie->leg_domain) {
475 		dev_err(dev, "Failed to get a INTx IRQ domain\n");
476 		return -ENODEV;
477 	}
478 
479 	/* Setup MSI */
480 	if (IS_ENABLED(CONFIG_PCI_MSI)) {
481 		phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K);
482 
483 		ret = xilinx_allocate_msi_domains(pcie);
484 		if (ret) {
485 			irq_domain_remove(pcie->leg_domain);
486 			return ret;
487 		}
488 
489 		pcie_write(pcie, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1);
490 		pcie_write(pcie, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2);
491 	}
492 
493 	return 0;
494 }
495 
496 /**
497  * xilinx_pcie_init_port - Initialize hardware
498  * @pcie: PCIe port information
499  */
500 static void xilinx_pcie_init_port(struct xilinx_pcie *pcie)
501 {
502 	struct device *dev = pcie->dev;
503 
504 	if (xilinx_pcie_link_up(pcie))
505 		dev_info(dev, "PCIe Link is UP\n");
506 	else
507 		dev_info(dev, "PCIe Link is DOWN\n");
508 
509 	/* Disable all interrupts */
510 	pcie_write(pcie, ~XILINX_PCIE_IDR_ALL_MASK,
511 		   XILINX_PCIE_REG_IMR);
512 
513 	/* Clear pending interrupts */
514 	pcie_write(pcie, pcie_read(pcie, XILINX_PCIE_REG_IDR) &
515 			 XILINX_PCIE_IMR_ALL_MASK,
516 		   XILINX_PCIE_REG_IDR);
517 
518 	/* Enable all interrupts we handle */
519 	pcie_write(pcie, XILINX_PCIE_IMR_ENABLE_MASK, XILINX_PCIE_REG_IMR);
520 
521 	/* Enable the Bridge enable bit */
522 	pcie_write(pcie, pcie_read(pcie, XILINX_PCIE_REG_RPSC) |
523 			 XILINX_PCIE_REG_RPSC_BEN,
524 		   XILINX_PCIE_REG_RPSC);
525 }
526 
527 /**
528  * xilinx_pcie_parse_dt - Parse Device tree
529  * @pcie: PCIe port information
530  *
531  * Return: '0' on success and error value on failure
532  */
533 static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie)
534 {
535 	struct device *dev = pcie->dev;
536 	struct device_node *node = dev->of_node;
537 	struct resource regs;
538 	unsigned int irq;
539 	int err;
540 
541 	err = of_address_to_resource(node, 0, &regs);
542 	if (err) {
543 		dev_err(dev, "missing \"reg\" property\n");
544 		return err;
545 	}
546 
547 	pcie->reg_base = devm_pci_remap_cfg_resource(dev, &regs);
548 	if (IS_ERR(pcie->reg_base))
549 		return PTR_ERR(pcie->reg_base);
550 
551 	irq = irq_of_parse_and_map(node, 0);
552 	err = devm_request_irq(dev, irq, xilinx_pcie_intr_handler,
553 			       IRQF_SHARED | IRQF_NO_THREAD,
554 			       "xilinx-pcie", pcie);
555 	if (err) {
556 		dev_err(dev, "unable to request irq %d\n", irq);
557 		return err;
558 	}
559 
560 	return 0;
561 }
562 
563 /**
564  * xilinx_pcie_probe - Probe function
565  * @pdev: Platform device pointer
566  *
567  * Return: '0' on success and error value on failure
568  */
569 static int xilinx_pcie_probe(struct platform_device *pdev)
570 {
571 	struct device *dev = &pdev->dev;
572 	struct xilinx_pcie *pcie;
573 	struct pci_host_bridge *bridge;
574 	int err;
575 
576 	if (!dev->of_node)
577 		return -ENODEV;
578 
579 	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
580 	if (!bridge)
581 		return -ENODEV;
582 
583 	pcie = pci_host_bridge_priv(bridge);
584 	mutex_init(&pcie->map_lock);
585 	pcie->dev = dev;
586 
587 	err = xilinx_pcie_parse_dt(pcie);
588 	if (err) {
589 		dev_err(dev, "Parsing DT failed\n");
590 		return err;
591 	}
592 
593 	xilinx_pcie_init_port(pcie);
594 
595 	err = xilinx_pcie_init_irq_domain(pcie);
596 	if (err) {
597 		dev_err(dev, "Failed creating IRQ Domain\n");
598 		return err;
599 	}
600 
601 	bridge->sysdata = pcie;
602 	bridge->ops = &xilinx_pcie_ops;
603 
604 	err = pci_host_probe(bridge);
605 	if (err)
606 		xilinx_free_irq_domains(pcie);
607 
608 	return err;
609 }
610 
611 static const struct of_device_id xilinx_pcie_of_match[] = {
612 	{ .compatible = "xlnx,axi-pcie-host-1.00.a", },
613 	{}
614 };
615 
616 static struct platform_driver xilinx_pcie_driver = {
617 	.driver = {
618 		.name = "xilinx-pcie",
619 		.of_match_table = xilinx_pcie_of_match,
620 		.suppress_bind_attrs = true,
621 	},
622 	.probe = xilinx_pcie_probe,
623 };
624 builtin_platform_driver(xilinx_pcie_driver);
625