blob: 8ab1a2d1b4832d55d07e4043574575652a78721e [file] [log] [blame]
Paul Mundt98333852009-04-20 15:51:45 +09001#include <linux/kernel.h>
2#include <linux/mm.h>
3#include <linux/init.h>
4#include <linux/types.h>
5#include <linux/pci.h>
6
Paul Mundta3c0e0d2009-04-20 16:14:29 +09007unsigned long PCIBIOS_MIN_IO = 0x0000;
8unsigned long PCIBIOS_MIN_MEM = 0;
9
10/*
11 * We need to avoid collisions with `mirrored' VGA ports
12 * and other strange ISA hardware, so we always want the
13 * addresses to be allocated in the 0x000-0x0ff region
14 * modulo 0x400.
15 */
16void pcibios_align_resource(void *data, struct resource *res,
17 resource_size_t size, resource_size_t align)
18{
19 struct pci_dev *dev = data;
20 struct pci_channel *chan = dev->sysdata;
21 resource_size_t start = res->start;
22
23 if (res->flags & IORESOURCE_IO) {
24 if (start < PCIBIOS_MIN_IO + chan->io_resource->start)
25 start = PCIBIOS_MIN_IO + chan->io_resource->start;
26
27 /*
28 * Put everything into 0x00-0xff region modulo 0x400.
29 */
30 if (start & 0x300) {
31 start = (start + 0x3ff) & ~0x3ff;
32 res->start = start;
33 }
34 } else if (res->flags & IORESOURCE_MEM) {
35 if (start < PCIBIOS_MIN_MEM + chan->mem_resource->start)
36 start = PCIBIOS_MIN_MEM + chan->mem_resource->start;
37 }
38
39 res->start = start;
40}
41
Paul Mundt98333852009-04-20 15:51:45 +090042int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
43 enum pci_mmap_state mmap_state, int write_combine)
44{
45 /*
46 * I/O space can be accessed via normal processor loads and stores on
47 * this platform but for now we elect not to do this and portable
48 * drivers should not do this anyway.
49 */
50 if (mmap_state == pci_mmap_io)
51 return -EINVAL;
52
53 /*
54 * Ignore write-combine; for now only return uncached mappings.
55 */
56 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
57
58 return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
59 vma->vm_end - vma->vm_start,
60 vma->vm_page_prot);
61}
Paul Mundta3c0e0d2009-04-20 16:14:29 +090062
63#ifdef CONFIG_HOTPLUG
64EXPORT_SYMBOL(pcibios_resource_to_bus);
65EXPORT_SYMBOL(pcibios_bus_to_resource);
66EXPORT_SYMBOL(PCIBIOS_MIN_IO);
67EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
68#endif