Skip to content

Commit

Permalink
nios2: fix virt_to_phys for nios2 with MMU
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
hippo5329 committed Oct 23, 2015
1 parent 485e2d8 commit 8a3ea97
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arch/nios2/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8a3ea97

Please sign in to comment.