Blame view

include/common.h 29.2 KB
e22117437   wdenk   Initial revision
1
  /*
3b74e7ec5   Wolfgang Denk   MPC512x: remove i...
2
   * (C) Copyright 2000-2009
e22117437   wdenk   Initial revision
3
4
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   *
3765b3e7b   Wolfgang Denk   Coding Style clea...
5
   * SPDX-License-Identifier:	GPL-2.0+
e22117437   wdenk   Initial revision
6
7
8
   */
  
  #ifndef __COMMON_H_
d0b8feef8   Wolfgang Denk   Revert "common.h:...
9
  #define __COMMON_H_	1
e22117437   wdenk   Initial revision
10

fcd3c87e4   Wolfgang Denk   Make include/comm...
11
  #ifndef __ASSEMBLY__		/* put C only stuff in this section */
e22117437   wdenk   Initial revision
12
13
  typedef unsigned char		uchar;
  typedef volatile unsigned long	vu_long;
180d3f74e   wdenk   * Fix problems ca...
14
  typedef volatile unsigned short vu_short;
e22117437   wdenk   Initial revision
15
16
17
  typedef volatile unsigned char	vu_char;
  
  #include <config.h>
25ddd1fb0   Wolfgang Denk   Replace CONFIG_SY...
18
  #include <asm-offsets.h>
e22117437   wdenk   Initial revision
19
20
21
  #include <linux/bitops.h>
  #include <linux/types.h>
  #include <linux/string.h>
9aed50808   Marek Vasut   COMMON: Add __str...
22
  #include <linux/stringify.h>
e22117437   wdenk   Initial revision
23
24
  #include <asm/ptrace.h>
  #include <stdarg.h>
a821d08dc   Stefan Roese   ppc4xx: Remove AP...
25
  #if defined(CONFIG_PCI) && defined(CONFIG_4xx)
e22117437   wdenk   Initial revision
26
27
  #include <pci.h>
  #endif
180d3f74e   wdenk   * Fix problems ca...
28
  #if defined(CONFIG_8xx)
e22117437   wdenk   Initial revision
29
  #include <asm/8xx_immap.h>
03f9d7d17   Masahiro Yamada   mpc8xx: remove fa...
30
31
  #if defined(CONFIG_MPC859)	|| defined(CONFIG_MPC859T)	|| \
      defined(CONFIG_MPC866)	|| \
d4ca31c40   wdenk   * Cleanup lowboot...
32
      defined(CONFIG_MPC866P)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
33
  # define CONFIG_MPC866_FAMILY 1
0ace4d9d8   Masahiro Yamada   powerpc: mpc8xx: ...
34
  #elif defined(CONFIG_MPC885)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
35
  # define CONFIG_MPC885_FAMILY   1
180d3f74e   wdenk   * Fix problems ca...
36
37
38
  #endif
  #if   defined(CONFIG_MPC860)	   \
     || defined(CONFIG_MPC860T)	   \
1114257c9   wdenk   Patch by Yuli Bar...
39
40
     || defined(CONFIG_MPC866_FAMILY) \
     || defined(CONFIG_MPC885_FAMILY)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
41
  # define CONFIG_MPC86x 1
2535d6027   wdenk   * Patch by Martin...
42
  #endif
0db5bca80   wdenk   * Patch by Martin...
43
44
  #elif defined(CONFIG_5xx)
  #include <asm/5xx_immap.h>
7e6bf358d   wdenk   Patch by Martin K...
45
46
  #elif defined(CONFIG_MPC5xxx)
  #include <mpc5xxx.h>
8993e54b6   Rafal Jaworowski   [ADS5121] Support...
47
  #elif defined(CONFIG_MPC512X)
8993e54b6   Rafal Jaworowski   [ADS5121] Support...
48
  #include <asm/immap_512x.h>
58dac3276   Masahiro Yamada   powerpc: mpc8260:...
49
  #elif defined(CONFIG_MPC8260)
04a85b3b3   wdenk   * Patches by Pant...
50
  #if   defined(CONFIG_MPC8247) \
04a85b3b3   wdenk   * Patches by Pant...
51
     || defined(CONFIG_MPC8272)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
52
  #define CONFIG_MPC8272_FAMILY	1
04a85b3b3   wdenk   * Patches by Pant...
53
  #endif
e22117437   wdenk   Initial revision
54
55
  #include <asm/immap_8260.h>
  #endif
debb7354d   Jon Loeliger   Initial support f...
56
57
58
59
  #ifdef CONFIG_MPC86xx
  #include <mpc86xx.h>
  #include <asm/immap_86xx.h>
  #endif
42d1f0394   wdenk   * Patches by Xian...
60
61
62
63
  #ifdef CONFIG_MPC85xx
  #include <mpc85xx.h>
  #include <asm/immap_85xx.h>
  #endif
0f8986049   Peter Tyser   83xx: Replace CON...
64
  #ifdef CONFIG_MPC83xx
f046ccd15   Eran Liberty   * Patch by Eran L...
65
66
67
  #include <mpc83xx.h>
  #include <asm/immap_83xx.h>
  #endif
e22117437   wdenk   Initial revision
68
  #ifdef	CONFIG_4xx
b36df5611   Stefan Roese   ppc4xx: Move ppc4...
69
  #include <asm/ppc4xx.h>
e22117437   wdenk   Initial revision
70
71
  #endif
  #ifdef CONFIG_HYMOD
6dd652fa4   wdenk   Patches by Murray...
72
  #include <board/hymod/hymod.h>
e22117437   wdenk   Initial revision
73
74
75
76
  #endif
  #ifdef CONFIG_ARM
  #define asmlinkage	/* nothing */
  #endif
6cfcce676   Mike Frysinger   always pull in as...
77
78
79
  #ifdef CONFIG_BLACKFIN
  #include <asm/blackfin.h>
  #endif
2819e1365   Sekhar Nori   TI DA8xx: Integra...
80
81
82
  #ifdef CONFIG_SOC_DA8XX
  #include <asm/arch/hardware.h>
  #endif
e22117437   wdenk   Initial revision
83
84
85
86
  
  #include <part.h>
  #include <flash.h>
  #include <image.h>
4d1fd7f1a   York Sun   Add 64-bit data s...
87
88
89
  #ifdef __LP64__
  #define CONFIG_SYS_SUPPORT_64BIT_DATA
  #endif
21726a7af   Simon Glass   Add assert() for ...
90
  #ifdef DEBUG
88a85fb9f   Marek Vasut   DEBUG: Fix debug ...
91
  #define _DEBUG	1
21726a7af   Simon Glass   Add assert() for ...
92
  #else
88a85fb9f   Marek Vasut   DEBUG: Fix debug ...
93
  #define _DEBUG	0
21726a7af   Simon Glass   Add assert() for ...
94
95
96
  #endif
  
  /*
88a85fb9f   Marek Vasut   DEBUG: Fix debug ...
97
98
99
100
101
102
103
104
105
106
107
108
109
110
   * Output a debug text when condition "cond" is met. The "cond" should be
   * computed by a preprocessor in the best case, allowing for the best
   * optimization.
   */
  #define debug_cond(cond, fmt, args...)		\
  	do {					\
  		if (cond)			\
  			printf(fmt, ##args);	\
  	} while (0)
  
  #define debug(fmt, args...)			\
  	debug_cond(_DEBUG, fmt, ##args)
  
  /*
21726a7af   Simon Glass   Add assert() for ...
111
112
113
114
115
116
117
118
119
120
121
122
123
   * An assertion is run-time check done in debug mode only. If DEBUG is not
   * defined then it is skipped. If DEBUG is defined and the assertion fails,
   * then it calls panic*( which may or may not reset/halt U-Boot (see
   * CONFIG_PANIC_HANG), It is hoped that all failing assertions are found
   * before release, and after release it is hoped that they don't matter. But
   * in any case these failing assertions cannot be fixed with a reset (which
   * may just do the same assertion again).
   */
  void __assert_fail(const char *assertion, const char *file, unsigned line,
  		   const char *function);
  #define assert(x) \
  	({ if (!(x) && _DEBUG) \
  		__assert_fail(#x, __FILE__, __LINE__, __func__); })
594d57d0c   Matthias Kaehlcke   Add EP93xx ethern...
124
125
126
127
128
129
  #define error(fmt, args...) do {					\
  		printf("ERROR: " fmt "
  at %s:%d/%s()
  ",		\
  			##args, __FILE__, __LINE__, __func__);		\
  } while (0)
cfa460adf   William Juul   Update MTD to tha...
130
  #ifndef BUG
43835aac4   Detlev Zundel   Added interrupt h...
131
  #define BUG() do { \
511d0c72b   Wolfgang Denk   Coding style cleanup
132
133
  	printf("BUG: failure at %s:%d/%s()!
  ", __FILE__, __LINE__, __FUNCTION__); \
43835aac4   Detlev Zundel   Added interrupt h...
134
135
136
  	panic("BUG!"); \
  } while (0)
  #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
cfa460adf   William Juul   Update MTD to tha...
137
  #endif /* BUG */
43835aac4   Detlev Zundel   Added interrupt h...
138

c00e17c7f   Heiko Schocher   common: move BUIL...
139
140
  /* Force a compilation error if condition is true */
  #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
c83bf6a2d   wdenk   Add a common get_...
141
  typedef void (interrupt_handler_t)(void *);
e22117437   wdenk   Initial revision
142

c83bf6a2d   wdenk   Add a common get_...
143
  #include <asm/u-boot.h> /* boot information for Linux kernel */
e22117437   wdenk   Initial revision
144
  #include <asm/global_data.h>	/* global data used for startup functions */
71f951180   wdenk   * Fix CONFIG_NET_...
145
146
  /*
   * enable common handling for all TQM8xxL/M boards:
11d9eec47   Martin Krause   TQM885D: adjust f...
147
   * - CONFIG_TQM8xxM will be defined for all TQM8xxM boards
71f951180   wdenk   * Fix CONFIG_NET_...
148
   * - CONFIG_TQM8xxL will be defined for all TQM8xxL _and_ TQM8xxM boards
11d9eec47   Martin Krause   TQM885D: adjust f...
149
   *                  and for the TQM885D board
71f951180   wdenk   * Fix CONFIG_NET_...
150
151
152
   */
  #if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \
      defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \
11d9eec47   Martin Krause   TQM885D: adjust f...
153
      defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M)
71f951180   wdenk   * Fix CONFIG_NET_...
154
155
156
157
  # ifndef CONFIG_TQM8xxM
  #  define CONFIG_TQM8xxM
  # endif
  #endif
e22117437   wdenk   Initial revision
158
  #if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
d126bfbdb   wdenk   Add support for T...
159
      defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \
11d9eec47   Martin Krause   TQM885D: adjust f...
160
161
      defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM) || \
      defined(CONFIG_TQM885D)
e22117437   wdenk   Initial revision
162
163
164
165
  # ifndef CONFIG_TQM8xxL
  #  define CONFIG_TQM8xxL
  # endif
  #endif
e22117437   wdenk   Initial revision
166
  /*
c7de829c7   wdenk   * Patch by Thomas...
167
168
169
   * General Purpose Utilities
   */
  #define min(X, Y)				\
4f4eab4d1   Vivek Gautam   usb: common: Use ...
170
171
  	({ typeof(X) __x = (X);			\
  		typeof(Y) __y = (Y);		\
c7de829c7   wdenk   * Patch by Thomas...
172
173
174
  		(__x < __y) ? __x : __y; })
  
  #define max(X, Y)				\
4f4eab4d1   Vivek Gautam   usb: common: Use ...
175
176
  	({ typeof(X) __x = (X);			\
  		typeof(Y) __y = (Y);		\
c7de829c7   wdenk   * Patch by Thomas...
177
  		(__x > __y) ? __x : __y; })
4f4eab4d1   Vivek Gautam   usb: common: Use ...
178
179
180
181
182
183
184
185
186
187
188
189
190
  #define min3(X, Y, Z)				\
  	({ typeof(X) __x = (X);			\
  		typeof(Y) __y = (Y);		\
  		typeof(Z) __z = (Z);		\
  		__x < __y ? (__x < __z ? __x : __z) :	\
  		(__y < __z ? __y : __z); })
  
  #define max3(X, Y, Z)				\
  	({ typeof(X) __x = (X);			\
  		typeof(Y) __y = (Y);		\
  		typeof(Z) __z = (Z);		\
  		__x > __y ? (__x > __z ? __x : __z) :	\
  		(__y > __z ? __y : __z); })
a35925b8c   Simon Glass   Add abs() macro t...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
  /*
   * Return the absolute value of a number.
   *
   * This handles unsigned and signed longs, ints, shorts and chars.  For all
   * input types abs() returns a signed long.
   *
   * For 64-bit types, use abs64()
   */
  #define abs(x) ({						\
  		long ret;					\
  		if (sizeof(x) == sizeof(long)) {		\
  			long __x = (x);				\
  			ret = (__x < 0) ? -__x : __x;		\
  		} else {					\
  			int __x = (x);				\
  			ret = (__x < 0) ? -__x : __x;		\
  		}						\
  		ret;						\
  	})
  
  #define abs64(x) ({				\
  		s64 __x = (x);			\
  		(__x < 0) ? -__x : __x;		\
  	})
3fbeeea63   Heiko Schocher   common: move TOTA...
215
216
217
218
219
220
221
222
223
  #if defined(CONFIG_ENV_IS_EMBEDDED)
  #define TOTAL_MALLOC_LEN	CONFIG_SYS_MALLOC_LEN
  #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
  	(CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
        defined(CONFIG_ENV_IS_IN_NVRAM)
  #define	TOTAL_MALLOC_LEN	(CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
  #else
  #define	TOTAL_MALLOC_LEN	CONFIG_SYS_MALLOC_LEN
  #endif
c7de829c7   wdenk   * Patch by Thomas...
224

289011207   Haavard Skinnemoen   Move definition o...
225
226
227
228
229
230
231
232
233
234
  /**
   * container_of - cast a member of a structure out to the containing structure
   * @ptr:	the pointer to the member.
   * @type:	the type of the container struct this is embedded in.
   * @member:	the name of the member within the struct.
   *
   */
  #define container_of(ptr, type, member) ({			\
  	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
  	(type *)( (char *)__mptr - offsetof(type,member) );})
c7de829c7   wdenk   * Patch by Thomas...
235
  /*
e22117437   wdenk   Initial revision
236
237
   * Function Prototypes
   */
c83bf6a2d   wdenk   Add a common get_...
238
  void	hang		(void) __attribute__ ((noreturn));
e22117437   wdenk   Initial revision
239

f6c019c45   Wolfgang Denk   Unify timer_init(...
240
241
  int	timer_init(void);
  int	cpu_init(void);
e22117437   wdenk   Initial revision
242
  /* */
9973e3c61   Becky Bruce   Change initdram()...
243
  phys_size_t initdram (int);
c83bf6a2d   wdenk   Add a common get_...
244
  int	display_options (void);
4b42c9059   Timur Tabi   allow print_size ...
245
  void	print_size(unsigned long long, const char *);
bda32ffcf   Simon Glass   Update print_buff...
246
247
  int print_buffer(ulong addr, const void *data, uint width, uint count,
  		 uint linelen);
e22117437   wdenk   Initial revision
248
249
250
  
  /* common/main.c */
  void	main_loop	(void);
009dde195   Simon Glass   Rename run_comman...
251
  int run_command(const char *cmd, int flag);
1d43bfd2d   Thomas Betker   Add run_command_r...
252
  int run_command_repeatable(const char *cmd, int flag);
d51004a83   Simon Glass   Add run_command_l...
253
254
255
256
257
258
259
260
261
262
263
264
265
  
  /**
   * Run a list of commands separated by ; or even \0
   *
   * Note that if 'len' is not -1, then the command does not need to be nul
   * terminated, Memory will be allocated for the command in that case.
   *
   * @param cmd	List of commands to run, each separated bu semicolon
   * @param len	Length of commands excluding terminator if known (-1 if not)
   * @param flag	Execution flags (CMD_FLAG_...)
   * @return 0 on success, or != 0 on error.
   */
  int run_command_list(const char *cmd, int len, int flag);
e3150460a   Igor Grinberg   common: move exte...
266
  extern char console_buffer[];
e22117437   wdenk   Initial revision
267

ea0364f1b   Peter Tyser   Move lib_$ARCH di...
268
  /* arch/$(ARCH)/lib/board.c */
e05e5de7f   Albert ARIBAUD   arm: move C runti...
269
  void	board_init_f(ulong);
6d1b6f9f8   Mike Frysinger   Mark board_init_[...
270
  void	board_init_r  (gd_t *, ulong) __attribute__ ((noreturn));
e22117437   wdenk   Initial revision
271
272
273
  int	checkboard    (void);
  int	checkflash    (void);
  int	checkdram     (void);
e22117437   wdenk   Initial revision
274
  int	last_stage_init(void);
3b57fe0a7   wdenk   * Get (mostly) ri...
275
  extern ulong monitor_flash_len;
bea3f28d2   Haiying Wang   Add support for r...
276
  int mac_read_from_eeprom(void);
6ab6b2afa   Masahiro Yamada   dts: re-write dts...
277
  extern u8 __dtb_dt_begin[];	/* embedded device tree blob */
8f5d46872   Hadli, Manjunath   davinci: add supp...
278
  int set_cpu_clk_info(void);
9272a9b4f   Simon Glass   m68k: powerpc: Cl...
279
  int mdm_init(void);
365475e6d   Masahiro Yamada   Move #ifdef(CONFI...
280
  #if defined(CONFIG_DISPLAY_CPUINFO)
1938f4a5b   Simon Glass   Introduce generic...
281
  int print_cpuinfo(void);
365475e6d   Masahiro Yamada   Move #ifdef(CONFI...
282
283
284
285
286
287
  #else
  static inline int print_cpuinfo(void)
  {
  	return 0;
  }
  #endif
c2240d4db   Simon Glass   Adjust board_r.c ...
288
  int update_flash_size(int flash_size);
2c072c958   Simon Glass   sandbox: config: ...
289
  int arch_early_init_r(void);
e22117437   wdenk   Initial revision
290

15a33e49d   Simon Glass   Add option to dis...
291
292
293
294
295
296
297
298
  /**
   * Show the DRAM size in a board-specific way
   *
   * This is used by boards to display DRAM information in their own way.
   *
   * @param size	Size of DRAM (which should be displayed along with other info)
   */
  void board_show_dram(ulong size);
13d06981a   Simon Glass   image: Add device...
299
  /**
e29607ed9   Ma Haijun   ARM: convert arch...
300
   * arch_fixup_fdt() - Write arch-specific information to fdt
13d06981a   Simon Glass   image: Add device...
301
   *
e29607ed9   Ma Haijun   ARM: convert arch...
302
   * Defined in arch/$(ARCH)/lib/bootm-fdt.c
13d06981a   Simon Glass   image: Add device...
303
304
305
306
   *
   * @blob:	FDT blob to write to
   * @return 0 if ok, or -ve FDT_ERR_... on failure
   */
e29607ed9   Ma Haijun   ARM: convert arch...
307
  int arch_fixup_fdt(void *blob);
13d06981a   Simon Glass   image: Add device...
308

e22117437   wdenk   Initial revision
309
310
  /* common/flash.c */
  void flash_perror (int);
74de7aefd   Wolfgang Denk   Add "source" comm...
311
312
  /* common/cmd_source.c */
  int	source (ulong addr, const char *fit_uname);
e22117437   wdenk   Initial revision
313

c83bf6a2d   wdenk   Add a common get_...
314
  extern ulong load_addr;		/* Default Load Address */
1aec244ac   Simon Glass   tftpput: add save...
315
316
  extern ulong save_addr;		/* Default Save Address */
  extern ulong save_size;		/* Default Save Size */
e22117437   wdenk   Initial revision
317

4394f9a8c   Wolfgang Denk   BMW, PCIPPC2, PCI...
318
319
  /* common/cmd_doc.c */
  void	doc_probe(unsigned long physadr);
06283a640   Jason Hobbs   Add pxe command
320
321
  /* common/cmd_net.c */
  int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
669df7e42   Rob Herring   pxe: add support ...
322
323
324
325
326
  /* common/cmd_fat.c */
  int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
  
  /* common/cmd_ext2.c */
  int do_ext2load(cmd_tbl_t *, int, int, char * const []);
e22117437   wdenk   Initial revision
327
328
329
  /* common/cmd_nvedit.c */
  int	env_init     (void);
  void	env_relocate (void);
26a41790f   Rafal Jaworowski   Globalize envmatch()
330
  int	envmatch     (uchar *, int);
20f86a0ae   Simon Glass   sandbox: Deal wit...
331
332
333
334
335
  
  /* Avoid unfortunate conflict with libc's getenv() */
  #ifdef CONFIG_SANDBOX
  #define getenv uboot_getenv
  #endif
84b5e8022   Wolfgang Denk   Constify getenv()...
336
337
  char	*getenv	     (const char *);
  int	getenv_f     (const char *name, char *buf, unsigned len);
4a9b41310   Simon Glass   Add getenv_ulong(...
338
  ulong getenv_ulong(const char *name, int base, ulong default_val);
76b8f79c2   Simon Glass   Add getenv_hex() ...
339
340
341
342
343
344
345
346
347
348
349
350
  
  /**
   * getenv_hex() - Return an environment variable as a hex value
   *
   * Decode an environment as a hex number (it may or may not have a 0x
   * prefix). If the environment variable cannot be found, or does not start
   * with hex digits, the default value is returned.
   *
   * @varname:		Variable to decode
   * @default_val:	Value to return on error
   */
  ulong getenv_hex(const char *varname, ulong default_val);
ec8a252cd   Joe Hershberger   env: Use getenv_y...
351
352
353
354
355
  /*
   * Read an environment variable as a boolean
   * Return -1 if variable does not exist (default to true)
   */
  int getenv_yesno(const char *var);
c83bf6a2d   wdenk   Add a common get_...
356
  int	saveenv	     (void);
84b5e8022   Wolfgang Denk   Constify getenv()...
357
  int	setenv	     (const char *, const char *);
d67f10ce0   Simon Glass   Add setenv_ulong(...
358
  int setenv_ulong(const char *varname, ulong value);
bfc599664   Simon Glass   Update set_workin...
359
360
361
362
  int setenv_hex(const char *varname, ulong value);
  /**
   * setenv_addr - Set an environment variable to an address in hex
   *
1bce2aeb6   Robert P. J. Day   Cosmetic: Fix a n...
363
   * @varname:	Environment variable to set
bfc599664   Simon Glass   Update set_workin...
364
365
366
367
368
369
370
   * @addr:	Value to set it to
   * @return 0 if ok, 1 on error
   */
  static inline int setenv_addr(const char *varname, const void *addr)
  {
  	return setenv_hex(varname, (ulong)addr);
  }
e22117437   wdenk   Initial revision
371
  #ifdef CONFIG_ARM
96085e347   wdenk   Fix problem intro...
372
  # include <asm/mach-types.h>
b6e4c4033   wdenk   * Patch by Denis ...
373
  # include <asm/setup.h>
e22117437   wdenk   Initial revision
374
375
  # include <asm/u-boot-arm.h>	/* ARM version to be fixed! */
  #endif /* CONFIG_ARM */
fea257200   Graeme Russ   x86: Rename i386 ...
376
377
378
  #ifdef CONFIG_X86		/* x86 version to be fixed! */
  # include <asm/u-boot-x86.h>
  #endif /* CONFIG_X86 */
744d9859a   Simon Glass   sandbox: Add arch...
379
380
381
  #ifdef CONFIG_SANDBOX
  # include <asm/u-boot-sandbox.h>	/* TODO(sjg) what needs to be fixed? */
  #endif
e70838444   Macpaul Lin   nds32: add NDS32 ...
382
383
  #ifdef CONFIG_NDS32
  # include <asm/mach-types.h>
e3c58b029   ken kuo   nds32: Enable the...
384
  # include <asm/setup.h>
e70838444   Macpaul Lin   nds32: add NDS32 ...
385
386
  # include <asm/u-boot-nds32.h>
  #endif /* CONFIG_NDS32 */
e034ea3b7   Daniel Schwierzeck   MIPS: board.c: mo...
387
388
389
  #ifdef CONFIG_MIPS
  # include <asm/u-boot-mips.h>
  #endif /* CONFIG_MIPS */
bc5d54288   Alexey Brodkin   arc: bdinfo, imag...
390
391
392
  #ifdef CONFIG_ARC
  # include <asm/u-boot-arc.h>
  #endif /* CONFIG_ARC */
e22117437   wdenk   Initial revision
393

04a85b3b3   wdenk   * Patches by Pant...
394
395
396
  #ifdef CONFIG_AUTO_COMPLETE
  int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
  #endif
2f70c49e5   Heiko Schocher   netloop: speed up...
397
  int get_env_id (void);
04a85b3b3   wdenk   * Patches by Pant...
398

c83bf6a2d   wdenk   Add a common get_...
399
400
401
  void	pci_init      (void);
  void	pci_init_board(void);
  void	pciinfo	      (int, int);
e22117437   wdenk   Initial revision
402

a821d08dc   Stefan Roese   ppc4xx: Remove AP...
403
  #if defined(CONFIG_PCI) && defined(CONFIG_4xx)
c71103f9d   Matthias Fuchs   ppc4xx: Make is_p...
404
405
      int	   pci_pre_init	       (struct pci_controller *);
      int	   is_pci_host	       (struct pci_controller *);
466fff1a7   Stefan Roese   ppc4xx: Add pci_p...
406
  #endif
dbbd12572   Stefan Roese   ppc4xx: Add PPC40...
407
  #if defined(CONFIG_PCI) && (defined(CONFIG_440) || defined(CONFIG_405EX))
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
408
  #   if defined(CONFIG_SYS_PCI_TARGET_INIT)
c83bf6a2d   wdenk   Add a common get_...
409
  	void	pci_target_init	     (struct pci_controller *);
e22117437   wdenk   Initial revision
410
  #   endif
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
411
  #   if defined(CONFIG_SYS_PCI_MASTER_INIT)
c83bf6a2d   wdenk   Add a common get_...
412
  	void	pci_master_init	     (struct pci_controller *);
e22117437   wdenk   Initial revision
413
  #   endif
6f2eb3f3d   Stefan Roese   ppc4xx: Add basic...
414
415
416
  #if defined(CONFIG_440SPE) || \
      defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
      defined(CONFIG_405EX)
7f1913938   Grzegorz Bernacki   [PPC440SPe] Impro...
417
     void pcie_setup_hoses(int busno);
692519b1e   Rafal Jaworowski   Add support for P...
418
  #endif
e22117437   wdenk   Initial revision
419
420
421
422
  #endif
  
  int	misc_init_f   (void);
  int	misc_init_r   (void);
27b207fd0   wdenk   * Implement new m...
423
424
  /* common/exports.c */
  void	jumptable_init(void);
ecb1dc892   Mike Frysinger   Add support for L...
425
426
  /* common/kallsysm.c */
  const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
500856eb1   Rafal Jaworowski   API for external ...
427
428
  /* api/api.c */
  void	api_init (void);
c83bf6a2d   wdenk   Add a common get_...
429
  /* common/memsize.c */
a55d23ccf   Albert ARIBAUD   Remove volatile q...
430
  long	get_ram_size  (long *, long);
e38661634   York Sun   common: Add get_e...
431
  phys_size_t get_effective_memsize(void);
c83bf6a2d   wdenk   Add a common get_...
432

e22117437   wdenk   Initial revision
433
434
  /* $(BOARD)/$(BOARD).c */
  void	reset_phy     (void);
c83bf6a2d   wdenk   Add a common get_...
435
  void	fdc_hw_init   (void);
e22117437   wdenk   Initial revision
436
437
438
  
  /* $(BOARD)/eeprom.c */
  void eeprom_init  (void);
6dd652fa4   wdenk   Patches by Murray...
439
440
441
  #ifndef CONFIG_SPI
  int  eeprom_probe (unsigned dev_addr, unsigned offset);
  #endif
e22117437   wdenk   Initial revision
442
443
444
445
446
447
448
449
450
451
452
  int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  #ifdef CONFIG_LWMON
  extern uchar pic_read  (uchar reg);
  extern void  pic_write (uchar reg, uchar val);
  #endif
  
  /*
   * Set this up regardless of board
   * type, to prevent errors.
   */
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
453
454
  #if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
  # define CONFIG_SYS_DEF_EEPROM_ADDR 0
e22117437   wdenk   Initial revision
455
  #else
548738b4d   Heiko Schocher   cmd_eeprom: I2C u...
456
  #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
457
  # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
548738b4d   Heiko Schocher   cmd_eeprom: I2C u...
458
  #endif
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
459
  #endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */
e22117437   wdenk   Initial revision
460

bdccc4fed   wdenk   * Map ISP1362 USB...
461
  #if defined(CONFIG_SPI)
e22117437   wdenk   Initial revision
462
463
  extern void spi_init_f (void);
  extern void spi_init_r (void);
c83bf6a2d   wdenk   Add a common get_...
464
  extern ssize_t spi_read	 (uchar *, int, uchar *, int);
e22117437   wdenk   Initial revision
465
466
  extern ssize_t spi_write (uchar *, int, uchar *, int);
  #endif
e22117437   wdenk   Initial revision
467
468
469
470
471
472
473
474
475
476
477
  #ifdef CONFIG_HERMES
  /* $(BOARD)/hermes.c */
  void hermes_start_lxt980 (int speed);
  #endif
  
  #ifdef CONFIG_EVB64260
  void  evb64260_init(void);
  void  debug_led(int, int);
  void  display_mem_map(void);
  void  perform_soft_reset(void);
  #endif
e22117437   wdenk   Initial revision
478
  /* $(BOARD)/$(BOARD).c */
c837dcb1a   wdenk   * The PS/2 mux on...
479
480
  int board_early_init_f (void);
  int board_late_init (void);
e22117437   wdenk   Initial revision
481
  int board_postclk_init (void); /* after clocks/timebase, before env/serial */
c837dcb1a   wdenk   * The PS/2 mux on...
482
  int board_early_init_r (void);
e22117437   wdenk   Initial revision
483
  void board_poweroff (void);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
484
  #if defined(CONFIG_SYS_DRAM_TEST)
e22117437   wdenk   Initial revision
485
  int testdram(void);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
486
  #endif /* CONFIG_SYS_DRAM_TEST */
e22117437   wdenk   Initial revision
487
488
  
  /* $(CPU)/start.S */
c83bf6a2d   wdenk   Add a common get_...
489
  #if defined(CONFIG_5xx) || \
0db5bca80   wdenk   * Patch by Martin...
490
      defined(CONFIG_8xx)
e22117437   wdenk   Initial revision
491
492
  uint	get_immr      (uint);
  #endif
c83bf6a2d   wdenk   Add a common get_...
493
  uint	get_pir	      (void);
36c728774   wdenk   * Patch by Mark J...
494
495
496
  #if defined(CONFIG_MPC5xxx)
  uint	get_svr       (void);
  #endif
e22117437   wdenk   Initial revision
497
  uint	get_pvr	      (void);
547b4cb25   wdenk   Patches by Jon Lo...
498
  uint	get_svr	      (void);
e22117437   wdenk   Initial revision
499
500
501
502
503
504
505
506
507
508
509
510
  uint	rd_ic_cst     (void);
  void	wr_ic_cst     (uint);
  void	wr_ic_adr     (uint);
  uint	rd_dc_cst     (void);
  void	wr_dc_cst     (uint);
  void	wr_dc_adr     (uint);
  int	icache_status (void);
  void	icache_enable (void);
  void	icache_disable(void);
  int	dcache_status (void);
  void	dcache_enable (void);
  void	dcache_disable(void);
2c451f783   Aneesh V   armv7: cache main...
511
  void	mmu_disable(void);
5c6db120f   Benoît Thébaudeau   arm: Remove unuse...
512
513
514
515
  #if defined(CONFIG_ARM)
  void	relocate_code(ulong);
  #else
  void	relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
959eaa74b   Benoît Thébaudeau   arm: relocate_cod...
516
  #endif
e22117437   wdenk   Initial revision
517
518
519
  ulong	get_endaddr   (void);
  void	trap_init     (ulong);
  #if defined (CONFIG_4xx)	|| \
eeb1b77b7   wdenk   * Patch by Pierre...
520
      defined (CONFIG_MPC5xxx)	|| \
e22117437   wdenk   Initial revision
521
522
523
      defined (CONFIG_74xx_7xx)	|| \
      defined (CONFIG_74x)	|| \
      defined (CONFIG_75x)	|| \
0ac6f8b74   wdenk   Patch by Jon Loel...
524
      defined (CONFIG_74xx)	|| \
cd94ba397   Marian Balakowicz   Add Dcbz(), Dcbi(...
525
      defined (CONFIG_MPC85xx)	|| \
debb7354d   Jon Loeliger   Initial support f...
526
      defined (CONFIG_MPC86xx)	|| \
0f8986049   Peter Tyser   83xx: Replace CON...
527
      defined (CONFIG_MPC83xx)
c83bf6a2d   wdenk   Add a common get_...
528
529
530
531
532
533
534
535
536
537
538
539
540
  unsigned char	in8(unsigned int);
  void		out8(unsigned int, unsigned char);
  unsigned short	in16(unsigned int);
  unsigned short	in16r(unsigned int);
  void		out16(unsigned int, unsigned short value);
  void		out16r(unsigned int, unsigned short value);
  unsigned long	in32(unsigned int);
  unsigned long	in32r(unsigned int);
  void		out32(unsigned int, unsigned long value);
  void		out32r(unsigned int, unsigned long value);
  void		ppcDcbf(unsigned long value);
  void		ppcDcbi(unsigned long value);
  void		ppcSync(void);
0ac6f8b74   wdenk   Patch by Jon Loel...
541
  void		ppcDcbz(unsigned long value);
e22117437   wdenk   Initial revision
542
  #endif
0643631aa   Michal Simek   16bit read/write ...
543
544
545
546
  #if defined (CONFIG_MICROBLAZE)
  unsigned short	in16(unsigned int);
  void		out16(unsigned int, unsigned short value);
  #endif
e22117437   wdenk   Initial revision
547

0f8986049   Peter Tyser   83xx: Replace CON...
548
  #if defined (CONFIG_MPC83xx)
90f30a710   Dave Liu   mpc83xx: Fix the ...
549
550
  void		ppcDWload(unsigned int *addr, unsigned int *ret);
  void		ppcDWstore(unsigned int *addr, unsigned int *value);
7c6db9104   Heiko Schocher   powerpc, mpc83xx:...
551
552
553
554
555
  void disable_addr_trans(void);
  void enable_addr_trans(void);
  #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  void ddr_enable_ecc(unsigned int dram_size);
  #endif
90f30a710   Dave Liu   mpc83xx: Fix the ...
556
  #endif
fc9ae1bac   Rajeshwari Shinde   exynos: Export ti...
557
558
559
560
561
  /*
   * Return the current value of a monotonically increasing microsecond timer.
   * Granularity may be larger than 1us if hardware does not support this.
   */
  ulong timer_get_us(void);
e22117437   wdenk   Initial revision
562
  /* $(CPU)/cpu.c */
fbb9ecf74   Timur Tabi   powerpc/mp: add s...
563
564
565
566
567
568
569
570
571
572
573
574
  static inline int cpumask_next(int cpu, unsigned int mask)
  {
  	for (cpu++; !((1 << cpu) & mask); cpu++)
  		;
  
  	return cpu;
  }
  
  #define for_each_cpu(iter, cpu, num_cpus, mask) \
  	for (iter = 0, cpu = cpumask_next(-1, mask); \
  		iter < num_cpus; \
  		iter++, cpu = cpumask_next(cpu, mask)) \
0e870980a   Poonam Aggrwal   8xxx: Removed CON...
575
  int	cpu_numcores  (void);
fbb9ecf74   Timur Tabi   powerpc/mp: add s...
576
577
  u32	cpu_mask      (void);
  int	is_core_valid (unsigned int);
0e870980a   Poonam Aggrwal   8xxx: Removed CON...
578
  int	probecpu      (void);
e22117437   wdenk   Initial revision
579
580
581
582
583
  int	checkcpu      (void);
  int	checkicache   (void);
  int	checkdcache   (void);
  void	upmconfig     (unsigned int, unsigned int *, unsigned int);
  ulong	get_tbclk     (void);
1fb4dab2a   Przemyslaw Marczak   arm:reset: call t...
584
  void	reset_misc    (void);
3ec924a3c   wdenk   Patch by Steven S...
585
  void	reset_cpu     (ulong addr);
6a16e0dfc   Kim Phillips   mpc83xx: move com...
586
587
588
589
590
591
  #if defined (CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
  void ft_cpu_setup(void *blob, bd_t *bd);
  #ifdef CONFIG_PCI
  void ft_pci_setup(void *blob, bd_t *bd);
  #endif
  #endif
ba6a16981   Andre Przywara   ARM: add SMP supp...
592
593
  void smp_set_core_boot_addr(unsigned long addr, int corenr);
  void smp_kick_all_cpus(void);
e22117437   wdenk   Initial revision
594
595
596
597
598
  
  /* $(CPU)/serial.c */
  int	serial_init   (void);
  void	serial_setbrg (void);
  void	serial_putc   (const char);
756f586a7   wdenk   * Patch by Yusdi ...
599
  void	serial_putc_raw(const char);
e22117437   wdenk   Initial revision
600
  void	serial_puts   (const char *);
e22117437   wdenk   Initial revision
601
602
  int	serial_getc   (void);
  int	serial_tstc   (void);
709ea543b   Simon Glass   stdio: Pass devic...
603
604
605
606
  /* These versions take a stdio_dev pointer */
  struct stdio_dev;
  int serial_stub_getc(struct stdio_dev *sdev);
  int serial_stub_tstc(struct stdio_dev *sdev);
756f586a7   wdenk   * Patch by Yusdi ...
607
608
609
610
611
612
  void	_serial_setbrg (const int);
  void	_serial_putc   (const char, const int);
  void	_serial_putc_raw(const char, const int);
  void	_serial_puts   (const char *, const int);
  int	_serial_getc   (const int);
  int	_serial_tstc   (const int);
e22117437   wdenk   Initial revision
613
614
  /* $(CPU)/speed.c */
  int	get_clocks (void);
c178d3da6   wdenk   * Add variable CP...
615
616
  int	get_clocks_866 (void);
  int	sdram_adjust_866 (void);
e9132ea94   wdenk   Clean up the TQM8...
617
  int	adjust_sdram_tbs_8xx (void);
58dac3276   Masahiro Yamada   powerpc: mpc8260:...
618
  #if defined(CONFIG_MPC8260)
e22117437   wdenk   Initial revision
619
  int	prt_8260_clks (void);
f046ccd15   Eran Liberty   * Patch by Eran L...
620
  #elif defined(CONFIG_MPC5xxx)
945af8d72   wdenk   * Add support for...
621
622
  int	prt_mpc5xxx_clks (void);
  #endif
e22117437   wdenk   Initial revision
623
624
625
626
  #ifdef CONFIG_4xx
  ulong	get_OPB_freq (void);
  ulong	get_PCI_freq (void);
  #endif
ac67804fb   kevin.morfitt@fearnside-systems.co.uk   Add a unified s3c...
627
628
  #if defined(CONFIG_S3C24X0) || \
      defined(CONFIG_LH7A40X) || \
fcfb632bd   Matthias Kaehlcke   ARM: Add support ...
629
      defined(CONFIG_EP93XX)
e22117437   wdenk   Initial revision
630
631
632
633
634
  ulong	get_FCLK (void);
  ulong	get_HCLK (void);
  ulong	get_PCLK (void);
  ulong	get_UCLK (void);
  #endif
f39748ae8   wdenk   * Patch by Paul R...
635
636
637
  #if defined(CONFIG_LH7A40X)
  ulong	get_PLLCLK (void);
  #endif
281e00a3b   wdenk   * Code cleanup
638
639
640
641
642
643
644
645
646
  #if defined(CONFIG_IMX)
  ulong get_systemPLLCLK(void);
  ulong get_FCLK(void);
  ulong get_HCLK(void);
  ulong get_BCLK(void);
  ulong get_PERCLK1(void);
  ulong get_PERCLK2(void);
  ulong get_PERCLK3(void);
  #endif
e22117437   wdenk   Initial revision
647
  ulong	get_bus_freq  (ulong);
550650ddd   Stefan Roese   ppc4xx: Use commo...
648
  int get_serial_clock(void);
e22117437   wdenk   Initial revision
649

42d1f0394   wdenk   * Patches by Xian...
650
651
  #if defined(CONFIG_MPC85xx)
  typedef MPC85xx_SYS_INFO sys_info_t;
c83bf6a2d   wdenk   Add a common get_...
652
  void	get_sys_info  ( sys_info_t * );
871a57bb8   Miao Yan   common/cmd_bootm:...
653
654
655
656
  #  if defined(CONFIG_OF_LIBFDT)
  	void ft_fixup_cpu(void *, u64);
  	void ft_fixup_num_cores(void *);
  #  endif
42d1f0394   wdenk   * Patches by Xian...
657
  #endif
debb7354d   Jon Loeliger   Initial support f...
658
659
660
  #if defined(CONFIG_MPC86xx)
  typedef MPC86xx_SYS_INFO sys_info_t;
  void   get_sys_info  ( sys_info_t * );
5df4b0ad0   Kumar Gala   powerpc/8xxx: Rep...
661
662
663
664
  static inline ulong get_ddr_freq(ulong dummy)
  {
  	return get_bus_freq(dummy);
  }
2f78eae50   York Sun   ARMv8/FSL_LSCH3: ...
665
666
  #else
  ulong get_ddr_freq(ulong);
debb7354d   Jon Loeliger   Initial support f...
667
  #endif
42d1f0394   wdenk   * Patches by Xian...
668

99bcad180   Stefan Roese   ppc4xx: Remove IO...
669
  #if defined(CONFIG_4xx)
e22117437   wdenk   Initial revision
670
  #  if defined(CONFIG_440)
6c5879f38   Marian Balakowicz   Add support for A...
671
672
673
674
  #	if defined(CONFIG_440SPE)
  	 unsigned long determine_sysper(void);
  	 unsigned long determine_pci_clock_per(void);
  #	endif
e22117437   wdenk   Initial revision
675
  #  endif
087dfdb79   Stefan Roese   ppc4xx: Consolida...
676
  typedef PPC4xx_SYS_INFO sys_info_t;
f31d38b9e   Stefan Roese   ppc4xx: Enable 40...
677
  int	ppc440spe_revB(void);
c83bf6a2d   wdenk   Add a common get_...
678
  void	get_sys_info  ( sys_info_t * );
e22117437   wdenk   Initial revision
679
680
681
  #endif
  
  /* $(CPU)/cpu_init.c */
58dac3276   Masahiro Yamada   powerpc: mpc8260:...
682
  #if defined(CONFIG_8xx) || defined(CONFIG_MPC8260)
e22117437   wdenk   Initial revision
683
684
  void	cpu_init_f    (volatile immap_t *immr);
  #endif
701e64014   York Sun   powerpc/mpc85xx: ...
685
  #if defined(CONFIG_4xx) || defined(CONFIG_MCF52x2) || defined(CONFIG_MPC86xx)
e22117437   wdenk   Initial revision
686
687
  void	cpu_init_f    (void);
  #endif
701e64014   York Sun   powerpc/mpc85xx: ...
688
689
690
  #ifdef CONFIG_MPC85xx
  ulong cpu_init_f(void);
  #endif
bf9e3b38f   wdenk   * Some code cleanup
691

e22117437   wdenk   Initial revision
692
  int	cpu_init_r    (void);
58dac3276   Masahiro Yamada   powerpc: mpc8260:...
693
  #if defined(CONFIG_MPC8260)
e22117437   wdenk   Initial revision
694
  int	prt_8260_rsr  (void);
0f8986049   Peter Tyser   83xx: Replace CON...
695
  #elif defined(CONFIG_MPC83xx)
9be39a67c   Dave Liu   mpc83xx: Add supp...
696
  int	prt_83xx_rsr  (void);
e22117437   wdenk   Initial revision
697
698
699
  #endif
  
  /* $(CPU)/interrupts.c */
c83bf6a2d   wdenk   Add a common get_...
700
701
  int	interrupt_init	   (void);
  void	timer_interrupt	   (struct pt_regs *);
e22117437   wdenk   Initial revision
702
703
704
705
706
  void	external_interrupt (struct pt_regs *);
  void	irq_install_handler(int, interrupt_handler_t *, void *);
  void	irq_free_handler   (int);
  void	reset_timer	   (void);
  ulong	get_timer	   (ulong base);
b2e16a85a   Simon Glass   Add trace library
707
708
709
  
  /* Return value of monotonic microsecond timer */
  unsigned long timer_get_us(void);
e22117437   wdenk   Initial revision
710
711
712
713
714
715
716
717
718
  void	enable_interrupts  (void);
  int	disable_interrupts (void);
  
  /* $(CPU)/.../commproc.c */
  int	dpram_init (void);
  uint	dpram_base(void);
  uint	dpram_base_align(uint align);
  uint	dpram_alloc(uint size);
  uint	dpram_alloc_align(uint size,uint align);
bdccc4fed   wdenk   * Map ISP1362 USB...
719
720
721
  void	bootcount_store (ulong);
  ulong	bootcount_load (void);
  #define BOOTCOUNT_MAGIC		0xB001C041
e22117437   wdenk   Initial revision
722
723
  
  /* $(CPU)/.../<eth> */
c5bded3c8   Wolfgang Denk   Add mii_init() pr...
724
  void mii_init (void);
e22117437   wdenk   Initial revision
725
726
727
  
  /* $(CPU)/.../lcd.c */
  ulong	lcd_setmem (ulong);
e22117437   wdenk   Initial revision
728
729
  /* $(CPU)/.../video.c */
  ulong	video_setmem (ulong);
ea0364f1b   Peter Tyser   Move lib_$ARCH di...
730
  /* arch/$(ARCH)/lib/cache.c */
cba4b1809   Aneesh V   arm: do not force...
731
  void	enable_caches(void);
e22117437   wdenk   Initial revision
732
  void	flush_cache   (unsigned long, unsigned long);
2c451f783   Aneesh V   armv7: cache main...
733
  void	flush_dcache_all(void);
03d3bfb00   Stefan Roese   MIPS: Add flush_d...
734
735
  void	flush_dcache_range(unsigned long start, unsigned long stop);
  void	invalidate_dcache_range(unsigned long start, unsigned long stop);
2c451f783   Aneesh V   armv7: cache main...
736
737
  void	invalidate_dcache_all(void);
  void	invalidate_icache_all(void);
0db5bca80   wdenk   * Patch by Martin...
738

ea0364f1b   Peter Tyser   Move lib_$ARCH di...
739
  /* arch/$(ARCH)/lib/ticks.S */
e22117437   wdenk   Initial revision
740
741
  unsigned long long get_ticks(void);
  void	wait_ticks    (unsigned long);
ea0364f1b   Peter Tyser   Move lib_$ARCH di...
742
  /* arch/$(ARCH)/lib/time.c */
3eb90bad6   Ingo van Lil   Generic udelay() ...
743
  void	__udelay      (unsigned long);
e22117437   wdenk   Initial revision
744
745
746
  ulong	usec2ticks    (unsigned long usec);
  ulong	ticks2usec    (unsigned long ticks);
  int	init_timebase (void);
78acc472d   Peter Tyser   Rename lib_generi...
747
  /* lib/gunzip.c */
87d93a1ba   Wolfgang Wegner   move prototypes f...
748
749
750
  int gunzip(void *, int, unsigned char *, unsigned long *);
  int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
  						int stoponerr, int offset);
54c6977e9   Wolfgang Denk   Add qsort - add s...
751
752
753
  /* lib/qsort.c */
  void qsort(void *base, size_t nmemb, size_t size,
  	   int(*compar)(const void *, const void *));
560d424b6   Mike Frysinger   env: re-add suppo...
754
  int strcmp_compar(const void *, const void *);
54c6977e9   Wolfgang Denk   Add qsort - add s...
755

78acc472d   Peter Tyser   Rename lib_generi...
756
  /* lib/time.c */
3eb90bad6   Ingo van Lil   Generic udelay() ...
757
  void	udelay        (unsigned long);
c4c9fbeba   Anatolij Gustschin   consolidate mdela...
758
  void mdelay(unsigned long);
3eb90bad6   Ingo van Lil   Generic udelay() ...
759

e11938eab   Jason Hobbs   lib: add uuid_str...
760
  /* lib/uuid.c */
d718ded05   Przemyslaw Marczak   lib: uuid: code r...
761
  #include <uuid.h>
e11938eab   Jason Hobbs   lib: add uuid_str...
762

78acc472d   Peter Tyser   Rename lib_generi...
763
  /* lib/vsprintf.c */
9785c905c   Simon Glass   Move vsprintf fun...
764
  #include <vsprintf.h>
e22117437   wdenk   Initial revision
765

78acc472d   Peter Tyser   Rename lib_generi...
766
  /* lib/strmhz.c */
55f7934d2   Ed Swarthout   strmhz: Make hz u...
767
  char *	strmhz(char *buf, unsigned long hz);
0768b7a87   Haavard Skinnemoen   Consolidate strmh...
768

78acc472d   Peter Tyser   Rename lib_generi...
769
  /* lib/crc32.c */
449609f5b   Prafulla Wadaskar   tools: mkimage: F...
770
  #include <u-boot/crc.h>
e22117437   wdenk   Initial revision
771

9acf1ca50   Michael Walle   lib: add rand() f...
772
  /* lib/rand.c */
9acf1ca50   Michael Walle   lib: add rand() f...
773
774
775
776
  #define RAND_MAX -1U
  void srand(unsigned int seed);
  unsigned int rand(void);
  unsigned int rand_r(unsigned int *seedp);
9acf1ca50   Michael Walle   lib: add rand() f...
777

e22117437   wdenk   Initial revision
778
  /* common/console.c */
e22117437   wdenk   Initial revision
779
780
  int	console_init_f(void);	/* Before relocation; uses the serial  stuff	*/
  int	console_init_r(void);	/* After  relocation; uses the console stuff	*/
d7be3056d   Mike Frysinger   stdio: constify "...
781
  int	console_assign(int file, const char *devname);	/* Assign the console	*/
e22117437   wdenk   Initial revision
782
783
784
785
  int	ctrlc (void);
  int	had_ctrlc (void);	/* have we had a Control-C since last clear? */
  void	clear_ctrlc (void);	/* clear the Control-C condition */
  int	disable_ctrlc (int);	/* 1 to disable, 0 to enable Control-C detect */
a5dffa4b6   Pierre Aubert   Add the function ...
786
  int confirm_yesno(void);        /*  1 if input is "y", "Y", "yes" or "YES" */
e22117437   wdenk   Initial revision
787
788
789
  /*
   * STDIO based functions (can always be used)
   */
e22117437   wdenk   Initial revision
790
  /* serial stuff */
d9c27253c   Wolfgang Denk   Make *printf() re...
791
  int	serial_printf (const char *fmt, ...)
dc4b0b38d   Andrew Klossner   Fix printf errors.
792
  		__attribute__ ((format (__printf__, 1, 2)));
e22117437   wdenk   Initial revision
793
794
795
796
797
798
799
  /* stdin */
  int	getc(void);
  int	tstc(void);
  
  /* stdout */
  void	putc(const char c);
  void	puts(const char *s);
d9c27253c   Wolfgang Denk   Make *printf() re...
800
  int	printf(const char *fmt, ...)
dc4b0b38d   Andrew Klossner   Fix printf errors.
801
  		__attribute__ ((format (__printf__, 1, 2)));
d9c27253c   Wolfgang Denk   Make *printf() re...
802
  int	vprintf(const char *fmt, va_list args);
e22117437   wdenk   Initial revision
803
804
805
806
807
808
809
810
811
  
  /* stderr */
  #define eputc(c)		fputc(stderr, c)
  #define eputs(s)		fputs(stderr, s)
  #define eprintf(fmt,args...)	fprintf(stderr,fmt ,##args)
  
  /*
   * FILE based functions (can only be used AFTER relocation!)
   */
e22117437   wdenk   Initial revision
812
813
814
815
  #define stdin		0
  #define stdout		1
  #define stderr		2
  #define MAX_FILES	3
d9c27253c   Wolfgang Denk   Make *printf() re...
816
  int	fprintf(int file, const char *fmt, ...)
dc4b0b38d   Andrew Klossner   Fix printf errors.
817
  		__attribute__ ((format (__printf__, 2, 3)));
e22117437   wdenk   Initial revision
818
819
820
821
  void	fputs(int file, const char *s);
  void	fputc(int file, const char c);
  int	ftstc(int file);
  int	fgetc(int file);
88d52c6af   Lei Wen   lib: add gzip lib...
822
823
824
825
826
827
  /* lib/gzip.c */
  int gzip(void *dst, unsigned long *lenp,
  		unsigned char *src, unsigned long srclen);
  int zzip(void *dst, unsigned long *lenp, unsigned char *src,
  		unsigned long srclen, int stoponerr,
  		int (*func)(unsigned long, unsigned long));
4ef8d53ca   Joe Hershberger   net: Allow filter...
828
829
830
831
832
833
  /* lib/net_utils.c */
  #include <net.h>
  static inline IPaddr_t getenv_IPaddr(char *var)
  {
  	return string_to_ip(getenv(var));
  }
16a28ef21   Gary Jennejohn   IOMUX: Add consol...
834
835
836
837
838
839
  /*
   * CONSOLE multiplexing.
   */
  #ifdef CONFIG_CONSOLE_MUX
  #include <iomux.h>
  #endif
e22117437   wdenk   Initial revision
840
  int	pcmcia_init (void);
fb364bec5   Wolfgang Denk   Fix include/commo...
841
842
843
  #ifdef CONFIG_STATUS_LED
  # include <status_led.h>
  #endif
097e17836   Simon Glass   bootstage: Create...
844
845
  
  #include <bootstage.h>
e22117437   wdenk   Initial revision
846

48522bb50   Joe Hershberger   net: cosmetic: ne...
847
848
849
  #ifdef CONFIG_SHOW_ACTIVITY
  void show_activity(int arg);
  #endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
850
851
852
853
  /* Multicore arch functions */
  #ifdef CONFIG_MP
  int cpu_status(int nr);
  int cpu_reset(int nr);
4194b3668   Kumar Gala   Add support to di...
854
  int cpu_disable(int nr);
54841ab50   Wolfgang Denk   Make sure that ar...
855
  int cpu_release(int nr, int argc, char * const argv[]);
fcd3c87e4   Wolfgang Denk   Make include/comm...
856
  #endif
4213fc291   Simon Glass   sandbox: Add un/m...
857
858
859
860
861
862
863
864
865
866
  /* Define a null map_sysmem() if the architecture doesn't use it */
  # ifndef CONFIG_ARCH_MAP_SYSMEM
  static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
  {
  	return (void *)(uintptr_t)paddr;
  }
  
  static inline void unmap_sysmem(const void *vaddr)
  {
  }
781adb571   Simon Glass   sandbox: Provide ...
867

ed072b96e   Simon Glass   sandbox: Make map...
868
  static inline phys_addr_t map_to_sysmem(const void *ptr)
781adb571   Simon Glass   sandbox: Provide ...
869
870
871
  {
  	return (phys_addr_t)(uintptr_t)ptr;
  }
4213fc291   Simon Glass   sandbox: Add un/m...
872
  # endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
873
  #endif /* __ASSEMBLY__ */
13e95e423   Stefan Roese   ppc: Include <asm...
874
875
876
877
878
879
880
  #ifdef CONFIG_PPC
  /*
   * Has to be included outside of the #ifndef __ASSEMBLY__ section.
   * Otherwise might lead to compilation errors in assembler files.
   */
  #include <asm/cache.h>
  #endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
881
882
883
884
  /* Put only stuff here that the assembler can digest */
  
  #ifdef CONFIG_POST
  #define CONFIG_HAS_POST
800eb0964   Michael Zaidman   POST cleanup.
885
886
887
  #ifndef CONFIG_POST_ALT_LIST
  #define CONFIG_POST_STD_LIST
  #endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
888
  #endif
8aa1a2d11   wdenk   Patch by Steven S...
889
  #ifdef CONFIG_INIT_CRITICAL
2f6fa46d4   Wolfgang Denk   Fixed common.h sp...
890
  #error CONFIG_INIT_CRITICAL is deprecated!
8aa1a2d11   wdenk   Patch by Steven S...
891
892
  #error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
  #endif
3cfb0c51b   Kumar Gala   Remove duplicate ...
893
  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
155cfb5ef   Anton Staaf   common: fix behav...
894
  #define ROUND(a,b)		(((a) + (b) - 1) & ~((b) - 1))
d50c7d4be   Wolfgang Denk   strmhz(): Round n...
895
896
897
  #define DIV_ROUND(n,d)		(((n) + ((d)/2)) / (d))
  #define DIV_ROUND_UP(n,d)	(((n) + (d) - 1) / (d))
  #define roundup(x, y)		((((x) + ((y) - 1)) / (y)) * (y))
022f12163   Kumar Gala   85xx: Round up fr...
898

23d5c7386   Soren Brinkmann   common: Provide D...
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
  /*
   * Divide positive or negative dividend by positive divisor and round
   * to closest integer. Result is undefined for negative divisors and
   * for negative dividends if the divisor variable type is unsigned.
   */
  #define DIV_ROUND_CLOSEST(x, divisor)(			\
  {							\
  	typeof(x) __x = x;				\
  	typeof(divisor) __d = divisor;			\
  	(((typeof(x))-1) > 0 ||				\
  	 ((typeof(divisor))-1) > 0 || (__x) > 0) ?	\
  		(((__x) + ((__d) / 2)) / (__d)) :	\
  		(((__x) - ((__d) / 2)) / (__d));	\
  }							\
  )
4b03ac8b5   Andy Fleming   Add ALIGN() macro
914
915
  #define ALIGN(x,a)		__ALIGN_MASK((x),(typeof(x))(a)-1)
  #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
1e41f5ad4   Anton Staaf   cache: include as...
916
917
918
919
920
921
922
  /*
   * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture.  It
   * is used to align DMA buffers.
   */
  #ifndef __ASSEMBLY__
  #include <asm/cache.h>
  #endif
46a6d51c8   Anton staaf   cache: add ALLOC_...
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
  /*
   * The ALLOC_CACHE_ALIGN_BUFFER macro is used to allocate a buffer on the
   * stack that meets the minimum architecture alignment requirements for DMA.
   * Such a buffer is useful for DMA operations where flushing and invalidating
   * the cache before and after a read and/or write operation is required for
   * correct operations.
   *
   * When called the macro creates an array on the stack that is sized such
   * that:
   *
   * 1) The beginning of the array can be advanced enough to be aligned.
   *
   * 2) The size of the aligned portion of the array is a multiple of the minimum
   *    architecture alignment required for DMA.
   *
   * 3) The aligned portion contains enough space for the original number of
   *    elements requested.
   *
   * The macro then creates a pointer to the aligned portion of this array and
   * assigns to the pointer the address of the first element in the aligned
   * portion of the array.
   *
   * Calling the macro as:
   *
   *     ALLOC_CACHE_ALIGN_BUFFER(uint32_t, buffer, 1024);
   *
   * Will result in something similar to saying:
   *
   *     uint32_t    buffer[1024];
   *
   * The following differences exist:
   *
   * 1) The resulting buffer is guaranteed to be aligned to the value of
   *    ARCH_DMA_MINALIGN.
   *
   * 2) The buffer variable created by the macro is a pointer to the specified
   *    type, and NOT an array of the specified type.  This can be very important
   *    if you want the address of the buffer, which you probably do, to pass it
   *    to the DMA hardware.  The value of &buffer is different in the two cases.
   *    In the macro case it will be the address of the pointer, not the address
   *    of the space reserved for the buffer.  However, in the second case it
   *    would be the address of the buffer.  So if you are replacing hard coded
   *    stack buffers with this macro you need to make sure you remove the & from
   *    the locations where you are taking the address of the buffer.
   *
   * Note that the size parameter is the number of array elements to allocate,
   * not the number of bytes.
   *
   * This macro can not be used outside of function scope, or for the creation
   * of a function scoped static buffer.  It can not be used to create a cache
   * line aligned global buffer.
   */
e8232fea4   Mischa Jonker   Add parentheses t...
975
  #define PAD_COUNT(s, pad) (((s) - 1) / (pad) + 1)
ae1768a72   Egbert Eich   disk/gpt: Fix GPT...
976
977
  #define PAD_SIZE(s, pad) (PAD_COUNT(s, pad) * pad)
  #define ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, pad)		\
e8232fea4   Mischa Jonker   Add parentheses t...
978
  	char __##name[ROUND(PAD_SIZE((size) * sizeof(type), pad), align)  \
ae1768a72   Egbert Eich   disk/gpt: Fix GPT...
979
  		      + (align - 1)];					\
de4d11355   Marek Vasut   common.h: Introdu...
980
981
  									\
  	type *name = (type *) ALIGN((uintptr_t)__##name, align)
ae1768a72   Egbert Eich   disk/gpt: Fix GPT...
982
983
984
985
  #define ALLOC_ALIGN_BUFFER(type, name, size, align)		\
  	ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, 1)
  #define ALLOC_CACHE_ALIGN_BUFFER_PAD(type, name, size, pad)		\
  	ALLOC_ALIGN_BUFFER_PAD(type, name, size, ARCH_DMA_MINALIGN, pad)
46a6d51c8   Anton staaf   cache: add ALLOC_...
986
  #define ALLOC_CACHE_ALIGN_BUFFER(type, name, size)			\
de4d11355   Marek Vasut   common.h: Introdu...
987
988
989
990
991
992
993
994
995
  	ALLOC_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN)
  
  /*
   * DEFINE_CACHE_ALIGN_BUFFER() is similar to ALLOC_CACHE_ALIGN_BUFFER, but it's
   * purpose is to allow allocating aligned buffers outside of function scope.
   * Usage of this macro shall be avoided or used with extreme care!
   */
  #define DEFINE_ALIGN_BUFFER(type, name, size, align)			\
  	static char __##name[roundup(size * sizeof(type), align)]	\
d7ea4d4d4   Egbert Eich   disk/iso: Add Sup...
996
  			__aligned(align);				\
46a6d51c8   Anton staaf   cache: add ALLOC_...
997
  									\
de4d11355   Marek Vasut   common.h: Introdu...
998
999
1000
  	static type *name = (type *)__##name
  #define DEFINE_CACHE_ALIGN_BUFFER(type, name, size)			\
  	DEFINE_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN)
46a6d51c8   Anton staaf   cache: add ALLOC_...
1001

c3eb3fe49   Mike Frysinger   env: allow people...
1002
1003
1004
1005
  /* Pull in stuff for the build system */
  #ifdef DO_DEPS_ONLY
  # include <environment.h>
  #endif
e22117437   wdenk   Initial revision
1006
  #endif	/* __COMMON_H_ */