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