public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] nios2: fix map_physmem to do real cache mapping
@ 2015-10-27  1:09 Thomas Chou
  2015-10-27  9:17 ` Marek Vasut
  2015-11-03  5:15 ` Thomas Chou
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Chou @ 2015-10-27  1:09 UTC (permalink / raw)
  To: u-boot

Fix the map_physmem() to do real cache mapping.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 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(-)

diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index ff0fa20..88c4e18 100644
--- a/arch/nios2/cpu/cpu.c
+++ b/arch/nios2/cpu/cpu.c
@@ -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;
 }
diff --git a/arch/nios2/include/asm/global_data.h b/arch/nios2/include/asm/global_data.h
index d6a2cfa..9f3bd00 100644
--- a/arch/nios2/include/asm/global_data.h
+++ b/arch/nios2/include/asm/global_data.h
@@ -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>
diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
index e7da35b..007df8d 100644
--- a/arch/nios2/include/asm/io.h
+++ b/arch/nios2/include/asm/io.h
@@ -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);
 }
 
 /*
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] nios2: fix map_physmem to do real cache mapping
  2015-10-27  1:09 [U-Boot] [PATCH] nios2: fix map_physmem to do real cache mapping Thomas Chou
@ 2015-10-27  9:17 ` Marek Vasut
  2015-11-03  5:15 ` Thomas Chou
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2015-10-27  9:17 UTC (permalink / raw)
  To: u-boot

On Tuesday, October 27, 2015 at 02:09:43 AM, Thomas Chou wrote:
> Fix the map_physmem() to do real cache mapping.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>

Acked-by: Marek Vasut <marex@denx.de>

[...]

>  #include <asm-generic/global_data.h>
> diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
> index e7da35b..007df8d 100644
> --- a/arch/nios2/include/asm/io.h
> +++ b/arch/nios2/include/asm/io.h
> @@ -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.

> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] nios2: fix map_physmem to do real cache mapping
  2015-10-27  1:09 [U-Boot] [PATCH] nios2: fix map_physmem to do real cache mapping Thomas Chou
  2015-10-27  9:17 ` Marek Vasut
@ 2015-11-03  5:15 ` Thomas Chou
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Chou @ 2015-11-03  5:15 UTC (permalink / raw)
  To: u-boot



On 2015?10?27? 09:09, Thomas Chou wrote:
> Fix the map_physmem() to do real cache mapping.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>   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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-03  5:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27  1:09 [U-Boot] [PATCH] nios2: fix map_physmem to do real cache mapping Thomas Chou
2015-10-27  9:17 ` Marek Vasut
2015-11-03  5:15 ` Thomas Chou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox