[U-Boot] [PATCH] nios2: fix virt_to_phys for nios2 with MMU

Marek Vasut marex at denx.de
Thu Oct 22 03:43:22 CEST 2015


On Wednesday, October 21, 2015 at 03:10:44 PM, Thomas Chou wrote:
> 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 <thomas at wytron.com.tw>
> ---
>  arch/nios2/include/asm/io.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
> index d0adf08..fdfc14e 100644
> --- a/arch/nios2/include/asm/io.h
> +++ b/arch/nios2/include/asm/io.h
> @@ -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:

Acked-by: Marek Vasut <marex at denx.de>

>  }
> 
>  static inline void *ioremap(unsigned long physaddr, unsigned long size)

Best regards,
Marek Vasut


More information about the U-Boot mailing list