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