^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Implement the default iomap interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * (C) Copyright 2004 Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * (C) Copyright 2006 Ralf Baechle <ralf@linux-mips.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * (C) Copyright 2007 MIPS Technologies, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * written by Ralf Baechle <ralf@linux-mips.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #ifdef CONFIG_PCI_DRIVERS_LEGACY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) void __iomem *__pci_ioport_map(struct pci_dev *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) unsigned long port, unsigned int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct pci_controller *ctrl = dev->bus->sysdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) unsigned long base = ctrl->io_map_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* This will eventually become a BUG_ON but for now be gentle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (unlikely(!ctrl->io_map_base)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct pci_bus *bus = dev->bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) char name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) while (bus->parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) bus = bus->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ctrl->io_map_base = base = mips_io_port_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) printk(KERN_WARNING "io_map_base of root PCI bus %s unset. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) "Trying to continue but you better\nfix this issue or "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) "report it to linux-mips@linux-mips.org or your "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) "vendor.\n", name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #ifdef CONFIG_PCI_DOMAINS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) panic("To avoid data corruption io_map_base MUST be set with "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) "multiple PCI domains.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return (void __iomem *) (ctrl->io_map_base + port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif /* CONFIG_PCI_DRIVERS_LEGACY */