blob: 52c02185f40e0ead25d761ed1c685a56de33f74a [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 volatile unsigned long vu_long;
wdenkad276f22004-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 Hershbergercbf1a932016-04-04 04:07:33 -050023#include <errno.h>
Masahiro Yamadaa4f0b8e2016-12-28 00:36:00 +090024#include <time.h>
Wolfgang Denk0191e472010-10-26 14:34:52 +020025#include <asm-offsets.h>
wdenke2211742002-11-02 23:30:20 +000026#include <linux/bitops.h>
Masahiro Yamada958f0f02017-09-16 14:10:45 +090027#include <linux/bug.h>
Masahiro Yamada29d2a622016-12-28 00:35:59 +090028#include <linux/delay.h>
wdenke2211742002-11-02 23:30:20 +000029#include <linux/types.h>
Masahiro Yamadabf9c2932017-09-16 14:10:40 +090030#include <linux/printk.h>
wdenke2211742002-11-02 23:30:20 +000031#include <linux/string.h>
Marek Vasuta3f16342012-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 Yamada5e882e92017-09-16 14:10:39 +090035#include <stdio.h>
Masahiro Yamadabd426622014-11-07 03:03:28 +090036#include <linux/kernel.h>
Simon Glass76135792017-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 Sun6c480012014-02-26 17:03:19 -080042#ifdef __LP64__
43#define CONFIG_SYS_SUPPORT_64BIT_DATA
44#endif
45
Simon Glass9054a022017-12-04 13:48:20 -070046#include <log.h>
Simon Glass02aa9e62011-06-29 09:49:34 +000047
wdenk87249ba2004-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 Delaunaya0a2b212018-03-13 13:57:00 +010051/* startup functions, used in:
52 * common/board_f.c
Patrick Delaunay98c8bbc2018-03-13 13:57:01 +010053 * common/init/board_init.c
Patrick Delaunayb76e7cf2018-03-13 13:57:02 +010054 * common/board_r.c
Patrick Delaunayb1d23442018-03-13 13:57:03 +010055 * common/board_info.c
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010056 */
Patrick Delaunayc6bfcd52018-03-09 18:28:12 +010057#include <init.h>
58
wdenk452cfd62002-11-19 11:04:11 +000059/*
wdenke2211742002-11-02 23:30:20 +000060 * Function Prototypes
61 */
wdenk87249ba2004-01-06 22:38:14 +000062void hang (void) __attribute__ ((noreturn));
wdenke2211742002-11-02 23:30:20 +000063
Simon Glass7da617c2015-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 Delaunayb76e7cf2018-03-13 13:57:02 +010069int checkflash(void);
70int checkdram(void);
Masahiro Yamada43c08932014-02-05 11:28:25 +090071extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000072extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
Patrick Delaunaya0a2b212018-03-13 13:57:00 +010073int mdm_init(void);
wdenke2211742002-11-02 23:30:20 +000074
Simon Glasseacd14f2012-11-30 13:01:20 +000075/**
Ma Haijun62358242014-07-12 14:24:06 +010076 * arch_fixup_fdt() - Write arch-specific information to fdt
Simon Glass9ca37422013-05-08 08:06:01 +000077 *
Ma Haijun62358242014-07-12 14:24:06 +010078 * Defined in arch/$(ARCH)/lib/bootm-fdt.c
Simon Glass9ca37422013-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 Haijun62358242014-07-12 14:24:06 +010083int arch_fixup_fdt(void *blob);
Simon Glass9ca37422013-05-08 08:06:01 +000084
wdenke2211742002-11-02 23:30:20 +000085/* common/flash.c */
86void flash_perror (int);
87
Wolfgang Denk85c25df2009-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
wdenk87249ba2004-01-06 22:38:14 +000091extern ulong load_addr; /* Default Load Address */
Simon Glass34f52292011-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 Hobbs0e3a5932011-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 Herringeee675f2012-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
wdenk874ac262003-07-24 23:38:38 +0000104/* common/exports.c */
105void jumptable_init(void);
106
Mike Frysingera46fbba2009-05-20 04:35:14 -0400107/* common/kallsysm.c */
108const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
109
wdenk87249ba2004-01-06 22:38:14 +0000110/* common/memsize.c */
Albert ARIBAUDa9606732011-07-03 05:55:33 +0000111long get_ram_size (long *, long);
York Sun863e8d82014-02-11 11:57:26 -0800112phys_size_t get_effective_memsize(void);
wdenk87249ba2004-01-06 22:38:14 +0000113
wdenke2211742002-11-02 23:30:20 +0000114/* $(BOARD)/$(BOARD).c */
115void reset_phy (void);
wdenk87249ba2004-01-06 22:38:14 +0000116void fdc_hw_init (void);
wdenke2211742002-11-02 23:30:20 +0000117
Adam Ford4e96ff82018-04-15 13:51:26 -0400118#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200119# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
Heiko Schocher9bb0dd52010-01-07 08:55:40 +0100120#endif
wdenke2211742002-11-02 23:30:20 +0000121
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200122#if defined(CONFIG_SYS_DRAM_TEST)
wdenke2211742002-11-02 23:30:20 +0000123int testdram(void);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200124#endif /* CONFIG_SYS_DRAM_TEST */
wdenke2211742002-11-02 23:30:20 +0000125
Benoît Thébaudeaua0436612013-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ébaudeau9039c102013-04-11 09:35:43 +0000130#endif
Simon Glass243182c2017-05-17 08:23:06 -0600131
Diego Dorta206d5802017-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 Marczakec1c1222014-09-01 13:50:48 +0200136void reset_misc (void);
wdenk1e8d0c52005-04-03 17:23:39 +0000137void reset_cpu (ulong addr);
Kim Phillipsdc0b59d2007-08-15 22:30:26 -0500138void ft_cpu_setup(void *blob, bd_t *bd);
Kim Phillipsdc0b59d2007-08-15 22:30:26 -0500139void ft_pci_setup(void *blob, bd_t *bd);
Kim Phillipsdc0b59d2007-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 Roese3ddce572010-09-20 16:05:31 +0200144int get_serial_clock(void);
wdenke2211742002-11-02 23:30:20 +0000145
Jason Hobbs6e39cce2011-08-23 11:06:56 +0000146/* lib/uuid.c */
Przemyslaw Marczak0c813362014-04-02 10:20:03 +0200147#include <uuid.h>
Jason Hobbs6e39cce2011-08-23 11:06:56 +0000148
Peter Tyser685b7f52010-04-12 22:28:05 -0500149/* lib/vsprintf.c */
Simon Glassf7ae68062011-11-02 09:52:07 +0000150#include <vsprintf.h>
wdenke2211742002-11-02 23:30:20 +0000151
Joe Hershberger05a377b2012-05-23 08:01:04 +0000152/* lib/net_utils.c */
153#include <net.h>
Joe Hershberger05a377b2012-05-23 08:01:04 +0000154
Simon Glass8445d002012-01-14 15:24:44 +0000155#include <bootstage.h>
wdenke2211742002-11-02 23:30:20 +0000156
Andre Przywara9fcee532017-01-02 11:48:30 +0000157#else /* __ASSEMBLY__ */
158
Andre Przywara9fcee532017-01-02 11:48:30 +0000159#endif /* __ASSEMBLY__ */
Wolfgang Denk66e8d442009-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 Zaidmanf969a682010-09-20 08:51:53 +0200165#ifndef CONFIG_POST_ALT_LIST
166#define CONFIG_POST_STD_LIST
167#endif
Wolfgang Denk66e8d442009-07-24 00:17:48 +0200168#endif
169
Anton Staaf07a036a2011-09-02 13:45:28 +0000170#define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
Andy Fleming2ef5ed02008-06-16 13:58:53 -0500171
Anton Staafcda2e482011-10-17 16:46:13 -0700172/*
Simon Glassd61718b2015-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 Glass63f581f2015-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 Frysinger63b8f122011-07-08 10:44:25 +0000190/* Pull in stuff for the build system */
191#ifdef DO_DEPS_ONLY
Simon Glass9d1f6192019-08-02 09:44:25 -0600192# include <env_internal.h>
Mike Frysinger63b8f122011-07-08 10:44:25 +0000193#endif
194
wdenke2211742002-11-02 23:30:20 +0000195#endif /* __COMMON_H_ */