Blame view

include/common.h 29.8 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>
d4ca31c40   wdenk   * Cleanup lowboot...
30
31
32
33
34
  #if defined(CONFIG_MPC852)	|| defined(CONFIG_MPC852T)	|| \
      defined(CONFIG_MPC859)	|| defined(CONFIG_MPC859T)	|| \
      defined(CONFIG_MPC859DSL)	|| \
      defined(CONFIG_MPC866)	|| defined(CONFIG_MPC866T)	|| \
      defined(CONFIG_MPC866P)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
35
  # define CONFIG_MPC866_FAMILY 1
180d3f74e   wdenk   * Fix problems ca...
36
37
38
39
  #elif defined(CONFIG_MPC870) \
     || defined(CONFIG_MPC875) \
     || defined(CONFIG_MPC880) \
     || defined(CONFIG_MPC885)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
40
  # define CONFIG_MPC885_FAMILY   1
180d3f74e   wdenk   * Fix problems ca...
41
42
43
  #endif
  #if   defined(CONFIG_MPC860)	   \
     || defined(CONFIG_MPC860T)	   \
1114257c9   wdenk   Patch by Yuli Bar...
44
45
     || defined(CONFIG_MPC866_FAMILY) \
     || defined(CONFIG_MPC885_FAMILY)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
46
  # define CONFIG_MPC86x 1
2535d6027   wdenk   * Patch by Martin...
47
  #endif
0db5bca80   wdenk   * Patch by Martin...
48
49
  #elif defined(CONFIG_5xx)
  #include <asm/5xx_immap.h>
7e6bf358d   wdenk   Patch by Martin K...
50
51
  #elif defined(CONFIG_MPC5xxx)
  #include <mpc5xxx.h>
8993e54b6   Rafal Jaworowski   [ADS5121] Support...
52
  #elif defined(CONFIG_MPC512X)
8993e54b6   Rafal Jaworowski   [ADS5121] Support...
53
  #include <asm/immap_512x.h>
e22117437   wdenk   Initial revision
54
  #elif defined(CONFIG_8260)
04a85b3b3   wdenk   * Patches by Pant...
55
56
57
58
  #if   defined(CONFIG_MPC8247) \
     || defined(CONFIG_MPC8248) \
     || defined(CONFIG_MPC8271) \
     || defined(CONFIG_MPC8272)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
59
  #define CONFIG_MPC8272_FAMILY	1
04a85b3b3   wdenk   * Patches by Pant...
60
61
  #endif
  #if defined(CONFIG_MPC8272_FAMILY)
d0b8feef8   Wolfgang Denk   Revert "common.h:...
62
  #define CONFIG_MPC8260	1
04a85b3b3   wdenk   * Patches by Pant...
63
  #endif
e22117437   wdenk   Initial revision
64
65
  #include <asm/immap_8260.h>
  #endif
debb7354d   Jon Loeliger   Initial support f...
66
67
68
69
  #ifdef CONFIG_MPC86xx
  #include <mpc86xx.h>
  #include <asm/immap_86xx.h>
  #endif
42d1f0394   wdenk   * Patches by Xian...
70
71
72
73
  #ifdef CONFIG_MPC85xx
  #include <mpc85xx.h>
  #include <asm/immap_85xx.h>
  #endif
0f8986049   Peter Tyser   83xx: Replace CON...
74
  #ifdef CONFIG_MPC83xx
f046ccd15   Eran Liberty   * Patch by Eran L...
75
76
77
  #include <mpc83xx.h>
  #include <asm/immap_83xx.h>
  #endif
e22117437   wdenk   Initial revision
78
  #ifdef	CONFIG_4xx
b36df5611   Stefan Roese   ppc4xx: Move ppc4...
79
  #include <asm/ppc4xx.h>
e22117437   wdenk   Initial revision
80
81
  #endif
  #ifdef CONFIG_HYMOD
6dd652fa4   wdenk   Patches by Murray...
82
  #include <board/hymod/hymod.h>
e22117437   wdenk   Initial revision
83
84
85
86
  #endif
  #ifdef CONFIG_ARM
  #define asmlinkage	/* nothing */
  #endif
6cfcce676   Mike Frysinger   always pull in as...
87
88
89
  #ifdef CONFIG_BLACKFIN
  #include <asm/blackfin.h>
  #endif
2819e1365   Sekhar Nori   TI DA8xx: Integra...
90
91
92
  #ifdef CONFIG_SOC_DA8XX
  #include <asm/arch/hardware.h>
  #endif
e22117437   wdenk   Initial revision
93
94
95
96
  
  #include <part.h>
  #include <flash.h>
  #include <image.h>
21726a7af   Simon Glass   Add assert() for ...
97
  #ifdef DEBUG
88a85fb9f   Marek Vasut   DEBUG: Fix debug ...
98
  #define _DEBUG	1
21726a7af   Simon Glass   Add assert() for ...
99
  #else
88a85fb9f   Marek Vasut   DEBUG: Fix debug ...
100
  #define _DEBUG	0
