aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Rini2021-04-09 07:41:32 -0400
committerTom Rini2021-04-09 10:08:52 -0400
commita1e95e3805eacca1162f6049dceb9b1d2726cbf5 (patch)
treee4499db55ac8ee7b600a873a231b134d0adfc1a4 /common
parentf6127db8cc8dec22cf9cd6d6363d812f659ce517 (diff)
parent2fc93e5bafdae7cf6373479e054e9f3943fde23c (diff)
Merge tag 'u-boot-imx-20210409' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
u-boot-imx-20210409 ------------------- - Secure Boot : - HAB for MX8M / MX7ULP - CAAM fixes - Fixes for imxrt1020 - Fixes for USDHC driver - Fixes for Toradex (Colibri / Apalis) - Switch to DM for several boards - mx23 olinuxo - usbarmory - marsboard / riotboard - Gateworks GW Ventana - NXP upstream patches (LPDDR / CAAM / HAB) CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/7089
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_nand.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index d13a5245974..59f4a84a36a 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -42,21 +42,33 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,
ulong size, void *dst)
{
- ulong sector;
int err;
+#ifdef CONFIG_SYS_NAND_BLOCK_SIZE
+ ulong sector;
sector = *(int *)load->priv;
offs = sector + nand_spl_adjust_offset(sector, offs - sector);
+#else
+ offs *= load->bl_len;
+ size *= load->bl_len;
+#endif
err = nand_spl_load_image(offs, size, dst);
if (err)
return 0;
- return size;
+ return size / load->bl_len;
+}
+
+struct mtd_info * __weak nand_get_mtd(void)
+{
+ return NULL;
}
static int spl_nand_load_element(struct spl_image_info *spl_image,
int offset, struct image_header *header)
{
+ struct mtd_info *mtd = nand_get_mtd();
+ int bl_len = mtd ? mtd->writesize : 1;
int err;
err = nand_spl_load_image(offset, sizeof(*header), (void *)header);
@@ -71,18 +83,18 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
load.dev = NULL;
load.priv = &offset;
load.filename = NULL;
- load.bl_len = 1;
+ load.bl_len = bl_len;
load.read = spl_nand_fit_read;
- return spl_load_simple_fit(spl_image, &load, offset, header);
+ return spl_load_simple_fit(spl_image, &load, offset / bl_len, header);
} else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) {
struct spl_load_info load;
load.dev = NULL;
load.priv = NULL;
load.filename = NULL;
- load.bl_len = 1;
+ load.bl_len = bl_len;
load.read = spl_nand_fit_read;
- return spl_load_imx_container(spl_image, &load, offset);
+ return spl_load_imx_container(spl_image, &load, offset / bl_len);
} else {
err = spl_parse_image_header(spl_image, header);
if (err)