blob: 8b37b58747474cad67d0ac19cfe0cc66bf27b4c0 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenke2211742002-11-02 23:30:20 +00002/*
Simon Glassec1fa182019-08-02 09:44:27 -06003 * Common header file for U-Boot
4 *
5 * This file still includes quite a bit of stuff that should be in separate
Simon Glass288b29e2019-11-14 12:57:43 -07006 * headers. Please think before adding more things.
Simon Glass10453152019-11-14 12:57:30 -07007 * Patches to remove things are welcome.
Simon Glassec1fa182019-08-02 09:44:27 -06008 *
Wolfgang Denk3b74e7e2009-05-16 10:47:45 +02009 * (C) Copyright 2000-2009
wdenke2211742002-11-02 23:30:20 +000010 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenke2211742002-11-02 23:30:20 +000011 */
12
13#ifndef __COMMON_H_
Wolfgang Denkd0b8fee2012-01-06 07:36:44 +010014#define __COMMON_H_ 1
wdenke2211742002-11-02 23:30:20 +000015
Wolfgang Denkfcd3c872009-07-24 00:17:48 +020016#ifndef __ASSEMBLY__ /* put C only stuff in this section */
17
wdenke2211742002-11-02 23:30:20 +000018typedef unsigned char uchar;
19typedef volatile unsigned long vu_long;
wdenk180d3f72004-01-04 16:28:35 +000020typedef volatile unsigned short vu_short;
wdenke2211742002-11-02 23:30:20 +000021typedef volatile unsigned char vu_char;
22
23#include <config.h>
Joe Hershberger2307ea42016-04-04 04:07:33 -050024#include <errno.h>
Masahiro Yamadaa7b81762016-12-28 00:36:00 +090025#include <time.h>
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +020026#include <asm-offsets.h>
wdenke2211742002-11-02 23:30:20 +000027#include <linux/bitops.h>
Masahiro Yamada0a70fb42017-09-16 14:10:45 +090028#include <linux/bug.h>
Masahiro Yamada5bc516e2016-12-28 00:35:59 +090029#include <linux/delay.h>
wdenke2211742002-11-02 23:30:20 +000030#include <linux/types.h>
Masahiro Yamadab44b3022017-09-16 14:10:40 +090031#include <linux/printk.h>
wdenke2211742002-11-02 23:30:20 +000032#include <linux/string.h>
Marek Vasut9aed5082012-09-27 17:08:15 +020033#include <linux/stringify.h>
wdenke2211742002-11-02 23:30:20 +000034#include <asm/ptrace.h>
35#include <stdarg.h>
Masahiro Yamada7fea7b12017-09-16 14:10:39 +090036#include <stdio.h>
Masahiro Yamadacba1da42014-11-07 03:03:28 +090037#include <linux/kernel.h>
Simon Glass85043152017-05-17 08:23:05 -060038
wdenke2211742002-11-02 23:30:20 +000039#include <part.h>
40#include <flash.h>
41#include <image.h>
42
York Sun4d1fd7f2014-02-26 17:03:19 -080043#ifdef __LP64__
44#define CONFIG_SYS_SUPPORT_64BIT_DATA
45#endif
46
Simon Glass0e98b0a2017-12-04 13:48:20 -070047#include <log.h>
Simon Glass21726a72011-06-29 09:49:34 +000048
wdenkc83bf6a2004-01-06 22:38:14 +000049#include <asm/u-boot.h> /* boot information for Linux kernel */
wdenke2211742002-11-02 23:30:20 +000050#include <asm/global_data.h> /* global data used for startup functions */
51
Patrick Delaunayd6f87712018-03-13 13:57:00 +010052/* startup functions, used in:
53 * common/board_f.c
Patrick Delaunay11f86cb2018-03-13 13:57:01 +010054 * common/init/board_init.c
Patrick Delaunaye2c219c2018-03-13 13:57:02 +010055 * common/board_r.c
Patrick Delaunayfc22ee22018-03-13 13:57:03 +010056 * common/board_info.c
Patrick Delaunayd6f87712018-03-13 13:57:00 +010057 */
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010058#include <init.h>
59
wdenkc7de8292002-11-19 11:04:11 +000060/*
wdenke2211742002-11-02 23:30:20 +000061 * Function Prototypes
62 */
wdenkc83bf6a2004-01-06 22:38:14 +000063void hang (void) __attribute__ ((noreturn));
wdenke2211742002-11-02 23:30:20 +000064
Simon Glass2ea09c82015-04-28 20:25:07 -060065#include <display_options.h>
wdenke2211742002-11-02 23:30:20 +000066
67/* common/main.c */
68void main_loop (void);
wdenke2211742002-11-02 23:30:20 +000069
Patrick Delaunaye2c219c2018-03-13 13:57:02 +010070int checkflash(void);
71int checkdram(void);
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090072extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000073extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
Patrick Delaunayd6f87712018-03-13 13:57:00 +010074int mdm_init(void);
wdenke2211742002-11-02 23:30:20 +000075
Simon Glass15a33e42012-11-30 13:01:20 +000076/**
Ma Haijune29607e2014-07-12 14:24:06 +010077 * arch_fixup_fdt() - Write arch-specific information to fdt
Simon Glass13d06982013-05-08 08:06:01 +000078 *
Ma Haijune29607e2014-07-12 14:24:06 +010079 * Defined in arch/$(ARCH)/lib/bootm-fdt.c
Simon Glass13d06982013-05-08 08:06:01 +000080 *
81 * @blob: FDT blob to write to
82 * @return 0 if ok, or -ve FDT_ERR_... on failure
83 */
Ma Haijune29607e2014-07-12 14:24:06 +010084int arch_fixup_fdt(void *blob);
Simon Glass13d06982013-05-08 08:06:01 +000085
wdenke2211742002-11-02 23:30:20 +000086/* common/flash.c */
87void flash_perror (int);
88
Wolfgang Denk74de7ae2009-04-01 23:34:12 +020089/* common/cmd_source.c */
90int source (ulong addr, const char *fit_uname);
wdenke2211742002-11-02 23:30:20 +000091
wdenkc83bf6a2004-01-06 22:38:14 +000092extern ulong load_addr; /* Default Load Address */
Simon Glass1aec2442011-10-21 18:51:38 +000093extern ulong save_addr; /* Default Save Address */
94extern ulong save_size; /* Default Save Size */
wdenke2211742002-11-02 23:30:20 +000095
Jason Hobbs06283a62011-08-31 10:37:30 -050096/* common/cmd_net.c */
97int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
98
Rob Herring669df7e2012-05-25 10:47:39 +000099/* common/cmd_fat.c */
100int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
101
102/* common/cmd_ext2.c */
103int do_ext2load(cmd_tbl_t *, int, int, char * const []);
104
wdenk27b207f2003-07-24 23:38:38 +0000105/* common/exports.c */
106void jumptable_init(void);
107
Mike Frysingerecb1dc82009-05-20 04:35:14 -0400108/* common/kallsysm.c */
109const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
110
wdenkc83bf6a2004-01-06 22:38:14 +0000111/* common/memsize.c */
Albert ARIBAUDa55d23c2011-07-03 05:55:33 +0000112long get_ram_size (long *, long);
York Sune3866162014-02-11 11:57:26 -0800113phys_size_t get_effective_memsize(void);
wdenkc83bf6a2004-01-06 22:38:14 +0000114
wdenke2211742002-11-02 23:30:20 +0000115/* $(BOARD)/$(BOARD).c */
116void reset_phy (void);
wdenkc83bf6a2004-01-06 22:38:14 +0000117void fdc_hw_init (void);
wdenke2211742002-11-02 23:30:20 +0000118
Adam Fordf1b1f772018-04-15 13:51:26 -0400119#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200120# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
Heiko Schocher548738b2010-01-07 08:55:40 +0100121#endif
wdenke2211742002-11-02 23:30:20 +0000122
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200123#if defined(CONFIG_SYS_DRAM_TEST)
wdenke2211742002-11-02 23:30:20 +0000124int testdram(void);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200125#endif /* CONFIG_SYS_DRAM_TEST */
wdenke2211742002-11-02 23:30:20 +0000126
Benoît Thébaudeau5c6db122013-04-11 09:35:53 +0000127#if defined(CONFIG_ARM)
128void relocate_code(ulong);
129#else
130void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
Benoît Thébaudeau959eaa72013-04-11 09:35:43 +0000131#endif
Simon Glass6e2941d2017-05-17 08:23:06 -0600132
Diego Dorta026d7952017-10-05 09:13:38 -0300133void s_init(void);
134
wdenke2211742002-11-02 23:30:20 +0000135void upmconfig (unsigned int, unsigned int *, unsigned int);
136ulong get_tbclk (void);
Przemyslaw Marczak1fb4dab2014-09-01 13:50:48 +0200137void reset_misc (void);
wdenk3ec924a2005-04-03 17:23:39 +0000138void reset_cpu (ulong addr);
Kim Phillips6a16e0d2007-08-15 22:30:26 -0500139void ft_cpu_setup(void *blob, bd_t *bd);
Kim Phillips6a16e0d2007-08-15 22:30:26 -0500140void ft_pci_setup(void *blob, bd_t *bd);
Kim Phillips6a16e0d2007-08-15 22:30:26 -0500141
wdenke2211742002-11-02 23:30:20 +0000142/* $(CPU)/speed.c */
143int get_clocks (void);
wdenke2211742002-11-02 23:30:20 +0000144ulong get_bus_freq (ulong);
Stefan Roese550650d2010-09-20 16:05:31 +0200145int get_serial_clock(void);
wdenke2211742002-11-02 23:30:20 +0000146
Jason Hobbse11938e2011-08-23 11:06:56 +0000147/* lib/uuid.c */
Przemyslaw Marczakd718ded2014-04-02 10:20:03 +0200148#include <uuid.h>
Jason Hobbse11938e2011-08-23 11:06:56 +0000149
Peter Tyser78acc472010-04-12 22:28:05 -0500150/* lib/vsprintf.c */
Simon Glass9785c902011-11-02 09:52:07 +0000151#include <vsprintf.h>
wdenke2211742002-11-02 23:30:20 +0000152
Joe Hershberger4ef8d532012-05-23 08:01:04 +0000153/* lib/net_utils.c */
154#include <net.h>
Joe Hershberger4ef8d532012-05-23 08:01:04 +0000155
Simon Glass097e1782012-01-14 15:24:44 +0000156#include <bootstage.h>
wdenke2211742002-11-02 23:30:20 +0000157
Andre Przywara2a6713b2017-01-02 11:48:30 +0000158#else /* __ASSEMBLY__ */
159
Andre Przywara2a6713b2017-01-02 11:48:30 +0000160#endif /* __ASSEMBLY__ */
Wolfgang Denkfcd3c872009-07-24 00:17:48 +0200161
162/* Put only stuff here that the assembler can digest */
163
164#ifdef CONFIG_POST
165#define CONFIG_HAS_POST
Michael Zaidman800eb092010-09-20 08:51:53 +0200166#ifndef CONFIG_POST_ALT_LIST
167#define CONFIG_POST_STD_LIST
168#endif
Wolfgang Denkfcd3c872009-07-24 00:17:48 +0200169#endif
170
Anton Staaf155cfb52011-09-02 13:45:28 +0000171#define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
Andy Fleming4b03ac82008-06-16 13:58:53 -0500172
Anton Staaf1e41f5a2011-10-17 16:46:13 -0700173/*
Simon Glassc9689ca2015-06-23 15:38:31 -0600174 * check_member() - Check the offset of a structure member
175 *
176 * @structure: Name of structure (e.g. global_data)
177 * @member: Name of member (e.g. baudrate)
178 * @offset: Expected offset in bytes
179 */
180#define check_member(structure, member, offset) _Static_assert( \
181 offsetof(struct structure, member) == offset, \
182 "`struct " #structure "` offset for `" #member "` is not " #offset)
183
Simon Glass476476e2015-08-04 12:33:52 -0600184/* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
185#ifdef CONFIG_EFI_STUB
186#define ll_boot_init() false
187#else
188#define ll_boot_init() true
189#endif
190
Mike Frysingerc3eb3fe2011-07-08 10:44:25 +0000191/* Pull in stuff for the build system */
192#ifdef DO_DEPS_ONLY
Simon Glassf3998fd2019-08-02 09:44:25 -0600193# include <env_internal.h>
Mike Frysingerc3eb3fe2011-07-08 10:44:25 +0000194#endif
195
wdenke2211742002-11-02 23:30:20 +0000196#endif /* __COMMON_H_ */