summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorJianlong Huang <jianlong.huang@starfivetech.com>2022-09-07 05:20:52 +0300
committerJianlong Huang <jianlong.huang@starfivetech.com>2022-11-03 11:29:26 +0300
commit62abf7817bc66ed679534d75d904b029713cade3 (patch)
treeb5a9c5fabce65a9631babb7b28c4190211d9094a /board
parenta4c05f0a0f3f67aeefe8c853f329dcd1981d39ec (diff)
downloadu-boot-62abf7817bc66ed679534d75d904b029713cade3.tar.xz
Support scan to boot from sd card or emmc
Get bootmode, if bootmode is flash, then default boot from sd card. Signed-off-by: Jianlong Huang <jianlong.huang@starfivetech.com>
Diffstat (limited to 'board')
-rwxr-xr-xboard/starfive/visionfive2/starfive_visionfive2.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c
index 2aa567ff85..c3ce8f7553 100755
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -20,6 +20,13 @@
#define SYS_CLOCK_ENABLE(clk) \
setbits_le32(SYS_CRG_BASE + clk, CLK_ENABLE_MASK)
+enum {
+ BOOT_FLASH = 0,
+ BOOT_SD,
+ BOOT_EMMC,
+ BOOT_UART,
+};
+
static void sys_reset_clear(ulong assert, ulong status, u32 rst)
{
u32 value;
@@ -209,6 +216,34 @@ static void jh7110_i2c_init(int id)
}
}
+static void get_boot_mode(void)
+{
+ u32 value;
+
+ value = in_le32(AON_IOMUX_BASE + AON_GPIO_DIN_REG);
+ switch (value & 0x03) {
+ case BOOT_FLASH:
+ env_set("bootmode", "flash");
+ env_set("devnum", "1");
+ break;
+
+ case BOOT_SD:
+ env_set("bootmode", "sd");
+ env_set("devnum", "1");
+ break;
+
+ case BOOT_EMMC:
+ env_set("bootmode", "emmc");
+ env_set("devnum", "0");
+ break;
+
+ default:
+ env_set("bootmode", "uart");
+ env_set("devnum", "1");
+ break;
+ }
+}
+
int board_init(void)
{
enable_caches();
@@ -231,6 +266,15 @@ int board_init(void)
return 0;
}
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+ get_boot_mode();
+
+ return 0;
+}
+#endif
+
#ifdef CONFIG_MISC_INIT_R
int misc_init_r(void)