Blame view

include/common.h 15.7 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  /* SPDX-License-Identifier: GPL-2.0+ */
e22117437   wdenk   Initial revision
2
  /*
3b74e7ec5   Wolfgang Denk   MPC512x: remove i...
3
   * (C) Copyright 2000-2009
e22117437   wdenk   Initial revision
4
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
e22117437   wdenk   Initial revision
5
6
7
   */
  
  #ifndef __COMMON_H_
d0b8feef8   Wolfgang Denk   Revert "common.h:...
8
  #define __COMMON_H_	1
e22117437   wdenk   Initial revision
9

fcd3c87e4   Wolfgang Denk   Make include/comm...
10
  #ifndef __ASSEMBLY__		/* put C only stuff in this section */
e22117437   wdenk   Initial revision
11
12
  typedef unsigned char		uchar;
  typedef volatile unsigned long	vu_long;
180d3f74e   wdenk   * Fix problems ca...
13
  typedef volatile unsigned short vu_short;
e22117437   wdenk   Initial revision
14
15
16
  typedef volatile unsigned char	vu_char;
  
  #include <config.h>
2307ea405   Joe Hershberger   common: Always in...
17
  #include <errno.h>
a7b817699   Masahiro Yamada   time: move timer ...
18
  #include <time.h>
25ddd1fb0   Wolfgang Denk   Replace CONFIG_SY...
19
  #include <asm-offsets.h>
e22117437   wdenk   Initial revision
20
  #include <linux/bitops.h>
0a70fb4c1   Masahiro Yamada   bug.h: move runti...
21
  #include <linux/bug.h>
