Debian Codegraph @

util/nvidia/cbootimage/src/t30/nvboot_bct_t30.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * See file CREDITS for list of people who contributed to this
17 * project.
18 */
19
20 #ifndef INCLUDED_NVBOOT_BCT_T30_H
21 #define INCLUDED_NVBOOT_BCT_T30_H
22
23 #include <sys/types.h>
24 #include "nvboot_sdram_param_t30.h"
25
26 /**
27 * Defines the number of 32-bit words in the customer_data area of the BCT.
28 */
29 #define NVBOOT_BCT_CUSTOMER_DATA_WORDS 504
30
31 /**
32 * Defines the number of bytes in the customer_data area of the BCT.
33 */
34 #define NVBOOT_BCT_CUSTOMER_DATA_SIZE \
35 (NVBOOT_BCT_CUSTOMER_DATA_WORDS * 4)
36
37 /**
38 * Defines the number of bytes in the reserved area of the BCT.
39 */
40 #define NVBOOT_BCT_RESERVED_SIZE 3
41
42 /**
43 * Defines the maximum number of bootloader descriptions in the BCT.
44 */
45 #define NVBOOT_MAX_BOOTLOADERS 4
46
47 /**
48 * Defines the maximum number of device parameter sets in the BCT.
49 * The value must be equal to (1 << # of device straps)
50 */
51 #define NVBOOT_BCT_MAX_PARAM_SETS 4
52
53 /**
54 * Defines the maximum number of SDRAM parameter sets in the BCT.
55 * The value must be equal to (1 << # of SDRAM straps)
56 */
57 #define NVBOOT_BCT_MAX_SDRAM_SETS 4
58
59 /**
60 * Defines the number of entries (bits) in the bad block table.
61 * The consequences of changing its value are as follows. Using P as the
62 * # of physical blocks in the boot loader and B as the value of this
63 * constant:
64 * B > P: There will be unused storage in the bad block table.
65 * B < P: The virtual block size will be greater than the physical block
66 * size, so the granularity of the bad block table will be less than
67 * one bit per physical block.
68 *
69 * 4096 bits is enough to represent an 8MiB partition of 2KiB blocks with one
70 * bit per block (1 virtual block = 1 physical block). This occupies 512 bytes
71 * of storage.
72 */
73 #define NVBOOT_BAD_BLOCK_TABLE_SIZE 4096
74
75 /**
76 * Defines the maximum number of blocks to search for BCTs.
77 *
78 * This value covers the initial block and a set of journal blocks.
79 *
80 * Ideally, this number will span several erase units for reliable updates
81 * and tolerance for blocks to become bad with use. Safe updates require
82 * a minimum of 2 erase units in which BCTs can appear.
83 *
84 * To ensure that the BCT search spans a sufficient range of configurations,
85 * the search block count has been set to 64. This allows for redundancy with
86 * a wide range of parts and provides room for greater problems in this
87 * region of the device.
88 */
89 #define NVBOOT_MAX_BCT_SEARCH_BLOCKS 64
90
91 /*
92 * Defines the CMAC-AES-128 hash length in 32 bit words. (128 bits = 4 words)
93 */
94 enum {NVBOOT_CMAC_AES_HASH_LENGTH = 4};
95
96 /**
97 * Defines the storage for a hash value (128 bits).
98 */
99 typedef struct nvboot_hash_rec {
100 uint32_t hash[NVBOOT_CMAC_AES_HASH_LENGTH];
101 } nvboot_hash;
102
103 /**
104 * Defines the params that can be configured for NAND devices.
105 */
106 typedef struct nvboot_nand_params_rec {
107 /**
108 * Specifies the clock divider for the PLL_P 432MHz source.
109 * If it is set to 18, then clock source to Nand controller is
110 * 432 / 18 = 24MHz.
111 */
112 uint8_t clock_divider;
113
114 /**
115 * Specifies the value to be programmed to Nand Async Timing
116 * Register 0
117 */
118 uint32_t async_timing0;
119 /**
120 * Specifies the value to be programmed to Nand Async Timing
121 * Register 1
122 */
123 uint32_t async_timing1;
124 /**
125 * Specifies the value to be programmed to Nand Async Timing
126 * Register 2
127 */
128 uint32_t async_timing2;
129 /**
130 * Specifies the value to be programmed to Nand Async Timing
131 * Register 3
132 */
133 uint32_t async_timing3;
134 /**
135 * Specifies the value to be programmed to Nand Sync DDR Timing
136 * Register 0
137 */
138 uint32_t sddr_timing0;
139 /**
140 * Specifies the value to be programmed to Nand Sync DDR Timing
141 * Register 1
142 */
143 uint32_t sddr_timing1;
144 /**
145 * Specifies the value to be programmed to Nand Toggle DDR Timing
146 * Register 0
147 */
148 uint32_t tddr_timing0;
149 /**
150 * Specifies the value to be programmed to Nand Toggle DDR Timing
151 * Register 1
152 */
153 uint32_t tddr_timing1;
154 /* Specifies the value to be programmed to FBIO_DQSIB_DELAY register */
155 uint8_t fbio_dqsib_dly_byte;
156 /* Specifies the value to be programmed to FBIO_DQUSE_DELAY register */
157 uint8_t fbio_quse_dly_byte;
158 /* Specifies the CFG_QUSE_LATE value to be programmed to FBIO
159 * configuration register */
160 uint8_t fbio_cfg_quse_late;
161 /* Specifies whether to enable sync DDR more or not */
162 uint8_t disable_sync_ddr;
163
164 /* Specifies the block size in log2 bytes */
165 uint8_t block_size_log2;
166
167 /* Specifies the page size in log2 bytes */
168 uint8_t page_size_log2;
169 } nvboot_nand_params;
170
171 /* Defines various data widths supported. */
172 typedef enum {
173 /**
174 * Specifies a 1 bit interface to eMMC.
175 * Note that 1-bit data width is only for the driver's internal use.
176 * Fuses doesn't provide option to select 1-bit data width.
177 * The driver selects 1-bit internally based on need.
178 * It is used for reading Extended CSD and when the power class
179 * requirements of a card for 4-bit or 8-bit transfers are not
180 * supported by the target board.
181 */
182 nvboot_sdmmc_data_width_1bit = 0,
183
184 /* Specifies a 4 bit interface to eMMC. */
185 nvboot_sdmmc_data_width_4bit = 1,
186
187 /* Specifies a 8 bit interface to eMMC. */
188 nvboot_sdmmc_data_width_8bit = 2,
189 /* Specifies a 4 bit Ddr interface to eMMC. */
190 nvboot_sdmmc_data_width_ddr_4bit = 5,
191 /* Specifies a 8 bit Ddr interface to eMMC. */
192 nvboot_sdmmc_data_width_ddr_8bit = 6,
193
194 nvboot_sdmmc_data_width_num,
195 nvboot_sdmmc_data_width_force32 = 0x7FFFFFFF
196 } nvboot_sdmmc_data_width;
197
198 /* Defines various sd controllers supported. */
199 typedef enum {
200 /* Specifies Sdmmc 4 controller interface */
201 nvboot_sdmmc_cntrl_4 = 0,
202 /* Specifies Sdmmc 3 controller interface */
203 nvboot_sdmmc_cntrl_3 = 1,
204 nvboot_sdmmc_cntrl_num,
205 nvboot_sdmmc_cntrl_force32 = 0x7FFFFFFF
206 } nvboot_sdmmc_cntrl;
207
208 /* Defines the parameters that can be changed after BCT is read. */
209 typedef struct nvboot_sdmmc_params_rec {
210 /**
211 * Specifies the clock divider for the SDMMC controller's clock source,
212 * which is PLLP running at 432MHz. If it is set to 18, then the SDMMC
213 * controller runs at 432/18 = 24MHz.
214 */
215 uint8_t clock_divider;
216
217 /* Specifies the data bus width. Supported data widths are 4/8 bits. */
218 nvboot_sdmmc_data_width data_width;
219
220 /**
221 * Max Power class supported by the target board.
222 * The driver determines the best data width and clock frequency
223 * supported within the power class range (0 to Max) if the selected
224 * data width cannot be used at the chosen clock frequency.
225 */
226 uint8_t max_power_class_supported;
227
228 /* Specifies the SD controller to be selected */
229 nvboot_sdmmc_cntrl sd_controller;
230 } nvboot_sdmmc_params;
231
232 typedef enum {
233 /* Specifies SPI clock source to be PLLP. */
234 nvboot_spi_clock_source_pllp_out0 = 0,
235
236 /* Specifies SPI clock source to be PLLC. */
237 nvboot_spi_clock_source_pllc_out0,
238
239 /* Specifies SPI clock source to be PLLM. */
240 nvboot_spi_clock_source_pllm_out0,
241
242 /* Specifies SPI clock source to be ClockM. */
243 nvboot_spi_clock_source_clockm,
244
245 nvboot_spi_clock_source_num,
246 nvboot_spi_clock_source_force32 = 0x7FFFFFF
247 } nvboot_spi_clock_source;
248
249
250 /**
251 * Defines the parameters SPI FLASH devices.
252 */
253 typedef struct nvboot_spiflash_params_rec {
254 /**
255 * Specifies the clock source to use.
256 */
257 nvboot_spi_clock_source clock_source;
258
259 /**
260 * Specifes the clock divider to use.
261 * The value is a 7-bit value based on an input clock of 432Mhz.
262 * Divider = (432+ DesiredFrequency-1)/DesiredFrequency;
263 * Typical values:
264 * NORMAL_READ at 20MHz: 22
265 * FAST_READ at 33MHz: 14
266 * FAST_READ at 40MHz: 11
267 * FAST_READ at 50MHz: 9
268 */
269 uint8_t clock_divider;
270
271 /**
272 * Specifies the type of command for read operations.
273 * NV_FALSE specifies a NORMAL_READ Command
274 * NV_TRUE specifies a FAST_READ Command
275 */
276 uint8_t read_command_type_fast;
277 } nvboot_spiflash_params;
278
279 /**
280 * Defines the union of the parameters required by each device.
281 */
282 typedef union {
283 uint8_t size[64];
284 /* Specifies optimized parameters for NAND */
285 nvboot_nand_params nand_params;
286 /* Specifies optimized parameters for eMMC and eSD */
287 nvboot_sdmmc_params sdmmc_params;
288 /* Specifies optimized parameters for SPI NOR */
289 nvboot_spiflash_params spiflash_params;
290 } nvboot_dev_params;
291
292 /**
293 * Identifies the types of devices from which the system booted.
294 * Used to identify primary and secondary boot devices.
295 * @note These no longer match the fuse API device values (for
296 * backward compatibility with AP15).
297 */
298 typedef enum {
299 /* Specifies a default (unset) value. */
300 nvboot_dev_type_none = 0,
301
302 /* Specifies NAND. */
303 nvboot_dev_type_nand,
304
305 /* Specifies SPI NOR. */
306 nvboot_dev_type_spi = 3,
307
308 /* Specifies SDMMC (either eMMC or eSD). */
309 nvboot_dev_type_sdmmc,
310
311 nvboot_dev_type_max,
312
313 /* Ignore -- Forces compilers to make 32-bit enums. */
314 nvboot_dev_type_force32 = 0x7FFFFFFF
315 } nvboot_dev_type;
316
317 /**
318 * Stores information needed to locate and verify a boot loader.
319 *
320 * There is one \c nv_bootloader_info structure for each copy of a BL stored on
321 * the device.
322 */
323 typedef struct nv_bootloader_info_rec {
324 uint32_t version;
325 uint32_t start_blk;
326 uint32_t start_page;
327 uint32_t length;
328 uint32_t load_addr;
329 uint32_t entry_point;
330 uint32_t attribute;
331 nvboot_hash crypto_hash;
332 } nv_bootloader_info;
333
334 /**
335 * Defines the bad block table structure stored in the BCT.
336 */
337 typedef struct nvboot_badblock_table_rec {
338 uint32_t entries_used;
339 uint8_t virtual_blk_size_log2;
340 uint8_t block_size_log2;
341 uint8_t bad_blks[NVBOOT_BAD_BLOCK_TABLE_SIZE / 8];
342 } nvboot_badblock_table;
343
344 /**
345 * Contains the information needed to load BLs from the secondary boot device.
346 *
347 * - Supplying NumParamSets = 0 indicates not to load any of them.
348 * - Supplying NumDramSets = 0 indicates not to load any of them.
349 * - The \c random_aes_blk member exists to increase the difficulty of
350 * key attacks based on knowledge of this structure.
351 */
352 typedef struct nvboot_config_table_rec {
353 nvboot_hash crypto_hash;
354 nvboot_hash random_aes_blk;
355 uint32_t boot_data_version;
356 uint32_t block_size_log2;
357 uint32_t page_size_log2;
358 uint32_t partition_size;
359 uint32_t num_param_sets;
360 nvboot_dev_type dev_type[NVBOOT_BCT_MAX_PARAM_SETS];
361 nvboot_dev_params dev_params[NVBOOT_BCT_MAX_PARAM_SETS];
362 uint32_t num_sdram_sets;
363 nvboot_sdram_params sdram_params[NVBOOT_BCT_MAX_SDRAM_SETS];
364 nvboot_badblock_table badblock_table;
365 uint32_t bootloader_used;
366 nv_bootloader_info bootloader[NVBOOT_MAX_BOOTLOADERS];
367 uint8_t customer_data[NVBOOT_BCT_CUSTOMER_DATA_SIZE];
368 /*
369 * ODMDATA is stored in the BCT in IRAM by the BootROM.
370 * Read the data @ bct_start + (bct_size - 12). This works
371 * on T20 and T30 BCTs, which are locked down. If this changes
372 * in new chips, we can revisit this algorithm.
373 */
374 uint32_t odm_data;
375 uint32_t reserved1;
376 uint8_t enable_fail_back;
377 uint8_t reserved[NVBOOT_BCT_RESERVED_SIZE];
378 } nvboot_config_table;
379 #endif /* #ifndef INCLUDED_NVBOOT_BCT_T30_H */