Lines Matching +full:child +full:- +full:interrupt +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0
5 * Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
27 #include "../pci-bridge-emul.h"
40 #define PCIE_BAR_CTRL_OFF(n) (0x1804 + (((n) - 1) * 4))
94 phys_addr_t base; member
102 void __iomem *base; member
130 writel(val, port->base + reg); in mvebu_writel()
135 return readl(port->base + reg); in mvebu_readl()
140 return port->io_target != -1 && port->io_attr != -1; in mvebu_has_ioport()
199 * BAR[0] -> internal registers (needed for MSI)
200 * BAR[1] -> covers all DRAM banks
201 * BAR[2] -> Disabled
202 * WIN[0-3] -> DRAM bank[0-3]
217 for (i = 0; i < dram->num_cs; i++) { in mvebu_pcie_setup_wins()
218 const struct mbus_dram_window *cs = dram->cs + i; in mvebu_pcie_setup_wins()
220 mvebu_writel(port, cs->base & 0xffff0000, in mvebu_pcie_setup_wins()
224 ((cs->size - 1) & 0xffff0000) | in mvebu_pcie_setup_wins()
225 (cs->mbus_attr << 8) | in mvebu_pcie_setup_wins()
226 (dram->mbus_dram_target_id << 4) | 1, in mvebu_pcie_setup_wins()
229 size += cs->size; in mvebu_pcie_setup_wins()
233 if ((size & (size - 1)) != 0) in mvebu_pcie_setup_wins()
237 mvebu_writel(port, dram->cs[0].base, PCIE_BAR_LO_OFF(1)); in mvebu_pcie_setup_wins()
239 mvebu_writel(port, ((size - 1) & 0xffff0000) | 1, in mvebu_pcie_setup_wins()
245 mvebu_writel(port, round_down(port->regs.start, SZ_1M), PCIE_BAR_LO_OFF(0)); in mvebu_pcie_setup_wins()
261 * as read-only but this mvebu controller has it as read-write and must in mvebu_pcie_setup_hw()
267 lnkcap |= FIELD_PREP(PCI_EXP_LNKCAP_MLW, port->is_x4 ? 4 : 1); in mvebu_pcie_setup_hw()
283 * Moreover Type 0 BAR registers (ranges 0x10 - 0x28 and 0x30 - 0x34) in mvebu_pcie_setup_hw()
311 if (port->slot_power_limit_value) { in mvebu_pcie_setup_hw()
312 sspl |= port->slot_power_limit_value << PCIE_SSPL_VALUE_SHIFT; in mvebu_pcie_setup_hw()
313 sspl |= port->slot_power_limit_scale << PCIE_SSPL_SCALE_SHIFT; in mvebu_pcie_setup_hw()
318 /* Mask all interrupt sources. */ in mvebu_pcie_setup_hw()
321 /* Clear all interrupt causes. */ in mvebu_pcie_setup_hw()
324 /* Check if "intx" interrupt was specified in DT. */ in mvebu_pcie_setup_hw()
325 if (port->intx_irq > 0) in mvebu_pcie_setup_hw()
329 * Fallback code when "intx" interrupt was not specified in DT: in mvebu_pcie_setup_hw()
335 * performance penalty as every PCIe interrupt handler needs to be in mvebu_pcie_setup_hw()
336 * called when some interrupt is triggered. in mvebu_pcie_setup_hw()
351 struct mvebu_pcie *pcie = bus->sysdata; in mvebu_pcie_child_rd_conf()
362 conf_data = port->base + PCIE_CONF_DATA_OFF; in mvebu_pcie_child_rd_conf()
364 mvebu_writel(port, PCIE_CONF_ADDR(bus->number, devfn, where), in mvebu_pcie_child_rd_conf()
387 struct mvebu_pcie *pcie = bus->sysdata; in mvebu_pcie_child_wr_conf()
398 conf_data = port->base + PCIE_CONF_DATA_OFF; in mvebu_pcie_child_wr_conf()
400 mvebu_writel(port, PCIE_CONF_ADDR(bus->number, devfn, where), in mvebu_pcie_child_wr_conf()
430 phys_addr_t base, size_t size) in mvebu_pcie_del_windows() argument
433 size_t sz = 1 << (fls(size) - 1); in mvebu_pcie_del_windows()
435 mvebu_mbus_del_window(base, sz); in mvebu_pcie_del_windows()
436 base += sz; in mvebu_pcie_del_windows()
437 size -= sz; in mvebu_pcie_del_windows()
449 phys_addr_t base, size_t size, in mvebu_pcie_add_windows() argument
455 size_t sz = 1 << (fls(size) - 1); in mvebu_pcie_add_windows()
458 ret = mvebu_mbus_add_window_remap_by_id(target, attribute, base, in mvebu_pcie_add_windows()
461 phys_addr_t end = base + sz - 1; in mvebu_pcie_add_windows()
463 dev_err(&port->pcie->pdev->dev, in mvebu_pcie_add_windows()
464 "Could not create MBus window at [mem %pa-%pa]: %d\n", in mvebu_pcie_add_windows()
465 &base, &end, ret); in mvebu_pcie_add_windows()
466 mvebu_pcie_del_windows(port, base - size_mapped, in mvebu_pcie_add_windows()
471 size -= sz; in mvebu_pcie_add_windows()
473 base += sz; in mvebu_pcie_add_windows()
488 if (desired->base == cur->base && desired->remap == cur->remap && in mvebu_pcie_set_window()
489 desired->size == cur->size) in mvebu_pcie_set_window()
492 if (cur->size != 0) { in mvebu_pcie_set_window()
493 mvebu_pcie_del_windows(port, cur->base, cur->size); in mvebu_pcie_set_window()
494 cur->size = 0; in mvebu_pcie_set_window()
495 cur->base = 0; in mvebu_pcie_set_window()
504 if (desired->size == 0) in mvebu_pcie_set_window()
507 ret = mvebu_pcie_add_windows(port, target, attribute, desired->base, in mvebu_pcie_set_window()
508 desired->size, desired->remap); in mvebu_pcie_set_window()
510 cur->size = 0; in mvebu_pcie_set_window()
511 cur->base = 0; in mvebu_pcie_set_window()
522 struct pci_bridge_emul_conf *conf = &port->bridge.conf; in mvebu_pcie_handle_iobase_change()
525 if (conf->iolimit < conf->iobase || in mvebu_pcie_handle_iobase_change()
526 le16_to_cpu(conf->iolimitupper) < le16_to_cpu(conf->iobaseupper)) in mvebu_pcie_handle_iobase_change()
527 return mvebu_pcie_set_window(port, port->io_target, port->io_attr, in mvebu_pcie_handle_iobase_change()
528 &desired, &port->iowin); in mvebu_pcie_handle_iobase_change()
531 * We read the PCI-to-PCI bridge emulated registers, and in mvebu_pcie_handle_iobase_change()
532 * calculate the base address and size of the address decoding in mvebu_pcie_handle_iobase_change()
533 * window to setup, according to the PCI-to-PCI bridge in mvebu_pcie_handle_iobase_change()
534 * specifications. iobase is the bus address, port->iowin_base in mvebu_pcie_handle_iobase_change()
537 desired.remap = ((conf->iobase & 0xF0) << 8) | in mvebu_pcie_handle_iobase_change()
538 (le16_to_cpu(conf->iobaseupper) << 16); in mvebu_pcie_handle_iobase_change()
539 desired.base = port->pcie->io.start + desired.remap; in mvebu_pcie_handle_iobase_change()
540 desired.size = ((0xFFF | ((conf->iolimit & 0xF0) << 8) | in mvebu_pcie_handle_iobase_change()
541 (le16_to_cpu(conf->iolimitupper) << 16)) - in mvebu_pcie_handle_iobase_change()
545 return mvebu_pcie_set_window(port, port->io_target, port->io_attr, &desired, in mvebu_pcie_handle_iobase_change()
546 &port->iowin); in mvebu_pcie_handle_iobase_change()
552 struct pci_bridge_emul_conf *conf = &port->bridge.conf; in mvebu_pcie_handle_membase_change()
555 if (le16_to_cpu(conf->memlimit) < le16_to_cpu(conf->membase)) in mvebu_pcie_handle_membase_change()
556 return mvebu_pcie_set_window(port, port->mem_target, port->mem_attr, in mvebu_pcie_handle_membase_change()
557 &desired, &port->memwin); in mvebu_pcie_handle_membase_change()
560 * We read the PCI-to-PCI bridge emulated registers, and in mvebu_pcie_handle_membase_change()
561 * calculate the base address and size of the address decoding in mvebu_pcie_handle_membase_change()
562 * window to setup, according to the PCI-to-PCI bridge in mvebu_pcie_handle_membase_change()
565 desired.base = ((le16_to_cpu(conf->membase) & 0xFFF0) << 16); in mvebu_pcie_handle_membase_change()
566 desired.size = (((le16_to_cpu(conf->memlimit) & 0xFFF0) << 16) | 0xFFFFF) - in mvebu_pcie_handle_membase_change()
567 desired.base + 1; in mvebu_pcie_handle_membase_change()
569 return mvebu_pcie_set_window(port, port->mem_target, port->mem_attr, &desired, in mvebu_pcie_handle_membase_change()
570 &port->memwin); in mvebu_pcie_handle_membase_change()
577 struct mvebu_pcie_port *port = bridge->data; in mvebu_pci_bridge_emul_base_conf_read()
590 __le32 *cfgspace = (__le32 *)&bridge->conf; in mvebu_pci_bridge_emul_base_conf_read()
604 __le32 *cfgspace = (__le32 *)&bridge->conf; in mvebu_pci_bridge_emul_base_conf_read()
625 struct mvebu_pcie_port *port = bridge->data; in mvebu_pci_bridge_emul_pcie_conf_read()
639 * is hard-wired to zero for downstream ports but HW returns 1. in mvebu_pci_bridge_emul_pcie_conf_read()
655 u16 slotctl = le16_to_cpu(bridge->pcie_conf.slotctl); in mvebu_pci_bridge_emul_pcie_conf_read()
656 u16 slotsta = le16_to_cpu(bridge->pcie_conf.slotsta); in mvebu_pci_bridge_emul_pcie_conf_read()
663 if (!port->slot_power_limit_value) in mvebu_pci_bridge_emul_pcie_conf_read()
667 /* This callback is 32-bit and in high bits is slot status. */ in mvebu_pci_bridge_emul_pcie_conf_read()
700 struct mvebu_pcie_port *port = bridge->data; in mvebu_pci_bridge_emul_ext_conf_read()
731 struct mvebu_pcie_port *port = bridge->data; in mvebu_pci_bridge_emul_base_conf_write()
732 struct pci_bridge_emul_conf *conf = &bridge->conf; in mvebu_pci_bridge_emul_base_conf_write()
743 conf->iobase &= ~0xf0; in mvebu_pci_bridge_emul_base_conf_write()
744 conf->iolimit &= ~0xf0; in mvebu_pci_bridge_emul_base_conf_write()
745 conf->iobase |= 0xf0; in mvebu_pci_bridge_emul_base_conf_write()
746 conf->iobaseupper = cpu_to_le16(0x0000); in mvebu_pci_bridge_emul_base_conf_write()
747 conf->iolimitupper = cpu_to_le16(0x0000); in mvebu_pci_bridge_emul_base_conf_write()
754 conf->membase = cpu_to_le16(le16_to_cpu(conf->membase) & ~0xfff0); in mvebu_pci_bridge_emul_base_conf_write()
755 conf->memlimit = cpu_to_le16(le16_to_cpu(conf->memlimit) & ~0xfff0); in mvebu_pci_bridge_emul_base_conf_write()
756 conf->membase = cpu_to_le16(le16_to_cpu(conf->membase) | 0xfff0); in mvebu_pci_bridge_emul_base_conf_write()
764 conf->iobase &= ~0xf0; in mvebu_pci_bridge_emul_base_conf_write()
765 conf->iolimit &= ~0xf0; in mvebu_pci_bridge_emul_base_conf_write()
766 conf->iobase |= 0xf0; in mvebu_pci_bridge_emul_base_conf_write()
767 conf->iobaseupper = cpu_to_le16(0x0000); in mvebu_pci_bridge_emul_base_conf_write()
768 conf->iolimitupper = cpu_to_le16(0x0000); in mvebu_pci_bridge_emul_base_conf_write()
774 mvebu_pcie_set_local_bus_nr(port, conf->secondary_bus); in mvebu_pci_bridge_emul_base_conf_write()
797 struct mvebu_pcie_port *port = bridge->data; in mvebu_pci_bridge_emul_pcie_conf_write()
807 * is hard-wired to zero for downstream ports but HW allows in mvebu_pci_bridge_emul_pcie_conf_write()
821 port->slot_power_limit_value) { in mvebu_pci_bridge_emul_pcie_conf_write()
834 * is read-only and can be cleared only by writing 0b to the in mvebu_pci_bridge_emul_pcie_conf_write()
835 * Interrupt Cause RW0C register (PCIE_INT_CAUSE_OFF). So in mvebu_pci_bridge_emul_pcie_conf_write()
836 * clear PME via Interrupt Cause. in mvebu_pci_bridge_emul_pcie_conf_write()
859 struct mvebu_pcie_port *port = bridge->data; in mvebu_pci_bridge_emul_ext_conf_write()
897 * Initialize the configuration space of the PCI-to-PCI bridge
903 struct pci_bridge_emul *bridge = &port->bridge; in mvebu_pci_bridge_emul_init()
910 bridge->conf.vendor = cpu_to_le16(dev_id & 0xffff); in mvebu_pci_bridge_emul_init()
911 bridge->conf.device = cpu_to_le16(dev_id >> 16); in mvebu_pci_bridge_emul_init()
912 bridge->conf.class_revision = cpu_to_le32(dev_rev & 0xff); in mvebu_pci_bridge_emul_init()
916 bridge->conf.iobase = PCI_IO_RANGE_TYPE_32; in mvebu_pci_bridge_emul_init()
917 bridge->conf.iolimit = PCI_IO_RANGE_TYPE_32; in mvebu_pci_bridge_emul_init()
927 bridge->pcie_conf.cap = cpu_to_le16(pcie_cap_ver | PCI_EXP_FLAGS_SLOT); in mvebu_pci_bridge_emul_init()
940 bridge->pcie_conf.slotcap = cpu_to_le32( in mvebu_pci_bridge_emul_init()
941 FIELD_PREP(PCI_EXP_SLTCAP_SPLV, port->slot_power_limit_value) | in mvebu_pci_bridge_emul_init()
942 FIELD_PREP(PCI_EXP_SLTCAP_SPLS, port->slot_power_limit_scale) | in mvebu_pci_bridge_emul_init()
943 FIELD_PREP(PCI_EXP_SLTCAP_PSN, port->port+1)); in mvebu_pci_bridge_emul_init()
944 bridge->pcie_conf.slotsta = cpu_to_le16(PCI_EXP_SLTSTA_PDS); in mvebu_pci_bridge_emul_init()
946 bridge->subsystem_vendor_id = ssdev_id & 0xffff; in mvebu_pci_bridge_emul_init()
947 bridge->subsystem_id = ssdev_id >> 16; in mvebu_pci_bridge_emul_init()
948 bridge->has_pcie = true; in mvebu_pci_bridge_emul_init()
949 bridge->pcie_start = PCIE_CAP_PCIEXP; in mvebu_pci_bridge_emul_init()
950 bridge->data = port; in mvebu_pci_bridge_emul_init()
951 bridge->ops = &mvebu_pci_bridge_emul_ops; in mvebu_pci_bridge_emul_init()
958 return sys->private_data; in sys_to_pcie()
967 for (i = 0; i < pcie->nports; i++) { in mvebu_pcie_find_port()
968 struct mvebu_pcie_port *port = &pcie->ports[i]; in mvebu_pcie_find_port()
970 if (!port->base) in mvebu_pcie_find_port()
973 if (bus->number == 0 && port->devfn == devfn) in mvebu_pcie_find_port()
975 if (bus->number != 0 && in mvebu_pcie_find_port()
976 bus->number >= port->bridge.conf.secondary_bus && in mvebu_pcie_find_port()
977 bus->number <= port->bridge.conf.subordinate_bus) in mvebu_pcie_find_port()
988 struct mvebu_pcie *pcie = bus->sysdata; in mvebu_pcie_wr_conf()
995 return pci_bridge_emul_conf_write(&port->bridge, where, size, val); in mvebu_pcie_wr_conf()
1002 struct mvebu_pcie *pcie = bus->sysdata; in mvebu_pcie_rd_conf()
1009 return pci_bridge_emul_conf_read(&port->bridge, where, size, val); in mvebu_pcie_rd_conf()
1019 struct mvebu_pcie_port *port = d->domain->host_data; in mvebu_pcie_intx_irq_mask()
1024 raw_spin_lock_irqsave(&port->irq_lock, flags); in mvebu_pcie_intx_irq_mask()
1028 raw_spin_unlock_irqrestore(&port->irq_lock, flags); in mvebu_pcie_intx_irq_mask()
1033 struct mvebu_pcie_port *port = d->domain->host_data; in mvebu_pcie_intx_irq_unmask()
1038 raw_spin_lock_irqsave(&port->irq_lock, flags); in mvebu_pcie_intx_irq_unmask()
1042 raw_spin_unlock_irqrestore(&port->irq_lock, flags); in mvebu_pcie_intx_irq_unmask()
1046 .name = "mvebu-INTx",
1054 struct mvebu_pcie_port *port = h->host_data; in mvebu_pcie_intx_irq_map()
1070 struct device *dev = &port->pcie->pdev->dev; in mvebu_pcie_init_irq_domain()
1073 raw_spin_lock_init(&port->irq_lock); in mvebu_pcie_init_irq_domain()
1075 pcie_intc_node = of_get_next_child(port->dn, NULL); in mvebu_pcie_init_irq_domain()
1077 dev_err(dev, "No PCIe Intc node found for %s\n", port->name); in mvebu_pcie_init_irq_domain()
1078 return -ENODEV; in mvebu_pcie_init_irq_domain()
1081 port->intx_irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, in mvebu_pcie_init_irq_domain()
1085 if (!port->intx_irq_domain) { in mvebu_pcie_init_irq_domain()
1086 dev_err(dev, "Failed to get INTx IRQ domain for %s\n", port->name); in mvebu_pcie_init_irq_domain()
1087 return -ENOMEM; in mvebu_pcie_init_irq_domain()
1097 struct device *dev = &port->pcie->pdev->dev; in mvebu_pcie_irq_handler()
1112 if (generic_handle_domain_irq(port->intx_irq_domain, i) == -EINVAL) in mvebu_pcie_irq_handler()
1121 /* Interrupt support on mvebu emulated bridges is not implemented yet */ in mvebu_pcie_map_irq()
1122 if (dev->bus->number == 0) in mvebu_pcie_map_irq()
1134 if (dev->bus->number != 0) in mvebu_pcie_align_resource()
1138 * On the PCI-to-PCI bridge side, the I/O windows must have at in mvebu_pcie_align_resource()
1141 * base address aligned on their size, and their size must be in mvebu_pcie_align_resource()
1148 if (res->flags & IORESOURCE_IO) in mvebu_pcie_align_resource()
1151 else if (res->flags & IORESOURCE_MEM) in mvebu_pcie_align_resource()
1164 ret = of_address_to_resource(np, 0, &port->regs); in mvebu_pcie_map_registers()
1168 return devm_ioremap_resource(&pdev->dev, &port->regs); in mvebu_pcie_map_registers()
1186 *tgt = -1; in mvebu_get_tgt_attr()
1187 *attr = -1; in mvebu_get_tgt_attr()
1191 return -EINVAL; in mvebu_get_tgt_attr()
1217 return -ENOENT; in mvebu_get_tgt_attr()
1226 for (i = 0; i < pcie->nports; i++) { in mvebu_pcie_suspend()
1227 struct mvebu_pcie_port *port = pcie->ports + i; in mvebu_pcie_suspend()
1228 if (!port->base) in mvebu_pcie_suspend()
1230 port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF); in mvebu_pcie_suspend()
1242 for (i = 0; i < pcie->nports; i++) { in mvebu_pcie_resume()
1243 struct mvebu_pcie_port *port = pcie->ports + i; in mvebu_pcie_resume()
1244 if (!port->base) in mvebu_pcie_resume()
1246 mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF); in mvebu_pcie_resume()
1257 clk_put(port->clk); in mvebu_pcie_port_clk_put()
1261 struct mvebu_pcie_port *port, struct device_node *child) in mvebu_pcie_parse_port() argument
1263 struct device *dev = &pcie->pdev->dev; in mvebu_pcie_parse_port()
1268 port->pcie = pcie; in mvebu_pcie_parse_port()
1270 if (of_property_read_u32(child, "marvell,pcie-port", &port->port)) { in mvebu_pcie_parse_port()
1271 dev_warn(dev, "ignoring %pOF, missing pcie-port property\n", in mvebu_pcie_parse_port()
1272 child); in mvebu_pcie_parse_port()
1276 if (of_property_read_u32(child, "marvell,pcie-lane", &port->lane)) in mvebu_pcie_parse_port()
1277 port->lane = 0; in mvebu_pcie_parse_port()
1279 if (!of_property_read_u32(child, "num-lanes", &num_lanes) && num_lanes == 4) in mvebu_pcie_parse_port()
1280 port->is_x4 = true; in mvebu_pcie_parse_port()
1282 port->name = devm_kasprintf(dev, GFP_KERNEL, "pcie%d.%d", port->port, in mvebu_pcie_parse_port()
1283 port->lane); in mvebu_pcie_parse_port()
1284 if (!port->name) { in mvebu_pcie_parse_port()
1285 ret = -ENOMEM; in mvebu_pcie_parse_port()
1289 port->devfn = of_pci_get_devfn(child); in mvebu_pcie_parse_port()
1290 if (port->devfn < 0) in mvebu_pcie_parse_port()
1292 if (PCI_FUNC(port->devfn) != 0) { in mvebu_pcie_parse_port()
1294 port->name); in mvebu_pcie_parse_port()
1298 ret = mvebu_get_tgt_attr(dev->of_node, port->devfn, IORESOURCE_MEM, in mvebu_pcie_parse_port()
1299 &port->mem_target, &port->mem_attr); in mvebu_pcie_parse_port()
1302 port->name); in mvebu_pcie_parse_port()
1306 if (resource_size(&pcie->io) != 0) { in mvebu_pcie_parse_port()
1307 mvebu_get_tgt_attr(dev->of_node, port->devfn, IORESOURCE_IO, in mvebu_pcie_parse_port()
1308 &port->io_target, &port->io_attr); in mvebu_pcie_parse_port()
1310 port->io_target = -1; in mvebu_pcie_parse_port()
1311 port->io_attr = -1; in mvebu_pcie_parse_port()
1315 * Old DT bindings do not contain "intx" interrupt in mvebu_pcie_parse_port()
1316 * so do not fail probing driver when interrupt does not exist. in mvebu_pcie_parse_port()
1318 port->intx_irq = of_irq_get_byname(child, "intx"); in mvebu_pcie_parse_port()
1319 if (port->intx_irq == -EPROBE_DEFER) { in mvebu_pcie_parse_port()
1320 ret = port->intx_irq; in mvebu_pcie_parse_port()
1323 if (port->intx_irq <= 0) { in mvebu_pcie_parse_port()
1325 "%pOF does not contain intx interrupt\n", in mvebu_pcie_parse_port()
1326 port->name, child); in mvebu_pcie_parse_port()
1329 port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset", in mvebu_pcie_parse_port()
1330 port->name); in mvebu_pcie_parse_port()
1331 if (!port->reset_name) { in mvebu_pcie_parse_port()
1332 ret = -ENOMEM; in mvebu_pcie_parse_port()
1336 port->reset_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(child), in mvebu_pcie_parse_port()
1338 port->name); in mvebu_pcie_parse_port()
1339 ret = PTR_ERR_OR_ZERO(port->reset_gpio); in mvebu_pcie_parse_port()
1341 if (ret != -ENOENT) in mvebu_pcie_parse_port()
1344 port->reset_gpio = NULL; in mvebu_pcie_parse_port()
1345 devm_kfree(dev, port->reset_name); in mvebu_pcie_parse_port()
1346 port->reset_name = NULL; in mvebu_pcie_parse_port()
1349 slot_power_limit = of_pci_get_slot_power_limit(child, in mvebu_pcie_parse_port()
1350 &port->slot_power_limit_value, in mvebu_pcie_parse_port()
1351 &port->slot_power_limit_scale); in mvebu_pcie_parse_port()
1354 port->name, in mvebu_pcie_parse_port()
1358 port->clk = of_clk_get_by_name(child, NULL); in mvebu_pcie_parse_port()
1359 if (IS_ERR(port->clk)) { in mvebu_pcie_parse_port()
1360 dev_err(dev, "%s: cannot get clock\n", port->name); in mvebu_pcie_parse_port()
1366 clk_put(port->clk); in mvebu_pcie_parse_port()
1376 devm_kfree(dev, port->reset_name); in mvebu_pcie_parse_port()
1377 port->reset_name = NULL; in mvebu_pcie_parse_port()
1378 devm_kfree(dev, port->name); in mvebu_pcie_parse_port()
1379 port->name = NULL; in mvebu_pcie_parse_port()
1387 * prior to releasing PERST. See table 2-4 in section 2.6.2 AC Specifications
1394 ret = clk_prepare_enable(port->clk); in mvebu_pcie_powerup()
1398 if (port->reset_gpio) { in mvebu_pcie_powerup()
1401 of_property_read_u32(port->dn, "reset-delay-us", in mvebu_pcie_powerup()
1406 gpiod_set_value_cansleep(port->reset_gpio, 0); in mvebu_pcie_powerup()
1419 gpiod_set_value_cansleep(port->reset_gpio, 1); in mvebu_pcie_powerdown()
1421 clk_disable_unprepare(port->clk); in mvebu_pcie_powerdown()
1431 struct device *dev = &pcie->pdev->dev; in mvebu_pcie_parse_request_resources()
1436 mvebu_mbus_get_pcie_mem_aperture(&pcie->mem); in mvebu_pcie_parse_request_resources()
1437 if (resource_size(&pcie->mem) == 0) { in mvebu_pcie_parse_request_resources()
1439 return -EINVAL; in mvebu_pcie_parse_request_resources()
1442 pcie->mem.name = "PCI MEM"; in mvebu_pcie_parse_request_resources()
1443 pci_add_resource(&bridge->windows, &pcie->mem); in mvebu_pcie_parse_request_resources()
1444 ret = devm_request_resource(dev, &iomem_resource, &pcie->mem); in mvebu_pcie_parse_request_resources()
1449 mvebu_mbus_get_pcie_io_aperture(&pcie->io); in mvebu_pcie_parse_request_resources()
1451 if (resource_size(&pcie->io) != 0) { in mvebu_pcie_parse_request_resources()
1452 pcie->realio.flags = pcie->io.flags; in mvebu_pcie_parse_request_resources()
1453 pcie->realio.start = PCIBIOS_MIN_IO; in mvebu_pcie_parse_request_resources()
1454 pcie->realio.end = min_t(resource_size_t, in mvebu_pcie_parse_request_resources()
1455 IO_SPACE_LIMIT - SZ_64K, in mvebu_pcie_parse_request_resources()
1456 resource_size(&pcie->io) - 1); in mvebu_pcie_parse_request_resources()
1457 pcie->realio.name = "PCI I/O"; in mvebu_pcie_parse_request_resources()
1459 ret = devm_pci_remap_iospace(dev, &pcie->realio, pcie->io.start); in mvebu_pcie_parse_request_resources()
1463 pci_add_resource(&bridge->windows, &pcie->realio); in mvebu_pcie_parse_request_resources()
1464 ret = devm_request_resource(dev, &ioport_resource, &pcie->realio); in mvebu_pcie_parse_request_resources()
1474 struct device *dev = &pdev->dev; in mvebu_pcie_probe()
1477 struct device_node *np = dev->of_node; in mvebu_pcie_probe()
1478 struct device_node *child; in mvebu_pcie_probe() local
1483 return -ENOMEM; in mvebu_pcie_probe()
1486 pcie->pdev = pdev; in mvebu_pcie_probe()
1495 pcie->ports = devm_kcalloc(dev, num, sizeof(*pcie->ports), GFP_KERNEL); in mvebu_pcie_probe()
1496 if (!pcie->ports) in mvebu_pcie_probe()
1497 return -ENOMEM; in mvebu_pcie_probe()
1500 for_each_available_child_of_node(np, child) { in mvebu_pcie_probe()
1501 struct mvebu_pcie_port *port = &pcie->ports[i]; in mvebu_pcie_probe()
1503 ret = mvebu_pcie_parse_port(pcie, port, child); in mvebu_pcie_probe()
1505 of_node_put(child); in mvebu_pcie_probe()
1511 port->dn = child; in mvebu_pcie_probe()
1514 pcie->nports = i; in mvebu_pcie_probe()
1516 for (i = 0; i < pcie->nports; i++) { in mvebu_pcie_probe()
1517 struct mvebu_pcie_port *port = &pcie->ports[i]; in mvebu_pcie_probe()
1518 int irq = port->intx_irq; in mvebu_pcie_probe()
1520 child = port->dn; in mvebu_pcie_probe()
1521 if (!child) in mvebu_pcie_probe()
1528 port->base = mvebu_pcie_map_registers(pdev, child, port); in mvebu_pcie_probe()
1529 if (IS_ERR(port->base)) { in mvebu_pcie_probe()
1530 dev_err(dev, "%s: cannot map registers\n", port->name); in mvebu_pcie_probe()
1531 port->base = NULL; in mvebu_pcie_probe()
1539 port->name); in mvebu_pcie_probe()
1540 devm_iounmap(dev, port->base); in mvebu_pcie_probe()
1541 port->base = NULL; in mvebu_pcie_probe()
1550 port->name); in mvebu_pcie_probe()
1551 pci_bridge_emul_cleanup(&port->bridge); in mvebu_pcie_probe()
1552 devm_iounmap(dev, port->base); in mvebu_pcie_probe()
1553 port->base = NULL; in mvebu_pcie_probe()
1568 * independent interrupt lines, independent window and memory in mvebu_pcie_probe()
1570 * peer-to-peer support between PCIe devices behind different in mvebu_pcie_probe()
1579 * host bridges into one bus zero, like in classic multi-port in mvebu_pcie_probe()
1582 * This means that pci-mvebu.c driver provides "virtual" bus 0 in mvebu_pcie_probe()
1599 * available (applies for pre-XP PCIe controllers) then Type 0 in mvebu_pcie_probe()
1619 * option 2. is not available on pre-XP PCIe controllers. Hence in mvebu_pcie_probe()
1642 bridge->sysdata = pcie; in mvebu_pcie_probe()
1643 bridge->ops = &mvebu_pcie_ops; in mvebu_pcie_probe()
1644 bridge->child_ops = &mvebu_pcie_child_ops; in mvebu_pcie_probe()
1645 bridge->align_resource = mvebu_pcie_align_resource; in mvebu_pcie_probe()
1646 bridge->map_irq = mvebu_pcie_map_irq; in mvebu_pcie_probe()
1660 pci_stop_root_bus(bridge->bus); in mvebu_pcie_remove()
1661 pci_remove_root_bus(bridge->bus); in mvebu_pcie_remove()
1664 for (i = 0; i < pcie->nports; i++) { in mvebu_pcie_remove()
1665 struct mvebu_pcie_port *port = &pcie->ports[i]; in mvebu_pcie_remove()
1666 int irq = port->intx_irq; in mvebu_pcie_remove()
1668 if (!port->base) in mvebu_pcie_remove()
1676 /* Mask all interrupt sources. */ in mvebu_pcie_remove()
1679 /* Clear all interrupt causes. */ in mvebu_pcie_remove()
1686 if (port->intx_irq_domain) in mvebu_pcie_remove()
1687 irq_domain_remove(port->intx_irq_domain); in mvebu_pcie_remove()
1690 pci_bridge_emul_cleanup(&port->bridge); in mvebu_pcie_remove()
1701 if (port->iowin.size) in mvebu_pcie_remove()
1702 mvebu_pcie_del_windows(port, port->iowin.base, port->iowin.size); in mvebu_pcie_remove()
1703 if (port->memwin.size) in mvebu_pcie_remove()
1704 mvebu_pcie_del_windows(port, port->memwin.base, port->memwin.size); in mvebu_pcie_remove()
1712 { .compatible = "marvell,armada-xp-pcie", },
1713 { .compatible = "marvell,armada-370-pcie", },
1714 { .compatible = "marvell,dove-pcie", },
1715 { .compatible = "marvell,kirkwood-pcie", },
1725 .name = "mvebu-pcie",