Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Implement the default iomap interfaces
0004  *
0005  * (C) Copyright 2004 Linus Torvalds
0006  * (C) Copyright 2006 Ralf Baechle <ralf@linux-mips.org>
0007  * (C) Copyright 2007 MIPS Technologies, Inc.
0008  *     written by Ralf Baechle <ralf@linux-mips.org>
0009  */
0010 #include <linux/pci.h>
0011 #include <linux/export.h>
0012 #include <asm/io.h>
0013 
0014 #ifdef CONFIG_PCI_DRIVERS_LEGACY
0015 
0016 void __iomem *__pci_ioport_map(struct pci_dev *dev,
0017                    unsigned long port, unsigned int nr)
0018 {
0019     struct pci_controller *ctrl = dev->bus->sysdata;
0020     unsigned long base = ctrl->io_map_base;
0021 
0022     /* This will eventually become a BUG_ON but for now be gentle */
0023     if (unlikely(!ctrl->io_map_base)) {
0024         struct pci_bus *bus = dev->bus;
0025         char name[8];
0026 
0027         while (bus->parent)
0028             bus = bus->parent;
0029 
0030         ctrl->io_map_base = base = mips_io_port_base;
0031 
0032         sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
0033         printk(KERN_WARNING "io_map_base of root PCI bus %s unset.  "
0034                "Trying to continue but you better\nfix this issue or "
0035                "report it to linux-mips@vger.kernel.org or your "
0036                "vendor.\n", name);
0037 #ifdef CONFIG_PCI_DOMAINS
0038         panic("To avoid data corruption io_map_base MUST be set with "
0039               "multiple PCI domains.");
0040 #endif
0041     }
0042 
0043     return (void __iomem *) (ctrl->io_map_base + port);
0044 }
0045 
0046 #endif /* CONFIG_PCI_DRIVERS_LEGACY */