Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 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 |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __INIT_H_ |
| 11 | #define __INIT_H_ 1 |
| 12 | |
Simon Glass | 6980b6b | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 13 | #include <linux/types.h> |
| 14 | |
Simon Glass | 284f71b | 2019-12-28 10:44:45 -0700 | [diff] [blame] | 15 | struct global_data; |
| 16 | |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 17 | #ifndef __ASSEMBLY__ /* put C only stuff in this section */ |
| 18 | |
Simon Glass | da25eff | 2019-12-28 10:44:56 -0700 | [diff] [blame] | 19 | /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */ |
| 20 | #ifdef CONFIG_EFI_STUB |
| 21 | #define ll_boot_init() false |
| 22 | #else |
| 23 | #define ll_boot_init() true |
| 24 | #endif |
| 25 | |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 26 | /* |
| 27 | * Function Prototypes |
| 28 | */ |
| 29 | |
| 30 | /* common/board_f.c */ |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 31 | void board_init_f(ulong dummy); |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * arch_cpu_init() - basic cpu-dependent setup for an architecture |
| 35 | * |
| 36 | * This is called after early malloc is available. It should handle any |
| 37 | * CPU- or SoC- specific init needed to continue the init sequence. See |
| 38 | * board_f.c for where it is called. If this is not provided, a default |
| 39 | * version (which does nothing) will be used. |
| 40 | * |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 41 | * Return: 0 on success, otherwise error |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 42 | */ |
| 43 | int arch_cpu_init(void); |
| 44 | |
| 45 | /** |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 46 | * arch_cpu_init_dm() - init CPU after driver model is available |
| 47 | * |
| 48 | * This is called immediately after driver model is available before |
| 49 | * relocation. This is similar to arch_cpu_init() but is able to reference |
| 50 | * devices |
| 51 | * |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 52 | * Return: 0 if OK, -ve on error |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 53 | */ |
| 54 | int arch_cpu_init_dm(void); |
| 55 | |
| 56 | /** |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 57 | * mach_cpu_init() - SoC/machine dependent CPU setup |
| 58 | * |
| 59 | * This is called after arch_cpu_init(). It should handle any |
| 60 | * SoC or machine specific init needed to continue the init sequence. See |
| 61 | * board_f.c for where it is called. If this is not provided, a default |
| 62 | * version (which does nothing) will be used. |
| 63 | * |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 64 | * Return: 0 on success, otherwise error |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 65 | */ |
| 66 | int mach_cpu_init(void); |
| 67 | |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 68 | /** |
| 69 | * arch_fsp_init() - perform firmware support package init |
| 70 | * |
| 71 | * Where U-Boot relies on binary blobs to handle part of the system init, this |
| 72 | * function can be used to set up the blobs. This is used on some Intel |
| 73 | * platforms. |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 74 | * |
| 75 | * Return: 0 |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 76 | */ |
| 77 | int arch_fsp_init(void); |
| 78 | |
Simon Glass | 564a4a0 | 2019-12-06 21:42:20 -0700 | [diff] [blame] | 79 | /** |
| 80 | * arch_fsp_init() - perform post-relocation firmware support package init |
| 81 | * |
| 82 | * Where U-Boot relies on binary blobs to handle part of the system init, this |
| 83 | * function can be used to set up the blobs. This is used on some Intel |
| 84 | * platforms. |
| 85 | * |
| 86 | * Return: 0 |
| 87 | */ |
| 88 | int arch_fsp_init_r(void); |
| 89 | |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 90 | int dram_init(void); |
| 91 | |
| 92 | /** |
| 93 | * dram_init_banksize() - Set up DRAM bank sizes |
| 94 | * |
| 95 | * This can be implemented by boards to set up the DRAM bank information in |
| 96 | * gd->bd->bi_dram(). It is called just before relocation, after dram_init() |
| 97 | * is called. |
| 98 | * |
| 99 | * If this is not provided, a default implementation will try to set up a |
| 100 | * single bank. It will do this if CONFIG_NR_DRAM_BANKS and |
| 101 | * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of |
| 102 | * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to |
| 103 | * get_effective_memsize(). |
| 104 | * |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 105 | * Return: 0 if OK, -ve on error |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 106 | */ |
| 107 | int dram_init_banksize(void); |
| 108 | |
| 109 | /** |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 110 | * arch_reserve_stacks() - Reserve all necessary stacks |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 111 | * |
| 112 | * This is used in generic board init sequence in common/board_f.c. Each |
| 113 | * architecture could provide this function to tailor the required stacks. |
| 114 | * |
| 115 | * On entry gd->start_addr_sp is pointing to the suggested top of the stack. |
| 116 | * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures |
| 117 | * require only this can leave it untouched. |
| 118 | * |
| 119 | * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective |
| 120 | * positions of the stack. The stack pointer(s) will be set to this later. |
| 121 | * gd->irq_sp is only required, if the architecture needs it. |
| 122 | * |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 123 | * Return: 0 if no error |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 124 | */ |
| 125 | int arch_reserve_stacks(void); |
| 126 | |
Patrick Delaunay | 18c5064 | 2018-03-13 13:57:04 +0100 | [diff] [blame] | 127 | /** |
| 128 | * init_cache_f_r() - Turn on the cache in preparation for relocation |
| 129 | * |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 130 | * Return: 0 if OK, -ve on error |
Patrick Delaunay | 18c5064 | 2018-03-13 13:57:04 +0100 | [diff] [blame] | 131 | */ |
| 132 | int init_cache_f_r(void); |
| 133 | |
Mario Six | 97bbb60 | 2018-08-06 10:23:41 +0200 | [diff] [blame] | 134 | #if !CONFIG_IS_ENABLED(CPU) |
| 135 | /** |
| 136 | * print_cpuinfo() - Display information about the CPU |
| 137 | * |
| 138 | * Return: 0 if OK, -ve on error |
| 139 | */ |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 140 | int print_cpuinfo(void); |
Mario Six | 97bbb60 | 2018-08-06 10:23:41 +0200 | [diff] [blame] | 141 | #endif |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 142 | int timer_init(void); |
| 143 | int reserve_mmu(void); |
| 144 | int misc_init_f(void); |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 145 | |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 146 | #if defined(CONFIG_DTB_RESELECT) |
| 147 | int embedded_dtb_select(void); |
| 148 | #endif |
| 149 | |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 150 | /* common/init/board_init.c */ |
| 151 | extern ulong monitor_flash_len; |
| 152 | |
| 153 | /** |
| 154 | * ulong board_init_f_alloc_reserve - allocate reserved area |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 155 | * @top: top of the reserve area, growing down. |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 156 | * |
| 157 | * This function is called by each architecture very early in the start-up |
| 158 | * code to allow the C runtime to reserve space on the stack for writable |
| 159 | * 'globals' such as GD and the malloc arena. |
| 160 | * |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 161 | * Return: bottom of reserved area |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 162 | */ |
| 163 | ulong board_init_f_alloc_reserve(ulong top); |
| 164 | |
| 165 | /** |
| 166 | * board_init_f_init_reserve - initialize the reserved area(s) |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 167 | * @base: top from which reservation was done |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 168 | * |
| 169 | * This function is called once the C runtime has allocated the reserved |
| 170 | * area on the stack. It must initialize the GD at the base of that area. |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 171 | */ |
| 172 | void board_init_f_init_reserve(ulong base); |
| 173 | |
Simon Glass | 6980b6b | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 174 | struct global_data; |
| 175 | |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 176 | /** |
| 177 | * arch_setup_gd() - Set up the global_data pointer |
Mario Six | 86c45a4 | 2018-08-06 10:23:40 +0200 | [diff] [blame] | 178 | * @gd_ptr: Pointer to global data |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 179 | * |
| 180 | * This pointer is special in some architectures and cannot easily be assigned |
| 181 | * to. For example on x86 it is implemented by adding a specific record to its |
| 182 | * Global Descriptor Table! So we we provide a function to carry out this task. |
| 183 | * For most architectures this can simply be: |
| 184 | * |
| 185 | * gd = gd_ptr; |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 186 | */ |
Simon Glass | 6980b6b | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 187 | void arch_setup_gd(struct global_data *gd_ptr); |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 188 | |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 189 | /* common/board_r.c */ |
Simon Glass | 6980b6b | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 190 | void board_init_r(struct global_data *id, ulong dest_addr) |
| 191 | __attribute__ ((noreturn)); |
Patrick Delaunay | b76e7cf | 2018-03-13 13:57:02 +0100 | [diff] [blame] | 192 | |
| 193 | int cpu_init_r(void); |
| 194 | int last_stage_init(void); |
| 195 | int mac_read_from_eeprom(void); |
| 196 | int set_cpu_clk_info(void); |
| 197 | int update_flash_size(int flash_size); |
| 198 | int arch_early_init_r(void); |
| 199 | void pci_init(void); |
| 200 | int misc_init_r(void); |
| 201 | #if defined(CONFIG_VID) |
| 202 | int init_func_vid(void); |
| 203 | #endif |
| 204 | |
Patrick Delaunay | b1d2344 | 2018-03-13 13:57:03 +0100 | [diff] [blame] | 205 | /* common/board_info.c */ |
| 206 | int checkboard(void); |
| 207 | int show_board_info(void); |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 208 | |
Simon Glass | 6980b6b | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 209 | /** |
| 210 | * Get the uppermost pointer that is valid to access |
| 211 | * |
| 212 | * Some systems may not map all of their address space. This function allows |
| 213 | * boards to indicate what their highest support pointer value is for DRAM |
| 214 | * access. |
| 215 | * |
| 216 | * @param total_size Size of U-Boot (unused?) |
| 217 | */ |
| 218 | ulong board_get_usable_ram_top(ulong total_size); |
| 219 | |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 220 | int board_early_init_f(void); |
| 221 | |
| 222 | /* manipulate the U-Boot fdt before its relocation */ |
| 223 | int board_fix_fdt(void *rw_fdt_blob); |
| 224 | int board_late_init(void); |
| 225 | int board_postclk_init(void); /* after clocks/timebase, before env/serial */ |
| 226 | int board_early_init_r(void); |
| 227 | |
Simon Glass | 18afe10 | 2019-11-14 12:57:47 -0700 | [diff] [blame] | 228 | /* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */ |
| 229 | void pci_init_board(void); |
| 230 | |
Simon Glass | 537ecc9 | 2019-11-14 12:57:48 -0700 | [diff] [blame] | 231 | void trap_init(unsigned long reloc_addr); |
| 232 | |
Simon Glass | a5037e2 | 2019-12-28 10:44:39 -0700 | [diff] [blame] | 233 | /** |
| 234 | * main_loop() - Enter the main loop of U-Boot |
| 235 | * |
| 236 | * This normally runs the command line. |
| 237 | */ |
| 238 | void main_loop(void); |
| 239 | |
Simon Glass | 284f71b | 2019-12-28 10:44:45 -0700 | [diff] [blame] | 240 | #if defined(CONFIG_ARM) |
| 241 | void relocate_code(ulong addr_moni); |
| 242 | #else |
| 243 | void relocate_code(ulong start_addr_sp, struct global_data *new_gd, |
| 244 | ulong relocaddr) |
| 245 | __attribute__ ((noreturn)); |
| 246 | #endif |
| 247 | |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 248 | #endif /* __ASSEMBLY__ */ |
| 249 | /* Put only stuff here that the assembler can digest */ |
| 250 | |
| 251 | #endif /* __INIT_H_ */ |