1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * MediaTek BootROM NAND header definitions
5 * Copyright (C) 2022 MediaTek Inc.
6 * Author: Weijie Gao <weijie.gao@mediatek.com>
9 #ifndef _MTK_NAND_HEADERS_H
10 #define _MTK_NAND_HEADERS_H
15 struct nand_header_info {
21 /* AP BROM Header for NAND */
22 union nand_boot_header {
27 uint16_t ioif; /* I/O interface */
28 uint16_t pagesize; /* NAND page size */
29 uint16_t addrcycles; /* Address cycles */
30 uint16_t oobsize; /* NAND page spare size */
31 uint16_t pages_of_block; /* Pages of one block */
32 uint16_t numblocks; /* Total blocks of NAND chip */
33 uint16_t writesize_shift;
34 uint16_t erasesize_shift;
36 uint8_t ecc_parity[28]; /* ECC parity of this header */
42 #define NAND_BOOT_NAME "BOOTLOADER!"
43 #define NAND_BOOT_VERSION "V006"
44 #define NAND_BOOT_ID "NFIINFO"
46 /* Find nand header data by name */
47 const union nand_boot_header *mtk_nand_header_find(const char *name);
49 /* Device header size using this nand header */
50 uint32_t mtk_nand_header_size(const union nand_boot_header *hdr_nand);
52 /* Get nand info from nand header (page size, spare size, ...) */
53 int mtk_nand_header_info(const void *ptr, struct nand_header_info *info);
55 /* Whether given header data is valid */
56 bool is_mtk_nand_header(const void *ptr);
58 /* Generate Device header using give nand header */
59 uint32_t mtk_nand_header_put(const union nand_boot_header *hdr_nand, void *ptr);
61 #endif /* _MTK_NAND_HEADERS_H */