5bc516ed6   Masahiro Yamada   delay: collect {m...
22
  #include <linux/delay.h>
e22117437   wdenk   Initial revision
23
  #include <linux/types.h>
b44b30260   Masahiro Yamada   printk: collect p...
24
  #include <linux/printk.h>
e22117437   wdenk   Initial revision
25
  #include <linux/string.h>
9aed50808   Marek Vasut   COMMON: Add __str...
26
  #include <linux/stringify.h>
e22117437   wdenk   Initial revision
27
28
  #include <asm/ptrace.h>
  #include <stdarg.h>
7fea7b1a3   Masahiro Yamada   stdio.h: move pri...
29
  #include <stdio.h>
cba1da495   Masahiro Yamada   include: move var...
30
  #include <linux/kernel.h>
850431590   Simon Glass   common: powerpc: ...
31

e22117437   wdenk   Initial revision
32
33
34
  #include <part.h>
  #include <flash.h>
  #include <image.h>
4d1fd7f1a   York Sun   Add 64-bit data s...
35
36
37
  #ifdef __LP64__
  #define CONFIG_SYS_SUPPORT_64BIT_DATA
  #endif
0e98b0a65   Simon Glass   Move debug and lo...
38
  #include <log.h>
21726a7af   Simon Glass   Add assert() for ...
39

c83bf6a2d   wdenk   Add a common get_...
40
  typedef void (interrupt_handler_t)(void *);
e22117437   wdenk   Initial revision
41

c83bf6a2d   wdenk   Add a common get_...
42
  #include <asm/u-boot.h> /* boot information for Linux kernel */
e22117437   wdenk   Initial revision
43
  #include <asm/global_data.h>	/* global data used for startup functions */
3fbeeea63   Heiko Schocher   common: move TOTA...
44
45
46
47
48
49
50
51
52
  #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...
53

d6f877123   Patrick Delaunay   common: move boar...
54
55
  /* startup functions, used in:
   * common/board_f.c
11f86cbaf   Patrick Delaunay   common: move boar...
56
   * common/init/board_init.c
e2c219cd7   Patrick Delaunay   common: move boar...
57
   * common/board_r.c
fc22ee215   Patrick Delaunay   common: move boar...
58
   * common/board_info.c
d6f877123   Patrick Delaunay   common: move boar...
59
   */
dafa84d27   Patrick Delaunay   common: add a pro...
60
  #include <init.h>
c7de829c7   wdenk   * Patch by Thomas...
61
  /*
e22117437   wdenk   Initial revision
62
63
   * Function Prototypes
   */
c83bf6a2d   wdenk   Add a common get_...
64
  void	hang		(void) __attribute__ ((noreturn));
e22117437   wdenk   Initial revision
65

f6c019c45   Wolfgang Denk   Unify timer_init(...
66
  int	cpu_init(void);
2ea09c836   Simon Glass   Move display_opti...
67
  #include <display_options.h>
e22117437   wdenk   Initial revision
68
69
70
  
  /* common/main.c */
  void	main_loop	(void);
009dde195   Simon Glass   Rename run_comman...
71
  int run_command(const char *cmd, int flag);
1d43bfd2d   Thomas Betker   Add run_command_r...
72
  int run_command_repeatable(const char *cmd, int flag);
d51004a83   Simon Glass   Add run_command_l...
73
74
75
76
77
78
79
80
81
82
83
84
85
  
  /**
   * 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
86

e2c219cd7   Patrick Delaunay   common: move boar...
87
88
  int checkflash(void);
  int checkdram(void);
6ab6b2afa   Masahiro Yamada   dts: re-write dts...
89
  extern u8 __dtb_dt_begin[];	/* embedded device tree blob */
9bd76b807   Goldschmidt Simon   spl: make CONFIG_...
90
  extern u8 __dtb_dt_spl_begin[];	/* embedded device tree blob for SPL/TPL */
d6f877123   Patrick Delaunay   common: move boar...
91
  int mdm_init(void);
e22117437   wdenk   Initial revision
92

9b149c2a2   Ye Li   MLK-18591-3 andro...
93
94
95
  #ifdef CONFIG_ANDROID_BOOT_IMAGE
  void get_reboot_reason(char *ret);
  #endif
15a33e49d   Simon Glass   Add option to dis...
96
97
98
99
100
101
102
  /**
   * 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)
   */
ea11b401b   Andrew Bradford   meminfo cmd: Enab...
103
  void board_show_dram(phys_size_t size);
15a33e49d   Simon Glass   Add option to dis...
104

13d06981a   Simon Glass   image: Add device...
105
  /**
7b78d6438   Alexander Graf   efi_loader: Reser...
106
107
108
109
110
111
112
113
114
115
116
   * Get the uppermost pointer that is valid to access
   *
   * Some systems may not map all of their address space. This function allows
   * boards to indicate what their highest support pointer value is for DRAM
   * access.
   *
   * @param total_size	Size of U-Boot (unused?)
   */
  ulong board_get_usable_ram_top(ulong total_size);
  
  /**
e29607ed9   Ma Haijun   ARM: convert arch...
117
   * arch_fixup_fdt() - Write arch-specific information to fdt
13d06981a   Simon Glass   image: Add device...
118
   *
e29607ed9   Ma Haijun   ARM: convert arch...
119
   * Defined in arch/$(ARCH)/lib/bootm-fdt.c
13d06981a   Simon Glass   image: Add device...
120
121
122
123
   *
   * @blob:	FDT blob to write to
   * @return 0 if ok, or -ve FDT_ERR_... on failure
   */
e29607ed9   Ma Haijun   ARM: convert arch...
124
  int arch_fixup_fdt(void *blob);
13d06981a   Simon Glass   image: Add device...
125

e22117437   wdenk   Initial revision
126
127
  /* common/flash.c */
  void flash_perror (int);
74de7aefd   Wolfgang Denk   Add "source" comm...
128
129
  /* common/cmd_source.c */
  int	source (ulong addr, const char *fit_uname);
e22117437   wdenk   Initial revision
130

c83bf6a2d   wdenk   Add a common get_...
131
  extern ulong load_addr;		/* Default Load Address */
1aec244ac   Simon Glass   tftpput: add save...
132
133
  extern ulong save_addr;		/* Default Save Address */
  extern ulong save_size;		/* Default Save Size */
e22117437   wdenk   Initial revision
134

06283a640   Jason Hobbs   Add pxe command
135
136
  /* common/cmd_net.c */
  int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
669df7e42   Rob Herring   pxe: add support ...
137
  /* common/cmd_fat.c */
237742f73   Peng Fan   MLK-12425-2 video...
138
139
140
  int do_fat_size(cmd_tbl_t *, int, int, char * const []);
  
  /* common/cmd_fat.c */
669df7e42   Rob Herring   pxe: add support ...
141
142
143
144
  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
145
146
147
  /* common/cmd_nvedit.c */
  int	env_init     (void);
  void	env_relocate (void);
26a41790f   Rafal Jaworowski   Globalize envmatch()
148
  int	envmatch     (uchar *, int);
20f86a0ae   Simon Glass   sandbox: Deal wit...
149

00caae6d4   Simon Glass   env: Rename geten...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  /**
   * env_get() - Look up the value of an environment variable
   *
   * In U-Boot proper this can be called before relocation (which is when the
   * environment is loaded from storage, i.e. GD_FLG_ENV_READY is 0). In that
   * case this function calls env_get_f().
   *
   * @varname:	Variable to look up
   * @return value of variable, or NULL if not found
   */
  char *env_get(const char *varname);
  
  /**
   * env_get_f() - Look up the value of an environment variable (early)
   *
   * This function is called from env_get() if the environment has not been
   * loaded yet (GD_FLG_ENV_READY flag is 0). Some environment locations will
   * support reading the value (slowly) and some will not.
   *
   * @varname:	Variable to look up
   * @return value of variable, or NULL if not found
   */
  int env_get_f(const char *name, char *buf, unsigned len);
bfebc8c96   Simon Glass   env: Rename geten...
173
174
175
176
177
178
179
180
181
182
183
184
  /**
   * env_get_ulong() - Return an environment variable as an integer value
   *
   * Most U-Boot environment variables store hex values. For those which store
   * (e.g.) base-10 integers, this function can be used to read the value.
   *
   * @name:	Variable to look up
   * @base:	Base to use (e.g. 10 for base 10, 2 for binary)
   * @default_val: Default value to return if no value is found
   * @return the value found, or @default_val if none
   */
  ulong env_get_ulong(const char *name, int base, ulong default_val);
76b8f79c2   Simon Glass   Add getenv_hex() ...
185
186
  
  /**
bfebc8c96   Simon Glass   env: Rename geten...
187
   * env_get_hex() - Return an environment variable as a hex value
76b8f79c2   Simon Glass   Add getenv_hex() ...
188
189
190
191
192
193
194
195
   *
   * 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
   */
bfebc8c96   Simon Glass   env: Rename geten...
196
  ulong env_get_hex(const char *varname, ulong default_val);
76b8f79c2   Simon Glass   Add getenv_hex() ...
197

ec8a252cd   Joe Hershberger   env: Use getenv_y...
198
199
200
201
  /*
   * Read an environment variable as a boolean
   * Return -1 if variable does not exist (default to true)
   */
bfebc8c96   Simon Glass   env: Rename geten...
202
  int env_get_yesno(const char *var);
382bee57f   Simon Glass   env: Rename seten...
203
204
205
206
207
208
209
210
211
212
213
214
  
  /**
   * env_set() - set an environment variable
   *
   * This sets or deletes the value of an environment variable. For setting the
   * value the variable is created if it does not already exist.
   *
   * @varname: Variable to adjust
   * @value: Value to set for the variable, or NULL or "" to delete the variable
   * @return 0 if OK, 1 on error
   */
  int env_set(const char *varname, const char *value);
bfc599664   Simon Glass   Update set_workin...
215
  /**
018f53032   Simon Glass   env: Rename commo...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
   * env_set_ulong() - set an environment variable to an integer
   *
   * @varname: Variable to adjust
   * @value: Value to set for the variable (will be converted to a string)
   * @return 0 if OK, 1 on error
   */
  int env_set_ulong(const char *varname, ulong value);
  
  /**
   * env_set_hex() - set an environment variable to a hex value
   *
   * @varname: Variable to adjust
   * @value: Value to set for the variable (will be converted to a hex string)
   * @return 0 if OK, 1 on error
   */
  int env_set_hex(const char *varname, ulong value);
  
  /**
   * env_set_addr - Set an environment variable to an address in hex
bfc599664   Simon Glass   Update set_workin...
235
   *
1bce2aeb6   Robert P. J. Day   Cosmetic: Fix a n...
236
   * @varname:	Environment variable to set
bfc599664   Simon Glass   Update set_workin...
237
238
239
   * @addr:	Value to set it to
   * @return 0 if ok, 1 on error
   */
018f53032   Simon Glass   env: Rename commo...
240
  static inline int env_set_addr(const char *varname, const void *addr)
bfc599664   Simon Glass   Update set_workin...
241
  {
018f53032   Simon Glass   env: Rename commo...
242
  	return env_set_hex(varname, (ulong)addr);
bfc599664   Simon Glass   Update set_workin...
243
  }
04a85b3b3   wdenk   * Patches by Pant...
244
  #ifdef CONFIG_AUTO_COMPLETE
03dcf17db   Boris Brezillon   common: command: ...
245
246
  int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf,
  		 bool dollar_comp);
04a85b3b3   wdenk   * Patches by Pant...
247
  #endif
2f70c49e5   Heiko Schocher   netloop: speed up...
248
  int get_env_id (void);
04a85b3b3   wdenk   * Patches by Pant...
249

c83bf6a2d   wdenk   Add a common get_...
250
  void	pci_init_board(void);
e22117437   wdenk   Initial revision
251

27b207fd0   wdenk   * Implement new m...
252
253
  /* common/exports.c */
  void	jumptable_init(void);
ecb1dc892   Mike Frysinger   Add support for L...
254
255
  /* common/kallsysm.c */
  const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
c83bf6a2d   wdenk   Add a common get_...
256
  /* common/memsize.c */
a55d23ccf   Albert ARIBAUD   Remove volatile q...
257
  long	get_ram_size  (long *, long);
e38661634   York Sun   common: Add get_e...
258
  phys_size_t get_effective_memsize(void);
c83bf6a2d   wdenk   Add a common get_...
259

e22117437   wdenk   Initial revision
260
261
  /* $(BOARD)/$(BOARD).c */
  void	reset_phy     (void);
c83bf6a2d   wdenk   Add a common get_...
262
  void	fdc_hw_init   (void);
e22117437   wdenk   Initial revision
263
264
  
  /* $(BOARD)/eeprom.c */
eb5ba3aef   Simon Glass   i2c: Drop use of ...
265
  #ifdef CONFIG_CMD_EEPROM
354e3ed75   Marek Vasut   eeprom: Add bus a...
266
  void eeprom_init  (int bus);
e22117437   wdenk   Initial revision
267
268
  int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
eb5ba3aef   Simon Glass   i2c: Drop use of ...
269
270
271
272
273
274
275
276
277
  #else
  /*
   * Some EEPROM code is depecated because it used the legacy I2C interface. Add
   * some macros here so we don't have to touch every one of those uses
   */
  #define eeprom_init(bus)
  #define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
  #define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
  #endif
e22117437   wdenk   Initial revision
278

f1b1f7706   Adam Ford   Convert CONFIG_SP...
279
  #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
280
  # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
548738b4d   Heiko Schocher   cmd_eeprom: I2C u...
281
  #endif
e22117437   wdenk   Initial revision
282

e22117437   wdenk   Initial revision
283
  /* $(BOARD)/$(BOARD).c */
c837dcb1a   wdenk   * The PS/2 mux on...
284
  int board_early_init_f (void);
2a792753d   mario.six@gdsys.cc   dm: Add callback ...
285
  int board_fix_fdt (void *rw_fdt_blob); /* manipulate the U-Boot fdt before its relocation */
c837dcb1a   wdenk   * The PS/2 mux on...
286
  int board_late_init (void);
e22117437   wdenk   Initial revision
287
  int board_postclk_init (void); /* after clocks/timebase, before env/serial */
c837dcb1a   wdenk   * The PS/2 mux on...
288
  int board_early_init_r (void);
e22117437   wdenk   Initial revision
289

6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
290
  #if defined(CONFIG_SYS_DRAM_TEST)
e22117437   wdenk   Initial revision
291
  int testdram(void);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
292
  #endif /* CONFIG_SYS_DRAM_TEST */
e22117437   wdenk   Initial revision
293
294
  
  /* $(CPU)/start.S */
e22117437   wdenk   Initial revision
295
296
297
298
299
300
  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...
301
  void	mmu_disable(void);
5c6db120f   Benoît Thébaudeau   arm: Remove unuse...
302
303
304
305
  #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...
306
  #endif
e22117437   wdenk   Initial revision
307
308
  ulong	get_endaddr   (void);
  void	trap_init     (ulong);
6e2941d78   Simon Glass   common: freescale...
309

e22117437   wdenk   Initial revision
310
  /* $(CPU)/cpu.c */
fbb9ecf74   Timur Tabi   powerpc/mp: add s...
311
312
313
314
315
316
317
318
319
320
321
322
  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...
323
  int	cpu_numcores  (void);
b8bf0adc1   Shaveta Leekha   powerpc/mpc85xx: ...
324
  int	cpu_num_dspcores(void);
fbb9ecf74   Timur Tabi   powerpc/mp: add s...
325
  u32	cpu_mask      (void);
b8bf0adc1   Shaveta Leekha   powerpc/mpc85xx: ...
326
  u32	cpu_dsp_mask(void);
fbb9ecf74   Timur Tabi   powerpc/mp: add s...
327
  int	is_core_valid (unsigned int);
cbcbf71bf   Simon Glass   powerpc: Drop pro...
328

026d7958b   Diego Dorta   common: Add a pro...
329
  void s_init(void);
e22117437   wdenk   Initial revision
330
331
332
333
334
  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...
335
  void	reset_misc    (void);
3ec924a3c   wdenk   Patch by Steven S...
336
  void	reset_cpu     (ulong addr);
6a16e0dfc   Kim Phillips   mpc83xx: move com...
337
  void ft_cpu_setup(void *blob, bd_t *bd);
6a16e0dfc   Kim Phillips   mpc83xx: move com...
338
  void ft_pci_setup(void *blob, bd_t *bd);
6a16e0dfc   Kim Phillips   mpc83xx: move com...
339

ba6a16981   Andre Przywara   ARM: add SMP supp...
340
341
  void smp_set_core_boot_addr(unsigned long addr, int corenr);
  void smp_kick_all_cpus(void);
e22117437   wdenk   Initial revision
342
343
344
345
346
  
  /* $(CPU)/serial.c */
  int	serial_init   (void);
  void	serial_setbrg (void);
  void	serial_putc   (const char);
756f586a7   wdenk   * Patch by Yusdi ...
347
  void	serial_putc_raw(const char);
e22117437   wdenk   Initial revision
348
  void	serial_puts   (const char *);
e22117437   wdenk   Initial revision
349
350
351
352
353
  int	serial_getc   (void);
  int	serial_tstc   (void);
  
  /* $(CPU)/speed.c */
  int	get_clocks (void);
e22117437   wdenk   Initial revision
354
  ulong	get_bus_freq  (ulong);
550650ddd   Stefan Roese   ppc4xx: Use commo...
355
  int get_serial_clock(void);
e22117437   wdenk   Initial revision
356

e22117437   wdenk   Initial revision
357
  /* $(CPU)/interrupts.c */
c83bf6a2d   wdenk   Add a common get_...
358
359
  int	interrupt_init	   (void);
  void	timer_interrupt	   (struct pt_regs *);
e22117437   wdenk   Initial revision
360
361
362
363
  void	external_interrupt (struct pt_regs *);
  void	irq_install_handler(int, interrupt_handler_t *, void *);
  void	irq_free_handler   (int);
  void	reset_timer	   (void);
b2e16a85a   Simon Glass   Add trace library
364
365
366
  
  /* Return value of monotonic microsecond timer */
  unsigned long timer_get_us(void);
e22117437   wdenk   Initial revision
367
368
369
370
371
372
373
374
375
  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...
376
377
  void	bootcount_store (ulong);
  ulong	bootcount_load (void);
e22117437   wdenk   Initial revision
378
379
  
  /* $(CPU)/.../<eth> */
c5bded3c8   Wolfgang Denk   Add mii_init() pr...
380
  void mii_init (void);
e22117437   wdenk   Initial revision
381
382
383
  
  /* $(CPU)/.../lcd.c */
  ulong	lcd_setmem (ulong);
e22117437   wdenk   Initial revision
384
385
  /* $(CPU)/.../video.c */
  ulong	video_setmem (ulong);
ea0364f1b   Peter Tyser   Move lib_$ARCH di...
386
  /* arch/$(ARCH)/lib/cache.c */
cba4b1809   Aneesh V   arm: do not force...
387
  void	enable_caches(void);
e22117437   wdenk   Initial revision
388
  void	flush_cache   (unsigned long, unsigned long);
2c451f783   Aneesh V   armv7: cache main...
389
  void	flush_dcache_all(void);
03d3bfb00   Stefan Roese   MIPS: Add flush_d...
390
391
  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...
392
393
  void	invalidate_dcache_all(void);
  void	invalidate_icache_all(void);
0db5bca80   wdenk   * Patch by Martin...
394

4d24a11ee   Simon Glass   arm: Allow cleanu...
395
396
397
398
399
400
401
402
403
404
405
406
407
408
  enum {
  	/* Disable caches (else flush caches but leave them active) */
  	CBL_DISABLE_CACHES		= 1 << 0,
  	CBL_SHOW_BOOTSTAGE_REPORT	= 1 << 1,
  
  	CBL_ALL				= 3,
  };
  
  /**
   * Clean up ready for linux
   *
   * @param flags		Flags to control what is done
   */
  int cleanup_before_linux_select(int flags);
ea0364f1b   Peter Tyser   Move lib_$ARCH di...
409
  /* arch/$(ARCH)/lib/ticks.S */
19ea4678c   Simon Glass   Use uint64_t for ...
410
  uint64_t get_ticks(void);
e22117437   wdenk   Initial revision
411
  void	wait_ticks    (unsigned long);
ea0364f1b   Peter Tyser   Move lib_$ARCH di...
412
  /* arch/$(ARCH)/lib/time.c */
e22117437   wdenk   Initial revision
413
414
  ulong	usec2ticks    (unsigned long usec);
  ulong	ticks2usec    (unsigned long ticks);
e22117437   wdenk   Initial revision
415

78acc472d   Peter Tyser   Rename lib_generi...
416
  /* lib/gunzip.c */
376ddf9d4   Jean-Jacques Hiblot   gzip: add a funct...
417
  int gzip_parse_header(const unsigned char *src, unsigned long len);
87d93a1ba   Wolfgang Wegner   move prototypes f...
418
419
420
  int gunzip(void *, int, unsigned char *, unsigned long *);
  int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
  						int stoponerr, int offset);
