[U-Boot] [PATCH v2 6/8] reset: socfpga: add reset handling for old kernels

Marek Vasut marex at denx.de
Thu Feb 21 21:51:31 UTC 2019


On 2/21/19 10:43 PM, Simon Goldschmidt wrote:
> This adds code to take peripherals out of reset based on an environment
> variable. This is in preparation for removing the code that does this from
> SPL.
> 
> However, some drivers even in current Linux cannot handle peripheral reset,
> so until this works, we need a compatibility workaround.
> 
> This workaround is implemented in the 'remove' callback of this reset
> driver, which is called on OS_PREPARE: it checks if the environment
> variable "socfpga_permodrst_ungate" - if it is set to 1, it deasserts all
> peripheral resets, which is what the gen5 SPL did up to now.
> 
> This is in preparation to clean up the SPL and implementing proper reset
> handling for U-Boot.
> 
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
> ---
> 
> Changes in v2:
> - moved from Kernel option "OLD_SOCFPGA_KERNEL_COMPAT" to environment
>   variable "socfpga_permodrst_ungate"
> 
>  drivers/reset/reset-socfpga.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
> index b2acfcd2ec..749f671e05 100644
> --- a/drivers/reset/reset-socfpga.c
> +++ b/drivers/reset/reset-socfpga.c
> @@ -89,6 +89,36 @@ static int socfpga_reset_probe(struct udevice *dev)
>  	return 0;
>  }
>  
> +#ifndef CONFIG_SPL_BUILD
> +/*
> + * This remove function is called before starting OS to deassert peripheral
> + * resets for Kernels that don't support this.
> + *
> + * The reset driver checks the environment variable "socfpga_permodrst_ungate"
> + * when it is removed. If this variable is '1', all peripherals in 'permodrst'
> + * are taken out of reset before booting into the OS.
> + * This should be required for gen5 systems only that are running Linux kernels
> + * without proper peripheral reset support for all drivers used.
> + */
> +static int socfpga_reset_remove(struct udevice *dev)
> +{
> +	struct socfpga_reset_data *data = dev_get_priv(dev);
> +	const char *env_str;
> +	long val;
> +
> +	env_str = env_get("socfpga_permodrst_ungate");
> +	if (env_str) {
> +		val = simple_strtol(env_str, NULL, 0);
> +		if (val == 1) {
> +			puts("Deasserting all peripheral resets\n");
> +			writel(0, data->membase + 4);
> +		}
> +	}
> +
> +	return 0;
> +}
> +#endif
> +
>  static const struct udevice_id socfpga_reset_match[] = {
>  	{ .compatible = "altr,rst-mgr" },
>  	{ /* sentinel */ },
> @@ -101,4 +131,8 @@ U_BOOT_DRIVER(socfpga_reset) = {
>  	.probe = socfpga_reset_probe,
>  	.priv_auto_alloc_size = sizeof(struct socfpga_reset_data),
>  	.ops = &socfpga_reset_ops,
> +#ifndef CONFIG_SPL_BUILD
> +	.remove = socfpga_reset_remove,
> +	.flags	= DM_FLAG_OS_PREPARE,
> +#endif
>  };

Does this work if you use Falcon mode ? :)

-- 
Best regards,
Marek Vasut


More information about the U-Boot mailing list