blob: 6b92548243ee452d5fa0d0023e8f66c2c3298bf8 [file] [log] [blame]
wdenke2211742002-11-02 23:30:20 +00001/*
wdenk1ebf41e2004-01-02 14:00:00 +00002 * (C) Copyright 2000-2004
wdenke2211742002-11-02 23:30:20 +00003 * 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>
wdenk2bb11052003-07-17 23:16:40 +000046#ifdef CONFIG_MPC860
47#define CONFIG_MPC86x 1
48#endif
49#ifdef CONFIG_MPC860T
50#define CONFIG_MPC86x 1
51#endif
wdenk1ebf41e2004-01-02 14:00:00 +000052#if defined(CONFIG_MPC852) || defined(CONFIG_MPC852T) || \
53 defined(CONFIG_MPC859) || defined(CONFIG_MPC859T) || \
54 defined(CONFIG_MPC859DSL) || \
55 defined(CONFIG_MPC866) || defined(CONFIG_MPC866T) || \
56 defined(CONFIG_MPC866P)
wdenk2bb11052003-07-17 23:16:40 +000057#define CONFIG_MPC866_et_al 1
58#define CONFIG_MPC86x 1
59#endif
wdenk359733b2003-03-31 17:27:09 +000060#elif defined(CONFIG_5xx)
61#include <asm/5xx_immap.h>
wdenke2211742002-11-02 23:30:20 +000062#elif defined(CONFIG_8260)
63#include <asm/immap_8260.h>
64#endif
wdenk9c53f402003-10-15 23:53:47 +000065#ifdef CONFIG_MPC85xx
66#include <mpc85xx.h>
67#include <asm/immap_85xx.h>
68#endif
wdenke2211742002-11-02 23:30:20 +000069#ifdef CONFIG_4xx
70#include <ppc4xx.h>
71#endif
72#ifdef CONFIG_HYMOD
wdenkb00ec162003-06-19 23:40:20 +000073#include <board/hymod/hymod.h>
wdenke2211742002-11-02 23:30:20 +000074#endif
75#ifdef CONFIG_ARM
76#define asmlinkage /* nothing */
77#endif
78
79#include <part.h>
80#include <flash.h>
81#include <image.h>
82
83#ifdef DEBUG
84#define debug(fmt,args...) printf (fmt ,##args)
wdenk88e72a32003-06-19 23:04:19 +000085#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
wdenke2211742002-11-02 23:30:20 +000086#else
87#define debug(fmt,args...)
wdenk88e72a32003-06-19 23:04:19 +000088#define debugX(level,fmt,args...)
wdenke2211742002-11-02 23:30:20 +000089#endif /* DEBUG */
90
91typedef void (interrupt_handler_t)(void *);
92
93#include <asm/u-boot.h> /* boot information for Linux kernel */
94#include <asm/global_data.h> /* global data used for startup functions */
95
wdenk7a428cc2003-06-15 22:40:42 +000096/*
97 * enable common handling for all TQM8xxL/M boards:
98 * - CONFIG_TQM8xxM will be defined for all TQM8xxM boards
99 * - CONFIG_TQM8xxL will be defined for all TQM8xxL _and_ TQM8xxM boards
100 */
101#if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \
102 defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \
wdenk1ebf41e2004-01-02 14:00:00 +0000103 defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M)
wdenk7a428cc2003-06-15 22:40:42 +0000104# ifndef CONFIG_TQM8xxM
105# define CONFIG_TQM8xxM
106# endif
107#endif
wdenke2211742002-11-02 23:30:20 +0000108#if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
wdenk6bd14892003-04-10 11:18:18 +0000109 defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \
wdenk7a428cc2003-06-15 22:40:42 +0000110 defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM)
wdenke2211742002-11-02 23:30:20 +0000111# ifndef CONFIG_TQM8xxL
112# define CONFIG_TQM8xxL
113# endif
114#endif
115
116
117/*
wdenk452cfd62002-11-19 11:04:11 +0000118 * General Purpose Utilities
119 */
120#define min(X, Y) \
121 ({ typeof (X) __x = (X), __y = (Y); \
122 (__x < __y) ? __x : __y; })
123
124#define max(X, Y) \
125 ({ typeof (X) __x = (X), __y = (Y); \
126 (__x > __y) ? __x : __y; })
127
128
129/*
wdenke2211742002-11-02 23:30:20 +0000130 * Function Prototypes
131 */
132
133#if CONFIG_SERIAL_SOFTWARE_FIFO
134void serial_buffered_init (void);
135void serial_buffered_putc (const char);
136void serial_buffered_puts (const char *);
137int serial_buffered_getc (void);
138int serial_buffered_tstc (void);
139#endif /* CONFIG_SERIAL_SOFTWARE_FIFO */
140
141void hang (void) __attribute__ ((noreturn));
142
143/* */
144long int initdram (int);
145int display_options (void);
146void print_size (ulong, const char *);
147
148/* common/main.c */
149void main_loop (void);
150int run_command (const char *cmd, int flag);
151int readline (const char *const prompt);
wdenkb00ec162003-06-19 23:40:20 +0000152void init_cmd_timeout(void);
wdenke2211742002-11-02 23:30:20 +0000153void reset_cmd_timeout(void);
154
wdenk9f837932003-10-09 19:00:25 +0000155/* lib_$(ARCH)/board.c */
wdenke2211742002-11-02 23:30:20 +0000156void board_init_f (ulong);
157void board_init_r (gd_t *, ulong);
158int checkboard (void);
159int checkflash (void);
160int checkdram (void);
161char * strmhz(char *buf, long hz);
162int last_stage_init(void);
wdenkb9a83a92003-05-30 12:48:29 +0000163extern ulong monitor_flash_len;
wdenke2211742002-11-02 23:30:20 +0000164
165/* common/flash.c */
166void flash_perror (int);
167
wdenkf12e3962003-06-29 21:03:46 +0000168/* common/cmd_autoscript.c */
169int autoscript (ulong addr);
170
wdenke2211742002-11-02 23:30:20 +0000171/* common/cmd_bootm.c */
wdenkf12e3962003-06-29 21:03:46 +0000172void print_image_hdr (image_header_t *hdr);
wdenke2211742002-11-02 23:30:20 +0000173
174extern ulong load_addr; /* Default Load Address */
175
176/* common/cmd_nvedit.c */
177int env_init (void);
178void env_relocate (void);
179char *getenv (uchar *);
180int getenv_r (uchar *name, uchar *buf, unsigned len);
181int saveenv (void);
182#ifdef CONFIG_PPC /* ARM version to be fixed! */
183void inline setenv (char *, char *);
wdenk591dda52002-11-18 00:14:45 +0000184#else
185void setenv (char *, char *);
wdenke2211742002-11-02 23:30:20 +0000186#endif /* CONFIG_PPC */
187#ifdef CONFIG_ARM
wdenkbc01dd52004-01-02 16:05:07 +0000188# include <asm/setup.h>
wdenke2211742002-11-02 23:30:20 +0000189# include <asm/u-boot-arm.h> /* ARM version to be fixed! */
190#endif /* CONFIG_ARM */
wdenk591dda52002-11-18 00:14:45 +0000191#ifdef CONFIG_I386 /* x86 version to be fixed! */
wdenk57b2d802003-06-27 21:31:46 +0000192# include <asm/u-boot-i386.h>
wdenk591dda52002-11-18 00:14:45 +0000193#endif /* CONFIG_I386 */
wdenke2211742002-11-02 23:30:20 +0000194
195void pci_init (void);
stroesef5dd4102003-02-14 11:21:23 +0000196void pci_init_board(void);
wdenke2211742002-11-02 23:30:20 +0000197void pciinfo (int, int);
198
199#if defined(CONFIG_PCI) && defined(CONFIG_440)
200# if defined(CFG_PCI_PRE_INIT)
201 int pci_pre_init (struct pci_controller * );
202# endif
203# if defined(CFG_PCI_TARGET_INIT)
204 void pci_target_init (struct pci_controller *);
205# endif
206# if defined(CFG_PCI_MASTER_INIT)
207 void pci_master_init (struct pci_controller *);
208# endif
209 int is_pci_host (struct pci_controller *);
210#endif
211
212int misc_init_f (void);
213int misc_init_r (void);
214
wdenk874ac262003-07-24 23:38:38 +0000215/* common/exports.c */
216void jumptable_init(void);
217
wdenke2211742002-11-02 23:30:20 +0000218/* $(BOARD)/$(BOARD).c */
219void reset_phy (void);
wdenk1272e232002-11-10 22:06:23 +0000220void fdc_hw_init (void);
wdenke2211742002-11-02 23:30:20 +0000221
222/* $(BOARD)/eeprom.c */
223void eeprom_init (void);
wdenkb00ec162003-06-19 23:40:20 +0000224#ifndef CONFIG_SPI
225int eeprom_probe (unsigned dev_addr, unsigned offset);
226#endif
wdenke2211742002-11-02 23:30:20 +0000227int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
228int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
229#ifdef CONFIG_LWMON
230extern uchar pic_read (uchar reg);
231extern void pic_write (uchar reg, uchar val);
232#endif
233
234/*
235 * Set this up regardless of board
236 * type, to prevent errors.
237 */
238#if defined(CONFIG_SPI) || !defined(CFG_I2C_EEPROM_ADDR)
239# define CFG_DEF_EEPROM_ADDR 0
240#else
241# define CFG_DEF_EEPROM_ADDR CFG_I2C_EEPROM_ADDR
242#endif /* CONFIG_SPI || !defined(CFG_I2C_EEPROM_ADDR) */
243
wdenk0a658552003-08-05 17:43:17 +0000244#if defined(CONFIG_SPI)
wdenke2211742002-11-02 23:30:20 +0000245extern void spi_init_f (void);
246extern void spi_init_r (void);
247extern ssize_t spi_read (uchar *, int, uchar *, int);
248extern ssize_t spi_write (uchar *, int, uchar *, int);
249#endif
250
251#ifdef CONFIG_RPXCLASSIC
252void rpxclassic_init (void);
253#endif
254
255#ifdef CONFIG_MBX
256/* $(BOARD)/mbx8xx.c */
257void mbx_init (void);
258void board_serial_init (void);
259void board_ether_init (void);
260#endif
261
262#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_MBX) || defined(CONFIG_IAD210)
263void board_get_enetaddr (uchar *addr);
264#endif
265
266#ifdef CONFIG_HERMES
267/* $(BOARD)/hermes.c */
268void hermes_start_lxt980 (int speed);
269#endif
270
271#ifdef CONFIG_EVB64260
272void evb64260_init(void);
273void debug_led(int, int);
274void display_mem_map(void);
275void perform_soft_reset(void);
276#endif
277
278void load_sernum_ethaddr (void);
279
280/* $(BOARD)/$(BOARD).c */
281int board_pre_init (void);
wdenk7a428cc2003-06-15 22:40:42 +0000282int board_post_init (void);
wdenke2211742002-11-02 23:30:20 +0000283int board_postclk_init (void); /* after clocks/timebase, before env/serial */
284void board_poweroff (void);
285
286#if defined(CFG_DRAM_TEST)
287int testdram(void);
288#endif /* CFG_DRAM_TEST */
289
290/* $(CPU)/start.S */
wdenk359733b2003-03-31 17:27:09 +0000291#if defined(CONFIG_5xx) || \
292 defined(CONFIG_8xx)
wdenke2211742002-11-02 23:30:20 +0000293uint get_immr (uint);
294#endif
wdenk9c53f402003-10-15 23:53:47 +0000295uint get_pir (void);
wdenke2211742002-11-02 23:30:20 +0000296uint get_pvr (void);
297uint rd_ic_cst (void);
298void wr_ic_cst (uint);
299void wr_ic_adr (uint);
300uint rd_dc_cst (void);
301void wr_dc_cst (uint);
302void wr_dc_adr (uint);
303int icache_status (void);
304void icache_enable (void);
305void icache_disable(void);
306int dcache_status (void);
307void dcache_enable (void);
308void dcache_disable(void);
309void relocate_code (ulong, gd_t *, ulong);
310ulong get_endaddr (void);
311void trap_init (ulong);
312#if defined (CONFIG_4xx) || \
313 defined (CONFIG_74xx_7xx) || \
314 defined (CONFIG_74x) || \
315 defined (CONFIG_75x) || \
316 defined (CONFIG_74xx)
317unsigned char in8(unsigned int);
318void out8(unsigned int, unsigned char);
319unsigned short in16(unsigned int);
320unsigned short in16r(unsigned int);
321void out16(unsigned int, unsigned short value);
322void out16r(unsigned int, unsigned short value);
323unsigned long in32(unsigned int);
324unsigned long in32r(unsigned int);
325void out32(unsigned int, unsigned long value);
326void out32r(unsigned int, unsigned long value);
327void ppcDcbf(unsigned long value);
328void ppcDcbi(unsigned long value);
329void ppcSync(void);
330#endif
331
332/* $(CPU)/cpu.c */
333int checkcpu (void);
334int checkicache (void);
335int checkdcache (void);
336void upmconfig (unsigned int, unsigned int *, unsigned int);
337ulong get_tbclk (void);
338
339/* $(CPU)/serial.c */
340int serial_init (void);
341void serial_setbrg (void);
342void serial_putc (const char);
343void serial_puts (const char *);
344void serial_addr (unsigned int);
345int serial_getc (void);
346int serial_tstc (void);
347
348/* $(CPU)/speed.c */
349int get_clocks (void);
350#if defined(CONFIG_8260)
351int prt_8260_clks (void);
352#endif
wdenk21136db2003-07-16 21:53:01 +0000353#if defined(CONFIG_MPC5XXX)
354int prt_mpc5xxx_clks (void);
355#endif
wdenke2211742002-11-02 23:30:20 +0000356#ifdef CONFIG_4xx
357ulong get_OPB_freq (void);
358ulong get_PCI_freq (void);
359#endif
360#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
361ulong get_FCLK (void);
362ulong get_HCLK (void);
363ulong get_PCLK (void);
364ulong get_UCLK (void);
365#endif
wdenk67f13362003-12-27 19:24:54 +0000366#if defined CONFIG_INCA_IP
367uint incaip_get_cpuclk (void);
368#endif
wdenke2211742002-11-02 23:30:20 +0000369ulong get_bus_freq (ulong);
370
wdenk9c53f402003-10-15 23:53:47 +0000371#if defined(CONFIG_MPC85xx)
372typedef MPC85xx_SYS_INFO sys_info_t;
373void get_sys_info ( sys_info_t * );
374#endif
375
wdenke2211742002-11-02 23:30:20 +0000376#if defined(CONFIG_4xx) || defined(CONFIG_IOP480)
377# if defined(CONFIG_440)
378 typedef PPC440_SYS_INFO sys_info_t;
379# else
380 typedef PPC405_SYS_INFO sys_info_t;
381# endif
382void get_sys_info ( sys_info_t * );
383#endif
384
385/* $(CPU)/cpu_init.c */
386#if defined(CONFIG_8xx) || defined(CONFIG_8260)
387void cpu_init_f (volatile immap_t *immr);
388#endif
wdenk9c53f402003-10-15 23:53:47 +0000389#if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx)
wdenke2211742002-11-02 23:30:20 +0000390void cpu_init_f (void);
391#endif
392int cpu_init_r (void);
393#if defined(CONFIG_8260)
394int prt_8260_rsr (void);
395#endif
396
397/* $(CPU)/interrupts.c */
398int interrupt_init (void);
399void timer_interrupt (struct pt_regs *);
400void external_interrupt (struct pt_regs *);
401void irq_install_handler(int, interrupt_handler_t *, void *);
402void irq_free_handler (int);
403void reset_timer (void);
404ulong get_timer (ulong base);
405void set_timer (ulong t);
406void enable_interrupts (void);
407int disable_interrupts (void);
408
409/* $(CPU)/.../commproc.c */
410int dpram_init (void);
411uint dpram_base(void);
412uint dpram_base_align(uint align);
413uint dpram_alloc(uint size);
414uint dpram_alloc_align(uint size,uint align);
415void post_word_store (ulong);
416ulong post_word_load (void);
wdenk0a658552003-08-05 17:43:17 +0000417void bootcount_store (ulong);
418ulong bootcount_load (void);
419#define BOOTCOUNT_MAGIC 0xB001C041
wdenke2211742002-11-02 23:30:20 +0000420
421/* $(CPU)/.../<eth> */
422void mii_init (void);
423
424/* $(CPU)/.../lcd.c */
425ulong lcd_setmem (ulong);
426
427/* $(CPU)/.../vfd.c */
428ulong vfd_setmem (ulong);
429
430/* $(CPU)/.../video.c */
431ulong video_setmem (ulong);
432
433/* ppc/cache.c */
434void flush_cache (unsigned long, unsigned long);
435
wdenk359733b2003-03-31 17:27:09 +0000436
wdenk9f837932003-10-09 19:00:25 +0000437/* lib_$(ARCH)/ticks.S */
wdenke2211742002-11-02 23:30:20 +0000438unsigned long long get_ticks(void);
439void wait_ticks (unsigned long);
440
wdenk9f837932003-10-09 19:00:25 +0000441/* lib_$(ARCH)/time.c */
wdenke2211742002-11-02 23:30:20 +0000442void udelay (unsigned long);
443ulong usec2ticks (unsigned long usec);
444ulong ticks2usec (unsigned long ticks);
445int init_timebase (void);
446
wdenk9f837932003-10-09 19:00:25 +0000447/* lib_generic/vsprintf.c */
wdenke2211742002-11-02 23:30:20 +0000448ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
449long simple_strtol(const char *cp,char **endp,unsigned int base);
450void panic(const char *fmt, ...);
451int sprintf(char * buf, const char *fmt, ...);
452int vsprintf(char *buf, const char *fmt, va_list args);
453
wdenk9f837932003-10-09 19:00:25 +0000454/* lib_generic/crc32.c */
wdenke2211742002-11-02 23:30:20 +0000455ulong crc32 (ulong, const unsigned char *, uint);
456ulong crc32_no_comp (ulong, const unsigned char *, uint);
457
458/* common/console.c */
wdenke2211742002-11-02 23:30:20 +0000459int console_init_f(void); /* Before relocation; uses the serial stuff */
460int console_init_r(void); /* After relocation; uses the console stuff */
461int console_assign (int file, char *devname); /* Assign the console */
462int ctrlc (void);
463int had_ctrlc (void); /* have we had a Control-C since last clear? */
464void clear_ctrlc (void); /* clear the Control-C condition */
465int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */
466
467/*
468 * STDIO based functions (can always be used)
469 */
470
471/* serial stuff */
472void serial_printf (const char *fmt, ...);
473
474/* stdin */
475int getc(void);
476int tstc(void);
477
478/* stdout */
479void putc(const char c);
480void puts(const char *s);
481void printf(const char *fmt, ...);
wdenkb00ec162003-06-19 23:40:20 +0000482void vprintf(const char *fmt, va_list args);
wdenke2211742002-11-02 23:30:20 +0000483
484/* stderr */
485#define eputc(c) fputc(stderr, c)
486#define eputs(s) fputs(stderr, s)
487#define eprintf(fmt,args...) fprintf(stderr,fmt ,##args)
488
489/*
490 * FILE based functions (can only be used AFTER relocation!)
491 */
492
493#define stdin 0
494#define stdout 1
495#define stderr 2
496#define MAX_FILES 3
497
498void fprintf(int file, const char *fmt, ...);
499void fputs(int file, const char *s);
500void fputc(int file, const char c);
501int ftstc(int file);
502int fgetc(int file);
503
504int pcmcia_init (void);
505
506#ifdef CONFIG_SHOW_BOOT_PROGRESS
507void show_boot_progress (int status);
508#endif
509
510#endif /* __COMMON_H_ */