918e9ebb4   Eric Nelson   gunzip: add gzwri...
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
  /**
   * gzwrite progress indicators: defined weak to allow board-specific
   * overrides:
   *
   *	gzwrite_progress_init called on startup
   *	gzwrite_progress called during decompress/write loop
   *	gzwrite_progress_finish called at end of loop to
   *		indicate success (retcode=0) or failure
   */
  void gzwrite_progress_init(u64 expected_size);
  
  void gzwrite_progress(int iteration,
  		     u64 bytes_written,
  		     u64 total_bytes);
  
  void gzwrite_progress_finish(int retcode,
  			     u64 totalwritten,
  			     u64 totalsize,
  			     u32 expected_crc,
  			     u32 calculated_crc);
  
  /**
   * decompress and write gzipped image from memory to block device
   *
   * @param	src		compressed image address
   * @param	len		compressed image length in bytes
   * @param	dev		block device descriptor
   * @param	szwritebuf	bytes per write (pad to erase size)
   * @param	startoffs	offset in bytes of first write
   * @param	szexpected	expected uncompressed length
   *				may be zero to use gzip trailer
   *				for files under 4GiB
   */
  int gzwrite(unsigned char *src, int len,
4101f6879   Simon Glass   dm: Drop the bloc...
455
  	    struct blk_desc *dev,
918e9ebb4   Eric Nelson   gunzip: add gzwri...
456
457
458
  	    unsigned long szwritebuf,
  	    u64 startoffs,
  	    u64 szexpected);
