blob: 8ed3f25a9047d06b80cfeffa495cb2f18984a306 [file] [log] [blame]
Ralf Baechle140c1722006-12-07 15:35:43 +01001/*
2 * Implement the default iomap interfaces
3 *
4 * (C) Copyright 2004 Linus Torvalds
5 * (C) Copyright 2006 Ralf Baechle <ralf@linux-mips.org>
6 * (C) Copyright 2007 MIPS Technologies, Inc.
7 * written by Ralf Baechle <ralf@linux-mips.org>
8 */
9#include <linux/pci.h>
Paul Gortmaker527581b2016-08-21 15:58:15 -040010#include <linux/export.h>
Ralf Baechle140c1722006-12-07 15:35:43 +010011#include <asm/io.h>
12
Paul Burtonc5611df2016-10-05 18:18:12 +010013#ifdef CONFIG_PCI_DRIVERS_LEGACY
14
Michael S. Tsirkin0f3b3952012-01-30 00:23:38 +020015void __iomem *__pci_ioport_map(struct pci_dev *dev,
16 unsigned long port, unsigned int nr)
Ralf Baechle140c1722006-12-07 15:35:43 +010017{
18 struct pci_controller *ctrl = dev->bus->sysdata;
19 unsigned long base = ctrl->io_map_base;
20
21 /* This will eventually become a BUG_ON but for now be gentle */
22 if (unlikely(!ctrl->io_map_base)) {
23 struct pci_bus *bus = dev->bus;
24 char name[8];
25
26 while (bus->parent)
27 bus = bus->parent;
28
29 ctrl->io_map_base = base = mips_io_port_base;
30
31 sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
32 printk(KERN_WARNING "io_map_base of root PCI bus %s unset. "
33 "Trying to continue but you better\nfix this issue or "
34 "report it to linux-mips@linux-mips.org or your "
35 "vendor.\n", name);
36#ifdef CONFIG_PCI_DOMAINS
37 panic("To avoid data corruption io_map_base MUST be set with "
38 "multiple PCI domains.");
39#endif
40 }
41
42 return (void __iomem *) (ctrl->io_map_base + port);
43}
44
Paul Burtonc5611df2016-10-05 18:18:12 +010045#endif /* CONFIG_PCI_DRIVERS_LEGACY */
46
Ralf Baechle140c1722006-12-07 15:35:43 +010047void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
48{
49 iounmap(addr);
50}
51
52EXPORT_SYMBOL(pci_iounmap);