summaryrefslogtreecommitdiffstats
path: root/drivers/mci
diff options
context:
space:
mode:
authorRouven Czerwinski <r.czerwinski@pengutronix.de>2019-08-06 07:10:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-08-07 09:42:09 +0200
commit390ee3ebcd25570ac44d4e4fcfc00e120422f057 (patch)
tree35480f0e907776d75378a28d571461a2fed598fe /drivers/mci
parenta4d2576463e2c973ce9c6797877949f1366444d9 (diff)
downloadbarebox-390ee3ebcd25570ac44d4e4fcfc00e120422f057.tar.gz
barebox-390ee3ebcd25570ac44d4e4fcfc00e120422f057.tar.xz
esdhc-pbl: extract header parsing from image start
Extract the header parsing code from esdc_start_image. The header parsing function will be used by the piggy loading code added in the next commit. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci')
-rw-r--r--drivers/mci/imx-esdhc-pbl.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index 367daa85a6..49514fc538 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -243,27 +243,22 @@ static int esdhc_read_blocks(struct esdhc *esdhc, void *dst, size_t len)
}
#ifdef CONFIG_ARCH_IMX
-static int
-esdhc_start_image(struct esdhc *esdhc, ptrdiff_t address, ptrdiff_t entry, u32 offset)
+static int esdhc_search_header(struct esdhc *esdhc,
+ struct imx_flash_header_v2 **header_pointer,
+ void *buffer, u32 *offset)
{
-
- void *buf = (void *)address;
- struct imx_flash_header_v2 *hdr;
- int ret, len;
- void __noreturn (*bb)(void);
- unsigned int ofs;
+ int ret;
int i, header_count = 1;
-
- len = imx_image_size();
- len = ALIGN(len, SECTOR_SIZE);
+ void *buf = buffer;
+ struct imx_flash_header_v2 *hdr;
for (i = 0; i < header_count; i++) {
ret = esdhc_read_blocks(esdhc, buf,
- offset + SZ_1K + SECTOR_SIZE);
+ *offset + SZ_1K + SECTOR_SIZE);
if (ret)
return ret;
- hdr = buf + offset + SZ_1K;
+ hdr = buf + *offset + SZ_1K;
if (!is_imx_flash_header_v2(hdr)) {
pr_debug("IVT header not found on SD card. "
@@ -286,10 +281,31 @@ esdhc_start_image(struct esdhc *esdhc, ptrdiff_t address, ptrdiff_t entry, u32 o
* this time skipping anything HDMI firmware
* related.
*/
- offset += hdr->boot_data.size + hdr->header.length;
+ *offset += hdr->boot_data.size + hdr->header.length;
header_count++;
}
}
+ *header_pointer = hdr;
+ return 0;
+}
+
+static int
+esdhc_start_image(struct esdhc *esdhc, ptrdiff_t address, ptrdiff_t entry,
+ u32 offset)
+{
+
+ void *buf = (void *)address;
+ struct imx_flash_header_v2 *hdr = NULL;
+ int ret, len;
+ void __noreturn (*bb)(void);
+ unsigned int ofs;
+
+ len = imx_image_size();
+ len = ALIGN(len, SECTOR_SIZE);
+
+ ret = esdhc_search_header(esdhc, &hdr, buf, &offset);
+ if (ret)
+ return ret;
pr_debug("Check ok, loading image\n");