027b728d4   Julius Werner   Add support for L...
459
460
  /* lib/lz4_wrapper.c */
  int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
54c6977e9   Wolfgang Denk   Add qsort - add s...
461
462
463
  /* 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...
464
  int strcmp_compar(const void *, const void *);
54c6977e9   Wolfgang Denk   Add qsort - add s...
465

e11938eab   Jason Hobbs   lib: add uuid_str...
466
  /* lib/uuid.c */
d718ded05   Przemyslaw Marczak   lib: uuid: code r...
467
  #include <uuid.h>
e11938eab   Jason Hobbs   lib: add uuid_str...
468

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

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

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

9acf1ca50   Michael Walle   lib: add rand() f...
478
  /* lib/rand.c */
9acf1ca50   Michael Walle   lib: add rand() f...
479
480
481
482
  #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...
483

e22117437   wdenk   Initial revision
484
485
486
  /*
   * STDIO based functions (can always be used)
   */
e22117437   wdenk   Initial revision
487
  /* serial stuff */
d9c27253c   Wolfgang Denk   Make *printf() re...
488
  int	serial_printf (const char *fmt, ...)
dc4b0b38d   Andrew Klossner   Fix printf errors.
489
  		__attribute__ ((format (__printf__, 1, 2)));
e22117437   wdenk   Initial revision
490

