Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 2 | /* |
Simon Glass | 1ed83ba | 2019-08-02 09:44:27 -0600 | [diff] [blame] | 3 | * Common header file for U-Boot |
| 4 | * |
| 5 | * This file still includes quite a bit of stuff that should be in separate |
Simon Glass | adaaa48 | 2019-11-14 12:57:43 -0700 | [diff] [blame] | 6 | * headers. Please think before adding more things. |
Simon Glass | 495a5dc | 2019-11-14 12:57:30 -0700 | [diff] [blame] | 7 | * Patches to remove things are welcome. |
Simon Glass | 1ed83ba | 2019-08-02 09:44:27 -0600 | [diff] [blame] | 8 | * |
Wolfgang Denk | f342f86 | 2009-05-16 10:47:45 +0200 | [diff] [blame] | 9 | * (C) Copyright 2000-2009 |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 10 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #ifndef __COMMON_H_ |
Wolfgang Denk | bcbd521 | 2012-01-06 07:36:44 +0100 | [diff] [blame] | 14 | #define __COMMON_H_ 1 |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 15 | |
Wolfgang Denk | 66e8d44 | 2009-07-24 00:17:48 +0200 | [diff] [blame] | 16 | #ifndef __ASSEMBLY__ /* put C only stuff in this section */ |
| 17 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 18 | typedef volatile unsigned long vu_long; |
wdenk | ad276f2 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 19 | typedef volatile unsigned short vu_short; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 20 | typedef volatile unsigned char vu_char; |
| 21 | |
| 22 | #include <config.h> |
Joe Hershberger | cbf1a93 | 2016-04-04 04:07:33 -0500 | [diff] [blame] | 23 | #include <errno.h> |
Masahiro Yamada | a4f0b8e | 2016-12-28 00:36:00 +0900 | [diff] [blame] | 24 | #include <time.h> |
Wolfgang Denk | 0191e47 | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 25 | #include <asm-offsets.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 26 | #include <linux/bitops.h> |
Masahiro Yamada | 958f0f0 | 2017-09-16 14:10:45 +0900 | [diff] [blame] | 27 | #include <linux/bug.h> |
Masahiro Yamada | 29d2a62 | 2016-12-28 00:35:59 +0900 | [diff] [blame] | 28 | #include <linux/delay.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 29 | #include <linux/types.h> |
Masahiro Yamada | bf9c293 | 2017-09-16 14:10:40 +0900 | [diff] [blame] | 30 | #include <linux/printk.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 31 | #include <linux/string.h> |
Marek Vasut | a3f1634 | 2012-09-27 17:08:15 +0200 | [diff] [blame] | 32 | #include <linux/stringify.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 33 | #include <asm/ptrace.h> |
| 34 | #include <stdarg.h> |
Masahiro Yamada | 5e882e9 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 35 | #include <stdio.h> |
Masahiro Yamada | bd42662 | 2014-11-07 03:03:28 +0900 | [diff] [blame] | 36 | #include <linux/kernel.h> |
Simon Glass | 7613579 | 2017-05-17 08:23:05 -0600 | [diff] [blame] | 37 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 38 | #include <part.h> |
| 39 | #include <flash.h> |
| 40 | #include <image.h> |
| 41 | |
York Sun | 6c48001 | 2014-02-26 17:03:19 -0800 | [diff] [blame] | 42 | #ifdef __LP64__ |
| 43 | #define CONFIG_SYS_SUPPORT_64BIT_DATA |
| 44 | #endif |
| 45 | |
Simon Glass | 9054a02 | 2017-12-04 13:48:20 -0700 | [diff] [blame] | 46 | #include <log.h> |
Simon Glass | 02aa9e6 | 2011-06-29 09:49:34 +0000 | [diff] [blame] | 47 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 48 | #include <asm/u-boot.h> /* boot information for Linux kernel */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 49 | #include <asm/global_data.h> /* global data used for startup functions */ |
| 50 | |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 51 | /* startup functions, used in: |
| 52 | * common/board_f.c |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 53 | * common/init/board_init.c |
Patrick Delaunay | b76e7cf | 2018-03-13 13:57:02 +0100 | [diff] [blame] | 54 | * common/board_r.c |
Patrick Delaunay | b1d2344 | 2018-03-13 13:57:03 +0100 | [diff] [blame] | 55 | * common/board_info.c |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 56 | */ |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 57 | #include <init.h> |
| 58 | |
wdenk | 452cfd6 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 59 | /* |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 60 | * Function Prototypes |
| 61 | */ |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 62 | void hang (void) __attribute__ ((noreturn)); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 63 | |
Simon Glass | 7da617c | 2015-04-28 20:25:07 -0600 | [diff] [blame] | 64 | #include <display_options.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 65 | |
| 66 | /* common/main.c */ |
| 67 | void main_loop (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 68 | |
Patrick Delaunay | b76e7cf | 2018-03-13 13:57:02 +0100 | [diff] [blame] | 69 | int checkflash(void); |
| 70 | int checkdram(void); |
Masahiro Yamada | 43c0893 | 2014-02-05 11:28:25 +0900 | [diff] [blame] | 71 | extern u8 __dtb_dt_begin[]; /* embedded device tree blob */ |
Goldschmidt Simon | 5e7a1c2 | 2017-11-21 12:29:56 +0000 | [diff] [blame] | 72 | extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */ |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 73 | int mdm_init(void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 74 | |
Simon Glass | eacd14f | 2012-11-30 13:01:20 +0000 | [diff] [blame] | 75 | /** |
Ma Haijun | 6235824 | 2014-07-12 14:24:06 +0100 | [diff] [blame] | 76 | * arch_fixup_fdt() - Write arch-specific information to fdt |
Simon Glass | 9ca3742 | 2013-05-08 08:06:01 +0000 | [diff] [blame] | 77 | * |
Ma Haijun | 6235824 | 2014-07-12 14:24:06 +0100 | [diff] [blame] | 78 | * Defined in arch/$(ARCH)/lib/bootm-fdt.c |
Simon Glass | 9ca3742 | 2013-05-08 08:06:01 +0000 | [diff] [blame] | 79 | * |
| 80 | * @blob: FDT blob to write to |
| 81 | * @return 0 if ok, or -ve FDT_ERR_... on failure |
| 82 | */ |
Ma Haijun | 6235824 | 2014-07-12 14:24:06 +0100 | [diff] [blame] | 83 | int arch_fixup_fdt(void *blob); |
Simon Glass | 9ca3742 | 2013-05-08 08:06:01 +0000 | [diff] [blame] | 84 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 85 | /* common/flash.c */ |
| 86 | void flash_perror (int); |
| 87 | |
Wolfgang Denk | 85c25df | 2009-04-01 23:34:12 +0200 | [diff] [blame] | 88 | /* common/cmd_source.c */ |
| 89 | int source (ulong addr, const char *fit_uname); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 90 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 91 | extern ulong load_addr; /* Default Load Address */ |
Simon Glass | 34f5229 | 2011-10-21 18:51:38 +0000 | [diff] [blame] | 92 | extern ulong save_addr; /* Default Save Address */ |
| 93 | extern ulong save_size; /* Default Save Size */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 94 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 95 | /* common/cmd_net.c */ |
| 96 | int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
| 97 | |
Rob Herring | eee675f | 2012-05-25 10:47:39 +0000 | [diff] [blame] | 98 | /* common/cmd_fat.c */ |
| 99 | int do_fat_fsload(cmd_tbl_t *, int, int, char * const []); |
| 100 | |
| 101 | /* common/cmd_ext2.c */ |
| 102 | int do_ext2load(cmd_tbl_t *, int, int, char * const []); |
| 103 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 104 | /* common/exports.c */ |
| 105 | void jumptable_init(void); |
| 106 | |
Mike Frysinger | a46fbba | 2009-05-20 04:35:14 -0400 | [diff] [blame] | 107 | /* common/kallsysm.c */ |
| 108 | const char *symbol_lookup(unsigned long addr, unsigned long *caddr); |
| 109 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 110 | /* common/memsize.c */ |
Albert ARIBAUD | a960673 | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 111 | long get_ram_size (long *, long); |
York Sun | 863e8d8 | 2014-02-11 11:57:26 -0800 | [diff] [blame] | 112 | phys_size_t get_effective_memsize(void); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 113 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 114 | /* $(BOARD)/$(BOARD).c */ |
| 115 | void reset_phy (void); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 116 | void fdc_hw_init (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 117 | |
Adam Ford | 4e96ff8 | 2018-04-15 13:51:26 -0400 | [diff] [blame] | 118 | #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 119 | # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR |
Heiko Schocher | 9bb0dd5 | 2010-01-07 08:55:40 +0100 | [diff] [blame] | 120 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 121 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 122 | #if defined(CONFIG_SYS_DRAM_TEST) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 123 | int testdram(void); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 124 | #endif /* CONFIG_SYS_DRAM_TEST */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 125 | |
Benoît Thébaudeau | a043661 | 2013-04-11 09:35:53 +0000 | [diff] [blame] | 126 | #if defined(CONFIG_ARM) |
| 127 | void relocate_code(ulong); |
| 128 | #else |
| 129 | void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn)); |
Benoît Thébaudeau | 9039c10 | 2013-04-11 09:35:43 +0000 | [diff] [blame] | 130 | #endif |
Simon Glass | 243182c | 2017-05-17 08:23:06 -0600 | [diff] [blame] | 131 | |
Diego Dorta | 206d580 | 2017-10-05 09:13:38 -0300 | [diff] [blame] | 132 | void s_init(void); |
| 133 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 134 | void upmconfig (unsigned int, unsigned int *, unsigned int); |
| 135 | ulong get_tbclk (void); |
Przemyslaw Marczak | ec1c122 | 2014-09-01 13:50:48 +0200 | [diff] [blame] | 136 | void reset_misc (void); |
wdenk | 1e8d0c5 | 2005-04-03 17:23:39 +0000 | [diff] [blame] | 137 | void reset_cpu (ulong addr); |
Kim Phillips | dc0b59d | 2007-08-15 22:30:26 -0500 | [diff] [blame] | 138 | void ft_cpu_setup(void *blob, bd_t *bd); |
Kim Phillips | dc0b59d | 2007-08-15 22:30:26 -0500 | [diff] [blame] | 139 | void ft_pci_setup(void *blob, bd_t *bd); |
Kim Phillips | dc0b59d | 2007-08-15 22:30:26 -0500 | [diff] [blame] | 140 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 141 | /* $(CPU)/speed.c */ |
| 142 | int get_clocks (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 143 | ulong get_bus_freq (ulong); |
Stefan Roese | 3ddce57 | 2010-09-20 16:05:31 +0200 | [diff] [blame] | 144 | int get_serial_clock(void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 145 | |
Jason Hobbs | 6e39cce | 2011-08-23 11:06:56 +0000 | [diff] [blame] | 146 | /* lib/uuid.c */ |
Przemyslaw Marczak | 0c81336 | 2014-04-02 10:20:03 +0200 | [diff] [blame] | 147 | #include <uuid.h> |
Jason Hobbs | 6e39cce | 2011-08-23 11:06:56 +0000 | [diff] [blame] | 148 | |
Peter Tyser | 685b7f5 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 149 | /* lib/vsprintf.c */ |
Simon Glass | f7ae6806 | 2011-11-02 09:52:07 +0000 | [diff] [blame] | 150 | #include <vsprintf.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 151 | |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 152 | /* lib/net_utils.c */ |
| 153 | #include <net.h> |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 154 | |
Simon Glass | 8445d00 | 2012-01-14 15:24:44 +0000 | [diff] [blame] | 155 | #include <bootstage.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 156 | |
Andre Przywara | 9fcee53 | 2017-01-02 11:48:30 +0000 | [diff] [blame] | 157 | #else /* __ASSEMBLY__ */ |
| 158 | |
Andre Przywara | 9fcee53 | 2017-01-02 11:48:30 +0000 | [diff] [blame] | 159 | #endif /* __ASSEMBLY__ */ |
Wolfgang Denk | 66e8d44 | 2009-07-24 00:17:48 +0200 | [diff] [blame] | 160 | |
| 161 | /* Put only stuff here that the assembler can digest */ |
| 162 | |
| 163 | #ifdef CONFIG_POST |
| 164 | #define CONFIG_HAS_POST |
Michael Zaidman | f969a68 | 2010-09-20 08:51:53 +0200 | [diff] [blame] | 165 | #ifndef CONFIG_POST_ALT_LIST |
| 166 | #define CONFIG_POST_STD_LIST |
| 167 | #endif |
Wolfgang Denk | 66e8d44 | 2009-07-24 00:17:48 +0200 | [diff] [blame] | 168 | #endif |
| 169 | |
Anton Staaf | 07a036a | 2011-09-02 13:45:28 +0000 | [diff] [blame] | 170 | #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1)) |
Andy Fleming | 2ef5ed0 | 2008-06-16 13:58:53 -0500 | [diff] [blame] | 171 | |
Anton Staaf | cda2e48 | 2011-10-17 16:46:13 -0700 | [diff] [blame] | 172 | /* |
Simon Glass | d61718b | 2015-06-23 15:38:31 -0600 | [diff] [blame] | 173 | * check_member() - Check the offset of a structure member |
| 174 | * |
| 175 | * @structure: Name of structure (e.g. global_data) |
| 176 | * @member: Name of member (e.g. baudrate) |
| 177 | * @offset: Expected offset in bytes |
| 178 | */ |
| 179 | #define check_member(structure, member, offset) _Static_assert( \ |
| 180 | offsetof(struct structure, member) == offset, \ |
| 181 | "`struct " #structure "` offset for `" #member "` is not " #offset) |
| 182 | |
Simon Glass | 63f581f | 2015-08-04 12:33:52 -0600 | [diff] [blame] | 183 | /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */ |
| 184 | #ifdef CONFIG_EFI_STUB |
| 185 | #define ll_boot_init() false |
| 186 | #else |
| 187 | #define ll_boot_init() true |
| 188 | #endif |
| 189 | |
Mike Frysinger | 63b8f12 | 2011-07-08 10:44:25 +0000 | [diff] [blame] | 190 | /* Pull in stuff for the build system */ |
| 191 | #ifdef DO_DEPS_ONLY |
Simon Glass | 9d1f619 | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 192 | # include <env_internal.h> |
Mike Frysinger | 63b8f12 | 2011-07-08 10:44:25 +0000 | [diff] [blame] | 193 | #endif |
| 194 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 195 | #endif /* __COMMON_H_ */ |