init.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  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
  8. */
  9. #ifndef __INIT_H_
  10. #define __INIT_H_ 1
  11. #ifndef __ASSEMBLY__ /* put C only stuff in this section */
  12. #include <linux/types.h>
  13. /*
  14. * In case of the EFI app the UEFI firmware provides the low-level
  15. * initialisation.
  16. */
  17. #ifdef CONFIG_EFI
  18. #define ll_boot_init() false
  19. #else
  20. #include <asm/global_data.h>
  21. #define ll_boot_init() (!(gd->flags & GD_FLG_SKIP_LL_INIT))
  22. #endif
  23. /*
  24. * Function Prototypes
  25. */
  26. /* common/board_f.c */
  27. void board_init_f(ulong dummy);
  28. /**
  29. * arch_cpu_init() - basic cpu-dependent setup for an architecture
  30. *
  31. * This is called after early malloc is available. It should handle any
  32. * CPU- or SoC- specific init needed to continue the init sequence. See
  33. * board_f.c for where it is called. If this is not provided, a default
  34. * version (which does nothing) will be used.
  35. *
  36. * Return: 0 on success, otherwise error
  37. */
  38. int arch_cpu_init(void);
  39. /**
  40. * arch_cpu_init_dm() - init CPU after driver model is available
  41. *
  42. * This is called immediately after driver model is available before
  43. * relocation. This is similar to arch_cpu_init() but is able to reference
  44. * devices
  45. *
  46. * Return: 0 if OK, -ve on error
  47. */
  48. int arch_cpu_init_dm(void);
  49. /**
  50. * 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. *
  57. * Return: 0 on success, otherwise error
  58. */
  59. int mach_cpu_init(void);
  60. /**
  61. * arch_fsp_init() - perform firmware support package init
  62. *
  63. * Where U-Boot relies on binary blobs to handle part of the system init, this
  64. * function can be used to set up the blobs. This is used on some Intel
  65. * platforms.
  66. *
  67. * Return: 0
  68. */
  69. int arch_fsp_init(void);
  70. /**
  71. * arch_fsp_init() - perform post-relocation firmware support package init
  72. *
  73. * Where U-Boot relies on binary blobs to handle part of the system init, this
  74. * function can be used to set up the blobs. This is used on some Intel
  75. * platforms.
  76. *
  77. * Return: 0
  78. */
  79. int arch_fsp_init_r(void);
  80. int dram_init(void);
  81. /**
  82. * dram_init_banksize() - Set up DRAM bank sizes
  83. *
  84. * This can be implemented by boards to set up the DRAM bank information in
  85. * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
  86. * is called.
  87. *
  88. * If this is not provided, a default implementation will try to set up a
  89. * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
  90. * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of
  91. * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to
  92. * get_effective_memsize().
  93. *
  94. * Return: 0 if OK, -ve on error
  95. */
  96. int dram_init_banksize(void);
  97. long get_ram_size(long *base, long size);
  98. phys_size_t get_effective_memsize(void);
  99. int testdram(void);
  100. /**
  101. * arch_reserve_stacks() - Reserve all necessary stacks
  102. *
  103. * This is used in generic board init sequence in common/board_f.c. Each
  104. * architecture could provide this function to tailor the required stacks.
  105. *
  106. * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
  107. * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
  108. * require only this can leave it untouched.
  109. *
  110. * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
  111. * positions of the stack. The stack pointer(s) will be set to this later.
  112. * gd->irq_sp is only required, if the architecture needs it.
  113. *
  114. * Return: 0 if no error
  115. */
  116. int arch_reserve_stacks(void);
  117. /**
  118. * arch_reserve_mmu() - Reserve memory for MMU TLB table
  119. *
  120. * Architecture-specific routine for reserving memory for the MMU TLB table.
  121. * This is used in generic board init sequence in common/board_f.c.
  122. *
  123. * If an implementation is not provided, it will just be a nop stub.
  124. *
  125. * Return: 0 if OK
  126. */
  127. int arch_reserve_mmu(void);
  128. /**
  129. * arch_setup_bdinfo() - Architecture dependent boardinfo setup
  130. *
  131. * Architecture-specific routine for populating various boardinfo fields of
  132. * gd->bd. It is called during the generic board init sequence.
  133. *
  134. * If an implementation is not provided, it will just be a nop stub.
  135. *
  136. * Return: 0 if OK
  137. */
  138. int arch_setup_bdinfo(void);
  139. /**
  140. * setup_bdinfo() - Generic boardinfo setup
  141. *
  142. * Routine for populating various generic boardinfo fields of
  143. * gd->bd. It is called during the generic board init sequence.
  144. *
  145. * Return: 0 if OK
  146. */
  147. int setup_bdinfo(void);
  148. /**
  149. * cpu_secondary_init_r() - CPU-specific secondary initialization
  150. *
  151. * After non-volatile devices, environment and cpu code are setup, have
  152. * another round to deal with any initialization that might require
  153. * full access to the environment or loading of some image (firmware)
  154. * from a non-volatile device.
  155. *
  156. * It is called during the generic post-relocation init sequence.
  157. *
  158. * Return: 0 if OK
  159. */
  160. int cpu_secondary_init_r(void);
  161. /**
  162. * pci_ep_init() - Initialize pci endpoint devices
  163. *
  164. * It is called during the generic post-relocation init sequence.
  165. *
  166. * Return: 0 if OK
  167. */
  168. int pci_ep_init(void);
  169. /**
  170. * pci_init() - Enumerate pci devices
  171. *
  172. * It is called during the generic post-relocation init sequence to enumerate
  173. * pci buses. This is needed, for instance, in the case of DM PCI-based
  174. * Ethernet devices, which will not be detected without having the enumeration
  175. * performed earlier.
  176. *
  177. * Return: 0 if OK
  178. */
  179. int pci_init(void);
  180. /**
  181. * init_cache_f_r() - Turn on the cache in preparation for relocation
  182. *
  183. * Return: 0 if OK, -ve on error
  184. */
  185. int init_cache_f_r(void);
  186. #if !CONFIG_IS_ENABLED(CPU)
  187. /**
  188. * print_cpuinfo() - Display information about the CPU
  189. *
  190. * Return: 0 if OK, -ve on error
  191. */
  192. int print_cpuinfo(void);
  193. #endif
  194. int timer_init(void);
  195. int misc_init_f(void);
  196. #if defined(CONFIG_DTB_RESELECT)
  197. int embedded_dtb_select(void);
  198. #endif
  199. /* common/init/board_init.c */
  200. extern ulong monitor_flash_len;
  201. /**
  202. * ulong board_init_f_alloc_reserve - allocate reserved area
  203. * @top: top of the reserve area, growing down.
  204. *
  205. * This function is called by each architecture very early in the start-up
  206. * code to allow the C runtime to reserve space on the stack for writable
  207. * 'globals' such as GD and the malloc arena.
  208. *
  209. * Return: bottom of reserved area
  210. */
  211. ulong board_init_f_alloc_reserve(ulong top);
  212. /**
  213. * board_init_f_init_reserve - initialize the reserved area(s)
  214. * @base: top from which reservation was done
  215. *
  216. * This function is called once the C runtime has allocated the reserved
  217. * area on the stack. It must initialize the GD at the base of that area.
  218. */
  219. void board_init_f_init_reserve(ulong base);
  220. struct global_data;
  221. /**
  222. * arch_setup_gd() - Set up the global_data pointer
  223. * @gd_ptr: Pointer to global data
  224. *
  225. * This pointer is special in some architectures and cannot easily be assigned
  226. * to. For example on x86 it is implemented by adding a specific record to its
  227. * Global Descriptor Table! So we we provide a function to carry out this task.
  228. * For most architectures this can simply be:
  229. *
  230. * gd = gd_ptr;
  231. */
  232. void arch_setup_gd(struct global_data *gd_ptr);
  233. /* common/board_r.c */
  234. void board_init_r(struct global_data *id, ulong dest_addr)
  235. __attribute__ ((noreturn));
  236. int cpu_init_r(void);
  237. int last_stage_init(void);
  238. int mac_read_from_eeprom(void);
  239. int set_cpu_clk_info(void);
  240. int update_flash_size(int flash_size);
  241. int arch_early_init_r(void);
  242. int misc_init_r(void);
  243. #if defined(CONFIG_VID)
  244. int init_func_vid(void);
  245. #endif
  246. /* common/board_info.c */
  247. int checkboard(void);
  248. int show_board_info(void);
  249. /**
  250. * Get the uppermost pointer that is valid to access
  251. *
  252. * Some systems may not map all of their address space. This function allows
  253. * boards to indicate what their highest support pointer value is for DRAM
  254. * access.
  255. *
  256. * @param total_size Size of U-Boot (unused?)
  257. */
  258. ulong board_get_usable_ram_top(ulong total_size);
  259. int board_early_init_f(void);
  260. /* manipulate the U-Boot fdt before its relocation */
  261. int board_fix_fdt(void *rw_fdt_blob);
  262. int board_late_init(void);
  263. int board_postclk_init(void); /* after clocks/timebase, before env/serial */
  264. int board_early_init_r(void);
  265. /**
  266. * arch_initr_trap() - Init traps
  267. *
  268. * Arch specific routine for initializing traps. It is called during the
  269. * generic board init sequence, after relocation.
  270. *
  271. * Return: 0 if OK
  272. */
  273. int arch_initr_trap(void);
  274. /**
  275. * init_addr_map()
  276. *
  277. * Initialize non-identity virtual-physical memory mappings for 32bit CPUs.
  278. * It is called during the generic board init sequence, after relocation.
  279. *
  280. * Return: 0 if OK
  281. */
  282. int init_addr_map(void);
  283. /**
  284. * main_loop() - Enter the main loop of U-Boot
  285. *
  286. * This normally runs the command line.
  287. */
  288. void main_loop(void);
  289. #if defined(CONFIG_ARM)
  290. void relocate_code(ulong addr_moni);
  291. #else
  292. void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
  293. ulong relocaddr)
  294. __attribute__ ((noreturn));
  295. #endif
  296. /* Print a numeric value (for use in arch_print_bdinfo()) */
  297. void bdinfo_print_num_l(const char *name, ulong value);
  298. void bdinfo_print_num_ll(const char *name, unsigned long long value);
  299. /* Print a clock speed in MHz */
  300. void bdinfo_print_mhz(const char *name, unsigned long hz);
  301. /* Show arch-specific information for the 'bd' command */
  302. void arch_print_bdinfo(void);
  303. int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
  304. #endif /* __ASSEMBLY__ */
  305. /* Put only stuff here that the assembler can digest */
  306. #endif /* __INIT_H_ */