]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
imx: move get_boot_device to common file
authorPeng Fan <peng.fan@nxp.com>
Tue, 26 Jul 2022 08:40:37 +0000 (16:40 +0800)
committerStefano Babic <sbabic@denx.de>
Tue, 26 Jul 2022 09:29:00 +0000 (11:29 +0200)
i.MX8MN/P/ULP supports ROM API, they have almost same get_boot_device
implementation, so move to a common file. And when support i.MX9,
no need to include the other function copy.

Since sys_proto.h is included in imx_romapi.c, there will be build
warning for i.MX8M because wdog_regs not defined, so include imx-regs.h
in i.MX8M sys_proro.h

Signed-off-by: Peng Fan <peng.fan@nxp.com>
arch/arm/include/asm/arch-imx8m/sys_proto.h
arch/arm/mach-imx/Makefile
arch/arm/mach-imx/imx8m/soc.c
arch/arm/mach-imx/imx8ulp/soc.c
arch/arm/mach-imx/romapi.c

index f8854e771284af2f0e02f468629bf528fa306d2f..55b46afaf78b06f199288b9f120387848322459b 100644 (file)
@@ -7,6 +7,7 @@
 #define __ARCH_NMX8M_SYS_PROTO_H
 
 #include <asm/mach-imx/sys_proto.h>
+#include <asm/arch/imx-regs.h>
 
 void set_wdog_reset(struct wdog_regs *wdog);
 void enable_tzc380(void);
index 3cbcb151b86f518b09b8682e61ac9e4f768557cd..fb463634e5005e77add9c65e123fd4e80cdb5adc 100644 (file)
@@ -242,5 +242,6 @@ obj-$(CONFIG_IMX8M) += imx8m/
 obj-$(CONFIG_ARCH_IMX8) += imx8/
 obj-$(CONFIG_ARCH_IMXRT) += imxrt/
 
+obj-$(CONFIG_IMX8MN)$(CONFIG_IMX8MP)$(CONFIG_IMX8ULP) += imx_romapi.o
 obj-$(CONFIG_SPL_BOOTROM_SUPPORT) += spl_imx_romapi.o
 obj-$(CONFIG_IMX8_ROMAPI) += romapi.o
index 81fee5801dbeefe1de42c7413a34bdcd98a8ed8a..d115b25a5b6c04398b8970117dc2da83b108ee4a 100644 (file)
@@ -599,50 +599,6 @@ int arch_cpu_init(void)
 
 #if defined(CONFIG_IMX8MN) || defined(CONFIG_IMX8MP)
 struct rom_api *g_rom_api = (struct rom_api *)0x980;
-
-enum boot_device get_boot_device(void)
-{
-       int ret;
-       u32 boot;
-       u16 boot_type;
-       u8 boot_instance;
-       enum boot_device boot_dev = SD1_BOOT;
-
-       ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot);
-
-       if (ret != ROM_API_OKAY) {
-               puts("ROMAPI: failure at query_boot_info\n");
-               return -1;
-       }
-
-       boot_type = boot >> 16;
-       boot_instance = (boot >> 8) & 0xff;
-
-       switch (boot_type) {
-       case BT_DEV_TYPE_SD:
-               boot_dev = boot_instance + SD1_BOOT;
-               break;
-       case BT_DEV_TYPE_MMC:
-               boot_dev = boot_instance + MMC1_BOOT;
-               break;
-       case BT_DEV_TYPE_NAND:
-               boot_dev = NAND_BOOT;
-               break;
-       case BT_DEV_TYPE_FLEXSPINOR:
-               boot_dev = QSPI_BOOT;
-               break;
-       case BT_DEV_TYPE_SPI_NOR:
-               boot_dev = SPI_NOR_BOOT;
-               break;
-       case BT_DEV_TYPE_USB:
-               boot_dev = USB_BOOT;
-               break;
-       default:
-               break;
-       }
-
-       return boot_dev;
-}
 #endif
 
 #if defined(CONFIG_IMX8M)
index c0f0df356ead7d007f90132deb6d9daff801c26f..9545edc42c5102674cd15e76b71a07444154896a 100644 (file)
@@ -34,47 +34,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct rom_api *g_rom_api = (struct rom_api *)0x1980;
 
-enum boot_device get_boot_device(void)
-{
-       int ret;
-       u32 boot;
-       u16 boot_type;
-       u8 boot_instance;
-       enum boot_device boot_dev = SD1_BOOT;
-
-       ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot);
-
-       if (ret != ROM_API_OKAY) {
-               puts("ROMAPI: failure at query_boot_info\n");
-               return -1;
-       }
-
-       boot_type = boot >> 16;
-       boot_instance = (boot >> 8) & 0xff;
-
-       switch (boot_type) {
-       case BT_DEV_TYPE_SD:
-               boot_dev = boot_instance + SD1_BOOT;
-               break;
-       case BT_DEV_TYPE_MMC:
-               boot_dev = boot_instance + MMC1_BOOT;
-               break;
-       case BT_DEV_TYPE_NAND:
-               boot_dev = NAND_BOOT;
-               break;
-       case BT_DEV_TYPE_FLEXSPINOR:
-               boot_dev = QSPI_BOOT;
-               break;
-       case BT_DEV_TYPE_USB:
-               boot_dev = USB_BOOT;
-               break;
-       default:
-               break;
-       }
-
-       return boot_dev;
-}
-
 bool is_usb_boot(void)
 {
        return get_boot_device() == USB_BOOT;
index 0e7b1d1a001d39e16bdf61a6ef5fdef955d55e92..4b5f50c030098334bc9523d8931f0676d05d15a6 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <asm/global_data.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/mach-imx/boot_mode.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -28,3 +29,49 @@ u32 rom_api_query_boot_infor(u32 info_type, u32 *info)
 
        return ret;
 }
+
+extern struct rom_api *g_rom_api;
+
+enum boot_device get_boot_device(void)
+{
+       volatile gd_t *pgd = gd;
+       int ret;
+       u32 boot;
+       u16 boot_type;
+       u8 boot_instance;
+       enum boot_device boot_dev = SD1_BOOT;
+
+       ret = g_rom_api->query_boot_infor(QUERY_BT_DEV, &boot,
+                                         ((uintptr_t)&boot) ^ QUERY_BT_DEV);
+       set_gd(pgd);
+
+       if (ret != ROM_API_OKAY) {
+               puts("ROMAPI: failure at query_boot_info\n");
+               return -1;
+       }
+
+       boot_type = boot >> 16;
+       boot_instance = (boot >> 8) & 0xff;
+
+       switch (boot_type) {
+       case BT_DEV_TYPE_SD:
+               boot_dev = boot_instance + SD1_BOOT;
+               break;
+       case BT_DEV_TYPE_MMC:
+               boot_dev = boot_instance + MMC1_BOOT;
+               break;
+       case BT_DEV_TYPE_NAND:
+               boot_dev = NAND_BOOT;
+               break;
+       case BT_DEV_TYPE_FLEXSPINOR:
+               boot_dev = QSPI_BOOT;
+               break;
+       case BT_DEV_TYPE_USB:
+               boot_dev = USB_BOOT;
+               break;
+       default:
+               break;
+       }
+
+       return boot_dev;
+}