aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/drivers/pci
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-04-20 03:14:29 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-04-20 03:14:29 -0400
commita3c0e0d0032d5bbfd7dc04827a257c717d432a5b (patch)
treeba853dce3346b33c44cd4d224ca662632186594e /arch/sh/drivers/pci
parent9833385131fc4e8c52f95320ab899051d1c06831 (diff)
sh: pci: Consolidate pcibios_align_resource() definitions.
This introduces a saner pcibios_align_resource() that can be used regardless of whether pci-auto or pci-new are being used, and consolidates it in pci-lib.c. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/drivers/pci')
-rw-r--r--arch/sh/drivers/pci/pci-lib.c42
-rw-r--r--arch/sh/drivers/pci/pci-new.c23
-rw-r--r--arch/sh/drivers/pci/pci.c23
3 files changed, 42 insertions, 46 deletions
diff --git a/arch/sh/drivers/pci/pci-lib.c b/arch/sh/drivers/pci/pci-lib.c
index 1a43a350d574..8ab1a2d1b483 100644
--- a/arch/sh/drivers/pci/pci-lib.c
+++ b/arch/sh/drivers/pci/pci-lib.c
@@ -4,6 +4,41 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/pci.h> 5#include <linux/pci.h>
6 6
7unsigned 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
7int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 42int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
8 enum pci_mmap_state mmap_state, int write_combine) 43 enum pci_mmap_state mmap_state, int write_combine)
9{ 44{
@@ -24,3 +59,10 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
24 vma->vm_end - vma->vm_start, 59 vma->vm_end - vma->vm_start,
25 vma->vm_page_prot); 60 vma->vm_page_prot);
26} 61}
62
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
diff --git a/arch/sh/drivers/pci/pci-new.c b/arch/sh/drivers/pci/pci-new.c
index 097eb8811120..4e9251f3d090 100644
--- a/arch/sh/drivers/pci/pci-new.c
+++ b/arch/sh/drivers/pci/pci-new.c
@@ -129,29 +129,6 @@ pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
129 res->end = region->end + offset; 129 res->end = region->end + offset;
130} 130}
131 131
132void pcibios_align_resource(void *data, struct resource *res,
133 resource_size_t size, resource_size_t align)
134 __attribute__ ((weak));
135
136/*
137 * We need to avoid collisions with `mirrored' VGA ports
138 * and other strange ISA hardware, so we always want the
139 * addresses to be allocated in the 0x000-0x0ff region
140 * modulo 0x400.
141 */
142void pcibios_align_resource(void *data, struct resource *res,
143 resource_size_t size, resource_size_t align)
144{
145 if (res->flags & IORESOURCE_IO) {
146 resource_size_t start = res->start;
147
148 if (start & 0x300) {
149 start = (start + 0x3ff) & ~0x3ff;
150 res->start = start;
151 }
152 }
153}
154
155int pcibios_enable_device(struct pci_dev *dev, int mask) 132int pcibios_enable_device(struct pci_dev *dev, int mask)
156{ 133{
157 u16 cmd, old_cmd; 134 u16 cmd, old_cmd;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 6d659cd93c9d..f670988e033d 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -86,29 +86,6 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
86 res->end = region->end; 86 res->end = region->end;
87} 87}
88 88
89void pcibios_align_resource(void *data, struct resource *res,
90 resource_size_t size, resource_size_t align)
91 __attribute__ ((weak));
92
93/*
94 * We need to avoid collisions with `mirrored' VGA ports
95 * and other strange ISA hardware, so we always want the
96 * addresses to be allocated in the 0x000-0x0ff region
97 * modulo 0x400.
98 */
99void pcibios_align_resource(void *data, struct resource *res,
100 resource_size_t size, resource_size_t align)
101{
102 if (res->flags & IORESOURCE_IO) {
103 resource_size_t start = res->start;
104
105 if (start & 0x300) {
106 start = (start + 0x3ff) & ~0x3ff;
107 res->start = start;
108 }
109 }
110}
111
112int pcibios_enable_device(struct pci_dev *dev, int mask) 89int pcibios_enable_device(struct pci_dev *dev, int mask)
113{ 90{
114 u16 cmd, old_cmd; 91 u16 cmd, old_cmd;