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