blob: 8b65b2afe42fef1d2e3596f807689595ce16363e [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
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010015#ifndef __ASSEMBLY__ /* put C only stuff in this section */
16
17/*
18 * Function Prototypes
19 */
20
21/* common/board_f.c */
Patrick Delaunayd6f87712018-03-13 13:57:00 +010022void board_init_f(ulong dummy);
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010023
24/**
25 * arch_cpu_init() - basic cpu-dependent setup for an architecture
26 *
27 * This is called after early malloc is available. It should handle any
28 * CPU- or SoC- specific init needed to continue the init sequence. See
29 * board_f.c for where it is called. If this is not provided, a default
30 * version (which does nothing) will be used.
31 *
Mario Sixdc145a72018-08-06 10:23:40 +020032 * Return: 0 on success, otherwise error
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010033 */
34int arch_cpu_init(void);
35
36/**
Patrick Delaunayd6f87712018-03-13 13:57:00 +010037 * arch_cpu_init_dm() - init CPU after driver model is available
38 *
39 * This is called immediately after driver model is available before
40 * relocation. This is similar to arch_cpu_init() but is able to reference
41 * devices
42 *
Mario Sixdc145a72018-08-06 10:23:40 +020043 * Return: 0 if OK, -ve on error
Patrick Delaunayd6f87712018-03-13 13:57:00 +010044 */
45int arch_cpu_init_dm(void);
46
47/**
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010048 * mach_cpu_init() - SoC/machine dependent CPU setup
49 *
50 * This is called after arch_cpu_init(). It should handle any
51 * SoC or machine specific init needed to continue the init sequence. See
52 * board_f.c for where it is called. If this is not provided, a default
53 * version (which does nothing) will be used.
54 *
Mario Sixdc145a72018-08-06 10:23:40 +020055 * Return: 0 on success, otherwise error
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010056 */
57int mach_cpu_init(void);
58
Patrick Delaunayd6f87712018-03-13 13:57:00 +010059/**
60 * arch_fsp_init() - perform firmware support package init
61 *
62 * Where U-Boot relies on binary blobs to handle part of the system init, this
63 * function can be used to set up the blobs. This is used on some Intel
64 * platforms.
Mario Sixdc145a72018-08-06 10:23:40 +020065 *
66 * Return: 0
Patrick Delaunayd6f87712018-03-13 13:57:00 +010067 */
68int arch_fsp_init(void);
69
70int dram_init(void);
71
72/**
73 * dram_init_banksize() - Set up DRAM bank sizes
74 *
75 * This can be implemented by boards to set up the DRAM bank information in
76 * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
77 * is called.
78 *
79 * If this is not provided, a default implementation will try to set up a
80 * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
81 * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of
82 * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to
83 * get_effective_memsize().
84 *
Mario Sixdc145a72018-08-06 10:23:40 +020085 * Return: 0 if OK, -ve on error
Patrick Delaunayd6f87712018-03-13 13:57:00 +010086 */
87int dram_init_banksize(void);
88
89/**
Mario Sixdc145a72018-08-06 10:23:40 +020090 * arch_reserve_stacks() - Reserve all necessary stacks
Patrick Delaunayd6f87712018-03-13 13:57:00 +010091 *
92 * This is used in generic board init sequence in common/board_f.c. Each
93 * architecture could provide this function to tailor the required stacks.
94 *
95 * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
96 * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
97 * require only this can leave it untouched.
98 *
99 * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
100 * positions of the stack. The stack pointer(s) will be set to this later.
101 * gd->irq_sp is only required, if the architecture needs it.
102 *
Mario Sixdc145a72018-08-06 10:23:40 +0200103 * Return: 0 if no error
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100104 */
105int arch_reserve_stacks(void);
106
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100107/**
108 * init_cache_f_r() - Turn on the cache in preparation for relocation
109 *
Mario Sixdc145a72018-08-06 10:23:40 +0200110 * Return: 0 if OK, -ve on error
Patrick Delaunayb8aa55c2018-03-13 13:57:04 +0100111 */
112int init_cache_f_r(void);
113
Mario Six5d6c61a2018-08-06 10:23:41 +0200114#if !CONFIG_IS_ENABLED(CPU)
115/**
116 * print_cpuinfo() - Display information about the CPU
117 *
118 * Return: 0 if OK, -ve on error
119 */
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100120int print_cpuinfo(void);
Mario Six5d6c61a2018-08-06 10:23:41 +0200121#endif
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100122int timer_init(void);
123int reserve_mmu(void);
124int misc_init_f(void);
Mario Sixdc145a72018-08-06 10:23:40 +0200125
Patrick Delaunayd6f87712018-03-13 13:57:00 +0100126#if defined(CONFIG_DTB_RESELECT)
127int embedded_dtb_select(void);
128#endif
129
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100130/* common/init/board_init.c */
131extern ulong monitor_flash_len;
132
133/**
134 * ulong board_init_f_alloc_reserve - allocate reserved area
Mario Sixdc145a72018-08-06 10:23:40 +0200135 * @top: top of the reserve area, growing down.
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100136 *
137 * This function is called by each architecture very early in the start-up
138 * code to allow the C runtime to reserve space on the stack for writable
139 * 'globals' such as GD and the malloc arena.
140 *
Mario Sixdc145a72018-08-06 10:23:40 +0200141 * Return: bottom of reserved area
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100142 */
143ulong board_init_f_alloc_reserve(ulong top);
144
145/**
146 * board_init_f_init_reserve - initialize the reserved area(s)
Mario Sixdc145a72018-08-06 10:23:40 +0200147 * @base: top from which reservation was done
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100148 *
149 * This function is called once the C runtime has allocated the reserved
150 * area on the stack. It must initialize the GD at the base of that area.
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100151 */
152void board_init_f_init_reserve(ulong base);
153
Simon Glass67c4e9f2019-11-14 12:57:45 -0700154struct global_data;
155
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100156/**
157 * arch_setup_gd() - Set up the global_data pointer
Mario Sixdc145a72018-08-06 10:23:40 +0200158 * @gd_ptr: Pointer to global data
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100159 *
160 * This pointer is special in some architectures and cannot easily be assigned
161 * to. For example on x86 it is implemented by adding a specific record to its
162 * Global Descriptor Table! So we we provide a function to carry out this task.
163 * For most architectures this can simply be:
164 *
165 * gd = gd_ptr;
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100166 */
Simon Glass67c4e9f2019-11-14 12:57:45 -0700167void arch_setup_gd(struct global_data *gd_ptr);
Patrick Delaunay11f86cb2018-03-13 13:57:01 +0100168
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100169/* common/board_r.c */
Simon Glass67c4e9f2019-11-14 12:57:45 -0700170void board_init_r(struct global_data *id, ulong dest_addr)
171 __attribute__ ((noreturn));
Patrick Delaunaye2c219c2018-03-13 13:57:02 +0100172
173int cpu_init_r(void);
174int last_stage_init(void);
175int mac_read_from_eeprom(void);
176int set_cpu_clk_info(void);
177int update_flash_size(int flash_size);
178int arch_early_init_r(void);
179void pci_init(void);
180int misc_init_r(void);
181#if defined(CONFIG_VID)
182int init_func_vid(void);
183#endif
184
Patrick Delaunayfc22ee22018-03-13 13:57:03 +0100185/* common/board_info.c */
186int checkboard(void);
187int show_board_info(void);
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100188
Simon Glass67c4e9f2019-11-14 12:57:45 -0700189/**
190 * Get the uppermost pointer that is valid to access
191 *
192 * Some systems may not map all of their address space. This function allows
193 * boards to indicate what their highest support pointer value is for DRAM
194 * access.
195 *
196 * @param total_size Size of U-Boot (unused?)
197 */
198ulong board_get_usable_ram_top(ulong total_size);
199
Simon Glass52559322019-11-14 12:57:46 -0700200int board_early_init_f(void);
201
202/* manipulate the U-Boot fdt before its relocation */
203int board_fix_fdt(void *rw_fdt_blob);
204int board_late_init(void);
205int board_postclk_init(void); /* after clocks/timebase, before env/serial */
206int board_early_init_r(void);
207
Simon Glass2cf431c2019-11-14 12:57:47 -0700208/* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */
209void pci_init_board(void);
210
Simon Glassd67bdaa2019-11-14 12:57:48 -0700211void trap_init(unsigned long reloc_addr);
212
Patrick Delaunaydafa84d2018-03-09 18:28:12 +0100213#endif /* __ASSEMBLY__ */
214/* Put only stuff here that the assembler can digest */
215
216#endif /* __INIT_H_ */