]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: mach-k3: j721e_init: Add support for backup boot modes
authorAndreas Dannenberg <dannenberg@ti.com>
Sat, 16 May 2020 15:35:01 +0000 (21:05 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Tue, 19 May 2020 09:10:54 +0000 (14:40 +0530)
When the boot of J721E devices using the primary bootmode (configured
via device pins) fails a boot using the configured backup bootmode is
attempted. To take advantage of the backup boot mode feature go ahead
and add support to the J721E init code to determine whether the ROM code
performed the boot using the primary or backup boot mode, and if booted
from the backup boot mode, decode the bootmode settings into the
appropriate U-Boot mode accordingly so that the boot can proceed.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
arch/arm/mach-k3/include/mach/j721e_hardware.h
arch/arm/mach-k3/include/mach/j721e_spl.h
arch/arm/mach-k3/j721e_init.c

index ead136ed6381955ef6d9b76e77d409bb850c9f60..2efa911a9a9d025de75779acd4504512d1e4059e 100644 (file)
@@ -18,6 +18,8 @@
 #define MAIN_DEVSTAT_BKUP_BOOTMODE_SHIFT       1
 #define MAIN_DEVSTAT_PRIM_BOOTMODE_MMC_PORT_MASK       BIT(6)
 #define MAIN_DEVSTAT_PRIM_BOOTMODE_PORT_SHIFT          6
+#define MAIN_DEVSTAT_BKUP_MMC_PORT_MASK                        BIT(7)
+#define MAIN_DEVSTAT_BKUP_MMC_PORT_SHIFT               7
 
 #define WKUP_CTRL_MMR0_BASE                            0x43000000
 #define MCU_CTRL_MMR0_BASE                             0x40f00000
index 475278bd041a752da2629e49409fd6f137ba83cc..1cabc01dc49c8146081b66809be91a0c5e00fbc0 100644 (file)
 #define BOOT_DEVICE_MMC2_2             0x16
 #define BOOT_DEVICE_RAM                        0x17
 
+/* Backup boot modes with MCU Only = 0 */
+#define BACKUP_BOOT_DEVICE_RAM         0x0
+#define BACKUP_BOOT_DEVICE_USB         0x1
+#define BACKUP_BOOT_DEVICE_UART                0x3
+#define BACKUP_BOOT_DEVICE_ETHERNET    0x4
+#define BACKUP_BOOT_DEVICE_MMC2                0x5
+#define BACKUP_BOOT_DEVICE_SPI         0x6
+#define BACKUP_BOOT_DEVICE_I2C         0x7
+
 #define BOOT_MODE_B_SHIFT              4
 #define BOOT_MODE_B_MASK               BIT(4)
 
+#define K3_PRIMARY_BOOTMODE            0x0
+#define K3_BACKUP_BOOTMODE             0x1
+
 #endif
index 71fc20c30bfcf4a295bd2c2985fd7a89d36bbe0a..18a3c1c0524bbdfe25270565b2f3a665797c8e2f 100644 (file)
@@ -235,6 +235,35 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
        }
 }
 
+static u32 __get_backup_bootmedia(u32 main_devstat)
+{
+       u32 bkup_boot = (main_devstat & MAIN_DEVSTAT_BKUP_BOOTMODE_MASK) >>
+                       MAIN_DEVSTAT_BKUP_BOOTMODE_SHIFT;
+
+       switch (bkup_boot) {
+       case BACKUP_BOOT_DEVICE_USB:
+               return BOOT_DEVICE_DFU;
+       case BACKUP_BOOT_DEVICE_UART:
+               return BOOT_DEVICE_UART;
+       case BACKUP_BOOT_DEVICE_ETHERNET:
+               return BOOT_DEVICE_ETHERNET;
+       case BACKUP_BOOT_DEVICE_MMC2:
+       {
+               u32 port = (main_devstat & MAIN_DEVSTAT_BKUP_MMC_PORT_MASK) >>
+                           MAIN_DEVSTAT_BKUP_MMC_PORT_SHIFT;
+               if (port == 0x0)
+                       return BOOT_DEVICE_MMC1;
+               return BOOT_DEVICE_MMC2;
+       }
+       case BACKUP_BOOT_DEVICE_SPI:
+               return BOOT_DEVICE_SPI;
+       case BACKUP_BOOT_DEVICE_I2C:
+               return BOOT_DEVICE_I2C;
+       }
+
+       return BOOT_DEVICE_RAM;
+}
+
 static u32 __get_primary_bootmedia(u32 main_devstat, u32 wkup_devstat)
 {
 
@@ -271,8 +300,10 @@ u32 spl_boot_device(void)
        /* MAIN CTRL MMR can only be read if MCU ONLY is 0 */
        main_devstat = readl(CTRLMMR_MAIN_DEVSTAT);
 
-       /* ToDo: Add support for backup boot media */
-       return __get_primary_bootmedia(main_devstat, wkup_devstat);
+       if (bootindex == K3_PRIMARY_BOOTMODE)
+               return __get_primary_bootmedia(main_devstat, wkup_devstat);
+       else
+               return __get_backup_bootmedia(main_devstat);
 }
 #endif