blob: fd51d7f9667102c61c42bc0c733a7a040a203ddb [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Patrick Delaunayc6bfcd52018-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 Delaunayc6bfcd52018-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 Glass3ba929a2020-10-30 21:38:53 -060015#include <linux/types.h>
16
Simon Glassda25eff2019-12-28 10:44:56 -070017/* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
18#ifdef CONFIG_EFI_STUB
19#define ll_boot_init() false
20#else
Simon Glass3ba929a2020-10-30 21:38:53 -060021#include <asm/global_data.h>
22
Simon Glass0b2f1912020-04-26 09:12:57 -060023#define ll_boot_init() (!(gd->flags & GD_FLG_SKIP_LL_INIT))
Simon Glassda25eff2019-12-28 10:44:56 -070024#endif
25
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +010026/*
27 * Function Prototypes
28 */
29
30/* common/board_f.c */
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010031void board_init_f(ulong dummy);
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +010032
33/**
34 * arch_cpu_init() - basic cpu-dependent setup for an architecture
35 *
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.
40 *
Mario Six86c45a42018-08-06 10:23:40 +020041 * Return: 0 on success, otherwise error
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +010042 */
43int arch_cpu_init(void);
44
45/**
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010046 * arch_cpu_init_dm() - init CPU after driver model is available
47 *
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
50 * devices
51 *
Mario Six86c45a42018-08-06 10:23:40 +020052 * Return: 0 if OK, -ve on error
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010053 */
54int arch_cpu_init_dm(void);
55
56/**
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +010057 * mach_cpu_init() - SoC/machine dependent CPU setup
58 *
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.
63 *
Mario Six86c45a42018-08-06 10:23:40 +020064 * Return: 0 on success, otherwise error
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +010065 */
66int mach_cpu_init(void);
67
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010068/**
69 * arch_fsp_init() - perform firmware support package init
70 *
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
73 * platforms.
Mario Six86c45a42018-08-06 10:23:40 +020074 *
75 * Return: 0
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010076 */
77int arch_fsp_init(void);
78
Simon Glass564a4a02019-12-06 21:42:20 -070079/**
80 * arch_fsp_init() - perform post-relocation firmware support package init
81 *
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
84 * platforms.
85 *
86 * Return: 0
87 */
88int arch_fsp_init_r(void);
89
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010090int dram_init(void);
91
92/**
93 * dram_init_banksize() - Set up DRAM bank sizes
94 *
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()
97 * is called.
98 *
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().
104 *
Mario Six86c45a42018-08-06 10:23:40 +0200105 * Return: 0 if OK, -ve on error
Patrick Delaunaya0a2b212018-03-13 13:57:00 +0100106 */
107int dram_init_banksize(void);
108
Simon Glass8e16b1e2019-12-28 10:45:05 -0700109long get_ram_size(long *base, long size);
110phys_size_t get_effective_memsize(void);
111
Simon Glass0ffd9db2019-12-28 10:45:06 -0700112int testdram(void);
113
Patrick Delaunaya0a2b212018-03-13 13:57:00 +0100114/**
Mario Six86c45a42018-08-06 10:23:40 +0200115 * arch_reserve_stacks() - Reserve all necessary stacks
Patrick Delaunaya0a2b212018-03-13 13:57:00 +0100116 *
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.
119 *
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.
123 *
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.
127 *
Mario Six86c45a42018-08-06 10:23:40 +0200128 * Return: 0 if no error
Patrick Delaunaya0a2b212018-03-13 13:57:00 +0100129 */
130int arch_reserve_stacks(void);
131
Patrick Delaunay18c50642018-03-13 13:57:04 +0100132/**
Ovidiu Panait2a2941b2020-03-29 20:57:41 +0300133 * arch_reserve_mmu() - Reserve memory for MMU TLB table
134 *
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.
137 *
138 * If an implementation is not provided, it will just be a nop stub.
139 *
140 * Return: 0 if OK
141 */
142int arch_reserve_mmu(void);
143
144/**
Ovidiu Panait3d0b0402020-07-24 14:12:15 +0300145 * arch_setup_bdinfo() - Architecture dependent boardinfo setup
146 *
147 * Architecture-specific routine for populating various boardinfo fields of
148 * gd->bd. It is called during the generic board init sequence.
149 *
150 * If an implementation is not provided, it will just be a nop stub.
151 *
152 * Return: 0 if OK
153 */
154int arch_setup_bdinfo(void);
155
156/**
Ovidiu Panait0c5e9a02020-07-24 14:12:14 +0300157 * setup_bdinfo() - Generic boardinfo setup
158 *
159 * Routine for populating various generic boardinfo fields of
160 * gd->bd. It is called during the generic board init sequence.
161 *
162 * Return: 0 if OK
163 */
164int setup_bdinfo(void);
165
166/**
Ovidiu Panaitc14c0f92020-11-28 10:43:09 +0200167 * cpu_secondary_init_r() - CPU-specific secondary initialization
168 *
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.
173 *
174 * It is called during the generic post-relocation init sequence.
175 *
176 * Return: 0 if OK
177 */
178int cpu_secondary_init_r(void);
179
180/**
Ovidiu Panaita45c6e12020-11-28 10:43:11 +0200181 * pci_ep_init() - Initialize pci endpoint devices
182 *
183 * It is called during the generic post-relocation init sequence.
184 *
185 * Return: 0 if OK
186 */
187int pci_ep_init(void);
188
189/**
Ovidiu Panaite353edb2020-11-28 10:43:12 +0200190 * pci_init() - Enumerate pci devices
191 *
192 * It is called during the generic post-relocation init sequence to enumerate
193 * pci buses. This is needed, for instance, in the case of DM PCI-based
194 * Ethernet devices, which will not be detected without having the enumeration
195 * performed earlier.
196 *
197 * Return: 0 if OK
198 */
199int pci_init(void);
200
201/**
Patrick Delaunay18c50642018-03-13 13:57:04 +0100202 * init_cache_f_r() - Turn on the cache in preparation for relocation
203 *
Mario Six86c45a42018-08-06 10:23:40 +0200204 * Return: 0 if OK, -ve on error
Patrick Delaunay18c50642018-03-13 13:57:04 +0100205 */
206int init_cache_f_r(void);
207
Mario Six97bbb602018-08-06 10:23:41 +0200208#if !CONFIG_IS_ENABLED(CPU)
209/**
210 * print_cpuinfo() - Display information about the CPU
211 *
212 * Return: 0 if OK, -ve on error
213 */
Patrick Delaunaya0a2b212018-03-13 13:57:00 +0100214int print_cpuinfo(void);
Mario Six97bbb602018-08-06 10:23:41 +0200215#endif
Patrick Delaunaya0a2b212018-03-13 13:57:00 +0100216int timer_init(void);
Patrick Delaunaya0a2b212018-03-13 13:57:00 +0100217int misc_init_f(void);
Mario Six86c45a42018-08-06 10:23:40 +0200218
Patrick Delaunaya0a2b212018-03-13 13:57:00 +0100219#if defined(CONFIG_DTB_RESELECT)
220int embedded_dtb_select(void);
221#endif
222
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100223/* common/init/board_init.c */
224extern ulong monitor_flash_len;
225
226/**
227 * ulong board_init_f_alloc_reserve - allocate reserved area
Mario Six86c45a42018-08-06 10:23:40 +0200228 * @top: top of the reserve area, growing down.
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100229 *
230 * This function is called by each architecture very early in the start-up
231 * code to allow the C runtime to reserve space on the stack for writable
232 * 'globals' such as GD and the malloc arena.
233 *
Mario Six86c45a42018-08-06 10:23:40 +0200234 * Return: bottom of reserved area
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100235 */
236ulong board_init_f_alloc_reserve(ulong top);
237
238/**
239 * board_init_f_init_reserve - initialize the reserved area(s)
Mario Six86c45a42018-08-06 10:23:40 +0200240 * @base: top from which reservation was done
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100241 *
242 * This function is called once the C runtime has allocated the reserved
243 * area on the stack. It must initialize the GD at the base of that area.
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100244 */
245void board_init_f_init_reserve(ulong base);
246
Simon Glass6980b6b2019-11-14 12:57:45 -0700247struct global_data;
248
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100249/**
250 * arch_setup_gd() - Set up the global_data pointer
Mario Six86c45a42018-08-06 10:23:40 +0200251 * @gd_ptr: Pointer to global data
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100252 *
253 * This pointer is special in some architectures and cannot easily be assigned
254 * to. For example on x86 it is implemented by adding a specific record to its
255 * Global Descriptor Table! So we we provide a function to carry out this task.
256 * For most architectures this can simply be:
257 *
258 * gd = gd_ptr;
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100259 */
Simon Glass6980b6b2019-11-14 12:57:45 -0700260void arch_setup_gd(struct global_data *gd_ptr);
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +0100261
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +0100262/* common/board_r.c */
Simon Glass6980b6b2019-11-14 12:57:45 -0700263void board_init_r(struct global_data *id, ulong dest_addr)
264 __attribute__ ((noreturn));
Patrick Delaunayb76e7cf2018-03-13 13:57:02 +0100265
266int cpu_init_r(void);
267int last_stage_init(void);
268int mac_read_from_eeprom(void);
269int set_cpu_clk_info(void);
270int update_flash_size(int flash_size);
271int arch_early_init_r(void);
Patrick Delaunayb76e7cf2018-03-13 13:57:02 +0100272int misc_init_r(void);
273#if defined(CONFIG_VID)
274int init_func_vid(void);
275#endif
276
Patrick Delaunayb1d23442018-03-13 13:57:03 +0100277/* common/board_info.c */
278int checkboard(void);
279int show_board_info(void);
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +0100280
Simon Glass6980b6b2019-11-14 12:57:45 -0700281/**
282 * Get the uppermost pointer that is valid to access
283 *
284 * Some systems may not map all of their address space. This function allows
285 * boards to indicate what their highest support pointer value is for DRAM
286 * access.
287 *
288 * @param total_size Size of U-Boot (unused?)
289 */
290ulong board_get_usable_ram_top(ulong total_size);
291
Simon Glassa7b51302019-11-14 12:57:46 -0700292int board_early_init_f(void);
293
294/* manipulate the U-Boot fdt before its relocation */
295int board_fix_fdt(void *rw_fdt_blob);
296int board_late_init(void);
297int board_postclk_init(void); /* after clocks/timebase, before env/serial */
298int board_early_init_r(void);
299
Simon Glass18afe102019-11-14 12:57:47 -0700300/* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */
301void pci_init_board(void);
302
Ovidiu Panait2c823912020-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 Glass537ecc92019-11-14 12:57:48 -0700312
Simon Glassa5037e22019-12-28 10:44:39 -0700313/**
314 * main_loop() - Enter the main loop of U-Boot
315 *
316 * This normally runs the command line.
317 */
318void main_loop(void);
319
Simon Glass284f71b2019-12-28 10:44:45 -0700320#if defined(CONFIG_ARM)
321void relocate_code(ulong addr_moni);
322#else
323void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
324 ulong relocaddr)
325 __attribute__ ((noreturn));
326#endif
327
Simon Glass7e246632020-05-10 14:16:55 -0600328/* Print a numeric value (for use in arch_print_bdinfo()) */
Bin Meng1ae7a0c2021-01-31 20:36:05 +0800329void bdinfo_print_num_l(const char *name, ulong value);
330void bdinfo_print_num_ll(const char *name, unsigned long long value);
Simon Glass7e246632020-05-10 14:16:55 -0600331
332/* Print a clock speed in MHz */
333void bdinfo_print_mhz(const char *name, unsigned long hz);
334
Simon Glassa83ab162020-05-10 14:16:56 -0600335/* Show arch-specific information for the 'bd' command */
336void arch_print_bdinfo(void);
337
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +0100338#endif /* __ASSEMBLY__ */
339/* Put only stuff here that the assembler can digest */
340
341#endif /* __INIT_H_ */