21726a7af   Simon Glass   Add assert() for ...
101
102
103
  #endif
  
  /*
88a85fb9f   Marek Vasut   DEBUG: Fix debug ...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
   * 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 ...
118
119
120
121
122
123
124
125
126
127
128
129
130
   * 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...
131
132
133
134
135
136
  #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...
137
  #ifndef BUG
43835aac4   Detlev Zundel   Added interrupt h...
138
  #define BUG() do { \
511d0c72b   Wolfgang Denk   Coding style cleanup
139
140
  	printf("BUG: failure at %s:%d/%s()!
  ", __FILE__, __LINE__, __FUNCTION__); \
43835aac4   Detlev Zundel   Added interrupt h...
141
142
143
  	panic("BUG!"); \
  } while (0)
  #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
cfa460adf   William Juul   Update MTD to tha...
144
  #endif /* BUG */
43835aac4   Detlev Zundel   Added interrupt h...
145

c00e17c7f   Heiko Schocher   common: move BUIL...
146
147
  /* 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_...
148
  typedef void (interrupt_handler_t)(void *);
e22117437   wdenk   Initial revision
149

c83bf6a2d   wdenk   Add a common get_...
150
  #include <asm/u-boot.h> /* boot information for Linux kernel */
e22117437   wdenk   Initial revision
151
  #include <asm/global_data.h>	/* global data used for startup functions */
71f951180   wdenk   * Fix CONFIG_NET_...
152
153
  /*
   * enable common handling for all TQM8xxL/M boards:
11d9eec47   Martin Krause   TQM885D: adjust f...
154
   * - CONFIG_TQM8xxM will be defined for all TQM8xxM boards
71f951180   wdenk   * Fix CONFIG_NET_...
155
   * - CONFIG_TQM8xxL will be defined for all TQM8xxL _and_ TQM8xxM boards
11d9eec47   Martin Krause   TQM885D: adjust f...
156
   *                  and for the TQM885D board
71f951180   wdenk   * Fix CONFIG_NET_...
157
158
159
   */
  #if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \
      defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \
11d9eec47   Martin Krause   TQM885D: adjust f...
160
      defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M)
71f951180   wdenk   * Fix CONFIG_NET_...
161
162
163
164
  # ifndef CONFIG_TQM8xxM
  #  define CONFIG_TQM8xxM
  # endif
  #endif
e22117437   wdenk   Initial revision
165
  #if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
d126bfbdb   wdenk   Add support for T...
166
      defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \
11d9eec47   Martin Krause   TQM885D: adjust f...
167
168
      defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM) || \
      defined(CONFIG_TQM885D)
e22117437   wdenk   Initial revision
169
170
171
172
  # ifndef CONFIG_TQM8xxL
  #  define CONFIG_TQM8xxL
  # endif
  #endif
e22117437   wdenk   Initial revision
173
  /*
c7de829c7   wdenk   * Patch by Thomas...
174
175
176
   * General Purpose Utilities
   */
  #define min(X, Y)				\
4f4eab4d1   Vivek Gautam   usb: common: Use ...
177
178
  	({ typeof(X) __x = (X);			\
  		typeof(Y) __y = (Y);		\
c7de829c7   wdenk   * Patch by Thomas...
179
180
181
  		(__x < __y) ? __x : __y; })
  
  #define max(X, Y)				\
4f4eab4d1   Vivek Gautam   usb: common: Use ...
182
183
  	({ typeof(X) __x = (X);			\
  		typeof(Y) __y = (Y);		\
c7de829c7   wdenk   * Patch by Thomas...
184
  		(__x > __y) ? __x : __y; })
20d04774f   Andy Fleming   Consolidate MAX/M...
185
186
  #define MIN(x, y)  min(x, y)
  #define MAX(x, y)  max(x, y)
4f4eab4d1   Vivek Gautam   usb: common: Use ...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  #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); })
  
  #define MIN3(x, y, z)  min3(x, y, z)
  #define MAX3(x, y, z)  max3(x, y, z)
a35925b8c   Simon Glass   Add abs() macro t...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
  /*
   * 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...
227
228
229
230
231
232
233
234
235
  #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...
236

289011207   Haavard Skinnemoen   Move definition o...
237
238
239
240
241
242
243
244
245
246
  /**
   * 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...
247
  /*
e22117437   wdenk   Initial revision
248
249
   * Function Prototypes
   */
c83bf6a2d   wdenk   Add a common get_...
250
  void	hang		(void) __attribute__ ((noreturn));
e22117437   wdenk   Initial revision
251

f6c019c45   Wolfgang Denk   Unify timer_init(...
252
253
  int	timer_init(void);
  int	cpu_init(void);
e22117437   wdenk   Initial revision
254
  /* */
9973e3c61   Becky Bruce   Change initdram()...
255
  phys_size_t initdram (int);
c83bf6a2d   wdenk   Add a common get_...
256
  int	display_options (void);
4b42c9059   Timur Tabi   allow print_size ...
257
  void	print_size(unsigned long long, const char *);
bda32ffcf   Simon Glass   Update print_buff...
258
259
  int print_buffer(ulong addr, const void *data, uint width, uint count,
  		 uint linelen);
e22117437   wdenk   Initial revision
260
261
262
  
  /* common/main.c */
  void	main_loop	(void);
009dde195   Simon Glass   Rename run_comman...
263
  int run_command(const char *cmd, int flag);
d51004a83   Simon Glass   Add run_command_l...
264
265
266
267
268
269
270
271
272
273
274
275
276
  
  /**
   * 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);
e22117437   wdenk   Initial revision
277
  int	readline	(const char *const prompt);
9c3483113   Heiko Schocher   common: add possi...
278
279
  int	readline_into_buffer(const char *const prompt, char *buffer,
  			int timeout);
6636b62a6   James Yang   Expose parse_line...
280
  int	parse_line (char *, char *[]);
6dd652fa4   wdenk   Patches by Murray...
281
  void	init_cmd_timeout(void);
e22117437   wdenk   Initial revision
282
  void	reset_cmd_timeout(void);
e3150460a   Igor Grinberg   common: move exte...
283
  extern char console_buffer[];
e22117437   wdenk   Initial revision
284

ea0364f1b   Peter Tyser   Move lib_$ARCH di...
285
  /* arch/$(ARCH)/lib/board.c */
e05e5de7f   Albert ARIBAUD   arm: move C runti...
286
  void	board_init_f(ulong);
6d1b6f9f8   Mike Frysinger   Mark board_init_[...
287
  void	board_init_r  (gd_t *, ulong) __attribute__ ((noreturn));
e22117437   wdenk   Initial revision
288
289
290
  int	checkboard    (void);
  int	checkflash    (void);
  int	checkdram     (void);
e22117437   wdenk   Initial revision
291
  int	last_stage_init(void);
3b57fe0a7   wdenk   * Get (mostly) ri...
292
  extern ulong monitor_flash_len;
bea3f28d2   Haiying Wang   Add support for r...
293
  int mac_read_from_eeprom(void);
6ab6b2afa   Masahiro Yamada   dts: re-write dts...
294
  extern u8 __dtb_dt_begin[];	/* embedded device tree blob */
8f5d46872   Hadli, Manjunath   davinci: add supp...
295
  int set_cpu_clk_info(void);
365475e6d   Masahiro Yamada   Move #ifdef(CONFI...
296
  #if defined(CONFIG_DISPLAY_CPUINFO)
1938f4a5b   Simon Glass   Introduce generic...
297
  int print_cpuinfo(void);
365475e6d   Masahiro Yamada   Move #ifdef(CONFI...
298
299
300
301
302
303
  #else
  static inline int print_cpuinfo(void)
  {
  	return 0;
  }
  #endif
c2240d4db   Simon Glass   Adjust board_r.c ...
304
  int update_flash_size(int flash_size);
e22117437   wdenk   Initial revision
305

15a33e49d   Simon Glass   Add option to dis...
306
307
308
309
310
311
312
313
  /**
   * 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...
314
315
316
317
318
319
320
321
322
  /**
   * arch_fixup_memory_node() - Write arch-specific memory information to fdt
   *
   * Defined in arch/$(ARCH)/lib/bootm.c
   *
   * @blob:	FDT blob to write to
   * @return 0 if ok, or -ve FDT_ERR_... on failure
   */
  int arch_fixup_memory_node(void *blob);
e22117437   wdenk   Initial revision
323
324
  /* common/flash.c */
  void flash_perror (int);
74de7aefd   Wolfgang Denk   Add "source" comm...
325
326
  /* common/cmd_source.c */
  int	source (ulong addr, const char *fit_uname);
e22117437   wdenk   Initial revision
327

c83bf6a2d   wdenk   Add a common get_...
328
  extern ulong load_addr;		/* Default Load Address */
1aec244ac   Simon Glass   tftpput: add save...
329
330
  extern ulong save_addr;		/* Default Save Address */
  extern ulong save_size;		/* Default Save Size */
e22117437   wdenk   Initial revision
331

4394f9a8c   Wolfgang Denk   BMW, PCIPPC2, PCI...
332
333
  /* common/cmd_doc.c */
  void	doc_probe(unsigned long physadr);
06283a640   Jason Hobbs   Add pxe command
334
335
  /* common/cmd_net.c */
  int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
669df7e42   Rob Herring   pxe: add support ...
336
337
338
339
340
  /* 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
341
342
343
  /* common/cmd_nvedit.c */
  int	env_init     (void);
  void	env_relocate (void);
26a41790f   Rafal Jaworowski   Globalize envmatch()
344
  int	envmatch     (uchar *, int);
84b5e8022   Wolfgang Denk   Constify getenv()...
345
346
  char	*getenv	     (const char *);
  int	getenv_f     (const char *name, char *buf, unsigned len);
4a9b41310   Simon Glass   Add getenv_ulong(...
347
  ulong getenv_ulong(const char *name, int base, ulong default_val);
76b8f79c2   Simon Glass   Add getenv_hex() ...
348
349
350
351
352
353
354
355
356
357
358
359
  
  /**
   * 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...
360
361
362
363
364
  /*
   * 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_...
365
  int	saveenv	     (void);
84b5e8022   Wolfgang Denk   Constify getenv()...
366
  int	setenv	     (const char *, const char *);
d67f10ce0   Simon Glass   Add setenv_ulong(...
367
  int setenv_ulong(const char *varname, ulong value);
bfc599664   Simon Glass   Update set_workin...
368
369
370
371
  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...
372
   * @varname:	Environment variable to set
bfc599664   Simon Glass   Update set_workin...
373
374
375
376
377
378
379
   * @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
380
  #ifdef CONFIG_ARM
96085e347   wdenk   Fix problem intro...
381
  # include <asm/mach-types.h>
b6e4c4033   wdenk   * Patch by Denis ...
382
  # include <asm/setup.h>
e22117437   wdenk   Initial revision
383
384
  # include <asm/u-boot-arm.h>	/* ARM version to be fixed! */
  #endif /* CONFIG_ARM */
fea257200   Graeme Russ   x86: Rename i386 ...
385
386
387
  #ifdef CONFIG_X86		/* x86 version to be fixed! */
  # include <asm/u-boot-x86.h>
  #endif /* CONFIG_X86 */
744d9859a   Simon Glass   sandbox: Add arch...
388
389
390
  #ifdef CONFIG_SANDBOX
  # include <asm/u-boot-sandbox.h>	/* TODO(sjg) what needs to be fixed? */
  #endif
e70838444   Macpaul Lin   nds32: add NDS32 ...
391
392
  #ifdef CONFIG_NDS32
  # include <asm/mach-types.h>
e3c58b029   ken kuo   nds32: Enable the...
393
  # include <asm/setup.h>
e70838444   Macpaul Lin   nds32: add NDS32 ...
394
395
  # include <asm/u-boot-nds32.h>
  #endif /* CONFIG_NDS32 */
e034ea3b7   Daniel Schwierzeck   MIPS: board.c: mo...
396
397
398
  #ifdef CONFIG_MIPS
  # include <asm/u-boot-mips.h>
  #endif /* CONFIG_MIPS */
bc5d54288   Alexey Brodkin   arc: bdinfo, imag...
399
400
401
  #ifdef CONFIG_ARC
  # include <asm/u-boot-arc.h>
  #endif /* CONFIG_ARC */
e22117437   wdenk   Initial revision
402

04a85b3b3   wdenk   * Patches by Pant...
403
404
405
  #ifdef CONFIG_AUTO_COMPLETE
  int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
  #endif
2f70c49e5   Heiko Schocher   netloop: speed up...
406
  int get_env_id (void);
04a85b3b3   wdenk   * Patches by Pant...
407

c83bf6a2d   wdenk   Add a common get_...
408
409
410
  void	pci_init      (void);
  void	pci_init_board(void);
  void	pciinfo	      (int, int);
e22117437   wdenk   Initial revision
411

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

e22117437   wdenk   Initial revision
442
443
  /* $(BOARD)/$(BOARD).c */
  void	reset_phy     (void);
c83bf6a2d   wdenk   Add a common get_...
444
  void	fdc_hw_init   (void);
e22117437   wdenk   Initial revision
445
446
447
  
  /* $(BOARD)/eeprom.c */
  void eeprom_init  (void);
6dd652fa4   wdenk   Patches by Murray...
448
449
450
  #ifndef CONFIG_SPI
  int  eeprom_probe (unsigned dev_addr, unsigned offset);
  #endif
e22117437   wdenk   Initial revision
451
452
453
454
455
456
457
458
459
460
461
  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...
462
463
  #if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
  # define CONFIG_SYS_DEF_EEPROM_ADDR 0
e22117437   wdenk   Initial revision
464
  #else
548738b4d   Heiko Schocher   cmd_eeprom: I2C u...
465
  #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
466
  # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
548738b4d   Heiko Schocher   cmd_eeprom: I2C u...
467
  #endif
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
468
  #endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */
e22117437   wdenk   Initial revision
469

bdccc4fed   wdenk   * Map ISP1362 USB...
470
  #if defined(CONFIG_SPI)
e22117437   wdenk   Initial revision
471
472
  extern void spi_init_f (void);
  extern void spi_init_r (void);
c83bf6a2d   wdenk   Add a common get_...
473
  extern ssize_t spi_read	 (uchar *, int, uchar *, int);
e22117437   wdenk   Initial revision
474
475
476
477
478
479
  extern ssize_t spi_write (uchar *, int, uchar *, int);
  #endif
  
  #ifdef CONFIG_RPXCLASSIC
  void rpxclassic_init (void);
  #endif
e63c8ee3d   wdenk   Patch by Sam Song...
480
  void rpxlite_init (void);
e22117437   wdenk   Initial revision
481
482
483
484
485
486
  #ifdef CONFIG_MBX
  /* $(BOARD)/mbx8xx.c */
  void	mbx_init (void);
  void	board_serial_init (void);
  void	board_ether_init (void);
  #endif
e22117437   wdenk   Initial revision
487
488
489
490
491
492
493
494
495
496
497
  #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
498
  /* $(BOARD)/$(BOARD).c */
c837dcb1a   wdenk   * The PS/2 mux on...
499
500
  int board_early_init_f (void);
  int board_late_init (void);
e22117437   wdenk   Initial revision
501
  int board_postclk_init (void); /* after clocks/timebase, before env/serial */
c837dcb1a   wdenk   * The PS/2 mux on...
502
  int board_early_init_r (void);
e22117437   wdenk   Initial revision
503
  void board_poweroff (void);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
504
  #if defined(CONFIG_SYS_DRAM_TEST)
e22117437   wdenk   Initial revision
505
  int testdram(void);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
506
  #endif /* CONFIG_SYS_DRAM_TEST */
e22117437   wdenk   Initial revision
507
508
  
  /* $(CPU)/start.S */
c83bf6a2d   wdenk   Add a common get_...
509
  #if defined(CONFIG_5xx) || \
0db5bca80   wdenk   * Patch by Martin...
510
      defined(CONFIG_8xx)
e22117437   wdenk   Initial revision
511
512
  uint	get_immr      (uint);
  #endif
c83bf6a2d   wdenk   Add a common get_...
513
  uint	get_pir	      (void);
36c728774   wdenk   * Patch by Mark J...
514
515
516
  #if defined(CONFIG_MPC5xxx)
  uint	get_svr       (void);
  #endif
e22117437   wdenk   Initial revision
517
  uint	get_pvr	      (void);
547b4cb25   wdenk   Patches by Jon Lo...
518
  uint	get_svr	      (void);
e22117437   wdenk   Initial revision
519
520
521
522
523
524
525
526
527
528
529
530
  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...
531
  void	mmu_disable(void);
5c6db120f   Benoît Thébaudeau   arm: Remove unuse...
532
533
534
535
  #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...
536
  #endif
e22117437   wdenk   Initial revision
537
538
539
  ulong	get_endaddr   (void);
  void	trap_init     (ulong);
  #if defined (CONFIG_4xx)	|| \
eeb1b77b7   wdenk   * Patch by Pierre...
540
      defined (CONFIG_MPC5xxx)	|| \
e22117437   wdenk   Initial revision
541
542
543
      defined (CONFIG_74xx_7xx)	|| \
      defined (CONFIG_74x)	|| \
      defined (CONFIG_75x)	|| \
0ac6f8b74   wdenk   Patch by Jon Loel...
544
      defined (CONFIG_74xx)	|| \
cd94ba397   Marian Balakowicz   Add Dcbz(), Dcbi(...
545
      defined (CONFIG_MPC85xx)	|| \
debb7354d   Jon Loeliger   Initial support f...
546
      defined (CONFIG_MPC86xx)	|| \
0f8986049   Peter Tyser   83xx: Replace CON...
547
      defined (CONFIG_MPC83xx)
c83bf6a2d   wdenk   Add a common get_...
548
549
550
551
552
553
554
555
556
557
558
559
560
  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...
561
  void		ppcDcbz(unsigned long value);
e22117437   wdenk   Initial revision
562
  #endif
0643631aa   Michal Simek   16bit read/write ...
563
564
565
566
  #if defined (CONFIG_MICROBLAZE)
  unsigned short	in16(unsigned int);
  void		out16(unsigned int, unsigned short value);
  #endif
e22117437   wdenk   Initial revision
567

0f8986049   Peter Tyser   83xx: Replace CON...
568
  #if defined (CONFIG_MPC83xx)
90f30a710   Dave Liu   mpc83xx: Fix the ...
569
570
  void		ppcDWload(unsigned int *addr, unsigned int *ret);
  void		ppcDWstore(unsigned int *addr, unsigned int *value);
7c6db9104   Heiko Schocher   powerpc, mpc83xx:...
571
572
573
574
575
  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 ...
576
  #endif
fc9ae1bac   Rajeshwari Shinde   exynos: Export ti...
577
578
579
580
581
  /*
   * 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
582
  /* $(CPU)/cpu.c */
fbb9ecf74   Timur Tabi   powerpc/mp: add s...
583
584
585
586
587
588
589
590
591
592
593
594
  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...
595
  int	cpu_numcores  (void);
fbb9ecf74   Timur Tabi   powerpc/mp: add s...
596
597
  u32	cpu_mask      (void);
  int	is_core_valid (unsigned int);
0e870980a   Poonam Aggrwal   8xxx: Removed CON...
598
  int	probecpu      (void);
e22117437   wdenk   Initial revision
599
600
601
602
603
  int	checkcpu      (void);
  int	checkicache   (void);
  int	checkdcache   (void);
  void	upmconfig     (unsigned int, unsigned int *, unsigned int);
  ulong	get_tbclk     (void);
3ec924a3c   wdenk   Patch by Steven S...
604
  void	reset_cpu     (ulong addr);
6a16e0dfc   Kim Phillips   mpc83xx: move com...
605
606
607
608
609
610
  #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...
611
612
  void smp_set_core_boot_addr(unsigned long addr, int corenr);
  void smp_kick_all_cpus(void);
e22117437   wdenk   Initial revision
613
614
615
616
617
  
  /* $(CPU)/serial.c */
  int	serial_init   (void);
  void	serial_setbrg (void);
  void	serial_putc   (const char);
756f586a7   wdenk   * Patch by Yusdi ...
618
  void	serial_putc_raw(const char);
e22117437   wdenk   Initial revision
619
  void	serial_puts   (const char *);
e22117437   wdenk   Initial revision
620
621
  int	serial_getc   (void);
  int	serial_tstc   (void);
756f586a7   wdenk   * Patch by Yusdi ...
622
623
624
625
626
627
  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
628
629
  /* $(CPU)/speed.c */
  int	get_clocks (void);
c178d3da6   wdenk   * Add variable CP...
630
631
  int	get_clocks_866 (void);
  int	sdram_adjust_866 (void);
e9132ea94   wdenk   Clean up the TQM8...
632
  int	adjust_sdram_tbs_8xx (void);
e22117437   wdenk   Initial revision
633
634
  #if defined(CONFIG_8260)
  int	prt_8260_clks (void);
f046ccd15   Eran Liberty   * Patch by Eran L...
635
  #elif defined(CONFIG_MPC5xxx)
945af8d72   wdenk   * Add support for...
636
637
  int	prt_mpc5xxx_clks (void);
  #endif
e22117437   wdenk   Initial revision
638
639
640
641
  #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...
642
643
  #if defined(CONFIG_S3C24X0) || \
      defined(CONFIG_LH7A40X) || \
fcfb632bd   Matthias Kaehlcke   ARM: Add support ...
644
      defined(CONFIG_EP93XX)
e22117437   wdenk   Initial revision
645
646
647
648
649
  ulong	get_FCLK (void);
  ulong	get_HCLK (void);
  ulong	get_PCLK (void);
  ulong	get_UCLK (void);
  #endif
f39748ae8   wdenk   * Patch by Paul R...
650
651
652
  #if defined(CONFIG_LH7A40X)
  ulong	get_PLLCLK (void);
  #endif
7cb22f97e   wdenk   * Make CPU clock ...
653
  #if defined CONFIG_INCA_IP
c83bf6a2d   wdenk   Add a common get_...
654
  uint	incaip_get_cpuclk (void);
7cb22f97e   wdenk   * Make CPU clock ...
655
  #endif
281e00a3b   wdenk   * Code cleanup
656
657
658
659
660
661
662
663
664
  #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
665
  ulong	get_bus_freq  (ulong);
550650ddd   Stefan Roese   ppc4xx: Use commo...
666
  int get_serial_clock(void);
e22117437   wdenk   Initial revision
667

d29d17d7b   York Sun   powerpc/mpc83xx: ...
668
669
670
  #if defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx)
  ulong get_ddr_freq(ulong);
  #endif
42d1f0394   wdenk   * Patches by Xian...
671
672
  #if defined(CONFIG_MPC85xx)
  typedef MPC85xx_SYS_INFO sys_info_t;
c83bf6a2d   wdenk   Add a common get_...
673
  void	get_sys_info  ( sys_info_t * );
871a57bb8   Miao Yan   common/cmd_bootm:...
674
675
676
677
  #  if defined(CONFIG_OF_LIBFDT)
  	void ft_fixup_cpu(void *, u64);
  	void ft_fixup_num_cores(void *);
  #  endif
42d1f0394   wdenk   * Patches by Xian...
678
  #endif
debb7354d   Jon Loeliger   Initial support f...
679
680
681
  #if defined(CONFIG_MPC86xx)
  typedef MPC86xx_SYS_INFO sys_info_t;
  void   get_sys_info  ( sys_info_t * );
5df4b0ad0   Kumar Gala   powerpc/8xxx: Rep...
682
683
684
685
  static inline ulong get_ddr_freq(ulong dummy)
  {
  	return get_bus_freq(dummy);
  }
debb7354d   Jon Loeliger   Initial support f...
686
  #endif
42d1f0394   wdenk   * Patches by Xian...
687

99bcad180   Stefan Roese   ppc4xx: Remove IO...
688
  #if defined(CONFIG_4xx)
e22117437   wdenk   Initial revision
689
  #  if defined(CONFIG_440)
6c5879f38   Marian Balakowicz   Add support for A...
690
691
692
693
  #	if defined(CONFIG_440SPE)
  	 unsigned long determine_sysper(void);
  	 unsigned long determine_pci_clock_per(void);
  #	endif
e22117437   wdenk   Initial revision
694
  #  endif
087dfdb79   Stefan Roese   ppc4xx: Consolida...
695
  typedef PPC4xx_SYS_INFO sys_info_t;
f31d38b9e   Stefan Roese   ppc4xx: Enable 40...
696
  int	ppc440spe_revB(void);
c83bf6a2d   wdenk   Add a common get_...
697
  void	get_sys_info  ( sys_info_t * );
e22117437   wdenk   Initial revision
698
699
700
701
702
703
  #endif
  
  /* $(CPU)/cpu_init.c */
  #if defined(CONFIG_8xx) || defined(CONFIG_8260)
  void	cpu_init_f    (volatile immap_t *immr);
  #endif
debb7354d   Jon Loeliger   Initial support f...
704
  #if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) || defined(CONFIG_MCF52x2) ||defined(CONFIG_MPC86xx)
e22117437   wdenk   Initial revision
705
706
  void	cpu_init_f    (void);
  #endif
bf9e3b38f   wdenk   * Some code cleanup
707

e22117437   wdenk   Initial revision
708
709
710
  int	cpu_init_r    (void);
  #if defined(CONFIG_8260)
  int	prt_8260_rsr  (void);
0f8986049   Peter Tyser   83xx: Replace CON...
711
  #elif defined(CONFIG_MPC83xx)
9be39a67c   Dave Liu   mpc83xx: Add supp...
712
  int	prt_83xx_rsr  (void);
e22117437   wdenk   Initial revision
713
714
715
  #endif
  
  /* $(CPU)/interrupts.c */
c83bf6a2d   wdenk   Add a common get_...
716
717
  int	interrupt_init	   (void);
  void	timer_interrupt	   (struct pt_regs *);
e22117437   wdenk   Initial revision
718
719
720
721
722
  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
723
724
725
  
  /* Return value of monotonic microsecond timer */
  unsigned long timer_get_us(void);
e22117437   wdenk   Initial revision
726
727
728
729
730
731
732
733
734
  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...
735
736
737
  void	bootcount_store (ulong);
  ulong	bootcount_load (void);
  #define BOOTCOUNT_MAGIC		0xB001C041
e22117437   wdenk   Initial revision
738
739
  
  /* $(CPU)/.../<eth> */
c5bded3c8   Wolfgang Denk   Add mii_init() pr...
740
  void mii_init (void);
e22117437   wdenk   Initial revision
741
742
743
  
  /* $(CPU)/.../lcd.c */
  ulong	lcd_setmem (ulong);
e22117437   wdenk   Initial revision
744
745
  /* $(CPU)/.../video.c */
  ulong	video_setmem (ulong);
ea0364f1b   Peter Tyser   Move lib_$ARCH di...
746
  /* arch/$(ARCH)/lib/cache.c */
cba4b1809   Aneesh V   arm: do not force...
747
  void	enable_caches(void);
e22117437   wdenk   Initial revision
748
  void	flush_cache   (unsigned long, unsigned long);
2c451f783   Aneesh V   armv7: cache main...
749
  void	flush_dcache_all(void);
03d3bfb00   Stefan Roese   MIPS: Add flush_d...
750
751
  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...
752
753
  void	invalidate_dcache_all(void);
  void	invalidate_icache_all(void);
0db5bca80   wdenk   * Patch by Martin...
754

ea0364f1b   Peter Tyser   Move lib_$ARCH di...
755
  /* arch/$(ARCH)/lib/ticks.S */
e22117437   wdenk   Initial revision
756
757
  unsigned long long get_ticks(void);
  void	wait_ticks    (unsigned long);
ea0364f1b   Peter Tyser   Move lib_$ARCH di...
758
  /* arch/$(ARCH)/lib/time.c */
3eb90bad6   Ingo van Lil   Generic udelay() ...
759
  void	__udelay      (unsigned long);
e22117437   wdenk   Initial revision
760
761
762
  ulong	usec2ticks    (unsigned long usec);
  ulong	ticks2usec    (unsigned long ticks);
  int	init_timebase (void);
78acc472d   Peter Tyser   Rename lib_generi...
763
  /* lib/gunzip.c */
87d93a1ba   Wolfgang Wegner   move prototypes f...
764
765
766
  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...
767
768
769
  /* 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...
770
  int strcmp_compar(const void *, const void *);
54c6977e9   Wolfgang Denk   Add qsort - add s...
771

78acc472d   Peter Tyser   Rename lib_generi...
772
  /* lib/time.c */
3eb90bad6   Ingo van Lil   Generic udelay() ...
773
  void	udelay        (unsigned long);
c4c9fbeba   Anatolij Gustschin   consolidate mdela...
774
  void mdelay(unsigned long);
3eb90bad6   Ingo van Lil   Generic udelay() ...
775

e11938eab   Jason Hobbs   lib: add uuid_str...
776
777
778
  /* lib/uuid.c */
  void uuid_str_to_bin(const char *uuid, unsigned char *out);
  int uuid_str_valid(const char *uuid);
78acc472d   Peter Tyser   Rename lib_generi...
779
  /* lib/vsprintf.c */
9785c905c   Simon Glass   Move vsprintf fun...
780
  #include <vsprintf.h>
e22117437   wdenk   Initial revision
781

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

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

9acf1ca50   Michael Walle   lib: add rand() f...
788
  /* lib/rand.c */
99e139d59   Michael Walle   net: use common r...
789
790
791
  #if defined(CONFIG_RANDOM_MACADDR) || \
  	defined(CONFIG_BOOTP_RANDOM_DELAY) || \
  	defined(CONFIG_CMD_LINK_LOCAL)
9acf1ca50   Michael Walle   lib: add rand() f...
792
793
794
795
796
  #define RAND_MAX -1U
  void srand(unsigned int seed);
  unsigned int rand(void);
  unsigned int rand_r(unsigned int *seedp);
  #endif
e22117437   wdenk   Initial revision
797
  /* common/console.c */
e22117437   wdenk   Initial revision
798
799
  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 "...
800
  int	console_assign(int file, const char *devname);	/* Assign the console	*/
e22117437   wdenk   Initial revision
801
802
803
804
805
806
807
808
  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 */
  
  /*
   * STDIO based functions (can always be used)
   */
e22117437   wdenk   Initial revision
809
  /* serial stuff */
d9c27253c   Wolfgang Denk   Make *printf() re...
810
  int	serial_printf (const char *fmt, ...)
dc4b0b38d   Andrew Klossner   Fix printf errors.
811
  		__attribute__ ((format (__printf__, 1, 2)));
e22117437   wdenk   Initial revision
812
813
814
815
816
817
818
  /* stdin */
  int	getc(void);
  int	tstc(void);
  
  /* stdout */
  void	putc(const char c);
  void	puts(const char *s);
d9c27253c   Wolfgang Denk   Make *printf() re...
819
  int	printf(const char *fmt, ...)
dc4b0b38d   Andrew Klossner   Fix printf errors.
820
  		__attribute__ ((format (__printf__, 1, 2)));
d9c27253c   Wolfgang Denk   Make *printf() re...
821
  int	vprintf(const char *fmt, va_list args);
e22117437   wdenk   Initial revision
822
823
824
825
826
827
828
829
830
  
  /* 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
831
832
833
834
  #define stdin		0
  #define stdout		1
  #define stderr		2
  #define MAX_FILES	3
d9c27253c   Wolfgang Denk   Make *printf() re...
835
  int	fprintf(int file, const char *fmt, ...)
dc4b0b38d   Andrew Klossner   Fix printf errors.
836
  		__attribute__ ((format (__printf__, 2, 3)));
e22117437   wdenk   Initial revision
837
838
839
840
  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...
841
842
843
844
845
846
  /* 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...
847
848
849
850
851
852
  /* 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...
853
854
855
856
857
858
  /*
   * CONSOLE multiplexing.
   */
  #ifdef CONFIG_CONSOLE_MUX
  #include <iomux.h>
  #endif
e22117437   wdenk   Initial revision
859
  int	pcmcia_init (void);
fb364bec5   Wolfgang Denk   Fix include/commo...
860
861
862
  #ifdef CONFIG_STATUS_LED
  # include <status_led.h>
  #endif
097e17836   Simon Glass   bootstage: Create...
863
864
  
  #include <bootstage.h>
e22117437   wdenk   Initial revision
865

48522bb50   Joe Hershberger   net: cosmetic: ne...
866
867
868
  #ifdef CONFIG_SHOW_ACTIVITY
  void show_activity(int arg);
  #endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
869
870
871
872
  /* Multicore arch functions */
  #ifdef CONFIG_MP
  int cpu_status(int nr);
  int cpu_reset(int nr);
4194b3668   Kumar Gala   Add support to di...
873
  int cpu_disable(int nr);
54841ab50   Wolfgang Denk   Make sure that ar...
874
  int cpu_release(int nr, int argc, char * const argv[]);
fcd3c87e4   Wolfgang Denk   Make include/comm...
875
  #endif
4213fc291   Simon Glass   sandbox: Add un/m...
876
877
878
879
880
881
882
883
884
885
  /* 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 ...
886

ed072b96e   Simon Glass   sandbox: Make map...
887
  static inline phys_addr_t map_to_sysmem(const void *ptr)
781adb571   Simon Glass   sandbox: Provide ...
888
889
890
  {
  	return (phys_addr_t)(uintptr_t)ptr;
  }
4213fc291   Simon Glass   sandbox: Add un/m...
891
  # endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
892
  #endif /* __ASSEMBLY__ */
13e95e423   Stefan Roese   ppc: Include <asm...
893
894
895
896
897
898
899
  #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...
900
901
902
903
  /* Put only stuff here that the assembler can digest */
  
  #ifdef CONFIG_POST
  #define CONFIG_HAS_POST
800eb0964   Michael Zaidman   POST cleanup.
904
905
906
  #ifndef CONFIG_POST_ALT_LIST
  #define CONFIG_POST_STD_LIST
  #endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
907
  #endif
8aa1a2d11   wdenk   Patch by Steven S...
908
  #ifdef CONFIG_INIT_CRITICAL
2f6fa46d4   Wolfgang Denk   Fixed common.h sp...
909
  #error CONFIG_INIT_CRITICAL is deprecated!
8aa1a2d11   wdenk   Patch by Steven S...
910
911
  #error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
  #endif
3cfb0c51b   Kumar Gala   Remove duplicate ...
912
  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
155cfb5ef   Anton Staaf   common: fix behav...
913
  #define ROUND(a,b)		(((a) + (b) - 1) & ~((b) - 1))
d50c7d4be   Wolfgang Denk   strmhz(): Round n...
914
915
916
  #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...
917

23d5c7386   Soren Brinkmann   common: Provide D...
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
  /*
   * 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
933
934
  #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...
935
936
937
938
939
940
941
  /*
   * 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_...
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
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
  /*
   * 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...
994
  #define PAD_COUNT(s, pad) (((s) - 1) / (pad) + 1)
ae1768a72   Egbert Eich   disk/gpt: Fix GPT...
995
996
  #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...
997
  	char __##name[ROUND(PAD_SIZE((size) * sizeof(type), pad), align)  \
ae1768a72   Egbert Eich   disk/gpt: Fix GPT...
998
  		      + (align - 1)];					\
de4d11355   Marek Vasut   common.h: Introdu...
999
1000
  									\
  	type *name = (type *) ALIGN((uintptr_t)__##name, align)
ae1768a72   Egbert Eich   disk/gpt: Fix GPT...
1001
1002
1003
1004
  #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_...
1005
  #define ALLOC_CACHE_ALIGN_BUFFER(type, name, size)			\
de4d11355   Marek Vasut   common.h: Introdu...
1006
1007
1008
1009
1010
1011
1012
1013
1014
  	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...
1015
  			__aligned(align);				\
46a6d51c8   Anton staaf   cache: add ALLOC_...
1016
  									\
de4d11355   Marek Vasut   common.h: Introdu...
1017
1018
1019
  	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_...
1020

c3eb3fe49   Mike Frysinger   env: allow people...
1021
1022
1023
1024
  /* Pull in stuff for the build system */
  #ifdef DO_DEPS_ONLY
  # include <environment.h>
  #endif
e22117437   wdenk   Initial revision
1025
  #endif	/* __COMMON_H_ */