blob: 9abe02145236721e0fe593e0e5fab4de688861c9 [file] [log] [blame]
Stefan Roese3dc06672020-11-30 13:14:23 +01001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2020 Marvell International Ltd.
4 */
5
6/*
7 * Bootloader definitions that are shared with other programs
8 */
9
10#ifndef __CVMX_BOOTLOADER__
11#define __CVMX_BOOTLOADER__
12
13/*
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.
19 */
20#define BOOTLOADER_HEADER_MAGIC 0x424f4f54 /* "BOOT" in ASCII */
21
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
26
27#define BOOTLOADER_HEADER_CURRENT_MAJOR_REV 1
28#define BOOTLOADER_HEADER_CURRENT_MINOR_REV 2
29/*
30 * Revision history
31 * 1.1 Initial released revision. (SDK 1.9)
32 * 1.2 TLB based relocatable image (SDK 2.0)
33 */
34
35#ifndef __ASSEMBLY__
36struct 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)
41 */
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 */
45
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 */
50
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 */
54 uint32_t flags;
55 uint16_t image_type; /* Defined in bootloader_image_t enum */
56 uint16_t resv0; /* pad */
57
58 uint32_t reserved1;
59 uint32_t reserved2;
60 uint32_t reserved3;
61 uint32_t reserved4;
62
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];
67} __packed;
68
69/* Defines for flag field */
70#define BL_HEADER_FLAG_FAILSAFE 1
71
72enum 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 */
82 BL_HEADER_IMAGE_MAX,
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
86};
87
88#endif /* __ASSEMBLY__ */
89
90/*
91 * Maximum address searched for NAND boot images and environments.
92 * This is used by stage1 and stage2.
93 */
94#define MAX_NAND_SEARCH_ADDR 0x800000
95
96/* Maximum address to look for start of normal bootloader */
97#define MAX_NOR_SEARCH_ADDR 0x400000
98
99/*
100 * Defines for RAM based environment set by the host or the previous
101 * bootloader in a chain boot configuration.
102 */
103
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
112
113/* Board numbers and names */
114
115/* Type defines for board and chip types */
116enum 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,
122 CVMX_BOARD_TYPE_MAX,
123 /* NOTE: 256-257 are being used by a customer. */
124
125 /*
126 * The range from CVMX_BOARD_TYPE_MAX to
127 * CVMX_BOARD_TYPE_CUST_DEFINED_MIN is reserved
128 * for future SDK use.
129 */
130
131 /*
132 * Set aside a range for customer boards. These numbers are managed
133 * by Cavium.
134 */
135 CVMX_BOARD_TYPE_CUST_DEFINED_MIN = 10000,
136 CVMX_BOARD_TYPE_CUST_DEFINED_MAX = 20000,
137
138 /*
139 * Set aside a range for customer private use. The SDK won't
140 * use any numbers in this range.
141 */
142 CVMX_BOARD_TYPE_CUST_PRIVATE_MIN = 20001,
143 CVMX_BOARD_TYPE_CUST_PRIVATE_MAX = 30000,
144};
145
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)
149
150static inline const char
151*cvmx_board_type_to_string(enum cvmx_board_types_enum type)
152{
153 switch (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);
159
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);
163
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);
167 }
168
169 return "Unsupported Board";
170}
171
172#endif /* __CVMX_BOOTLOADER__ */