]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
dafa84d2 PD |
2 | /* |
3 | * (C) Copyright 2000-2009 | |
4 | * Wolfgang Denk, DENX Software Engineering, [email protected]. | |
5 | * | |
6 | * Copy the startup prototype, previously defined in common.h | |
7 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved | |
dafa84d2 PD |
8 | */ |
9 | ||
10 | #ifndef __INIT_H_ | |
11 | #define __INIT_H_ 1 | |
12 | ||
13 | #ifndef __ASSEMBLY__ /* put C only stuff in this section */ | |
14 | ||
401d1c4f SG |
15 | #include <linux/types.h> |
16 | ||
35a3f871 SG |
17 | /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */ |
18 | #ifdef CONFIG_EFI_STUB | |
19 | #define ll_boot_init() false | |
20 | #else | |
401d1c4f SG |
21 | #include <asm/global_data.h> |
22 | ||
ba974a01 | 23 | #define ll_boot_init() (!(gd->flags & GD_FLG_SKIP_LL_INIT)) |
35a3f871 SG |
24 | #endif |
25 | ||
dafa84d2 PD |
26 | /* |
27 | * Function Prototypes | |
28 | */ | |
29 | ||
30 | /* common/board_f.c */ | |
d6f87712 | 31 | void board_init_f(ulong dummy); |
dafa84d2 PD |
32 | |
33 | /** | |
34 | * arch_cpu_init() - basic cpu-dependent setup for an architecture | |
35 | * | |
36 | * This is called after early malloc is available. It should handle any | |
37 | * CPU- or SoC- specific init needed to continue the init sequence. See | |
38 | * board_f.c for where it is called. If this is not provided, a default | |
39 | * version (which does nothing) will be used. | |
40 | * | |
dc145a7b | 41 | * Return: 0 on success, otherwise error |
dafa84d2 PD |
42 | */ |
43 | int arch_cpu_init(void); | |
44 | ||
d6f87712 PD |
45 | /** |
46 | * arch_cpu_init_dm() - init CPU after driver model is available | |
47 | * | |
48 | * This is called immediately after driver model is available before | |
49 | * relocation. This is similar to arch_cpu_init() but is able to reference | |
50 | * devices | |
51 | * | |
dc145a7b | 52 | * Return: 0 if OK, -ve on error |
d6f87712 PD |
53 | */ |
54 | int arch_cpu_init_dm(void); | |
55 | ||
dafa84d2 PD |
56 | /** |
57 | * mach_cpu_init() - SoC/machine dependent CPU setup | |
58 | * | |
59 | * This is called after arch_cpu_init(). It should handle any | |
60 | * SoC or machine specific init needed to continue the init sequence. See | |
61 | * board_f.c for where it is called. If this is not provided, a default | |
62 | * version (which does nothing) will be used. | |
63 | * | |
dc145a7b | 64 | * Return: 0 on success, otherwise error |
dafa84d2 PD |
65 | */ |
66 | int mach_cpu_init(void); | |
67 | ||
d6f87712 PD |
68 | /** |
69 | * arch_fsp_init() - perform firmware support package init | |
70 | * | |
71 | * Where U-Boot relies on binary blobs to handle part of the system init, this | |
72 | * function can be used to set up the blobs. This is used on some Intel | |
73 | * platforms. | |
dc145a7b MS |
74 | * |
75 | * Return: 0 | |
d6f87712 PD |
76 | */ |
77 | int arch_fsp_init(void); | |
78 | ||
fe08d39d SG |
79 | /** |
80 | * arch_fsp_init() - perform post-relocation firmware support package init | |
81 | * | |
82 | * Where U-Boot relies on binary blobs to handle part of the system init, this | |
83 | * function can be used to set up the blobs. This is used on some Intel | |
84 | * platforms. | |
85 | * | |
86 | * Return: 0 | |
87 | */ | |
88 | int arch_fsp_init_r(void); | |
89 | ||
d6f87712 PD |
90 | int dram_init(void); |
91 | ||
92 | /** | |
93 | * dram_init_banksize() - Set up DRAM bank sizes | |
94 | * | |
95 | * This can be implemented by boards to set up the DRAM bank information in | |
96 | * gd->bd->bi_dram(). It is called just before relocation, after dram_init() | |
97 | * is called. | |
98 | * | |
99 | * If this is not provided, a default implementation will try to set up a | |
100 | * single bank. It will do this if CONFIG_NR_DRAM_BANKS and | |
101 | * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of | |
102 | * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to | |
103 | * get_effective_memsize(). | |
104 | * | |
dc145a7b | 105 | * Return: 0 if OK, -ve on error |
d6f87712 PD |
106 | */ |
107 | int dram_init_banksize(void); | |
108 | ||
9b4a205f SG |
109 | long get_ram_size(long *base, long size); |
110 | phys_size_t get_effective_memsize(void); | |
111 | ||
49acd56e SG |
112 | int testdram(void); |
113 | ||
d6f87712 | 114 | /** |
dc145a7b | 115 | * arch_reserve_stacks() - Reserve all necessary stacks |
d6f87712 PD |
116 | * |
117 | * This is used in generic board init sequence in common/board_f.c. Each | |
118 | * architecture could provide this function to tailor the required stacks. | |
119 | * | |
120 | * On entry gd->start_addr_sp is pointing to the suggested top of the stack. | |
121 | * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures | |
122 | * require only this can leave it untouched. | |
123 | * | |
124 | * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective | |
125 | * positions of the stack. The stack pointer(s) will be set to this later. | |
126 | * gd->irq_sp is only required, if the architecture needs it. | |
127 | * | |
dc145a7b | 128 | * Return: 0 if no error |
d6f87712 PD |
129 | */ |
130 | int arch_reserve_stacks(void); | |
131 | ||
79926e4f OP |
132 | /** |
133 | * arch_reserve_mmu() - Reserve memory for MMU TLB table | |
134 | * | |
135 | * Architecture-specific routine for reserving memory for the MMU TLB table. | |
136 | * This is used in generic board init sequence in common/board_f.c. | |
137 | * | |
138 | * If an implementation is not provided, it will just be a nop stub. | |
139 | * | |
140 | * Return: 0 if OK | |
141 | */ | |
142 | int arch_reserve_mmu(void); | |
143 | ||
81e7cb1e OP |
144 | /** |
145 | * arch_setup_bdinfo() - Architecture dependent boardinfo setup | |
146 | * | |
147 | * Architecture-specific routine for populating various boardinfo fields of | |
148 | * gd->bd. It is called during the generic board init sequence. | |
149 | * | |
150 | * If an implementation is not provided, it will just be a nop stub. | |
151 | * | |
152 | * Return: 0 if OK | |
153 | */ | |
154 | int arch_setup_bdinfo(void); | |
155 | ||
ba743103 OP |
156 | /** |
157 | * setup_bdinfo() - Generic boardinfo setup | |
158 | * | |
159 | * Routine for populating various generic boardinfo fields of | |
160 | * gd->bd. It is called during the generic board init sequence. | |
161 | * | |
162 | * Return: 0 if OK | |
163 | */ | |
164 | int setup_bdinfo(void); | |
165 | ||
fb504b2c OP |
166 | /** |
167 | * cpu_secondary_init_r() - CPU-specific secondary initialization | |
168 | * | |
169 | * After non-volatile devices, environment and cpu code are setup, have | |
170 | * another round to deal with any initialization that might require | |
171 | * full access to the environment or loading of some image (firmware) | |
172 | * from a non-volatile device. | |
173 | * | |
174 | * It is called during the generic post-relocation init sequence. | |
175 | * | |
176 | * Return: 0 if OK | |
177 | */ | |
178 | int cpu_secondary_init_r(void); | |
179 | ||
c343e8c0 OP |
180 | /** |
181 | * pci_ep_init() - Initialize pci endpoint devices | |
182 | * | |
183 | * It is called during the generic post-relocation init sequence. | |
184 | * | |
185 | * Return: 0 if OK | |
186 | */ | |
187 | int pci_ep_init(void); | |
188 | ||
b9f6d0f7 OP |
189 | /** |
190 | * pci_init() - Enumerate pci devices | |
191 | * | |
192 | * It is called during the generic post-relocation init sequence to enumerate | |
193 | * pci buses. This is needed, for instance, in the case of DM PCI-based | |
194 | * Ethernet devices, which will not be detected without having the enumeration | |
195 | * performed earlier. | |
196 | * | |
197 | * Return: 0 if OK | |
198 | */ | |
199 | int pci_init(void); | |
200 | ||
b8aa55cb PD |
201 | /** |
202 | * init_cache_f_r() - Turn on the cache in preparation for relocation | |
203 | * | |
dc145a7b | 204 | * Return: 0 if OK, -ve on error |
b8aa55cb PD |
205 | */ |
206 | int init_cache_f_r(void); | |
207 | ||
5d6c61ac MS |
208 | #if !CONFIG_IS_ENABLED(CPU) |
209 | /** | |
210 | * print_cpuinfo() - Display information about the CPU | |
211 | * | |
212 | * Return: 0 if OK, -ve on error | |
213 | */ | |
d6f87712 | 214 | int print_cpuinfo(void); |
5d6c61ac | 215 | #endif |
d6f87712 | 216 | int timer_init(void); |
d6f87712 | 217 | int misc_init_f(void); |
dc145a7b | 218 | |
d6f87712 PD |
219 | #if defined(CONFIG_DTB_RESELECT) |
220 | int embedded_dtb_select(void); | |
221 | #endif | |
222 | ||
11f86cba PD |
223 | /* common/init/board_init.c */ |
224 | extern ulong monitor_flash_len; | |
225 | ||
226 | /** | |
227 | * ulong board_init_f_alloc_reserve - allocate reserved area | |
dc145a7b | 228 | * @top: top of the reserve area, growing down. |
11f86cba PD |
229 | * |
230 | * This function is called by each architecture very early in the start-up | |
231 | * code to allow the C runtime to reserve space on the stack for writable | |
232 | * 'globals' such as GD and the malloc arena. | |
233 | * | |
dc145a7b | 234 | * Return: bottom of reserved area |
11f86cba PD |
235 | */ |
236 | ulong board_init_f_alloc_reserve(ulong top); | |
237 | ||
238 | /** | |
239 | * board_init_f_init_reserve - initialize the reserved area(s) | |
dc145a7b | 240 | * @base: top from which reservation was done |
11f86cba PD |
241 | * |
242 | * This function is called once the C runtime has allocated the reserved | |
243 | * area on the stack. It must initialize the GD at the base of that area. | |
11f86cba PD |
244 | */ |
245 | void board_init_f_init_reserve(ulong base); | |
246 | ||
67c4e9f8 SG |
247 | struct global_data; |
248 | ||
11f86cba PD |
249 | /** |
250 | * arch_setup_gd() - Set up the global_data pointer | |
dc145a7b | 251 | * @gd_ptr: Pointer to global data |
11f86cba PD |
252 | * |
253 | * This pointer is special in some architectures and cannot easily be assigned | |
254 | * to. For example on x86 it is implemented by adding a specific record to its | |
255 | * Global Descriptor Table! So we we provide a function to carry out this task. | |
256 | * For most architectures this can simply be: | |
257 | * | |
258 | * gd = gd_ptr; | |
11f86cba | 259 | */ |
67c4e9f8 | 260 | void arch_setup_gd(struct global_data *gd_ptr); |
11f86cba | 261 | |
dafa84d2 | 262 | /* common/board_r.c */ |
67c4e9f8 SG |
263 | void board_init_r(struct global_data *id, ulong dest_addr) |
264 | __attribute__ ((noreturn)); | |
e2c219cd PD |
265 | |
266 | int cpu_init_r(void); | |
267 | int last_stage_init(void); | |
268 | int mac_read_from_eeprom(void); | |
269 | int set_cpu_clk_info(void); | |
270 | int update_flash_size(int flash_size); | |
271 | int arch_early_init_r(void); | |
e2c219cd PD |
272 | int misc_init_r(void); |
273 | #if defined(CONFIG_VID) | |
274 | int init_func_vid(void); | |
275 | #endif | |
276 | ||
fc22ee21 PD |
277 | /* common/board_info.c */ |
278 | int checkboard(void); | |
279 | int show_board_info(void); | |
dafa84d2 | 280 | |
67c4e9f8 SG |
281 | /** |
282 | * Get the uppermost pointer that is valid to access | |
283 | * | |
284 | * Some systems may not map all of their address space. This function allows | |
285 | * boards to indicate what their highest support pointer value is for DRAM | |
286 | * access. | |
287 | * | |
288 | * @param total_size Size of U-Boot (unused?) | |
289 | */ | |
290 | ulong board_get_usable_ram_top(ulong total_size); | |
291 | ||
5255932f SG |
292 | int board_early_init_f(void); |
293 | ||
294 | /* manipulate the U-Boot fdt before its relocation */ | |
295 | int board_fix_fdt(void *rw_fdt_blob); | |
296 | int board_late_init(void); | |
297 | int board_postclk_init(void); /* after clocks/timebase, before env/serial */ | |
298 | int board_early_init_r(void); | |
299 | ||
2cf431c2 SG |
300 | /* TODO([email protected]): Drop this when DM_PCI migration is completed */ |
301 | void pci_init_board(void); | |
302 | ||
130845ba OP |
303 | /** |
304 | * arch_initr_trap() - Init traps | |
305 | * | |
306 | * Arch specific routine for initializing traps. It is called during the | |
307 | * generic board init sequence, after relocation. | |
308 | * | |
309 | * Return: 0 if OK | |
310 | */ | |
311 | int arch_initr_trap(void); | |
d67bdaa7 | 312 | |
6b8d3cea SG |
313 | /** |
314 | * main_loop() - Enter the main loop of U-Boot | |
315 | * | |
316 | * This normally runs the command line. | |
317 | */ | |
318 | void main_loop(void); | |
319 | ||
94133872 SG |
320 | #if defined(CONFIG_ARM) |
321 | void relocate_code(ulong addr_moni); | |
322 | #else | |
323 | void relocate_code(ulong start_addr_sp, struct global_data *new_gd, | |
324 | ulong relocaddr) | |
325 | __attribute__ ((noreturn)); | |
326 | #endif | |
327 | ||
655f17ff | 328 | /* Print a numeric value (for use in arch_print_bdinfo()) */ |
98592c75 BM |
329 | void bdinfo_print_num_l(const char *name, ulong value); |
330 | void bdinfo_print_num_ll(const char *name, unsigned long long value); | |
655f17ff SG |
331 | |
332 | /* Print a clock speed in MHz */ | |
333 | void bdinfo_print_mhz(const char *name, unsigned long hz); | |
334 | ||
59b0d7d8 SG |
335 | /* Show arch-specific information for the 'bd' command */ |
336 | void arch_print_bdinfo(void); | |
337 | ||
dafa84d2 PD |
338 | #endif /* __ASSEMBLY__ */ |
339 | /* Put only stuff here that the assembler can digest */ | |
340 | ||
341 | #endif /* __INIT_H_ */ |