Skip to contentSkip to conversation

nios2: fix map_physmem to do real cache mapping

PATCH New Thomas Chou 2 participants 3 messages Oct 27, 2015 – Nov 3, 2015 NIOS2 architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nios2: fix map_physmem to do real cache mapping

Fix the map_physmem() to do real cache mapping.

---
 arch/nios2/cpu/cpu.c                 | 3 ++-
 arch/nios2/include/asm/global_data.h | 1 +
 arch/nios2/include/asm/io.h          | 8 ++++++--
 3 files changed, 9 insertions(+), 3 deletions(-)
arch/nios2/cpu/cpu.c +2 -1
index ff0fa20..88c4e18 100644
@@ -117,7 +117,8 @@ static int altera_nios2_probe(struct udevice *dev)
 		"altr,has-initda", 0);
 	gd->arch.has_mmu = fdtdec_get_int(blob, node,
 		"altr,has-mmu", 0);
-	gd->arch.io_region_base = gd->arch.has_mmu ? 0xe0000000 : 0x8000000;
+	gd->arch.io_region_base = gd->arch.has_mmu ? 0xe0000000 : 0x80000000;
+	gd->arch.mem_region_base = gd->arch.has_mmu ? 0xc0000000 : 0x00000000;
 
 	return 0;
 }
arch/nios2/include/asm/global_data.h +1 -0
index d6a2cfa..9f3bd00 100644
@@ -18,6 +18,7 @@ struct arch_global_data {
 	int has_initda;
 	int has_mmu;
 	u32 io_region_base;
+	u32 mem_region_base;
 };
 
 #include <asm-generic/global_data.h>
arch/nios2/include/asm/io.h +6 -2
index e7da35b..007df8d 100644
@@ -18,7 +18,7 @@ static inline void sync(void)
  * that can be used to access the memory range with the caching
  * properties specified by "flags".
  */
-#define MAP_NOCACHE	(0)
+#define MAP_NOCACHE	(1)
 #define MAP_WRCOMBINE	(0)
 #define MAP_WRBACK	(0)
 #define MAP_WRTHROUGH	(0)
@@ -26,7 +26,11 @@ static inline void sync(void)
 static inline void *
 map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
 {
-	return (void *)paddr;
+	DECLARE_GLOBAL_DATA_PTR;
+	if (flags)
+		return (void *)(paddr | gd->arch.io_region_base);
+	else
+		return (void *)(paddr | gd->arch.mem_region_base);
 }
 
 /*
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 nios2: fix map_physmem to do real cache mapping

Quoted 3 lines · Thomas Chou

Fix the map_physmem() to do real cache mapping.

[...]

Quoted 6 lines

#include <asm-generic/global_data.h>

arch/nios2/include/asm/io.h +0 -0
index e7da35b..007df8d 100644

arch/nios2/include/asm/io.h static inline void sync(void) · line 24

Quoted 8 lines
arch/nios2/include/asm/io.h +1 -1
@@ -18,7 +18,7 @@ static inline void sync(void)
  * that can be used to access the memory range with the caching
  * properties specified by "flags".
  */
-#define MAP_NOCACHE	(0)
+#define MAP_NOCACHE	(1)
 #define MAP_WRCOMBINE	(0)
 #define MAP_WRBACK	(0)
 #define MAP_WRTHROUGH	(0)

Eventually, you might want to create a patch to drop these useless parenthesis.

arch/nios2/include/asm/io.h static inline void sync(void) · line 36

Quoted 13 lines
arch/nios2/include/asm/io.h +5 -1
@@ -26,7 +26,11 @@ static inline void sync(void)
 static inline void *
 map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
 {
-	return (void *)paddr;
+	DECLARE_GLOBAL_DATA_PTR;
+	if (flags)
+		return (void *)(paddr | gd->arch.io_region_base);
+	else
+		return (void *)(paddr | gd->arch.mem_region_base);
 }
 
 /*

Best regards,
Marek Vasut

#2 lore raw

PATCH 1/1 nios2: fix map_physmem to do real cache mapping

In reply to Thomas Chou
Quoted 9 lines · Thomas Chou

Fix the map_physmem() to do real cache mapping.

---
  arch/nios2/cpu/cpu.c                 | 3 ++-
  arch/nios2/include/asm/global_data.h | 1 +
  arch/nios2/include/asm/io.h          | 8 ++++++--
  3 files changed, 9 insertions(+), 3 deletions(-)

Applied to u-boot-nios.