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 * arch_cpu_init_dm() - init CPU after driver model is available
51 * This is called immediately after driver model is available before
52 * relocation. This is similar to arch_cpu_init() but is able to reference
55 * Return: 0 if OK, -ve on error
57 int arch_cpu_init_dm(void);
60 * mach_cpu_init() - SoC/machine dependent CPU setup
62 * This is called after arch_cpu_init(). It should handle any
63 * SoC or machine specific init needed to continue the init sequence. See
64 * board_f.c for where it is called. If this is not provided, a default
65 * version (which does nothing) will be used.
67 * Return: 0 on success, otherwise error
69 int mach_cpu_init(void);
72 * arch_fsp_init() - perform 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(void);
83 * arch_fsp_init() - perform post-relocation firmware support package init
85 * Where U-Boot relies on binary blobs to handle part of the system init, this
86 * function can be used to set up the blobs. This is used on some Intel
91 int arch_fsp_init_r(void);
96 * dram_init_banksize() - Set up DRAM bank sizes
98 * This can be implemented by boards to set up the DRAM bank information in
99 * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
102 * If this is not provided, a default implementation will try to set up a
103 * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
104 * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of
105 * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to
106 * get_effective_memsize().
108 * Return: 0 if OK, -ve on error
110 int dram_init_banksize(void);
112 long get_ram_size(long *base, long size);
113 phys_size_t get_effective_memsize(void);
118 * arch_reserve_stacks() - Reserve all necessary stacks
120 * This is used in generic board init sequence in common/board_f.c. Each
121 * architecture could provide this function to tailor the required stacks.
123 * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
124 * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
125 * require only this can leave it untouched.
127 * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
128 * positions of the stack. The stack pointer(s) will be set to this later.
129 * gd->irq_sp is only required, if the architecture needs it.
131 * Return: 0 if no error
133 int arch_reserve_stacks(void);
136 * arch_reserve_mmu() - Reserve memory for MMU TLB table
138 * Architecture-specific routine for reserving memory for the MMU TLB table.
139 * This is used in generic board init sequence in common/board_f.c.
141 * If an implementation is not provided, it will just be a nop stub.
145 int arch_reserve_mmu(void);
148 * arch_setup_bdinfo() - Architecture dependent boardinfo setup
150 * Architecture-specific routine for populating various boardinfo fields of
151 * gd->bd. It is called during the generic board init sequence.
153 * If an implementation is not provided, it will just be a nop stub.
157 int arch_setup_bdinfo(void);
160 * setup_bdinfo() - Generic boardinfo setup
162 * Routine for populating various generic boardinfo fields of
163 * gd->bd. It is called during the generic board init sequence.
167 int setup_bdinfo(void);
170 * cpu_secondary_init_r() - CPU-specific secondary initialization
172 * After non-volatile devices, environment and cpu code are setup, have
173 * another round to deal with any initialization that might require
174 * full access to the environment or loading of some image (firmware)
175 * from a non-volatile device.
177 * It is called during the generic post-relocation init sequence.
181 int cpu_secondary_init_r(void);
184 * pci_ep_init() - Initialize pci endpoint devices
186 * It is called during the generic post-relocation init sequence.
190 int pci_ep_init(void);
193 * pci_init() - Enumerate pci devices
195 * It is called during the generic post-relocation init sequence to enumerate
196 * pci buses. This is needed, for instance, in the case of DM PCI-based
197 * Ethernet devices, which will not be detected without having the enumeration
205 * init_cache_f_r() - Turn on the cache in preparation for relocation
207 * Return: 0 if OK, -ve on error
209 int init_cache_f_r(void);
211 #if !CONFIG_IS_ENABLED(CPU)
213 * print_cpuinfo() - Display information about the CPU
215 * Return: 0 if OK, -ve on error
217 int print_cpuinfo(void);
219 int timer_init(void);
220 int misc_init_f(void);
222 #if defined(CONFIG_DTB_RESELECT)
223 int embedded_dtb_select(void);
226 /* common/init/board_init.c */
227 extern ulong monitor_flash_len;
230 * ulong board_init_f_alloc_reserve - allocate reserved area
231 * @top: top of the reserve area, growing down.
233 * This function is called by each architecture very early in the start-up
234 * code to allow the C runtime to reserve space on the stack for writable
235 * 'globals' such as GD and the malloc arena.
237 * Return: bottom of reserved area
239 ulong board_init_f_alloc_reserve(ulong top);
242 * board_init_f_init_reserve - initialize the reserved area(s)
243 * @base: top from which reservation was done
245 * This function is called once the C runtime has allocated the reserved
246 * area on the stack. It must initialize the GD at the base of that area.
248 void board_init_f_init_reserve(ulong base);
253 * arch_setup_gd() - Set up the global_data pointer
254 * @gd_ptr: Pointer to global data
256 * This pointer is special in some architectures and cannot easily be assigned
257 * to. For example on x86 it is implemented by adding a specific record to its
258 * Global Descriptor Table! So we we provide a function to carry out this task.
259 * For most architectures this can simply be:
263 void arch_setup_gd(struct global_data *gd_ptr);
265 /* common/board_r.c */
266 void board_init_r(struct global_data *id, ulong dest_addr)
267 __attribute__ ((noreturn));
269 int cpu_init_r(void);
270 int last_stage_init(void);
271 int mac_read_from_eeprom(void);
272 int set_cpu_clk_info(void);
273 int update_flash_size(int flash_size);
274 int arch_early_init_r(void);
275 int misc_init_r(void);
276 #if defined(CONFIG_VID)
277 int init_func_vid(void);
280 /* common/board_info.c */
281 int checkboard(void);
282 int show_board_info(void);
285 * Get the uppermost pointer that is valid to access
287 * Some systems may not map all of their address space. This function allows
288 * boards to indicate what their highest support pointer value is for DRAM
291 * @param total_size Size of U-Boot (unused?)
293 ulong board_get_usable_ram_top(ulong total_size);
295 int board_early_init_f(void);
297 /* manipulate the U-Boot fdt before its relocation */
298 int board_fix_fdt(void *rw_fdt_blob);
299 int board_late_init(void);
300 int board_postclk_init(void); /* after clocks/timebase, before env/serial */
301 int board_early_init_r(void);
304 * arch_initr_trap() - Init traps
306 * Arch specific routine for initializing traps. It is called during the
307 * generic board init sequence, after relocation.
311 int arch_initr_trap(void);
316 * Initialize non-identity virtual-physical memory mappings for 32bit CPUs.
317 * It is called during the generic board init sequence, after relocation.
321 int init_addr_map(void);
324 * main_loop() - Enter the main loop of U-Boot
326 * This normally runs the command line.
328 void main_loop(void);
330 #if defined(CONFIG_ARM)
331 void relocate_code(ulong addr_moni);
333 void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
335 __attribute__ ((noreturn));
338 /* Print a numeric value (for use in arch_print_bdinfo()) */
339 void bdinfo_print_num_l(const char *name, ulong value);
340 void bdinfo_print_num_ll(const char *name, unsigned long long value);
342 /* Print a clock speed in MHz */
343 void bdinfo_print_mhz(const char *name, unsigned long hz);
345 /* Show arch-specific information for the 'bd' command */
346 void arch_print_bdinfo(void);
348 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
350 #endif /* __ASSEMBLY__ */
351 /* Put only stuff here that the assembler can digest */
353 #endif /* __INIT_H_ */