blob: 0f48ccb57ad274417fbffca66ce20392d23de531 [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
Simon Glass67c4e9f2019-11-14 12:57:45 -070013#include <linux/types.h>
14
Simon Glass94133872019-12-28 10:44:45 -070015struct global_data;
16
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010017#ifndef __ASSEMBLY__ /* put C only stuff in this section */
18
Simon Glass35a3f872019-12-28 10:44:56 -070019/* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
20#ifdef CONFIG_EFI_STUB
21#define ll_boot_init() false
22#else
Simon Glassba974a02020-04-26 09:12:57 -060023#define ll_boot_init() (!(gd->flags & GD_FLG_SKIP_LL_INIT))
Simon Glass35a3f872019-12-28 10:44:56 -070024#endif
25
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010026/*
27 * Function Prototypes
28 */
29
30/* common/board_f.c */
Patrick Delaunayd6f87712018-03-13 13:57:00 +010031void board_init_f(ulong dummy);
Patrick Delaunaydafa84d2018-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 Sixdc145a72018-08-06 10:23:40 +020041 * Return: 0 on success, otherwise error
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010042 */
43int arch_cpu_init(void);
44
45/**
Patrick Delaunayd6f87712018-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 Sixdc145a72018-08-06 10:23:40 +020052 * Return: 0 if OK, -ve on error
Patrick Delaunayd6f87712018-03-13 13:57:00 +010053 */
54int arch_cpu_init_dm(void);
55
56/**
Patrick Delaunaydafa84d2018-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 Sixdc145a72018-08-06 10:23:40 +020064 * Return: 0 on success, otherwise error
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010065 */
66int mach_cpu_init(void);
67
Patrick Delaunayd6f87712018-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 Sixdc145a72018-08-06 10:23:40 +020074 *
75 * Return: 0
Patrick Delaunayd6f87712018-03-13 13:57:00 +010076 */
77int arch_fsp_init(void);
78
Simon Glassfe08d392019-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 Delaunayd6f87712018-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 Sixdc145a72018-08-06 10:23:40 +0200105 * Return: 0 if OK, -ve on error
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100106 */
107int dram_init_banksize(void);
108
Simon Glass9b4a2052019-12-28 10:45:05 -0700109long get_ram_size(long *base, long size);
110phys_size_t get_effective_memsize(void);
111
Simon Glass49acd562019-12-28 10:45:06 -0700112int testdram(void);
113
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100114/**
Mario Sixdc145a72018-08-06 10:23:40 +0200115 * arch_reserve_stacks() - Reserve all necessary stacks
Patrick Delaunayd6f87712018-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 Sixdc145a72018-08-06 10:23:40 +0200128 * Return: 0 if no error
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100129 */
130int arch_reserve_stacks(void);
131
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100132/**
Ovidiu Panait79926e42020-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 Panait81e7cb12020-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 Panaitba743102020-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/**
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100167 * init_cache_f_r() - Turn on the cache in preparation for relocation
168 *
Mario Sixdc145a72018-08-06 10:23:40 +0200169 * Return: 0 if OK, -ve on error
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100170 */
171int init_cache_f_r(void);
172
Mario Six5d6c61a2018-08-06 10:23:41 +0200173#if !CONFIG_IS_ENABLED(CPU)
174/**
175 * print_cpuinfo() - Display information about the CPU
176 *
177 * Return: 0 if OK, -ve on error
178 */
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100179int print_cpuinfo(void);
Mario Six5d6c61a2018-08-06 10:23:41 +0200180#endif
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100181int timer_init(void);
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100182int misc_init_f(void);
Mario Sixdc145a72018-08-06 10:23:40 +0200183
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100184#if defined(CONFIG_DTB_RESELECT)
185int embedded_dtb_select(void);
186#endif
187
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100188/* common/init/board_init.c */
189extern ulong monitor_flash_len;
190
191/**
192 * ulong board_init_f_alloc_reserve - allocate reserved area
Mario Sixdc145a72018-08-06 10:23:40 +0200193 * @top: top of the reserve area, growing down.
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100194 *
195 * This function is called by each architecture very early in the start-up
196 * code to allow the C runtime to reserve space on the stack for writable
197 * 'globals' such as GD and the malloc arena.
198 *
Mario Sixdc145a72018-08-06 10:23:40 +0200199 * Return: bottom of reserved area
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100200 */
201ulong board_init_f_alloc_reserve(ulong top);
202
203/**
204 * board_init_f_init_reserve - initialize the reserved area(s)
Mario Sixdc145a72018-08-06 10:23:40 +0200205 * @base: top from which reservation was done
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100206 *
207 * This function is called once the C runtime has allocated the reserved
208 * area on the stack. It must initialize the GD at the base of that area.
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100209 */
210void board_init_f_init_reserve(ulong base);
211
Simon Glass67c4e9f2019-11-14 12:57:45 -0700212struct global_data;
213
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100214/**
215 * arch_setup_gd() - Set up the global_data pointer
Mario Sixdc145a72018-08-06 10:23:40 +0200216 * @gd_ptr: Pointer to global data
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100217 *
218 * This pointer is special in some architectures and cannot easily be assigned
219 * to. For example on x86 it is implemented by adding a specific record to its
220 * Global Descriptor Table! So we we provide a function to carry out this task.
221 * For most architectures this can simply be:
222 *
223 * gd = gd_ptr;
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100224 */
Simon Glass67c4e9f2019-11-14 12:57:45 -0700225void arch_setup_gd(struct global_data *gd_ptr);
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100226
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100227/* common/board_r.c */
Simon Glass67c4e9f2019-11-14 12:57:45 -0700228void board_init_r(struct global_data *id, ulong dest_addr)
229 __attribute__ ((noreturn));
Patrick Delaunaye2c219c2018-03-13 13:57:02 +0100230
231int cpu_init_r(void);
232int last_stage_init(void);
233int mac_read_from_eeprom(void);
234int set_cpu_clk_info(void);
235int update_flash_size(int flash_size);
236int arch_early_init_r(void);
237void pci_init(void);
Xiaowei Baofd00c532020-07-09 23:31:34 +0800238void pci_ep_init(void);
Patrick Delaunaye2c219c2018-03-13 13:57:02 +0100239int misc_init_r(void);
240#if defined(CONFIG_VID)
241int init_func_vid(void);
242#endif
243
Patrick Delaunayfc22ee22018-03-13 13:57:03 +0100244/* common/board_info.c */
245int checkboard(void);
246int show_board_info(void);
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100247
Simon Glass67c4e9f2019-11-14 12:57:45 -0700248/**
249 * Get the uppermost pointer that is valid to access
250 *
251 * Some systems may not map all of their address space. This function allows
252 * boards to indicate what their highest support pointer value is for DRAM
253 * access.
254 *
255 * @param total_size Size of U-Boot (unused?)
256 */
257ulong board_get_usable_ram_top(ulong total_size);
258
Simon Glass52559322019-11-14 12:57:46 -0700259int board_early_init_f(void);
260
261/* manipulate the U-Boot fdt before its relocation */
262int board_fix_fdt(void *rw_fdt_blob);
263int board_late_init(void);
264int board_postclk_init(void); /* after clocks/timebase, before env/serial */
265int board_early_init_r(void);
266
Simon Glass2cf431c2019-11-14 12:57:47 -0700267/* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */
268void pci_init_board(void);
269
Simon Glassd67bdaa2019-11-14 12:57:48 -0700270void trap_init(unsigned long reloc_addr);
271
Simon Glass6b8d3ce2019-12-28 10:44:39 -0700272/**
273 * main_loop() - Enter the main loop of U-Boot
274 *
275 * This normally runs the command line.
276 */
277void main_loop(void);
278
Simon Glass94133872019-12-28 10:44:45 -0700279#if defined(CONFIG_ARM)
280void relocate_code(ulong addr_moni);
281#else
282void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
283 ulong relocaddr)
284 __attribute__ ((noreturn));
285#endif
286
Simon Glass655f17f2020-05-10 14:16:55 -0600287/* Print a numeric value (for use in arch_print_bdinfo()) */
288void bdinfo_print_num(const char *name, ulong value);
289
290/* Print a clock speed in MHz */
291void bdinfo_print_mhz(const char *name, unsigned long hz);
292
Simon Glass59b0d7d2020-05-10 14:16:56 -0600293/* Show arch-specific information for the 'bd' command */
294void arch_print_bdinfo(void);
295
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100296#endif /* __ASSEMBLY__ */
297/* Put only stuff here that the assembler can digest */
298
299#endif /* __INIT_H_ */