blob: 20c3976af09a717496aace4b5d76238fc7f5ec87 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Patrick Delaunaydafa84d2018-03-09 18:28:12 +01002/*
3 * (C) Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
6 * Copy the startup prototype, previously defined in common.h
7 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
Patrick Delaunaydafa84d2018-03-09 18:28:12 +01008 */
9
10#ifndef __INIT_H_
11#define __INIT_H_ 1
12
13#ifndef __ASSEMBLY__ /* put C only stuff in this section */
14
Simon Glass401d1c42020-10-30 21:38:53 -060015#include <linux/types.h>
16
Simon Glass90794862021-12-29 11:57:43 -070017/*
18 * In case of the EFI app the UEFI firmware provides the low-level
19 * initialisation.
20 */
21#ifdef CONFIG_EFI
Simon Glass35a3f872019-12-28 10:44:56 -070022#define ll_boot_init() false
23#else
Simon Glass401d1c42020-10-30 21:38:53 -060024#include <asm/global_data.h>
25
Simon Glassba974a02020-04-26 09:12:57 -060026#define ll_boot_init() (!(gd->flags & GD_FLG_SKIP_LL_INIT))
Simon Glass35a3f872019-12-28 10:44:56 -070027#endif
28
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010029/*
30 * Function Prototypes
31 */
32
33/* common/board_f.c */
Patrick Delaunayd6f87712018-03-13 13:57:00 +010034void board_init_f(ulong dummy);
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010035
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 *
Mario Sixdc145a72018-08-06 10:23:40 +020044 * Return: 0 on success, otherwise error
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010045 */
46int arch_cpu_init(void);
47
48/**
Patrick Delaunayd6f87712018-03-13 13:57:00 +010049 * arch_cpu_init_dm() - init CPU after driver model is available
50 *
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
53 * devices
54 *
Mario Sixdc145a72018-08-06 10:23:40 +020055 * Return: 0 if OK, -ve on error
Patrick Delaunayd6f87712018-03-13 13:57:00 +010056 */
57int arch_cpu_init_dm(void);
58
59/**
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010060 * mach_cpu_init() - SoC/machine dependent CPU setup
61 *
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.
66 *
Mario Sixdc145a72018-08-06 10:23:40 +020067 * Return: 0 on success, otherwise error
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010068 */
69int mach_cpu_init(void);
70
Patrick Delaunayd6f87712018-03-13 13:57:00 +010071/**
72 * arch_fsp_init() - perform firmware support package init
73 *
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
76 * platforms.
Mario Sixdc145a72018-08-06 10:23:40 +020077 *
78 * Return: 0
Patrick Delaunayd6f87712018-03-13 13:57:00 +010079 */
80int arch_fsp_init(void);
81
Simon Glassfe08d392019-12-06 21:42:20 -070082/**
83 * arch_fsp_init() - perform post-relocation firmware support package init
84 *
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
87 * platforms.
88 *
89 * Return: 0
90 */
91int arch_fsp_init_r(void);
92
Patrick Delaunayd6f87712018-03-13 13:57:00 +010093int dram_init(void);
94
95/**
96 * dram_init_banksize() - Set up DRAM bank sizes
97 *
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()
100 * is called.
101 *
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().
107 *
Mario Sixdc145a72018-08-06 10:23:40 +0200108 * Return: 0 if OK, -ve on error
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100109 */
110int dram_init_banksize(void);
111
Simon Glass9b4a2052019-12-28 10:45:05 -0700112long get_ram_size(long *base, long size);
113phys_size_t get_effective_memsize(void);
114
Simon Glass49acd562019-12-28 10:45:06 -0700115int testdram(void);
116
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100117/**
Mario Sixdc145a72018-08-06 10:23:40 +0200118 * arch_reserve_stacks() - Reserve all necessary stacks
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100119 *
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.
122 *
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.
126 *
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.
130 *
Mario Sixdc145a72018-08-06 10:23:40 +0200131 * Return: 0 if no error
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100132 */
133int arch_reserve_stacks(void);
134
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100135/**
Ovidiu Panait79926e42020-03-29 20:57:41 +0300136 * arch_reserve_mmu() - Reserve memory for MMU TLB table
137 *
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.
140 *
141 * If an implementation is not provided, it will just be a nop stub.
142 *
143 * Return: 0 if OK
144 */
145int arch_reserve_mmu(void);
146
147/**
Ovidiu Panait81e7cb12020-07-24 14:12:15 +0300148 * arch_setup_bdinfo() - Architecture dependent boardinfo setup
149 *
150 * Architecture-specific routine for populating various boardinfo fields of
151 * gd->bd. It is called during the generic board init sequence.
152 *
153 * If an implementation is not provided, it will just be a nop stub.
154 *
155 * Return: 0 if OK
156 */
157int arch_setup_bdinfo(void);
158
159/**
Ovidiu Panaitba743102020-07-24 14:12:14 +0300160 * setup_bdinfo() - Generic boardinfo setup
161 *
162 * Routine for populating various generic boardinfo fields of
163 * gd->bd. It is called during the generic board init sequence.
164 *
165 * Return: 0 if OK
166 */
167int setup_bdinfo(void);
168
169/**
Ovidiu Panaitfb504b22020-11-28 10:43:09 +0200170 * cpu_secondary_init_r() - CPU-specific secondary initialization
171 *
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.
176 *
177 * It is called during the generic post-relocation init sequence.
178 *
179 * Return: 0 if OK
180 */
181int cpu_secondary_init_r(void);
182
183/**
Ovidiu Panaitc343e8c2020-11-28 10:43:11 +0200184 * pci_ep_init() - Initialize pci endpoint devices
185 *
186 * It is called during the generic post-relocation init sequence.
187 *
188 * Return: 0 if OK
189 */
190int pci_ep_init(void);
191
192/**
Ovidiu Panaitb9f6d0f2020-11-28 10:43:12 +0200193 * pci_init() - Enumerate pci devices
194 *
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
198 * performed earlier.
199 *
200 * Return: 0 if OK
201 */
202int pci_init(void);
203
204/**
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100205 * init_cache_f_r() - Turn on the cache in preparation for relocation
206 *
Mario Sixdc145a72018-08-06 10:23:40 +0200207 * Return: 0 if OK, -ve on error
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100208 */
209int init_cache_f_r(void);
210
Mario Six5d6c61a2018-08-06 10:23:41 +0200211#if !CONFIG_IS_ENABLED(CPU)
212/**
213 * print_cpuinfo() - Display information about the CPU
214 *
215 * Return: 0 if OK, -ve on error
216 */
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100217int print_cpuinfo(void);
Mario Six5d6c61a2018-08-06 10:23:41 +0200218#endif
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100219int timer_init(void);
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100220int misc_init_f(void);
Mario Sixdc145a72018-08-06 10:23:40 +0200221
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100222#if defined(CONFIG_DTB_RESELECT)
223int embedded_dtb_select(void);
224#endif
225
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100226/* common/init/board_init.c */
227extern ulong monitor_flash_len;
228
229/**
230 * ulong board_init_f_alloc_reserve - allocate reserved area
Mario Sixdc145a72018-08-06 10:23:40 +0200231 * @top: top of the reserve area, growing down.
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100232 *
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.
236 *
Mario Sixdc145a72018-08-06 10:23:40 +0200237 * Return: bottom of reserved area
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100238 */
239ulong board_init_f_alloc_reserve(ulong top);
240
241/**
242 * board_init_f_init_reserve - initialize the reserved area(s)
Mario Sixdc145a72018-08-06 10:23:40 +0200243 * @base: top from which reservation was done
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100244 *
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.
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100247 */
248void board_init_f_init_reserve(ulong base);
249
Simon Glass67c4e9f2019-11-14 12:57:45 -0700250struct global_data;
251
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100252/**
253 * arch_setup_gd() - Set up the global_data pointer
Mario Sixdc145a72018-08-06 10:23:40 +0200254 * @gd_ptr: Pointer to global data
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100255 *
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:
260 *
261 * gd = gd_ptr;
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100262 */
Simon Glass67c4e9f2019-11-14 12:57:45 -0700263void arch_setup_gd(struct global_data *gd_ptr);
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100264
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100265/* common/board_r.c */
Simon Glass67c4e9f2019-11-14 12:57:45 -0700266void board_init_r(struct global_data *id, ulong dest_addr)
267 __attribute__ ((noreturn));
Patrick Delaunaye2c219c2018-03-13 13:57:02 +0100268
269int cpu_init_r(void);
270int last_stage_init(void);
271int mac_read_from_eeprom(void);
272int set_cpu_clk_info(void);
273int update_flash_size(int flash_size);
274int arch_early_init_r(void);
Patrick Delaunaye2c219c2018-03-13 13:57:02 +0100275int misc_init_r(void);
276#if defined(CONFIG_VID)
277int init_func_vid(void);
278#endif
279
Patrick Delaunayfc22ee22018-03-13 13:57:03 +0100280/* common/board_info.c */
281int checkboard(void);
282int show_board_info(void);
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100283
Simon Glass67c4e9f2019-11-14 12:57:45 -0700284/**
285 * Get the uppermost pointer that is valid to access
286 *
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
289 * access.
290 *
291 * @param total_size Size of U-Boot (unused?)
292 */
293ulong board_get_usable_ram_top(ulong total_size);
294
Simon Glass52559322019-11-14 12:57:46 -0700295int board_early_init_f(void);
296
297/* manipulate the U-Boot fdt before its relocation */
298int board_fix_fdt(void *rw_fdt_blob);
299int board_late_init(void);
300int board_postclk_init(void); /* after clocks/timebase, before env/serial */
301int board_early_init_r(void);
302
Ovidiu Panait130845b2020-11-28 10:43:18 +0200303/**
304 * arch_initr_trap() - Init traps
305 *
306 * Arch specific routine for initializing traps. It is called during the
307 * generic board init sequence, after relocation.
308 *
309 * Return: 0 if OK
310 */
311int arch_initr_trap(void);
Simon Glassd67bdaa2019-11-14 12:57:48 -0700312
Simon Glass6b8d3ce2019-12-28 10:44:39 -0700313/**
Ovidiu Panait2fd81be2022-01-01 19:13:29 +0200314 * init_addr_map()
315 *
316 * Initialize non-identity virtual-physical memory mappings for 32bit CPUs.
317 * It is called during the generic board init sequence, after relocation.
318 *
319 * Return: 0 if OK
320 */
321int init_addr_map(void);
322
323/**
Simon Glass6b8d3ce2019-12-28 10:44:39 -0700324 * main_loop() - Enter the main loop of U-Boot
325 *
326 * This normally runs the command line.
327 */
328void main_loop(void);
329
Simon Glass94133872019-12-28 10:44:45 -0700330#if defined(CONFIG_ARM)
331void relocate_code(ulong addr_moni);
332#else
333void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
334 ulong relocaddr)
335 __attribute__ ((noreturn));
336#endif
337
Simon Glass655f17f2020-05-10 14:16:55 -0600338/* Print a numeric value (for use in arch_print_bdinfo()) */
Bin Meng98592c72021-01-31 20:36:05 +0800339void bdinfo_print_num_l(const char *name, ulong value);
340void bdinfo_print_num_ll(const char *name, unsigned long long value);
Simon Glass655f17f2020-05-10 14:16:55 -0600341
342/* Print a clock speed in MHz */
343void bdinfo_print_mhz(const char *name, unsigned long hz);
344
Simon Glass59b0d7d2020-05-10 14:16:56 -0600345/* Show arch-specific information for the 'bd' command */
346void arch_print_bdinfo(void);
347
Andy Shevchenko4b325312021-11-08 21:03:38 +0300348int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
349
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100350#endif /* __ASSEMBLY__ */
351/* Put only stuff here that the assembler can digest */
352
353#endif /* __INIT_H_ */