[PATCH v2 06/19] arm: mach-k3: sysfw-loader: Add support for rom loading sysfw image

Suman Anna s-anna at ti.com
Thu Aug 6 15:40:53 CEST 2020


On 8/5/20 12:14 PM, Lokesh Vutla wrote:
> Starting J7200 SoC, ROM supports for loading sysfw directly from boot
> image. In such cases, SPL need not load sysfw from boot media, but need
> to receive boot notification message from sysfw. So separate out
> remoteproc calls for system controller from sysfw loader and just
> receive the boot notification if sysfw is already loaded.
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla at ti.com>

Reviewed-by: Suman Anna <s-anna at ti.com>

> ---
>  arch/arm/mach-k3/am6_init.c                  |  2 +-
>  arch/arm/mach-k3/include/mach/sysfw-loader.h |  4 +-
>  arch/arm/mach-k3/j721e_init.c                |  2 +-
>  arch/arm/mach-k3/sysfw-loader.c              | 56 +++++++++++++-------
>  4 files changed, 43 insertions(+), 21 deletions(-)
> 
> diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
> index e66d1c1fe1..603834e507 100644
> --- a/arch/arm/mach-k3/am6_init.c
> +++ b/arch/arm/mach-k3/am6_init.c
> @@ -216,7 +216,7 @@ void board_init_f(ulong dummy)
>  	 * Load, start up, and configure system controller firmware while
>  	 * also populating the SYSFW post-PM configuration callback hook.
>  	 */
> -	k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock);
> +	k3_sysfw_loader(false, k3_mmc_stop_clock, k3_mmc_restart_clock);
>  
>  	/* Prepare console output */
>  	preloader_console_init();
> diff --git a/arch/arm/mach-k3/include/mach/sysfw-loader.h b/arch/arm/mach-k3/include/mach/sysfw-loader.h
> index 6f5612b4fd..b23a9e821e 100644
> --- a/arch/arm/mach-k3/include/mach/sysfw-loader.h
> +++ b/arch/arm/mach-k3/include/mach/sysfw-loader.h
> @@ -7,6 +7,8 @@
>  #ifndef _SYSFW_LOADER_H_
>  #define _SYSFW_LOADER_H_
>  
> -void k3_sysfw_loader(void (*config_pm_pre_callback)(void), void (*config_pm_done_callback)(void));
> +void k3_sysfw_loader(bool rom_loaded_sysfw,
> +		     void (*config_pm_pre_callback)(void),
> +		     void (*config_pm_done_callback)(void));
>  
>  #endif
> diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
> index 2010cab1d1..461a9d7f8f 100644
> --- a/arch/arm/mach-k3/j721e_init.c
> +++ b/arch/arm/mach-k3/j721e_init.c
> @@ -174,7 +174,7 @@ void board_init_f(ulong dummy)
>  	 * callback hook, effectively switching on (or over) the console
>  	 * output.
>  	 */
> -	k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock);
> +	k3_sysfw_loader(false, k3_mmc_stop_clock, k3_mmc_restart_clock);
>  
>  	/* Prepare console output */
>  	preloader_console_init();
> diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c
> index f4b0d4a928..78c158c63f 100644
> --- a/arch/arm/mach-k3/sysfw-loader.c
> +++ b/arch/arm/mach-k3/sysfw-loader.c
> @@ -33,6 +33,12 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define SYSFW_CFG_RM			"rm-cfg.bin"
>  #define SYSFW_CFG_SEC			"sec-cfg.bin"
>  
> +/*
> + * It is assumed that remoteproc device 0 is the corresponding
> + * system-controller that runs SYSFW. Make sure DT reflects the same.
> + */
> +#define K3_SYSTEM_CONTROLLER_RPROC_ID	0
> +
>  static bool sysfw_loaded;
>  static void *sysfw_load_address;
>  
> @@ -72,6 +78,26 @@ static int fit_get_data_by_name(const void *fit, int images, const char *name,
>  	return fit_image_get_data(fit, node_offset, addr, size);
>  }
>  
> +static void k3_start_system_controller(int rproc_id, bool rproc_loaded,
> +				       ulong addr, ulong size)
> +{
> +	int ret;
> +
> +	ret = rproc_dev_init(rproc_id);
> +	if (ret)
> +		panic("rproc failed to be initialized (%d)\n", ret);
> +
> +	if (!rproc_loaded) {
> +		ret = rproc_load(rproc_id, addr, size);
> +		if (ret)
> +			panic("Firmware failed to start on rproc (%d)\n", ret);
> +	}
> +
> +	ret = rproc_start(0);
> +	if (ret)
> +		panic("Firmware init failed on rproc (%d)\n", ret);
> +}
> +
>  static void k3_sysfw_load_using_fit(void *fit)
>  {
>  	int images;
> @@ -91,23 +117,9 @@ static void k3_sysfw_load_using_fit(void *fit)
>  		panic("Error accessing %s node in FIT (%d)\n", SYSFW_FIRMWARE,
>  		      ret);
>  
> -	/*
> -	 * Start up system controller firmware
> -	 *
> -	 * It is assumed that remoteproc device 0 is the corresponding
> -	 * system-controller that runs SYSFW. Make sure DT reflects the same.
> -	 */
> -	ret = rproc_dev_init(0);
> -	if (ret)
> -		panic("rproc failed to be initialized (%d)\n", ret);
> -
> -	ret = rproc_load(0, (ulong)sysfw_addr, (ulong)sysfw_size);
> -	if (ret)
> -		panic("Firmware failed to start on rproc (%d)\n", ret);
> -
> -	ret = rproc_start(0);
> -	if (ret)
> -		panic("Firmware init failed on rproc (%d)\n", ret);
> +	/* Start up system controller firmware */
> +	k3_start_system_controller(K3_SYSTEM_CONTROLLER_RPROC_ID, false,
> +				   (ulong)sysfw_addr, (ulong)sysfw_size);
>  }
>  
>  static void k3_sysfw_configure_using_fit(void *fit,
> @@ -223,7 +235,8 @@ static void *k3_sysfw_get_spi_addr(void)
>  }
>  #endif
>  
> -void k3_sysfw_loader(void (*config_pm_pre_callback) (void),
> +void k3_sysfw_loader(bool rom_loaded_sysfw,
> +		     void (*config_pm_pre_callback)(void),
>  		     void (*config_pm_done_callback)(void))
>  {
>  	struct spl_image_info spl_image = { 0 };
> @@ -231,6 +244,13 @@ void k3_sysfw_loader(void (*config_pm_pre_callback) (void),
>  	struct ti_sci_handle *ti_sci;
>  	int ret = 0;
>  
> +	if (rom_loaded_sysfw) {
> +		k3_start_system_controller(K3_SYSTEM_CONTROLLER_RPROC_ID,
> +					   rom_loaded_sysfw, 0, 0);
> +		sysfw_loaded = true;
> +		return;
> +	}
> +
>  	/* Reserve a block of aligned memory for loading the SYSFW image */
>  	sysfw_load_address = memalign(ARCH_DMA_MINALIGN,
>  				      CONFIG_K3_SYSFW_IMAGE_SIZE_MAX);
> 



More information about the U-Boot mailing list