common.h 19.5 KB
Newer Older
wdenk's avatar
wdenk committed
1
/*
2
 * (C) Copyright 2000-2007
wdenk's avatar
wdenk committed
3 4 5 6 7 8 9 10 11 12 13 14
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
wdenk's avatar
wdenk committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#ifndef __COMMON_H_
#define __COMMON_H_	1

#undef	_LINUX_CONFIG_H
#define _LINUX_CONFIG_H 1	/* avoid reading Linux autoconf.h file	*/

typedef unsigned char		uchar;
typedef volatile unsigned long	vu_long;
32
typedef volatile unsigned short vu_short;
wdenk's avatar
wdenk committed
33 34 35 36 37 38 39 40
typedef volatile unsigned char	vu_char;

#include <config.h>
#include <linux/bitops.h>
#include <linux/types.h>
#include <linux/string.h>
#include <asm/ptrace.h>
#include <stdarg.h>
41
#if defined(CONFIG_PCI) && (defined(CONFIG_4xx) && !defined(CONFIG_AP1000))
wdenk's avatar
wdenk committed
42 43
#include <pci.h>
#endif
44
#if defined(CONFIG_8xx)
wdenk's avatar
wdenk committed
45
#include <asm/8xx_immap.h>
wdenk's avatar
wdenk committed
46 47 48 49 50
#if defined(CONFIG_MPC852)	|| defined(CONFIG_MPC852T)	|| \
    defined(CONFIG_MPC859)	|| defined(CONFIG_MPC859T)	|| \
    defined(CONFIG_MPC859DSL)	|| \
    defined(CONFIG_MPC866)	|| defined(CONFIG_MPC866T)	|| \
    defined(CONFIG_MPC866P)
wdenk's avatar
wdenk committed
51
# define CONFIG_MPC866_FAMILY 1
52 53 54 55
#elif defined(CONFIG_MPC870) \
   || defined(CONFIG_MPC875) \
   || defined(CONFIG_MPC880) \
   || defined(CONFIG_MPC885)
wdenk's avatar
wdenk committed
56
# define CONFIG_MPC885_FAMILY   1
57 58 59
#endif
#if   defined(CONFIG_MPC860)	   \
   || defined(CONFIG_MPC860T)	   \
wdenk's avatar
wdenk committed
60 61
   || defined(CONFIG_MPC866_FAMILY) \
   || defined(CONFIG_MPC885_FAMILY)
62
# define CONFIG_MPC86x 1
wdenk's avatar
wdenk committed
63
#endif
64 65
#elif defined(CONFIG_5xx)
#include <asm/5xx_immap.h>
wdenk's avatar
wdenk committed
66 67
#elif defined(CONFIG_MPC5xxx)
#include <mpc5xxx.h>
68 69 70
#elif defined(CONFIG_MPC512X)
#include <mpc512x.h>
#include <asm/immap_512x.h>
wdenk's avatar
wdenk committed
71 72
#elif defined(CONFIG_MPC8220)
#include <asm/immap_8220.h>
wdenk's avatar
wdenk committed
73
#elif defined(CONFIG_8260)
74 75 76 77 78 79 80 81 82
#if   defined(CONFIG_MPC8247) \
   || defined(CONFIG_MPC8248) \
   || defined(CONFIG_MPC8271) \
   || defined(CONFIG_MPC8272)
#define CONFIG_MPC8272_FAMILY	1
#endif
#if defined(CONFIG_MPC8272_FAMILY)
#define CONFIG_MPC8260	1
#endif
wdenk's avatar
wdenk committed
83 84
#include <asm/immap_8260.h>
#endif
85 86 87 88
#ifdef CONFIG_MPC86xx
#include <mpc86xx.h>
#include <asm/immap_86xx.h>
#endif
89 90 91 92
#ifdef CONFIG_MPC85xx
#include <mpc85xx.h>
#include <asm/immap_85xx.h>
#endif
Eran Liberty's avatar
Eran Liberty committed
93 94 95 96
#ifdef CONFIG_MPC83XX
#include <mpc83xx.h>
#include <asm/immap_83xx.h>
#endif
wdenk's avatar
wdenk committed
97 98 99 100
#ifdef	CONFIG_4xx
#include <ppc4xx.h>
#endif
#ifdef CONFIG_HYMOD
wdenk's avatar
wdenk committed
101
#include <board/hymod/hymod.h>
wdenk's avatar
wdenk committed
102 103 104 105
#endif
#ifdef CONFIG_ARM
#define asmlinkage	/* nothing */
#endif
106 107 108
#ifdef CONFIG_BLACKFIN
#include <asm/blackfin.h>
#endif
wdenk's avatar
wdenk committed
109 110 111 112 113 114 115

