Lines Matching +full:loongson +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
3 * Loongson PCI Host Controller Driver
12 #include <linux/pci-acpi.h>
13 #include <linux/pci-ecam.h>
39 #define FLAG_CFG1 BIT(1)
58 dev->class = PCI_CLASS_BRIDGE_PCI_NORMAL; in bridge_class_quirk()
73 pdev->mmio_always_on = 1; in system_bus_quirk()
74 pdev->non_compliant_bars = 1; in system_bus_quirk()
84 * Some Loongson PCIe ports have hardware limitations on their Maximum Read
87 * bridges. However, some MIPS Loongson firmware doesn't set MRRS properly,
93 struct pci_bus *bus = pdev->bus; in loongson_set_min_mrrs_quirk()
96 { PCI_VDEVICE(LOONGSON, DEV_LS2K_PCIE_PORT0) }, in loongson_set_min_mrrs_quirk()
97 { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT0) }, in loongson_set_min_mrrs_quirk()
98 { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT1) }, in loongson_set_min_mrrs_quirk()
99 { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT2) }, in loongson_set_min_mrrs_quirk()
100 { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT3) }, in loongson_set_min_mrrs_quirk()
101 { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT4) }, in loongson_set_min_mrrs_quirk()
102 { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT5) }, in loongson_set_min_mrrs_quirk()
103 { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT6) }, in loongson_set_min_mrrs_quirk()
109 bridge = bus->self; in loongson_set_min_mrrs_quirk()
110 bus = bus->parent; in loongson_set_min_mrrs_quirk()
126 struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->bus); in loongson_mrrs_quirk()
128 bridge->no_inc_mrrs = 1; in loongson_mrrs_quirk()
149 pdev->pin = 1 + (PCI_FUNC(pdev->devfn) & 3); in loongson_pci_pin_quirk()
171 return (struct loongson_pci *)(bus->sysdata); in pci_bus_to_loongson_pci()
173 cfg = bus->sysdata; in pci_bus_to_loongson_pci()
174 return (struct loongson_pci *)(cfg->priv); in pci_bus_to_loongson_pci()
181 unsigned char busnum = bus->number; in cfg0_map()
184 addroff |= BIT(24); /* Type 1 Access */ in cfg0_map()
188 return priv->cfg0_base + addroff; in cfg0_map()
195 unsigned char busnum = bus->number; in cfg1_map()
198 addroff |= BIT(28); /* Type 1 Access */ in cfg1_map()
202 return priv->cfg1_base + addroff; in cfg1_map()
223 if ((priv->data->flags & FLAG_DEV_FIX) && bus->self) { in pci_loongson_map_bus()
228 /* Don't access non-existent devices */ in pci_loongson_map_bus()
229 if (priv->data->flags & FLAG_DEV_HIDDEN) { in pci_loongson_map_bus()
235 if (where < PCI_CFG_SPACE_SIZE && priv->cfg0_base) in pci_loongson_map_bus()
239 if (where < PCI_CFG_SPACE_EXP_SIZE && priv->cfg1_base) in pci_loongson_map_bus()
265 /* LS2K/LS7A accept 8/16/32-bit PCI config operations */
272 /* RS780/SR5690 only accept 32-bit PCI config operations */
295 { .compatible = "loongson,ls2k-pci",
297 { .compatible = "loongson,ls7a-pci",
299 { .compatible = "loongson,rs780e-pci",
307 struct device *dev = &pdev->dev; in loongson_pci_probe()
308 struct device_node *node = dev->of_node; in loongson_pci_probe()
313 return -ENODEV; in loongson_pci_probe()
317 return -ENODEV; in loongson_pci_probe()
320 priv->pdev = pdev; in loongson_pci_probe()
321 priv->data = of_device_get_match_data(dev); in loongson_pci_probe()
323 if (priv->data->flags & FLAG_CFG0) { in loongson_pci_probe()
328 priv->cfg0_base = devm_pci_remap_cfg_resource(dev, regs); in loongson_pci_probe()
329 if (IS_ERR(priv->cfg0_base)) in loongson_pci_probe()
330 return PTR_ERR(priv->cfg0_base); in loongson_pci_probe()
334 if (priv->data->flags & FLAG_CFG1) { in loongson_pci_probe()
335 regs = platform_get_resource(pdev, IORESOURCE_MEM, 1); in loongson_pci_probe()
339 priv->cfg1_base = devm_pci_remap_cfg_resource(dev, regs); in loongson_pci_probe()
340 if (IS_ERR(priv->cfg1_base)) in loongson_pci_probe()
341 priv->cfg1_base = NULL; in loongson_pci_probe()
345 bridge->sysdata = priv; in loongson_pci_probe()
346 bridge->ops = priv->data->ops; in loongson_pci_probe()
347 bridge->map_irq = loongson_map_irq; in loongson_pci_probe()
354 .name = "loongson-pci",
367 struct device *dev = cfg->parent; in loongson_pci_ecam_init()
373 return -ENOMEM; in loongson_pci_ecam_init()
377 return -ENOMEM; in loongson_pci_ecam_init()
379 cfg->priv = priv; in loongson_pci_ecam_init()
380 data->flags = FLAG_CFG1 | FLAG_DEV_HIDDEN; in loongson_pci_ecam_init()
381 priv->data = data; in loongson_pci_ecam_init()
382 priv->cfg1_base = cfg->win - (cfg->busr.start << 16); in loongson_pci_ecam_init()