88d52c6af   Lei Wen   lib: add gzip lib...
491
492
493
494
495
496
  /* 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...
497
498
  /* lib/net_utils.c */
  #include <net.h>
723806cc5   Simon Glass   env: Rename some ...
499
  static inline struct in_addr env_get_ip(char *var)
4ef8d53ca   Joe Hershberger   net: Allow filter...
500
  {
00caae6d4   Simon Glass   env: Rename geten...
501
  	return string_to_ip(env_get(var));
4ef8d53ca   Joe Hershberger   net: Allow filter...
502
  }
e22117437   wdenk   Initial revision
503
  int	pcmcia_init (void);
2d8d190c8   Uri Mashiach   status_led: Kconf...
504
  #ifdef CONFIG_LED_STATUS
fb364bec5   Wolfgang Denk   Fix include/commo...
505
506
  # include <status_led.h>
  #endif
097e17836   Simon Glass   bootstage: Create...
507
508
  
  #include <bootstage.h>
e22117437   wdenk   Initial revision
509

48522bb50   Joe Hershberger   net: cosmetic: ne...
510
511
512
  #ifdef CONFIG_SHOW_ACTIVITY
  void show_activity(int arg);
  #endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
513
514
  /* Multicore arch functions */
  #ifdef CONFIG_MP