#include <part.h>
#include <flash.h>
#include <image.h>

#ifdef	DEBUG
#define debug(fmt,args...)	printf (fmt ,##args)
116
#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
wdenk's avatar
wdenk committed
117 118
#else
#define debug(fmt,args...)
119
#define debugX(level,fmt,args...)
wdenk's avatar
wdenk committed
120 121
#endif	/* DEBUG */

122
#ifndef BUG
123
#define BUG() do { \
Wolfgang Denk's avatar
Wolfgang Denk committed
124
	printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
125 126 127
	panic("BUG!"); \
} while (0)
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
128
#endif /* BUG */
129

130
typedef void (interrupt_handler_t)(void *);
wdenk's avatar
wdenk committed
131

132
#include <asm/u-boot.h> /* boot information for Linux kernel */
wdenk's avatar
wdenk committed
133 134
#include <asm/global_data.h>	/* global data used for startup functions */

135 136
/*
 * enable common handling for all TQM8xxL/M boards:
137
 * - CONFIG_TQM8xxM will be defined for all TQM8xxM boards
138
 * - CONFIG_TQM8xxL will be defined for all TQM8xxL _and_ TQM8xxM boards
139
 *                  and for the TQM885D board
140 141 142
 */
#if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \
    defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \
143
    defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M)
144 145 146 147
# ifndef CONFIG_TQM8xxM
#  define CONFIG_TQM8xxM
# endif
#endif
wdenk's avatar
wdenk committed
148
#if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
wdenk's avatar
wdenk committed
149
    defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \
150 151
    defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM) || \
    defined(CONFIG_TQM885D)
wdenk's avatar
wdenk committed
152 153 154 155 156
# ifndef CONFIG_TQM8xxL
#  define CONFIG_TQM8xxL
# endif
#endif

wdenk's avatar
wdenk committed
157 158 159 160 161 162 163 164 165 166 167
#ifndef CONFIG_SERIAL_MULTI

#if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2) \
 || defined(CONFIG_8xx_CONS_SCC1) || defined(CONFIG_8xx_CONS_SCC2) \
 || defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)

#define CONFIG_SERIAL_MULTI	1

#endif

#endif /* CONFIG_SERIAL_MULTI */
wdenk's avatar
wdenk committed
168

169 170 171 172 173 174 175 176 177 178 179
/*
 * General Purpose Utilities
 */
#define min(X, Y)				\
	({ typeof (X) __x = (X), __y = (Y);	\
		(__x < __y) ? __x : __y; })

#define max(X, Y)				\
	({ typeof (X) __x = (X), __y = (Y);	\
		(__x > __y) ? __x : __y; })

Andy Fleming's avatar
Andy Fleming committed
180 181 182
#define MIN(x, y)  min(x, y)
#define MAX(x, y)  max(x, y)

183

184 185 186 187 188 189 190 191 192 193 194
/**
 * container_of - cast a member of a structure out to the containing structure
 * @ptr:	the pointer to the member.
 * @type:	the type of the container struct this is embedded in.
 * @member:	the name of the member within the struct.
 *
 */
#define container_of(ptr, type, member) ({			\
	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
	(type *)( (char *)__mptr - offsetof(type,member) );})

wdenk's avatar
wdenk committed
195 196 197 198
/*
 * Function Prototypes
 */

