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