summaryrefslogtreecommitdiffstats
path: root/arch/ppc
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-10-23 11:06:56 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-03 07:27:44 +0100
commitb792124a7dd30f03b9ad0e06589b5b58ed930d3b (patch)
tree9811bbbc0b5bb5baade7d32309ced5b3c59046df /arch/ppc
parent6b127d4f189c03f4417f6185de1aeb55b1706f94 (diff)
downloadbarebox-b792124a7dd30f03b9ad0e06589b5b58ed930d3b.tar.gz
barebox-b792124a7dd30f03b9ad0e06589b5b58ed930d3b.tar.xz
rework remap_range
remap_range is for remapping regions with different cache attributes. It is implemented for ARM and PowerPC only, the other architectures only provide stubs. Currently the new cache attributes are passed in an architecture specific way and the attributes have to be retrieved by calls to mmu_get_pte_cached_flags() and mmu_get_pte_uncached_flags(). Make this simpler by providing architecture independent flags which can be directly passed to remap_range() Also provide a MAP_ARCH_DEFAULT flag and a arch_can_remap() function. The MAP_ARCH_DEFAULT defaults to whatever caching type the architecture has as default. the arch_can_remap() function returns true if the architecture can change the cache attributes, false otherwise. This allows the memtest code to better find out what it has to do. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/ppc')
-rw-r--r--arch/ppc/cpu-85xx/mmu.c26
-rw-r--r--arch/ppc/include/asm/mmu.h24
2 files changed, 21 insertions, 29 deletions
diff --git a/arch/ppc/cpu-85xx/mmu.c b/arch/ppc/cpu-85xx/mmu.c
index 7e86e6b2b6..6b93c3e8db 100644
--- a/arch/ppc/cpu-85xx/mmu.c
+++ b/arch/ppc/cpu-85xx/mmu.c
@@ -14,17 +14,29 @@
#include <common.h>
#include <asm/cache.h>
+#include <mmu.h>
#include <mach/mmu.h>
-void remap_range(void *_start, size_t size, uint32_t flags)
+int arch_remap_range(void *_start, size_t size, unsigned flags)
{
- uint32_t ptr, start, tsize, valid, wimge;
+ uint32_t ptr, start, tsize, valid, wimge, pte_flags;
unsigned long epn;
phys_addr_t rpn = 0;
int esel = 0;
+ switch (flags) {
+ case MAP_UNCACHED:
+ pte_flags = MAS2_I;
+ break;
+ case MAP_CACHED:
+ pte_flags = 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+
ptr = start = (uint32_t)_start;
- wimge = flags | MAS2_M;
+ wimge = pte_flags | MAS2_M;
while (ptr < (start + size)) {
esel = e500_find_tlb_idx((void *)ptr, 1);
@@ -41,14 +53,6 @@ void remap_range(void *_start, size_t size, uint32_t flags)
/* convert tsize to bytes to increment address. */
ptr += (1ULL << ((tsize) + 10));
}
-}
-uint32_t mmu_get_pte_cached_flags(void)
-{
return 0;
}
-
-uint32_t mmu_get_pte_uncached_flags(void)
-{
- return MAS2_I;
-}
diff --git a/arch/ppc/include/asm/mmu.h b/arch/ppc/include/asm/mmu.h
index 6e15975545..c691de1c77 100644
--- a/arch/ppc/include/asm/mmu.h
+++ b/arch/ppc/include/asm/mmu.h
@@ -557,25 +557,13 @@ extern int write_bat(ppc_bat_t bat, unsigned long upper, unsigned long lower);
#ifndef __ASSEMBLY__
+#define MAP_ARCH_DEFAULT MAP_CACHED
+
#ifdef CONFIG_MMU
-void remap_range(void *_start, size_t size, uint32_t flags);
-uint32_t mmu_get_pte_cached_flags(void);
-uint32_t mmu_get_pte_uncached_flags(void);
-#else
-static inline void remap_range(void *_start, size_t size, uint32_t flags)
-{
-}
-
-static inline uint32_t mmu_get_pte_cached_flags(void)
-{
- return 0;
-}
-
-static inline uint32_t mmu_get_pte_uncached_flags(void)
-{
- return 0;
-}
-#endif /* CONFIG_MMU */
+#define ARCH_HAS_REMAP
+int arch_remap_range(void *_start, size_t size, unsigned flags);
+#endif
+
#endif
#endif /* _PPC_MMU_H_ */