aboutsummaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/Kconfig4
-rw-r--r--common/spl/spl.c9
-rw-r--r--common/spl/spl_mmc.c16
-rw-r--r--common/spl/spl_sata.c12
-rw-r--r--common/spl/spl_spi.c2
5 files changed, 39 insertions, 4 deletions
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 9552ed4..c155a3b 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -344,7 +344,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
default 0x75 if ARCH_DAVINCI
default 0x8a if ARCH_MX6 || ARCH_MX7
default 0x100 if ARCH_UNIPHIER
- default 0x140 if ARCH_MVEBU
+ default 0x0 if ARCH_MVEBU
default 0x200 if ARCH_SOCFPGA || ARCH_AT91
default 0x300 if ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || OMAP44XX || \
OMAP54XX || AM33XX || AM43XX || ARCH_K3
@@ -1099,6 +1099,7 @@ config SPL_SATA_SUPPORT
config SPL_SATA_RAW_U_BOOT_USE_SECTOR
bool "SATA raw mode: by sector"
depends on SPL_SATA_SUPPORT
+ default y if ARCH_MVEBU
help
Use sector number for specifying U-Boot location on SATA disk in
raw mode.
@@ -1106,6 +1107,7 @@ config SPL_SATA_RAW_U_BOOT_USE_SECTOR
config SPL_SATA_RAW_U_BOOT_SECTOR
hex "Sector on the SATA disk to load U-Boot from"
depends on SPL_SATA_RAW_U_BOOT_USE_SECTOR
+ default 0x1 if ARCH_MVEBU
help
Sector on the SATA disk to load U-Boot from, when the SATA disk is being
used in raw mode. Units: SATA disk sectors (1 sector = 512 bytes).
diff --git a/common/spl/spl.c b/common/spl/spl.c
index f6375b0..d55d3c2 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -300,6 +300,12 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
}
#endif
+__weak int spl_parse_board_header(struct spl_image_info *spl_image,
+ const void *image_header, size_t size)
+{
+ return -EINVAL;
+}
+
__weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
const struct image_header *header)
{
@@ -352,6 +358,9 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
}
#endif
+ if (!spl_parse_board_header(spl_image, (const void *)header, sizeof(*header)))
+ return 0;
+
#ifdef CONFIG_SPL_RAW_IMAGE_SUPPORT
/* Signature not found - assume u-boot.bin */
debug("mkimage signature not found - ih_magic = %x\n",
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 4dff9bf..212a2b0 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -20,26 +20,40 @@
static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
ulong sector, struct image_header *header)
{
+ u32 image_offset_sectors;
u32 image_size_sectors;
unsigned long count;
+ u32 image_offset;
int ret;
ret = spl_parse_image_header(spl_image, header);
if (ret)
return ret;
+ /* convert offset to sectors - round down */
+ image_offset_sectors = spl_image->offset / mmc->read_bl_len;
+ /* calculate remaining offset */
+ image_offset = spl_image->offset % mmc->read_bl_len;
+
/* convert size to sectors - round up */
image_size_sectors = (spl_image->size + mmc->read_bl_len - 1) /
mmc->read_bl_len;
/* Read the header too to avoid extra memcpy */
- count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors,
+ count = blk_dread(mmc_get_blk_desc(mmc),
+ sector + image_offset_sectors,
+ image_size_sectors,
(void *)(ulong)spl_image->load_addr);
debug("read %x sectors to %lx\n", image_size_sectors,
spl_image->load_addr);
if (count != image_size_sectors)
return -EIO;
+ if (image_offset)
+ memmove((void *)(ulong)spl_image->load_addr,
+ (void *)(ulong)spl_image->load_addr + image_offset,
+ spl_image->size);
+
return 0;
}
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index e108af0..535a921 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -36,6 +36,8 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image,
struct image_header *header;
unsigned long count;
u32 image_size_sectors;
+ u32 image_offset_sectors;
+ u32 image_offset;
int ret;
header = spl_get_load_buffer(-sizeof(*header), stor_dev->blksz);
@@ -48,11 +50,19 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image,
return ret;
image_size_sectors = DIV_ROUND_UP(spl_image->size, stor_dev->blksz);
- count = blk_dread(stor_dev, sector, image_size_sectors,
+ image_offset_sectors = spl_image->offset / stor_dev->blksz;
+ image_offset = spl_image->offset % stor_dev->blksz;
+ count = blk_dread(stor_dev, sector + image_offset_sectors,
+ image_size_sectors,
(void *)spl_image->load_addr);
if (count != image_size_sectors)
return -EIO;
+ if (image_offset)
+ memmove((void *)spl_image->load_addr,
+ (void *)spl_image->load_addr + image_offset,
+ spl_image->size);
+
return 0;
}
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 6a4e033..9884e7c 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -159,7 +159,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
err = spl_parse_image_header(spl_image, header);
if (err)
return err;
- err = spi_flash_read(flash, payload_offs,
+ err = spi_flash_read(flash, payload_offs + spl_image->offset,
spl_image->size,
(void *)spl_image->load_addr);
}