blob: a9cb28813f0bc3ebee5be26d6f48f87e824a1fd9 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Ralf Baechle140c1722006-12-07 15:35:43 +01002/*
3 * Implement the default iomap interfaces
4 *
5 * (C) Copyright 2004 Linus Torvalds
6 * (C) Copyright 2006 Ralf Baechle <ralf@linux-mips.org>
7 * (C) Copyright 2007 MIPS Technologies, Inc.
8 * written by Ralf Baechle <ralf@linux-mips.org>
9 */
10#include <linux/pci.h>
Paul Gortmaker527581b2016-08-21 15:58:15 -040011#include <linux/export.h>
Ralf Baechle140c1722006-12-07 15:35:43 +010012#include <asm/io.h>
13
Paul Burtonc5611df2016-10-05 18:18:12 +010014#ifdef CONFIG_PCI_DRIVERS_LEGACY
15
Michael S. Tsirkin0f3b3952012-01-30 00:23:38 +020016void __iomem *__pci_ioport_map(struct pci_dev *dev,
17 unsigned long port, unsigned int nr)
Ralf Baechle140c1722006-12-07 15:35:43 +010018{
19 struct pci_controller *ctrl = dev->bus->sysdata;
20 unsigned long base = ctrl->io_map_base;
21
22 /* This will eventually become a BUG_ON but for now be gentle */
23 if (unlikely(!ctrl->io_map_base)) {
24 struct pci_bus *bus = dev->bus;
25 char name[8];
26
27 while (bus->parent)
28 bus = bus->parent;
29
30 ctrl->io_map_base = base = mips_io_port_base;
31
32 sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
33 printk(KERN_WARNING "io_map_base of root PCI bus %s unset. "
34 "Trying to continue but you better\nfix this issue or "
Lukas Bulwahn057a14d2021-02-22 17:19:03 +010035 "report it to linux-mips@vger.kernel.org or your "
Ralf Baechle140c1722006-12-07 15:35:43 +010036 "vendor.\n", name);
37#ifdef CONFIG_PCI_DOMAINS
38 panic("To avoid data corruption io_map_base MUST be set with "
39 "multiple PCI domains.");
40#endif
41 }
42
43 return (void __iomem *) (ctrl->io_map_base + port);
44}
45
Paul Burtonc5611df2016-10-05 18:18:12 +010046#endif /* CONFIG_PCI_DRIVERS_LEGACY */