From ebc4ef61d76fc182773fe225151adc9b913c62eb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 30 Nov 2016 15:30:50 -0700 Subject: [PATCH] spl: Add a name to the SPL load-image methods It is useful to name each method so that we can print out this name when using the method. Currently this happens using a separate function. In preparation for unifying this, add a name to each method. The name is only available if we have libcommon support (i.e can use printf()). Signed-off-by: Simon Glass --- arch/arm/mach-sunxi/board.c | 2 +- arch/arm/mach-uniphier/boot-mode/spl_board.c | 2 +- arch/sandbox/cpu/spl.c | 2 +- common/spl/spl.c | 4 ++-- common/spl/spl_mmc.c | 6 +++--- common/spl/spl_nand.c | 2 +- common/spl/spl_net.c | 5 +++-- common/spl/spl_nor.c | 2 +- common/spl/spl_onenand.c | 3 ++- common/spl/spl_sata.c | 2 +- common/spl/spl_spi.c | 2 +- common/spl/spl_ubi.c | 4 ++-- common/spl/spl_usb.c | 2 +- common/spl/spl_ymodem.c | 2 +- drivers/mtd/spi/sunxi_spi_spl.c | 2 +- include/spl.h | 15 ++++++++++++++- 16 files changed, 36 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index 0f8ead980c..205236d5ec 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -142,7 +142,7 @@ static int spl_board_load_image(struct spl_image_info *spl_image, return 0; } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_BOARD, spl_board_load_image); +SPL_LOAD_IMAGE_METHOD("FEL", 0, BOOT_DEVICE_BOARD, spl_board_load_image); #endif void s_init(void) diff --git a/arch/arm/mach-uniphier/boot-mode/spl_board.c b/arch/arm/mach-uniphier/boot-mode/spl_board.c index 854ab056da..ba840873ed 100644 --- a/arch/arm/mach-uniphier/boot-mode/spl_board.c +++ b/arch/arm/mach-uniphier/boot-mode/spl_board.c @@ -127,4 +127,4 @@ static int spl_board_load_image(struct spl_image_info *spl_image, return 0; } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_BOARD, spl_board_load_image); +SPL_LOAD_IMAGE_METHOD("eMMC", 0, BOOT_DEVICE_BOARD, spl_board_load_image); diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 1ad7fb6c60..632446b2cd 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -51,7 +51,7 @@ static int spl_board_load_image(struct spl_image_info *spl_image, /* Hopefully this will not return */ return os_spl_to_uboot(fname); } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_BOARD, spl_board_load_image); +SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image); void spl_board_init(void) { diff --git a/common/spl/spl.c b/common/spl/spl.c index 9bcbd09ff3..30b4c50251 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -221,10 +221,10 @@ static int spl_ram_load_image(struct spl_image_info *spl_image, return 0; } #if defined(CONFIG_SPL_RAM_DEVICE) -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_RAM, spl_ram_load_image); +SPL_LOAD_IMAGE_METHOD("RAM", 0, BOOT_DEVICE_RAM, spl_ram_load_image); #endif #if defined(CONFIG_SPL_DFU_SUPPORT) -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_DFU, spl_ram_load_image); +SPL_LOAD_IMAGE_METHOD("USB DFU", 0, BOOT_DEVICE_DFU, spl_ram_load_image); #endif #endif diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 32d7c2a84b..85e3de8f23 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -355,6 +355,6 @@ int spl_mmc_load_image(struct spl_image_info *spl_image, return err; } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_MMC1, spl_mmc_load_image); -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_MMC2, spl_mmc_load_image); -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_MMC2_2, spl_mmc_load_image); +SPL_LOAD_IMAGE_METHOD("MMC1", 0, BOOT_DEVICE_MMC1, spl_mmc_load_image); +SPL_LOAD_IMAGE_METHOD("MMC2", 0, BOOT_DEVICE_MMC2, spl_mmc_load_image); +SPL_LOAD_IMAGE_METHOD("MMC2_2", 0, BOOT_DEVICE_MMC2_2, spl_mmc_load_image); diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index d1abda6e4c..cd39f9be9d 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -151,4 +151,4 @@ static int spl_nand_load_image(struct spl_image_info *spl_image, } #endif /* Use priorty 1 so that Ubi can override this */ -SPL_LOAD_IMAGE_METHOD(1, BOOT_DEVICE_NAND, spl_nand_load_image); +SPL_LOAD_IMAGE_METHOD("NAND", 1, BOOT_DEVICE_NAND, spl_nand_load_image); diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c index f4b4bc4833..0fba0172ea 100644 --- a/common/spl/spl_net.c +++ b/common/spl/spl_net.c @@ -51,7 +51,8 @@ int spl_net_load_image_cpgmac(struct spl_image_info *spl_image, return spl_net_load_image(spl_image, bootdev); } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_CPGMAC, spl_net_load_image_cpgmac); +SPL_LOAD_IMAGE_METHOD("eth device", 0, BOOT_DEVICE_CPGMAC, + spl_net_load_image_cpgmac); #endif #ifdef CONFIG_SPL_USBETH_SUPPORT @@ -62,5 +63,5 @@ int spl_net_load_image_usb(struct spl_image_info *spl_image, return spl_net_load_image(spl_image, bootdev); } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_USBETH, spl_net_load_image_usb); +SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb); #endif diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c index 6bfa399bac..d07ca84382 100644 --- a/common/spl/spl_nor.c +++ b/common/spl/spl_nor.c @@ -71,4 +71,4 @@ static int spl_nor_load_image(struct spl_image_info *spl_image, return 0; } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_NOR, spl_nor_load_image); +SPL_LOAD_IMAGE_METHOD("NOR", 0, BOOT_DEVICE_NOR, spl_nor_load_image); diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c index f076e2c7c8..fc98e9cbe5 100644 --- a/common/spl/spl_onenand.c +++ b/common/spl/spl_onenand.c @@ -36,4 +36,5 @@ static int spl_onenand_load_image(struct spl_image_info *spl_image, return 0; } /* Use priorty 1 so that Ubi can override this */ -SPL_LOAD_IMAGE_METHOD(1, BOOT_DEVICE_ONENAND, spl_onenand_load_image); +SPL_LOAD_IMAGE_METHOD("OneNAND", 1, BOOT_DEVICE_ONENAND, + spl_onenand_load_image); diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c index a3c07cd9ce..5476206131 100644 --- a/common/spl/spl_sata.c +++ b/common/spl/spl_sata.c @@ -57,4 +57,4 @@ static int spl_sata_load_image(struct spl_image_info *spl_image, return 0; } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_SATA, spl_sata_load_image); +SPL_LOAD_IMAGE_METHOD("SATA", 0, BOOT_DEVICE_SATA, spl_sata_load_image); diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index 78b8cd16bb..cd1d6b285e 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -125,4 +125,4 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, return err; } /* Use priorty 1 so that boards can override this */ -SPL_LOAD_IMAGE_METHOD(1, BOOT_DEVICE_SPI, spl_spi_load_image); +SPL_LOAD_IMAGE_METHOD("SPI", 1, BOOT_DEVICE_SPI, spl_spi_load_image); diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c index c03910bb40..24633f4766 100644 --- a/common/spl/spl_ubi.c +++ b/common/spl/spl_ubi.c @@ -78,5 +78,5 @@ out: return ret; } /* Use priorty 0 so that Ubi will override NAND and ONENAND methods */ -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_NAND, spl_ubi_load_image); -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_ONENAND, spl_ubi_load_image); +SPL_LOAD_IMAGE_METHOD("NAND", 0, BOOT_DEVICE_NAND, spl_ubi_load_image); +SPL_LOAD_IMAGE_METHOD("OneNAND", 0, BOOT_DEVICE_ONENAND, spl_ubi_load_image); diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c index e37966ed6c..567a450505 100644 --- a/common/spl/spl_usb.c +++ b/common/spl/spl_usb.c @@ -65,4 +65,4 @@ static int spl_usb_load_image(struct spl_image_info *spl_image, return 0; } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_USB, spl_usb_load_image); +SPL_LOAD_IMAGE_METHOD("USB", 0, BOOT_DEVICE_USB, spl_usb_load_image); diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c index 957894dccb..ff8085b795 100644 --- a/common/spl/spl_ymodem.c +++ b/common/spl/spl_ymodem.c @@ -132,4 +132,4 @@ end_stream: printf("Loaded %d bytes\n", size); return 0; } -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_UART, spl_ymodem_load_image); +SPL_LOAD_IMAGE_METHOD("UART", 0, BOOT_DEVICE_UART, spl_ymodem_load_image); diff --git a/drivers/mtd/spi/sunxi_spi_spl.c b/drivers/mtd/spi/sunxi_spi_spl.c index 75023149a4..e70064c677 100644 --- a/drivers/mtd/spi/sunxi_spi_spl.c +++ b/drivers/mtd/spi/sunxi_spi_spl.c @@ -284,4 +284,4 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, return 0; } /* Use priorty 0 to override the default if it happens to be linked in */ -SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_SPI, spl_spi_load_image); +SPL_LOAD_IMAGE_METHOD("sunxi SPI" 0, BOOT_DEVICE_SPI, spl_spi_load_image); diff --git a/include/spl.h b/include/spl.h index 9d221c1b55..6e746b2046 100644 --- a/include/spl.h +++ b/include/spl.h @@ -152,10 +152,14 @@ struct spl_boot_device { /** * Holds information about a way of loading an SPL image * + * @name: User-friendly name for this method (e.g. "MMC") * @boot_device: Boot device that this loader supports * @load_image: Function to call to load image */ struct spl_image_loader { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT + const char *name; +#endif uint boot_device; /** * load_image() - Load an SPL image @@ -177,11 +181,20 @@ struct spl_image_loader { * _boot_device is the BOOT_DEVICE_... value * _method is the load_image function to call */ -#define SPL_LOAD_IMAGE_METHOD(_priority, _boot_device, _method) \ +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +#define SPL_LOAD_IMAGE_METHOD(_name, _priority, _boot_device, _method) \ SPL_LOAD_IMAGE(_method ## _priority ## _boot_device) = { \ + .name = _name, \ .boot_device = _boot_device, \ .load_image = _method, \ } +#else +#define SPL_LOAD_IMAGE_METHOD(_name, _priority, _boot_device, _method) \ + SPL_LOAD_IMAGE(_method ## _priority ## _boot_device) = { \ + .boot_device = _boot_device, \ + .load_image = _method, \ + } +#endif /* SPL FAT image functions */ int spl_load_image_fat(struct spl_image_info *spl_image, -- 2.25.1