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