summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-01-15 07:58:29 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-01-15 07:58:29 +0100
commitddd37817ed0f6ebe09c6ea9c041b77d215089b45 (patch)
treebeeba9975f13332e5fa7d13e526202b5b08c212d /drivers
parent460d0073731096f5a99333a8aefdd5814a97d4e5 (diff)
parent917c6716f68249565cf8aa4d6e01ef5545247c34 (diff)
downloadbarebox-ddd37817ed0f6ebe09c6ea9c041b77d215089b45.tar.gz
barebox-ddd37817ed0f6ebe09c6ea9c041b77d215089b45.tar.xz
Merge branch 'for-next/imx'
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mci/imx-esdhc-pbl.c64
1 files changed, 13 insertions, 51 deletions
diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index c0d27fb7eb..2579cfd9d1 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -121,8 +121,8 @@ static int esdhc_search_header(struct fsl_esdhc_host *host,
}
static int
-esdhc_start_image(struct fsl_esdhc_host *host, ptrdiff_t address, ptrdiff_t entry,
- u32 offset)
+esdhc_load_image(struct fsl_esdhc_host *host, ptrdiff_t address,
+ ptrdiff_t entry, u32 offset, bool start)
{
void *buf = (void *)address;
@@ -177,6 +177,9 @@ esdhc_start_image(struct fsl_esdhc_host *host, ptrdiff_t address, ptrdiff_t entr
pr_debug("Image loaded successfully\n");
+ if (!start)
+ return 0;
+
bb = buf + ofs;
sync_caches_for_execution();
@@ -254,22 +257,23 @@ int imx6_esdhc_start_image(int instance)
imx_esdhc_init(&host, &data);
- return esdhc_start_image(&host, 0x10000000, 0x10000000, 0);
+ return esdhc_load_image(&host, 0x10000000, 0x10000000, 0, true);
}
/**
- * imx8_esdhc_start_image - Load and start an image from USDHC controller
+ * imx8_esdhc_load_image - Load and optionally start an image from USDHC controller
* @instance: The USDHC controller instance (0..2)
+ * @start: Whether to directly start the loaded image
*
* This uses esdhc_start_image() to load an image from SD/MMC. It is
* assumed that the image is the currently running barebox image (This
* information is used to calculate the length of the image). The
* image is started afterwards.
*
- * Return: If successful, this function does not return. A negative error
- * code is returned when this function fails.
+ * Return: If successful, this function does not return (if directly started)
+ * or 0. A negative error code is returned when this function fails.
*/
-int imx8_esdhc_start_image(int instance)
+int imx8_esdhc_load_image(int instance, bool start)
{
struct esdhc_soc_data data;
struct fsl_esdhc_host host;
@@ -279,50 +283,8 @@ int imx8_esdhc_start_image(int instance)
if (ret)
return ret;
- return esdhc_start_image(&host, MX8MQ_DDR_CSD1_BASE_ADDR,
- MX8MQ_ATF_BL33_BASE_ADDR, SZ_32K);
-}
-
-int imx8_esdhc_load_piggy(int instance)
-{
- void *buf, *piggy;
- struct imx_flash_header_v2 *hdr = NULL;
- struct esdhc_soc_data data;
- struct fsl_esdhc_host host;
- int ret, len;
- int offset = SZ_32K;
-
- ret = imx8_esdhc_init(&host, &data, instance);
- if (ret)
- return ret;
-
- /*
- * 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(&host, &hdr, buf, &offset);
- if (ret)
- return ret;
-
- len = offset + hdr->boot_data.size + piggydata_size();
- len = ALIGN(len, SECTOR_SIZE);
-
- ret = esdhc_read_blocks(&host, buf, len);
-
- /*
- * Calculate location of the piggydata at the offset loaded into RAM
- */
- piggy = buf + offset + hdr->boot_data.size;
-
- /*
- * Copy the piggydata where the uncompressing code expects it
- */
- memcpy(input_data, piggy, piggydata_size());
-
- return ret;
+ return esdhc_load_image(&host, MX8MQ_DDR_CSD1_BASE_ADDR,
+ MX8MQ_ATF_BL33_BASE_ADDR, SZ_32K, start);
}
#endif