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