[openwrt/openwrt] uboot-mediatek: mt7988: set rootdisk according to boot device

LEDE Commits lede-commits at lists.infradead.org
Thu Feb 15 11:35:04 PST 2024


dangole pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/b165d451bd868d8939ee332c00fe9f307fac7ae6

commit b165d451bd868d8939ee332c00fe9f307fac7ae6
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Tue Dec 5 04:10:31 2023 +0000

    uboot-mediatek: mt7988: set rootdisk according to boot device
    
    If nodes /chosen/rootdisk-${bootdevice} exists, set /chosen/rootdisk
    phandle according to boot device selected by the bootstrap pins.
    
    Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 .../patches/310-mt7988-select-rootdisk.patch       | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch
new file mode 100644
index 0000000000..f6654731cb
--- /dev/null
+++ b/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch
@@ -0,0 +1,66 @@
+--- a/board/mediatek/mt7988/mt7988_rfb.c
++++ b/board/mediatek/mt7988/mt7988_rfb.c
+@@ -11,6 +11,8 @@
+ #include <env.h>
+ #include <init.h>
+ #include <asm/global_data.h>
++#include <asm/io.h>
+ #include <linux/delay.h>
++#include <linux/libfdt.h>
+ 
+ #ifndef CONFIG_RESET_BUTTON_LABEL
+@@ -44,3 +50,54 @@ int board_late_init(void)
+ 	env_relocate();
+ 	return 0;
+ }
++
++#define	MT7988_BOOT_NOR		0
++#define	MT7988_BOOT_SPIM_NAND	1
++#define	MT7988_BOOT_EMMC	2
++#define	MT7988_BOOT_SNFI_NAND	3
++
++int ft_system_setup(void *blob, struct bd_info *bd)
++{
++	const u32 *media_handle_p;
++	int chosen, len, ret;
++	const char *media;
++	u32 media_handle;
++
++	switch ((readl(0x1001f6f0) & 0xc00) >> 10) {
++	case MT7988_BOOT_NOR:
++		media = "rootdisk-nor";
++		break
++		;;
++	case MT7988_BOOT_SPIM_NAND:
++		media = "rootdisk-spim-nand";
++		break
++		;;
++	case MT7988_BOOT_EMMC:
++		media = "rootdisk-emmc";
++		break
++		;;
++	case MT7988_BOOT_SNFI_NAND:
++		media = "rootdisk-sd";
++		break
++		;;
++	}
++
++	chosen = fdt_path_offset(blob, "/chosen");
++	if (chosen <= 0)
++		return 0;
++
++	media_handle_p = fdt_getprop(blob, chosen, media, &len);
++	if (media_handle_p <= 0 || len != 4)
++		return 0;
++
++	media_handle = *media_handle_p;
++	ret = fdt_setprop(blob, chosen, "rootdisk", &media_handle, sizeof(media_handle));
++	if (ret) {
++		printf("cannot set media phandle %s as rootdisk /chosen node\n", media);
++		return ret;
++	}
++
++	printf("set /chosen/rootdisk to bootrom media: %s (phandle 0x%08x)\n", media, fdt32_to_cpu(media_handle));
++
++	return 0;
++}




More information about the lede-commits mailing list