Add a function to remap an IO range into a virtual addresses range. This is particulary usefull for the few devices mapped at physical address 0, as the MTD boot devices. Signed-off-by: Robert Jarzmik <robert.jarzmik@xxxxxxx> --- arch/arm/cpu/mmu.c | 12 ++++++++++++ arch/arm/include/asm/mmu.h | 6 ++++++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index 8e4e81a..c6c91df 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -111,6 +111,18 @@ static void remap_range(void *_start, size_t size, uint32_t flags) tlb_invalidate(); } +void *map_io_sections(unsigned long phys, void *_start, size_t size) +{ + unsigned long start = (unsigned long)_start, sec; + + phys >>= 20; + for (sec = start; sec < start + size; sec += (1 << 20)) + ttb[sec >> 20] = (phys++ << 20) | PMD_SECT_DEF_UNCACHED; + + tlb_invalidate(); + return _start; +} + /* * remap the memory bank described by mem cachable and * bufferable diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h index 9ca5e2a..f5ae7a8 100644 --- a/arch/arm/include/asm/mmu.h +++ b/arch/arm/include/asm/mmu.h @@ -32,6 +32,7 @@ void dma_flush_range(unsigned long, unsigned long); void dma_inv_range(unsigned long, unsigned long); unsigned long virt_to_phys(void *virt); void *phys_to_virt(unsigned long phys); +void *map_io_sections(unsigned long physaddr, void *start, size_t size); #else static inline void *dma_alloc_coherent(size_t size) @@ -66,6 +67,11 @@ static inline void dma_inv_range(unsigned long s, unsigned long e) { } +static inline void *map_io_sections(unsigned long phys, void *start, size_t size) +{ + return (void *)phys; +} + #endif #ifdef CONFIG_CACHE_L2X0 -- 1.7.5.4 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox