blob: 8b37b58747474cad67d0ac19cfe0cc66bf27b4c0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenke2211742002-11-02 23:30:20 +00002/*
Simon Glass1ed83ba2019-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 Glassadaaa482019-11-14 12:57:43 -07006 * headers. Please think before adding more things.
Simon Glass495a5dc2019-11-14 12:57:30 -07007 * Patches to remove things are welcome.
Simon Glass1ed83ba2019-08-02 09:44:27 -06008 *
Wolfgang Denkf342f862009-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 Denkbcbd5212012-01-06 07:36:44 +010014#define __COMMON_H_ 1
wdenke2211742002-11-02 23:30:20 +000015
Wolfgang Denk66e8d442009-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;
wdenkad276f22004-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 Hershbergercbf1a932016-04-04 04:07:33 -050024#include <errno.h>
Masahiro Yamadaa4f0b8e2016-12-28 00:36:00 +090025#include <time.h>
Wolfgang Denk0191e472010-10-26 14:34:52 +020026#include <asm-offsets.h>
wdenke2211742002-11-02 23:30:20 +000027#include <linux/bitops.h>
Masahiro Yamada958f0f02017-09-16 14:10:45 +090028#include <linux/bug.h>
Masahiro Yamada29d2a622016-12-28 00:35:59 +090029#include <linux/delay.h>
wdenke2211742002-11-02 23:30:20 +000030#include <linux/types.h>
Masahiro Yamadabf9c2932017-09-16 14:10:40 +090031#include <linux/printk.h>
wdenke2211742002-11-02 23:30:20 +000032#include <linux/string.h>
Marek Vasuta3f16342012-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 Yamada5e882e92017-09-16 14:10:39 +090036#include <stdio.h>
Masahiro Yamadabd426622014-11-07 03:03:28 +090037#include <linux/kernel.h>
Simon Glass76135792017-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 Sun6c480012014-02-26 17:03:19 -080043#ifdef __LP64__
44#define CONFIG_SYS_SUPPORT_64BIT_DATA
45#endif
46
Simon Glass9054a022017-12-04 13:48:20 -070047#include <log.h>
Simon Glass02aa9e62011-06-29 09:49:34 +000048
wdenk87249ba2004-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 Delaunaya0a2b212018-03-13 13:57:00 +010052/* startup functions, used in:
53 * common/board_f.c
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +010054 * common/init/board_init.c
Patrick Delaunayb76e7cf2018-03-13 13:57:02 +010055 * common/board_r.c
Patrick Delaunayb1d23442018-03-13 13:57:03 +010056 * common/board_info.c
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010057 */
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +010058#include <init.h>
59
wdenk452cfd62002-11-19 11:04:11 +000060/*
wdenke2211742002-11-02 23:30:20 +000061 * Function Prototypes
62 */
wdenk87249ba2004-01-06 22:38:14 +000063void hang (void) __attribute__ ((noreturn));
wdenke2211742002-11-02 23:30:20 +000064
Simon Glass7da617c2015-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 Delaunayb76e7cf2018-03-13 13:57:02 +010070int checkflash(void);
71int checkdram(void);
Masahiro Yamada43c08932014-02-05 11:28:25 +090072extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000073extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010074int mdm_init(void);
wdenke2211742002-11-02 23:30:20 +000075
Simon Glasseacd14f2012-11-30 13:01:20 +000076/**
Ma Haijun62358242014-07-12 14:24:06 +010077 * arch_fixup_fdt() - Write arch-specific information to fdt
Simon Glass9ca37422013-05-08 08:06:01 +000078 *
Ma Haijun62358242014-07-12 14:24:06 +010079 * Defined in arch/$(ARCH)/lib/bootm-fdt.c
Simon Glass9ca37422013-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 Haijun62358242014-07-12 14:24:06 +010084int arch_fixup_fdt(void *blob);
Simon Glass9ca37422013-05-08 08:06:01 +000085
wdenke2211742002-11-02 23:30:20 +000086/* common/flash.c */
87void flash_perror (int);
88
Wolfgang Denk85c25df2009-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
wdenk87249ba2004-01-06 22:38:14 +000092extern ulong load_addr; /* Default Load Address */
Simon Glass34f52292011-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 Hobbs0e3a5932011-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 Herringeee675f2012-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
wdenk874ac262003-07-24 23:38:38 +0000105/* common/exports.c */
106void jumptable_init(void);
107
Mike Frysingera46fbba2009-05-20 04:35:14 -0400108/* common/kallsysm.c */
109const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
110
wdenk87249ba2004-01-06 22:38:14 +0000111/* common/memsize.c */
Albert ARIBAUDa9606732011-07-03 05:55:33 +0000112long get_ram_size (long *, long);
York Sun863e8d82014-02-11 11:57:26 -0800113phys_size_t get_effective_memsize(void);
wdenk87249ba2004-01-06 22:38:14 +0000114
wdenke2211742002-11-02 23:30:20 +0000115/* $(BOARD)/$(BOARD).c */
116void reset_phy (void);
wdenk87249ba2004-01-06 22:38:14 +0000117void fdc_hw_init (void);
wdenke2211742002-11-02 23:30:20 +0000118
Adam Ford4e96ff82018-04-15 13:51:26 -0400119#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200120# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
Heiko Schocher9bb0dd52010-01-07 08:55:40 +0100121#endif
wdenke2211742002-11-02 23:30:20 +0000122
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200123#if defined(CONFIG_SYS_DRAM_TEST)
wdenke2211742002-11-02 23:30:20 +0000124int testdram(void);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200125#endif /* CONFIG_SYS_DRAM_TEST */
wdenke2211742002-11-02 23:30:20 +0000126
Benoît Thébaudeaua0436612013-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ébaudeau9039c102013-04-11 09:35:43 +0000131#endif
Simon Glass243182c2017-05-17 08:23:06 -0600132
Diego Dorta206d5802017-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 Marczakec1c1222014-09-01 13:50:48 +0200137void reset_misc (void);
wdenk1e8d0c52005-04-03 17:23:39 +0000138void reset_cpu (ulong addr);
Kim Phillipsdc0b59d2007-08-15 22:30:26 -0500139void ft_cpu_setup(void *blob, bd_t *bd);
Kim Phillipsdc0b59d2007-08-15 22:30:26 -0500140void ft_pci_setup(void *blob, bd_t *bd);
Kim Phillipsdc0b59d2007-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 Roese3ddce572010-09-20 16:05:31 +0200145int get_serial_clock(void);
wdenke2211742002-11-02 23:30:20 +0000146
Jason Hobbs6e39cce2011-08-23 11:06:56 +0000147/* lib/uuid.c */
Przemyslaw Marczak0c813362014-04-02 10:20:03 +0200148#include <uuid.h>
Jason Hobbs6e39cce2011-08-23 11:06:56 +0000149
Peter Tyser685b7f52010-04-12 22:28:05 -0500150/* lib/vsprintf.c */
Simon Glassf7ae68062011-11-02 09:52:07 +0000151#include <vsprintf.h>
wdenke2211742002-11-02 23:30:20 +0000152
Joe Hershberger05a377b2012-05-23 08:01:04 +0000153/* lib/net_utils.c */
154#include <net.h>
Joe Hershberger05a377b2012-05-23 08:01:04 +0000155
Simon Glass8445d002012-01-14 15:24:44 +0000156#include <bootstage.h>
wdenke2211742002-11-02 23:30:20 +0000157
Andre Przywara9fcee532017-01-02 11:48:30 +0000158#else /* __ASSEMBLY__ */
159
Andre Przywara9fcee532017-01-02 11:48:30 +0000160#endif /* __ASSEMBLY__ */
Wolfgang Denk66e8d442009-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 Zaidmanf969a682010-09-20 08:51:53 +0200166#ifndef CONFIG_POST_ALT_LIST
167#define CONFIG_POST_STD_LIST
168#endif
Wolfgang Denk66e8d442009-07-24 00:17:48 +0200169#endif
170
Anton Staaf07a036a2011-09-02 13:45:28 +0000171#define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
Andy Fleming2ef5ed02008-06-16 13:58:53 -0500172
Anton Staafcda2e482011-10-17 16:46:13 -0700173/*
Simon Glassd61718b2015-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 Glass63f581f2015-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 Frysinger63b8f122011-07-08 10:44:25 +0000191/* Pull in stuff for the build system */
192#ifdef DO_DEPS_ONLY
Simon Glass9d1f6192019-08-02 09:44:25 -0600193# include <env_internal.h>
Mike Frysinger63b8f122011-07-08 10:44:25 +0000194#endif
195
wdenke2211742002-11-02 23:30:20 +0000196#endif /* __COMMON_H_ */