Blame view

include/init.h 6.97 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  /* SPDX-License-Identifier: GPL-2.0+ */
dafa84d27   Patrick Delaunay   common: add a pro...
2
3
4
5
6
7
  /*
   * (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
dafa84d27   Patrick Delaunay   common: add a pro...
8
9
10
11
   */
  
  #ifndef __INIT_H_
  #define __INIT_H_	1
67c4e9f81   Simon Glass   common: Move boar...
12
  #include <linux/types.h>
941338725   Simon Glass   common: Move relo...
13
  struct global_data;
dafa84d27   Patrick Delaunay   common: add a pro...
14
  #ifndef __ASSEMBLY__		/* put C only stuff in this section */
35a3f871f   Simon Glass   common: Move ll_b...
15
16
17
18
19
20
  /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
  #ifdef CONFIG_EFI_STUB
  #define ll_boot_init()	false
  #else
  #define ll_boot_init()	true
  #endif
dafa84d27   Patrick Delaunay   common: add a pro...
21
22
23
24
25
  /*
   * Function Prototypes
   */
  
  /* common/board_f.c */
d6f877123   Patrick Delaunay   common: move boar...
26
  void board_init_f(ulong dummy);
dafa84d27   Patrick Delaunay   common: add a pro...
27
28
29
30
31
32
33
34
35
  
  /**
   * 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.
   *
dc145a7be   Mario Six   init: Fix documen...
36
   * Return: 0 on success, otherwise error
dafa84d27   Patrick Delaunay   common: add a pro...
37
38
39
40
   */
  int arch_cpu_init(void);
  
  /**
d6f877123   Patrick Delaunay   common: move boar...
41
42
43
44
45
46
   * arch_cpu_init_dm() - init CPU after driver model is available
   *
   * This is called immediately after driver model is available before
   * relocation. This is similar to arch_cpu_init() but is able to reference
   * devices
   *
dc145a7be   Mario Six   init: Fix documen...
47
   * Return: 0 if OK, -ve on error
d6f877123   Patrick Delaunay   common: move boar...
48
49
50
51
   */
  int arch_cpu_init_dm(void);
  
  /**
dafa84d27   Patrick Delaunay   common: add a pro...
52
53
54
55
56
57
58
   * 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.
   *
dc145a7be   Mario Six   init: Fix documen...
59
   * Return: 0 on success, otherwise error
dafa84d27   Patrick Delaunay   common: add a pro...
60
61
   */
  int mach_cpu_init(void);
d6f877123   Patrick Delaunay   common: move boar...
62
63
64
65
66
67
  /**
   * 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.
dc145a7be   Mario Six   init: Fix documen...
68
69
   *
   * Return: 0
d6f877123   Patrick Delaunay   common: move boar...
70
71
   */
  int arch_fsp_init(void);
fe08d39d1   Simon Glass   x86: fsp: Add a n...
72
73
74
75
76
77
78
79
80
81
  /**
   * 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);
d6f877123   Patrick Delaunay   common: move boar...
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  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
   * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of
   * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to
   * get_effective_memsize().
   *
dc145a7be   Mario Six   init: Fix documen...
97
   * Return: 0 if OK, -ve on error
d6f877123   Patrick Delaunay   common: move boar...
98
99
   */
  int dram_init_banksize(void);
9b4a205f4   Simon Glass   common: Move RAM-...
100
101
  long get_ram_size(long *base, long size);
  phys_size_t get_effective_memsize(void);
49acd56e4   Simon Glass   common: Move test...
102
  int testdram(void);
d6f877123   Patrick Delaunay   common: move boar...
103
  /**
dc145a7be   Mario Six   init: Fix documen...
104
   * arch_reserve_stacks() - Reserve all necessary stacks
d6f877123   Patrick Delaunay   common: move boar...
105
106
107
108
109
110
111
112
113
114
115
116
   *
   * 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.
   *
dc145a7be   Mario Six   init: Fix documen...
117
   * Return: 0 if no error
d6f877123   Patrick Delaunay   common: move boar...
118
119
   */
  int arch_reserve_stacks(void);
b8aa55cb6   Patrick Delaunay   common: move init...
120
121
122
  /**
   * init_cache_f_r() - Turn on the cache in preparation for relocation
   *
dc145a7be   Mario Six   init: Fix documen...
123
   * Return: 0 if OK, -ve on error
b8aa55cb6   Patrick Delaunay   common: move init...
124
125
   */
  int init_cache_f_r(void);
5d6c61ac4   Mario Six   board_f: Use stat...
126
127
128
129
130
131
  #if !CONFIG_IS_ENABLED(CPU)
  /**
   * print_cpuinfo() - Display information about the CPU
   *
   * Return: 0 if OK, -ve on error
   */
d6f877123   Patrick Delaunay   common: move boar...
132
  int print_cpuinfo(void);
5d6c61ac4   Mario Six   board_f: Use stat...
133
  #endif
d6f877123   Patrick Delaunay   common: move boar...
134
135
136
  int timer_init(void);
  int reserve_mmu(void);
  int misc_init_f(void);
dc145a7be   Mario Six   init: Fix documen...
137

d6f877123   Patrick Delaunay   common: move boar...
138
139
140
  #if defined(CONFIG_DTB_RESELECT)
  int embedded_dtb_select(void);
  #endif
11f86cbaf   Patrick Delaunay   common: move boar...
141
142
143
144
145
  /* common/init/board_init.c */
  extern ulong monitor_flash_len;
  
  /**
   * ulong board_init_f_alloc_reserve - allocate reserved area
dc145a7be   Mario Six   init: Fix documen...
146
   * @top: top of the reserve area, growing down.
11f86cbaf   Patrick Delaunay   common: move boar...
147
148
149
150
151
   *
   * 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.
   *
dc145a7be   Mario Six   init: Fix documen...
152
   * Return: bottom of reserved area
11f86cbaf   Patrick Delaunay   common: move boar...
153
154
155
156
157
   */
  ulong board_init_f_alloc_reserve(ulong top);
  
  /**
   * board_init_f_init_reserve - initialize the reserved area(s)
dc145a7be   Mario Six   init: Fix documen...
158
   * @base:	top from which reservation was done
11f86cbaf   Patrick Delaunay   common: move boar...
159
160
161
   *
   * 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.
11f86cbaf   Patrick Delaunay   common: move boar...
162
163
   */
  void board_init_f_init_reserve(ulong base);
67c4e9f81   Simon Glass   common: Move boar...
164
  struct global_data;
11f86cbaf   Patrick Delaunay   common: move boar...
165
166
  /**
   * arch_setup_gd() - Set up the global_data pointer
dc145a7be   Mario Six   init: Fix documen...
167
   * @gd_ptr: Pointer to global data
11f86cbaf   Patrick Delaunay   common: move boar...
168
169
170
171
172
173
174
   *
   * 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;
11f86cbaf   Patrick Delaunay   common: move boar...
175
   */
67c4e9f81   Simon Glass   common: Move boar...
176
  void arch_setup_gd(struct global_data *gd_ptr);
11f86cbaf   Patrick Delaunay   common: move boar...
177

dafa84d27   Patrick Delaunay   common: add a pro...
178
  /* common/board_r.c */
67c4e9f81   Simon Glass   common: Move boar...
179
180
  void board_init_r(struct global_data *id, ulong dest_addr)
  	__attribute__ ((noreturn));
e2c219cd7   Patrick Delaunay   common: move boar...
181
182
183
184
185
186
187
188
189
190
191
192
  
  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);
  void pci_init(void);
  int misc_init_r(void);
  #if defined(CONFIG_VID)
  int init_func_vid(void);
  #endif
fc22ee215   Patrick Delaunay   common: move boar...
193
194
195
  /* common/board_info.c */
  int checkboard(void);
  int show_board_info(void);
dafa84d27   Patrick Delaunay   common: add a pro...
196

a2018ab0d   Ye Li   MLK-18591-3 andro...
197
198
199
  #ifdef CONFIG_ANDROID_BOOT_IMAGE
  void get_reboot_reason(char *ret);
  #endif
67c4e9f81   Simon Glass   common: Move boar...
200
201
202
203
204
205
206
207
208
209
  /**
   * Get the uppermost pointer that is valid to access
   *
   * Some systems may not map all of their address space. This function allows
   * boards to indicate what their highest support pointer value is for DRAM
   * access.
   *
   * @param total_size	Size of U-Boot (unused?)
   */
  ulong board_get_usable_ram_top(ulong total_size);
5255932f0   Simon Glass   common: Move some...
210
211
212
213
214
215
216
  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);
2cf431c22   Simon Glass   common: Move pci_...
217
218
  /* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */
  void pci_init_board(void);
d67bdaa79   Simon Glass   common: Move trap...
219
  void trap_init(unsigned long reloc_addr);
6b8d3ceaf   Simon Glass   common: Move main...
220
221
222
223
224
225
  /**
   * main_loop() - Enter the main loop of U-Boot
   *
   * This normally runs the command line.
   */
  void main_loop(void);
941338725   Simon Glass   common: Move relo...
226
227
228
229
230
231
232
  #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
dafa84d27   Patrick Delaunay   common: add a pro...
233
234
235
236
  #endif	/* __ASSEMBLY__ */
  /* Put only stuff here that the assembler can digest */
  
  #endif	/* __INIT_H_ */