diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-06-07 06:00:40 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-06-11 08:54:10 +0200 |
commit | ceb7bc504b6eb80c2fc152d3e21311d01ba918b4 (patch) | |
tree | 0d193369a0aef13587960afe9f1a14e8b4ce4743 /arch | |
parent | 50f8837c93c19910b22e20612337086f55dd4196 (diff) | |
download | barebox-ceb7bc504b6eb80c2fc152d3e21311d01ba918b4.tar.gz barebox-ceb7bc504b6eb80c2fc152d3e21311d01ba918b4.tar.xz |
ARM: i.MX: xload-esdhc: Allow custom buffer address, device offset
Add code to support specifying different buffer address and SD/MMC
device offset to read it from in esdhc_start_image(). This change is
needed to support i.MX8.
NOTE: We intentionnaly "emulate" reading at arbitrary offset in
esdhc_start_image() as opposed to implementing it in
esdhc_read_blocks() in order to avoid having to detect if units of
blocks or bytes should be used to specify offset to CMD18.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-imx/xload-esdhc.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/arch/arm/mach-imx/xload-esdhc.c b/arch/arm/mach-imx/xload-esdhc.c index 4580f53cda..6ab4cabb77 100644 --- a/arch/arm/mach-imx/xload-esdhc.c +++ b/arch/arm/mach-imx/xload-esdhc.c @@ -216,10 +216,11 @@ static int esdhc_read_blocks(struct esdhc *esdhc, void *dst, size_t len) return 0; } -static int esdhc_start_image(struct esdhc *esdhc) +static int +esdhc_start_image(struct esdhc *esdhc, ptrdiff_t address, u32 offset) { - void *buf = (void *)0x10000000; - u32 *ivt = buf + SZ_1K; + void *buf = (void *)address; + u32 *ivt = buf + offset + SZ_1K; int ret, len; void __noreturn (*bb)(void); unsigned int ofs; @@ -227,9 +228,10 @@ static int esdhc_start_image(struct esdhc *esdhc) len = imx_image_size(); len = ALIGN(len, SECTOR_SIZE); - ret = esdhc_read_blocks(esdhc, buf, 3 * SECTOR_SIZE); + ret = esdhc_read_blocks(esdhc, buf, offset + SZ_1K + SECTOR_SIZE); if (ret) return ret; + if (*(u32 *)(ivt) != 0x402000d1) { pr_debug("IVT header not found on SD card. Found 0x%08x instead of 0x402000d1\n", *ivt); @@ -238,7 +240,7 @@ static int esdhc_start_image(struct esdhc *esdhc) pr_debug("Check ok, loading image\n"); - ret = esdhc_read_blocks(esdhc, buf, len); + ret = esdhc_read_blocks(esdhc, buf, offset + len); if (ret) { pr_err("Loading image failed with %d\n", ret); return ret; @@ -246,7 +248,7 @@ static int esdhc_start_image(struct esdhc *esdhc) pr_debug("Image loaded successfully\n"); - ofs = *(ivt + 1) - *(ivt + 8); + ofs = offset + *(ivt + 1) - *(ivt + 8); bb = buf + ofs; @@ -288,5 +290,5 @@ int imx6_esdhc_start_image(int instance) esdhc.is_mx6 = 1; - return esdhc_start_image(&esdhc); + return esdhc_start_image(&esdhc, 0x10000000, 0); } |