* [PATCH] common: spl: nand: improve u-boot offsets overriding
@ 2026-04-14 8:03 Weijie Gao
2026-04-14 15:18 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Weijie Gao @ 2026-04-14 8:03 UTC (permalink / raw)
To: u-boot; +Cc: GSS_MTK_Uboot_upstream, Tom Rini, Weijie Gao
This patch introduces spl_nand_get_uboot_raw_page_redund() to wrap the
CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND macro, similar as what
spl_nand_get_uboot_raw_page() has already done.
Also, make it possible to use these functions without defining related
macros.
This patch also replaces all references to CONFIG_SYS_NAND_U_BOOT_OFFS and
CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND with the return value of the two
functions mentioned above.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
common/spl/spl_nand.c | 38 ++++++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index f449b31f594..cce2e1a6df3 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -18,21 +18,34 @@
uint32_t __weak spl_nand_get_uboot_raw_page(void)
{
+#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS
return CONFIG_SYS_NAND_U_BOOT_OFFS;
+#else
+ return 0;
+#endif
+}
+
+uint32_t __weak spl_nand_get_uboot_raw_page_redund(void)
+{
+#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
+ return CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND;
+#else
+ return 0;
+#endif
}
#if defined(CONFIG_SPL_NAND_RAW_ONLY)
static int spl_nand_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
+ u32 offs = spl_nand_get_uboot_raw_page();
+
nand_init();
printf("Loading U-Boot from 0x%08x (size 0x%08x) to 0x%08x\n",
- CONFIG_SYS_NAND_U_BOOT_OFFS, CFG_SYS_NAND_U_BOOT_SIZE,
- CFG_SYS_NAND_U_BOOT_DST);
+ offs, CFG_SYS_NAND_U_BOOT_SIZE, CFG_SYS_NAND_U_BOOT_DST);
- nand_spl_load_image(spl_nand_get_uboot_raw_page(),
- CFG_SYS_NAND_U_BOOT_SIZE,
+ nand_spl_load_image(offs, CFG_SYS_NAND_U_BOOT_SIZE,
map_sysmem(CFG_SYS_NAND_U_BOOT_DST,
CFG_SYS_NAND_U_BOOT_SIZE));
spl_set_header_raw_uboot(spl_image);
@@ -127,6 +140,7 @@ static int spl_nand_load_image_os(struct spl_image_info *spl_image,
static int spl_nand_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
+ u32 offs = spl_nand_get_uboot_raw_page();
int err;
#ifdef CONFIG_SPL_NAND_SOFTECC
@@ -155,14 +169,14 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
#endif
#endif
/* Load u-boot */
- err = spl_nand_load_element(spl_image, bootdev, spl_nand_get_uboot_raw_page());
-#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
-#if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
- if (err)
- err = spl_nand_load_element(spl_image, bootdev,
- CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND);
-#endif
-#endif
+ err = spl_nand_load_element(spl_image, bootdev, offs);
+ if (err) {
+ u32 offs_redund = spl_nand_get_uboot_raw_page_redund();
+
+ if (offs != offs_redund)
+ err = spl_nand_load_element(spl_image, bootdev,
+ offs_redund);
+ }
nand_deselect();
return err;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] common: spl: nand: improve u-boot offsets overriding
2026-04-14 8:03 [PATCH] common: spl: nand: improve u-boot offsets overriding Weijie Gao
@ 2026-04-14 15:18 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2026-04-14 15:18 UTC (permalink / raw)
To: Weijie Gao; +Cc: u-boot, GSS_MTK_Uboot_upstream
[-- Attachment #1: Type: text/plain, Size: 1558 bytes --]
On Tue, Apr 14, 2026 at 04:03:21PM +0800, Weijie Gao wrote:
> This patch introduces spl_nand_get_uboot_raw_page_redund() to wrap the
> CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND macro, similar as what
> spl_nand_get_uboot_raw_page() has already done.
> Also, make it possible to use these functions without defining related
> macros.
>
> This patch also replaces all references to CONFIG_SYS_NAND_U_BOOT_OFFS and
> CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND with the return value of the two
> functions mentioned above.
>
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> ---
> common/spl/spl_nand.c | 38 ++++++++++++++++++++++++++------------
> 1 file changed, 26 insertions(+), 12 deletions(-)
>
> diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
> index f449b31f594..cce2e1a6df3 100644
> --- a/common/spl/spl_nand.c
> +++ b/common/spl/spl_nand.c
> @@ -18,21 +18,34 @@
>
> uint32_t __weak spl_nand_get_uboot_raw_page(void)
> {
> +#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS
> return CONFIG_SYS_NAND_U_BOOT_OFFS;
> +#else
> + return 0;
> +#endif
> +}
> +
> +uint32_t __weak spl_nand_get_uboot_raw_page_redund(void)
> +{
> +#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
> + return CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND;
> +#else
> + return 0;
> +#endif
> }
This is closer, but not quite what I was thinking. We should be able to
use IF_ENABLED_INT to get either the real value of
CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND or 0, and then maybe (maybe not)
clean up the rest of these changes a bit more. Thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-14 15:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 8:03 [PATCH] common: spl: nand: improve u-boot offsets overriding Weijie Gao
2026-04-14 15:18 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox