~funderscore blog cgit wiki get in touch
aboutsummaryrefslogtreecommitdiff
blob: 3bf30476a2e0d613564494953c15af36f63f9145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * (C) Copyright 2000-2009
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * Copy the startup prototype, previously defined in common.h
 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
 */

#ifndef __INIT_H_
#define __INIT_H_	1

#ifndef __ASSEMBLY__		/* put C only stuff in this section */

#include <linux/types.h>

/*
 * In case of the EFI app the UEFI firmware provides the low-level
 * initialisation.
 */
#ifdef CONFIG_EFI
#define ll_boot_init()	false
#else
#include <asm/global_data.h>

#define ll_boot_init()	(!(gd->flags & GD_FLG_SKIP_LL_INIT))
#endif

/*
 * Function Prototypes
 */

/* common/board_f.c */
void board_init_f(ulong dummy);

/**
 * arch_cpu_init() - basic cpu-dependent setup for an architecture
 *
 * This is called after early malloc is available. It should handle any
 * CPU- or SoC- specific init needed to continue the init sequence. See
 * board_f.c for where it is called. If this is not provided, a default
 * version (which does nothing) will be used.
 *
 * Return: 0 on success, otherwise error
 */
int arch_cpu_init(void);

/**
 * mach_cpu_init() - SoC/machine dependent CPU setup
 *
 * This is called after arch_cpu_init(). It should handle any
 * SoC or machine specific init needed to continue the init sequence. See
 * board_f.c for where it is called. If this is not provided, a default
 * version (which does nothing) will be used.
 *
 * Return: 0 on success, otherwise error
 */
int mach_cpu_init(void);

/**
 * arch_fsp_init() - perform firmware support package init
 *
 * Where U-Boot relies on binary blobs to handle part of the system init, this
 * function can be used to set up the blobs. This is used on some Intel
 * platforms.
 *
 * Return: 0
 */
int arch_fsp_init(void);

/**
 * arch_fsp_init() - perform post-relocation firmware support package init
 *
 * Where U-Boot relies on binary blobs to handle part of the system init, this
 * function can be used to set up the blobs. This is used on some Intel
 * platforms.
 *
 * Return: 0
 */
int arch_fsp_init_r(void);

int dram_init(void);

/**
 * dram_init_banksize() - Set up DRAM bank sizes
 *
 * This can be implemented by boards to set up the DRAM bank information in
 * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
 * is called.
 *
 * If this is not provided, a default implementation will try to set up a
 * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
 * CFG_SYS_SDRAM_BASE are set. The bank will have a start address of
 * CFG_SYS_SDRAM_BASE and the size will be determined by a call to
 * get_effective_memsize().
 *
 * Return: 0 if OK, -ve on error
 */
int dram_init_banksize(void);

long get_ram_size(long *base, long size);
phys_size_t get_effective_memsize(void);

int testdram(void);

/**
 * arch_setup_dest_addr() - Fix up initial reloc address
 *
 * This is called in generic board init sequence in common/board_f.c at the end
 * of the setup_dest_addr() initcall. Each architecture could provide this
 * function to make adjustments to the initial reloc address.
 *
 * If an implementation is not provided, it will just be a nop stub.
 *
 * Return: 0 if OK
 */
int arch_setup_dest_addr(void);

/**
 * arch_reserve_stacks() - Reserve all necessary stacks
 *
 * This is used in generic board init sequence in common/board_f.c. Each
 * architecture could provide this function to tailor the required stacks.
 *
 * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
 * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
 * require only this can leave it untouched.
 *
 * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
 * positions of the stack. The stack pointer(s) will be set to this later.
 * gd->irq_sp is only required, if the architecture needs it.
 *
 * Return: 0 if no error
 */
int arch_reserve_stacks(void);

/**
 * arch_reserve_mmu() - Reserve memory for MMU TLB table
 *
 * Architecture-specific routine for reserving memory for the MMU TLB table.
 * This is used in generic board init sequence in common/board_f.c.
 *
 * If an implementation is not provided, it will just be a nop stub.
 *
 * Return: 0 if OK
 */
int arch_reserve_mmu(void);

/**
 * arch_setup_bdinfo() - Architecture dependent boardinfo setup
 *
 * Architecture-specific routine for populating various boardinfo fields of
 * gd->bd. It is called during the generic board init sequence.
 *
 * If an implementation is not provided, it will just be a nop stub.
 *
 * Return: 0 if OK
 */
int arch_setup_bdinfo(void);

/**
 * setup_bdinfo() - Generic boardinfo setup
 *
 * Routine for populating various generic boardinfo fields of
 * gd->bd. It is called during the generic board init sequence.
 *
 * Return: 0 if OK
 */
int setup_bdinfo(void);

#if defined(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) || \
defined(CONFIG_SAVE_PREV_BL_FDT_ADDR)
/**
 * save_prev_bl_data - Save prev bl data in env vars.
 *
 * When u-boot is chain-loaded, save previous bootloader data,
 * like initramfs address to environment variables.
 *
 * Return: 0 if ok; -ENODATA on error
 */
int save_prev_bl_data(void);
#endif

/**
 * cpu_secondary_init_r() - CPU-specific secondary initialization
 *
 * After non-volatile devices, environment and cpu code are setup, have
 * another round to deal with any initialization that might require
 * full access to the environment or loading of some image (firmware)
 * from a non-volatile device.
 *
 * It is called during the generic post-relocation init sequence.
 *
 * Return: 0 if OK
 */
int cpu_secondary_init_r(void);

