]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[ARM] mm 10: allow memory type to be specified with ioremap
authorRussell King <rmk@dyn-67.arm.linux.org.uk>
Sat, 5 May 2007 19:59:27 +0000 (20:59 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 5 May 2007 19:59:27 +0000 (20:59 +0100)
__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>
arch/arm/mach-iop13xx/io.c
arch/arm/mach-iop13xx/pci.c
arch/arm/mm/ioremap.c
arch/arm/mm/nommu.c
arch/arm/plat-iop/io.c
include/asm-arm/arch-ixp23xx/io.h
include/asm-arm/arch-ixp4xx/io.h
include/asm-arm/io.h
include/asm-arm/mach/map.h

index e79a1b62600fa013ca4c6d027d2f02ae259d4f92..5b22fdeca52c1189e7821cb35d9c8d6bcc4f44ed 100644 (file)
@@ -41,7 +41,7 @@ void * __iomem __iop13xx_io(unsigned long io_addr)
 EXPORT_SYMBOL(__iop13xx_io);
 
 void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size,
-       unsigned long flags)
+       unsigned int mtype)
 {
        void __iomem * retval;
 
@@ -61,9 +61,9 @@ void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size,
                                 (cookie - IOP13XX_PCIE_LOWER_MEM_RA));
                break;
        case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA:
-               retval = __ioremap(IOP13XX_PBI_LOWER_MEM_PA +
-                                 (cookie - IOP13XX_PBI_LOWER_MEM_RA),
-                                 size, flags);
+               retval = __arm_ioremap(IOP13XX_PBI_LOWER_MEM_PA +
+                                      (cookie - IOP13XX_PBI_LOWER_MEM_RA),
+                                      size, mtype);
                break;
        case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA:
                retval = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(cookie);
@@ -75,7 +75,7 @@ void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size,
                retval = (void *) IOP13XX_PMMR_PHYS_TO_VIRT(cookie);
                break;
        default:
-               retval = __ioremap(cookie, size, flags);
+               retval = __arm_ioremap(cookie, size, mtype);
        }
 
        return retval;
index 89ec70ea318745c30f70335754de79314c62bf43..d85b88fcb7e83f1afba773c4459afc9f59202f66 100644 (file)
@@ -88,9 +88,9 @@ void iop13xx_map_pci_memory(void)
 
                                if (end) {
                                        iop13xx_atux_mem_base =
-                                       (u32) __ioremap_pfn(
+                                       (u32) __arm_ioremap_pfn(
                                        __phys_to_pfn(IOP13XX_PCIX_LOWER_MEM_PA)
-                                       , 0, iop13xx_atux_mem_size, 0);
+                                       , 0, iop13xx_atux_mem_size, MT_DEVICE);
                                        if (!iop13xx_atux_mem_base) {
                                                printk("%s: atux allocation "
                                                       "failed\n", __FUNCTION__);
@@ -114,9 +114,9 @@ void iop13xx_map_pci_memory(void)
 
                                if (end) {
                                        iop13xx_atue_mem_base =
-                                       (u32) __ioremap_pfn(
+                                       (u32) __arm_ioremap_pfn(
                                        __phys_to_pfn(IOP13XX_PCIE_LOWER_MEM_PA)
-                                       , 0, iop13xx_atue_mem_size, 0);
+                                       , 0, iop13xx_atue_mem_size, MT_DEVICE);
                                        if (!iop13xx_atue_mem_base) {
                                                printk("%s: atue allocation "
                                                       "failed\n", __FUNCTION__);
index 216623eece352d45da46230b492960ccdef54f5c..d6167ad4e011bf4db3b8da4cb248383d38e1b4d1 100644 (file)
@@ -262,11 +262,10 @@ remap_area_supersections(unsigned long virt, unsigned long pfn,
  * mapping.  See include/asm-arm/proc-armv/pgtable.h for more information.
  */
 void __iomem *
-__ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
-             unsigned long flags)
+__arm_ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
+                 unsigned int mtype)
 {
        const struct mem_type *type;
-       struct mem_type t;
        int err;
        unsigned long addr;
        struct vm_struct * area;
@@ -277,10 +276,9 @@ __ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
        if (pfn >= 0x100000 && (__pfn_to_phys(pfn) & ~SUPERSECTION_MASK))
                return NULL;
 
-       t = *get_mem_type(MT_DEVICE);
-       t.prot_sect |= flags;
-       t.prot_pte |= flags;
-       type = &t;
+       type = get_mem_type(mtype);
+       if (!type)
+               return NULL;
 
        size = PAGE_ALIGN(size);
 
@@ -311,10 +309,10 @@ __ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
        flush_cache_vmap(addr, addr + size);
        return (void __iomem *) (offset + addr);
 }
-EXPORT_SYMBOL(__ioremap_pfn);
+EXPORT_SYMBOL(__arm_ioremap_pfn);
 
 void __iomem *
-__ioremap(unsigned long phys_addr, size_t size, unsigned long flags)
+__arm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
 {
        unsigned long last_addr;
        unsigned long offset = phys_addr & ~PAGE_MASK;
@@ -332,9 +330,9 @@ __ioremap(unsigned long phys_addr, size_t size, unsigned long flags)
         */
        size = PAGE_ALIGN(last_addr + 1) - phys_addr;
 
-       return __ioremap_pfn(pfn, offset, size, flags);
+       return __arm_ioremap_pfn(pfn, offset, size, mtype);
 }
-EXPORT_SYMBOL(__ioremap);
+EXPORT_SYMBOL(__arm_ioremap);
 
 void __iounmap(volatile void __iomem *addr)
 {
index 05818fc0c705453c58a551fdd6485fcdd1abdd1d..8cd3a60954f0e78c53d4e0efb5eec7f5f6272e88 100644 (file)
@@ -62,21 +62,21 @@ void flush_dcache_page(struct page *page)
 }
 EXPORT_SYMBOL(flush_dcache_page);
 
-void __iomem *__ioremap_pfn(unsigned long pfn, unsigned long offset,
-                           size_t size, unsigned long flags)
+void __iomem *__arm_ioremap_pfn(unsigned long pfn, unsigned long offset,
+                               size_t size, unsigned int mtype)
 {
        if (pfn >= (0x100000000ULL >> PAGE_SHIFT))
                return NULL;
        return (void __iomem *) (offset + (pfn << PAGE_SHIFT));
 }
-EXPORT_SYMBOL(__ioremap_pfn);
+EXPORT_SYMBOL(__arm_ioremap_pfn);
 
-void __iomem *__ioremap(unsigned long phys_addr, size_t size,
-                       unsigned long flags)
+void __iomem *__arm_ioremap(unsigned long phys_addr, size_t size,
+                           unsigned int mtype)
 {
        return (void __iomem *)phys_addr;
 }
-EXPORT_SYMBOL(__ioremap);
+EXPORT_SYMBOL(__arm_ioremap);
 
 void __iounmap(volatile void __iomem *addr)
 {
index f7eccecf2e47b6d7ac6daa869edc897e03949cd2..498675d028d0399c4205b8a3a56682807e3e1331 100644 (file)
@@ -22,7 +22,7 @@
 #include <asm/io.h>
 
 void * __iomem __iop3xx_ioremap(unsigned long cookie, size_t size,
-       unsigned long flags)
+       unsigned int mtype)
 {
        void __iomem * retval;
 
@@ -34,7 +34,7 @@ void * __iomem __iop3xx_ioremap(unsigned long cookie, size_t size,
                retval = (void *) IOP3XX_PMMR_PHYS_TO_VIRT(cookie);
                break;
        default:
-               retval = __ioremap(cookie, size, flags);
+               retval = __arm_ioremap(cookie, size, mtype);
        }
 
        return retval;
index 18415a81ac74e48654854797eaf327381bb02c49..66f5bafc315c6153cd94cd4b925d2d89cbfce5e4 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/kernel.h>      /* For BUG */
 
 static inline void __iomem *
-ixp23xx_ioremap(unsigned long addr, unsigned long size, unsigned long flags)
+ixp23xx_ioremap(unsigned long addr, unsigned long size, unsigned int mtype)
 {
        if (addr >= IXP23XX_PCI_MEM_START &&
                addr <= IXP23XX_PCI_MEM_START + IXP23XX_PCI_MEM_SIZE) {
@@ -34,7 +34,7 @@ ixp23xx_ioremap(unsigned long addr, unsigned long size, unsigned long flags)
                        ((addr - IXP23XX_PCI_MEM_START) + IXP23XX_PCI_MEM_VIRT);
        }
 
-       return __ioremap(addr, size, flags);
+       return __arm_ioremap(addr, size, mtype);
 }
 
 static inline void
index a41ba229c56448a7c69442a83d4a4c1272dda714..b27c910adf9d58a4935763ea62e9eaf247aedc1e 100644 (file)
@@ -59,10 +59,10 @@ extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data);
  * fallback to the default.
  */
 static inline void __iomem *
-__ixp4xx_ioremap(unsigned long addr, size_t size, unsigned long flags)
+__ixp4xx_ioremap(unsigned long addr, size_t size, unsigned int mtype)
 {
        if((addr < 0x48000000) || (addr > 0x4fffffff))
-               return __ioremap(addr, size, flags);
+               return __arm_ioremap(addr, size, mtype);
 
        return (void *)addr;
 }
index 5f60b4220906858b50bf79cbc2d0b6687ffe250b..8261ff9e7955757f89b5e7a36dbfdf0ba2a3c57a 100644 (file)
@@ -56,13 +56,22 @@ extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
 
 /*
  * Architecture ioremap implementation.
- *
- * __ioremap takes CPU physical address.
- *
- * __ioremap_pfn takes a Page Frame Number and an offset into that page
  */
-extern void __iomem * __ioremap_pfn(unsigned long, unsigned long, size_t, unsigned long);
-extern void __iomem * __ioremap(unsigned long, size_t, unsigned long);
+#define MT_DEVICE              0
+#define MT_DEVICE_NONSHARED    1
+#define MT_DEVICE_CACHED       2
+#define MT_DEVICE_IXP2000      3
+/*
+ * types 4 onwards can be found in asm/mach/map.h and are undefined
+ * for ioremap
+ */
+
+/*
+ * __arm_ioremap takes CPU physical address.
+ * __arm_ioremap_pfn takes a Page Frame Number and an offset into that page
+ */
+extern void __iomem * __arm_ioremap_pfn(unsigned long, unsigned long, size_t, unsigned int);
+extern void __iomem * __arm_ioremap(unsigned long, size_t, unsigned int);
 extern void __iounmap(volatile void __iomem *addr);
 
 /*
@@ -203,14 +212,14 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
  *
  */
 #ifndef __arch_ioremap
-#define ioremap(cookie,size)           __ioremap(cookie,size,0)
-#define ioremap_nocache(cookie,size)   __ioremap(cookie,size,0)
-#define ioremap_cached(cookie,size)    __ioremap(cookie,size,L_PTE_CACHEABLE)
+#define ioremap(cookie,size)           __arm_ioremap(cookie, size, MT_DEVICE)
+#define ioremap_nocache(cookie,size)   __arm_ioremap(cookie, size, MT_DEVICE)
+#define ioremap_cached(cookie,size)    __arm_ioremap(cookie, size, MT_DEVICE_CACHED)
 #define iounmap(cookie)                        __iounmap(cookie)
 #else
-#define ioremap(cookie,size)           __arch_ioremap((cookie),(size),0)
-#define ioremap_nocache(cookie,size)   __arch_ioremap((cookie),(size),0)
-#define ioremap_cached(cookie,size)    __arch_ioremap((cookie),(size),L_PTE_CACHEABLE)
+#define ioremap(cookie,size)           __arch_ioremap((cookie), (size), MT_DEVICE)
+#define ioremap_nocache(cookie,size)   __arch_ioremap((cookie), (size), MT_DEVICE)
+#define ioremap_cached(cookie,size)    __arch_ioremap((cookie), (size), MT_DEVICE_CACHED)
 #define iounmap(cookie)                        __arch_iounmap(cookie)
 #endif
 
index 8afef40730afbb9d621d86801727a80c3ddb651b..7ef3c83901806b4abadd0b748568028fcf1470a5 100644 (file)
@@ -9,6 +9,8 @@
  *
  *  Page table mapping constructs and function prototypes
  */
+#include <asm/io.h>
+
 struct map_desc {
        unsigned long virtual;
        unsigned long pfn;
@@ -16,10 +18,7 @@ struct map_desc {
        unsigned int type;
 };
 
-#define MT_DEVICE              0
-#define MT_DEVICE_NONSHARED    1
-#define MT_DEVICE_CACHED       2
-#define MT_DEVICE_IXP2000      3
+/* types 0-3 are defined in asm/io.h */
 #define MT_CACHECLEAN          4
 #define MT_MINICLEAN           5
 #define MT_LOW_VECTORS         6