From: Paul Burton Date: Thu, 14 Sep 2017 22:05:13 +0000 (-0700) Subject: sandbox: Use asm-generic/io.h X-Git-Tag: v2017.11-rc2~143 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f7ae1ca3e894d67ef1e8b6256a26c08e30e25127;p=oweals%2Fu-boot.git sandbox: Use asm-generic/io.h Convert the sandbox architecture to make use of the new asm-generic/io.h to provide address mapping functions. As sandbox actually performs non-identity mapping between physical & virtual addresses we can't simply make use of the generic mapping functions, but are able to implement phys_to_virt() & make use of it from map_physmem(). Signed-off-by: Paul Burton Cc: Simon Glass Acked-by: Simon Glass --- diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 01991049cc..66c3a6a88a 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -56,6 +56,16 @@ int cleanup_before_linux_select(int flags) return 0; } +void *phys_to_virt(phys_addr_t paddr) +{ + return (void *)(gd->arch.ram_buf + paddr); +} + +phys_addr_t virt_to_phys(void *vaddr) +{ + return (phys_addr_t)((uint8_t *)vaddr - gd->arch.ram_buf); +} + void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) { #if defined(CONFIG_PCI) && !defined(CONFIG_SPL_BUILD) @@ -73,7 +83,7 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) } #endif - return (void *)(gd->arch.ram_buf + paddr); + return phys_to_virt(paddr); } void unmap_physmem(const void *vaddr, unsigned long flags) diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index a6856356df..fd3c2478f7 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -7,22 +7,22 @@ #ifndef __SANDBOX_ASM_IO_H #define __SANDBOX_ASM_IO_H -/* - * Given a physical address and a length, return a virtual address - * that can be used to access the memory range with the caching - * properties specified by "flags". - */ -#define MAP_NOCACHE (0) -#define MAP_WRCOMBINE (0) -#define MAP_WRBACK (0) -#define MAP_WRTHROUGH (0) +void *phys_to_virt(phys_addr_t paddr); +#define phys_to_virt phys_to_virt + +phys_addr_t virt_to_phys(void *vaddr); +#define virt_to_phys virt_to_phys void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags); +#define map_physmem map_physmem /* * Take down a mapping set up by map_physmem(). */ void unmap_physmem(const void *vaddr, unsigned long flags); +#define unmap_physmem unmap_physmem + +#include /* For sandbox, we want addresses to point into our RAM buffer */ static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)