Lines Matching +full:gemini +full:- +full:pci
1 // SPDX-License-Identifier: GPL-2.0
3 * Support for Faraday Technology FTPC100 PCI Controller
7 * Based on the out-of-tree OpenWRT patch for Cortina Gemini:
10 * Based on SL2312 PCI controller code
21 #include <linux/pci.h>
30 #include "../pci.h"
38 #define FTPCI_CTRL 0x08 /* PCI control signal */
40 #define FTPCI_CONFIG 0x28 /* PCI configuration command register */
79 * Bit 31..20 defines the PCI side memory base
106 * struct faraday_pci_variant - encodes IP block differences
165 return -EINVAL; in faraday_res_to_memcfg()
171 pr_warn("truncated PCI memory base\n"); in faraday_res_to_memcfg()
174 pr_debug("Translated pci base @%pap, size %pap to config %08x\n", in faraday_res_to_memcfg()
187 p->base + FTPCI_CONFIG); in faraday_raw_pci_read_config()
189 *value = readl(p->base + FTPCI_DATA); in faraday_raw_pci_read_config()
202 struct faraday_pci *p = bus->sysdata; in faraday_pci_read_config()
204 dev_dbg(&bus->dev, in faraday_pci_read_config()
208 return faraday_raw_pci_read_config(p, bus->number, fn, config, size, value); in faraday_pci_read_config()
219 p->base + FTPCI_CONFIG); in faraday_raw_pci_write_config()
223 writel(value, p->base + FTPCI_DATA); in faraday_raw_pci_write_config()
226 writew(value, p->base + FTPCI_DATA + (config & 3)); in faraday_raw_pci_write_config()
229 writeb(value, p->base + FTPCI_DATA + (config & 3)); in faraday_raw_pci_write_config()
241 struct faraday_pci *p = bus->sysdata; in faraday_pci_write_config()
243 dev_dbg(&bus->dev, in faraday_pci_write_config()
247 return faraday_raw_pci_write_config(p, bus->number, fn, config, size, in faraday_pci_write_config()
303 generic_handle_domain_irq(p->irqdomain, i); in faraday_pci_irq_handler()
310 .name = "PCI",
320 irq_set_chip_data(irq, domain->host_data); in faraday_pci_irq_map()
331 struct device_node *intc = of_get_next_child(p->dev->of_node, NULL); in faraday_pci_setup_cascaded_irq()
336 dev_err(p->dev, "missing child interrupt-controller node\n"); in faraday_pci_setup_cascaded_irq()
337 return -EINVAL; in faraday_pci_setup_cascaded_irq()
340 /* All PCI IRQs cascade off this one */ in faraday_pci_setup_cascaded_irq()
343 dev_err(p->dev, "failed to get parent IRQ\n"); in faraday_pci_setup_cascaded_irq()
345 return irq ?: -EINVAL; in faraday_pci_setup_cascaded_irq()
348 p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX, in faraday_pci_setup_cascaded_irq()
351 if (!p->irqdomain) { in faraday_pci_setup_cascaded_irq()
352 dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n"); in faraday_pci_setup_cascaded_irq()
353 return -EINVAL; in faraday_pci_setup_cascaded_irq()
359 irq_create_mapping(p->irqdomain, i); in faraday_pci_setup_cascaded_irq()
366 struct device *dev = p->dev; in faraday_pci_parse_map_dma_ranges()
377 resource_list_for_each_entry(entry, &bridge->dma_ranges) { in faraday_pci_parse_map_dma_ranges()
378 u64 pci_addr = entry->res->start - entry->offset; in faraday_pci_parse_map_dma_ranges()
379 u64 end = entry->res->end - entry->offset; in faraday_pci_parse_map_dma_ranges()
383 resource_size(entry->res), &val); in faraday_pci_parse_map_dma_ranges()
387 return -EINVAL; in faraday_pci_parse_map_dma_ranges()
390 dev_info(dev, "DMA MEM%d BASE: 0x%016llx -> 0x%016llx config %08x\n", in faraday_pci_parse_map_dma_ranges()
396 dev_err(dev, "ignore extraneous dma-range %d\n", i); in faraday_pci_parse_map_dma_ranges()
408 struct device *dev = &pdev->dev; in faraday_pci_probe()
423 return -ENOMEM; in faraday_pci_probe()
425 host->ops = &faraday_pci_ops; in faraday_pci_probe()
427 host->sysdata = p; in faraday_pci_probe()
428 p->dev = dev; in faraday_pci_probe()
434 p->bus_clk = devm_clk_get_enabled(dev, "PCICLK"); in faraday_pci_probe()
435 if (IS_ERR(p->bus_clk)) in faraday_pci_probe()
436 return PTR_ERR(p->bus_clk); in faraday_pci_probe()
438 p->base = devm_platform_ioremap_resource(pdev, 0); in faraday_pci_probe()
439 if (IS_ERR(p->base)) in faraday_pci_probe()
440 return PTR_ERR(p->base); in faraday_pci_probe()
442 win = resource_list_first_type(&host->windows, IORESOURCE_IO); in faraday_pci_probe()
444 io = win->res; in faraday_pci_probe()
445 if (!faraday_res_to_memcfg(io->start - win->offset, in faraday_pci_probe()
448 writel(val, p->base + FTPCI_IOSIZE); in faraday_pci_probe()
451 return -EINVAL; in faraday_pci_probe()
456 val = readl(p->base + FTPCI_CTRL); in faraday_pci_probe()
460 writel(val, p->base + FTPCI_CTRL); in faraday_pci_probe()
463 if (variant->cascaded_irq) { in faraday_pci_probe()
472 if (!IS_ERR(p->bus_clk)) { in faraday_pci_probe()
478 rate = clk_get_rate(p->bus_clk); in faraday_pci_probe()
483 ret = clk_set_rate(p->bus_clk, 66000000); in faraday_pci_probe()
492 rate = clk_get_rate(p->bus_clk); in faraday_pci_probe()
508 p->bus = host->bus; in faraday_pci_probe()
509 p->bus->max_bus_speed = max_bus_speed; in faraday_pci_probe()
510 p->bus->cur_bus_speed = cur_bus_speed; in faraday_pci_probe()
512 pci_bus_assign_resources(p->bus); in faraday_pci_probe()
513 pci_bus_add_devices(p->bus); in faraday_pci_probe()
536 .compatible = "faraday,ftpci100-dual",