]> Git Repo - J-u-boot.git/blame - include/common.h
* Fix problems caused by Robert Schwebel's cramfs patch
[J-u-boot.git] / include / common.h
CommitLineData
e2211743 1/*
d4ca31c4 2 * (C) Copyright 2000-2004
e2211743
WD
3 * Wolfgang Denk, DENX Software Engineering, [email protected].
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
180d3f74 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e2211743
WD
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
30typedef unsigned char uchar;
31typedef volatile unsigned long vu_long;
180d3f74 32typedef volatile unsigned short vu_short;
e2211743
WD
33typedef volatile unsigned char vu_char;
34
35#include <config.h>
36#include <linux/bitops.h>
37#include <linux/types.h>
38#include <linux/string.h>
39#include <asm/ptrace.h>
40#include <stdarg.h>
41#if defined(CONFIG_PCI) && defined(CONFIG_440)
42#include <pci.h>
43#endif
180d3f74 44#if defined(CONFIG_8xx)
e2211743 45#include <asm/8xx_immap.h>
d4ca31c4
WD
46#if defined(CONFIG_MPC852) || defined(CONFIG_MPC852T) || \
47 defined(CONFIG_MPC859) || defined(CONFIG_MPC859T) || \
48 defined(CONFIG_MPC859DSL) || \
49 defined(CONFIG_MPC866) || defined(CONFIG_MPC866T) || \
50 defined(CONFIG_MPC866P)
180d3f74
WD
51# define CONFIG_MPC866_et_al 1
52#elif defined(CONFIG_MPC870) \
53 || defined(CONFIG_MPC875) \
54 || defined(CONFIG_MPC880) \
55 || defined(CONFIG_MPC885)
56# define CONFIG_DUET 1
57#endif
58#if defined(CONFIG_MPC860) \
59 || defined(CONFIG_MPC860T) \
60 || defined(CONFIG_MPC866_et_al) \
61 || defined(CONFIG_DUET)
62# define CONFIG_MPC86x 1
2535d602 63#endif
0db5bca8
WD
64#elif defined(CONFIG_5xx)
65#include <asm/5xx_immap.h>
e2211743
WD
66#elif defined(CONFIG_8260)
67#include <asm/immap_8260.h>
68#endif
42d1f039
WD
69#ifdef CONFIG_MPC85xx
70#include <mpc85xx.h>
71#include <asm/immap_85xx.h>
72#endif
e2211743
WD
73#ifdef CONFIG_4xx
74#include <ppc4xx.h>
75#endif
76#ifdef CONFIG_HYMOD
6dd652fa 77#include <board/hymod/hymod.h>
e2211743
WD
78#endif
79#ifdef CONFIG_ARM
80#define asmlinkage /* nothing */
81#endif
82
83#include <part.h>
84#include <flash.h>
85#include <image.h>
86
87#ifdef DEBUG
88#define debug(fmt,args...) printf (fmt ,##args)
52f52c14 89#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
e2211743
WD
90#else
91#define debug(fmt,args...)
52f52c14 92#define debugX(level,fmt,args...)
e2211743
WD
93#endif /* DEBUG */
94
95typedef void (interrupt_handler_t)(void *);
96
97#include <asm/u-boot.h> /* boot information for Linux kernel */
98#include <asm/global_data.h> /* global data used for startup functions */
99
71f95118
WD
100/*
101 * enable common handling for all TQM8xxL/M boards:
102 * - CONFIG_TQM8xxM will be defined for all TQM8xxM boards
103 * - CONFIG_TQM8xxL will be defined for all TQM8xxL _and_ TQM8xxM boards
104 */
105#if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \
106 defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \
d4ca31c4 107 defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M)
71f95118
WD
108# ifndef CONFIG_TQM8xxM
109# define CONFIG_TQM8xxM
110# endif
111#endif
e2211743 112#if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
d126bfbd 113 defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \
71f95118 114 defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM)
e2211743
WD
115# ifndef CONFIG_TQM8xxL
116# define CONFIG_TQM8xxL
117# endif
118#endif
119
120
c7de829c
WD
121/*
122 * General Purpose Utilities
123 */
124#define min(X, Y) \
125 ({ typeof (X) __x = (X), __y = (Y); \
126 (__x < __y) ? __x : __y; })
127
128#define max(X, Y) \
129 ({ typeof (X) __x = (X), __y = (Y); \
130 (__x > __y) ? __x : __y; })
131
132
e2211743
WD
133/*
134 * Function Prototypes
135 */
136
137#if CONFIG_SERIAL_SOFTWARE_FIFO
138void serial_buffered_init (void);
139void serial_buffered_putc (const char);
140void serial_buffered_puts (const char *);
141int serial_buffered_getc (void);
142int serial_buffered_tstc (void);
143#endif /* CONFIG_SERIAL_SOFTWARE_FIFO */
144
145void hang (void) __attribute__ ((noreturn));
146
147/* */
148long int initdram (int);
149int display_options (void);
150void print_size (ulong, const char *);
151
152/* common/main.c */
153void main_loop (void);
154int run_command (const char *cmd, int flag);
155int readline (const char *const prompt);
6dd652fa 156void init_cmd_timeout(void);
e2211743
WD
157void reset_cmd_timeout(void);
158
15647dc7 159/* lib_$(ARCH)/board.c */
e2211743
WD
160void board_init_f (ulong);
161void board_init_r (gd_t *, ulong);
162int checkboard (void);
163int checkflash (void);
164int checkdram (void);
165char * strmhz(char *buf, long hz);
166int last_stage_init(void);
3b57fe0a 167extern ulong monitor_flash_len;
e2211743
WD
168
169/* common/flash.c */
170void flash_perror (int);
171
b0fce99b
WD
172/* common/cmd_autoscript.c */
173int autoscript (ulong addr);
174
e2211743 175/* common/cmd_bootm.c */
b0fce99b 176void print_image_hdr (image_header_t *hdr);
e2211743
WD
177
178extern ulong load_addr; /* Default Load Address */
179
180/* common/cmd_nvedit.c */
181int env_init (void);
182void env_relocate (void);
183char *getenv (uchar *);
184int getenv_r (uchar *name, uchar *buf, unsigned len);
185int saveenv (void);
186#ifdef CONFIG_PPC /* ARM version to be fixed! */
187void inline setenv (char *, char *);
2262cfee
WD
188#else
189void setenv (char *, char *);
e2211743
WD
190#endif /* CONFIG_PPC */
191#ifdef CONFIG_ARM
b6e4c403 192# include <asm/setup.h>
e2211743
WD
193# include <asm/u-boot-arm.h> /* ARM version to be fixed! */
194#endif /* CONFIG_ARM */
2262cfee 195#ifdef CONFIG_I386 /* x86 version to be fixed! */
8bde7f77 196# include <asm/u-boot-i386.h>
2262cfee 197#endif /* CONFIG_I386 */
e2211743
WD
198
199void pci_init (void);
ad10dd9a 200void pci_init_board(void);
e2211743
WD
201void pciinfo (int, int);
202
203#if defined(CONFIG_PCI) && defined(CONFIG_440)
204# if defined(CFG_PCI_PRE_INIT)
205 int pci_pre_init (struct pci_controller * );
206# endif
207# if defined(CFG_PCI_TARGET_INIT)
208 void pci_target_init (struct pci_controller *);
209# endif
210# if defined(CFG_PCI_MASTER_INIT)
211 void pci_master_init (struct pci_controller *);
212# endif
213 int is_pci_host (struct pci_controller *);
214#endif
215
216int misc_init_f (void);
217int misc_init_r (void);
218
27b207fd
WD
219/* common/exports.c */
220void jumptable_init(void);
221
e2211743
WD
222/* $(BOARD)/$(BOARD).c */
223void reset_phy (void);
7f6c2cbc 224void fdc_hw_init (void);
e2211743
WD
225
226/* $(BOARD)/eeprom.c */
227void eeprom_init (void);
6dd652fa
WD
228#ifndef CONFIG_SPI
229int eeprom_probe (unsigned dev_addr, unsigned offset);
230#endif
e2211743
WD
231int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
232int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
233#ifdef CONFIG_LWMON
234extern uchar pic_read (uchar reg);
235extern void pic_write (uchar reg, uchar val);
236#endif
237
238/*
239 * Set this up regardless of board
240 * type, to prevent errors.
241 */
242#if defined(CONFIG_SPI) || !defined(CFG_I2C_EEPROM_ADDR)
243# define CFG_DEF_EEPROM_ADDR 0
244#else
245# define CFG_DEF_EEPROM_ADDR CFG_I2C_EEPROM_ADDR
246#endif /* CONFIG_SPI || !defined(CFG_I2C_EEPROM_ADDR) */
247
bdccc4fe 248#if defined(CONFIG_SPI)
e2211743
WD
249extern void spi_init_f (void);
250extern void spi_init_r (void);
251extern ssize_t spi_read (uchar *, int, uchar *, int);
252extern ssize_t spi_write (uchar *, int, uchar *, int);
253#endif
254
255#ifdef CONFIG_RPXCLASSIC
256void rpxclassic_init (void);
257#endif
258
259#ifdef CONFIG_MBX
260/* $(BOARD)/mbx8xx.c */
261void mbx_init (void);
262void board_serial_init (void);
263void board_ether_init (void);
264#endif
265
266#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_MBX) || defined(CONFIG_IAD210)
267void board_get_enetaddr (uchar *addr);
268#endif
269
270#ifdef CONFIG_HERMES
271/* $(BOARD)/hermes.c */
272void hermes_start_lxt980 (int speed);
273#endif
274
275#ifdef CONFIG_EVB64260
276void evb64260_init(void);
277void debug_led(int, int);
278void display_mem_map(void);
279void perform_soft_reset(void);
280#endif
281
282void load_sernum_ethaddr (void);
283
284/* $(BOARD)/$(BOARD).c */
285int board_pre_init (void);
71f95118 286int board_post_init (void);
e2211743
WD
287int board_postclk_init (void); /* after clocks/timebase, before env/serial */
288void board_poweroff (void);
289
290#if defined(CFG_DRAM_TEST)
291int testdram(void);
292#endif /* CFG_DRAM_TEST */
293
294/* $(CPU)/start.S */
0db5bca8
WD
295#if defined(CONFIG_5xx) || \
296 defined(CONFIG_8xx)
e2211743
WD
297uint get_immr (uint);
298#endif
42d1f039 299uint get_pir (void);
e2211743
WD
300uint get_pvr (void);
301uint rd_ic_cst (void);
302void wr_ic_cst (uint);
303void wr_ic_adr (uint);
304uint rd_dc_cst (void);
305void wr_dc_cst (uint);
306void wr_dc_adr (uint);
307int icache_status (void);
308void icache_enable (void);
309void icache_disable(void);
310int dcache_status (void);
311void dcache_enable (void);
312void dcache_disable(void);
313void relocate_code (ulong, gd_t *, ulong);
314ulong get_endaddr (void);
315void trap_init (ulong);
316#if defined (CONFIG_4xx) || \
317 defined (CONFIG_74xx_7xx) || \
318 defined (CONFIG_74x) || \
319 defined (CONFIG_75x) || \
320 defined (CONFIG_74xx)
321unsigned char in8(unsigned int);
322void out8(unsigned int, unsigned char);
323unsigned short in16(unsigned int);
324unsigned short in16r(unsigned int);
325void out16(unsigned int, unsigned short value);
326void out16r(unsigned int, unsigned short value);
327unsigned long in32(unsigned int);
328unsigned long in32r(unsigned int);
329void out32(unsigned int, unsigned long value);
330void out32r(unsigned int, unsigned long value);
331void ppcDcbf(unsigned long value);
332void ppcDcbi(unsigned long value);
333void ppcSync(void);
334#endif
335
336/* $(CPU)/cpu.c */
337int checkcpu (void);
338int checkicache (void);
339int checkdcache (void);
340void upmconfig (unsigned int, unsigned int *, unsigned int);
341ulong get_tbclk (void);
342
343/* $(CPU)/serial.c */
344int serial_init (void);
345void serial_setbrg (void);
346void serial_putc (const char);
347void serial_puts (const char *);
348void serial_addr (unsigned int);
349int serial_getc (void);
350int serial_tstc (void);
351
352/* $(CPU)/speed.c */
353int get_clocks (void);
354#if defined(CONFIG_8260)
355int prt_8260_clks (void);
356#endif
945af8d7
WD
357#if defined(CONFIG_MPC5XXX)
358int prt_mpc5xxx_clks (void);
359#endif
e2211743
WD
360#ifdef CONFIG_4xx
361ulong get_OPB_freq (void);
362ulong get_PCI_freq (void);
363#endif
364#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
365ulong get_FCLK (void);
366ulong get_HCLK (void);
367ulong get_PCLK (void);
368ulong get_UCLK (void);
369#endif
7cb22f97
WD
370#if defined CONFIG_INCA_IP
371uint incaip_get_cpuclk (void);
372#endif
e2211743
WD
373ulong get_bus_freq (ulong);
374
42d1f039
WD
375#if defined(CONFIG_MPC85xx)
376typedef MPC85xx_SYS_INFO sys_info_t;
377void get_sys_info ( sys_info_t * );
378#endif
379
e2211743
WD
380#if defined(CONFIG_4xx) || defined(CONFIG_IOP480)
381# if defined(CONFIG_440)
382 typedef PPC440_SYS_INFO sys_info_t;
383# else
384 typedef PPC405_SYS_INFO sys_info_t;
385# endif
386void get_sys_info ( sys_info_t * );
387#endif
388
389/* $(CPU)/cpu_init.c */
390#if defined(CONFIG_8xx) || defined(CONFIG_8260)
391void cpu_init_f (volatile immap_t *immr);
392#endif
42d1f039 393#if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx)
e2211743
WD
394void cpu_init_f (void);
395#endif
396int cpu_init_r (void);
397#if defined(CONFIG_8260)
398int prt_8260_rsr (void);
399#endif
400
401/* $(CPU)/interrupts.c */
402int interrupt_init (void);
403void timer_interrupt (struct pt_regs *);
404void external_interrupt (struct pt_regs *);
405void irq_install_handler(int, interrupt_handler_t *, void *);
406void irq_free_handler (int);
407void reset_timer (void);
408ulong get_timer (ulong base);
409void set_timer (ulong t);
410void enable_interrupts (void);
411int disable_interrupts (void);
412
413/* $(CPU)/.../commproc.c */
414int dpram_init (void);
415uint dpram_base(void);
416uint dpram_base_align(uint align);
417uint dpram_alloc(uint size);
418uint dpram_alloc_align(uint size,uint align);
419void post_word_store (ulong);
420ulong post_word_load (void);
bdccc4fe
WD
421void bootcount_store (ulong);
422ulong bootcount_load (void);
423#define BOOTCOUNT_MAGIC 0xB001C041
e2211743
WD
424
425/* $(CPU)/.../<eth> */
426void mii_init (void);
427
428/* $(CPU)/.../lcd.c */
429ulong lcd_setmem (ulong);
430
431/* $(CPU)/.../vfd.c */
432ulong vfd_setmem (ulong);
433
434/* $(CPU)/.../video.c */
435ulong video_setmem (ulong);
436
437/* ppc/cache.c */
438void flush_cache (unsigned long, unsigned long);
439
0db5bca8 440
15647dc7 441/* lib_$(ARCH)/ticks.S */
e2211743
WD
442unsigned long long get_ticks(void);
443void wait_ticks (unsigned long);
444
15647dc7 445/* lib_$(ARCH)/time.c */
e2211743
WD
446void udelay (unsigned long);
447ulong usec2ticks (unsigned long usec);
448ulong ticks2usec (unsigned long ticks);
449int init_timebase (void);
450
15647dc7 451/* lib_generic/vsprintf.c */
e2211743
WD
452ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
453long simple_strtol(const char *cp,char **endp,unsigned int base);
454void panic(const char *fmt, ...);
455int sprintf(char * buf, const char *fmt, ...);
456int vsprintf(char *buf, const char *fmt, va_list args);
457
15647dc7 458/* lib_generic/crc32.c */
e2211743
WD
459ulong crc32 (ulong, const unsigned char *, uint);
460ulong crc32_no_comp (ulong, const unsigned char *, uint);
461
462/* common/console.c */
e2211743
WD
463int console_init_f(void); /* Before relocation; uses the serial stuff */
464int console_init_r(void); /* After relocation; uses the console stuff */
465int console_assign (int file, char *devname); /* Assign the console */
466int ctrlc (void);
467int had_ctrlc (void); /* have we had a Control-C since last clear? */
468void clear_ctrlc (void); /* clear the Control-C condition */
469int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */
470
471/*
472 * STDIO based functions (can always be used)
473 */
474
475/* serial stuff */
476void serial_printf (const char *fmt, ...);
477
478/* stdin */
479int getc(void);
480int tstc(void);
481
482/* stdout */
483void putc(const char c);
484void puts(const char *s);
485void printf(const char *fmt, ...);
6dd652fa 486void vprintf(const char *fmt, va_list args);
e2211743
WD
487
488/* stderr */
489#define eputc(c) fputc(stderr, c)
490#define eputs(s) fputs(stderr, s)
491#define eprintf(fmt,args...) fprintf(stderr,fmt ,##args)
492
493/*
494 * FILE based functions (can only be used AFTER relocation!)
495 */
496
497#define stdin 0
498#define stdout 1
499#define stderr 2
500#define MAX_FILES 3
501
502void fprintf(int file, const char *fmt, ...);
503void fputs(int file, const char *s);
504void fputc(int file, const char c);
505int ftstc(int file);
506int fgetc(int file);
507
508int pcmcia_init (void);
509
510#ifdef CONFIG_SHOW_BOOT_PROGRESS
511void show_boot_progress (int status);
512#endif
513
514#endif /* __COMMON_H_ */
This page took 0.093527 seconds and 4 git commands to generate.