]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
nios2: fix virt_to_phys for nios2 with MMU
authorThomas Chou <thomas@wytron.com.tw>
Thu, 22 Oct 2015 07:38:24 +0000 (15:38 +0800)
committerThomas Chou <thomas@wytron.com.tw>
Fri, 23 Oct 2015 06:55:48 +0000 (14:55 +0800)
As the virtual address and physical address mapping of nios2 with
MMU are different. Add a check of MMU, and fix the mapping.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
Reviewed-by: Ley Foon Tan <lftan@altera.com>
arch/nios2/include/asm/io.h

index d0adf08cd6a54be52ff688fc0bc38464a13b3008..e7da35b0c9efa9920487d36e28fce733b18d84a4 100644 (file)
@@ -39,7 +39,11 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 static inline phys_addr_t virt_to_phys(void * vaddr)
 {
-       return (phys_addr_t)(vaddr);
+       DECLARE_GLOBAL_DATA_PTR;
+       if (gd->arch.has_mmu)
+               return (phys_addr_t)vaddr & 0x1fffffff;
+       else
+               return (phys_addr_t)vaddr & 0x7fffffff;
 }
 
 static inline void *ioremap(unsigned long physaddr, unsigned long size)