1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * MediaTek BootROM header definitions
5 * Copyright (C) 2018 MediaTek Inc.
6 * Author: Weijie Gao <weijie.gao@mediatek.com>
12 /* Device header definitions, all fields are little-endian */
14 /* Header for NOR/SD/eMMC */
15 union gen_boot_header {
25 #define EMMC_BOOT_NAME "EMMC_BOOT"
26 #define SF_BOOT_NAME "SF_BOOT"
27 #define SDMMC_BOOT_NAME "SDMMC_BOOT"
30 union nand_boot_header {
39 uint16_t pages_of_block;
41 uint16_t writesize_shift;
42 uint16_t erasesize_shift;
44 uint8_t ecc_parity[28];
50 #define NAND_BOOT_NAME "BOOTLOADER!"
51 #define NAND_BOOT_VERSION "V006"
52 #define NAND_BOOT_ID "NFIINFO"
54 /* BootROM layout header */
55 struct brom_layout_header {
62 uint32_t header_size_2;
63 uint32_t total_size_2;
67 #define BRLYT_NAME "BRLYT"
68 #define BRLYT_MAGIC 0x42424242
71 BRLYT_TYPE_INVALID = 0,
72 BRLYT_TYPE_NAND = 0x10002,
73 BRLYT_TYPE_EMMC = 0x10005,
74 BRLYT_TYPE_NOR = 0x10007,
75 BRLYT_TYPE_SDMMC = 0x10008,
76 BRLYT_TYPE_SNAND = 0x10009
79 /* Combined device header for NOR/SD/eMMC */
80 struct gen_device_header {
81 union gen_boot_header boot;
84 struct brom_layout_header brlyt;
85 uint8_t brlyt_pad[0x400];
89 /* BootROM header definitions */
90 struct gfh_common_header {
97 #define GFH_HEADER_MAGIC "MMM"
99 #define GFH_TYPE_FILE_INFO 0
100 #define GFH_TYPE_BL_INFO 1
101 #define GFH_TYPE_BROM_CFG 7
102 #define GFH_TYPE_BL_SEC_KEY 3
103 #define GFH_TYPE_ANTI_CLONE 2
104 #define GFH_TYPE_BROM_SEC_CFG 8
106 struct gfh_file_info {
107 struct gfh_common_header gfh;
118 uint32_t jump_offset;
122 #define GFH_FILE_INFO_NAME "FILE_INFO"
124 #define GFH_FLASH_TYPE_GEN 5
125 #define GFH_FLASH_TYPE_NAND 2
127 #define GFH_SIG_TYPE_NONE 0
128 #define GFH_SIG_TYPE_SHA256 1
131 struct gfh_common_header gfh;
135 struct gfh_brom_cfg {
136 struct gfh_common_header gfh;
138 uint32_t usbdl_by_auto_detect_timeout_ms;
139 uint8_t unused[0x48];
140 uint32_t usbdl_by_kcol0_timeout_ms;
141 uint32_t usbdl_by_flag_timeout_ms;
145 #define GFH_BROM_CFG_USBDL_BY_AUTO_DETECT_TIMEOUT_EN 0x02
146 #define GFH_BROM_CFG_USBDL_AUTO_DETECT_DIS 0x10
147 #define GFH_BROM_CFG_USBDL_BY_KCOL0_TIMEOUT_EN 0x80
148 #define GFH_BROM_CFG_USBDL_BY_FLAG_TIMEOUT_EN 0x100
150 struct gfh_bl_sec_key {
151 struct gfh_common_header gfh;
155 struct gfh_anti_clone {
156 struct gfh_common_header gfh;
164 struct gfh_brom_sec_cfg {
165 struct gfh_common_header gfh;
167 char customer_name[0x20];
171 #define BROM_SEC_CFG_JTAG_EN 1
172 #define BROM_SEC_CFG_UART_EN 2
175 struct gfh_file_info file_info;
176 struct gfh_bl_info bl_info;
177 struct gfh_brom_cfg brom_cfg;
178 struct gfh_bl_sec_key bl_sec_key;
179 struct gfh_anti_clone anti_clone;
180 struct gfh_brom_sec_cfg brom_sec_cfg;
183 /* LK image header */
197 #define LK_PART_MAGIC 0x58881688
199 #endif /* _MTK_IMAGE_H */