summaryrefslogtreecommitdiffstats
path: root/drivers/mci/imx-esdhc-pbl.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-08-22 10:50:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-08-23 10:10:09 +0200
commit10f3061d97e610ceee0ea43cb04bb8fd0b0e96c2 (patch)
tree95d7892d5c049426b429a6032956d3861d946ceb /drivers/mci/imx-esdhc-pbl.c
parente42f738cd89b9ec997966cedc5aa58368f3ffadd (diff)
downloadbarebox-10f3061d97e610ceee0ea43cb04bb8fd0b0e96c2.tar.gz
barebox-10f3061d97e610ceee0ea43cb04bb8fd0b0e96c2.tar.xz
ARM: i.MX8: Fix piggydata loading
We are running at MX8MQ_ATF_BL33_BASE_ADDR now, so we can't use this as a temporary buffer. Add 32MiB to that address and use this instead. Also copy the piggydata to the place where we expect it later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Diffstat (limited to 'drivers/mci/imx-esdhc-pbl.c')
-rw-r--r--drivers/mci/imx-esdhc-pbl.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index fb27c84163..aa93af656c 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -428,14 +428,12 @@ int imx8_esdhc_start_image(int instance)
int imx8_esdhc_load_piggy(int instance)
{
- void *buf = (void *)MX8MQ_ATF_BL33_BASE_ADDR;
+ void *buf, *piggy;
struct imx_flash_header_v2 *hdr = NULL;
- void *bb = 0;
struct esdhc esdhc;
int ret, len;
int offset = SZ_32K;
-
switch (instance) {
case 0:
esdhc.regs = IOMEM(MX8MQ_USDHC1_BASE_ADDR);
@@ -450,6 +448,13 @@ int imx8_esdhc_load_piggy(int instance)
esdhc.is_be = 0;
esdhc.is_mx6 = 1;
+ /*
+ * We expect to be running at MX8MQ_ATF_BL33_BASE_ADDR where the atf
+ * has jumped to. Use a temporary buffer where we won't overwrite
+ * ourselves.
+ */
+ buf = (void *)MX8MQ_ATF_BL33_BASE_ADDR + SZ_32M;
+
ret = esdhc_search_header(&esdhc, &hdr, buf, &offset);
if (ret)
return ret;
@@ -462,13 +467,13 @@ int imx8_esdhc_load_piggy(int instance)
/*
* Calculate location of the piggydata at the offset loaded into RAM
*/
- buf = buf + offset + hdr->boot_data.size;
+ piggy = buf + offset + hdr->boot_data.size;
+
/*
- * Barebox expects the piggydata right behind the PBL in the beginning
- * of RAM.
+ * Copy the piggydata where the uncompressing code expects it
*/
- bb = (void *) MX8MQ_DDR_CSD1_BASE_ADDR + barebox_pbl_size;
- memcpy(bb, buf, piggydata_size());
+ memcpy(input_data, piggy, piggydata_size());
+
return ret;
}
#endif