Introduce CONFIG_SOCFPGA_RESET_LEGACY_COMPAT to control whether all peripheral resets are deasserted before booting into the OS. This behaviour is only required for systems running Linux kernels that lack proper peripheral reset driver support.
Previously the decision was driven solely by the environment variable socfpga_legacy_reset_compat, which defaulted to 1 across all SoCFPGA targets. The new Kconfig option defaults to y for all ARCH_SOCFPGA targets to preserve existing behaviour, but allows individual platforms to opt out at compile time. When the option is disabled, the bulk deassertion is skipped unconditionally and the environment variable is ignored. Since the Kconfig option is now the single source of truth, the hardcoded socfpga_legacy_reset_compat=1 default environment string is removed from SoCFPGA board configs and from the keymile secu1 board .env file. This is a no-op for boards that keep CONFIG_SOCFPGA_RESET_LEGACY_COMPAT=y, since the driver falls back to true when the variable is absent, but removes a redundant source of truth and keeps the configuration consistent across platforms. Runtime override via setenv remains functional for platforms with the option enabled. Signed-off-by: Chen Huei Lok <[email protected]> --- board/keymile/secu1/socfpga_secu.env | 1 - drivers/reset/Kconfig | 12 +++++++++++ drivers/reset/reset-socfpga.c | 30 ++++++++++++-------------- include/configs/socfpga_common.h | 1 - include/configs/socfpga_dbm_soc1.h | 3 +-- include/configs/socfpga_mcvevk.h | 1 - include/configs/socfpga_soc64_common.h | 3 --- include/configs/socfpga_vining_fpga.h | 3 +-- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/board/keymile/secu1/socfpga_secu.env b/board/keymile/secu1/socfpga_secu.env index 60999882958..417330a5503 100644 --- a/board/keymile/secu1/socfpga_secu.env +++ b/board/keymile/secu1/socfpga_secu.env @@ -12,7 +12,6 @@ load=tftpboot ${loadaddr} u-boot-with-nand-spl.sfp loadaddr=CONFIG_KM_KERNEL_ADDR newenv=nand erase 0x100000 0x40000 release=run newenv; reset -socfpga_legacy_reset_compat=1 update=nand erase 0x0 0x00100000 && nand write ${loadaddr} 0x0 ${filesize} userload=ubi part nand.ubi && diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index e7c0870c918..0ddfc76756b 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -147,6 +147,18 @@ config RESET_SOCFPGA help Support for reset controller on SoCFPGA platform. +config SOCFPGA_RESET_LEGACY_COMPAT + bool "SoCFPGA legacy peripheral reset compatibility" + depends on RESET_SOCFPGA + default y + help + When enabled, all peripheral resets are deasserted before booting + into the OS. This is required for systems running Linux kernels that + lack proper peripheral reset driver support (typically gen5 and + Arria10 platforms, Stratix10, Agilex, Agilex5, Agilex7m, N5X). + Disable for future platforms whose kernels have full peripheral + reset driver support. + config RESET_MEDIATEK bool "Reset controller driver for MediaTek SoCs" depends on DM_RESET && ARCH_MEDIATEK && CLK diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c index 36a205f9fca..26e7fae3f74 100644 --- a/drivers/reset/reset-socfpga.c +++ b/drivers/reset/reset-socfpga.c @@ -32,34 +32,32 @@ struct socfpga_reset_data { void __iomem *modrst_base; }; -/* - * For compatibility with Kernels that don't support peripheral reset, this - * driver can keep the old behaviour of not asserting peripheral reset before - * starting the OS and deasserting all peripheral resets (enabling all - * peripherals). +/** + * socfpga_reset_keep_enabled() - decide whether to bulk-deassert before OS * - * For that, the reset driver checks the environment variable - * "socfpga_legacy_reset_compat". If this variable is '1', perihperals are not - * reset again once taken out of reset and all peripherals in 'permodrst' are - * taken out of reset before booting into the OS. - * Note that this should be required for gen5 systems only that are running - * Linux kernels without proper peripheral reset support for all drivers used. + * Called from .remove (DM_FLAG_OS_PREPARE) on the U-Boot proper hand-off + * path. When CONFIG_SOCFPGA_RESET_LEGACY_COMPAT is disabled, always return + * false. Otherwise honour env "socfpga_legacy_reset_compat" if present + * (true only for value 1); if absent, return true so behaviour matches the + * former hardcoded =1 default env entries removed by this series. */ static bool socfpga_reset_keep_enabled(void) { + if (!IS_ENABLED(CONFIG_SOCFPGA_RESET_LEGACY_COMPAT)) + return false; + #if !defined(CONFIG_XPL_BUILD) || CONFIG_IS_ENABLED(ENV_SUPPORT) - const char *env_str; + const char *env_str = env_get("socfpga_legacy_reset_compat"); long val; - env_str = env_get("socfpga_legacy_reset_compat"); if (env_str) { val = simple_strtol(env_str, NULL, 0); - if (val == 1) - return true; + return val == 1; } #endif - return false; + /* Env absent: preserve legacy bulk-deassert. */ + return true; } static int socfpga_reset_assert(struct reset_ctl *reset_ctl) diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h index 36d6bfb3d03..c67e1f9d894 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -153,7 +153,6 @@ "scriptaddr=0x02100000\0" \ "pxefile_addr_r=0x02200000\0" \ "ramdisk_addr_r=0x02300000\0" \ - "socfpga_legacy_reset_compat=1\0" \ BOOTENV #endif diff --git a/include/configs/socfpga_dbm_soc1.h b/include/configs/socfpga_dbm_soc1.h index 565a661258f..ebbab4966c7 100644 --- a/include/configs/socfpga_dbm_soc1.h +++ b/include/configs/socfpga_dbm_soc1.h @@ -79,8 +79,7 @@ "echo Running bootscript... ; " \ "source ${kernel_addr_r} ; " \ "fi ; " \ - "fi\0" \ - "socfpga_legacy_reset_compat=1\0" + "fi\0" /* The rest of the configuration is shared */ #include <configs/socfpga_common.h> diff --git a/include/configs/socfpga_mcvevk.h b/include/configs/socfpga_mcvevk.h index ac70d91e208..22005929ed3 100644 --- a/include/configs/socfpga_mcvevk.h +++ b/include/configs/socfpga_mcvevk.h @@ -21,7 +21,6 @@ "netdev=eth0\0" \ "hostname=mcvevk\0" \ "kernel_addr_r=0x10000000\0" \ - "socfpga_legacy_reset_compat=1\0" \ "bootm_size=0xa000000\0" \ "dfu_alt_info=mmc raw 0 3867148288\0" \ "update_filename=u-boot-with-spl.sfp\0" \ diff --git a/include/configs/socfpga_soc64_common.h b/include/configs/socfpga_soc64_common.h index 4d333c63ad9..7ff4b31c496 100644 --- a/include/configs/socfpga_soc64_common.h +++ b/include/configs/socfpga_soc64_common.h @@ -144,7 +144,6 @@ " ${qspi_clock}; echo QSPI clock frequency updated; fi; fi\0" \ "scriptaddr=0x81000000\0" \ "scriptfile=boot.scr\0" \ - "socfpga_legacy_reset_compat=1\0" \ "smc_fid_rd=0xC2000007\0" \ "smc_fid_wr=0xC2000008\0" \ "smc_fid_upd=0xC2000009\0 " \ @@ -177,7 +176,6 @@ "scriptaddr=0x05FF0000\0" \ "scriptfile=boot.scr\0" \ "nandroot=ubi0:rootfs\0" \ - "socfpga_legacy_reset_compat=1\0" \ "smc_fid_rd=0xC2000007\0" \ "smc_fid_wr=0xC2000008\0" \ "smc_fid_upd=0xC2000009\0 " \ @@ -236,7 +234,6 @@ " root=${nandroot} rw rootwait rootfstype=ubifs ubi.mtd=1; " \ "bootm ${loadaddr}\0" \ "nandfitload=ubi part root; ubi readvol ${loadaddr} kernel\0" \ - "socfpga_legacy_reset_compat=1\0" \ "smc_fid_rd=0xC2000007\0" \ "smc_fid_wr=0xC2000008\0" \ "smc_fid_upd=0xC2000009\0 " diff --git a/include/configs/socfpga_vining_fpga.h b/include/configs/socfpga_vining_fpga.h index ad13f1345b0..8c04006bf50 100644 --- a/include/configs/socfpga_vining_fpga.h +++ b/include/configs/socfpga_vining_fpga.h @@ -181,8 +181,7 @@ "led 1 on ; " /* Top RED */ \ "run ubi_ubi ; " \ "else echo \"Unsupported boot mode: \"${bootmode} ; " \ - "fi\0" \ - "socfpga_legacy_reset_compat=1\0" + "fi\0" /* The rest of the configuration is shared */ #include <configs/socfpga_common.h> -- 2.43.7
