]> git.sur5r.net Git - u-boot/commitdiff
spl: Convert boot_device into a struct
authorSimon Glass <sjg@chromium.org>
Sun, 25 Sep 2016 00:19:57 +0000 (18:19 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 6 Oct 2016 18:53:36 +0000 (14:53 -0400)
At present some spl_xxx_load_image() functions take a parameter and some
don't. Of those that do, most take an integer but one takes a string.

Convert this parameter into a struct so that we can pass all functions the
same thing. This will allow us to use a common function signature.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
16 files changed:
arch/arm/mach-sunxi/board.c
arch/arm/mach-uniphier/boot-mode/spl_board.c
arch/sandbox/cpu/spl.c
common/spl/spl.c
common/spl/spl_mmc.c
common/spl/spl_nand.c
common/spl/spl_net.c
common/spl/spl_nor.c
common/spl/spl_onenand.c
common/spl/spl_sata.c
common/spl/spl_ubi.c
common/spl/spl_usb.c
common/spl/spl_ymodem.c
drivers/mtd/spi/spi_spl_load.c
drivers/mtd/spi/sunxi_spi_spl.c
include/spl.h

index 6d9518d4c6036a09a7462674df5ef0a940404ef6..8a385a25fdf41b2132d3638da1809370f82a3a19 100644 (file)
@@ -133,7 +133,7 @@ static int gpio_init(void)
        return 0;
 }
 
