iomap-pci.c 1.3 KB

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