Lines Matching +full:ecam +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (c) 2012 - 2014 Xilinx, Inc.
7 * Based on the Tegra PCIe driver
24 #include <linux/pci-ecam.h>
94 * struct xilinx_pcie - PCIe port information
115 return readl(pcie->reg_base + reg); in pcie_read()
120 writel(val, pcie->reg_base + reg); in pcie_write()
130 * xilinx_pcie_clear_err_interrupts - Clear Error Interrupts
135 struct device *dev = pcie->dev; in xilinx_pcie_clear_err_interrupts()
147 * xilinx_pcie_valid_device - Check if a valid device is present on bus
155 struct xilinx_pcie *pcie = bus->sysdata; in xilinx_pcie_valid_device()
169 * xilinx_pcie_map_bus - Get configuration base
180 struct xilinx_pcie *pcie = bus->sysdata; in xilinx_pcie_map_bus()
185 return pcie->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); in xilinx_pcie_map_bus()
213 return -EINVAL; in xilinx_msi_set_affinity()
221 msg->address_lo = lower_32_bits(pa); in xilinx_compose_msi_msg()
222 msg->address_hi = upper_32_bits(pa); in xilinx_compose_msi_msg()
223 msg->data = data->hwirq; in xilinx_compose_msi_msg()
235 struct xilinx_pcie *pcie = domain->host_data; in xilinx_msi_domain_alloc()
238 mutex_lock(&pcie->map_lock); in xilinx_msi_domain_alloc()
240 hwirq = bitmap_find_free_region(pcie->msi_map, XILINX_NUM_MSI_IRQS, order_base_2(nr_irqs)); in xilinx_msi_domain_alloc()
242 mutex_unlock(&pcie->map_lock); in xilinx_msi_domain_alloc()
245 return -ENOSPC; in xilinx_msi_domain_alloc()
249 &xilinx_msi_bottom_chip, domain->host_data, in xilinx_msi_domain_alloc()
259 struct xilinx_pcie *pcie = domain->host_data; in xilinx_msi_domain_free()
261 mutex_lock(&pcie->map_lock); in xilinx_msi_domain_free()
263 bitmap_release_region(pcie->msi_map, d->hwirq, order_base_2(nr_irqs)); in xilinx_msi_domain_free()
265 mutex_unlock(&pcie->map_lock); in xilinx_msi_domain_free()
280 struct fwnode_handle *fwnode = dev_fwnode(pcie->dev); in xilinx_allocate_msi_domains()
286 dev_err(pcie->dev, "failed to create IRQ domain\n"); in xilinx_allocate_msi_domains()
287 return -ENOMEM; in xilinx_allocate_msi_domains()
291 pcie->msi_domain = pci_msi_create_irq_domain(fwnode, &xilinx_msi_info, parent); in xilinx_allocate_msi_domains()
292 if (!pcie->msi_domain) { in xilinx_allocate_msi_domains()
293 dev_err(pcie->dev, "failed to create MSI domain\n"); in xilinx_allocate_msi_domains()
295 return -ENOMEM; in xilinx_allocate_msi_domains()
303 struct irq_domain *parent = pcie->msi_domain->parent; in xilinx_free_msi_domains()
305 irq_domain_remove(pcie->msi_domain); in xilinx_free_msi_domains()
312 * xilinx_pcie_intx_map - Set the handler for the INTx and mark IRQ as valid
323 irq_set_chip_data(irq, domain->host_data); in xilinx_pcie_intx_map()
337 * xilinx_pcie_intr_handler - Interrupt Service Handler
346 struct device *dev = pcie->dev; in xilinx_pcie_intr_handler()
370 dev_warn(dev, "ECAM access timeout\n"); in xilinx_pcie_intr_handler()
402 domain = pcie->msi_domain->parent; in xilinx_pcie_intr_handler()
406 domain = pcie->leg_domain; in xilinx_pcie_intr_handler()
451 * xilinx_pcie_init_irq_domain - Initialize IRQ domain
458 struct device *dev = pcie->dev; in xilinx_pcie_init_irq_domain()
463 pcie_intc_node = of_get_next_child(dev->of_node, NULL); in xilinx_pcie_init_irq_domain()
466 return -ENODEV; in xilinx_pcie_init_irq_domain()
469 pcie->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, in xilinx_pcie_init_irq_domain()
473 if (!pcie->leg_domain) { in xilinx_pcie_init_irq_domain()
475 return -ENODEV; in xilinx_pcie_init_irq_domain()
494 * xilinx_pcie_init_port - Initialize hardware
499 struct device *dev = pcie->dev; in xilinx_pcie_init_port()
525 * xilinx_pcie_parse_dt - Parse Device tree
532 struct device *dev = pcie->dev; in xilinx_pcie_parse_dt()
533 struct device_node *node = dev->of_node; in xilinx_pcie_parse_dt()
544 pcie->reg_base = devm_pci_remap_cfg_resource(dev, ®s); in xilinx_pcie_parse_dt()
545 if (IS_ERR(pcie->reg_base)) in xilinx_pcie_parse_dt()
546 return PTR_ERR(pcie->reg_base); in xilinx_pcie_parse_dt()
551 "xilinx-pcie", pcie); in xilinx_pcie_parse_dt()
561 * xilinx_pcie_probe - Probe function
568 struct device *dev = &pdev->dev; in xilinx_pcie_probe()
573 if (!dev->of_node) in xilinx_pcie_probe()
574 return -ENODEV; in xilinx_pcie_probe()
578 return -ENODEV; in xilinx_pcie_probe()
581 mutex_init(&pcie->map_lock); in xilinx_pcie_probe()
582 pcie->dev = dev; in xilinx_pcie_probe()
598 bridge->sysdata = pcie; in xilinx_pcie_probe()
599 bridge->ops = &xilinx_pcie_ops; in xilinx_pcie_probe()
609 { .compatible = "xlnx,axi-pcie-host-1.00.a", },
615 .name = "xilinx-pcie",