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