-int spl_board_load_image(void)
+int spl_board_load_image(struct spl_boot_device *bootdev)
 {
        debug("Returning to FEL sp=%x, lr=%x\n", fel_stash.sp, fel_stash.lr);
        return_to_fel(fel_stash.sp, fel_stash.lr);
index 63ab41ce1b31defe4985a7429a52091de45141eb..4eadc2f26a75a50b07d88fb3176f0a62ad260b8a 100644 (file)
@@ -65,7 +65,7 @@ int uniphier_rom_get_mmc_funcptr(int (**send_cmd)(u32, u32),
        return 0;
 }
 
-int spl_board_load_image(void)
+int spl_board_load_image(struct spl_boot_device *bootdev)
 {
        int (*send_cmd)(u32 cmd, u32 arg);
        int (*card_blockaddr)(u32 rca);
index e8349c0b932d7202d1daac766a4a657f04e3a1c5..4cee293f76a96adad96767f3e72018c09070d724 100644 (file)
@@ -38,7 +38,7 @@ void spl_board_announce_boot_device(void)
        printf("%s\n", fname);
 }
 
-int spl_board_load_image(void)
+int spl_board_load_image(struct spl_boot_device *bootdev)
 {
        char fname[256];
        int ret;
index 6d071312bc50a4ed35e6cdbb886fa1099b7db1a3..167bff07f9d2d9e495b1c0eea6b583a6cb242fb5 100644 (file)
@@ -185,7 +185,7 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
        return count;
 }
 
-static int spl_ram_load_image(void)
+static int spl_ram_load_image(struct spl_boot_device *bootdev)
 {
        struct image_header *header;
 
@@ -349,71 +349,76 @@ static inline void announce_boot_device(u32 boot_device) { }
 
 static int spl_load_image(u32 boot_device)
 {
+       struct spl_boot_device bootdev;
+
+       bootdev.boot_device = boot_device;
+       bootdev.boot_device_name = NULL;
+
        switch (boot_device) {
 #ifdef CONFIG_SPL_RAM_DEVICE
        case BOOT_DEVICE_RAM:
-               return spl_ram_load_image();
+               return spl_ram_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_MMC_SUPPORT
        case BOOT_DEVICE_MMC1:
        case BOOT_DEVICE_MMC2:
        case BOOT_DEVICE_MMC2_2:
-               return spl_mmc_load_image(boot_device);
+               return spl_mmc_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_UBI
        case BOOT_DEVICE_NAND:
        case BOOT_DEVICE_ONENAND:
-               return spl_ubi_load_image(boot_device);
+               return spl_ubi_load_image(&bootdev);
 #else
 #ifdef CONFIG_SPL_NAND_SUPPORT
        case BOOT_DEVICE_NAND:
-               return spl_nand_load_image();
+               return spl_nand_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_ONENAND_SUPPORT
        case BOOT_DEVICE_ONENAND:
-               return spl_onenand_load_image();
+               return spl_onenand_load_image(&bootdev);
 #endif
 #endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
        case BOOT_DEVICE_NOR:
-               return spl_nor_load_image();
+               return spl_nor_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_YMODEM_SUPPORT
        case BOOT_DEVICE_UART:
-               return spl_ymodem_load_image();
+               return spl_ymodem_load_image(&bootdev);
 #endif
 #if defined(CONFIG_SPL_SPI_SUPPORT) || defined(CONFIG_SPL_SPI_FLASH_SUPPORT)
        case BOOT_DEVICE_SPI:
-               return spl_spi_load_image();
+               return spl_spi_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_ETH_SUPPORT
        case BOOT_DEVICE_CPGMAC:
 #ifdef CONFIG_SPL_ETH_DEVICE
-               return spl_net_load_image(CONFIG_SPL_ETH_DEVICE);
-#else
-               return spl_net_load_image(NULL);
+               bootdev.boot_device_name = CONFIG_SPL_ETH_DEVICE;
 #endif
+               return spl_net_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_USBETH_SUPPORT
        case BOOT_DEVICE_USBETH:
-               return spl_net_load_image("usb_ether");
+               bootdev.boot_device_name = "usb_ether";
+               return spl_net_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_USB_SUPPORT
        case BOOT_DEVICE_USB:
-               return spl_usb_load_image();
+               return spl_usb_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_DFU_SUPPORT
        case BOOT_DEVICE_DFU:
                spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
-               return spl_ram_load_image();
+               return spl_ram_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_SATA_SUPPORT
        case BOOT_DEVICE_SATA:
-               return spl_sata_load_image();
+               return spl_sata_load_image(&bootdev);
 #endif
 #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
        case BOOT_DEVICE_BOARD:
-               return spl_board_load_image();
+               return spl_board_load_image(&bootdev);
 #endif
        default:
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
index 97c11b37f66b0e543dd06934ab50598aceeaff07..899caf4a9b536f4b61910ddd6caad36d5cd70dd9 100644 (file)
@@ -267,14 +267,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
 }
 #endif
 
-int spl_mmc_load_image(u32 boot_device)
+int spl_mmc_load_image(struct spl_boot_device *bootdev)
 {
        struct mmc *mmc = NULL;
        u32 boot_mode;
        int err = 0;
        __maybe_unused int part;
 
-       err = spl_mmc_find_device(&mmc, boot_device);
+       err = spl_mmc_find_device(&mmc, bootdev->boot_device);
        if (err)
                return err;
 
@@ -286,7 +286,7 @@ int spl_mmc_load_image(u32 boot_device)
                return err;
        }
 
-       boot_mode = spl_boot_mode(boot_device);
+       boot_mode = spl_boot_mode(bootdev->boot_device);
        err = -EINVAL;
        switch (boot_mode) {
        case MMCSD_MODE_EMMCBOOT:
index f25220f1721be0da088d8698e0e9a41a17159537..575de661d39f9806a4b308ca5b0f2e7ebcdc5896 100644 (file)
@@ -13,7 +13,7 @@
 #include <fdt.h>
 
 #if defined(CONFIG_SPL_NAND_RAW_ONLY)
-int spl_nand_load_image(void)
+int spl_nand_load_image(struct spl_boot_device *bootdev)
 {
        nand_init();
 
index f417d177eb100d172a3b250caafdd93a514c945c..730f88e0d602e21b552a7f8170095f3d88f322f8 100644 (file)
@@ -14,7 +14,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int spl_net_load_image(const char *device)
+int spl_net_load_image(struct spl_boot_device *bootdev)
 {
        int rv;
 
@@ -27,8 +27,8 @@ int spl_net_load_image(const char *device)
                printf("No Ethernet devices found\n");
                return -ENODEV;
        }
-       if (device)
-               setenv("ethact", device);
+       if (bootdev->boot_device_name)
+               setenv("ethact", bootdev->boot_device_name);
        rv = net_loop(BOOTP);
        if (rv < 0) {
                printf("Problem booting with BOOTP\n");
index 57771e8f57833327f5e67c108036e7efc861dc6e..f10d679922f3e0c1c24319c95d383b71828650ef 100644 (file)
@@ -7,7 +7,7 @@
 #include <common.h>
 #include <spl.h>
 
-int spl_nor_load_image(void)
+int spl_nor_load_image(struct spl_boot_device *bootdev)
 {
        int ret;
        /*
index 8d2c51bc479643f8a3056efffe52e310b94331c8..f5e2f95b13ea5090f0602884c9237648ec05e53e 100644 (file)
@@ -14,7 +14,7 @@
 #include <asm/io.h>
 #include <onenand_uboot.h>
 
-int spl_onenand_load_image(void)
+int spl_onenand_load_image(struct spl_boot_device *bootdev)
 {
        struct image_header *header;
        int ret;
index 9d8cc7c2ddf7a75eb9da4c61f1ca38216277f153..77fd73c9893d2df12edc686178d5d295ac389440 100644 (file)
@@ -20,7 +20,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int spl_sata_load_image(void)
+int spl_sata_load_image(struct spl_boot_device *bootdev)
 {
        int err;
        struct blk_desc *stor_dev;
index 5198babaae30a3db53f1cc9b4d8386a818b1ad09..d64e6cf57d18c5d16ea87ff68717de2df00d46d0 100644 (file)
 #include <ubispl.h>
 #include <spl.h>
 
-int spl_ubi_load_image(u32 boot_device)
+int spl_ubi_load_image(struct spl_boot_device *bootdev)
 {
        struct image_header *header;
        struct ubispl_info info;
        struct ubispl_load volumes[2];
        int ret = 1;
 
-       switch (boot_device) {
+       switch (bootdev->boot_device) {
 #ifdef CONFIG_SPL_NAND_SUPPORT
        case BOOT_DEVICE_NAND:
                nand_init();
@@ -71,7 +71,7 @@ int spl_ubi_load_image(u32 boot_device)
                spl_parse_image_header(&spl_image, header);
 out:
 #ifdef CONFIG_SPL_NAND_SUPPORT
-       if (boot_device == BOOT_DEVICE_NAND)
+       if (bootdev->boot_device == BOOT_DEVICE_NAND)
                nand_deselect();
 #endif
        return ret;
index 04fa66758cbc0255da1fa97632dd655aeb1dd918..f990336a3c4aa78f9f401e702910c4ba8ef9fd20 100644 (file)
@@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static int usb_stor_curr_dev = -1; /* current device */
 #endif
 
-int spl_usb_load_image(void)
+int spl_usb_load_image(struct spl_boot_device *bootdev)
 {
        int err;
        struct blk_desc *stor_dev;
index 1323b6f028fb000541a01a31bb806fb78b96e08a..d82b138568aae268ae5b146ba756aafa4aa4ee7a 100644 (file)
@@ -68,7 +68,7 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
        return size;
 }
 
-int spl_ymodem_load_image(void)
+int spl_ymodem_load_image(struct spl_boot_device *bootdev)
 {
        int size = 0;
        int err;
index ac5eae33236946e57b0aedefb0dfe896d5a47678..e4cc0d08229f996c0c5689beab38d40417d4e75a 100644 (file)
@@ -65,7 +65,7 @@ static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,
  * configured and available since this code loads the main U-Boot image
  * from SPI into SDRAM and starts it from there.
  */
-int spl_spi_load_image(void)
+int spl_spi_load_image(struct spl_boot_device *bootdev)
 {
        int err = 0;
        struct spi_flash *flash;
index a992bfaca1bebaaca23babdf4d12a18234f55cfd..767959cdfadce4ca5ec5898aa2fad92db0838f36 100644 (file)
@@ -262,7 +262,7 @@ static void spi0_read_data(void *buf, u32 addr, u32 len)
 
 /*****************************************************************************/
 
-int spl_spi_load_image(void)
+int spl_spi_load_image(struct spl_boot_device *bootdev)
 {
        int err;
        struct image_header *header;
index f7009553b9884d1c07512842c89af272578bb413..4435089b168c331489bcbb65de156e16e0b85d5b 100644 (file)
@@ -131,35 +131,53 @@ int spl_start_uboot(void);
  */
 void spl_display_print(void);
 
+/**
+ * struct spl_boot_device - Describes a boot device used by SPL
+ *
+ * @boot_device: A number indicating the BOOT_DEVICE type. There are various
+ * BOOT_DEVICE... #defines and enums in U-Boot and they are not consistently
+ * numbered.
+ * @boot_device_name: Named boot device, or NULL if none.
+ *
+ * Note: Additional fields can be added here, bearing in mind that SPL is
+ * size-sensitive and common fields will be present on all boards. This
+ * struct can also be used to return additional information about the load
+ * process if that becomes useful.
+ */
+struct spl_boot_device {
+       uint boot_device;
+       const char *boot_device_name;
+};
+
 /* NAND SPL functions */
-int spl_nand_load_image(void);
+int spl_nand_load_image(struct spl_boot_device *bootdev);
 
 /* OneNAND SPL functions */
-int spl_onenand_load_image(void);
+int spl_onenand_load_image(struct spl_boot_device *bootdev);
 
 /* NOR SPL functions */
-int spl_nor_load_image(void);
+int spl_nor_load_image(struct spl_boot_device *bootdev);
 
 /* UBI SPL functions */
-int spl_ubi_load_image(u32 boot_device);
+int spl_ubi_load_image(struct spl_boot_device *bootdev);
 
 /* MMC SPL functions */
-int spl_mmc_load_image(u32 boot_device);
+int spl_mmc_load_image(struct spl_boot_device *bootdev);
 
 /* YMODEM SPL functions */
-int spl_ymodem_load_image(void);
+int spl_ymodem_load_image(struct spl_boot_device *bootdev);
 
 /* SPI SPL functions */
-int spl_spi_load_image(void);
+int spl_spi_load_image(struct spl_boot_device *bootdev);
 
 /* Ethernet SPL functions */
-int spl_net_load_image(const char *device);
+int spl_net_load_image(struct spl_boot_device *bootdev);
 
 /* USB SPL functions */
-int spl_usb_load_image(void);
+int spl_usb_load_image(struct spl_boot_device *bootdev);
 
 /* SATA SPL functions */
-int spl_sata_load_image(void);
+int spl_sata_load_image(struct spl_boot_device *bootdev);
 
 /* SPL FAT image functions */
 int spl_load_image_fat(struct blk_desc *block_dev, int partition,
@@ -214,6 +232,6 @@ int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr);
  *
  * @return 0 on success, negative errno value on failure.
  */
-int spl_board_load_image(void);
+int spl_board_load_image(struct spl_boot_device *bootdev);
 
 #endif