2 * Implement the default iomap interfaces
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>
10 #include <linux/module.h>
13 static void __iomem
*ioport_map_pci(struct pci_dev
*dev
,
14 unsigned long port
, unsigned int nr
)
16 struct pci_controller
*ctrl
= dev
->bus
->sysdata
;
17 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
;
27 ctrl
->io_map_base
= base
= mips_io_port_base
;
29 sprintf(name
, "%04x:%02x", pci_domain_nr(bus
), bus
->number
);
30 printk(KERN_WARNING
"io_map_base of root PCI bus %s unset. "
31 "Trying to continue but you better\nfix this issue or "
32 "report it to linux-mips@linux-mips.org or your "
34 #ifdef CONFIG_PCI_DOMAINS
35 panic("To avoid data corruption io_map_base MUST be set with "
36 "multiple PCI domains.");
40 return (void __iomem
*) (ctrl
->io_map_base
+ port
);
44 * Create a virtual mapping cookie for a PCI BAR (memory or IO)
46 void __iomem
*pci_iomap(struct pci_dev
*dev
, int bar
, unsigned long maxlen
)
48 resource_size_t start
= pci_resource_start(dev
, bar
);
49 resource_size_t len
= pci_resource_len(dev
, bar
);
50 unsigned long flags
= pci_resource_flags(dev
, bar
);
54 if (maxlen
&& len
> maxlen
)
56 if (flags
& IORESOURCE_IO
)
57 return ioport_map_pci(dev
, start
, len
);
58 if (flags
& IORESOURCE_MEM
) {
59 if (flags
& IORESOURCE_CACHEABLE
)
60 return ioremap(start
, len
);
61 return ioremap_nocache(start
, len
);
67 EXPORT_SYMBOL(pci_iomap
);
69 void pci_iounmap(struct pci_dev
*dev
, void __iomem
* addr
)
74 EXPORT_SYMBOL(pci_iounmap
);