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