From 1ce61cbbe7b351041b31c59cf7c5d8b056a199ec Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Tue, 27 Oct 2015 08:30:22 +0800 Subject: nios2: fix map_physmem to do real cache mapping Fix the map_physmem() to do real cache mapping. Signed-off-by: Thomas Chou Acked-by: Marek Vasut --- arch/nios2/include/asm/global_data.h | 1 + arch/nios2/include/asm/io.h | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'arch/nios2/include') 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 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); } /* -- cgit v1.1 From 1cda48f333acd0f822720275730de0e6a6591a75 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Thu, 29 Oct 2015 21:00:32 +0800 Subject: nios2: remove the useless parenthesis in asm/io.h Remove the useless parenthesis in asm/io.h as suggested by Marek. Signed-off-by: Thomas Chou Acked-by: Marek Vasut --- arch/nios2/include/asm/io.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'arch/nios2/include') diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h index 007df8d..e04050f 100644 --- a/arch/nios2/include/asm/io.h +++ b/arch/nios2/include/asm/io.h @@ -18,10 +18,10 @@ static inline void sync(void) * that can be used to access the memory range with the caching * properties specified by "flags". */ -#define MAP_NOCACHE (1) -#define MAP_WRCOMBINE (0) -#define MAP_WRBACK (0) -#define MAP_WRTHROUGH (0) +#define MAP_NOCACHE 1 +#define MAP_WRCOMBINE 0 +#define MAP_WRBACK 0 +#define MAP_WRTHROUGH 0 static inline void * map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) -- cgit v1.1 From 2de4823dc0424923a6d6070a7378a7bf6ee67556 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Tue, 27 Oct 2015 09:02:17 +0800 Subject: nios2: change virt_to_phys to use physaddr_mask in global data As virt_to_phys() is used a lot in DMA transfer, change it to use physaddr_mask in global data. This will save an "if" statement and get a little faster. Signed-off-by: Thomas Chou Acked-by: Marek Vasut --- arch/nios2/include/asm/global_data.h | 1 + arch/nios2/include/asm/io.h | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'arch/nios2/include') diff --git a/arch/nios2/include/asm/global_data.h b/arch/nios2/include/asm/global_data.h index 9f3bd00..9863fd9 100644 --- a/arch/nios2/include/asm/global_data.h +++ b/arch/nios2/include/asm/global_data.h @@ -19,6 +19,7 @@ struct arch_global_data { int has_mmu; u32 io_region_base; u32 mem_region_base; + u32 physaddr_mask; }; #include diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h index e04050f..03a3418 100644 --- a/arch/nios2/include/asm/io.h +++ b/arch/nios2/include/asm/io.h @@ -44,10 +44,7 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags) static inline phys_addr_t virt_to_phys(void * vaddr) { DECLARE_GLOBAL_DATA_PTR; - if (gd->arch.has_mmu) - return (phys_addr_t)vaddr & 0x1fffffff; - else - return (phys_addr_t)vaddr & 0x7fffffff; + return (phys_addr_t)vaddr & gd->arch.physaddr_mask; } static inline void *ioremap(unsigned long physaddr, unsigned long size) -- cgit v1.1