]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
sh: Prepare for dynamic PMB support
authorMatt Fleming <matt@console-pimps.org>
Tue, 6 Oct 2009 21:22:25 +0000 (21:22 +0000)
committerPaul Mundt <lethal@linux-sh.org>
Sat, 10 Oct 2009 12:51:12 +0000 (21:51 +0900)
To allow the MMU to be switched between 29bit and 32bit mode at runtime
some constants need to swapped for functions that return a runtime
value.

Signed-off-by: Matt Fleming <matt@console-pimps.org>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/include/asm/addrspace.h
arch/sh/include/asm/mmu.h
arch/sh/include/asm/pgtable.h
arch/sh/include/asm/pgtable_32.h
arch/sh/include/asm/scatterlist.h
arch/sh/mm/cache-sh4.c
arch/sh/mm/init.c

index ebd6e49ba39e137ebb5477db700f2dd4e2ce23df..99d6b3ecbe22d41167d2f4221d8d6223250f7017 100644 (file)
 #define P3_ADDR_MAX            P4SEG
 #endif
 
+#ifndef __ASSEMBLY__
+#ifdef CONFIG_PMB
+extern int __in_29bit_mode(void);
+#endif /* CONFIG_PMB */
+#endif /* __ASSEMBLY__ */
+
 #endif /* __KERNEL__ */
 #endif /* __ASM_SH_ADDRSPACE_H */
index f5963037c9d6804457b85b1247c8b09408d94d48..5025e12b786468ebe32cedaee0bfb21a97afd025 100644 (file)
@@ -7,6 +7,8 @@
 #define PMB_PASCR              0xff000070
 #define PMB_IRMCR              0xff000078
 
+#define PASCR_SE               0x80000000
+
 #define PMB_ADDR               0xf6100000
 #define PMB_DATA               0xf7100000
 #define PMB_ENTRY_MAX          16
@@ -75,4 +77,3 @@ void pmb_unmap(unsigned long addr);
 #endif /* __ASSEMBLY__ */
 
 #endif /* __MMU_H */
-
index 4f3efa7d5a6458625e796cffe28eb1498e13fc9b..5dff5787dfebb041cfd817cc4b4c50886d788f25 100644 (file)
@@ -75,13 +75,31 @@ static inline unsigned long long neff_sign_extend(unsigned long val)
 #define USER_PTRS_PER_PGD      (TASK_SIZE/PGDIR_SIZE)
 #define FIRST_USER_ADDRESS     0
 
-#ifdef CONFIG_32BIT
-#define PHYS_ADDR_MASK         0xffffffff
+#define PHYS_ADDR_MASK29               0x1fffffff
+#define PHYS_ADDR_MASK32               0xffffffff
+
+#ifdef CONFIG_PMB
+static inline unsigned long phys_addr_mask(void)
+{
+       /* Is the MMU in 29bit mode? */
+       if (__in_29bit_mode())
+               return PHYS_ADDR_MASK29;
+
+       return PHYS_ADDR_MASK32;
+}
+#elif CONFIG_32BIT
+static inline unsigned long phys_addr_mask(void)
+{
+       return PHYS_ADDR_MASK32;
+}
 #else
-#define PHYS_ADDR_MASK         0x1fffffff
+static inline unsigned long phys_addr_mask(void)
+{
+       return PHYS_ADDR_MASK29;
+}
 #endif
 
-#define PTE_PHYS_MASK          (PHYS_ADDR_MASK & PAGE_MASK)
+#define PTE_PHYS_MASK          (phys_addr_mask() & PAGE_MASK)
 #define PTE_FLAGS_MASK         (~(PTE_PHYS_MASK) << PAGE_SHIFT)
 
 #ifdef CONFIG_SUPERH32
index c0d359ce337b33a6c177790e9f712d3c8cf8d0a7..b354355162034bdfac9c0ef10a15ec9b833fbc9f 100644 (file)
@@ -108,7 +108,7 @@ static inline unsigned long copy_ptea_attributes(unsigned long x)
 #define _PAGE_CLEAR_FLAGS      (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE)
 #endif
 
-#define _PAGE_FLAGS_HARDWARE_MASK      (PHYS_ADDR_MASK & ~(_PAGE_CLEAR_FLAGS))
+#define _PAGE_FLAGS_HARDWARE_MASK      (phys_addr_mask() & ~(_PAGE_CLEAR_FLAGS))
 
 /* Hardware flags, page size encoding */
 #if !defined(CONFIG_MMU)
index 327cc2e4c97bb174da3b9d5f8cef96d300902c98..e38d1d4c7f6fdf52f7298995faece12c02a223c8 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __ASM_SH_SCATTERLIST_H
 #define __ASM_SH_SCATTERLIST_H
 
-#define ISA_DMA_THRESHOLD      PHYS_ADDR_MASK
+#define ISA_DMA_THRESHOLD      phys_addr_mask()
 
 #include <asm-generic/scatterlist.h>
 
index 639bb329fc813dd594a393cf3e38258ac2dc55c8..56dd55a1b13e00b717dbc94bee1b54bdd855f640 100644 (file)
@@ -88,12 +88,12 @@ static inline void flush_cache_4096(unsigned long start,
        unsigned long flags, exec_offset = 0;
 
        /*
-        * All types of SH-4 require PC to be in P2 to operate on the I-cache.
-        * Some types of SH-4 require PC to be in P2 to operate on the D-cache.
+        * All types of SH-4 require PC to be uncached to operate on the I-cache.
+        * Some types of SH-4 require PC to be uncached to operate on the D-cache.
         */
        if ((boot_cpu_data.flags & CPU_HAS_P2_FLUSH_BUG) ||
            (start < CACHE_OC_ADDRESS_ARRAY))
-               exec_offset = 0x20000000;
+               exec_offset = cached_to_uncached;
 
        local_irq_save(flags);
        __flush_cache_4096(start | SH_CACHE_ASSOC,
index 8173e38afd38f4ecbf9e6c7a5bfae805a50cba48..c8af6c5fa586e111876bef30bf8d20fb100f9713 100644 (file)
@@ -323,4 +323,12 @@ int memory_add_physaddr_to_nid(u64 addr)
 }
 EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
 #endif
+
 #endif /* CONFIG_MEMORY_HOTPLUG */
+
+#ifdef CONFIG_PMB
+int __in_29bit_mode(void)
+{
+       return !(ctrl_inl(PMB_PASCR) & PASCR_SE);
+}
+#endif /* CONFIG_PMB */