199
#ifdef CONFIG_SERIAL_SOFTWARE_FIFO
wdenk's avatar
wdenk committed
200 201 202 203 204 205 206
void	serial_buffered_init (void);
void	serial_buffered_putc (const char);
void	serial_buffered_puts (const char *);
int	serial_buffered_getc (void);
int	serial_buffered_tstc (void);
#endif /* CONFIG_SERIAL_SOFTWARE_FIFO */

207
void	hang		(void) __attribute__ ((noreturn));
wdenk's avatar
wdenk committed
208 209

/* */
210
phys_size_t initdram (int);
211
int	display_options (void);
212
void	print_size (phys_size_t, const char *);
Wolfgang Denk's avatar
Wolfgang Denk committed
213
int	print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);
wdenk's avatar
wdenk committed
214 215 216 217 218

/* common/main.c */
void	main_loop	(void);
int	run_command	(const char *cmd, int flag);
int	readline	(const char *const prompt);
James Yang's avatar
James Yang committed
219 220
int	readline_into_buffer	(const char *const prompt, char * buffer);
int	parse_line (char *, char *[]);
wdenk's avatar
wdenk committed
221
void	init_cmd_timeout(void);
wdenk's avatar
wdenk committed
222 223
void	reset_cmd_timeout(void);

224
/* lib_$(ARCH)/board.c */
225 226
void	board_init_f  (ulong) __attribute__ ((noreturn));
void	board_init_r  (gd_t *, ulong) __attribute__ ((noreturn));
wdenk's avatar
wdenk committed
227 228 229 230
int	checkboard    (void);
int	checkflash    (void);
int	checkdram     (void);
int	last_stage_init(void);
231
extern ulong monitor_flash_len;
232
int mac_read_from_eeprom(void);
wdenk's avatar
wdenk committed
233 234 235 236

/* common/flash.c */
void flash_perror (int);

237
/* common/cmd_autoscript.c */
238
int	autoscript (ulong addr, const char *fit_uname);
wdenk's avatar
wdenk committed
239

240
extern ulong load_addr;		/* Default Load Address */
wdenk's avatar
wdenk committed
241

242 243 244
/* common/cmd_doc.c */
void	doc_probe(unsigned long physadr);

wdenk's avatar
wdenk committed
245 246 247
/* common/cmd_nvedit.c */
int	env_init     (void);
void	env_relocate (void);
Rafal Jaworowski's avatar
Rafal Jaworowski committed
248
int	envmatch     (uchar *, int);
Wolfgang Denk's avatar
Wolfgang Denk committed
249 250
char	*getenv	     (char *);
int	getenv_r     (char *name, char *buf, unsigned len);
251
int	saveenv	     (void);
wdenk's avatar
wdenk committed
252
#ifdef CONFIG_PPC		/* ARM version to be fixed! */
Steven A. Falco's avatar
Steven A. Falco committed
253
int inline setenv   (char *, char *);
254
#else
Steven A. Falco's avatar
Steven A. Falco committed
255
int	setenv	     (char *, char *);
256 257 258
#ifdef CONFIG_HAS_UID
void	forceenv     (char *, char *);
#endif
wdenk's avatar
wdenk committed
259 260
#endif /* CONFIG_PPC */
#ifdef CONFIG_ARM
261
# include <asm/mach-types.h>
wdenk's avatar
wdenk committed
262
# include <asm/setup.h>
wdenk's avatar
wdenk committed
263 264
# include <asm/u-boot-arm.h>	/* ARM version to be fixed! */
#endif /* CONFIG_ARM */
265
#ifdef CONFIG_I386		/* x86 version to be fixed! */
wdenk's avatar
wdenk committed
266
# include <asm/u-boot-i386.h>
267
#endif /* CONFIG_I386 */
wdenk's avatar
wdenk committed
268

269 270 271 272
#ifdef CONFIG_AUTO_COMPLETE
int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
#endif

273 274 275
void	pci_init      (void);
void	pci_init_board(void);
void	pciinfo	      (int, int);
wdenk's avatar
wdenk committed
276

277
#if defined(CONFIG_PCI) && (defined(CONFIG_4xx) && !defined(CONFIG_AP1000))
278
    int	   pci_pre_init	       (struct pci_controller * );
279 280
#endif