20b016a33   Michal Simek   common: Fix cpu n...
515
516
517
518
  int cpu_status(u32 nr);
  int cpu_reset(u32 nr);
  int cpu_disable(u32 nr);
  int cpu_release(u32 nr, int argc, char * const argv[]);
fcd3c87e4   Wolfgang Denk   Make include/comm...
519
  #endif
9b149c2a2   Ye Li   MLK-18591-3 andro...
520
521
522
  #ifdef CONFIG_CMD_READ
  int do_raw_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  #endif
2a6713b09   Andre Przywara   move UL() macro f...
523
  #else	/* __ASSEMBLY__ */
2a6713b09   Andre Przywara   move UL() macro f...
524
  #endif	/* __ASSEMBLY__ */
fcd3c87e4   Wolfgang Denk   Make include/comm...
525
526
527
528
529
  
  /* Put only stuff here that the assembler can digest */
  
  #ifdef CONFIG_POST
  #define CONFIG_HAS_POST
800eb0964   Michael Zaidman   POST cleanup.
530
531
532
  #ifndef CONFIG_POST_ALT_LIST
  #define CONFIG_POST_STD_LIST
  #endif
fcd3c87e4   Wolfgang Denk   Make include/comm...
533
  #endif
155cfb5ef   Anton Staaf   common: fix behav...
534
  #define ROUND(a,b)		(((a) + (b) - 1) & ~((b) - 1))
4b03ac8b5   Andy Fleming   Add ALIGN() macro
535

1e41f5ad4   Anton Staaf   cache: include as...
536
  /*
c9689ca31   Simon Glass   Add a way of chec...
537
538
539
540
541
542
543
544
545
   * check_member() - Check the offset of a structure member
   *
   * @structure:	Name of structure (e.g. global_data)
   * @member:	Name of member (e.g. baudrate)
   * @offset:	Expected offset in bytes
   */
  #define check_member(structure, member, offset) _Static_assert( \
  	offsetof(struct structure, member) == offset, \
  	"`struct " #structure "` offset for `" #member "` is not " #offset)
476476e73   Simon Glass   efi: Add support ...
546
547
548
549
550
551
  /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
  #ifdef CONFIG_EFI_STUB
  #define ll_boot_init()	false
  #else
  #define ll_boot_init()	true
  #endif
c3eb3fe49   Mike Frysinger   env: allow people...
552
553
554
555
  /* Pull in stuff for the build system */
  #ifdef DO_DEPS_ONLY
  # include <environment.h>
  #endif
e22117437   wdenk   Initial revision
556
  #endif	/* __COMMON_H_ */