162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Implement the default iomap interfaces 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * (C) Copyright 2004 Linus Torvalds 662306a36Sopenharmony_ci * (C) Copyright 2006 Ralf Baechle <ralf@linux-mips.org> 762306a36Sopenharmony_ci * (C) Copyright 2007 MIPS Technologies, Inc. 862306a36Sopenharmony_ci * written by Ralf Baechle <ralf@linux-mips.org> 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci#include <linux/pci.h> 1162306a36Sopenharmony_ci#include <linux/export.h> 1262306a36Sopenharmony_ci#include <asm/io.h> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#ifdef CONFIG_PCI_DRIVERS_LEGACY 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_civoid __iomem *__pci_ioport_map(struct pci_dev *dev, 1762306a36Sopenharmony_ci unsigned long port, unsigned int nr) 1862306a36Sopenharmony_ci{ 1962306a36Sopenharmony_ci struct pci_controller *ctrl = dev->bus->sysdata; 2062306a36Sopenharmony_ci unsigned long base = ctrl->io_map_base; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci /* This will eventually become a BUG_ON but for now be gentle */ 2362306a36Sopenharmony_ci if (unlikely(!ctrl->io_map_base)) { 2462306a36Sopenharmony_ci struct pci_bus *bus = dev->bus; 2562306a36Sopenharmony_ci char name[8]; 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci while (bus->parent) 2862306a36Sopenharmony_ci bus = bus->parent; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci ctrl->io_map_base = base = mips_io_port_base; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number); 3362306a36Sopenharmony_ci printk(KERN_WARNING "io_map_base of root PCI bus %s unset. " 3462306a36Sopenharmony_ci "Trying to continue but you better\nfix this issue or " 3562306a36Sopenharmony_ci "report it to linux-mips@vger.kernel.org or your " 3662306a36Sopenharmony_ci "vendor.\n", name); 3762306a36Sopenharmony_ci#ifdef CONFIG_PCI_DOMAINS 3862306a36Sopenharmony_ci panic("To avoid data corruption io_map_base MUST be set with " 3962306a36Sopenharmony_ci "multiple PCI domains."); 4062306a36Sopenharmony_ci#endif 4162306a36Sopenharmony_ci } 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci return (void __iomem *) (ctrl->io_map_base + port); 4462306a36Sopenharmony_ci} 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#endif /* CONFIG_PCI_DRIVERS_LEGACY */ 47