Stefan Roese's avatar
Stefan Roese committed
281
#if defined(CONFIG_PCI) && (defined(CONFIG_440) || defined(CONFIG_405EX))
282
#   if defined(CONFIG_SYS_PCI_TARGET_INIT)
283
	void	pci_target_init	     (struct pci_controller *);
wdenk's avatar
wdenk committed
284
#   endif
285
#   if defined(CONFIG_SYS_PCI_MASTER_INIT)
286
	void	pci_master_init	     (struct pci_controller *);
wdenk's avatar
wdenk committed
287
#   endif
288
    int	    is_pci_host		(struct pci_controller *);
289 290 291
#if defined(CONFIG_440SPE) || \
    defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
    defined(CONFIG_405EX)
292
   void pcie_setup_hoses(int busno);
293
#endif
wdenk's avatar
wdenk committed
294 295 296 297 298
#endif

int	misc_init_f   (void);
int	misc_init_r   (void);

299 300 301
/* common/exports.c */
void	jumptable_init(void);

302 303 304
/* api/api.c */
void	api_init (void);

305
/* common/memsize.c */
306
long	get_ram_size  (volatile long *, long);
307

wdenk's avatar
wdenk committed
308 309
/* $(BOARD)/$(BOARD).c */
void	reset_phy     (void);
310
void	fdc_hw_init   (void);
wdenk's avatar
wdenk committed
311 312 313

/* $(BOARD)/eeprom.c */
void eeprom_init  (void);
wdenk's avatar
wdenk committed
314 315 316
#ifndef CONFIG_SPI
int  eeprom_probe (unsigned dev_addr, unsigned offset);
#endif
wdenk's avatar
wdenk committed
317 318 319 320 321 322 323 324 325 326 327
int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
#ifdef CONFIG_LWMON
extern uchar pic_read  (uchar reg);
extern void  pic_write (uchar reg, uchar val);
#endif

/*
 * Set this up regardless of board
 * type, to prevent errors.
 */
328 329
#if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
# define CONFIG_SYS_DEF_EEPROM_ADDR 0
wdenk's avatar
wdenk committed
330
#else
331 332
# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
#endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */
wdenk's avatar
wdenk committed
333

334
#if defined(CONFIG_SPI)
wdenk's avatar
wdenk committed
335 336
extern void spi_init_f (void);
extern void spi_init_r (void);
337
extern ssize_t spi_read	 (uchar *, int, uchar *, int);
wdenk's avatar
wdenk committed
338 339 340 341 342 343 344
extern ssize_t spi_write (uchar *, int, uchar *, int);
#endif

#ifdef CONFIG_RPXCLASSIC
void rpxclassic_init (void);
#endif

wdenk's avatar
wdenk committed
345 346
void rpxlite_init (void);

wdenk's avatar
wdenk committed
347 348 349 350 351 352 353
#ifdef CONFIG_MBX
/* $(BOARD)/mbx8xx.c */
void	mbx_init (void);
void	board_serial_init (void);
void	board_ether_init (void);
#endif

wdenk's avatar
wdenk committed
354
#if defined(CONFIG_RPXCLASSIC)	|| defined(CONFIG_MBX) || \
355
    defined(CONFIG_IAD210)	|| defined(CONFIG_XPEDITE1K) || \
356 357
    defined(CONFIG_METROBOX)    || defined(CONFIG_KAREF) || \
    defined(CONFIG_V38B)
wdenk's avatar
wdenk committed
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
void	board_get_enetaddr (uchar *addr);
#endif

#ifdef CONFIG_HERMES
/* $(BOARD)/hermes.c */
void hermes_start_lxt980 (int speed);
#endif

#ifdef CONFIG_EVB64260
void  evb64260_init(void);
void  debug_led(int, int);
void  display_mem_map(void);
void  perform_soft_reset(void);
#endif

void	load_sernum_ethaddr (void);

/* $(BOARD)/$(BOARD).c */
376 377
int board_early_init_f (void);
int board_late_init (void);
wdenk's avatar
wdenk committed
378
int board_postclk_init (void); /* after clocks/timebase, before env/serial */
379
int board_early_init_r (void);
wdenk's avatar
wdenk committed
380 381
void board_poweroff (void);

