]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - include/init.h
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 post-relocation 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_r(void);
74 * dram_init_banksize() - Set up DRAM bank sizes
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()
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
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
84 * get_effective_memsize().
86 * Return: 0 if OK, -ve on error
88 int dram_init_banksize(void);
90 long get_ram_size(long *base
, long size
);
91 phys_size_t
get_effective_memsize(void);
96 * arch_setup_dest_addr() - Fix up initial reloc address
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.
102 * If an implementation is not provided, it will just be a nop stub.
106 int arch_setup_dest_addr(void);
109 * arch_reserve_stacks() - Reserve all necessary stacks
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.
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.
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.
122 * Return: 0 if no error
124 int arch_reserve_stacks(void);
127 * arch_reserve_mmu() - Reserve memory for MMU TLB table
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.
132 * If an implementation is not provided, it will just be a nop stub.
136 int arch_reserve_mmu(void);
139 * arch_setup_bdinfo() - Architecture dependent boardinfo setup
141 * Architecture-specific routine for populating various boardinfo fields of
142 * gd->bd. It is called during the generic board init sequence.
144 * If an implementation is not provided, it will just be a nop stub.
148 int arch_setup_bdinfo(void);
151 * setup_bdinfo() - Generic boardinfo setup
153 * Routine for populating various generic boardinfo fields of
154 * gd->bd. It is called during the generic board init sequence.
158 int setup_bdinfo(void);
160 #if defined(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) || \
161 defined(CONFIG_SAVE_PREV_BL_FDT_ADDR)
163 * save_prev_bl_data - Save prev bl data in env vars.
165 * When u-boot is chain-loaded, save previous bootloader data,
166 * like initramfs address to environment variables.
168 * Return: 0 if ok; -ENODATA on error
170 int save_prev_bl_data(void);
174 * cpu_secondary_init_r() - CPU-specific secondary initialization
176 * After non-volatile devices, environment and cpu code are setup, have
177 * another round to deal with any initialization that might require
178 * full access to the environment or loading of some image (firmware)
179 * from a non-volatile device.
181 * It is called during the generic post-relocation init sequence.
185 int cpu_secondary_init_r(void);
188 * pci_ep_init() - Initialize pci endpoint devices
190 * It is called during the generic post-relocation init sequence.
194 int pci_ep_init(void);
197 * pci_init() - Enumerate pci devices
199 * It is called during the generic post-relocation init sequence to enumerate
200 * pci buses. This is needed, for instance, in the case of DM PCI-based
201 * Ethernet devices, which will not be detected without having the enumeration
209 * init_cache_f_r() - Turn on the cache in preparation for relocation
211 * Return: 0 if OK, -ve on error
213 int init_cache_f_r(void);
215 #if !CONFIG_IS_ENABLED(CPU)
217 * print_cpuinfo() - Display information about the CPU
219 * Return: 0 if OK, -ve on error
221 int print_cpuinfo(void);
223 int timer_init(void);
225 #if defined(CONFIG_DTB_RESELECT)
226 int embedded_dtb_select(void);
229 /* common/init/board_init.c */
230 extern ulong monitor_flash_len
;
233 * ulong board_init_f_alloc_reserve - allocate reserved area
234 * @top: top of the reserve area, growing down.
236 * This function is called by each architecture very early in the start-up
237 * code to allow the C runtime to reserve space on the stack for writable
238 * 'globals' such as GD and the malloc arena.
240 * Return: bottom of reserved area
242 ulong
board_init_f_alloc_reserve(ulong top
);
245 * board_init_f_init_reserve - initialize the reserved area(s)
246 * @base: top from which reservation was done
248 * This function is called once the C runtime has allocated the reserved
249 * area on the stack. It must initialize the GD at the base of that area.
251 void board_init_f_init_reserve(ulong base
);
256 * arch_setup_gd() - Set up the global_data pointer
257 * @gd_ptr: Pointer to global data
259 * This pointer is special in some architectures and cannot easily be assigned
260 * to. For example on x86 it is implemented by adding a specific record to its
261 * Global Descriptor Table! So we we provide a function to carry out this task.
262 * For most architectures this can simply be:
266 void arch_setup_gd(struct global_data
*gd_ptr
);
268 /* common/board_r.c */
269 void board_init_r(struct global_data
*id
, ulong dest_addr
)
270 __attribute__ ((noreturn
));
272 int cpu_init_r(void);
273 int mac_read_from_eeprom(void);
276 * serial_read_from_eeprom - read the serial number from EEPROM
278 * This function reads the serial number from the EEPROM and sets the
279 * appropriate environment variable.
281 * The environment variable is only set if it has not been set
282 * already. This ensures that any user-saved variables are never
285 * This function must be called after relocation.
287 int serial_read_from_eeprom(int devnum
);
288 int set_cpu_clk_info(void);
289 int update_flash_size(int flash_size
);
290 int arch_early_init_r(void);
291 int misc_init_r(void);
293 /* common/board_info.c */
294 int checkboard(void);
297 * show_board_info() - Show board information
299 * Check sysinfo for board information. Failing that if the root node of the DTB
300 * has a "model" property, show it.
302 * Then call checkboard().
304 * Return 0 if OK, -ve on error
306 int show_board_info(void);
309 * board_get_usable_ram_top() - get uppermost address for U-Boot relocation
311 * Some systems have reserved memory areas in high memory. By implementing this
312 * function boards can indicate the highest address value to be used when
313 * relocating U-Boot. The returned address is exclusive (i.e. 1 byte above the
314 * last usable address).
316 * Due to overflow on systems with 32bit phys_addr_t a value 0 is used instead
319 * @total_size: monitor length in bytes (size of U-Boot code)
320 * Return: uppermost address for U-Boot relocation
322 phys_addr_t
board_get_usable_ram_top(phys_size_t total_size
);
324 int board_early_init_f(void);
326 /* manipulate the U-Boot fdt before its relocation */
327 int board_fix_fdt(void *rw_fdt_blob
);
328 int board_late_init(void);
329 int board_postclk_init(void); /* after clocks/timebase, before env/serial */
330 int board_early_init_r(void);
333 * arch_initr_trap() - Init traps
335 * Arch specific routine for initializing traps. It is called during the
336 * generic board init sequence, after relocation.
340 int arch_initr_trap(void);
345 * Initialize non-identity virtual-physical memory mappings for 32bit CPUs.
346 * It is called during the generic board init sequence, after relocation.
350 int init_addr_map(void);
353 * main_loop() - Enter the main loop of U-Boot
355 * This normally runs the command line.
357 void main_loop(void);
359 #if defined(CONFIG_ARM)
360 void relocate_code(ulong addr_moni
);
362 void relocate_code(ulong start_addr_sp
, struct global_data
*new_gd
,
364 __attribute__ ((noreturn
));
367 /* Print a numeric value (for use in arch_print_bdinfo()) */
368 void bdinfo_print_num_l(const char *name
, ulong value
);
369 void bdinfo_print_num_ll(const char *name
, unsigned long long value
);
371 /* Print a string value (for use in arch_print_bdinfo()) */
372 void bdinfo_print_str(const char *name
, const char *str
);
374 /* Print a clock speed in MHz */
375 void bdinfo_print_mhz(const char *name
, unsigned long hz
);
378 * bdinfo_print_size - print size variables in bdinfo format
379 * @name: string to print before the size
380 * @size: size to print
382 * Helper function for displaying size variables as properly formatted bdinfo
383 * entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
384 * "xxx GiB", etc. as needed;
386 * For use in arch_print_bdinfo().
388 void bdinfo_print_size(const char *name
, uint64_t size
);
390 /* Show arch-specific information for the 'bd' command */
391 void arch_print_bdinfo(void);
393 int do_bdinfo(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[]);
395 #endif /* __ASSEMBLY__ */
396 /* Put only stuff here that the assembler can digest */
398 #endif /* __INIT_H_ */