1*83d290c5STom 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 * 30dafa84d2SPatrick Delaunay * @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 * 41d6f87712SPatrick Delaunay * @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 * 53dafa84d2SPatrick Delaunay * @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. 63d6f87712SPatrick Delaunay */ 64d6f87712SPatrick Delaunay int arch_fsp_init(void); 65d6f87712SPatrick Delaunay 66d6f87712SPatrick Delaunay int dram_init(void); 67d6f87712SPatrick Delaunay 68d6f87712SPatrick Delaunay /** 69d6f87712SPatrick Delaunay * dram_init_banksize() - Set up DRAM bank sizes 70d6f87712SPatrick Delaunay * 71d6f87712SPatrick Delaunay * This can be implemented by boards to set up the DRAM bank information in 72d6f87712SPatrick Delaunay * gd->bd->bi_dram(). It is called just before relocation, after dram_init() 73d6f87712SPatrick Delaunay * is called. 74d6f87712SPatrick Delaunay * 75d6f87712SPatrick Delaunay * If this is not provided, a default implementation will try to set up a 76d6f87712SPatrick Delaunay * single bank. It will do this if CONFIG_NR_DRAM_BANKS and 77d6f87712SPatrick Delaunay * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of 78d6f87712SPatrick Delaunay * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to 79d6f87712SPatrick Delaunay * get_effective_memsize(). 80d6f87712SPatrick Delaunay * 81d6f87712SPatrick Delaunay * @return 0 if OK, -ve on error 82d6f87712SPatrick Delaunay */ 83d6f87712SPatrick Delaunay int dram_init_banksize(void); 84d6f87712SPatrick Delaunay 85d6f87712SPatrick Delaunay /** 86d6f87712SPatrick Delaunay * Reserve all necessary stacks 87d6f87712SPatrick Delaunay * 88d6f87712SPatrick Delaunay * This is used in generic board init sequence in common/board_f.c. Each 89d6f87712SPatrick Delaunay * architecture could provide this function to tailor the required stacks. 90d6f87712SPatrick Delaunay * 91d6f87712SPatrick Delaunay * On entry gd->start_addr_sp is pointing to the suggested top of the stack. 92d6f87712SPatrick Delaunay * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures 93d6f87712SPatrick Delaunay * require only this can leave it untouched. 94d6f87712SPatrick Delaunay * 95d6f87712SPatrick Delaunay * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective 96d6f87712SPatrick Delaunay * positions of the stack. The stack pointer(s) will be set to this later. 97d6f87712SPatrick Delaunay * gd->irq_sp is only required, if the architecture needs it. 98d6f87712SPatrick Delaunay * 99d6f87712SPatrick Delaunay * @return 0 if no error 100d6f87712SPatrick Delaunay */ 101d6f87712SPatrick Delaunay int arch_reserve_stacks(void); 102d6f87712SPatrick Delaunay 103b8aa55cbSPatrick Delaunay /** 104b8aa55cbSPatrick Delaunay * init_cache_f_r() - Turn on the cache in preparation for relocation 105b8aa55cbSPatrick Delaunay * 106b8aa55cbSPatrick Delaunay * @return 0 if OK, -ve on error 107b8aa55cbSPatrick Delaunay */ 108b8aa55cbSPatrick Delaunay int init_cache_f_r(void); 109b8aa55cbSPatrick Delaunay 110d6f87712SPatrick Delaunay int print_cpuinfo(void); 111d6f87712SPatrick Delaunay int timer_init(void); 112d6f87712SPatrick Delaunay int reserve_mmu(void); 113d6f87712SPatrick Delaunay int misc_init_f(void); 114d6f87712SPatrick Delaunay #if defined(CONFIG_DTB_RESELECT) 115d6f87712SPatrick Delaunay int embedded_dtb_select(void); 116d6f87712SPatrick Delaunay #endif 117d6f87712SPatrick Delaunay 11811f86cbaSPatrick Delaunay /* common/init/board_init.c */ 11911f86cbaSPatrick Delaunay extern ulong monitor_flash_len; 12011f86cbaSPatrick Delaunay 12111f86cbaSPatrick Delaunay /** 12211f86cbaSPatrick Delaunay * ulong board_init_f_alloc_reserve - allocate reserved area 12311f86cbaSPatrick Delaunay * 12411f86cbaSPatrick Delaunay * This function is called by each architecture very early in the start-up 12511f86cbaSPatrick Delaunay * code to allow the C runtime to reserve space on the stack for writable 12611f86cbaSPatrick Delaunay * 'globals' such as GD and the malloc arena. 12711f86cbaSPatrick Delaunay * 12811f86cbaSPatrick Delaunay * @top: top of the reserve area, growing down. 12911f86cbaSPatrick Delaunay * @return: bottom of reserved area 13011f86cbaSPatrick Delaunay */ 13111f86cbaSPatrick Delaunay ulong board_init_f_alloc_reserve(ulong top); 13211f86cbaSPatrick Delaunay 13311f86cbaSPatrick Delaunay /** 13411f86cbaSPatrick Delaunay * board_init_f_init_reserve - initialize the reserved area(s) 13511f86cbaSPatrick Delaunay * 13611f86cbaSPatrick Delaunay * This function is called once the C runtime has allocated the reserved 13711f86cbaSPatrick Delaunay * area on the stack. It must initialize the GD at the base of that area. 13811f86cbaSPatrick Delaunay * 13911f86cbaSPatrick Delaunay * @base: top from which reservation was done 14011f86cbaSPatrick Delaunay */ 14111f86cbaSPatrick Delaunay void board_init_f_init_reserve(ulong base); 14211f86cbaSPatrick Delaunay 14311f86cbaSPatrick Delaunay /** 14411f86cbaSPatrick Delaunay * arch_setup_gd() - Set up the global_data pointer 14511f86cbaSPatrick Delaunay * 14611f86cbaSPatrick Delaunay * This pointer is special in some architectures and cannot easily be assigned 14711f86cbaSPatrick Delaunay * to. For example on x86 it is implemented by adding a specific record to its 14811f86cbaSPatrick Delaunay * Global Descriptor Table! So we we provide a function to carry out this task. 14911f86cbaSPatrick Delaunay * For most architectures this can simply be: 15011f86cbaSPatrick Delaunay * 15111f86cbaSPatrick Delaunay * gd = gd_ptr; 15211f86cbaSPatrick Delaunay * 15311f86cbaSPatrick Delaunay * @gd_ptr: Pointer to global data 15411f86cbaSPatrick Delaunay */ 15511f86cbaSPatrick Delaunay void arch_setup_gd(gd_t *gd_ptr); 15611f86cbaSPatrick Delaunay 157dafa84d2SPatrick Delaunay /* common/board_r.c */ 158e2c219cdSPatrick Delaunay void board_init_r(gd_t *id, ulong dest_addr) __attribute__ ((noreturn)); 159e2c219cdSPatrick Delaunay 160e2c219cdSPatrick Delaunay int cpu_init_r(void); 161e2c219cdSPatrick Delaunay int last_stage_init(void); 162e2c219cdSPatrick Delaunay int mac_read_from_eeprom(void); 163e2c219cdSPatrick Delaunay int set_cpu_clk_info(void); 164e2c219cdSPatrick Delaunay int update_flash_size(int flash_size); 165e2c219cdSPatrick Delaunay int arch_early_init_r(void); 166e2c219cdSPatrick Delaunay void pci_init(void); 167e2c219cdSPatrick Delaunay int misc_init_r(void); 168e2c219cdSPatrick Delaunay #if defined(CONFIG_VID) 169e2c219cdSPatrick Delaunay int init_func_vid(void); 170e2c219cdSPatrick Delaunay #endif 171e2c219cdSPatrick Delaunay 172fc22ee21SPatrick Delaunay /* common/board_info.c */ 173fc22ee21SPatrick Delaunay int checkboard(void); 174fc22ee21SPatrick Delaunay int show_board_info(void); 175dafa84d2SPatrick Delaunay 176dafa84d2SPatrick Delaunay #endif /* __ASSEMBLY__ */ 177dafa84d2SPatrick Delaunay /* Put only stuff here that the assembler can digest */ 178dafa84d2SPatrick Delaunay 179dafa84d2SPatrick Delaunay #endif /* __INIT_H_ */ 180