init.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. #include <linux/types.h>
  12. #ifndef __ASSEMBLY__ /* put C only stuff in this section */
  13. /*
  14. * Function Prototypes
  15. */
  16. /* common/board_f.c */
  17. void board_init_f(ulong dummy);
  18. /**
  19. * arch_cpu_init() - basic cpu-dependent setup for an architecture
  20. *
  21. * This is called after early malloc is available. It should handle any
  22. * CPU- or SoC- specific init needed to continue the init sequence. See
  23. * board_f.c for where it is called. If this is not provided, a default
  24. * version (which does nothing) will be used.
  25. *
  26. * Return: 0 on success, otherwise error
  27. */
  28. int arch_cpu_init(void);
  29. /**
  30. * arch_cpu_init_dm() - init CPU after driver model is available
  31. *
  32. * This is called immediately after driver model is available before
  33. * relocation. This is similar to arch_cpu_init() but is able to reference
  34. * devices
  35. *
  36. * Return: 0 if OK, -ve on error
  37. */
  38. int arch_cpu_init_dm(void);
  39. /**
  40. * mach_cpu_init() - SoC/machine dependent CPU setup
  41. *
  42. * This is called after arch_cpu_init(). It should handle any
  43. * SoC or machine specific init needed to continue the init sequence. See
  44. * board_f.c for where it is called. If this is not provided, a default
  45. * version (which does nothing) will be used.
  46. *
  47. * Return: 0 on success, otherwise error
  48. */
  49. int mach_cpu_init(void);
  50. /**
  51. * arch_fsp_init() - perform firmware support package init
  52. *
  53. * Where U-Boot relies on binary blobs to handle part of the system init, this
  54. * function can be used to set up the blobs. This is used on some Intel
  55. * platforms.
  56. *
  57. * Return: 0
  58. */
  59. int arch_fsp_init(void);
  60. int dram_init(void);
  61. /**
  62. * dram_init_banksize() - Set up DRAM bank sizes
  63. *
  64. * This can be implemented by boards to set up the DRAM bank information in
  65. * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
  66. * is called.
  67. *
  68. * If this is not provided, a default implementation will try to set up a
  69. * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
  70. * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of
  71. * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to
  72. * get_effective_memsize().
  73. *
  74. * Return: 0 if OK, -ve on error
  75. */
  76. int dram_init_banksize(void);
  77. /**
  78. * arch_reserve_stacks() - Reserve all necessary stacks
  79. *
  80. * This is used in generic board init sequence in common/board_f.c. Each
  81. * architecture could provide this function to tailor the required stacks.
  82. *
  83. * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
  84. * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
  85. * require only this can leave it untouched.
  86. *
  87. * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
  88. * positions of the stack. The stack pointer(s) will be set to this later.
  89. * gd->irq_sp is only required, if the architecture needs it.
  90. *
  91. * Return: 0 if no error
  92. */
  93. int arch_reserve_stacks(void);
  94. /**
  95. * init_cache_f_r() - Turn on the cache in preparation for relocation
  96. *
  97. * Return: 0 if OK, -ve on error
  98. */
  99. int init_cache_f_r(void);
  100. #if !CONFIG_IS_ENABLED(CPU)
  101. /**
  102. * print_cpuinfo() - Display information about the CPU
  103. *
  104. * Return: 0 if OK, -ve on error
  105. */
  106. int print_cpuinfo(void);
  107. #endif
  108. int timer_init(void);
  109. int reserve_mmu(void);
  110. int misc_init_f(void);
  111. #if defined(CONFIG_DTB_RESELECT)
  112. int embedded_dtb_select(void);
  113. #endif
  114. /* common/init/board_init.c */
  115. extern ulong monitor_flash_len;
  116. /**
  117. * ulong board_init_f_alloc_reserve - allocate reserved area
  118. * @top: top of the reserve area, growing down.
  119. *
  120. * This function is called by each architecture very early in the start-up
  121. * code to allow the C runtime to reserve space on the stack for writable
  122. * 'globals' such as GD and the malloc arena.
  123. *
  124. * Return: bottom of reserved area
  125. */
  126. ulong board_init_f_alloc_reserve(ulong top);
  127. /**
  128. * board_init_f_init_reserve - initialize the reserved area(s)
  129. * @base: top from which reservation was done
  130. *
  131. * This function is called once the C runtime has allocated the reserved
  132. * area on the stack. It must initialize the GD at the base of that area.
  133. */
  134. void board_init_f_init_reserve(ulong base);
  135. struct global_data;
  136. /**
  137. * arch_setup_gd() - Set up the global_data pointer
  138. * @gd_ptr: Pointer to global data
  139. *
  140. * This pointer is special in some architectures and cannot easily be assigned
  141. * to. For example on x86 it is implemented by adding a specific record to its
  142. * Global Descriptor Table! So we we provide a function to carry out this task.
  143. * For most architectures this can simply be:
  144. *
  145. * gd = gd_ptr;
  146. */
  147. void arch_setup_gd(struct global_data *gd_ptr);
  148. /* common/board_r.c */
  149. void board_init_r(struct global_data *id, ulong dest_addr)
  150. __attribute__ ((noreturn));
  151. int cpu_init_r(void);
  152. int last_stage_init(void);
  153. int mac_read_from_eeprom(void);
  154. int set_cpu_clk_info(void);
  155. int update_flash_size(int flash_size);
  156. int arch_early_init_r(void);
  157. void pci_init(void);
  158. int misc_init_r(void);
  159. #if defined(CONFIG_VID)
  160. int init_func_vid(void);
  161. #endif
  162. /* common/board_info.c */
  163. int checkboard(void);
  164. int show_board_info(void);
  165. /**
  166. * Get the uppermost pointer that is valid to access
  167. *
  168. * Some systems may not map all of their address space. This function allows
  169. * boards to indicate what their highest support pointer value is for DRAM
  170. * access.
  171. *
  172. * @param total_size Size of U-Boot (unused?)
  173. */
  174. ulong board_get_usable_ram_top(ulong total_size);
  175. int board_early_init_f(void);
  176. /* manipulate the U-Boot fdt before its relocation */
  177. int board_fix_fdt(void *rw_fdt_blob);
  178. int board_late_init(void);
  179. int board_postclk_init(void); /* after clocks/timebase, before env/serial */
  180. int board_early_init_r(void);
  181. /* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */
  182. void pci_init_board(void);
  183. void trap_init(unsigned long reloc_addr);
  184. #endif /* __ASSEMBLY__ */
  185. /* Put only stuff here that the assembler can digest */
  186. #endif /* __INIT_H_ */