]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pcm052: bk4: sdcard: Add support for SD card booting/recovery
authorLukasz Majewski <lukma@denx.de>
Wed, 13 Feb 2019 21:46:56 +0000 (22:46 +0100)
committerStefano Babic <sbabic@denx.de>
Sat, 13 Apr 2019 18:30:08 +0000 (20:30 +0200)
This code allows reusing the default u-boot as in the late board init, the
default envs are restored and proper recovery scripts executed.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
arch/arm/cpu/armv7/vf610/Kconfig
arch/arm/include/asm/arch-vf610/imx-regs.h
board/phytec/pcm052/pcm052.c

index 13905b5281f21678b8fe5031008411c3eefc745f..5d485a3ce24006e581fdfca29246cbc3a307e7ab 100644 (file)
@@ -23,6 +23,7 @@ config TARGET_BK4R1
        bool "BK4r1"
        select SYS_FSL_ERRATUM_ESDHC135
        select SYS_FSL_ERRATUM_ESDHC_A001
+       select BOARD_LATE_INIT
 
 endchoice
 
index 5d1f63c98bfeaa64ab63efee47f59bd5fa7253b4..ae0a187c4db85e7132df9e0219bc1e1a9c985982 100644 (file)
 #define SRC_SRSR_WDOG_M4                               (0x1 << 4)
 #define SRC_SRSR_WDOG_A5                               (0x1 << 3)
 #define SRC_SRSR_POR_RST                               (0x1 << 0)
+#define SRC_SBMR1_BOOTCFG1_SDMMC        BIT(6)
+#define SRC_SBMR1_BOOTCFG1_MMC          BIT(4)
 #define SRC_SBMR2_BMOD_MASK             (0x3 << 24)
 #define SRC_SBMR2_BMOD_SHIFT            24
 #define SRC_SBMR2_BMOD_FUSES            0x0
index 4a18b0e0f478a085d8bf3f94dfab5e5858cdd069..d4f170a5034b7dccd228b984441eb5760ce09f9d 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/arch/ddrmc-vf610.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/clock.h>
+#include <environment.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -307,6 +308,37 @@ int board_init(void)
        return 0;
 }
 
+#ifdef CONFIG_TARGET_BK4R1
+int board_late_init(void)
+{
+       struct src *psrc = (struct src *)SRC_BASE_ADDR;
+       u32 reg;
+
+       /*
+        * BK4r1 handle emergency/service SD card boot
+        * Checking the SBMR1 register BOOTCFG1 byte:
+        * NAND:
+        *      bit [2] - NAND data width - 16
+        *      bit [5] - NAND fast boot
+        *      bit [7] = 1 - NAND as a source of booting
+        * SD card (0x64):
+        *      bit [4] = 0 - SD card source
+        *      bit [6] = 1 - SD/MMC source
+        */
+
+       reg = readl(&psrc->sbmr1);
+       if ((reg & SRC_SBMR1_BOOTCFG1_SDMMC) &&
+           !(reg & SRC_SBMR1_BOOTCFG1_MMC)) {
+               printf("------ SD card boot -------\n");
+               set_default_env("!LVFBootloader", 0);
+               env_set("bootcmd",
+                       "run prepare_install_bk4r1_envs; run install_bk4r1rs");
+       }
+
+       return 0;
+}
+#endif /* CONFIG_TARGET_BK4R1 */
+
 int checkboard(void)
 {
 #ifdef CONFIG_TARGET_BK4R1