382
#if defined(CONFIG_SYS_DRAM_TEST)
wdenk's avatar
wdenk committed
383
int testdram(void);
384
#endif /* CONFIG_SYS_DRAM_TEST */
wdenk's avatar
wdenk committed
385 386

/* $(CPU)/start.S */
387
#if defined(CONFIG_5xx) || \
388
    defined(CONFIG_8xx)
wdenk's avatar
wdenk committed
389 390
uint	get_immr      (uint);
#endif
391
uint	get_pir	      (void);
wdenk's avatar
wdenk committed
392 393 394
#if defined(CONFIG_MPC5xxx)
uint	get_svr       (void);
#endif
wdenk's avatar
wdenk committed
395
uint	get_pvr	      (void);
wdenk's avatar
wdenk committed
396
uint	get_svr	      (void);
wdenk's avatar
wdenk committed
397 398 399 400 401 402 403 404 405 406 407 408
uint	rd_ic_cst     (void);
void	wr_ic_cst     (uint);
void	wr_ic_adr     (uint);
uint	rd_dc_cst     (void);
void	wr_dc_cst     (uint);
void	wr_dc_adr     (uint);
int	icache_status (void);
void	icache_enable (void);
void	icache_disable(void);
int	dcache_status (void);
void	dcache_enable (void);
void	dcache_disable(void);
409
void	relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
wdenk's avatar
wdenk committed
410 411 412
ulong	get_endaddr   (void);
void	trap_init     (ulong);
#if defined (CONFIG_4xx)	|| \
wdenk's avatar
wdenk committed
413
    defined (CONFIG_MPC5xxx)	|| \
wdenk's avatar
wdenk committed
414 415 416
    defined (CONFIG_74xx_7xx)	|| \
    defined (CONFIG_74x)	|| \
    defined (CONFIG_75x)	|| \
wdenk's avatar
wdenk committed
417
    defined (CONFIG_74xx)	|| \
wdenk's avatar
wdenk committed
418
    defined (CONFIG_MPC8220)	|| \
419
    defined (CONFIG_MPC85xx)	|| \
420
    defined (CONFIG_MPC86xx)	|| \
421
    defined (CONFIG_MPC83XX)
422 423 424 425 426 427 428 429 430 431 432 433 434
unsigned char	in8(unsigned int);
void		out8(unsigned int, unsigned char);
unsigned short	in16(unsigned int);
unsigned short	in16r(unsigned int);
void		out16(unsigned int, unsigned short value);
void		out16r(unsigned int, unsigned short value);
unsigned long	in32(unsigned int);
unsigned long	in32r(unsigned int);
void		out32(unsigned int, unsigned long value);
void		out32r(unsigned int, unsigned long value);
void		ppcDcbf(unsigned long value);
void		ppcDcbi(unsigned long value);
void		ppcSync(void);
wdenk's avatar
wdenk committed
435
void		ppcDcbz(unsigned long value);
wdenk's avatar
wdenk committed
436
#endif
Michal Simek's avatar
Michal Simek committed
437 438 439 440
#if defined (CONFIG_MICROBLAZE)
unsigned short	in16(unsigned int);
void		out16(unsigned int, unsigned short value);
#endif
wdenk's avatar
wdenk committed
441

442 443 444 445 446
#if defined (CONFIG_MPC83XX)
void		ppcDWload(unsigned int *addr, unsigned int *ret);
void		ppcDWstore(unsigned int *addr, unsigned int *value);
#endif

wdenk's avatar
wdenk committed
447 448 449 450 451 452
/* $(CPU)/cpu.c */
int	checkcpu      (void);
int	checkicache   (void);
int	checkdcache   (void);
void	upmconfig     (unsigned int, unsigned int *, unsigned int);
ulong	get_tbclk     (void);
wdenk's avatar
wdenk committed
453
void	reset_cpu     (ulong addr);
454 455 456 457 458 459 460
#if defined (CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
void ft_cpu_setup(void *blob, bd_t *bd);
#ifdef CONFIG_PCI
void ft_pci_setup(void *blob, bd_t *bd);
#endif
#endif

