]>
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 | ||
90794864 SG |
17 | /* |
18 | * In case of the EFI app the UEFI firmware provides the low-level | |
19 | * initialisation. | |
20 | */ | |
21 | #ifdef CONFIG_EFI | |
35a3f871 SG |
22 | #define ll_boot_init() false |
23 | #else | |
401d1c4f SG |
24 | #include <asm/global_data.h> |
25 | ||
ba974a01 | 26 | #define ll_boot_init() (!(gd->flags & GD_FLG_SKIP_LL_INIT)) |
35a3f871 SG |
27 | #endif |
28 | ||
dafa84d2 PD |
29 | /* |
30 | * Function Prototypes | |
31 | */ | |
32 | ||
33 | /* common/board_f.c */ | |
d6f87712 | 34 | void board_init_f(ulong dummy); |
dafa84d2 PD |
35 | |
36 | /** | |
37 | * arch_cpu_init() - basic cpu-dependent setup for an architecture | |
38 | * | |
39 | * This is called after early malloc is available. It should handle any | |
40 | * CPU- or SoC- specific init needed to continue the init sequence. See | |
41 | * board_f.c for where it is called. If this is not provided, a default | |
42 | * version (which does nothing) will be used. | |
43 | * | |
dc145a7b | 44 | * Return: 0 on success, otherwise error |
dafa84d2 PD |
45 | */ |
46 | int arch_cpu_init(void); | |
47 | ||
48 | /** | |
49 | * mach_cpu_init() - SoC/machine dependent CPU setup | |
50 | * | |
51 | * This is called after arch_cpu_init(). It should handle any | |
52 | * SoC or machine specific init needed to continue the init sequence. See | |
53 | * board_f.c for where it is called. If this is not provided, a default | |
54 | * version (which does nothing) will be used. | |
55 | * | |
dc145a7b | 56 | * Return: 0 on success, otherwise error |
dafa84d2 PD |
57 | */ |
58 | int mach_cpu_init(void); | |
59 | ||
fe08d39d SG |
60 | /** |
61 | * arch_fsp_init() - perform post-relocation firmware support package init | |
62 | * | |
63 | * Where U-Boot relies on binary blobs to handle part of the system init, this | |
64 | * function can be used to set up the blobs. This is used on some Intel | |
65 | * platforms. | |
66 | * | |
67 | * Return: 0 | |
68 | */ | |
69 | int arch_fsp_init_r(void); | |
70 | ||
d6f87712 PD |
71 | int dram_init(void); |
72 | ||
73 | /** | |
74 | * dram_init_banksize() - Set up DRAM bank sizes | |
75 | * | |
76 | * This can be implemented by boards to set up the DRAM bank information in | |
77 | * gd->bd->bi_dram(). It is called just before relocation, after dram_init() | |
78 | * is called. | |
79 | * | |
80 | * If this is not provided, a default implementation will try to set up a | |
81 | * single bank. It will do this if CONFIG_NR_DRAM_BANKS and | |
aa6e94de TR |
82 | * CFG_SYS_SDRAM_BASE are set. The bank will have a start address of |
83 | * CFG_SYS_SDRAM_BASE and the size will be determined by a call to | |
d6f87712 PD |
84 | * get_effective_memsize(). |
85 | * | |
dc145a7b | 86 | * Return: 0 if OK, -ve on error |
d6f87712 PD |
87 | */ |
88 | int dram_init_banksize(void); | |
89 | ||
9b4a205f SG |
90 | long get_ram_size(long *base, long size); |
91 | phys_size_t get_effective_memsize(void); | |
92 | ||
49acd56e SG |
93 | int testdram(void); |
94 | ||
d63fc994 OP |
95 | /** |
96 | * arch_setup_dest_addr() - Fix up initial reloc address | |
97 | * | |
98 | * This is called in generic board init sequence in common/board_f.c at the end | |
99 | * of the setup_dest_addr() initcall. Each architecture could provide this | |
100 | * function to make adjustments to the initial reloc address. | |
101 | * | |
102 | * If an implementation is not provided, it will just be a nop stub. | |
103 | * | |
104 | * Return: 0 if OK | |
105 | */ | |
106 | int arch_setup_dest_addr(void); | |
107 | ||
d6f87712 | 108 | /** |
dc145a7b | 109 | * arch_reserve_stacks() - Reserve all necessary stacks |
d6f87712 PD |
110 | * |
111 | * This is used in generic board init sequence in common/board_f.c. Each | |
112 | * architecture could provide this function to tailor the required stacks. | |
113 | * | |
114 | * On entry gd->start_addr_sp is pointing to the suggested top of the stack. | |
115 | * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures | |
116 | * require only this can leave it untouched. | |
117 | * | |
118 | * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective | |
119 | * positions of the stack. The stack pointer(s) will be set to this later. | |
120 | * gd->irq_sp is only required, if the architecture needs it. | |
121 | * | |
dc145a7b | 122 | * Return: 0 if no error |
d6f87712 PD |
123 | */ |
124 | int arch_reserve_stacks(void); | |
125 | ||
79926e4f OP |
126 | /** |
127 | * arch_reserve_mmu() - Reserve memory for MMU TLB table | |
128 | * | |
129 | * Architecture-specific routine for reserving memory for the MMU TLB table. | |
130 | * This is used in generic board init sequence in common/board_f.c. | |
131 | * | |
132 | * If an implementation is not provided, it will just be a nop stub. | |
133 | * | |
134 | * Return: 0 if OK | |
135 | */ | |
136 | int arch_reserve_mmu(void); | |
137 | ||
81e7cb1e OP |
138 | /** |
139 | * arch_setup_bdinfo() - Architecture dependent boardinfo setup | |
140 | * | |
141 | * Architecture-specific routine for populating various boardinfo fields of | |
142 | * gd->bd. It is called during the generic board init sequence. | |
143 | * | |
144 | * If an implementation is not provided, it will just be a nop stub. | |
145 | * | |
146 | * Return: 0 if OK | |
147 | */ | |
148 | int arch_setup_bdinfo(void); | |
149 | ||
ba743103 OP |
150 | /** |
151 | * setup_bdinfo() - Generic boardinfo setup | |
152 | * | |
153 | * Routine for populating various generic boardinfo fields of | |
154 | * gd->bd. It is called during the generic board init sequence. | |
155 | * | |
156 | * Return: 0 if OK | |
157 | */ | |
158 | int setup_bdinfo(void); | |
159 | ||
12a3e1ad DS |
160 | #if defined(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) || \ |
161 | defined(CONFIG_SAVE_PREV_BL_FDT_ADDR) | |
162 | /** | |
163 | * save_prev_bl_data - Save prev bl data in env vars. | |
164 | * | |
165 | * When u-boot is chain-loaded, save previous bootloader data, | |
166 | * like initramfs address to environment variables. | |
167 | * | |
168 | * Return: 0 if ok; -ENODATA on error | |
169 | */ | |
170 | int save_prev_bl_data(void); | |
ca84ba63 CC |
171 | |
172 | /** | |
173 | * get_prev_bl_fdt_addr - When u-boot is chainloaded, get the address | |
174 | * of the FDT passed by the previous bootloader. | |
175 | * | |
176 | * Return: the address of the FDT passed by the previous bootloader | |
177 | * or 0 if not found. | |
178 | */ | |
179 | phys_addr_t get_prev_bl_fdt_addr(void); | |
180 | #else | |
181 | #define get_prev_bl_fdt_addr() 0LLU | |
12a3e1ad DS |
182 | #endif |
183 | ||
fb504b2c OP |
184 | /** |
185 | * cpu_secondary_init_r() - CPU-specific secondary initialization | |
186 | * | |
187 | * After non-volatile devices, environment and cpu code are setup, have | |
188 | * another round to deal with any initialization that might require | |
189 | * full access to the environment or loading of some image (firmware) | |
190 | * from a non-volatile device. | |
191 | * | |
192 | * It is called during the generic post-relocation init sequence. | |
193 | * | |
194 | * Return: 0 if OK | |
195 | */ | |
196 | int cpu_secondary_init_r(void); | |
197 | ||
c343e8c0 OP |
198 | /** |
199 | * pci_ep_init() - Initialize pci endpoint devices | |
200 | * | |
201 | * It is called during the generic post-relocation init sequence. | |
202 | * | |
203 | * Return: 0 if OK | |
204 | */ | |
205 | int pci_ep_init(void); | |
206 | ||
b9f6d0f7 OP |
207 | /** |
208 | * pci_init() - Enumerate pci devices | |
209 | * | |
210 | * It is called during the generic post-relocation init sequence to enumerate | |
211 | * pci buses. This is needed, for instance, in the case of DM PCI-based | |
212 | * Ethernet devices, which will not be detected without having the enumeration | |
213 | * performed earlier. | |
214 | * | |
215 | * Return: 0 if OK | |
216 | */ | |
217 | int pci_init(void); | |
218 | ||
b8aa55cb PD |
219 | /** |
220 | * init_cache_f_r() - Turn on the cache in preparation for relocation | |
221 | * | |
dc145a7b | 222 | * Return: 0 if OK, -ve on error |
b8aa55cb PD |
223 | */ |
224 | int init_cache_f_r(void); | |
225 | ||
5d6c61ac MS |
226 | #if !CONFIG_IS_ENABLED(CPU) |
227 | /** | |
228 | * print_cpuinfo() - Display information about the CPU | |
229 | * | |
230 | * Return: 0 if OK, -ve on error | |
231 | */ | |
d6f87712 | 232 | int print_cpuinfo(void); |
5d6c61ac | 233 | #endif |
d6f87712 | 234 | int timer_init(void); |
dc145a7b | 235 | |
d6f87712 PD |
236 | #if defined(CONFIG_DTB_RESELECT) |
237 | int embedded_dtb_select(void); | |
238 | #endif | |
239 | ||
11f86cba PD |
240 | /* common/init/board_init.c */ |
241 | extern ulong monitor_flash_len; | |
242 | ||
243 | /** | |
244 | * ulong board_init_f_alloc_reserve - allocate reserved area | |
dc145a7b | 245 | * @top: top of the reserve area, growing down. |
11f86cba PD |
246 | * |
247 | * This function is called by each architecture very early in the start-up | |
248 | * code to allow the C runtime to reserve space on the stack for writable | |
249 | * 'globals' such as GD and the malloc arena. | |
250 | * | |
dc145a7b | 251 | * Return: bottom of reserved area |
11f86cba PD |
252 | */ |
253 | ulong board_init_f_alloc_reserve(ulong top); | |
254 | ||
255 | /** | |
256 | * board_init_f_init_reserve - initialize the reserved area(s) | |
dc145a7b | 257 | * @base: top from which reservation was done |
11f86cba PD |
258 | * |
259 | * This function is called once the C runtime has allocated the reserved | |
260 | * area on the stack. It must initialize the GD at the base of that area. | |
11f86cba PD |
261 | */ |
262 | void board_init_f_init_reserve(ulong base); | |
263 | ||
67c4e9f8 SG |
264 | struct global_data; |
265 | ||
11f86cba PD |
266 | /** |
267 | * arch_setup_gd() - Set up the global_data pointer | |
dc145a7b | 268 | * @gd_ptr: Pointer to global data |
11f86cba PD |
269 | * |
270 | * This pointer is special in some architectures and cannot easily be assigned | |
271 | * to. For example on x86 it is implemented by adding a specific record to its | |
272 | * Global Descriptor Table! So we we provide a function to carry out this task. | |
273 | * For most architectures this can simply be: | |
274 | * | |
275 | * gd = gd_ptr; | |
11f86cba | 276 | */ |
67c4e9f8 | 277 | void arch_setup_gd(struct global_data *gd_ptr); |
11f86cba | 278 | |
dafa84d2 | 279 | /* common/board_r.c */ |
67c4e9f8 SG |
280 | void board_init_r(struct global_data *id, ulong dest_addr) |
281 | __attribute__ ((noreturn)); | |
e2c219cd PD |
282 | |
283 | int cpu_init_r(void); | |
e2c219cd | 284 | int mac_read_from_eeprom(void); |
cd3dbb56 AR |
285 | |
286 | /** | |
287 | * serial_read_from_eeprom - read the serial number from EEPROM | |
288 | * | |
289 | * This function reads the serial number from the EEPROM and sets the | |
290 | * appropriate environment variable. | |
291 | * | |
292 | * The environment variable is only set if it has not been set | |
293 | * already. This ensures that any user-saved variables are never | |
294 | * overwritten. | |
295 | * | |
296 | * This function must be called after relocation. | |
297 | */ | |
298 | int serial_read_from_eeprom(int devnum); | |
e2c219cd PD |
299 | int set_cpu_clk_info(void); |
300 | int update_flash_size(int flash_size); | |
301 | int arch_early_init_r(void); | |
e2c219cd | 302 | int misc_init_r(void); |
e2c219cd | 303 | |
fc22ee21 PD |
304 | /* common/board_info.c */ |
305 | int checkboard(void); | |
ef211ab2 SG |
306 | |
307 | /** | |
308 | * show_board_info() - Show board information | |
309 | * | |
310 | * Check sysinfo for board information. Failing that if the root node of the DTB | |
311 | * has a "model" property, show it. | |
312 | * | |
313 | * Then call checkboard(). | |
314 | * | |
315 | * Return 0 if OK, -ve on error | |
316 | */ | |
fc22ee21 | 317 | int show_board_info(void); |
dafa84d2 | 318 | |
67c4e9f8 | 319 | /** |
289bd72e | 320 | * board_get_usable_ram_top() - get uppermost address for U-Boot relocation |
67c4e9f8 | 321 | * |
289bd72e HS |
322 | * Some systems have reserved memory areas in high memory. By implementing this |
323 | * function boards can indicate the highest address value to be used when | |
324 | * relocating U-Boot. The returned address is exclusive (i.e. 1 byte above the | |
325 | * last usable address). | |
67c4e9f8 | 326 | * |
289bd72e HS |
327 | * Due to overflow on systems with 32bit phys_addr_t a value 0 is used instead |
328 | * of 4GiB. | |
329 | * | |
330 | * @total_size: monitor length in bytes (size of U-Boot code) | |
331 | * Return: uppermost address for U-Boot relocation | |
67c4e9f8 | 332 | */ |
d768dd88 | 333 | phys_addr_t board_get_usable_ram_top(phys_size_t total_size); |
67c4e9f8 | 334 | |
5255932f SG |
335 | int board_early_init_f(void); |
336 | ||
337 | /* manipulate the U-Boot fdt before its relocation */ | |
338 | int board_fix_fdt(void *rw_fdt_blob); | |
339 | int board_late_init(void); | |
340 | int board_postclk_init(void); /* after clocks/timebase, before env/serial */ | |
341 | int board_early_init_r(void); | |
342 | ||
130845ba OP |
343 | /** |
344 | * arch_initr_trap() - Init traps | |
345 | * | |
346 | * Arch specific routine for initializing traps. It is called during the | |
347 | * generic board init sequence, after relocation. | |
348 | * | |
349 | * Return: 0 if OK | |
350 | */ | |
351 | int arch_initr_trap(void); | |
d67bdaa7 | 352 | |
2fd81be1 OP |
353 | /** |
354 | * init_addr_map() | |
355 | * | |
356 | * Initialize non-identity virtual-physical memory mappings for 32bit CPUs. | |
357 | * It is called during the generic board init sequence, after relocation. | |
358 | * | |
359 | * Return: 0 if OK | |
360 | */ | |
361 | int init_addr_map(void); | |
362 | ||
6b8d3cea SG |
363 | /** |
364 | * main_loop() - Enter the main loop of U-Boot | |
365 | * | |
366 | * This normally runs the command line. | |
367 | */ | |
368 | void main_loop(void); | |
369 | ||
94133872 SG |
370 | #if defined(CONFIG_ARM) |
371 | void relocate_code(ulong addr_moni); | |
372 | #else | |
373 | void relocate_code(ulong start_addr_sp, struct global_data *new_gd, | |
374 | ulong relocaddr) | |
375 | __attribute__ ((noreturn)); | |
376 | #endif | |
377 | ||
655f17ff | 378 | /* Print a numeric value (for use in arch_print_bdinfo()) */ |
98592c75 BM |
379 | void bdinfo_print_num_l(const char *name, ulong value); |
380 | void bdinfo_print_num_ll(const char *name, unsigned long long value); | |
655f17ff | 381 | |
40b8afe6 SG |
382 | /* Print a string value (for use in arch_print_bdinfo()) */ |
383 | void bdinfo_print_str(const char *name, const char *str); | |
384 | ||
655f17ff SG |
385 | /* Print a clock speed in MHz */ |
386 | void bdinfo_print_mhz(const char *name, unsigned long hz); | |
387 | ||
ae90d16a OP |
388 | /** |
389 | * bdinfo_print_size - print size variables in bdinfo format | |
390 | * @name: string to print before the size | |
391 | * @size: size to print | |
392 | * | |
393 | * Helper function for displaying size variables as properly formatted bdinfo | |
394 | * entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB", | |
395 | * "xxx GiB", etc. as needed; | |
396 | * | |
397 | * For use in arch_print_bdinfo(). | |
398 | */ | |
399 | void bdinfo_print_size(const char *name, uint64_t size); | |
400 | ||
59b0d7d8 SG |
401 | /* Show arch-specific information for the 'bd' command */ |
402 | void arch_print_bdinfo(void); | |
403 | ||
4b32531b AS |
404 | int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); |
405 | ||
dafa84d2 PD |
406 | #endif /* __ASSEMBLY__ */ |
407 | /* Put only stuff here that the assembler can digest */ | |
408 | ||
409 | #endif /* __INIT_H_ */ |