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