1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Copy the startup prototype, previously defined in common.h
7 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
13 #ifndef __ASSEMBLY__ /* put C only stuff in this section */
15 #include <linux/types.h>
18 * In case of the EFI app the UEFI firmware provides the low-level
22 #define ll_boot_init() false
24 #include <asm/global_data.h>
26 #define ll_boot_init() (!(gd->flags & GD_FLG_SKIP_LL_INIT))
33 /* common/board_f.c */
34 void board_init_f(ulong dummy);
37 * arch_cpu_init() - basic cpu-dependent setup for an architecture
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.
44 * Return: 0 on success, otherwise error
46 int arch_cpu_init(void);
49 * mach_cpu_init() - SoC/machine dependent CPU setup
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.
56 * Return: 0 on success, otherwise error
58 int mach_cpu_init(void);
61 * arch_fsp_init() - perform firmware support package init
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
69 int arch_fsp_init(void);
72 * arch_fsp_init() - perform post-relocation firmware support package init
74 * Where U-Boot relies on binary blobs to handle part of the system init, this
75 * function can be used to set up the blobs. This is used on some Intel
80 int arch_fsp_init_r(void);
85 * dram_init_banksize() - Set up DRAM bank sizes
87 * This can be implemented by boards to set up the DRAM bank information in
88 * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
91 * If this is not provided, a default implementation will try to set up a
92 * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
93 * CFG_SYS_SDRAM_BASE are set. The bank will have a start address of
94 * CFG_SYS_SDRAM_BASE and the size will be determined by a call to
95 * get_effective_memsize().
97 * Return: 0 if OK, -ve on error
99 int dram_init_banksize(void);
101 long get_ram_size(long *base, long size);
102 phys_size_t get_effective_memsize(void);
107 * arch_setup_dest_addr() - Fix up initial reloc address
109 * This is called in generic board init sequence in common/board_f.c at the end
110 * of the setup_dest_addr() initcall. Each architecture could provide this
111 * function to make adjustments to the initial reloc address.
113 * If an implementation is not provided, it will just be a nop stub.
117 int arch_setup_dest_addr(void);
120 * arch_reserve_stacks() - Reserve all necessary stacks
122 * This is used in generic board init sequence in common/board_f.c. Each
123 * architecture could provide this function to tailor the required stacks.
125 * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
126 * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
127 * require only this can leave it untouched.
129 * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
130 * positions of the stack. The stack pointer(s) will be set to this later.
131 * gd->irq_sp is only required, if the architecture needs it.
133 * Return: 0 if no error
135 int arch_reserve_stacks(void);
138 * arch_reserve_mmu() - Reserve memory for MMU TLB table
140 * Architecture-specific routine for reserving memory for the MMU TLB table.
141 * This is used in generic board init sequence in common/board_f.c.
143 * If an implementation is not provided, it will just be a nop stub.
147 int arch_reserve_mmu(void);
150 * arch_setup_bdinfo() - Architecture dependent boardinfo setup
152 * Architecture-specific routine for populating various boardinfo fields of
153 * gd->bd. It is called during the generic board init sequence.
155 * If an implementation is not provided, it will just be a nop stub.
159 int arch_setup_bdinfo(void);
162 * setup_bdinfo() - Generic boardinfo setup
164 * Routine for populating various generic boardinfo fields of
165 * gd->bd. It is called during the generic board init sequence.
169 int setup_bdinfo(void);
171 #if defined(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) || \
172 defined(CONFIG_SAVE_PREV_BL_FDT_ADDR)
174 * save_prev_bl_data - Save prev bl data in env vars.
176 * When u-boot is chain-loaded, save previous bootloader data,
177 * like initramfs address to environment variables.
179 * Return: 0 if ok; -ENODATA on error
181 int save_prev_bl_data(void);
185 * cpu_secondary_init_r() - CPU-specific secondary initialization
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.
192 * It is called during the generic post-relocation init sequence.
196 int cpu_secondary_init_r(void);
199 * pci_ep_init() - Initialize pci endpoint devices
201 * It is called during the generic post-relocation init sequence.
205 int pci_ep_init(void);
208 * pci_init() - Enumerate pci devices
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
220 * init_cache_f_r() - Turn on the cache in preparation for relocation
222 * Return: 0 if OK, -ve on error
224 int init_cache_f_r(void);
226 #if !CONFIG_IS_ENABLED(CPU)
228 * print_cpuinfo() - Display information about the CPU
230 * Return: 0 if OK, -ve on error
232 int print_cpuinfo(void);
234 int timer_init(void);
236 #if defined(CONFIG_DTB_RESELECT)
237 int embedded_dtb_select(void);
240 /* common/init/board_init.c */
241 extern ulong monitor_flash_len;
244 * ulong board_init_f_alloc_reserve - allocate reserved area
245 * @top: top of the reserve area, growing down.
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.
251 * Return: bottom of reserved area
253 ulong board_init_f_alloc_reserve(ulong top);
256 * board_init_f_init_reserve - initialize the reserved area(s)
257 * @base: top from which reservation was done
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.
262 void board_init_f_init_reserve(ulong base);
267 * arch_setup_gd() - Set up the global_data pointer
268 * @gd_ptr: Pointer to global data
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:
277 void arch_setup_gd(struct global_data *gd_ptr);
279 /* common/board_r.c */
280 void board_init_r(struct global_data *id, ulong dest_addr)
281 __attribute__ ((noreturn));
283 int cpu_init_r(void);
284 int last_stage_init(void);
285 int mac_read_from_eeprom(void);
286 int set_cpu_clk_info(void);
287 int update_flash_size(int flash_size);
288 int arch_early_init_r(void);
289 int misc_init_r(void);
290 #if defined(CONFIG_VID)
291 int init_func_vid(void);
294 /* common/board_info.c */
295 int checkboard(void);
296 int show_board_info(void);
299 * Get the uppermost pointer that is valid to access
301 * Some systems may not map all of their address space. This function allows
302 * boards to indicate what their highest support pointer value is for DRAM
305 * @param total_size Size of U-Boot (unused?)
307 phys_size_t board_get_usable_ram_top(phys_size_t total_size);
309 int board_early_init_f(void);
311 /* manipulate the U-Boot fdt before its relocation */
312 int board_fix_fdt(void *rw_fdt_blob);
313 int board_late_init(void);
314 int board_postclk_init(void); /* after clocks/timebase, before env/serial */
315 int board_early_init_r(void);
318 * arch_initr_trap() - Init traps
320 * Arch specific routine for initializing traps. It is called during the
321 * generic board init sequence, after relocation.
325 int arch_initr_trap(void);
330 * Initialize non-identity virtual-physical memory mappings for 32bit CPUs.
331 * It is called during the generic board init sequence, after relocation.
335 int init_addr_map(void);
338 * main_loop() - Enter the main loop of U-Boot
340 * This normally runs the command line.
342 void main_loop(void);
344 #if defined(CONFIG_ARM)
345 void relocate_code(ulong addr_moni);
347 void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
349 __attribute__ ((noreturn));
352 /* Print a numeric value (for use in arch_print_bdinfo()) */
353 void bdinfo_print_num_l(const char *name, ulong value);
354 void bdinfo_print_num_ll(const char *name, unsigned long long value);
356 /* Print a string value (for use in arch_print_bdinfo()) */
357 void bdinfo_print_str(const char *name, const char *str);
359 /* Print a clock speed in MHz */
360 void bdinfo_print_mhz(const char *name, unsigned long hz);
363 * bdinfo_print_size - print size variables in bdinfo format
364 * @name: string to print before the size
365 * @size: size to print
367 * Helper function for displaying size variables as properly formatted bdinfo
368 * entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
369 * "xxx GiB", etc. as needed;
371 * For use in arch_print_bdinfo().
373 void bdinfo_print_size(const char *name, uint64_t size);
375 /* Show arch-specific information for the 'bd' command */
376 void arch_print_bdinfo(void);
378 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
380 #endif /* __ASSEMBLY__ */
381 /* Put only stuff here that the assembler can digest */
383 #endif /* __INIT_H_ */