blob: 9a53456370f3b014340b9ed87913c6c9b766ad13 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Yen Lin22e9f892012-04-10 05:17:02 +00002/*
3 * (C) Copyright 2010, 2011
4 * NVIDIA Corporation <www.nvidia.com>
Yen Lin22e9f892012-04-10 05:17:02 +00005 */
6
7#ifndef _WARM_BOOT_H_
8#define _WARM_BOOT_H_
9
10#define STRAP_OPT_A_RAM_CODE_SHIFT 4
11#define STRAP_OPT_A_RAM_CODE_MASK (0xf << STRAP_OPT_A_RAM_CODE_SHIFT)
12
13/* Defines the supported operating modes */
14enum fuse_operating_mode {
15 MODE_PRODUCTION = 3,
16 MODE_UNDEFINED,
17};
18
19/* Defines the CMAC-AES-128 hash length in 32 bit words. (128 bits = 4 words) */
20enum {
21 HASH_LENGTH = 4
22};
23
24/* Defines the storage for a hash value (128 bits) */
25struct hash {
26 u32 hash[HASH_LENGTH];
27};
28
29/*
30 * Defines the code header information for the boot rom.
31 *
32 * The code immediately follows the code header.
33 *
34 * Note that the code header needs to be 16 bytes aligned to preserve
35 * the alignment of relevant data for hash and decryption computations without
36 * requiring extra copies to temporary memory areas.
37 */
38struct wb_header {
39 u32 length_insecure; /* length of the code header */
40 u32 reserved[3];
41 struct hash hash; /* hash of header+code, starts next field*/
42 struct hash random_aes_block; /* a data block to aid security. */
43 u32 length_secure; /* length of the code header */
44 u32 destination; /* destination address to put the wb code */
45 u32 entry_point; /* execution address of the wb code */
46 u32 code_length; /* length of the code */
47};
48
49/*
50 * The warm boot code needs direct access to these registers since it runs in
51 * SRAM and cannot call other U-Boot code.
52 */
53union osc_ctrl_reg {
54 struct {
55 u32 xoe:1;
56 u32 xobp:1;
57 u32 reserved0:2;
58 u32 xofs:6;
59 u32 reserved1:2;
60 u32 xods:5;
61 u32 reserved2:3;
62 u32 oscfi_spare:8;
63 u32 pll_ref_div:2;
64 u32 osc_freq:2;
65 };
66 u32 word;
67};
68
69union pllx_base_reg {
70 struct {
71 u32 divm:5;
72 u32 reserved0:3;
73 u32 divn:10;
74 u32 reserved1:2;
75 u32 divp:3;
76 u32 reserved2:4;
77 u32 lock:1;
78 u32 reserved3:1;
79 u32 ref_dis:1;
80 u32 enable:1;
81 u32 bypass:1;
82 };
83 u32 word;
84};
85
86union pllx_misc_reg {
87 struct {
88 u32 vcocon:4;
89 u32 lfcon:4;
90 u32 cpcon:4;
91 u32 lock_sel:6;
92 u32 reserved0:1;
93 u32 lock_enable:1;
94 u32 reserved1:1;
95 u32 dccon:1;
96 u32 pts:2;
97 u32 reserved2:6;
98 u32 out1_div_byp:1;
99 u32 out1_inv_clk:1;
100 };
101 u32 word;
102};
103
104/*
105 * TODO: This register is not documented in the TRM yet. We could move this
106 * into the EMC and give it a proper interface, but not while it is
107 * undocumented.
108 */
109union scratch3_reg {
110 struct {
111 u32 pllx_base_divm:5;
112 u32 pllx_base_divn:10;
113 u32 pllx_base_divp:3;
114 u32 pllx_misc_lfcon:4;
115 u32 pllx_misc_cpcon:4;
116 };
117 u32 word;
118};
119
Yen Lin22e9f892012-04-10 05:17:02 +0000120/**
121 * Save warmboot memory settings for a later resume
122 *
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100123 * Return: 0 if ok, -1 on error
Yen Lin22e9f892012-04-10 05:17:02 +0000124 */
125int warmboot_save_sdram_params(void);
126
127int warmboot_prepare_code(u32 seg_address, u32 seg_length);
128int sign_data_block(u8 *source, u32 length, u8 *signature);
129void wb_start(void); /* Start of WB assembly code */
130void wb_end(void); /* End of WB assembly code */
131
132#endif