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