wdenk's avatar
wdenk committed
461 462 463

/* $(CPU)/serial.c */
int	serial_init   (void);
wdenk's avatar
wdenk committed
464
void	serial_addr   (unsigned int);
wdenk's avatar
wdenk committed
465 466
void	serial_setbrg (void);
void	serial_putc   (const char);
wdenk's avatar
wdenk committed
467
void	serial_putc_raw(const char);
wdenk's avatar
wdenk committed
468 469 470 471
void	serial_puts   (const char *);
int	serial_getc   (void);
int	serial_tstc   (void);

wdenk's avatar
wdenk committed
472 473 474 475 476 477 478
void	_serial_setbrg (const int);
void	_serial_putc   (const char, const int);
void	_serial_putc_raw(const char, const int);
void	_serial_puts   (const char *, const int);
int	_serial_getc   (const int);
int	_serial_tstc   (const int);

wdenk's avatar
wdenk committed
479 480
/* $(CPU)/speed.c */
int	get_clocks (void);
481 482
int	get_clocks_866 (void);
int	sdram_adjust_866 (void);
483
int	adjust_sdram_tbs_8xx (void);
wdenk's avatar
wdenk committed
484 485
#if defined(CONFIG_8260)
int	prt_8260_clks (void);
Eran Liberty's avatar
Eran Liberty committed
486
#elif defined(CONFIG_MPC5xxx)
487 488
int	prt_mpc5xxx_clks (void);
#endif
489
#if defined(CONFIG_MPC512X)
490 491
int	prt_mpc512xxx_clks (void);
#endif
wdenk's avatar
wdenk committed
492 493 494
#if defined(CONFIG_MPC8220)
int	prt_mpc8220_clks (void);
#endif
wdenk's avatar
wdenk committed
495 496 497 498
#ifdef CONFIG_4xx
ulong	get_OPB_freq (void);
ulong	get_PCI_freq (void);
#endif
499 500
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || \
	defined(CONFIG_LH7A40X) || defined(CONFIG_S3C6400)
501 502
void	s3c2410_irq(void);
#define ARM920_IRQ_CALLBACK s3c2410_irq
wdenk's avatar
wdenk committed
503 504 505 506 507
ulong	get_FCLK (void);
ulong	get_HCLK (void);
ulong	get_PCLK (void);
ulong	get_UCLK (void);
#endif
wdenk's avatar
wdenk committed
508 509 510
#if defined(CONFIG_LH7A40X)
ulong	get_PLLCLK (void);
#endif
511
#if defined CONFIG_INCA_IP
512
uint	incaip_get_cpuclk (void);
513
#endif
wdenk's avatar
wdenk committed
514 515 516 517 518 519 520 521 522
#if defined(CONFIG_IMX)
ulong get_systemPLLCLK(void);
ulong get_FCLK(void);
ulong get_HCLK(void);
ulong get_BCLK(void);
ulong get_PERCLK1(void);
ulong get_PERCLK2(void);
ulong get_PERCLK3(void);
#endif
wdenk's avatar
wdenk committed
523 524
ulong	get_bus_freq  (ulong);

525 526
#if defined(CONFIG_MPC85xx)
typedef MPC85xx_SYS_INFO sys_info_t;
527
void	get_sys_info  ( sys_info_t * );
528
ulong	get_ddr_freq  (ulong);
529
#endif
530 531 532 533
#if defined(CONFIG_MPC86xx)
typedef MPC86xx_SYS_INFO sys_info_t;
void   get_sys_info  ( sys_info_t * );
#endif
534

wdenk's avatar
wdenk committed
535 536
#if defined(CONFIG_4xx) || defined(CONFIG_IOP480)
#  if defined(CONFIG_440)
537 538 539 540
#	if defined(CONFIG_440SPE)
	 unsigned long determine_sysper(void);
	 unsigned long determine_pci_clock_per(void);
