1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020 Marvell International Ltd.
7 * Bootloader definitions that are shared with other programs
10 #ifndef __CVMX_BOOTLOADER__
11 #define __CVMX_BOOTLOADER__
14 * The bootloader_header_t structure defines the header that is present
15 * at the start of binary u-boot images. This header is used to locate
16 * the bootloader image in NAND, and also to allow verification of images
17 * for normal NOR booting. This structure is placed at the beginning of a
18 * bootloader binary image, and remains in the executable code.
20 #define BOOTLOADER_HEADER_MAGIC 0x424f4f54 /* "BOOT" in ASCII */
22 #define BOOTLOADER_HEADER_COMMENT_LEN 64
23 #define BOOTLOADER_HEADER_VERSION_LEN 64
24 /* limited by the space to the next exception handler */
25 #define BOOTLOADER_HEADER_MAX_SIZE 0x200
27 #define BOOTLOADER_HEADER_CURRENT_MAJOR_REV 1
28 #define BOOTLOADER_HEADER_CURRENT_MINOR_REV 2
31 * 1.1 Initial released revision. (SDK 1.9)
32 * 1.2 TLB based relocatable image (SDK 2.0)
36 struct bootloader_header {
37 uint32_t jump_instr; /*
38 * Jump to executable code following the
39 * header. This allows this header to be
40 * (and remain) part of the executable image)
42 uint32_t nop_instr; /* Must be 0x0 */
43 uint32_t magic; /* Magic number to identify header */
44 uint32_t hcrc; /* CRC of all of header excluding this field */
46 uint16_t hlen; /* Length of header in bytes */
47 uint16_t maj_rev; /* Major revision */
48 uint16_t min_rev; /* Minor revision */
49 uint16_t board_type; /* Board type that the image is for */
51 uint32_t dlen; /* Length of data (following header) in bytes */
52 uint32_t dcrc; /* CRC of data */
53 uint64_t address; /* Mips virtual address */
55 uint16_t image_type; /* Defined in bootloader_image_t enum */
56 uint16_t resv0; /* pad */
63 /* Optional, for descriptive purposes */
64 char comment_string[BOOTLOADER_HEADER_COMMENT_LEN];
65 /* Optional, for descriptive purposes */
66 char version_string[BOOTLOADER_HEADER_VERSION_LEN];
69 /* Defines for flag field */
70 #define BL_HEADER_FLAG_FAILSAFE 1
72 enum bootloader_image {
73 BL_HEADER_IMAGE_UNKNOWN = 0x0,
74 BL_HEADER_IMAGE_STAGE2, /* Binary bootloader stage2 image */
75 BL_HEADER_IMAGE_STAGE3, /* Binary bootloader stage3 image */
76 BL_HEADER_IMAGE_NOR, /* Binary bootloader for NOR boot */
77 BL_HEADER_IMAGE_PCIBOOT, /* Binary bootloader for PCI boot */
78 BL_HEADER_IMAGE_UBOOT_ENV, /* Environment for u-boot */
79 /* Bootloader before U-Boot (stage 1/1.5) */
80 BL_HEADER_IMAGE_PRE_UBOOT,
81 BL_HEADER_IMAGE_STAGE1, /* NOR stage 1 bootloader */
83 /* Range for customer private use. Will not be used by Cavium Inc. */
84 BL_HEADER_IMAGE_CUST_RESERVED_MIN = 0x1000,
85 BL_HEADER_IMAGE_CUST_RESERVED_MAX = 0x1fff
88 #endif /* __ASSEMBLY__ */
91 * Maximum address searched for NAND boot images and environments.
92 * This is used by stage1 and stage2.
94 #define MAX_NAND_SEARCH_ADDR 0x800000
96 /* Maximum address to look for start of normal bootloader */
97 #define MAX_NOR_SEARCH_ADDR 0x400000
100 * Defines for RAM based environment set by the host or the previous
101 * bootloader in a chain boot configuration.
104 #define U_BOOT_RAM_ENV_ADDR 0x1000
105 #define U_BOOT_RAM_ENV_SIZE 0x1000
106 #define U_BOOT_RAM_ENV_CRC_SIZE 0x4
107 #define U_BOOT_RAM_ENV_ADDR_2 (U_BOOT_RAM_ENV_ADDR + U_BOOT_RAM_ENV_SIZE)
108 /* Address of environment in L2 cache if booted from cache */
109 #define U_BOOT_CACHE_ENV_ADDR 0x000ff000
110 /* Size of environment in L2 cache */
111 #define U_BOOT_CACHE_ENV_SIZE 0x1000
113 /* Board numbers and names */
115 /* Type defines for board and chip types */
116 enum cvmx_board_types_enum {
117 CVMX_BOARD_TYPE_NULL = 0,
118 CVMX_BOARD_TYPE_SIM = 1,
119 /* Special 'generic' board type, supports many boards */
120 CVMX_BOARD_TYPE_GENERIC = 28,
121 CVMX_BOARD_TYPE_EBB7304 = 76,
123 /* NOTE: 256-257 are being used by a customer. */
126 * The range from CVMX_BOARD_TYPE_MAX to
127 * CVMX_BOARD_TYPE_CUST_DEFINED_MIN is reserved
128 * for future SDK use.
132 * Set aside a range for customer boards. These numbers are managed
135 CVMX_BOARD_TYPE_CUST_DEFINED_MIN = 10000,
136 CVMX_BOARD_TYPE_CUST_DEFINED_MAX = 20000,
139 * Set aside a range for customer private use. The SDK won't
140 * use any numbers in this range.
142 CVMX_BOARD_TYPE_CUST_PRIVATE_MIN = 20001,
143 CVMX_BOARD_TYPE_CUST_PRIVATE_MAX = 30000,
146 /* Functions to return string based on type */
147 /* Skip CVMX_BOARD_TYPE_ */
148 #define ENUM_BRD_TYPE_CASE(x) case x: return(#x + 16)
150 static inline const char
151 *cvmx_board_type_to_string(enum cvmx_board_types_enum type)
154 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NULL);
155 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_SIM);
156 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_GENERIC);
157 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBB7304);
158 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_MAX);
160 /* Customer boards listed here */
161 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DEFINED_MIN);
162 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DEFINED_MAX);
164 /* Customer private range */
165 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MIN);
166 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MAX);
169 return "Unsupported Board";
172 #endif /* __CVMX_BOOTLOADER__ */