blob: 5158f97ece3774105087e557a5919b387bfce289 [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>
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
52#if defined(CONFIG_MPC866P) || \
53 defined(CONFIG_MPC866T) || \
54 defined(CONFIG_MPC859T) || \
55 defined(CONFIG_MPC859DSL) || \
56 defined(CONFIG_MPC852T)
57#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
65#ifdef CONFIG_4xx
66#include <ppc4xx.h>
67#endif
68#ifdef CONFIG_HYMOD
wdenkb00ec162003-06-19 23:40:20 +000069#include <board/hymod/hymod.h>
wdenke2211742002-11-02 23:30:20 +000070#endif
71#ifdef CONFIG_ARM
72#define asmlinkage /* nothing */
73#endif
74
75#include <part.h>
76#include <flash.h>
77#include <image.h>
78
79#ifdef DEBUG
80#define debug(fmt,args...) printf (fmt ,##args)
wdenk88e72a32003-06-19 23:04:19 +000081#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
wdenke2211742002-11-02 23:30:20 +000082#else
83#define debug(fmt,args...)
wdenk88e72a32003-06-19 23:04:19 +000084#define debugX(level,fmt,args...)
wdenke2211742002-11-02 23:30:20 +000085#endif /* DEBUG */
86
87typedef void (interrupt_handler_t)(void *);
88
89#include <asm/u-boot.h> /* boot information for Linux kernel */
90#include <asm/global_data.h> /* global data used for startup functions */
91
wdenk7a428cc2003-06-15 22:40:42 +000092/*
93 * enable common handling for all TQM8xxL/M boards:
94 * - CONFIG_TQM8xxM will be defined for all TQM8xxM boards
95 * - CONFIG_TQM8xxL will be defined for all TQM8xxL _and_ TQM8xxM boards
96 */
97#if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \
98 defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \
99 defined(CONFIG_TQM862M)
100# ifndef CONFIG_TQM8xxM
101# define CONFIG_TQM8xxM
102# endif
103#endif
wdenke2211742002-11-02 23:30:20 +0000104#if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
wdenk6bd14892003-04-10 11:18:18 +0000105 defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \
wdenk7a428cc2003-06-15 22:40:42 +0000106 defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM)
wdenke2211742002-11-02 23:30:20 +0000107# ifndef CONFIG_TQM8xxL
108# define CONFIG_TQM8xxL
109# endif
110#endif
111
112
113/*
wdenk452cfd62002-11-19 11:04:11 +0000114 * General Purpose Utilities
115 */
116#define min(X, Y) \
117 ({ typeof (X) __x = (X), __y = (Y); \
118 (__x < __y) ? __x : __y; })
119
120#define max(X, Y) \
121 ({ typeof (X) __x = (X), __y = (Y); \
122 (__x > __y) ? __x : __y; })
123
124
125/*
wdenke2211742002-11-02 23:30:20 +0000126 * Function Prototypes
127 */
128
129#if CONFIG_SERIAL_SOFTWARE_FIFO
130void serial_buffered_init (void);
131void serial_buffered_putc (const char);
132void serial_buffered_puts (const char *);
133int serial_buffered_getc (void);
134int serial_buffered_tstc (void);
135#endif /* CONFIG_SERIAL_SOFTWARE_FIFO */
136
137void hang (void) __attribute__ ((noreturn));
138
139/* */
140long int initdram (int);
141int display_options (void);
142void print_size (ulong, const char *);
143
144/* common/main.c */
145void main_loop (void);
146int run_command (const char *cmd, int flag);
147int readline (const char *const prompt);
wdenkb00ec162003-06-19 23:40:20 +0000148void init_cmd_timeout(void);
wdenke2211742002-11-02 23:30:20 +0000149void reset_cmd_timeout(void);
150
151/* common/board.c */
152void board_init_f (ulong);
153void board_init_r (gd_t *, ulong);
154int checkboard (void);
155int checkflash (void);
156int checkdram (void);
157char * strmhz(char *buf, long hz);
158int last_stage_init(void);
wdenkb9a83a92003-05-30 12:48:29 +0000159extern ulong monitor_flash_len;
wdenke2211742002-11-02 23:30:20 +0000160
161/* common/flash.c */
162void flash_perror (int);
163
wdenkf12e3962003-06-29 21:03:46 +0000164/* common/cmd_autoscript.c */
165int autoscript (ulong addr);
166
wdenke2211742002-11-02 23:30:20 +0000167/* common/cmd_bootm.c */
wdenkf12e3962003-06-29 21:03:46 +0000168void print_image_hdr (image_header_t *hdr);
wdenke2211742002-11-02 23:30:20 +0000169
170extern ulong load_addr; /* Default Load Address */
171
172/* common/cmd_nvedit.c */
173int env_init (void);
174void env_relocate (void);
175char *getenv (uchar *);
176int getenv_r (uchar *name, uchar *buf, unsigned len);
177int saveenv (void);
178#ifdef CONFIG_PPC /* ARM version to be fixed! */
179void inline setenv (char *, char *);
wdenk591dda52002-11-18 00:14:45 +0000180#else
181void setenv (char *, char *);
wdenke2211742002-11-02 23:30:20 +0000182#endif /* CONFIG_PPC */
183#ifdef CONFIG_ARM
184# include <asm/u-boot-arm.h> /* ARM version to be fixed! */
185#endif /* CONFIG_ARM */
wdenk591dda52002-11-18 00:14:45 +0000186#ifdef CONFIG_I386 /* x86 version to be fixed! */
wdenk57b2d802003-06-27 21:31:46 +0000187# include <asm/u-boot-i386.h>
wdenk591dda52002-11-18 00:14:45 +0000188#endif /* CONFIG_I386 */
wdenke2211742002-11-02 23:30:20 +0000189
190void pci_init (void);
stroesef5dd4102003-02-14 11:21:23 +0000191void pci_init_board(void);
wdenke2211742002-11-02 23:30:20 +0000192void pciinfo (int, int);
193
194#if defined(CONFIG_PCI) && defined(CONFIG_440)
195# if defined(CFG_PCI_PRE_INIT)
196 int pci_pre_init (struct pci_controller * );
197# endif
198# if defined(CFG_PCI_TARGET_INIT)
199 void pci_target_init (struct pci_controller *);
200# endif
201# if defined(CFG_PCI_MASTER_INIT)
202 void pci_master_init (struct pci_controller *);
203# endif
204 int is_pci_host (struct pci_controller *);
205#endif
206
207int misc_init_f (void);
208int misc_init_r (void);
209
wdenk874ac262003-07-24 23:38:38 +0000210/* common/exports.c */
211void jumptable_init(void);
212
wdenke2211742002-11-02 23:30:20 +0000213/* $(BOARD)/$(BOARD).c */
214void reset_phy (void);
wdenk1272e232002-11-10 22:06:23 +0000215void fdc_hw_init (void);
wdenke2211742002-11-02 23:30:20 +0000216
217/* $(BOARD)/eeprom.c */
218void eeprom_init (void);
wdenkb00ec162003-06-19 23:40:20 +0000219#ifndef CONFIG_SPI
220int eeprom_probe (unsigned dev_addr, unsigned offset);
221#endif
wdenke2211742002-11-02 23:30:20 +0000222int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
223int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
224#ifdef CONFIG_LWMON
225extern uchar pic_read (uchar reg);
226extern void pic_write (uchar reg, uchar val);
227#endif
228
229/*
230 * Set this up regardless of board
231 * type, to prevent errors.
232 */
233#if defined(CONFIG_SPI) || !defined(CFG_I2C_EEPROM_ADDR)
234# define CFG_DEF_EEPROM_ADDR 0
235#else
236# define CFG_DEF_EEPROM_ADDR CFG_I2C_EEPROM_ADDR
237#endif /* CONFIG_SPI || !defined(CFG_I2C_EEPROM_ADDR) */
238
wdenk541a76d2003-05-03 15:50:43 +0000239#if defined(CONFIG_PCU_E) || defined(CONFIG_CCM) || defined(CONFIG_ATC)
wdenke2211742002-11-02 23:30:20 +0000240extern void spi_init_f (void);
241extern void spi_init_r (void);
242extern ssize_t spi_read (uchar *, int, uchar *, int);
243extern ssize_t spi_write (uchar *, int, uchar *, int);
244#endif
245
246#ifdef CONFIG_RPXCLASSIC
247void rpxclassic_init (void);
248#endif
249
250#ifdef CONFIG_MBX
251/* $(BOARD)/mbx8xx.c */
252void mbx_init (void);
253void board_serial_init (void);
254void board_ether_init (void);
255#endif
256
257#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_MBX) || defined(CONFIG_IAD210)
258void board_get_enetaddr (uchar *addr);
259#endif
260
261#ifdef CONFIG_HERMES
262/* $(BOARD)/hermes.c */
263void hermes_start_lxt980 (int speed);
264#endif
265
266#ifdef CONFIG_EVB64260
267void evb64260_init(void);
268void debug_led(int, int);
269void display_mem_map(void);
270void perform_soft_reset(void);
271#endif
272
273void load_sernum_ethaddr (void);
274
275/* $(BOARD)/$(BOARD).c */
276int board_pre_init (void);
wdenk7a428cc2003-06-15 22:40:42 +0000277int board_post_init (void);
wdenke2211742002-11-02 23:30:20 +0000278int board_postclk_init (void); /* after clocks/timebase, before env/serial */
279void board_poweroff (void);
280
281#if defined(CFG_DRAM_TEST)
282int testdram(void);
283#endif /* CFG_DRAM_TEST */
284
285/* $(CPU)/start.S */
wdenk359733b2003-03-31 17:27:09 +0000286#if defined(CONFIG_5xx) || \
287 defined(CONFIG_8xx)
wdenke2211742002-11-02 23:30:20 +0000288uint get_immr (uint);
289#endif
290uint get_pvr (void);
291uint rd_ic_cst (void);
292void wr_ic_cst (uint);
293void wr_ic_adr (uint);
294uint rd_dc_cst (void);
295void wr_dc_cst (uint);
296void wr_dc_adr (uint);
297int icache_status (void);
298void icache_enable (void);
299void icache_disable(void);
300int dcache_status (void);
301void dcache_enable (void);
302void dcache_disable(void);
303void relocate_code (ulong, gd_t *, ulong);
304ulong get_endaddr (void);
305void trap_init (ulong);
306#if defined (CONFIG_4xx) || \
307 defined (CONFIG_74xx_7xx) || \
308 defined (CONFIG_74x) || \
309 defined (CONFIG_75x) || \
310 defined (CONFIG_74xx)
311unsigned char in8(unsigned int);
312void out8(unsigned int, unsigned char);
313unsigned short in16(unsigned int);
314unsigned short in16r(unsigned int);
315void out16(unsigned int, unsigned short value);
316void out16r(unsigned int, unsigned short value);
317unsigned long in32(unsigned int);
318unsigned long in32r(unsigned int);
319void out32(unsigned int, unsigned long value);
320void out32r(unsigned int, unsigned long value);
321void ppcDcbf(unsigned long value);
322void ppcDcbi(unsigned long value);
323void ppcSync(void);
324#endif
325
326/* $(CPU)/cpu.c */
327int checkcpu (void);
328int checkicache (void);
329int checkdcache (void);
330void upmconfig (unsigned int, unsigned int *, unsigned int);
331ulong get_tbclk (void);
332
333/* $(CPU)/serial.c */
334int serial_init (void);
335void serial_setbrg (void);
336void serial_putc (const char);
337void serial_puts (const char *);
338void serial_addr (unsigned int);
339int serial_getc (void);
340int serial_tstc (void);
341
342/* $(CPU)/speed.c */
343int get_clocks (void);
344#if defined(CONFIG_8260)
345int prt_8260_clks (void);
346#endif
wdenk21136db2003-07-16 21:53:01 +0000347#if defined(CONFIG_MPC5XXX)
348int prt_mpc5xxx_clks (void);
349#endif
wdenke2211742002-11-02 23:30:20 +0000350#ifdef CONFIG_4xx
351ulong get_OPB_freq (void);
352ulong get_PCI_freq (void);
353#endif
354#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
355ulong get_FCLK (void);
356ulong get_HCLK (void);
357ulong get_PCLK (void);
358ulong get_UCLK (void);
359#endif
360ulong get_bus_freq (ulong);
361
362#if defined(CONFIG_4xx) || defined(CONFIG_IOP480)
363# if defined(CONFIG_440)
364 typedef PPC440_SYS_INFO sys_info_t;
365# else
366 typedef PPC405_SYS_INFO sys_info_t;
367# endif
368void get_sys_info ( sys_info_t * );
369#endif
370
371/* $(CPU)/cpu_init.c */
372#if defined(CONFIG_8xx) || defined(CONFIG_8260)
373void cpu_init_f (volatile immap_t *immr);
374#endif
375#ifdef CONFIG_4xx
376void cpu_init_f (void);
377#endif
378int cpu_init_r (void);
379#if defined(CONFIG_8260)
380int prt_8260_rsr (void);
381#endif
382
383/* $(CPU)/interrupts.c */
384int interrupt_init (void);
385void timer_interrupt (struct pt_regs *);
386void external_interrupt (struct pt_regs *);
387void irq_install_handler(int, interrupt_handler_t *, void *);
388void irq_free_handler (int);
389void reset_timer (void);
390ulong get_timer (ulong base);
391void set_timer (ulong t);
392void enable_interrupts (void);
393int disable_interrupts (void);
394
395/* $(CPU)/.../commproc.c */
396int dpram_init (void);
397uint dpram_base(void);
398uint dpram_base_align(uint align);
399uint dpram_alloc(uint size);
400uint dpram_alloc_align(uint size,uint align);
401void post_word_store (ulong);
402ulong post_word_load (void);
403
404/* $(CPU)/.../<eth> */
405void mii_init (void);
406
407/* $(CPU)/.../lcd.c */
408ulong lcd_setmem (ulong);
409
410/* $(CPU)/.../vfd.c */
411ulong vfd_setmem (ulong);
412
413/* $(CPU)/.../video.c */
414ulong video_setmem (ulong);
415
416/* ppc/cache.c */
417void flush_cache (unsigned long, unsigned long);
418
wdenk359733b2003-03-31 17:27:09 +0000419
wdenke2211742002-11-02 23:30:20 +0000420/* ppc/ticks.S */
421unsigned long long get_ticks(void);
422void wait_ticks (unsigned long);
423
424/* ppc/time.c */
425void udelay (unsigned long);
426ulong usec2ticks (unsigned long usec);
427ulong ticks2usec (unsigned long ticks);
428int init_timebase (void);
429
430/* ppc/vsprintf.c */
431ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
432long simple_strtol(const char *cp,char **endp,unsigned int base);
433void panic(const char *fmt, ...);
434int sprintf(char * buf, const char *fmt, ...);
435int vsprintf(char *buf, const char *fmt, va_list args);
436
437/* ppc/crc32.c */
438ulong crc32 (ulong, const unsigned char *, uint);
439ulong crc32_no_comp (ulong, const unsigned char *, uint);
440
441/* common/console.c */
wdenke2211742002-11-02 23:30:20 +0000442int console_init_f(void); /* Before relocation; uses the serial stuff */
443int console_init_r(void); /* After relocation; uses the console stuff */
444int console_assign (int file, char *devname); /* Assign the console */
445int ctrlc (void);
446int had_ctrlc (void); /* have we had a Control-C since last clear? */
447void clear_ctrlc (void); /* clear the Control-C condition */
448int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */
449
450/*
451 * STDIO based functions (can always be used)
452 */
453
454/* serial stuff */
455void serial_printf (const char *fmt, ...);
456
457/* stdin */
458int getc(void);
459int tstc(void);
460
461/* stdout */
462void putc(const char c);
463void puts(const char *s);
464void printf(const char *fmt, ...);
wdenkb00ec162003-06-19 23:40:20 +0000465void vprintf(const char *fmt, va_list args);
wdenke2211742002-11-02 23:30:20 +0000466
467/* stderr */
468#define eputc(c) fputc(stderr, c)
469#define eputs(s) fputs(stderr, s)
470#define eprintf(fmt,args...) fprintf(stderr,fmt ,##args)
471
472/*
473 * FILE based functions (can only be used AFTER relocation!)
474 */
475
476#define stdin 0
477#define stdout 1
478#define stderr 2
479#define MAX_FILES 3
480
481void fprintf(int file, const char *fmt, ...);
482void fputs(int file, const char *s);
483void fputc(int file, const char c);
484int ftstc(int file);
485int fgetc(int file);
486
487int pcmcia_init (void);
488
489#ifdef CONFIG_SHOW_BOOT_PROGRESS
490void show_boot_progress (int status);
491#endif
492
493#endif /* __COMMON_H_ */