blob: f6105de66609dac6344de071513d8f8b4eea13ed [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
19/*
20 * Function Prototypes
21 */
22
23/* common/board_f.c */
Patrick Delaunayd6f87712018-03-13 13:57:00 +010024void board_init_f(ulong dummy);
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010025
26/**
27 * arch_cpu_init() - basic cpu-dependent setup for an architecture
28 *
29 * This is called after early malloc is available. It should handle any
30 * CPU- or SoC- specific init needed to continue the init sequence. See
31 * board_f.c for where it is called. If this is not provided, a default
32 * version (which does nothing) will be used.
33 *
Mario Sixdc145a72018-08-06 10:23:40 +020034 * Return: 0 on success, otherwise error
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010035 */
36int arch_cpu_init(void);
37
38/**
Patrick Delaunayd6f87712018-03-13 13:57:00 +010039 * arch_cpu_init_dm() - init CPU after driver model is available
40 *
41 * This is called immediately after driver model is available before
42 * relocation. This is similar to arch_cpu_init() but is able to reference
43 * devices
44 *
Mario Sixdc145a72018-08-06 10:23:40 +020045 * Return: 0 if OK, -ve on error
Patrick Delaunayd6f87712018-03-13 13:57:00 +010046 */
47int arch_cpu_init_dm(void);
48
49/**
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010050 * mach_cpu_init() - SoC/machine dependent CPU setup
51 *
52 * This is called after arch_cpu_init(). It should handle any
53 * SoC or machine specific init needed to continue the init sequence. See
54 * board_f.c for where it is called. If this is not provided, a default
55 * version (which does nothing) will be used.
56 *
Mario Sixdc145a72018-08-06 10:23:40 +020057 * Return: 0 on success, otherwise error
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010058 */
59int mach_cpu_init(void);
60
Patrick Delaunayd6f87712018-03-13 13:57:00 +010061/**
62 * arch_fsp_init() - perform firmware support package init
63 *
64 * Where U-Boot relies on binary blobs to handle part of the system init, this
65 * function can be used to set up the blobs. This is used on some Intel
66 * platforms.
Mario Sixdc145a72018-08-06 10:23:40 +020067 *
68 * Return: 0
Patrick Delaunayd6f87712018-03-13 13:57:00 +010069 */
70int arch_fsp_init(void);
71
Simon Glassfe08d392019-12-06 21:42:20 -070072/**
73 * arch_fsp_init() - perform post-relocation firmware support package init
74 *
75 * Where U-Boot relies on binary blobs to handle part of the system init, this
76 * function can be used to set up the blobs. This is used on some Intel
77 * platforms.
78 *
79 * Return: 0
80 */
81int arch_fsp_init_r(void);
82
Patrick Delaunayd6f87712018-03-13 13:57:00 +010083int dram_init(void);
84
85/**
86 * dram_init_banksize() - Set up DRAM bank sizes
87 *
88 * This can be implemented by boards to set up the DRAM bank information in
89 * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
90 * is called.
91 *
92 * If this is not provided, a default implementation will try to set up a
93 * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
94 * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of
95 * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to
96 * get_effective_memsize().
97 *
Mario Sixdc145a72018-08-06 10:23:40 +020098 * Return: 0 if OK, -ve on error
Patrick Delaunayd6f87712018-03-13 13:57:00 +010099 */
100int dram_init_banksize(void);
101
102/**
Mario Sixdc145a72018-08-06 10:23:40 +0200103 * arch_reserve_stacks() - Reserve all necessary stacks
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100104 *
105 * This is used in generic board init sequence in common/board_f.c. Each
106 * architecture could provide this function to tailor the required stacks.
107 *
108 * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
109 * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
110 * require only this can leave it untouched.
111 *
112 * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
113 * positions of the stack. The stack pointer(s) will be set to this later.
114 * gd->irq_sp is only required, if the architecture needs it.
115 *
Mario Sixdc145a72018-08-06 10:23:40 +0200116 * Return: 0 if no error
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100117 */
118int arch_reserve_stacks(void);
119
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100120/**
121 * init_cache_f_r() - Turn on the cache in preparation for relocation
122 *
Mario Sixdc145a72018-08-06 10:23:40 +0200123 * Return: 0 if OK, -ve on error
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100124 */
125int init_cache_f_r(void);
126
Mario Six5d6c61a2018-08-06 10:23:41 +0200127#if !CONFIG_IS_ENABLED(CPU)
128/**
129 * print_cpuinfo() - Display information about the CPU
130 *
131 * Return: 0 if OK, -ve on error
132 */
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100133int print_cpuinfo(void);
Mario Six5d6c61a2018-08-06 10:23:41 +0200134#endif
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100135int timer_init(void);
136int reserve_mmu(void);
137int misc_init_f(void);
Mario Sixdc145a72018-08-06 10:23:40 +0200138
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100139#if defined(CONFIG_DTB_RESELECT)
140int embedded_dtb_select(void);
141#endif
142
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100143/* common/init/board_init.c */
144extern ulong monitor_flash_len;
145
146/**
147 * ulong board_init_f_alloc_reserve - allocate reserved area
Mario Sixdc145a72018-08-06 10:23:40 +0200148 * @top: top of the reserve area, growing down.
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100149 *
150 * This function is called by each architecture very early in the start-up
151 * code to allow the C runtime to reserve space on the stack for writable
152 * 'globals' such as GD and the malloc arena.
153 *
Mario Sixdc145a72018-08-06 10:23:40 +0200154 * Return: bottom of reserved area
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100155 */
156ulong board_init_f_alloc_reserve(ulong top);
157
158/**
159 * board_init_f_init_reserve - initialize the reserved area(s)
Mario Sixdc145a72018-08-06 10:23:40 +0200160 * @base: top from which reservation was done
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100161 *
162 * This function is called once the C runtime has allocated the reserved
163 * area on the stack. It must initialize the GD at the base of that area.
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100164 */
165void board_init_f_init_reserve(ulong base);
166
Simon Glass67c4e9f2019-11-14 12:57:45 -0700167struct global_data;
168
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100169/**
170 * arch_setup_gd() - Set up the global_data pointer
Mario Sixdc145a72018-08-06 10:23:40 +0200171 * @gd_ptr: Pointer to global data
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100172 *
173 * This pointer is special in some architectures and cannot easily be assigned
174 * to. For example on x86 it is implemented by adding a specific record to its
175 * Global Descriptor Table! So we we provide a function to carry out this task.
176 * For most architectures this can simply be:
177 *
178 * gd = gd_ptr;
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100179 */
Simon Glass67c4e9f2019-11-14 12:57:45 -0700180void arch_setup_gd(struct global_data *gd_ptr);
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100181
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100182/* common/board_r.c */
Simon Glass67c4e9f2019-11-14 12:57:45 -0700183void board_init_r(struct global_data *id, ulong dest_addr)
184 __attribute__ ((noreturn));
Patrick Delaunaye2c219c2018-03-13 13:57:02 +0100185
186int cpu_init_r(void);
187int last_stage_init(void);
188int mac_read_from_eeprom(void);
189int set_cpu_clk_info(void);
190int update_flash_size(int flash_size);
191int arch_early_init_r(void);
192void pci_init(void);
193int misc_init_r(void);
194#if defined(CONFIG_VID)
195int init_func_vid(void);
196#endif
197
Patrick Delaunayfc22ee22018-03-13 13:57:03 +0100198/* common/board_info.c */
199int checkboard(void);
200int show_board_info(void);
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100201
Simon Glass67c4e9f2019-11-14 12:57:45 -0700202/**
203 * Get the uppermost pointer that is valid to access
204 *
205 * Some systems may not map all of their address space. This function allows
206 * boards to indicate what their highest support pointer value is for DRAM
207 * access.
208 *
209 * @param total_size Size of U-Boot (unused?)
210 */
211ulong board_get_usable_ram_top(ulong total_size);
212
Simon Glass52559322019-11-14 12:57:46 -0700213int board_early_init_f(void);
214
215/* manipulate the U-Boot fdt before its relocation */
216int board_fix_fdt(void *rw_fdt_blob);
217int board_late_init(void);
218int board_postclk_init(void); /* after clocks/timebase, before env/serial */
219int board_early_init_r(void);
220
Simon Glass2cf431c2019-11-14 12:57:47 -0700221/* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */
222void pci_init_board(void);
223
Simon Glassd67bdaa2019-11-14 12:57:48 -0700224void trap_init(unsigned long reloc_addr);
225
Simon Glass6b8d3ce2019-12-28 10:44:39 -0700226/**
227 * main_loop() - Enter the main loop of U-Boot
228 *
229 * This normally runs the command line.
230 */
231void main_loop(void);
232
Simon Glass94133872019-12-28 10:44:45 -0700233#if defined(CONFIG_ARM)
234void relocate_code(ulong addr_moni);
235#else
236void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
237 ulong relocaddr)
238 __attribute__ ((noreturn));
239#endif
240
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100241#endif /* __ASSEMBLY__ */
242/* Put only stuff here that the assembler can digest */
243
244#endif /* __INIT_H_ */