MLK-14991-1 imx8: Add support to get boot device
authorYe Li <ye.li@nxp.com>
Wed, 31 May 2017 08:23:38 +0000 (03:23 -0500)
committerJason Liu <jason.hui.liu@nxp.com>
Thu, 2 Nov 2017 18:36:52 +0000 (02:36 +0800)
For i.MX8QM and QXP, ROM provides rom info structure for passing boot device and
other boot information. Use it to implement the common function get_boot_device.

Signed-off-by: Ye Li <ye.li@nxp.com>
arch/arm/cpu/armv8/imx8/cpu.c
arch/arm/include/asm/arch-imx8/imx-regs.h
arch/arm/include/asm/arch-imx8/sys_proto.h
arch/arm/include/asm/imx-common/boot_mode.h

index 503e00a..6a926b0 100644 (file)
@@ -9,12 +9,14 @@
 #include <errno.h>
 #include <asm/io.h>
 #include <asm/imx-common/sci/sci.h>
+#include <asm/imx-common/boot_mode.h>
 #include <asm/arch/i2c.h>
 #include <asm/arch/clock.h>
 #include <asm/armv8/mmu.h>
 #include <elf.h>
 #include <asm/arch/sid.h>
 #include <asm/arch-imx/cpu.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -289,7 +291,7 @@ int init_i2c_power(unsigned i2c_num)
 #define FUSE_MAC0_WORD0 452
 #define FUSE_MAC0_WORD1 453
 #define FUSE_MAC1_WORD0 454
-#define FUSE_MAC1_WORD1 455 
+#define FUSE_MAC1_WORD1 455
 void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 {
        sc_err_t err;
@@ -584,3 +586,38 @@ void arch_preboot_os(void)
        imx8_config_smmu_sid(dev_sids, ARRAY_SIZE(dev_sids));
 }
 #endif
+
+enum boot_device get_boot_device(void)
+{
+       struct rom_sw_info_t **p =
+               (struct rom_sw_info_t **)ROM_SW_INFO_ADDR;
+
+       enum boot_device boot_dev = SD1_BOOT;
+       uint8_t boot_type = (*p)->boot_dev_info.dev_type;
+       uint8_t boot_instance = (*p)->boot_dev_info.instance;
+
+       switch (boot_type) {
+       case FLASH_TYPE_SD:
+               boot_dev = boot_instance + SD1_BOOT;
+               break;
+       case FLASH_TYPE_MMC:
+               boot_dev = boot_instance + MMC1_BOOT;
+               break;
+       case FLASH_TYPE_NAND:
+               boot_dev = NAND_BOOT;
+               break;
+       case FLASH_TYPE_FLEXSPINOR:
+               boot_dev = QSPI_BOOT;
+               break;
+       case BT_DEV_TYPE_SATA_DISK:
+               boot_dev = SATA_BOOT;
+               break;
+       case BT_DEV_TYPE_USB:
+               boot_dev = USB_BOOT;
+               break;
+       default:
+               break;
+       }
+
+       return boot_dev;
+}
index 4166e95..376bf00 100644 (file)
@@ -32,4 +32,6 @@
 #define LPUART_BASE            SCU_LPUART_BASE
 #endif
 
+#define ROM_SW_INFO_ADDR       0x00000890
+
 #endif /* __ASM_ARCH_IMX_REGS_H__ */
index a5dbb47..aee4592 100644 (file)
@@ -5,6 +5,38 @@
  */
 
 #include <asm/imx-common/sys_proto.h>
+#include <linux/types.h>
+
+enum boot_dev_type {
+       FLASH_TYPE_SD = 1,
+       FLASH_TYPE_MMC = 2,
+       FLASH_TYPE_NAND = 3,
+       FLASH_TYPE_FLEXSPINOR = 4,
+       FLASH_TYPE_WEIM = 5,
+       FLASH_TYPE_EEPROM = 6,
+       BT_DEV_TYPE_SATA_DISK = 7,
+
+       BT_DEV_TYPE_CAN = 0xC,
+       BT_DEV_TYPE_UART = 0xD,
+       BT_DEV_TYPE_USB = 0xE,
+       BT_DEV_TYPE_MEM_DEV = 0xF
+};
+
+struct boot_dev_info_t {
+       uint8_t bt_type;
+       uint8_t instance;
+       uint8_t dev_type;
+       uint8_t rsvd2;
+};
+
+struct rom_sw_info_t {
+       struct boot_dev_info_t boot_dev_info;
+       uint32_t core_freq;
+       uint32_t axi_freq;
+       uint32_t ddr_freq;
+       uint32_t rom_tick_freq;
+       uint32_t rsvd[3];
+};
 
 int init_qspi_power(void);
 int init_usb_power(void);
index 9599191..2c77233 100644 (file)
@@ -30,6 +30,7 @@ enum boot_device {
        MMC4_BOOT,
        NAND_BOOT,
        QSPI_BOOT,
+       FLEXSPI_BOOT,
        USB_BOOT,
        UNKNOWN_BOOT,
        BOOT_DEV_NUM = UNKNOWN_BOOT,