aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2007-05-05 15:59:27 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2007-05-05 15:59:27 -0400
commit3603ab2b62ad8372fc93816b080b370dd55d7cec (patch)
treee9012ae43fe5988c288074ee12fc4a0fc2f6b63a
parent0af92befeb4b330c46cce6b520b2cc775cd6931f (diff)
[ARM] mm 10: allow memory type to be specified with ioremap
__ioremap() took a set of page table flags (specifically the cacheable and bufferable bits) to control the mapping type. However, with the advent of ARMv6, this is far too limited. Replace the page table flags with a memory type index, so that the desired attributes can be selected from the mem_type table. Finally, to prevent silent miscompilation due to the differing arguments, rename the __ioremap() and __ioremap_pfn() functions. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-iop13xx/io.c10
-rw-r--r--arch/arm/mach-iop13xx/pci.c8
-rw-r--r--arch/arm/mm/ioremap.c20
-rw-r--r--arch/arm/mm/nommu.c12
-rw-r--r--arch/arm/plat-iop/io.c4
-rw-r--r--include/asm-arm/arch-ixp23xx/io.h4
-rw-r--r--include/asm-arm/arch-ixp4xx/io.h4
-rw-r--r--include/asm-arm/io.h33
-rw-r--r--include/asm-arm/mach/map.h7
9 files changed, 54 insertions, 48 deletions
diff --git a/arch/arm/mach-iop13xx/io.c b/arch/arm/mach-iop13xx/io.c
index e79a1b62600f..5b22fdeca52c 100644
--- a/arch/arm/mach-iop13xx/io.c
+++ b/arch/arm/mach-iop13xx/io.c
@@ -41,7 +41,7 @@ void * __iomem __iop13xx_io(unsigned long io_addr)
41EXPORT_SYMBOL(__iop13xx_io); 41EXPORT_SYMBOL(__iop13xx_io);
42 42
43void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size, 43void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size,
44 unsigned long flags) 44 unsigned int mtype)
45{ 45{
46 void __iomem * retval; 46 void __iomem * retval;
47 47
@@ -61,9 +61,9 @@ void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size,
61 (cookie - IOP13XX_PCIE_LOWER_MEM_RA)); 61 (cookie - IOP13XX_PCIE_LOWER_MEM_RA));
62 break; 62 break;
63 case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA: 63 case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA:
64 retval = __ioremap(IOP13XX_PBI_LOWER_MEM_PA + 64 retval = __arm_ioremap(IOP13XX_PBI_LOWER_MEM_PA +
65 (cookie - IOP13XX_PBI_LOWER_MEM_RA), 65 (cookie - IOP13XX_PBI_LOWER_MEM_RA),
66 size, flags); 66 size, mtype);
67 break; 67 break;
68 case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA: 68 case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA:
69 retval = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(cookie); 69 retval = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(cookie);
@@ -75,7 +75,7 @@ void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size,
75 retval = (void *) IOP13XX_PMMR_PHYS_TO_VIRT(cookie); 75 retval = (void *) IOP13XX_PMMR_PHYS_TO_VIRT(cookie);
76 break; 76 break;
77 default: 77 default:
78 retval = __ioremap(cookie, size, flags); 78 retval = __arm_ioremap(cookie, size, mtype);
79 } 79 }
80 80
81 return retval; 81 return retval;
diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/pci.c
index 89ec70ea3187..d85b88fcb7e8 100644
--- a/arch/arm/mach-iop13xx/pci.c
+++ b/arch/arm/mach-iop13xx/pci.c
@@ -88,9 +88,9 @@ void iop13xx_map_pci_memory(void)
88 88
89 if (end) { 89 if (end) {
90 iop13xx_atux_mem_base = 90 iop13xx_atux_mem_base =
91 (u32) __ioremap_pfn( 91 (u32) __arm_ioremap_pfn(
92 __phys_to_pfn(IOP13XX_PCIX_LOWER_MEM_PA) 92 __phys_to_pfn(IOP13XX_PCIX_LOWER_MEM_PA)
93 , 0, iop13xx_atux_mem_size, 0); 93 , 0, iop13xx_atux_mem_size, MT_DEVICE);
94 if (!iop13xx_atux_mem_base) { 94 if (!iop13xx_atux_mem_base) {
95 printk("%s: atux allocation " 95 printk("%s: atux allocation "
96 "failed\n", __FUNCTION__); 96 "failed\n", __FUNCTION__);
@@ -114,9 +114,9 @@ void iop13xx_map_pci_memory(void)
114 114
115 if (end) { 115 if (end) {
116 iop13xx_atue_mem_base = 116 iop13xx_atue_mem_base =
117 (u32) __ioremap_pfn( 117 (u32) __arm_ioremap_pfn(
118 __phys_to_pfn(IOP13XX_PCIE_LOWER_MEM_PA) 118 __phys_to_pfn(IOP13XX_PCIE_LOWER_MEM_PA)
119 , 0, iop13xx_atue_mem_size, 0); 119 , 0, iop13xx_atue_mem_size, MT_DEVICE);
120 if (!iop13xx_atue_mem_base) { 120 if (!iop13xx_atue_mem_base) {
121 printk("%s: atue allocation " 121 printk("%s: atue allocation "
122 "failed\n", __FUNCTION__); 122 "failed\n", __FUNCTION__);
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 216623eece35..d6167ad4e011 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -262,11 +262,10 @@ remap_area_supersections(unsigned long virt, unsigned long pfn,
262 * mapping. See include/asm-arm/proc-armv/pgtable.h for more information. 262 * mapping. See include/asm-arm/proc-armv/pgtable.h for more information.
263 */ 263 */
264void __iomem * 264void __iomem *
265__ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size, 265__arm_ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
266 unsigned long flags) 266 unsigned int mtype)
267{ 267{
268 const struct mem_type *type; 268 const struct mem_type *type;
269 struct mem_type t;
270 int err; 269 int err;
271 unsigned long addr; 270 unsigned long addr;
272 struct vm_struct * area; 271 struct vm_struct * area;
@@ -277,10 +276,9 @@ __ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
277 if (pfn >= 0x100000 && (__pfn_to_phys(pfn) & ~SUPERSECTION_MASK)) 276 if (pfn >= 0x100000 && (__pfn_to_phys(pfn) & ~SUPERSECTION_MASK))
278 return NULL; 277 return NULL;
279 278
280 t = *get_mem_type(MT_DEVICE); 279 type = get_mem_type(mtype);
281 t.prot_sect |= flags; 280 if (!type)
282 t.prot_pte |= flags; 281 return NULL;
283 type = &t;
284 282
285 size = PAGE_ALIGN(size); 283 size = PAGE_ALIGN(size);
286 284
@@ -311,10 +309,10 @@ __ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
311 flush_cache_vmap(addr, addr + size); 309 flush_cache_vmap(addr, addr + size);
312 return (void __iomem *) (offset + addr); 310 return (void __iomem *) (offset + addr);
313} 311}
314EXPORT_SYMBOL(__ioremap_pfn); 312EXPORT_SYMBOL(__arm_ioremap_pfn);
315 313
316void __iomem * 314void __iomem *
317__ioremap(unsigned long phys_addr, size_t size, unsigned long flags) 315__arm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
318{ 316{
319 unsigned long last_addr; 317 unsigned long last_addr;
320 unsigned long offset = phys_addr & ~PAGE_MASK; 318 unsigned long offset = phys_addr & ~PAGE_MASK;
@@ -332,9 +330,9 @@ __ioremap(unsigned long phys_addr, size_t size, unsigned long flags)
332 */ 330 */
333 size = PAGE_ALIGN(last_addr + 1) - phys_addr; 331 size = PAGE_ALIGN(last_addr + 1) - phys_addr;
334 332
335 return __ioremap_pfn(pfn, offset, size, flags); 333 return __arm_ioremap_pfn(pfn, offset, size, mtype);
336} 334}
337EXPORT_SYMBOL(__ioremap); 335EXPORT_SYMBOL(__arm_ioremap);
338 336
339void __iounmap(volatile void __iomem *addr) 337void __iounmap(volatile void __iomem *addr)
340{ 338{
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 05818fc0c705..8cd3a60954f0 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -62,21 +62,21 @@ void flush_dcache_page(struct page *page)
62} 62}
63EXPORT_SYMBOL(flush_dcache_page); 63EXPORT_SYMBOL(flush_dcache_page);
64 64
65void __iomem *__ioremap_pfn(unsigned long pfn, unsigned long offset, 65void __iomem *__arm_ioremap_pfn(unsigned long pfn, unsigned long offset,
66 size_t size, unsigned long flags) 66 size_t size, unsigned int mtype)
67{ 67{
68 if (pfn >= (0x100000000ULL >> PAGE_SHIFT)) 68 if (pfn >= (0x100000000ULL >> PAGE_SHIFT))
69 return NULL; 69 return NULL;
70 return (void __iomem *) (offset + (pfn << PAGE_SHIFT)); 70 return (void __iomem *) (offset + (pfn << PAGE_SHIFT));
71} 71}
72EXPORT_SYMBOL(__ioremap_pfn); 72EXPORT_SYMBOL(__arm_ioremap_pfn);
73 73
74void __iomem *__ioremap(unsigned long phys_addr, size_t size, 74void __iomem *__arm_ioremap(unsigned long phys_addr, size_t size,
75 unsigned long flags) 75 unsigned int mtype)
76{ 76{
77 return (void __iomem *)phys_addr; 77 return (void __iomem *)phys_addr;
78} 78}
79EXPORT_SYMBOL(__ioremap); 79EXPORT_SYMBOL(__arm_ioremap);
80 80
81void __iounmap(volatile void __iomem *addr) 81void __iounmap(volatile void __iomem *addr)
82{ 82{
diff --git a/arch/arm/plat-iop/io.c b/arch/arm/plat-iop/io.c
index f7eccecf2e47..498675d028d0 100644
--- a/arch/arm/plat-iop/io.c
+++ b/arch/arm/plat-iop/io.c
@@ -22,7 +22,7 @@
22#include <asm/io.h> 22#include <asm/io.h>
23 23
24void * __iomem __iop3xx_ioremap(unsigned long cookie, size_t size, 24void * __iomem __iop3xx_ioremap(unsigned long cookie, size_t size,
25 unsigned long flags) 25 unsigned int mtype)
26{ 26{
27 void __iomem * retval; 27 void __iomem * retval;
28 28
@@ -34,7 +34,7 @@ void * __iomem __iop3xx_ioremap(unsigned long cookie, size_t size,
34 retval = (void *) IOP3XX_PMMR_PHYS_TO_VIRT(cookie); 34 retval = (void *) IOP3XX_PMMR_PHYS_TO_VIRT(cookie);
35 break; 35 break;
36 default: 36 default:
37 retval = __ioremap(cookie, size, flags); 37 retval = __arm_ioremap(cookie, size, mtype);
38 } 38 }
39 39
40 return retval; 40 return retval;
diff --git a/include/asm-arm/arch-ixp23xx/io.h b/include/asm-arm/arch-ixp23xx/io.h
index 18415a81ac74..66f5bafc315c 100644
--- a/include/asm-arm/arch-ixp23xx/io.h
+++ b/include/asm-arm/arch-ixp23xx/io.h
@@ -23,7 +23,7 @@
23#include <linux/kernel.h> /* For BUG */ 23#include <linux/kernel.h> /* For BUG */
24 24
25static inline void __iomem * 25static inline void __iomem *
26ixp23xx_ioremap(unsigned long addr, unsigned long size, unsigned long flags) 26ixp23xx_ioremap(unsigned long addr, unsigned long size, unsigned int mtype)
27{ 27{
28 if (addr >= IXP23XX_PCI_MEM_START && 28 if (addr >= IXP23XX_PCI_MEM_START &&
29 addr <= IXP23XX_PCI_MEM_START + IXP23XX_PCI_MEM_SIZE) { 29 addr <= IXP23XX_PCI_MEM_START + IXP23XX_PCI_MEM_SIZE) {
@@ -34,7 +34,7 @@ ixp23xx_ioremap(unsigned long addr, unsigned long size, unsigned long flags)
34 ((addr - IXP23XX_PCI_MEM_START) + IXP23XX_PCI_MEM_VIRT); 34 ((addr - IXP23XX_PCI_MEM_START) + IXP23XX_PCI_MEM_VIRT);
35 } 35 }
36 36
37 return __ioremap(addr, size, flags); 37 return __arm_ioremap(addr, size, mtype);
38} 38}
39 39
40static inline void 40static inline void
diff --git a/include/asm-arm/arch-ixp4xx/io.h b/include/asm-arm/arch-ixp4xx/io.h
index a41ba229c564..b27c910adf9d 100644
--- a/include/asm-arm/arch-ixp4xx/io.h
+++ b/include/asm-arm/arch-ixp4xx/io.h
@@ -59,10 +59,10 @@ extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data);
59 * fallback to the default. 59 * fallback to the default.
60 */ 60 */
61static inline void __iomem * 61static inline void __iomem *
62__ixp4xx_ioremap(unsigned long addr, size_t size, unsigned long flags) 62__ixp4xx_ioremap(unsigned long addr, size_t size, unsigned int mtype)
63{ 63{
64 if((addr < 0x48000000) || (addr > 0x4fffffff)) 64 if((addr < 0x48000000) || (addr > 0x4fffffff))
65 return __ioremap(addr, size, flags); 65 return __arm_ioremap(addr, size, mtype);
66 66
67 return (void *)addr; 67 return (void *)addr;
68} 68}
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index 5f60b4220906..8261ff9e7955 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -56,13 +56,22 @@ extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
56 56
57/* 57/*
58 * Architecture ioremap implementation. 58 * Architecture ioremap implementation.
59 *
60 * __ioremap takes CPU physical address.
61 *
62 * __ioremap_pfn takes a Page Frame Number and an offset into that page
63 */ 59 */
64extern void __iomem * __ioremap_pfn(unsigned long, unsigned long, size_t, unsigned long); 60#define MT_DEVICE 0
65extern void __iomem * __ioremap(unsigned long, size_t, unsigned long); 61#define MT_DEVICE_NONSHARED 1
62#define MT_DEVICE_CACHED 2
63#define MT_DEVICE_IXP2000 3
64/*
65 * types 4 onwards can be found in asm/mach/map.h and are undefined
66 * for ioremap
67 */
68
69/*
70 * __arm_ioremap takes CPU physical address.
71 * __arm_ioremap_pfn takes a Page Frame Number and an offset into that page
72 */
73extern void __iomem * __arm_ioremap_pfn(unsigned long, unsigned long, size_t, unsigned int);
74extern void __iomem * __arm_ioremap(unsigned long, size_t, unsigned int);
66extern void __iounmap(volatile void __iomem *addr); 75extern void __iounmap(volatile void __iomem *addr);
67 76
68/* 77/*
@@ -203,14 +212,14 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
203 * 212 *
204 */ 213 */
205#ifndef __arch_ioremap 214#ifndef __arch_ioremap
206#define ioremap(cookie,size) __ioremap(cookie,size,0) 215#define ioremap(cookie,size) __arm_ioremap(cookie, size, MT_DEVICE)
207#define ioremap_nocache(cookie,size) __ioremap(cookie,size,0) 216#define ioremap_nocache(cookie,size) __arm_ioremap(cookie, size, MT_DEVICE)
208#define ioremap_cached(cookie,size) __ioremap(cookie,size,L_PTE_CACHEABLE) 217#define ioremap_cached(cookie,size) __arm_ioremap(cookie, size, MT_DEVICE_CACHED)
209#define iounmap(cookie) __iounmap(cookie) 218#define iounmap(cookie) __iounmap(cookie)
210#else 219#else
211#define ioremap(cookie,size) __arch_ioremap((cookie),(size),0) 220#define ioremap(cookie,size) __arch_ioremap((cookie), (size), MT_DEVICE)
212#define ioremap_nocache(cookie,size) __arch_ioremap((cookie),(size),0) 221#define ioremap_nocache(cookie,size) __arch_ioremap((cookie), (size), MT_DEVICE)
213#define ioremap_cached(cookie,size) __arch_ioremap((cookie),(size),L_PTE_CACHEABLE) 222#define ioremap_cached(cookie,size) __arch_ioremap((cookie), (size), MT_DEVICE_CACHED)
214#define iounmap(cookie) __arch_iounmap(cookie) 223#define iounmap(cookie) __arch_iounmap(cookie)
215#endif 224#endif
216 225
diff --git a/include/asm-arm/mach/map.h b/include/asm-arm/mach/map.h
index 8afef40730af..7ef3c8390180 100644
--- a/include/asm-arm/mach/map.h
+++ b/include/asm-arm/mach/map.h
@@ -9,6 +9,8 @@
9 * 9 *
10 * Page table mapping constructs and function prototypes 10 * Page table mapping constructs and function prototypes
11 */ 11 */
12#include <asm/io.h>
13
12struct map_desc { 14struct map_desc {
13 unsigned long virtual; 15 unsigned long virtual;
14 unsigned long pfn; 16 unsigned long pfn;
@@ -16,10 +18,7 @@ struct map_desc {
16 unsigned int type; 18 unsigned int type;
17}; 19};
18 20
19#define MT_DEVICE 0 21/* types 0-3 are defined in asm/io.h */
20#define MT_DEVICE_NONSHARED 1
21#define MT_DEVICE_CACHED 2
22#define MT_DEVICE_IXP2000 3
23#define MT_CACHECLEAN 4 22#define MT_CACHECLEAN 4
24#define MT_MINICLEAN 5 23#define MT_MINICLEAN 5
25#define MT_LOW_VECTORS 6 24#define MT_LOW_VECTORS 6