#	endif
wdenk's avatar
wdenk committed
541
#  endif
542
typedef PPC4xx_SYS_INFO sys_info_t;
543
int	ppc440spe_revB(void);
544
void	get_sys_info  ( sys_info_t * );
wdenk's avatar
wdenk committed
545 546 547 548 549 550
#endif

/* $(CPU)/cpu_init.c */
#if defined(CONFIG_8xx) || defined(CONFIG_8260)
void	cpu_init_f    (volatile immap_t *immr);
#endif
551
#if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) || defined(CONFIG_MCF52x2) ||defined(CONFIG_MPC86xx)
wdenk's avatar
wdenk committed
552 553
void	cpu_init_f    (void);
#endif
wdenk's avatar
wdenk committed
554

wdenk's avatar
wdenk committed
555 556 557
int	cpu_init_r    (void);
#if defined(CONFIG_8260)
int	prt_8260_rsr  (void);
558 559
#elif defined(CONFIG_MPC83XX)
int	prt_83xx_rsr  (void);
wdenk's avatar
wdenk committed
560 561 562
#endif

/* $(CPU)/interrupts.c */
563 564
int	interrupt_init	   (void);
void	timer_interrupt	   (struct pt_regs *);
wdenk's avatar
wdenk committed
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
void	external_interrupt (struct pt_regs *);
void	irq_install_handler(int, interrupt_handler_t *, void *);
void	irq_free_handler   (int);
void	reset_timer	   (void);
ulong	get_timer	   (ulong base);
void	set_timer	   (ulong t);
void	enable_interrupts  (void);
int	disable_interrupts (void);

/* $(CPU)/.../commproc.c */
int	dpram_init (void);
uint	dpram_base(void);
uint	dpram_base_align(uint align);
uint	dpram_alloc(uint size);
uint	dpram_alloc_align(uint size,uint align);
void	post_word_store (ulong);
ulong	post_word_load (void);
582 583 584
void	bootcount_store (ulong);
ulong	bootcount_load (void);
#define BOOTCOUNT_MAGIC		0xB001C041
wdenk's avatar
wdenk committed
585 586

/* $(CPU)/.../<eth> */
Wolfgang Denk's avatar
Wolfgang Denk committed
587
void mii_init (void);
wdenk's avatar
wdenk committed
588 589 590 591 592 593 594 595 596 597

/* $(CPU)/.../lcd.c */
ulong	lcd_setmem (ulong);

/* $(CPU)/.../vfd.c */
ulong	vfd_setmem (ulong);

/* $(CPU)/.../video.c */
ulong	video_setmem (ulong);

wdenk's avatar
wdenk committed
598
/* lib_$(ARCH)/cache.c */
wdenk's avatar
wdenk committed
599 600
void	flush_cache   (unsigned long, unsigned long);

601

602
/* lib_$(ARCH)/ticks.S */
wdenk's avatar
wdenk committed
603 604 605
unsigned long long get_ticks(void);
void	wait_ticks    (unsigned long);

606
/* lib_$(ARCH)/time.c */
wdenk's avatar
wdenk committed
607 608 609 610 611
void	udelay	      (unsigned long);
ulong	usec2ticks    (unsigned long usec);
ulong	ticks2usec    (unsigned long ticks);
int	init_timebase (void);

612
/* lib_generic/vsprintf.c */
wdenk's avatar
wdenk committed
613
ulong	simple_strtoul(const char *cp,char **endp,unsigned int base);
614
#ifdef CONFIG_SYS_64BIT_VSPRINTF
615 616
unsigned long long	simple_strtoull(const char *cp,char **endp,unsigned int base);
#endif
wdenk's avatar
wdenk committed
617
long	simple_strtol(const char *cp,char **endp,unsigned int base);
Andrew Klossner's avatar
Andrew Klossner committed
618 619 620 621
void	panic(const char *fmt, ...)
		__attribute__ ((format (__printf__, 1, 2)));
int	sprintf(char * buf, const char *fmt, ...)
		__attribute__ ((format (__printf__, 2, 3)));
622
int	vsprintf(char *buf, const char *fmt, va_list args);
wdenk's avatar
wdenk committed
623

624 625 626
/* lib_generic/strmhz.c */
char *	strmhz(char *buf, long hz);

