]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
nios2: change virt_to_phys to use physaddr_mask in global data
authorThomas Chou <thomas@wytron.com.tw>
Tue, 27 Oct 2015 01:02:17 +0000 (09:02 +0800)
committerThomas Chou <thomas@wytron.com.tw>
Fri, 6 Nov 2015 01:14:11 +0000 (09:14 +0800)
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 <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
arch/nios2/cpu/cpu.c
arch/nios2/include/asm/global_data.h
arch/nios2/include/asm/io.h

index 88c4e184eef31daae84fde0cee32a2d67181de32..f6d5cd399a3acea273007dfe0a28b6ff44c5aebb 100644 (file)
@@ -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;
 }
index 9f3bd001973eee1bff98dd1043dce278f9dce7c7..9863fd9f881ec6f419f8539da423809f2da682f0 100644 (file)
@@ -19,6 +19,7 @@ struct arch_global_data {
        int has_mmu;
        u32 io_region_base;
        u32 mem_region_base;
+       u32 physaddr_mask;
 };
 
 #include <asm-generic/global_data.h>
index e04050ff431cc10bb7f7beb065d71c95f20cb0b3..03a3418e847a46e9e7aea71be04c7fc49eceb15e 100644 (file)
@@ -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)