summaryrefslogtreecommitdiff
path: root/tools/mtk_image.c
diff options
context:
space:
mode:
authorWeijie Gao <weijie.gao@mediatek.com>2022-09-09 20:00:25 +0800
committerTom Rini <trini@konsulko.com>2022-09-23 15:09:16 -0400
commit3e3332130f4e99278f3686381b80b243a54948b0 (patch)
tree940ae732422af49be9f4b0b61bc70517bff52839 /tools/mtk_image.c
parentcadb1a858d071e4ec6afdacc9ad5c7057cae699d (diff)
tools: mtk_image: add support for nand headers used by newer chips
This patch adds more nand headers in two new types: 1. HSM header, used for spi-nand thru SNFI interface 2. SPIM header, used for spi-nand thru spi-mem interface The original nand header is renamed to AP header. Tested-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
Diffstat (limited to 'tools/mtk_image.c')
-rw-r--r--tools/mtk_image.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/mtk_image.c b/tools/mtk_image.c
index 1f7396aa69..9b3136afa3 100644
--- a/tools/mtk_image.c
+++ b/tools/mtk_image.c
@@ -33,6 +33,9 @@ static const struct brom_img_type {
}, {
.name = "snand",
.type = BRLYT_TYPE_SNAND
+ }, {
+ .name = "spim-nand",
+ .type = BRLYT_TYPE_SNAND
}
};
@@ -54,7 +57,7 @@ static char lk_name[32] = "U-Boot";
static uint32_t crc32tbl[256];
/* NAND header selected by user */
-static const union nand_boot_header *hdr_nand;
+static const struct nand_header_type *hdr_nand;
static uint32_t hdr_nand_size;
/* GFH header + 2 * 4KB pages of NAND */
@@ -366,20 +369,26 @@ static int mtk_image_verify_nand_header(const uint8_t *ptr, int print)
if (ret < 0)
return ret;
- bh = (struct brom_layout_header *)(ptr + info.page_size);
+ if (!ret) {
+ bh = (struct brom_layout_header *)(ptr + info.page_size);
- if (strcmp(bh->name, BRLYT_NAME))
- return -1;
+ if (strcmp(bh->name, BRLYT_NAME))
+ return -1;
+
+ if (le32_to_cpu(bh->magic) != BRLYT_MAGIC)
+ return -1;
- if (le32_to_cpu(bh->magic) != BRLYT_MAGIC) {
- return -1;
- } else {
if (le32_to_cpu(bh->type) == BRLYT_TYPE_NAND)
bootmedia = "Parallel NAND";
else if (le32_to_cpu(bh->type) == BRLYT_TYPE_SNAND)
bootmedia = "Serial NAND (SNFI/AP)";
else
return -1;
+ } else {
+ if (info.snfi)
+ bootmedia = "Serial NAND (SNFI/HSM)";
+ else
+ bootmedia = "Serial NAND (SPIM)";
}
if (print) {