183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 2dafa84d2SPatrick Delaunay /* 3dafa84d2SPatrick Delaunay * (C) Copyright 2000-2009 4dafa84d2SPatrick Delaunay * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 5dafa84d2SPatrick Delaunay * 6dafa84d2SPatrick Delaunay * Copy the startup prototype, previously defined in common.h 7dafa84d2SPatrick Delaunay * Copyright (C) 2018, STMicroelectronics - All Rights Reserved 8dafa84d2SPatrick Delaunay */ 9dafa84d2SPatrick Delaunay 10dafa84d2SPatrick Delaunay #ifndef __INIT_H_ 11dafa84d2SPatrick Delaunay #define __INIT_H_ 1 12dafa84d2SPatrick Delaunay 13dafa84d2SPatrick Delaunay #ifndef __ASSEMBLY__ /* put C only stuff in this section */ 14dafa84d2SPatrick Delaunay 15dafa84d2SPatrick Delaunay /* 16dafa84d2SPatrick Delaunay * Function Prototypes 17dafa84d2SPatrick Delaunay */ 18dafa84d2SPatrick Delaunay 19dafa84d2SPatrick Delaunay /* common/board_f.c */ 20d6f87712SPatrick Delaunay void board_init_f(ulong dummy); 21dafa84d2SPatrick Delaunay 22dafa84d2SPatrick Delaunay /** 23dafa84d2SPatrick Delaunay * arch_cpu_init() - basic cpu-dependent setup for an architecture 24dafa84d2SPatrick Delaunay * 25dafa84d2SPatrick Delaunay * This is called after early malloc is available. It should handle any 26dafa84d2SPatrick Delaunay * CPU- or SoC- specific init needed to continue the init sequence. See 27dafa84d2SPatrick Delaunay * board_f.c for where it is called. If this is not provided, a default 28dafa84d2SPatrick Delaunay * version (which does nothing) will be used. 29dafa84d2SPatrick Delaunay * 30dc145a7bSMario Six * Return: 0 on success, otherwise error 31dafa84d2SPatrick Delaunay */ 32dafa84d2SPatrick Delaunay int arch_cpu_init(void); 33dafa84d2SPatrick Delaunay 34dafa84d2SPatrick Delaunay /** 35d6f87712SPatrick Delaunay * arch_cpu_init_dm() - init CPU after driver model is available 36d6f87712SPatrick Delaunay * 37d6f87712SPatrick Delaunay * This is called immediately after driver model is available before 38d6f87712SPatrick Delaunay * relocation. This is similar to arch_cpu_init() but is able to reference 39d6f87712SPatrick Delaunay * devices 40d6f87712SPatrick Delaunay * 41dc145a7bSMario Six * Return: 0 if OK, -ve on error 42d6f87712SPatrick Delaunay */ 43d6f87712SPatrick Delaunay int arch_cpu_init_dm(void); 44d6f87712SPatrick Delaunay 45d6f87712SPatrick Delaunay /** 46dafa84d2SPatrick Delaunay * mach_cpu_init() - SoC/machine dependent CPU setup 47dafa84d2SPatrick Delaunay * 48dafa84d2SPatrick Delaunay * This is called after arch_cpu_init(). It should handle any 49dafa84d2SPatrick Delaunay * SoC or machine specific init needed to continue the init sequence. See 50dafa84d2SPatrick Delaunay * board_f.c for where it is called. If this is not provided, a default 51dafa84d2SPatrick Delaunay * version (which does nothing) will be used. 52dafa84d2SPatrick Delaunay * 53dc145a7bSMario Six * Return: 0 on success, otherwise error 54dafa84d2SPatrick Delaunay */ 55dafa84d2SPatrick Delaunay int mach_cpu_init(void); 56dafa84d2SPatrick Delaunay 57d6f87712SPatrick Delaunay /** 58d6f87712SPatrick Delaunay * arch_fsp_init() - perform firmware support package init 59d6f87712SPatrick Delaunay * 60d6f87712SPatrick Delaunay * Where U-Boot relies on binary blobs to handle part of the system init, this 61d6f87712SPatrick Delaunay * function can be used to set up the blobs. This is used on some Intel 62d6f87712SPatrick Delaunay * platforms. 63dc145a7bSMario Six * 64dc145a7bSMario Six * Return: 0 65d6f87712SPatrick Delaunay */ 66d6f87712SPatrick Delaunay int arch_fsp_init(void); 67d6f87712SPatrick Delaunay 68d6f87712SPatrick Delaunay int dram_init(void); 69d6f87712SPatrick Delaunay 70d6f87712SPatrick Delaunay /** 71d6f87712SPatrick Delaunay * dram_init_banksize() - Set up DRAM bank sizes 72d6f87712SPatrick Delaunay * 73d6f87712SPatrick Delaunay * This can be implemented by boards to set up the DRAM bank information in 74d6f87712SPatrick Delaunay * gd->bd->bi_dram(). It is called just before relocation, after dram_init() 75d6f87712SPatrick Delaunay * is called. 76d6f87712SPatrick Delaunay * 77d6f87712SPatrick Delaunay * If this is not provided, a default implementation will try to set up a 78d6f87712SPatrick Delaunay * single bank. It will do this if CONFIG_NR_DRAM_BANKS and 79d6f87712SPatrick Delaunay * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of 80d6f87712SPatrick Delaunay * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to 81d6f87712SPatrick Delaunay * get_effective_memsize(). 82d6f87712SPatrick Delaunay * 83dc145a7bSMario Six * Return: 0 if OK, -ve on error 84d6f87712SPatrick Delaunay */ 85d6f87712SPatrick Delaunay int dram_init_banksize(void); 86d6f87712SPatrick Delaunay 87d6f87712SPatrick Delaunay /** 88dc145a7bSMario Six * arch_reserve_stacks() - Reserve all necessary stacks 89d6f87712SPatrick Delaunay * 90d6f87712SPatrick Delaunay * This is used in generic board init sequence in common/board_f.c. Each 91d6f87712SPatrick Delaunay * architecture could provide this function to tailor the required stacks. 92d6f87712SPatrick Delaunay * 93d6f87712SPatrick Delaunay * On entry gd->start_addr_sp is pointing to the suggested top of the stack. 94d6f87712SPatrick Delaunay * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures 95d6f87712SPatrick Delaunay * require only this can leave it untouched. 96d6f87712SPatrick Delaunay * 97d6f87712SPatrick Delaunay * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective 98d6f87712SPatrick Delaunay * positions of the stack. The stack pointer(s) will be set to this later. 99d6f87712SPatrick Delaunay * gd->irq_sp is only required, if the architecture needs it. 100d6f87712SPatrick Delaunay * 101dc145a7bSMario Six * Return: 0 if no error 102d6f87712SPatrick Delaunay */ 103d6f87712SPatrick Delaunay int arch_reserve_stacks(void); 104d6f87712SPatrick Delaunay 105b8aa55cbSPatrick Delaunay /** 106b8aa55cbSPatrick Delaunay * init_cache_f_r() - Turn on the cache in preparation for relocation 107b8aa55cbSPatrick Delaunay * 108dc145a7bSMario Six * Return: 0 if OK, -ve on error 109b8aa55cbSPatrick Delaunay */ 110b8aa55cbSPatrick Delaunay int init_cache_f_r(void); 111b8aa55cbSPatrick Delaunay 112*5d6c61acSMario Six #if !CONFIG_IS_ENABLED(CPU) 113*5d6c61acSMario Six /** 114*5d6c61acSMario Six * print_cpuinfo() - Display information about the CPU 115*5d6c61acSMario Six * 116*5d6c61acSMario Six * Return: 0 if OK, -ve on error 117*5d6c61acSMario Six */ 118d6f87712SPatrick Delaunay int print_cpuinfo(void); 119*5d6c61acSMario Six #endif 120d6f87712SPatrick Delaunay int timer_init(void); 121d6f87712SPatrick Delaunay int reserve_mmu(void); 122d6f87712SPatrick Delaunay int misc_init_f(void); 123dc145a7bSMario Six 124d6f87712SPatrick Delaunay #if defined(CONFIG_DTB_RESELECT) 125d6f87712SPatrick Delaunay int embedded_dtb_select(void); 126d6f87712SPatrick Delaunay #endif 127d6f87712SPatrick Delaunay 12811f86cbaSPatrick Delaunay /* common/init/board_init.c */ 12911f86cbaSPatrick Delaunay extern ulong monitor_flash_len; 13011f86cbaSPatrick Delaunay 13111f86cbaSPatrick Delaunay /** 13211f86cbaSPatrick Delaunay * ulong board_init_f_alloc_reserve - allocate reserved area 133dc145a7bSMario Six * @top: top of the reserve area, growing down. 13411f86cbaSPatrick Delaunay * 13511f86cbaSPatrick Delaunay * This function is called by each architecture very early in the start-up 13611f86cbaSPatrick Delaunay * code to allow the C runtime to reserve space on the stack for writable 13711f86cbaSPatrick Delaunay * 'globals' such as GD and the malloc arena. 13811f86cbaSPatrick Delaunay * 139dc145a7bSMario Six * Return: bottom of reserved area 14011f86cbaSPatrick Delaunay */ 14111f86cbaSPatrick Delaunay ulong board_init_f_alloc_reserve(ulong top); 14211f86cbaSPatrick Delaunay 14311f86cbaSPatrick Delaunay /** 14411f86cbaSPatrick Delaunay * board_init_f_init_reserve - initialize the reserved area(s) 145dc145a7bSMario Six * @base: top from which reservation was done 14611f86cbaSPatrick Delaunay * 14711f86cbaSPatrick Delaunay * This function is called once the C runtime has allocated the reserved 14811f86cbaSPatrick Delaunay * area on the stack. It must initialize the GD at the base of that area. 14911f86cbaSPatrick Delaunay */ 15011f86cbaSPatrick Delaunay void board_init_f_init_reserve(ulong base); 15111f86cbaSPatrick Delaunay 15211f86cbaSPatrick Delaunay /** 15311f86cbaSPatrick Delaunay * arch_setup_gd() - Set up the global_data pointer 154dc145a7bSMario Six * @gd_ptr: Pointer to global data 15511f86cbaSPatrick Delaunay * 15611f86cbaSPatrick Delaunay * This pointer is special in some architectures and cannot easily be assigned 15711f86cbaSPatrick Delaunay * to. For example on x86 it is implemented by adding a specific record to its 15811f86cbaSPatrick Delaunay * Global Descriptor Table! So we we provide a function to carry out this task. 15911f86cbaSPatrick Delaunay * For most architectures this can simply be: 16011f86cbaSPatrick Delaunay * 16111f86cbaSPatrick Delaunay * gd = gd_ptr; 16211f86cbaSPatrick Delaunay */ 16311f86cbaSPatrick Delaunay void arch_setup_gd(gd_t *gd_ptr); 16411f86cbaSPatrick Delaunay 165dafa84d2SPatrick Delaunay /* common/board_r.c */ 166e2c219cdSPatrick Delaunay void board_init_r(gd_t *id, ulong dest_addr) __attribute__ ((noreturn)); 167e2c219cdSPatrick Delaunay 168e2c219cdSPatrick Delaunay int cpu_init_r(void); 169e2c219cdSPatrick Delaunay int last_stage_init(void); 170e2c219cdSPatrick Delaunay int mac_read_from_eeprom(void); 171e2c219cdSPatrick Delaunay int set_cpu_clk_info(void); 172e2c219cdSPatrick Delaunay int update_flash_size(int flash_size); 173e2c219cdSPatrick Delaunay int arch_early_init_r(void); 174e2c219cdSPatrick Delaunay void pci_init(void); 175e2c219cdSPatrick Delaunay int misc_init_r(void); 176e2c219cdSPatrick Delaunay #if defined(CONFIG_VID) 177e2c219cdSPatrick Delaunay int init_func_vid(void); 178e2c219cdSPatrick Delaunay #endif 179e2c219cdSPatrick Delaunay 180fc22ee21SPatrick Delaunay /* common/board_info.c */ 181fc22ee21SPatrick Delaunay int checkboard(void); 182fc22ee21SPatrick Delaunay int show_board_info(void); 183dafa84d2SPatrick Delaunay 184dafa84d2SPatrick Delaunay #endif /* __ASSEMBLY__ */ 185dafa84d2SPatrick Delaunay /* Put only stuff here that the assembler can digest */ 186dafa84d2SPatrick Delaunay 187dafa84d2SPatrick Delaunay #endif /* __INIT_H_ */ 188