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