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