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"
29 /* BootROM layout header */
30 struct brom_layout_header {
37 uint32_t header_size_2;
38 uint32_t total_size_2;
42 #define BRLYT_NAME "BRLYT"
43 #define BRLYT_MAGIC 0x42424242
46 BRLYT_TYPE_INVALID = 0,
47 BRLYT_TYPE_NAND = 0x10002,
48 BRLYT_TYPE_EMMC = 0x10005,
49 BRLYT_TYPE_NOR = 0x10007,
50 BRLYT_TYPE_SDMMC = 0x10008,
51 BRLYT_TYPE_SNAND = 0x10009
54 /* Combined device header for NOR/SD/eMMC */
55 struct gen_device_header {
56 union gen_boot_header boot;
59 struct brom_layout_header brlyt;
60 uint8_t brlyt_pad[0x400];
64 /* BootROM header definitions */
65 struct gfh_common_header {
66 uint32_t magic_version;
71 #define GFH_HEADER_MAGIC 0x4D4D4D
72 #define GFH_HEADER_VERSION_SHIFT 24
74 #define GFH_TYPE_FILE_INFO 0
75 #define GFH_TYPE_BL_INFO 1
76 #define GFH_TYPE_BROM_CFG 7
77 #define GFH_TYPE_BL_SEC_KEY 3
78 #define GFH_TYPE_ANTI_CLONE 2
79 #define GFH_TYPE_BROM_SEC_CFG 8
81 struct gfh_file_info {
82 struct gfh_common_header gfh;
97 #define GFH_FILE_INFO_NAME "FILE_INFO"
99 #define GFH_FLASH_TYPE_GEN 5
100 #define GFH_FLASH_TYPE_NAND 2
102 #define GFH_SIG_TYPE_NONE 0
103 #define GFH_SIG_TYPE_SHA256 1
106 struct gfh_common_header gfh;
110 struct gfh_brom_cfg {
111 struct gfh_common_header gfh;
113 uint32_t usbdl_by_auto_detect_timeout_ms;
114 uint8_t unused[0x45];
115 uint8_t jump_bl_arm64;
117 uint32_t usbdl_by_kcol0_timeout_ms;
118 uint32_t usbdl_by_flag_timeout_ms;
122 #define GFH_BROM_CFG_USBDL_BY_AUTO_DETECT_TIMEOUT_EN 0x02
123 #define GFH_BROM_CFG_USBDL_AUTO_DETECT_DIS 0x10
124 #define GFH_BROM_CFG_USBDL_BY_KCOL0_TIMEOUT_EN 0x80
125 #define GFH_BROM_CFG_USBDL_BY_FLAG_TIMEOUT_EN 0x100
126 #define GFH_BROM_CFG_JUMP_BL_ARM64_EN 0x1000
127 #define GFH_BROM_CFG_JUMP_BL_ARM64 0x64
129 struct gfh_bl_sec_key {
130 struct gfh_common_header gfh;
134 struct gfh_anti_clone {
135 struct gfh_common_header gfh;
143 struct gfh_brom_sec_cfg {
144 struct gfh_common_header gfh;
146 char customer_name[0x20];
150 #define BROM_SEC_CFG_JTAG_EN 1
151 #define BROM_SEC_CFG_UART_EN 2
154 struct gfh_file_info file_info;
155 struct gfh_bl_info bl_info;
156 struct gfh_brom_cfg brom_cfg;
157 struct gfh_bl_sec_key bl_sec_key;
158 struct gfh_anti_clone anti_clone;
159 struct gfh_brom_sec_cfg brom_sec_cfg;
162 /* LK image header */
176 #define LK_PART_MAGIC 0x58881688
178 /* MT7621 NAND SPL image header */
180 #define MT7621_IH_NMLEN 12
181 #define MT7621_IH_CRC_POLYNOMIAL 0x04c11db7
183 struct mt7621_nand_header {
184 char ih_name[MT7621_IH_NMLEN];
185 uint32_t nand_ac_timing;
186 uint32_t ih_stage_offset;
187 uint32_t ih_bootloader_offset;
188 uint32_t nand_info_1_data;
192 struct mt7621_stage1_header {
193 uint32_t jump_insn[2];
199 uint32_t next_offset;
202 #endif /* _MTK_IMAGE_H */