diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/image-fit.c | 48 | ||||
-rw-r--r-- | common/splash_source.c | 89 | ||||
-rw-r--r-- | common/usb_storage.c | 8 |
3 files changed, 132 insertions, 13 deletions
diff --git a/common/image-fit.c b/common/image-fit.c index 95d8bf4bb8..109ecfaacc 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -778,6 +778,54 @@ int fit_image_get_data(const void *fit, int noffset, } /** + * Get 'data-offset' property from a given image node. + * + * @fit: pointer to the FIT image header + * @noffset: component image node offset + * @data_offset: holds the data-offset property + * + * returns: + * 0, on success + * -ENOENT if the property could not be found + */ +int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset) +{ + const fdt32_t *val; + + val = fdt_getprop(fit, noffset, FIT_DATA_OFFSET_PROP, NULL); + if (!val) + return -ENOENT; + + *data_offset = fdt32_to_cpu(*val); + + return 0; +} + +/** + * Get 'data-size' property from a given image node. + * + * @fit: pointer to the FIT image header + * @noffset: component image node offset + * @data_size: holds the data-size property + * + * returns: + * 0, on success + * -ENOENT if the property could not be found + */ +int fit_image_get_data_size(const void *fit, int noffset, int *data_size) +{ + const fdt32_t *val; + + val = fdt_getprop(fit, noffset, FIT_DATA_SIZE_PROP, NULL); + if (!val) + return -ENOENT; + + *data_size = fdt32_to_cpu(*val); + + return 0; +} + +/** * fit_image_hash_get_algo - get hash algorithm name * @fit: pointer to the FIT format image header * @noffset: hash node offset diff --git a/common/splash_source.c b/common/splash_source.c index 230b2db4d5..a5eeb3f12c 100644 --- a/common/splash_source.c +++ b/common/splash_source.c @@ -7,15 +7,17 @@ */ #include <common.h> -#include <nand.h> +#include <bmp_layout.h> #include <errno.h> -#include <splash.h> -#include <spi_flash.h> +#include <fs.h> +#include <fdt_support.h> +#include <image.h> +#include <nand.h> +#include <sata.h> #include <spi.h> +#include <spi_flash.h> +#include <splash.h> #include <usb.h> -#include <sata.h> -#include <bmp_layout.h> -#include <fs.h> DECLARE_GLOBAL_DATA_PTR; @@ -295,6 +297,72 @@ static struct splash_location *select_splash_location( return NULL; } +#ifdef CONFIG_FIT +static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) +{ + int res; + int node_offset; + int splash_offset; + int splash_size; + struct image_header *img_header; + const u32 *fit_header; + u32 fit_size; + const size_t header_size = sizeof(struct image_header); + + /* Read in image header */ + res = splash_storage_read_raw(location, bmp_load_addr, header_size); + if (res < 0) + return res; + + img_header = (struct image_header *)bmp_load_addr; + fit_size = fdt_totalsize(img_header); + + /* Read in entire FIT */ + fit_header = (const u32 *)(bmp_load_addr + header_size); + res = splash_storage_read_raw(location, (u32)fit_header, fit_size); + if (res < 0) + return res; + + res = fit_check_format(fit_header); + if (!res) { + debug("Could not find valid FIT image\n"); + return -EINVAL; + } + + node_offset = fit_image_get_node(fit_header, location->name); + if (node_offset < 0) { + debug("Could not find splash image '%s' in FIT\n", + location->name); + return -ENOENT; + } + + res = fit_image_get_data_offset(fit_header, node_offset, + &splash_offset); + if (res < 0) { + printf("Failed to load splash image (err=%d)\n", res); + return res; + } + + res = fit_image_get_data_size(fit_header, node_offset, &splash_size); + if (res < 0) { + printf("Failed to load splash image (err=%d)\n", res); + return res; + } + + /* Align data offset to 4-byte boundrary */ + fit_size = fdt_totalsize(fit_header); + fit_size = (fit_size + 3) & ~3; + + /* Read in the splash data */ + location->offset = (location->offset + fit_size + splash_offset); + res = splash_storage_read_raw(location, bmp_load_addr , splash_size); + if (res < 0) + return res; + + return 0; +} +#endif /* CONFIG_FIT */ + /** * splash_source_load - load splash image from a supported location. * @@ -327,10 +395,13 @@ int splash_source_load(struct splash_location *locations, uint size) if (!splash_location) return -EINVAL; - if (splash_location->flags & SPLASH_STORAGE_RAW) + if (splash_location->flags == SPLASH_STORAGE_RAW) return splash_load_raw(splash_location, bmp_load_addr); - else if (splash_location->flags & SPLASH_STORAGE_FS) + else if (splash_location->flags == SPLASH_STORAGE_FS) return splash_load_fs(splash_location, bmp_load_addr); - +#ifdef CONFIG_FIT + else if (splash_location->flags == SPLASH_STORAGE_FIT) + return splash_load_fit(splash_location, bmp_load_addr); +#endif return -EINVAL; } diff --git a/common/usb_storage.c b/common/usb_storage.c index 0345aa22ef..b524a15e2b 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -303,7 +303,6 @@ void usb_stor_reset(void) usb_max_devs = 0; } -#ifndef CONFIG_DM_USB /******************************************************************************* * scan the usb and reports device info * to the user if mode = 1 @@ -311,11 +310,12 @@ void usb_stor_reset(void) */ int usb_stor_scan(int mode) { - unsigned char i; - if (mode == 1) printf(" scanning usb for storage devices... "); +#ifndef CONFIG_DM_USB + unsigned char i; + usb_disable_asynch(1); /* asynch transfer not allowed */ usb_stor_reset(); @@ -329,12 +329,12 @@ int usb_stor_scan(int mode) } /* for */ usb_disable_asynch(0); /* asynch transfer allowed */ +#endif printf("%d Storage Device(s) found\n", usb_max_devs); if (usb_max_devs > 0) return 0; return -1; } -#endif static int usb_stor_irq(struct usb_device *dev) { |