[U-Boot] [PATCH 1/3] ARMv8/layerscape: Add mmu_init API

Prabhakar Kushwaha prabhakar.kushwaha at nxp.com
Tue Jan 19 14:54:29 CET 2016


> -----Original Message-----
> From: Zhiqiang Hou [mailto:Zhiqiang.Hou at freescale.com]
> Sent: Tuesday, January 19, 2016 6:10 PM
> To: u-boot at lists.denx.de; albert.u.boot at aribaud.net;
> Mingkai.hu at freescale.com; yorksun at freescale.com
> Cc: leoli at freescale.com; prabhakar at freescale.com;
> bhupesh.sharma at freescale.com; sjg at chromium.org;
> bmeng.cn at gmail.com; hs at denx.de; joe.hershberger at ni.com;
> marex at denx.de; Zhiqiang Hou <zhiqiang.hou at nxp.com>; Hou Zhiqiang
> <B48286 at freescale.com>
> Subject: [PATCH 1/3] ARMv8/layerscape: Add mmu_init API
> 
> From: Hou Zhiqiang <B48286 at freescale.com>
> 
> Expose this API to make it reuseable when u-boot turn into other EL from
> EL3.
> 
> Signed-off-by: Hou Zhiqiang <B48286 at freescale.com>
> ---
>  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 24
> ++++++++++++++++++++++++
>  include/common.h                        |  1 +
>  2 files changed, 25 insertions(+)
> 
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> index 6ea28ed..df5670f 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> @@ -403,6 +403,30 @@ void enable_caches(void)
>  	final_mmu_setup();
>  	__asm_invalidate_tlb_all();
>  }
> +
> +static void mmu_disable(void)
> +{
> +	if (get_sctlr() & CR_M)
> +		set_sctlr(get_sctlr() & ~CR_M);
> +}
> +
> +static void mmu_enable(void)
> +{
> +	if (!(get_sctlr() & CR_M))
> +		set_sctlr(get_sctlr() | CR_M);
> +}
> +
> +void mmu_init(void)

Name of function is not mapping about what it is doing. 
This function assume MMU is already enabled with early_table and it will setup final_mmu_setup.

> +{
> +	mmu_disable();
> +	dcache_disable();
> +	icache_disable();
> +	final_mmu_setup();
> +	__asm_invalidate_tlb_all();
> +	mmu_enable();
> +	icache_enable();
> +	set_sctlr(get_sctlr() | CR_C);
> +}
>  #endif

If I am correct board_init_r deploy final_mmu_setup via enable_caches(). 
Why cannot existing framework be used.

> 
>  static inline u32 initiator_type(u32 cluster, int init_id) diff --git
> a/include/common.h b/include/common.h index 75c78d5..57a9b30 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -757,6 +757,7 @@ void	flush_dcache_range(unsigned long start,
> unsigned long stop);
>  void	invalidate_dcache_range(unsigned long start, unsigned long stop);
>  void	invalidate_dcache_all(void);
>  void	invalidate_icache_all(void);
> +void	mmu_init(void);
> 
>  enum {
>  	/* Disable caches (else flush caches but leave them active) */
> --
> 2.1.0.27.g96db324



More information about the U-Boot mailing list