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/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(-) (limited to 'arch/nios2') 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 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') 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/cpu/cpu.c | 1 + arch/nios2/include/asm/global_data.h | 1 + arch/nios2/include/asm/io.h | 5 +---- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'arch/nios2') diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index 88c4e18..f6d5cd3 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -119,6 +119,7 @@ static int altera_nios2_probe(struct udevice *dev) "altr,has-mmu", 0); gd->arch.io_region_base = gd->arch.has_mmu ? 0xe0000000 : 0x80000000; gd->arch.mem_region_base = gd->arch.has_mmu ? 0xc0000000 : 0x00000000; + gd->arch.physaddr_mask = gd->arch.has_mmu ? 0x1fffffff : 0x7fffffff; return 0; } 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 From 65af9f69716ca0a765eebb8c14d851f89e2196d3 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Tue, 3 Nov 2015 13:47:02 +0800 Subject: nios2: remove CONFIG_SYS_INIT_SP macro Remove CONFIG_SYS_INIT_SP macro, as the initial stack is set to below the u-boot code. Signed-off-by: Thomas Chou Reviewed-by: Marek Vasut Reviewed-by: Chin Liang See --- arch/nios2/cpu/start.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'arch/nios2') diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S index 8758e7e..bb86bbf 100644 --- a/arch/nios2/cpu/start.S +++ b/arch/nios2/cpu/start.S @@ -81,6 +81,7 @@ _cur: movhi r5, %hi(_cur - _start) mov r8, r4 movhi r5, %hi(_start) ori r5, r5, %lo(_start) /* r5 <- linked _start */ + mov sp, r5 /* initial stack below u-boot code */ beq r4, r5, 3f movhi r6, %hi(CONFIG_SYS_MONITOR_LEN) @@ -100,8 +101,6 @@ _cur: movhi r5, %hi(_cur - _start) _reloc: /* STACK INIT -- zero top two words for call back chain. */ - movhi sp, %hi(CONFIG_SYS_INIT_SP) - ori sp, sp, %lo(CONFIG_SYS_INIT_SP) addi sp, sp, -8 stw r0, 0(sp) stw r0, 4(sp) -- cgit v1.1 From 9208d7eba1c2f027cdd06e6ce6ec90d3889764bf Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Tue, 3 Nov 2015 13:52:15 +0800 Subject: nios2: fix cached mode in clearing the BSS As the generic board runs in cached mode, it should not use "stwio" which bypass the cache. Signed-off-by: Thomas Chou Reviewed-by: Chin Liang See --- arch/nios2/cpu/start.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/nios2') diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S index bb86bbf..54787c5 100644 --- a/arch/nios2/cpu/start.S +++ b/arch/nios2/cpu/start.S @@ -158,7 +158,7 @@ relocate_code: ori r6, r6, %lo(__bss_end) beq r5, r6, 5f -4: stwio r0, 0(r5) +4: stw r0, 0(r5) addi r5, r5, 4 bne r5, r6, 4b 5: -- cgit v1.1