diff mbox

[U-Boot,V2,3/5] splash_source: add support for filesystem formatted usb

Message ID 1446112484-24787-4-git-send-email-nikita@compulab.co.il
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show

Commit Message

Nikita Kiryanov Oct. 29, 2015, 9:54 a.m. UTC
Add support for loading splash image from USB drive formatted with a
filesystem.

Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Tom Rini <trini@konsulko.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
---
Changes in V2:
	- Refactored device initialization code so that #ifdefs are outside of
	  the functions. This affects patches 3 and 4.

 common/splash_source.c | 31 ++++++++++++++++++++++++++++++-
 include/splash.h       |  1 +
 2 files changed, 31 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/common/splash_source.c b/common/splash_source.c
index 7de8695..cf47569 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -12,6 +12,7 @@ 
 #include <splash.h>
 #include <spi_flash.h>
 #include <spi.h>
+#include <usb.h>
 #include <bmp_layout.h>
 #include <fs.h>
 
@@ -112,6 +113,9 @@  static int splash_select_fs_dev(struct splash_location *location)
 	case SPLASH_STORAGE_MMC:
 		res = fs_set_blk_dev("mmc", location->devpart, FS_TYPE_ANY);
 		break;
+	case SPLASH_STORAGE_USB:
+		res = fs_set_blk_dev("usb", location->devpart, FS_TYPE_ANY);
+		break;
 	default:
 		printf("Error: unsupported location storage.\n");
 		return -ENODEV;
@@ -123,11 +127,30 @@  static int splash_select_fs_dev(struct splash_location *location)
 	return res;
 }
 
+#ifdef CONFIG_USB_STORAGE
+static int splash_init_usb(void)
+{
+	int err;
+
+	err = usb_init();
+	if (err)
+		return err;
+
+	return usb_stor_scan(1) < 0 ? -ENODEV : 0;
+}
+#else
+static inline int splash_init_usb(void)
+{
+	printf("Cannot load splash image: no USB support\n");
+	return -ENOSYS;
+}
+#endif
+
 #define SPLASH_SOURCE_DEFAULT_FILE_NAME		"splash.bmp"
 
 static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr)
 {
-	int res;
+	int res = 0;
 	loff_t bmp_size;
 	char *splash_file;
 
@@ -135,6 +158,12 @@  static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr)
 	if (!splash_file)
 		splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
 
+	if (location->storage == SPLASH_STORAGE_USB)
+		res = splash_init_usb();
+
+	if (res)
+		return res;
+
 	res = splash_select_fs_dev(location);
 	if (res)
 		return res;
diff --git a/include/splash.h b/include/splash.h
index d1fba69..b728bd6 100644
--- a/include/splash.h
+++ b/include/splash.h
@@ -28,6 +28,7 @@  enum splash_storage {
 	SPLASH_STORAGE_NAND,
 	SPLASH_STORAGE_SF,
 	SPLASH_STORAGE_MMC,
+	SPLASH_STORAGE_USB,
 };
 
 enum splash_flags {