627
/* lib_generic/crc32.c */
628
uint32_t crc32 (uint32_t, const unsigned char *, uint);
629
uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint);
630
uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);
wdenk's avatar
wdenk committed
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645

/* common/console.c */
int	console_init_f(void);	/* Before relocation; uses the serial  stuff	*/
int	console_init_r(void);	/* After  relocation; uses the console stuff	*/
int	console_assign (int file, char *devname);	/* Assign the console	*/
int	ctrlc (void);
int	had_ctrlc (void);	/* have we had a Control-C since last clear? */
void	clear_ctrlc (void);	/* clear the Control-C condition */
int	disable_ctrlc (int);	/* 1 to disable, 0 to enable Control-C detect */

/*
 * STDIO based functions (can always be used)
 */

/* serial stuff */
Andrew Klossner's avatar
Andrew Klossner committed
646 647
void	serial_printf (const char *fmt, ...)
		__attribute__ ((format (__printf__, 1, 2)));
wdenk's avatar
wdenk committed
648 649 650 651 652 653 654 655

/* stdin */
int	getc(void);
int	tstc(void);

/* stdout */
void	putc(const char c);
void	puts(const char *s);
Andrew Klossner's avatar
Andrew Klossner committed
656 657
void	printf(const char *fmt, ...)
		__attribute__ ((format (__printf__, 1, 2)));
wdenk's avatar
wdenk committed
658
void	vprintf(const char *fmt, va_list args);
wdenk's avatar
wdenk committed
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673

/* stderr */
#define eputc(c)		fputc(stderr, c)
#define eputs(s)		fputs(stderr, s)
#define eprintf(fmt,args...)	fprintf(stderr,fmt ,##args)

/*
 * FILE based functions (can only be used AFTER relocation!)
 */

#define stdin		0
#define stdout		1
#define stderr		2
#define MAX_FILES	3

Andrew Klossner's avatar
Andrew Klossner committed
674 675
void	fprintf(int file, const char *fmt, ...)
		__attribute__ ((format (__printf__, 2, 3)));
wdenk's avatar
wdenk committed
676 677 678 679 680
void	fputs(int file, const char *s);
void	fputc(int file, const char c);
int	ftstc(int file);
int	fgetc(int file);

681 682 683 684 685 686 687
/*
 * CONSOLE multiplexing.
 */
#ifdef CONFIG_CONSOLE_MUX
#include <iomux.h>
#endif

wdenk's avatar
wdenk committed
688 689
int	pcmcia_init (void);

690 691
#ifdef CONFIG_STATUS_LED
# include <status_led.h>
wdenk's avatar
wdenk committed
692
#endif
693 694 695
/*
 * Board-specific Platform code can reimplement show_boot_progress () if needed
 */
696
void __attribute__((weak)) show_boot_progress (int val);
wdenk's avatar
wdenk committed
697

wdenk's avatar
wdenk committed
698
#ifdef CONFIG_INIT_CRITICAL
Wolfgang Denk's avatar
Wolfgang Denk committed
699
#error CONFIG_INIT_CRITICAL is deprecated!
wdenk's avatar
wdenk committed
700 701 702
#error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
#endif

703 704
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

705 706 707
#define DIV_ROUND(n,d)		(((n) + ((d)/2)) / (d))
#define DIV_ROUND_UP(n,d)	(((n) + (d) - 1) / (d))
#define roundup(x, y)		((((x) + ((y) - 1)) / (y)) * (y))
708

Andy Fleming's avatar
Andy Fleming committed
709 710 711
#define ALIGN(x,a)		__ALIGN_MASK((x),(typeof(x))(a)-1)
#define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))

712 713 714 715
/* Multicore arch functions */
#ifdef CONFIG_MP
int cpu_status(int nr);
int cpu_reset(int nr);
716
int cpu_release(int nr, int argc, char *argv[]);
717 718
#endif

719 720 721 722
#ifdef CONFIG_POST
#define CONFIG_HAS_POST
#endif

wdenk's avatar
wdenk committed
723
#endif	/* __COMMON_H_ */