]> Git Repo - J-u-boot.git/blobdiff - common/splash_source.c
global: Remove undef CONFIG_... for unused values
[J-u-boot.git] / common / splash_source.c
index 2c03cbdf928b30ba35f806a0f17239394542d029..a260137619806e3a0dd1ec41cb5bf8749be96b36 100644 (file)
@@ -65,6 +65,30 @@ static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
 }
 #endif
 
+static int splash_mmc_read_raw(u32 bmp_load_addr, struct splash_location *location,
+                              size_t read_size)
+{
+       struct disk_partition partition;
+       struct blk_desc *desc;
+       lbaint_t blkcnt;
+       int ret, n;
+
+       if (!IS_ENABLED(CONFIG_CMD_MMC)) {
+               debug("%s: mmc support not available\n", __func__);
+               return -ENOSYS;
+       }
+
+       ret = part_get_info_by_dev_and_name_or_num("mmc", location->devpart, &desc,
+                                                  &partition, 1);
+       if (ret < 0)
+               return ret;
+
+       blkcnt = DIV_ROUND_UP(read_size, partition.blksz);
+       n = blk_dread(desc, partition.start, blkcnt, (void *)(uintptr_t)bmp_load_addr);
+
+       return (n == blkcnt) ? 0 : -EIO;
+}
+
 static int splash_storage_read_raw(struct splash_location *location,
                               u32 bmp_load_addr, size_t read_size)
 {
@@ -75,6 +99,8 @@ static int splash_storage_read_raw(struct splash_location *location,
 
        offset = location->offset;
        switch (location->storage) {
+       case SPLASH_STORAGE_MMC:
+               return splash_mmc_read_raw(bmp_load_addr, location, read_size);
        case SPLASH_STORAGE_NAND:
                return splash_nand_read_raw(bmp_load_addr, offset, read_size);
        case SPLASH_STORAGE_SF:
@@ -327,17 +353,17 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
        int external_splash_addr;
        int external_splash_size;
        bool is_splash_external = false;
-       struct image_header *img_header;
+       struct legacy_img_hdr *img_header;
        const u32 *fit_header;
        u32 fit_size;
-       const size_t header_size = sizeof(struct image_header);
+       const size_t header_size = sizeof(struct legacy_img_hdr);
 
        /* 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;
+       img_header = (struct legacy_img_hdr *)bmp_load_addr;
        if (image_get_magic(img_header) != FDT_MAGIC) {
                printf("Could not find FDT magic\n");
                return -EINVAL;
@@ -422,6 +448,7 @@ int splash_source_load(struct splash_location *locations, uint size)
 {
        struct splash_location *splash_location;
        char *env_splashimage_value;
+       char *devpart;
        u32 bmp_load_addr;
 
        env_splashimage_value = env_get("splashimage");
@@ -438,6 +465,10 @@ int splash_source_load(struct splash_location *locations, uint size)
        if (!splash_location)
                return -EINVAL;
 
+       devpart = env_get("splashdevpart");
+       if (devpart)
+               splash_location->devpart = devpart;
+
        if (splash_location->flags == SPLASH_STORAGE_RAW)
                return splash_load_raw(splash_location, bmp_load_addr);
        else if (splash_location->flags == SPLASH_STORAGE_FS)
This page took 0.030491 seconds and 4 git commands to generate.