aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-11-12 17:27:39 -0500
committerPaul Mackerras <paulus@samba.org>2006-12-04 04:39:05 -0500
commit68a64357d15ae4f596e92715719071952006e83c (patch)
treedee519239225e92169ef77e4fad3be25c4dffe9d /arch
parent3d1ea8e8cb4d497a2dd73176cc82095b8f193589 (diff)
[POWERPC] Merge 32 and 64 bits asm-powerpc/io.h
powerpc: Merge 32 and 64 bits asm-powerpc/io.h The rework on io.h done for the new hookable accessors made it easier, so I just finished the work and merged 32 and 64 bits io.h for arch/powerpc. arch/ppc still uses the old version in asm-ppc, there is just too much gunk in there that I really can't be bothered trying to cleanup. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/io.c87
-rw-r--r--arch/powerpc/kernel/iomap.c2
-rw-r--r--arch/powerpc/kernel/pci_32.c34
-rw-r--r--arch/powerpc/kernel/rtas_pci.c1
-rw-r--r--arch/powerpc/kernel/traps.c8
-rw-r--r--arch/powerpc/mm/pgtable_32.c22
-rw-r--r--arch/powerpc/mm/pgtable_64.c16
-rw-r--r--arch/powerpc/platforms/chrp/setup.c1
-rw-r--r--arch/powerpc/platforms/iseries/setup.c4
-rw-r--r--arch/powerpc/platforms/powermac/setup.c2
11 files changed, 113 insertions, 66 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 600954df07ae..f9ce5d798de3 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -72,7 +72,7 @@ obj-$(CONFIG_AUDIT) += audit.o
72obj64-$(CONFIG_AUDIT) += compat_audit.o 72obj64-$(CONFIG_AUDIT) += compat_audit.o
73 73
74ifneq ($(CONFIG_PPC_INDIRECT_IO),y) 74ifneq ($(CONFIG_PPC_INDIRECT_IO),y)
75pci64-$(CONFIG_PPC64) += iomap.o 75obj-y += iomap.o
76endif 76endif
77 77
78ifeq ($(CONFIG_PPC_ISERIES),y) 78ifeq ($(CONFIG_PPC_ISERIES),y)
diff --git a/arch/powerpc/kernel/io.c b/arch/powerpc/kernel/io.c
index c1aa07524c26..34ae11494ddc 100644
--- a/arch/powerpc/kernel/io.c
+++ b/arch/powerpc/kernel/io.c
@@ -117,3 +117,90 @@ void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count)
117 asm volatile("sync"); 117 asm volatile("sync");
118} 118}
119EXPORT_SYMBOL(_outsl_ns); 119EXPORT_SYMBOL(_outsl_ns);
120
121#define IO_CHECK_ALIGN(v,a) ((((unsigned long)(v)) & ((a) - 1)) == 0)
122
123void _memset_io(volatile void __iomem *addr, int c, unsigned long n)
124{
125 void *p = (void __force *)addr;
126 u32 lc = c;
127 lc |= lc << 8;
128 lc |= lc << 16;
129
130 __asm__ __volatile__ ("sync" : : : "memory");
131 while(n && !IO_CHECK_ALIGN(p, 4)) {
132 *((volatile u8 *)p) = c;
133 p++;
134 n--;
135 }
136 while(n >= 4) {
137 *((volatile u32 *)p) = lc;
138 p += 4;
139 n -= 4;
140 }
141 while(n) {
142 *((volatile u8 *)p) = c;
143 p++;
144 n--;
145 }
146 __asm__ __volatile__ ("sync" : : : "memory");
147}
148EXPORT_SYMBOL(_memset_io);
149
150void _memcpy_fromio(void *dest, const volatile void __iomem *src,
151 unsigned long n)
152{
153 void *vsrc = (void __force *) src;
154
155 __asm__ __volatile__ ("sync" : : : "memory");
156 while(n && (!IO_CHECK_ALIGN(vsrc, 4) || !IO_CHECK_ALIGN(dest, 4))) {
157 *((u8 *)dest) = *((volatile u8 *)vsrc);
158 __asm__ __volatile__ ("eieio" : : : "memory");
159 vsrc++;
160 dest++;
161 n--;
162 }
163 while(n > 4) {
164 *((u32 *)dest) = *((volatile u32 *)vsrc);
165 __asm__ __volatile__ ("eieio" : : : "memory");
166 vsrc += 4;
167 dest += 4;
168 n -= 4;
169 }
170 while(n) {
171 *((u8 *)dest) = *((volatile u8 *)vsrc);
172 __asm__ __volatile__ ("eieio" : : : "memory");
173 vsrc++;
174 dest++;
175 n--;
176 }
177 __asm__ __volatile__ ("sync" : : : "memory");
178}
179EXPORT_SYMBOL(_memcpy_fromio);
180
181void _memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n)
182{
183 void *vdest = (void __force *) dest;
184
185 __asm__ __volatile__ ("sync" : : : "memory");
186 while(n && (!IO_CHECK_ALIGN(vdest, 4) || !IO_CHECK_ALIGN(src, 4))) {
187 *((volatile u8 *)vdest) = *((u8 *)src);
188 src++;
189 vdest++;
190 n--;
191 }
192 while(n > 4) {
193 *((volatile u32 *)vdest) = *((volatile u32 *)src);
194 src += 4;
195 vdest += 4;
196 n-=4;
197 }
198 while(n) {
199 *((volatile u8 *)vdest) = *((u8 *)src);
200 src++;
201 vdest++;
202 n--;
203 }
204 __asm__ __volatile__ ("sync" : : : "memory");
205}
206EXPORT_SYMBOL(_memcpy_toio);
diff --git a/arch/powerpc/kernel/iomap.c b/arch/powerpc/kernel/iomap.c
index a13a93dfc655..c68113371050 100644
--- a/arch/powerpc/kernel/iomap.c
+++ b/arch/powerpc/kernel/iomap.c
@@ -106,7 +106,7 @@ EXPORT_SYMBOL(iowrite32_rep);
106 106
107void __iomem *ioport_map(unsigned long port, unsigned int len) 107void __iomem *ioport_map(unsigned long port, unsigned int len)
108{ 108{
109 return (void __iomem *) (port+pci_io_base); 109 return (void __iomem *) (port + _IO_BASE);
110} 110}
111 111
112void ioport_unmap(void __iomem *addr) 112void ioport_unmap(void __iomem *addr)
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 0ad101a5fc5e..b08238f30502 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -1561,7 +1561,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
1561 *offset += hose->pci_mem_offset; 1561 *offset += hose->pci_mem_offset;
1562 res_bit = IORESOURCE_MEM; 1562 res_bit = IORESOURCE_MEM;
1563 } else { 1563 } else {
1564 io_offset = hose->io_base_virt - ___IO_BASE; 1564 io_offset = hose->io_base_virt - (void __iomem *)_IO_BASE;
1565 *offset += io_offset; 1565 *offset += io_offset;
1566 res_bit = IORESOURCE_IO; 1566 res_bit = IORESOURCE_IO;
1567 } 1567 }
@@ -1816,7 +1816,8 @@ void pci_resource_to_user(const struct pci_dev *dev, int bar,
1816 return; 1816 return;
1817 1817
1818 if (rsrc->flags & IORESOURCE_IO) 1818 if (rsrc->flags & IORESOURCE_IO)
1819 offset = ___IO_BASE - hose->io_base_virt + hose->io_base_phys; 1819 offset = (void __iomem *)_IO_BASE - hose->io_base_virt
1820 + hose->io_base_phys;
1820 1821
1821 *start = rsrc->start + offset; 1822 *start = rsrc->start + offset;
1822 *end = rsrc->end + offset; 1823 *end = rsrc->end + offset;
@@ -1835,35 +1836,6 @@ pci_init_resource(struct resource *res, unsigned long start, unsigned long end,
1835 res->child = NULL; 1836 res->child = NULL;
1836} 1837}
1837 1838
1838void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
1839{
1840 unsigned long start = pci_resource_start(dev, bar);
1841 unsigned long len = pci_resource_len(dev, bar);
1842 unsigned long flags = pci_resource_flags(dev, bar);
1843
1844 if (!len)
1845 return NULL;
1846 if (max && len > max)
1847 len = max;
1848 if (flags & IORESOURCE_IO)
1849 return ioport_map(start, len);
1850 if (flags & IORESOURCE_MEM)
1851 /* Not checking IORESOURCE_CACHEABLE because PPC does
1852 * not currently distinguish between ioremap and
1853 * ioremap_nocache.
1854 */
1855 return ioremap(start, len);
1856 /* What? */
1857 return NULL;
1858}
1859
1860void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
1861{
1862 /* Nothing to do */
1863}
1864EXPORT_SYMBOL(pci_iomap);
1865EXPORT_SYMBOL(pci_iounmap);
1866
1867unsigned long pci_address_to_pio(phys_addr_t address) 1839unsigned long pci_address_to_pio(phys_addr_t address)
1868{ 1840{
1869 struct pci_controller* hose = hose_head; 1841 struct pci_controller* hose = hose_head;
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 03cacc25a0ae..ace9f4c86e67 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -38,6 +38,7 @@
38#include <asm/rtas.h> 38#include <asm/rtas.h>
39#include <asm/mpic.h> 39#include <asm/mpic.h>
40#include <asm/ppc-pci.h> 40#include <asm/ppc-pci.h>
41#include <asm/eeh.h>
41 42
42/* RTAS tokens */ 43/* RTAS tokens */
43static int read_pci_config; 44static int read_pci_config;
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index c66b4771ef44..0d4e203fa7a0 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -53,10 +53,6 @@
53#endif 53#endif
54#include <asm/kexec.h> 54#include <asm/kexec.h>
55 55
56#ifdef CONFIG_PPC64 /* XXX */
57#define _IO_BASE pci_io_base
58#endif
59
60#ifdef CONFIG_DEBUGGER 56#ifdef CONFIG_DEBUGGER
61int (*__debugger)(struct pt_regs *regs); 57int (*__debugger)(struct pt_regs *regs);
62int (*__debugger_ipi)(struct pt_regs *regs); 58int (*__debugger_ipi)(struct pt_regs *regs);
@@ -241,7 +237,7 @@ void system_reset_exception(struct pt_regs *regs)
241 */ 237 */
242static inline int check_io_access(struct pt_regs *regs) 238static inline int check_io_access(struct pt_regs *regs)
243{ 239{
244#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32) 240#ifdef CONFIG_PPC32
245 unsigned long msr = regs->msr; 241 unsigned long msr = regs->msr;
246 const struct exception_table_entry *entry; 242 const struct exception_table_entry *entry;
247 unsigned int *nip = (unsigned int *)regs->nip; 243 unsigned int *nip = (unsigned int *)regs->nip;
@@ -274,7 +270,7 @@ static inline int check_io_access(struct pt_regs *regs)
274 return 1; 270 return 1;
275 } 271 }
276 } 272 }
277#endif /* CONFIG_PPC_PMAC && CONFIG_PPC32 */ 273#endif /* CONFIG_PPC32 */
278 return 0; 274 return 0;
279} 275}
280 276
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 7750c4425688..1891dbeeb8e9 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -149,6 +149,13 @@ ioremap(phys_addr_t addr, unsigned long size)
149EXPORT_SYMBOL(ioremap); 149EXPORT_SYMBOL(ioremap);
150 150
151void __iomem * 151void __iomem *
152ioremap_flags(phys_addr_t addr, unsigned long size, unsigned long flags)
153{
154 return __ioremap(addr, size, flags);
155}
156EXPORT_SYMBOL(ioremap_flags);
157
158void __iomem *
152__ioremap(phys_addr_t addr, unsigned long size, unsigned long flags) 159__ioremap(phys_addr_t addr, unsigned long size, unsigned long flags)
153{ 160{
154 unsigned long v, i; 161 unsigned long v, i;
@@ -247,20 +254,7 @@ void iounmap(volatile void __iomem *addr)
247} 254}
248EXPORT_SYMBOL(iounmap); 255EXPORT_SYMBOL(iounmap);
249 256
250void __iomem *ioport_map(unsigned long port, unsigned int len) 257int map_page(unsigned long va, phys_addr_t pa, int flags)
251{
252 return (void __iomem *) (port + _IO_BASE);
253}
254
255void ioport_unmap(void __iomem *addr)
256{
257 /* Nothing to do */
258}
259EXPORT_SYMBOL(ioport_map);
260EXPORT_SYMBOL(ioport_unmap);
261
262int
263map_page(unsigned long va, phys_addr_t pa, int flags)
264{ 258{
265 pmd_t *pd; 259 pmd_t *pd;
266 pte_t *pg; 260 pte_t *pg;
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index e9b21846ccbd..16e4ee1c2318 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -113,7 +113,7 @@ static int map_io_page(unsigned long ea, unsigned long pa, int flags)
113} 113}
114 114
115 115
116static void __iomem * __ioremap_com(unsigned long addr, unsigned long pa, 116static void __iomem * __ioremap_com(phys_addr_t addr, unsigned long pa,
117 unsigned long ea, unsigned long size, 117 unsigned long ea, unsigned long size,
118 unsigned long flags) 118 unsigned long flags)
119{ 119{
@@ -129,7 +129,7 @@ static void __iomem * __ioremap_com(unsigned long addr, unsigned long pa,
129 return (void __iomem *) (ea + (addr & ~PAGE_MASK)); 129 return (void __iomem *) (ea + (addr & ~PAGE_MASK));
130} 130}
131 131
132void __iomem * __ioremap(unsigned long addr, unsigned long size, 132void __iomem * __ioremap(phys_addr_t addr, unsigned long size,
133 unsigned long flags) 133 unsigned long flags)
134{ 134{
135 unsigned long pa, ea; 135 unsigned long pa, ea;
@@ -169,7 +169,7 @@ void __iomem * __ioremap(unsigned long addr, unsigned long size,
169} 169}
170 170
171 171
172void __iomem * ioremap(unsigned long addr, unsigned long size) 172void __iomem * ioremap(phys_addr_t addr, unsigned long size)
173{ 173{
174 unsigned long flags = _PAGE_NO_CACHE | _PAGE_GUARDED; 174 unsigned long flags = _PAGE_NO_CACHE | _PAGE_GUARDED;
175 175
@@ -178,7 +178,7 @@ void __iomem * ioremap(unsigned long addr, unsigned long size)
178 return __ioremap(addr, size, flags); 178 return __ioremap(addr, size, flags);
179} 179}
180 180
181void __iomem * ioremap_flags(unsigned long addr, unsigned long size, 181void __iomem * ioremap_flags(phys_addr_t addr, unsigned long size,
182 unsigned long flags) 182 unsigned long flags)
183{ 183{
184 if (ppc_md.ioremap) 184 if (ppc_md.ioremap)
@@ -189,7 +189,7 @@ void __iomem * ioremap_flags(unsigned long addr, unsigned long size,
189 189
190#define IS_PAGE_ALIGNED(_val) ((_val) == ((_val) & PAGE_MASK)) 190#define IS_PAGE_ALIGNED(_val) ((_val) == ((_val) & PAGE_MASK))
191 191
192int __ioremap_explicit(unsigned long pa, unsigned long ea, 192int __ioremap_explicit(phys_addr_t pa, unsigned long ea,
193 unsigned long size, unsigned long flags) 193 unsigned long size, unsigned long flags)
194{ 194{
195 struct vm_struct *area; 195 struct vm_struct *area;
@@ -244,7 +244,7 @@ int __ioremap_explicit(unsigned long pa, unsigned long ea,
244 * 244 *
245 * XXX what about calls before mem_init_done (ie python_countermeasures()) 245 * XXX what about calls before mem_init_done (ie python_countermeasures())
246 */ 246 */
247void __iounmap(void __iomem *token) 247void __iounmap(volatile void __iomem *token)
248{ 248{
249 void *addr; 249 void *addr;
250 250
@@ -256,7 +256,7 @@ void __iounmap(void __iomem *token)
256 im_free(addr); 256 im_free(addr);
257} 257}
258 258
259void iounmap(void __iomem *token) 259void iounmap(volatile void __iomem *token)
260{ 260{
261 if (ppc_md.iounmap) 261 if (ppc_md.iounmap)
262 ppc_md.iounmap(token); 262 ppc_md.iounmap(token);
@@ -282,7 +282,7 @@ static int iounmap_subset_regions(unsigned long addr, unsigned long size)
282 return 0; 282 return 0;
283} 283}
284 284
285int __iounmap_explicit(void __iomem *start, unsigned long size) 285int __iounmap_explicit(volatile void __iomem *start, unsigned long size)
286{ 286{
287 struct vm_struct *area; 287 struct vm_struct *area;
288 unsigned long addr; 288 unsigned long addr;
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index e6807d6d75bf..e1f51d455984 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -588,7 +588,6 @@ static int __init chrp_probe(void)
588 ISA_DMA_THRESHOLD = ~0L; 588 ISA_DMA_THRESHOLD = ~0L;
589 DMA_MODE_READ = 0x44; 589 DMA_MODE_READ = 0x44;
590 DMA_MODE_WRITE = 0x48; 590 DMA_MODE_WRITE = 0x48;
591 isa_io_base = CHRP_ISA_IO_BASE; /* default value */
592 591
593 return 1; 592 return 1;
594} 593}
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index 2f16d9330cfe..0f39bdbbf917 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -617,13 +617,13 @@ static void iseries_dedicated_idle(void)
617void __init iSeries_init_IRQ(void) { } 617void __init iSeries_init_IRQ(void) { }
618#endif 618#endif
619 619
620static void __iomem *iseries_ioremap(unsigned long address, unsigned long size, 620static void __iomem *iseries_ioremap(phys_addr_t address, unsigned long size,
621 unsigned long flags) 621 unsigned long flags)
622{ 622{
623 return (void __iomem *)address; 623 return (void __iomem *)address;
624} 624}
625 625
626static void iseries_iounmap(void __iomem *token) 626static void iseries_iounmap(volatile void __iomem *token)
627{ 627{
628} 628}
629 629
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 4ec6a5a65f30..d949e9df41ef 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -677,8 +677,6 @@ static int __init pmac_probe(void)
677 677
678#ifdef CONFIG_PPC32 678#ifdef CONFIG_PPC32
679 /* isa_io_base gets set in pmac_pci_init */ 679 /* isa_io_base gets set in pmac_pci_init */
680 isa_mem_base = PMAC_ISA_MEM_BASE;
681 pci_dram_offset = PMAC_PCI_DRAM_OFFSET;
682 ISA_DMA_THRESHOLD = ~0L; 680 ISA_DMA_THRESHOLD = ~0L;
683 DMA_MODE_READ = 1; 681 DMA_MODE_READ = 1;
684 DMA_MODE_WRITE = 2; 682 DMA_MODE_WRITE = 2;