/**
 * pci_ep_init() - Initialize pci endpoint devices
 *
 * It is called during the generic post-relocation init sequence.
 *
 * Return: 0 if OK
 */
int pci_ep_init(void);

/**
 * pci_init() - Enumerate pci devices
 *
 * It is called during the generic post-relocation init sequence to enumerate
 * pci buses. This is needed, for instance, in the case of DM PCI-based
 * Ethernet devices, which will not be detected without having the enumeration
 * performed earlier.
 *
 * Return: 0 if OK
 */
int pci_init(void);

/**
 * init_cache_f_r() - Turn on the cache in preparation for relocation
 *
 * Return: 0 if OK, -ve on error
 */
int init_cache_f_r(void);

#if !CONFIG_IS_ENABLED(CPU)
/**
 * print_cpuinfo() - Display information about the CPU
 *
 * Return: 0 if OK, -ve on error
 */
int print_cpuinfo(void);
#endif
int timer_init(void);

#if defined(CONFIG_DTB_RESELECT)
int embedded_dtb_select(void);
#endif

/* common/init/board_init.c */
extern ulong monitor_flash_len;

/**
 * ulong board_init_f_alloc_reserve - allocate reserved area
 * @top: top of the reserve area, growing down.
 *
 * This function is called by each architecture very early in the start-up
 * code to allow the C runtime to reserve space on the stack for writable
 * 'globals' such as GD and the malloc arena.
 *
 * Return: bottom of reserved area
 */
ulong board_init_f_alloc_reserve(ulong top);

/**
 * board_init_f_init_reserve - initialize the reserved area(s)
 * @base:	top from which reservation was done
 *
 * This function is called once the C runtime has allocated the reserved
 * area on the stack. It must initialize the GD at the base of that area.
 */
void board_init_f_init_reserve(ulong base);

struct global_data;

/**
 * arch_setup_gd() - Set up the global_data pointer
 * @gd_ptr: Pointer to global data
 *
 * This pointer is special in some architectures and cannot easily be assigned
 * to. For example on x86 it is implemented by adding a specific record to its
 * Global Descriptor Table! So we we provide a function to carry out this task.
 * For most architectures this can simply be:
 *
 *    gd = gd_ptr;
 */
void arch_setup_gd(struct global_data *gd_ptr);

/* common/board_r.c */
void board_init_r(struct global_data *id, ulong dest_addr)
	__attribute__ ((noreturn));

int cpu_init_r(void);
int last_stage_init(void);
int mac_read_from_eeprom(void);
int set_cpu_clk_info(void);
int update_flash_size(int flash_size);
int arch_early_init_r(void);
int misc_init_r(void);
#if defined(CONFIG_VID)
int init_func_vid(void);
#endif

/* common/board_info.c */
int checkboard(void);
int show_board_info(void);

/**
 * board_get_usable_ram_top() - get uppermost address for U-Boot relocation
 *
 * Some systems have reserved memory areas in high memory. By implementing this
 * function boards can indicate the highest address value to be used when
 * relocating U-Boot. The returned address is exclusive (i.e. 1 byte above the
 * last usable address).
 *
 * Due to overflow on systems with 32bit phys_addr_t a value 0 is used instead
 * of 4GiB.
 *
 * @total_size:	monitor length in bytes (size of U-Boot code)
 * Return:	uppermost address for U-Boot relocation
 */
phys_addr_t board_get_usable_ram_top(phys_size_t total_size);

int board_early_init_f(void);

/* manipulate the U-Boot fdt before its relocation */
int board_fix_fdt(void *rw_fdt_blob);
int board_late_init(void);
int board_postclk_init(void); /* after clocks/timebase, before env/serial */
int board_early_init_r(void);

/**
 * arch_initr_trap() - Init traps
 *
 * Arch specific routine for initializing traps. It is called during the
 * generic board init sequence, after relocation.
 *
 * Return: 0 if OK
 */
int arch_initr_trap(void);

/**
 * init_addr_map()
 *
 * Initialize non-identity virtual-physical memory mappings for 32bit CPUs.
 * It is called during the generic board init sequence, after relocation.
 *
 * Return: 0 if OK
 */
int init_addr_map(void);

/**
 * main_loop() - Enter the main loop of U-Boot
 *
 * This normally runs the command line.
 */
void main_loop(void);

#if defined(CONFIG_ARM)
void relocate_code(ulong addr_moni);
#else
void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
		   ulong relocaddr)
	__attribute__ ((noreturn));
#endif

/* Print a numeric value (for use in arch_print_bdinfo()) */
void bdinfo_print_num_l(const char *name, ulong value);
void bdinfo_print_num_ll(const char *name, unsigned long long value);

/* Print a string value (for use in arch_print_bdinfo()) */
void bdinfo_print_str(const char *name, const char *str);

/* Print a clock speed in MHz */
void bdinfo_print_mhz(const char *name, unsigned long hz);

/**
 * bdinfo_print_size - print size variables in bdinfo format
 * @name:	string to print before the size
 * @size:	size to print
 *
 * Helper function for displaying size variables as properly formatted bdinfo
 * entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
 * "xxx GiB", etc. as needed;
 *
 * For use in arch_print_bdinfo().
 */
void bdinfo_print_size(const char *name, uint64_t size);

/* Show arch-specific information for the 'bd' command */
void arch_print_bdinfo(void);

int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);

#endif	/* __ASSEMBLY__ */
/* Put only stuff here that the assembler can digest */

#endif	/* __INIT_H_ */