blob: 52c02185f40e0ead25d761ed1c685a56de33f74a [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 volatile unsigned long vu_long;
wdenk180d3f72004-01-04 16:28:35 +000019typedef volatile unsigned short vu_short;
wdenke2211742002-11-02 23:30:20 +000020typedef volatile unsigned char vu_char;
21
22#include <config.h>
Joe Hershberger2307ea42016-04-04 04:07:33 -050023#include <errno.h>
Masahiro Yamadaa7b81762016-12-28 00:36:00 +090024#include <time.h>
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +020025#include <asm-offsets.h>
wdenke2211742002-11-02 23:30:20 +000026#include <linux/bitops.h>
Masahiro Yamada0a70fb42017-09-16 14:10:45 +090027#include <linux/bug.h>
Masahiro Yamada5bc516e2016-12-28 00:35:59 +090028#include <linux/delay.h>
wdenke2211742002-11-02 23:30:20 +000029#include <linux/types.h>
Masahiro Yamadab44b3022017-09-16 14:10:40 +090030#include <linux/printk.h>
wdenke2211742002-11-02 23:30:20 +000031#include <linux/string.h>
Marek Vasut9aed5082012-09-27 17:08:15 +020032#include <linux/stringify.h>
wdenke2211742002-11-02 23:30:20 +000033#include <asm/ptrace.h>
34#include <stdarg.h>
Masahiro Yamada7fea7b12017-09-16 14:10:39 +090035#include <stdio.h>
Masahiro Yamadacba1da42014-11-07 03:03:28 +090036#include <linux/kernel.h>
Simon Glass85043152017-05-17 08:23:05 -060037
wdenke2211742002-11-02 23:30:20 +000038#include <part.h>
39#include <flash.h>
40#include <image.h>
41
York Sun4d1fd7f2014-02-26 17:03:19 -080042#ifdef __LP64__
43#define CONFIG_SYS_SUPPORT_64BIT_DATA
44#endif
45
Simon Glass0e98b0a2017-12-04 13:48:20 -070046#include <log.h>
Simon Glass21726a72011-06-29 09:49:34 +000047
wdenkc83bf6a2004-01-06 22:38:14 +000048#include <asm/u-boot.h> /* boot information for Linux kernel */
wdenke2211742002-11-02 23:30:20 +000049#include <asm/global_data.h> /* global data used for startup functions */
50
Patrick Delaunayd6f87712018-03-13 13:57:00 +010051/* startup functions, used in:
52 * common/board_f.c
Patrick Delaunay11f86cb2018-03-13 13:57:01 +010053 * common/init/board_init.c
Patrick Delaunaye2c219c2018-03-13 13:57:02 +010054 * common/board_r.c
Patrick Delaunayfc22ee22018-03-13 13:57:03 +010055 * common/board_info.c
Patrick Delaunayd6f87712018-03-13 13:57:00 +010056 */
Patrick Delaunaydafa84d2018-03-09 18:28:12 +010057#include <init.h>
58
wdenkc7de8292002-11-19 11:04:11 +000059/*
wdenke2211742002-11-02 23:30:20 +000060 * Function Prototypes
61 */
wdenkc83bf6a2004-01-06 22:38:14 +000062void hang (void) __attribute__ ((noreturn));
wdenke2211742002-11-02 23:30:20 +000063
Simon Glass2ea09c82015-04-28 20:25:07 -060064#include <display_options.h>
wdenke2211742002-11-02 23:30:20 +000065
66/* common/main.c */
67void main_loop (void);
wdenke2211742002-11-02 23:30:20 +000068
Patrick Delaunaye2c219c2018-03-13 13:57:02 +010069int checkflash(void);
70int checkdram(void);
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090071extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000072extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
Patrick Delaunayd6f87712018-03-13 13:57:00 +010073int mdm_init(void);
wdenke2211742002-11-02 23:30:20 +000074
Simon Glass15a33e42012-11-30 13:01:20 +000075/**
Ma Haijune29607e2014-07-12 14:24:06 +010076 * arch_fixup_fdt() - Write arch-specific information to fdt
Simon Glass13d06982013-05-08 08:06:01 +000077 *
Ma Haijune29607e2014-07-12 14:24:06 +010078 * Defined in arch/$(ARCH)/lib/bootm-fdt.c
Simon Glass13d06982013-05-08 08:06:01 +000079 *
80 * @blob: FDT blob to write to
81 * @return 0 if ok, or -ve FDT_ERR_... on failure
82 */
Ma Haijune29607e2014-07-12 14:24:06 +010083int arch_fixup_fdt(void *blob);
Simon Glass13d06982013-05-08 08:06:01 +000084
wdenke2211742002-11-02 23:30:20 +000085/* common/flash.c */
86void flash_perror (int);
87
Wolfgang Denk74de7ae2009-04-01 23:34:12 +020088/* common/cmd_source.c */
89int source (ulong addr, const char *fit_uname);
wdenke2211742002-11-02 23:30:20 +000090
wdenkc83bf6a2004-01-06 22:38:14 +000091extern ulong load_addr; /* Default Load Address */
Simon Glass1aec2442011-10-21 18:51:38 +000092extern ulong save_addr; /* Default Save Address */
93extern ulong save_size; /* Default Save Size */
wdenke2211742002-11-02 23:30:20 +000094
Jason Hobbs06283a62011-08-31 10:37:30 -050095/* common/cmd_net.c */
96int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
97
Rob Herring669df7e2012-05-25 10:47:39 +000098/* common/cmd_fat.c */
99int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
100
101/* common/cmd_ext2.c */
102int do_ext2load(cmd_tbl_t *, int, int, char * const []);
103
wdenk27b207f2003-07-24 23:38:38 +0000104/* common/exports.c */
105void jumptable_init(void);
106
Mike Frysingerecb1dc82009-05-20 04:35:14 -0400107/* common/kallsysm.c */
108const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
109
wdenkc83bf6a2004-01-06 22:38:14 +0000110/* common/memsize.c */
Albert ARIBAUDa55d23c2011-07-03 05:55:33 +0000111long get_ram_size (long *, long);
York Sune3866162014-02-11 11:57:26 -0800112phys_size_t get_effective_memsize(void);
wdenkc83bf6a2004-01-06 22:38:14 +0000113
wdenke2211742002-11-02 23:30:20 +0000114/* $(BOARD)/$(BOARD).c */
115void reset_phy (void);
wdenkc83bf6a2004-01-06 22:38:14 +0000116void fdc_hw_init (void);
wdenke2211742002-11-02 23:30:20 +0000117
Adam Fordf1b1f772018-04-15 13:51:26 -0400118#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200119# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
Heiko Schocher548738b2010-01-07 08:55:40 +0100120#endif
wdenke2211742002-11-02 23:30:20 +0000121
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200122#if defined(CONFIG_SYS_DRAM_TEST)
wdenke2211742002-11-02 23:30:20 +0000123int testdram(void);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200124#endif /* CONFIG_SYS_DRAM_TEST */
wdenke2211742002-11-02 23:30:20 +0000125
Benoît Thébaudeau5c6db122013-04-11 09:35:53 +0000126#if defined(CONFIG_ARM)
127void relocate_code(ulong);
128#else
129void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
Benoît Thébaudeau959eaa72013-04-11 09:35:43 +0000130#endif
Simon Glass6e2941d2017-05-17 08:23:06 -0600131
Diego Dorta026d7952017-10-05 09:13:38 -0300132void s_init(void);
133
wdenke2211742002-11-02 23:30:20 +0000134void upmconfig (unsigned int, unsigned int *, unsigned int);
135ulong get_tbclk (void);
Przemyslaw Marczak1fb4dab2014-09-01 13:50:48 +0200136void reset_misc (void);
wdenk3ec924a2005-04-03 17:23:39 +0000137void reset_cpu (ulong addr);
Kim Phillips6a16e0d2007-08-15 22:30:26 -0500138void ft_cpu_setup(void *blob, bd_t *bd);
Kim Phillips6a16e0d2007-08-15 22:30:26 -0500139void ft_pci_setup(void *blob, bd_t *bd);
Kim Phillips6a16e0d2007-08-15 22:30:26 -0500140
wdenke2211742002-11-02 23:30:20 +0000141/* $(CPU)/speed.c */
142int get_clocks (void);
wdenke2211742002-11-02 23:30:20 +0000143ulong get_bus_freq (ulong);
Stefan Roese550650d2010-09-20 16:05:31 +0200144int get_serial_clock(void);
wdenke2211742002-11-02 23:30:20 +0000145
Jason Hobbse11938e2011-08-23 11:06:56 +0000146/* lib/uuid.c */
Przemyslaw Marczakd718ded2014-04-02 10:20:03 +0200147#include <uuid.h>
Jason Hobbse11938e2011-08-23 11:06:56 +0000148
Peter Tyser78acc472010-04-12 22:28:05 -0500149/* lib/vsprintf.c */
Simon Glass9785c902011-11-02 09:52:07 +0000150#include <vsprintf.h>
wdenke2211742002-11-02 23:30:20 +0000151
Joe Hershberger4ef8d532012-05-23 08:01:04 +0000152/* lib/net_utils.c */
153#include <net.h>
Joe Hershberger4ef8d532012-05-23 08:01:04 +0000154
Simon Glass097e1782012-01-14 15:24:44 +0000155#include <bootstage.h>
wdenke2211742002-11-02 23:30:20 +0000156
Andre Przywara2a6713b2017-01-02 11:48:30 +0000157#else /* __ASSEMBLY__ */
158
Andre Przywara2a6713b2017-01-02 11:48:30 +0000159#endif /* __ASSEMBLY__ */
Wolfgang Denkfcd3c872009-07-24 00:17:48 +0200160
161/* Put only stuff here that the assembler can digest */
162
163#ifdef CONFIG_POST
164#define CONFIG_HAS_POST
Michael Zaidman800eb092010-09-20 08:51:53 +0200165#ifndef CONFIG_POST_ALT_LIST
166#define CONFIG_POST_STD_LIST
167#endif
Wolfgang Denkfcd3c872009-07-24 00:17:48 +0200168#endif
169
Anton Staaf155cfb52011-09-02 13:45:28 +0000170#define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
Andy Fleming4b03ac82008-06-16 13:58:53 -0500171
Anton Staaf1e41f5a2011-10-17 16:46:13 -0700172/*
Simon Glassc9689ca2015-06-23 15:38:31 -0600173 * 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 Glass476476e2015-08-04 12:33:52 -0600183/* 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 Frysingerc3eb3fe2011-07-08 10:44:25 +0000190/* Pull in stuff for the build system */
191#ifdef DO_DEPS_ONLY
Simon Glassf3998fd2019-08-02 09:44:25 -0600192# include <env_internal.h>
Mike Frysingerc3eb3fe2011-07-08 10:44:25 +0000193#endif
194
wdenke2211742002-11-02 23:30:20 +0000195#endif /* __COMMON_H_ */