blob: a13c47d80084e80a647e2cfc657cd510f10f84a9 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * (C) Copyright 2000-2009
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#ifndef __COMMON_H_
25#define __COMMON_H_ 1
26
27#undef _LINUX_CONFIG_H
28#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
29
30#ifndef __ASSEMBLY__ /* put C only stuff in this section */
31
32typedef unsigned char uchar;
33typedef volatile unsigned long vu_long;
34typedef volatile unsigned short vu_short;
35typedef volatile unsigned char vu_char;
36
37#include <config.h>
38#include <asm-offsets.h>
39#include <linux/bitops.h>
40#include <linux/types.h>
41#include <linux/string.h>
42#include <asm/ptrace.h>
43#include <stdarg.h>
44#include <dbglvl_printf.h>
45
46#if defined(CONFIG_PCI) && (defined(CONFIG_4xx) && !defined(CONFIG_AP1000))
47#include <pci.h>
48#endif
49#if defined(CONFIG_8xx)
50#include <asm/8xx_immap.h>
51#if defined(CONFIG_MPC852) || defined(CONFIG_MPC852T) || \
52 defined(CONFIG_MPC859) || defined(CONFIG_MPC859T) || \
53 defined(CONFIG_MPC859DSL) || \
54 defined(CONFIG_MPC866) || defined(CONFIG_MPC866T) || \
55 defined(CONFIG_MPC866P)
56# define CONFIG_MPC866_FAMILY 1
57#elif defined(CONFIG_MPC870) \
58 || defined(CONFIG_MPC875) \
59 || defined(CONFIG_MPC880) \
60 || defined(CONFIG_MPC885)
61# define CONFIG_MPC885_FAMILY 1
62#endif
63#if defined(CONFIG_MPC860) \
64 || defined(CONFIG_MPC860T) \
65 || defined(CONFIG_MPC866_FAMILY) \
66 || defined(CONFIG_MPC885_FAMILY)
67# define CONFIG_MPC86x 1
68#endif
69#elif defined(CONFIG_5xx)
70#include <asm/5xx_immap.h>
71#elif defined(CONFIG_MPC5xxx)
72#include <mpc5xxx.h>
73#elif defined(CONFIG_MPC512X)
74#include <asm/immap_512x.h>
75#elif defined(CONFIG_MPC8220)
76#include <asm/immap_8220.h>
77#elif defined(CONFIG_8260)
78#if defined(CONFIG_MPC8247) \
79 || defined(CONFIG_MPC8248) \
80 || defined(CONFIG_MPC8271) \
81 || defined(CONFIG_MPC8272)
82#define CONFIG_MPC8272_FAMILY 1
83#endif
84#if defined(CONFIG_MPC8272_FAMILY)
85#define CONFIG_MPC8260 1
86#endif
87#include <asm/immap_8260.h>
88#endif
89#ifdef CONFIG_MPC86xx
90#include <mpc86xx.h>
91#include <asm/immap_86xx.h>
92#endif
93#ifdef CONFIG_MPC85xx
94#include <mpc85xx.h>
95#include <asm/immap_85xx.h>
96#endif
97#ifdef CONFIG_MPC83xx
98#include <mpc83xx.h>
99#include <asm/immap_83xx.h>
100#endif
101#ifdef CONFIG_4xx
102#include <asm/ppc4xx.h>
103#endif
104#ifdef CONFIG_HYMOD
105#include <board/hymod/hymod.h>
106#endif
107#ifdef CONFIG_ARM
108#define asmlinkage /* nothing */
109#endif
110#ifdef CONFIG_BLACKFIN
111#include <asm/blackfin.h>
112#endif
113#ifdef CONFIG_SOC_DA8XX
114#include <asm/arch/hardware.h>
115#endif
116
117#include <part.h>
118#include <flash.h>
119#include <image.h>
120
121#if DEBUG
122#define debug(fmt,args...) printf (fmt ,##args)
123#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
124#else
125#define debug(fmt,args...)
126#define debugX(level,fmt,args...)
127#endif /* DEBUG */
128
129#if DEBUG
130# define _DEBUG 1
131#else
132# define _DEBUG 0
133#endif
134
135#define ECC_TEST_VER 0
136
137#define debug_cond(cond, fmt, args...) /* \
138 do { \
139 if (cond) \
140 printf(fmt, ##args); \
141 } while (0)*/
142/*
143 * An assertion is run-time check done in debug mode only. If DEBUG is not
144 * defined then it is skipped. If DEBUG is defined and the assertion fails,
145 * then it calls panic*( which may or may not reset/halt U-Boot (see
146 * CONFIG_PANIC_HANG), It is hoped that all failing assertions are found
147 * before release, and after release it is hoped that they don't matter. But
148 * in any case these failing assertions cannot be fixed with a reset (which
149 * may just do the same assertion again).
150 */
151void __assert_fail(const char *assertion, const char *file, unsigned line,
152 const char *function);
153#define assert(x) \
154 ({ if (!(x) && _DEBUG) \
155 __assert_fail(#x, __FILE__, __LINE__, __func__); })
156
157#define error(fmt, args...) do { \
158 printf("ERROR: " fmt "\nat %s:%d/%s()\n", \
159 ##args, __FILE__, __LINE__, __func__); \
160} while (0)
161
162#ifndef BUG
163#define BUG() do { \
164 printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
165 panic("BUG!"); \
166} while (0)
167#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
168#endif /* BUG */
169
170/* Force a compilation error if condition is true */
171#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
172
173typedef void (interrupt_handler_t)(void *);
174
175#include <asm/u-boot.h> /* boot information for Linux kernel */
176#include <asm/global_data.h> /* global data used for startup functions */
177
178/*
179 * enable common handling for all TQM8xxL/M boards:
180 * - CONFIG_TQM8xxM will be defined for all TQM8xxM boards
181 * - CONFIG_TQM8xxL will be defined for all TQM8xxL _and_ TQM8xxM boards
182 * and for the TQM885D board
183 */
184#if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \
185 defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \
186 defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M)
187# ifndef CONFIG_TQM8xxM
188# define CONFIG_TQM8xxM
189# endif
190#endif
191#if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
192 defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \
193 defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM) || \
194 defined(CONFIG_TQM885D)
195# ifndef CONFIG_TQM8xxL
196# define CONFIG_TQM8xxL
197# endif
198#endif
199
200#ifndef CONFIG_SERIAL_MULTI
201
202#if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2) \
203 || defined(CONFIG_8xx_CONS_SCC1) || defined(CONFIG_8xx_CONS_SCC2) \
204 || defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
205
206#define CONFIG_SERIAL_MULTI 1
207
208#endif
209
210#endif /* CONFIG_SERIAL_MULTI */
211
212/*
213 * General Purpose Utilities
214 */
215#define min(X, Y) \
216 ({ typeof (X) __x = (X); \
217 typeof (Y) __y = (Y); \
218 (__x < __y) ? __x : __y; })
219
220#define max(X, Y) \
221 ({ typeof (X) __x = (X); \
222 typeof (Y) __y = (Y); \
223 (__x > __y) ? __x : __y; })
224
225#define MIN(x, y) min(x, y)
226#define MAX(x, y) max(x, y)
227
228#if defined(CONFIG_ENV_IS_EMBEDDED)
229#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
230#elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
231 (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
232 defined(CONFIG_ENV_IS_IN_NVRAM)
233#define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
234#else
235#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
236#endif
237
238/**
239 * container_of - cast a member of a structure out to the containing structure
240 * @ptr: the pointer to the member.
241 * @type: the type of the container struct this is embedded in.
242 * @member: the name of the member within the struct.
243 *
244 */
245#define container_of(ptr, type, member) ({ \
246 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
247 (type *)( (char *)__mptr - offsetof(type,member) );})
248
249/*
250 * Function Prototypes
251 */
252
253void hang (void) __attribute__ ((noreturn));
254
255extern int timer_init(void);
256extern int cpu_init(void);
257
258int gpio_pad_init2rst(void);
259
260/* */
261phys_size_t initdram (int);
262int display_options (void);
263void print_size(unsigned long long, const char *);
264int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);
265
266/* common/main.c */
267void main_loop (void);
268int run_command (const char *cmd, int flag);
269int readline (const char *const prompt);
270int readline_into_buffer (const char *const prompt, char * buffer);
271int parse_line (char *, char *[]);
272void init_cmd_timeout(void);
273void reset_cmd_timeout(void);
274
275/* arch/$(ARCH)/lib/board.c */
276void board_init_f (ulong) __attribute__ ((noreturn));
277void board_init_r (gd_t *, ulong) __attribute__ ((noreturn));
278int checkboard (void);
279int checkflash (void);
280int checkdram (void);
281int last_stage_init(void);
282extern ulong monitor_flash_len;
283int mac_read_from_eeprom(void);
284
285/* common/flash.c */
286void flash_perror (int);
287
288/* common/cmd_source.c */
289int source (ulong addr, const char *fit_uname);
290
291extern ulong load_addr; /* Default Load Address */
292extern ulong save_addr; /* Default Save Address */
293extern ulong save_size; /* Default Save Size */
294
295/* common/cmd_doc.c */
296void doc_probe(unsigned long physadr);
297
298/* common/cmd_nvedit.c */
299int env_init (void);
300void env_relocate (void);
301int envmatch (uchar *, int);
302char *getenv (const char *);
303int getenv_f (const char *name, char *buf, unsigned len);
304int saveenv (void);
305#ifdef CONFIG_PPC /* ARM version to be fixed! */
306int inline setenv (const char *, const char *);
307#else
308int setenv (const char *, const char *);
309#endif /* CONFIG_PPC */
310#ifdef CONFIG_ARM
311# include <asm/mach-types.h>
312# include <asm/setup.h>
313# include <asm/u-boot-arm.h> /* ARM version to be fixed! */
314#endif /* CONFIG_ARM */
315#ifdef CONFIG_X86 /* x86 version to be fixed! */
316# include <asm/u-boot-x86.h>
317#endif /* CONFIG_X86 */
318
319#ifdef CONFIG_AUTO_COMPLETE
320int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
321#endif
322int get_env_id (void);
323
324void pci_init (void);
325void pci_init_board(void);
326void pciinfo (int, int);
327
328#if defined(CONFIG_PCI) && (defined(CONFIG_4xx) && !defined(CONFIG_AP1000))
329 int pci_pre_init (struct pci_controller *);
330 int is_pci_host (struct pci_controller *);
331#endif
332
333#if defined(CONFIG_PCI) && (defined(CONFIG_440) || defined(CONFIG_405EX))
334# if defined(CONFIG_SYS_PCI_TARGET_INIT)
335 void pci_target_init (struct pci_controller *);
336# endif
337# if defined(CONFIG_SYS_PCI_MASTER_INIT)
338 void pci_master_init (struct pci_controller *);
339# endif
340#if defined(CONFIG_440SPE) || \
341 defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
342 defined(CONFIG_405EX)
343 void pcie_setup_hoses(int busno);
344#endif
345#endif
346
347int misc_init_f (void);
348int misc_init_r (void);
349
350/* common/exports.c */
351void jumptable_init(void);
352
353/* common/kallsysm.c */
354const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
355
356/* api/api.c */
357void api_init (void);
358
359/* common/memsize.c */
360long get_ram_size (long *, long);
361
362/* $(BOARD)/$(BOARD).c */
363void reset_phy (void);
364void fdc_hw_init (void);
365
366/* $(BOARD)/eeprom.c */
367void eeprom_init (void);
368#ifndef CONFIG_SPI
369int eeprom_probe (unsigned dev_addr, unsigned offset);
370#endif
371int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
372int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
373#ifdef CONFIG_LWMON
374extern uchar pic_read (uchar reg);
375extern void pic_write (uchar reg, uchar val);
376#endif
377
378/*
379 * Set this up regardless of board
380 * type, to prevent errors.
381 */
382#if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
383# define CONFIG_SYS_DEF_EEPROM_ADDR 0
384#else
385#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
386# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
387#endif
388#endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */
389
390#if defined(CONFIG_SPI)
391extern void spi_init_f (void);
392extern void spi_init_r (void);
393extern ssize_t spi_read (uchar *, int, uchar *, int);
394extern ssize_t spi_write (uchar *, int, uchar *, int);
395#endif
396
397#ifdef CONFIG_RPXCLASSIC
398void rpxclassic_init (void);
399#endif
400
401void rpxlite_init (void);
402
403#ifdef CONFIG_MBX
404/* $(BOARD)/mbx8xx.c */
405void mbx_init (void);
406void board_serial_init (void);
407void board_ether_init (void);
408#endif
409
410#ifdef CONFIG_HERMES
411/* $(BOARD)/hermes.c */
412void hermes_start_lxt980 (int speed);
413#endif
414
415#ifdef CONFIG_EVB64260
416void evb64260_init(void);
417void debug_led(int, int);
418void display_mem_map(void);
419void perform_soft_reset(void);
420#endif
421
422/* $(BOARD)/$(BOARD).c */
423int board_early_init_f (void);
424int board_late_init (void);
425int board_postclk_init (void); /* after clocks/timebase, before env/serial */
426int board_early_init_r (void);
427void board_poweroff (void);
428
429#if defined(CONFIG_SYS_DRAM_TEST)
430int testdram(void);
431#endif /* CONFIG_SYS_DRAM_TEST */
432
433/* $(CPU)/start.S */
434#if defined(CONFIG_5xx) || \
435 defined(CONFIG_8xx)
436uint get_immr (uint);
437#endif
438uint get_pir (void);
439#if defined(CONFIG_MPC5xxx)
440uint get_svr (void);
441#endif
442uint get_pvr (void);
443uint get_svr (void);
444uint rd_ic_cst (void);
445void wr_ic_cst (uint);
446void wr_ic_adr (uint);
447uint rd_dc_cst (void);
448void wr_dc_cst (uint);
449void wr_dc_adr (uint);
450int icache_status (void);
451void icache_enable (void);
452void icache_disable(void);
453int dcache_status (void);
454void dcache_enable (void);
455void dcache_disable(void);
456void mmu_disable(void);
457void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
458ulong get_endaddr (void);
459void trap_init (ulong);
460#if defined (CONFIG_4xx) || \
461 defined (CONFIG_MPC5xxx) || \
462 defined (CONFIG_74xx_7xx) || \
463 defined (CONFIG_74x) || \
464 defined (CONFIG_75x) || \
465 defined (CONFIG_74xx) || \
466 defined (CONFIG_MPC8220) || \
467 defined (CONFIG_MPC85xx) || \
468 defined (CONFIG_MPC86xx) || \
469 defined (CONFIG_MPC83xx)
470unsigned char in8(unsigned int);
471void out8(unsigned int, unsigned char);
472unsigned short in16(unsigned int);
473unsigned short in16r(unsigned int);
474void out16(unsigned int, unsigned short value);
475void out16r(unsigned int, unsigned short value);
476unsigned long in32(unsigned int);
477unsigned long in32r(unsigned int);
478void out32(unsigned int, unsigned long value);
479void out32r(unsigned int, unsigned long value);
480void ppcDcbf(unsigned long value);
481void ppcDcbi(unsigned long value);
482void ppcSync(void);
483void ppcDcbz(unsigned long value);
484#endif
485#if defined (CONFIG_MICROBLAZE)
486unsigned short in16(unsigned int);
487void out16(unsigned int, unsigned short value);
488#endif
489
490#if defined (CONFIG_MPC83xx)
491void ppcDWload(unsigned int *addr, unsigned int *ret);
492void ppcDWstore(unsigned int *addr, unsigned int *value);
493void disable_addr_trans(void);
494void enable_addr_trans(void);
495#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
496void ddr_enable_ecc(unsigned int dram_size);
497#endif
498#endif
499
500/* $(CPU)/cpu.c */
501int cpu_numcores (void);
502int probecpu (void);
503int checkcpu (void);
504int checkicache (void);
505int checkdcache (void);
506void upmconfig (unsigned int, unsigned int *, unsigned int);
507ulong get_tbclk (void);
508void reset_cpu (ulong addr);
509#if defined (CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
510void ft_cpu_setup(void *blob, bd_t *bd);
511#ifdef CONFIG_PCI
512void ft_pci_setup(void *blob, bd_t *bd);
513#endif
514#endif
515
516
517/* $(CPU)/serial.c */
518int serial_init (void);
519void serial_exit (void);
520void serial_setbrg (void);
521void serial_putc (const char);
522void serial_putc_raw(const char);
523void serial_puts (const char *);
524int serial_getc (void);
525int serial_tstc (void);
526
527void _serial_setbrg (const int);
528void _serial_putc (const char, const int);
529void _serial_putc_raw(const char, const int);
530void _serial_puts (const char *, const int);
531int _serial_getc (const int);
532int _serial_tstc (const int);
533
534/* $(CPU)/speed.c */
535int get_clocks (void);
536int get_clocks_866 (void);
537int sdram_adjust_866 (void);
538int adjust_sdram_tbs_8xx (void);
539#if defined(CONFIG_8260)
540int prt_8260_clks (void);
541#elif defined(CONFIG_MPC5xxx)
542int prt_mpc5xxx_clks (void);
543#endif
544#if defined(CONFIG_MPC512X)
545int prt_mpc512xxx_clks (void);
546#endif
547#if defined(CONFIG_MPC8220)
548int prt_mpc8220_clks (void);
549#endif
550#ifdef CONFIG_4xx
551ulong get_OPB_freq (void);
552ulong get_PCI_freq (void);
553#endif
554#if defined(CONFIG_S3C24X0) || \
555 defined(CONFIG_LH7A40X) || \
556 defined(CONFIG_S3C6400) || \
557 defined(CONFIG_EP93XX)
558ulong get_FCLK (void);
559ulong get_HCLK (void);
560ulong get_PCLK (void);
561ulong get_UCLK (void);
562#endif
563#if defined(CONFIG_LH7A40X)
564ulong get_PLLCLK (void);
565#endif
566#if defined CONFIG_INCA_IP
567uint incaip_get_cpuclk (void);
568#endif
569#if defined(CONFIG_IMX)
570ulong get_systemPLLCLK(void);
571ulong get_FCLK(void);
572ulong get_HCLK(void);
573ulong get_BCLK(void);
574ulong get_PERCLK1(void);
575ulong get_PERCLK2(void);
576ulong get_PERCLK3(void);
577#endif
578ulong get_bus_freq (ulong);
579int get_serial_clock(void);
580
581#if defined(CONFIG_MPC85xx)
582typedef MPC85xx_SYS_INFO sys_info_t;
583void get_sys_info ( sys_info_t * );
584ulong get_ddr_freq (ulong);
585#endif
586#if defined(CONFIG_MPC86xx)
587typedef MPC86xx_SYS_INFO sys_info_t;
588void get_sys_info ( sys_info_t * );
589static inline ulong get_ddr_freq(ulong dummy)
590{
591 return get_bus_freq(dummy);
592}
593#endif
594
595#if defined(CONFIG_4xx) || defined(CONFIG_IOP480)
596# if defined(CONFIG_440)
597# if defined(CONFIG_440SPE)
598 unsigned long determine_sysper(void);
599 unsigned long determine_pci_clock_per(void);
600# endif
601# endif
602typedef PPC4xx_SYS_INFO sys_info_t;
603int ppc440spe_revB(void);
604void get_sys_info ( sys_info_t * );
605#endif
606
607/* $(CPU)/cpu_init.c */
608#if defined(CONFIG_8xx) || defined(CONFIG_8260)
609void cpu_init_f (volatile immap_t *immr);
610#endif
611#if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) || defined(CONFIG_MCF52x2) ||defined(CONFIG_MPC86xx)
612void cpu_init_f (void);
613#endif
614
615int cpu_init_r (void);
616#if defined(CONFIG_8260)
617int prt_8260_rsr (void);
618#elif defined(CONFIG_MPC83xx)
619int prt_83xx_rsr (void);
620#endif
621
622/* $(CPU)/interrupts.c */
623int interrupt_init (void);
624void timer_interrupt (struct pt_regs *);
625void external_interrupt (struct pt_regs *);
626void irq_install_handler(int, interrupt_handler_t *, void *);
627void irq_free_handler (int);
628void reset_timer (void);
629ulong get_timer (ulong base);
630void enable_interrupts (void);
631int disable_interrupts (void);
632
633/* $(CPU)/.../commproc.c */
634int dpram_init (void);
635uint dpram_base(void);
636uint dpram_base_align(uint align);
637uint dpram_alloc(uint size);
638uint dpram_alloc_align(uint size,uint align);
639void bootcount_store (ulong);
640ulong bootcount_load (void);
641#define BOOTCOUNT_MAGIC 0xB001C041
642
643/* $(CPU)/.../<eth> */
644void mii_init (void);
645
646/* $(CPU)/.../lcd.c */
647ulong lcd_setmem (ulong);
648
649/* $(CPU)/.../video.c */
650ulong video_setmem (ulong);
651
652/* arch/$(ARCH)/lib/cache.c */
653void enable_caches(void);
654void flush_cache (unsigned long, unsigned long);
655void flush_dcache_all(void);
656void flush_dcache_range(unsigned long start, unsigned long stop);
657void invalidate_dcache_range(unsigned long start, unsigned long stop);
658void invalidate_dcache_all(void);
659void invalidate_icache_all(void);
660
661/* arch/$(ARCH)/lib/ticks.S */
662unsigned long long get_ticks(void);
663void wait_ticks (unsigned long);
664
665/* arch/$(ARCH)/lib/time.c */
666void __udelay (unsigned long);
667ulong usec2ticks (unsigned long usec);
668ulong ticks2usec (unsigned long ticks);
669int init_timebase (void);
670
671/* lib/gunzip.c */
672int gunzip(void *, int, unsigned char *, unsigned long *);
673int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
674 int stoponerr, int offset);
675
676/* lib/net_utils.c */
677#include <net.h>
678static inline IPaddr_t getenv_IPaddr (char *var)
679{
680 return (string_to_ip(getenv(var)));
681}
682
683/* lib/qsort.c */
684void qsort(void *base, size_t nmemb, size_t size,
685 int(*compar)(const void *, const void *));
686int strcmp_compar(const void *, const void *);
687
688/* lib/timsort.c */
689int timsort(void *base, size_t nel, size_t width,
690 int (*compar) (const void *, const void *));
691
692/* lib/time.c */
693void udelay (unsigned long);
694
695/* lib/vsprintf.c */
696ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
697int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
698unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base);
699long simple_strtol(const char *cp,char **endp,unsigned int base);
700void panic(const char *fmt, ...)
701 __attribute__ ((format (__printf__, 1, 2), noreturn));
702int sprintf(char * buf, const char *fmt, ...)
703 __attribute__ ((format (__printf__, 2, 3)));
704int vsprintf(char *buf, const char *fmt, va_list args);
705
706/* lib/strmhz.c */
707char * strmhz(char *buf, unsigned long hz);
708
709/* lib/crc32.c */
710#include <u-boot/crc.h>
711
712/* common/console.c */
713int console_init_f(void); /* Before relocation; uses the serial stuff */
714int console_init_r(void); /* After relocation; uses the console stuff */
715int console_assign(int file, const char *devname); /* Assign the console */
716int ctrlc (void);
717int had_ctrlc (void); /* have we had a Control-C since last clear? */
718void clear_ctrlc (void); /* clear the Control-C condition */
719int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */
720
721/*
722 * STDIO based functions (can always be used)
723 */
724/* serial stuff */
725int serial_printf (const char *fmt, ...)
726 __attribute__ ((format (__printf__, 1, 2)));
727/* stdin */
728int getc(void);
729int tstc(void);
730
731/* stdout */
732void putc(const char c);
733void puts(const char *s);
734int printf(const char *fmt, ...)
735 __attribute__ ((format (__printf__, 1, 2)));
736int vprintf(const char *fmt, va_list args);
737
738/* stderr */
739#define eputc(c) fputc(stderr, c)
740#define eputs(s) fputs(stderr, s)
741#define eprintf(fmt,args...) fprintf(stderr,fmt ,##args)
742
743/*
744 * FILE based functions (can only be used AFTER relocation!)
745 */
746#define stdin 0
747#define stdout 1
748#define stderr 2
749#define MAX_FILES 3
750
751int fprintf(int file, const char *fmt, ...)
752 __attribute__ ((format (__printf__, 2, 3)));
753void fputs(int file, const char *s);
754void fputc(int file, const char c);
755int ftstc(int file);
756int fgetc(int file);
757
758/*
759 * CONSOLE multiplexing.
760 */
761#ifdef CONFIG_CONSOLE_MUX
762#include <iomux.h>
763#endif
764
765int pcmcia_init (void);
766
767#ifdef CONFIG_STATUS_LED
768# include <status_led.h>
769#endif
770/*
771 * Board-specific Platform code can reimplement show_boot_progress () if needed
772 */
773void show_boot_progress(int val);
774
775/* Multicore arch functions */
776#ifdef CONFIG_MP
777int cpu_status(int nr);
778int cpu_reset(int nr);
779int cpu_disable(int nr);
780int cpu_release(int nr, int argc, char * const argv[]);
781#endif
782
783#endif /* __ASSEMBLY__ */
784
785
786/* Added by zhouqi for --, 2014/01/14 */
787void sys_entry(void);
788int clk_init(void);
789int i2c_init(void);
790void jtag_init(void);
791int zftl_init( void );
792void system_reset(void);
793/* End added. zhouqi, 2014/01/14 */
794
795
796/* Put only stuff here that the assembler can digest */
797
798#ifdef CONFIG_POST
799#define CONFIG_HAS_POST
800#ifndef CONFIG_POST_ALT_LIST
801#define CONFIG_POST_STD_LIST
802#endif
803#endif
804
805#ifdef CONFIG_INIT_CRITICAL
806#error CONFIG_INIT_CRITICAL is deprecated!
807#error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
808#endif
809
810#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
811
812#define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
813#define DIV_ROUND(n,d) (((n) + ((d)/2)) / (d))
814#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
815#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
816
817#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)
818#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
819
820/* Pull in stuff for the build system */
821#ifdef DO_DEPS_ONLY
822# include <environment.h>
823#endif
824
825#endif /* __COMMON_H_ */