nios2: fix virt_to_phys for nios2 with MMU
PATCH 1/1 nios2: fix virt_to_phys for nios2 with MMU
As the virtual address and physical address mapping of nios2 with MMU are different. Add a check of MMU, and fix the mapping.
--- arch/nios2/include/asm/io.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/nios2/include/asm/io.h +5 -1
@@ -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)
Signature · 1 line
2.1.4
PATCH 1/1 nios2: fix virt_to_phys for nios2 with MMU
Quoted 13 lines · Thomas Chou
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 <[email protected]>--- arch/nios2/include/asm/io.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)arch/nios2/include/asm/io.h +0
-0
arch/nios2/include/asm/io.h static inline void unmap_physmem(void *vaddr, unsigned · line 47
Quoted 10 lines
arch/nios2/include/asm/io.h +5
-1@@ -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 ;
I _think_ the parenthesis around vaddr are not necessary, but otherwise, I really like to see this patch:
Quoted 3 lines
arch/nios2/include/asm/io.h +0
-0}static inline void *ioremap(unsigned long physaddr, unsigned long size)
Best regards,
Marek Vasut
PATCH 1/1 nios2: fix virt_to_phys for nios2 with MMU
In reply to Thomas ChouQuoted 13 lines · Thomas Chou
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 <[email protected]>--- arch/nios2/include/asm/io.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)arch/nios2/include/asm/io.h +0
-0
arch/nios2/include/asm/io.h static inline void unmap_physmem(void *vaddr, unsigned long flags) · line 47
Quoted 10 lines
arch/nios2/include/asm/io.h +5
-1@@ -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 ; }
Regards
Ley Foon
PATCH v2 1/1 nios2: fix virt_to_phys for nios2 with MMU
In reply to Thomas ChouAs the virtual address and physical address mapping of nios2 with MMU are different. Add a check of MMU, and fix the mapping.
---
v2
remove the parenthesis around vaddr as suggested by Marek.
arch/nios2/include/asm/io.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/nios2/include/asm/io.h +5 -1
@@ -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)
Signature · 1 line
2.1.4
PATCH v2 1/1 nios2: fix virt_to_phys for nios2 with MMU
Quoted 6 lines · Thomas Chou
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 <[email protected]>Acked-by Marek Vasut <[email protected]>Reviewed-by Ley Foon Tan <[email protected]>
Quoted 7 lines
---
v2
remove the parenthesis around vaddr as suggested by Marek.arch/nios2/include/asm/io.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Applied to u-boot-nios.