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 #include <linux/types.h>
17 #ifndef __ASSEMBLY__ /* put C only stuff in this section */
19 /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
20 #ifdef CONFIG_EFI_STUB
21 #define ll_boot_init() false
23 #define ll_boot_init() (!(gd->flags & GD_FLG_SKIP_LL_INIT))
30 /* common/board_f.c */
31 void board_init_f(ulong dummy);
34 * arch_cpu_init() - basic cpu-dependent setup for an architecture
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.
41 * Return: 0 on success, otherwise error
43 int arch_cpu_init(void);
46 * arch_cpu_init_dm() - init CPU after driver model is available
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
52 * Return: 0 if OK, -ve on error
54 int arch_cpu_init_dm(void);
57 * mach_cpu_init() - SoC/machine dependent CPU setup
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.
64 * Return: 0 on success, otherwise error
66 int mach_cpu_init(void);
69 * arch_fsp_init() - perform firmware support package init
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
77 int arch_fsp_init(void);
80 * arch_fsp_init() - perform post-relocation firmware support package init
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
88 int arch_fsp_init_r(void);
93 * dram_init_banksize() - Set up DRAM bank sizes
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()
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().
105 * Return: 0 if OK, -ve on error
107 int dram_init_banksize(void);
109 long get_ram_size(long *base, long size);
110 phys_size_t get_effective_memsize(void);
115 * arch_reserve_stacks() - Reserve all necessary stacks
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.
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.
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.
128 * Return: 0 if no error
130 int arch_reserve_stacks(void);
133 * arch_reserve_mmu() - Reserve memory for MMU TLB table
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.
138 * If an implementation is not provided, it will just be a nop stub.
142 int arch_reserve_mmu(void);
145 * arch_setup_bdinfo() - Architecture dependent boardinfo setup
147 * Architecture-specific routine for populating various boardinfo fields of
148 * gd->bd. It is called during the generic board init sequence.
150 * If an implementation is not provided, it will just be a nop stub.
154 int arch_setup_bdinfo(void);
157 * setup_bdinfo() - Generic boardinfo setup
159 * Routine for populating various generic boardinfo fields of
160 * gd->bd. It is called during the generic board init sequence.
164 int setup_bdinfo(void);
167 * cpu_secondary_init_r() - CPU-specific secondary initialization
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.
174 * It is called during the generic post-relocation init sequence.
178 int cpu_secondary_init_r(void);
181 * init_cache_f_r() - Turn on the cache in preparation for relocation
183 * Return: 0 if OK, -ve on error
185 int init_cache_f_r(void);
187 #if !CONFIG_IS_ENABLED(CPU)
189 * print_cpuinfo() - Display information about the CPU
191 * Return: 0 if OK, -ve on error
193 int print_cpuinfo(void);
195 int timer_init(void);
196 int misc_init_f(void);
198 #if defined(CONFIG_DTB_RESELECT)
199 int embedded_dtb_select(void);
202 /* common/init/board_init.c */
203 extern ulong monitor_flash_len;
206 * ulong board_init_f_alloc_reserve - allocate reserved area
207 * @top: top of the reserve area, growing down.
209 * This function is called by each architecture very early in the start-up
210 * code to allow the C runtime to reserve space on the stack for writable
211 * 'globals' such as GD and the malloc arena.
213 * Return: bottom of reserved area
215 ulong board_init_f_alloc_reserve(ulong top);
218 * board_init_f_init_reserve - initialize the reserved area(s)
219 * @base: top from which reservation was done
221 * This function is called once the C runtime has allocated the reserved
222 * area on the stack. It must initialize the GD at the base of that area.
224 void board_init_f_init_reserve(ulong base);
229 * arch_setup_gd() - Set up the global_data pointer
230 * @gd_ptr: Pointer to global data
232 * This pointer is special in some architectures and cannot easily be assigned
233 * to. For example on x86 it is implemented by adding a specific record to its
234 * Global Descriptor Table! So we we provide a function to carry out this task.
235 * For most architectures this can simply be:
239 void arch_setup_gd(struct global_data *gd_ptr);
241 /* common/board_r.c */
242 void board_init_r(struct global_data *id, ulong dest_addr)
243 __attribute__ ((noreturn));
245 int cpu_init_r(void);
246 int last_stage_init(void);
247 int mac_read_from_eeprom(void);
248 int set_cpu_clk_info(void);
249 int update_flash_size(int flash_size);
250 int arch_early_init_r(void);
252 void pci_ep_init(void);
253 int misc_init_r(void);
254 #if defined(CONFIG_VID)
255 int init_func_vid(void);
258 /* common/board_info.c */
259 int checkboard(void);
260 int show_board_info(void);
263 * Get the uppermost pointer that is valid to access
265 * Some systems may not map all of their address space. This function allows
266 * boards to indicate what their highest support pointer value is for DRAM
269 * @param total_size Size of U-Boot (unused?)
271 ulong board_get_usable_ram_top(ulong total_size);
273 int board_early_init_f(void);
275 /* manipulate the U-Boot fdt before its relocation */
276 int board_fix_fdt(void *rw_fdt_blob);
277 int board_late_init(void);
278 int board_postclk_init(void); /* after clocks/timebase, before env/serial */
279 int board_early_init_r(void);
281 /* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */
282 void pci_init_board(void);
284 void trap_init(unsigned long reloc_addr);
287 * main_loop() - Enter the main loop of U-Boot
289 * This normally runs the command line.
291 void main_loop(void);
293 #if defined(CONFIG_ARM)
294 void relocate_code(ulong addr_moni);
296 void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
298 __attribute__ ((noreturn));
301 /* Print a numeric value (for use in arch_print_bdinfo()) */
302 void bdinfo_print_num(const char *name, ulong value);
304 /* Print a clock speed in MHz */
305 void bdinfo_print_mhz(const char *name, unsigned long hz);
307 /* Show arch-specific information for the 'bd' command */
308 void arch_print_bdinfo(void);
310 #endif /* __ASSEMBLY__ */
311 /* Put only stuff here that the assembler can digest */
313 #endif /* __INIT_H_ */