aboutsummaryrefslogtreecommitdiff
path: root/package/boot/uboot-mediatek
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2024-02-24 03:00:27 +0000
committerDaniel Golle <daniel@makrotopia.org>2024-02-24 03:02:35 +0000
commit6368ed1ae5b628898b33273c8950f7b7575e4414 (patch)
tree45696ee55fb1b536e810dfcf6665e78a12371ce7 /package/boot/uboot-mediatek
parent9b6427e9083fc2baeb67fca977f621d0c93fd6f2 (diff)
mediatek: mt7623: phase out uImage.FIT partition parser
Use the new fitblk driver on the BananaPi R2 as well as UniElec U7623. Introduce boot device selection for fitblk's /chosen/rootdisk handle, similar to how it is already done on MT7622, MT7986 and MT7988. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/boot/uboot-mediatek')
-rw-r--r--package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch46
-rw-r--r--package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch7
-rw-r--r--package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch46
-rw-r--r--package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch12
-rw-r--r--package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch21
5 files changed, 102 insertions, 30 deletions
diff --git a/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch b/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch
new file mode 100644
index 0000000000..86c48badda
--- /dev/null
+++ b/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch
@@ -0,0 +1,46 @@
+--- a/board/mediatek/mt7623/mt7623_rfb.c
++++ b/board/mediatek/mt7623/mt7623_rfb.c
+@@ -5,6 +5,7 @@
+
+ #include <common.h>
+ #include <mmc.h>
++#include <part.h>
+ #include <asm/global_data.h>
+
+ DECLARE_GLOBAL_DATA_PTR;
+@@ -22,8 +23,9 @@ int mmc_get_boot_dev(void)
+ {
+ int g_mmc_devid = -1;
+ char *uflag = (char *)0x81DFFFF0;
++ struct blk_desc *desc;
+
+- if (!find_mmc_device(1))
++ if (blk_get_device_by_str("mmc", "1", &desc) < 0)
+ return 0;
+
+ if (strncmp(uflag,"eMMC",4)==0) {
+@@ -38,6 +40,23 @@ int mmc_get_boot_dev(void)
+
+ int mmc_get_env_dev(void)
+ {
+- return mmc_get_boot_dev();
++ struct udevice *dev;
++ const char *mmcdev;
++
++ switch (mmc_get_boot_dev()) {
++ case 0:
++ mmcdev = "mmc@11230000";
++ break;
++ case 1:
++ mmcdev = "mmc@11240000";
++ break;
++ default:
++ return -1;
++ }
++
++ if (uclass_get_device_by_name(UCLASS_MMC, mmcdev, &dev))
++ return -1;
++
++ return dev_seq(dev);
+ }
+ #endif
diff --git a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch
index 928dfe8428..b8d89058a2 100644
--- a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch
+++ b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch
@@ -1,6 +1,6 @@
--- a/board/mediatek/mt7623/mt7623_rfb.c
+++ b/board/mediatek/mt7623/mt7623_rfb.c
-@@ -4,8 +4,17 @@
+@@ -4,9 +4,18 @@
*/
#include <common.h>
@@ -9,6 +9,7 @@
+#include <env.h>
+#include <init.h>
#include <mmc.h>
+ #include <part.h>
#include <asm/global_data.h>
+#include <linux/delay.h>
+
@@ -18,8 +19,8 @@
DECLARE_GLOBAL_DATA_PTR;
-@@ -41,3 +50,25 @@ int mmc_get_env_dev(void)
- return mmc_get_boot_dev();
+@@ -60,3 +69,25 @@ int mmc_get_env_dev(void)
+ return dev_seq(dev);
}
#endif
+
diff --git a/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch
new file mode 100644
index 0000000000..0089307bbd
--- /dev/null
+++ b/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch
@@ -0,0 +1,46 @@
+--- a/board/mediatek/mt7623/mt7623_rfb.c
++++ b/board/mediatek/mt7623/mt7623_rfb.c
+@@ -91,3 +91,43 @@ int board_late_init(void)
+ env_relocate();
+ return 0;
+ }
++
++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;
++
++#ifdef CONFIG_MMC
++ switch (mmc_get_boot_dev()) {
++ case 0:
++ media = "rootdisk-emmc";
++ break
++ ;;
++ case 1:
++ 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));
++#endif
++
++ return 0;
++}
diff --git a/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch b/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch
index ca011aeca9..ab3424e6b5 100644
--- a/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch
+++ b/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch
@@ -1,6 +1,6 @@
--- a/configs/mt7623n_bpir2_defconfig
+++ b/configs/mt7623n_bpir2_defconfig
-@@ -7,34 +7,105 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
+@@ -7,34 +7,106 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
CONFIG_NR_DRAM_BANKS=1
CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x81ffff10
@@ -18,6 +18,7 @@
+CONFIG_LED_GPIO=y
+CONFIG_LOGLEVEL=7
+CONFIG_LOG=y
++CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_MENU_SHOW=y
+CONFIG_BOARD_LATE_INIT=y
@@ -110,7 +111,7 @@
CONFIG_USE_IPADDR=y
CONFIG_IPADDR="192.168.1.1"
CONFIG_USE_SERVERIP=y
-@@ -46,6 +117,12 @@ CONFIG_CLK=y
+@@ -46,6 +118,12 @@ CONFIG_CLK=y
CONFIG_SUPPORT_EMMC_BOOT=y
CONFIG_MMC_HS400_SUPPORT=y
CONFIG_MMC_MTK=y
@@ -123,7 +124,7 @@
CONFIG_PHY_FIXED=y
CONFIG_MEDIATEK_ETH=y
CONFIG_PINCTRL=y
-@@ -55,10 +132,13 @@ CONFIG_POWER_DOMAIN=y
+@@ -55,10 +133,13 @@ CONFIG_POWER_DOMAIN=y
CONFIG_MTK_POWER_DOMAIN=y
CONFIG_DM_SERIAL=y
CONFIG_MTK_SERIAL=y
@@ -139,7 +140,7 @@
# CONFIG_EFI_GRUB_ARM32_WORKAROUND is not set
--- /dev/null
+++ b/bananapi_bpi-r2_env
-@@ -0,0 +1,70 @@
+@@ -0,0 +1,69 @@
+ipaddr=192.168.1.1
+serverip=192.168.1.254
+loadaddr=0x88000000
@@ -192,14 +193,13 @@
+sdmmc_write_recovery=iminfo $fileaddr && mmc dev 1 && part start mmc 1 $part_recovery part_addr && part size mmc 1 $part_recovery part_size && run mmc_write_vol
+_checkbootedfrom=setenv _checkbootedfrom ; if itest.l *81dffff0 == 434d4d65 ; then setenv bootedfrom eMMC ; else setenv bootedfrom SD ; fi
+_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv
-+_firstboot=setenv _firstboot ; led $bootled_pwr off ;led $bootled_rec on ; run _checkbootedfrom _switch_to_menu _update_bootdev _update_bootcmd _update_bootcmd2 _init_env boot_first
++_firstboot=setenv _firstboot ; led $bootled_pwr off ;led $bootled_rec on ; run _checkbootedfrom _switch_to_menu _update_bootcmd _update_bootcmd2 _init_env boot_first
+_set_bootcmd_sdmmc=setenv boot_production "led $bootled_rec off ; led $bootled_pwr on ; run sdmmc_read_production && bootm $loadaddr ; led $bootled_pwr off"
+_set_bootcmd_emmc=setenv boot_production "led $bootled_rec off ; led $bootled_pwr on ; run emmc_read_production && bootm $loadaddr ; led $bootled_pwr off"
+_update_bootcmd=setenv _update_bootcmd ; if test "$bootedfrom" = "SD" ; then run _set_bootcmd_sdmmc ; else run _set_bootcmd_emmc ; fi ; setenv _set_bootcmd_sdmmc ; setenv _set_bootcmd_emmc
+_set_bootcmd2_sdmmc=setenv boot_recovery "led $bootled_pwr off ; led $bootled_rec on ; run sdmmc_read_recovery && bootm $loadaddr ; led $bootled_rec off"
+_set_bootcmd2_emmc=setenv boot_recovery "led $bootled_pwr off ; led $bootled_rec on ; run emmc_read_recovery && bootm $loadaddr ; led $bootled_rec off"
+_update_bootcmd2=setenv _update_bootcmd2 ; if test "$bootedfrom" = "SD" ; then run _set_bootcmd2_sdmmc ; else run _set_bootcmd2_emmc ; fi ; setenv _set_bootcmd2_sdmmc ; setenv _set_bootcmd2_emmc
-+_update_bootdev=setenv _update_bootdev ; if test "$bootedfrom" = "SD" ; then setenv bootargs "$console root=/dev/mmcblk1p65" ; else setenv bootargs "$console root=/dev/mmcblk0p65" ; fi
+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title [$bootedfrom] $ver" ; run _set_bm2
+_set_bm2=setenv _set_bm2 ; setenv bootmenu_2 "Boot production system from $bootedfrom.=run boot_production ; run bootmenu_confirm_return" ; run _set_bm3
diff --git a/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch b/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch
deleted file mode 100644
index 2f0ed85e53..0000000000
--- a/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/board/mediatek/mt7623/mt7623_rfb.c
-+++ b/board/mediatek/mt7623/mt7623_rfb.c
-@@ -9,6 +9,7 @@
- #include <env.h>
- #include <init.h>
- #include <mmc.h>
-+#include <part.h>
- #include <asm/global_data.h>
- #include <linux/delay.h>
-
-@@ -31,8 +32,9 @@ int mmc_get_boot_dev(void)
- {
- int g_mmc_devid = -1;
- char *uflag = (char *)0x81DFFFF0;
-+ struct blk_desc *desc;
-
-- if (!find_mmc_device(1))
-+ if (blk_get_device_by_str("mmc", "1", &desc) < 0)
- return 0;
-
- if (strncmp(uflag,"eMMC",4)==0) {