common.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. /*
  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. #ifndef __COMMON_H_
  24. #define __COMMON_H_ 1
  25. #undef _LINUX_CONFIG_H
  26. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  27. typedef unsigned char uchar;
  28. typedef volatile unsigned long vu_long;
  29. typedef volatile unsigned short vu_short;
  30. typedef volatile unsigned char vu_char;
  31. #include <config.h>
  32. #include <linux/bitops.h>
  33. #include <linux/types.h>
  34. #include <linux/string.h>
  35. #include <asm/ptrace.h>
  36. #include <stdarg.h>
  37. #if defined(CONFIG_PCI) && defined(CONFIG_440)
  38. #include <pci.h>
  39. #endif
  40. #ifdef CONFIG_8xx
  41. #include <asm/8xx_immap.h>
  42. #elif defined(CONFIG_8260)
  43. #include <asm/immap_8260.h>
  44. #endif
  45. #ifdef CONFIG_4xx
  46. #include <ppc4xx.h>
  47. #endif
  48. #ifdef CONFIG_HYMOD
  49. #include <asm/hymod.h>
  50. #endif
  51. #ifdef CONFIG_ARM
  52. #define asmlinkage /* nothing */
  53. #endif
  54. #include <part.h>
  55. #include <flash.h>
  56. #include <image.h>
  57. #ifdef DEBUG
  58. #define debug(fmt,args...) printf (fmt ,##args)
  59. #else
  60. #define debug(fmt,args...)
  61. #endif /* DEBUG */
  62. typedef void (interrupt_handler_t)(void *);
  63. #include <asm/u-boot.h> /* boot information for Linux kernel */
  64. #include <asm/global_data.h> /* global data used for startup functions */
  65. /* enable common handling for all TQM8xxL boards */
  66. #if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
  67. defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L)
  68. # ifndef CONFIG_TQM8xxL
  69. # define CONFIG_TQM8xxL
  70. # endif
  71. #endif
  72. /*
  73. * General Purpose Utilities
  74. */
  75. #define min(X, Y) \
  76. ({ typeof (X) __x = (X), __y = (Y); \
  77. (__x < __y) ? __x : __y; })
  78. #define max(X, Y) \
  79. ({ typeof (X) __x = (X), __y = (Y); \
  80. (__x > __y) ? __x : __y; })
  81. /*
  82. * Function Prototypes
  83. */
  84. #if CONFIG_SERIAL_SOFTWARE_FIFO
  85. void serial_buffered_init (void);
  86. void serial_buffered_putc (const char);
  87. void serial_buffered_puts (const char *);
  88. int serial_buffered_getc (void);
  89. int serial_buffered_tstc (void);
  90. #endif /* CONFIG_SERIAL_SOFTWARE_FIFO */
  91. void hang (void) __attribute__ ((noreturn));
  92. /* */
  93. long int initdram (int);
  94. int display_options (void);
  95. void print_size (ulong, const char *);
  96. /* common/main.c */
  97. void main_loop (void);
  98. int run_command (const char *cmd, int flag);
  99. int readline (const char *const prompt);
  100. void reset_cmd_timeout(void);
  101. /* common/board.c */
  102. void board_init_f (ulong);
  103. void board_init_r (gd_t *, ulong);
  104. int checkboard (void);
  105. int checkflash (void);
  106. int checkdram (void);
  107. char * strmhz(char *buf, long hz);
  108. int last_stage_init(void);
  109. /* common/flash.c */
  110. void flash_perror (int);
  111. /* common/cmd_bootm.c */
  112. void print_image_hdr (image_header_t *hdr);
  113. extern ulong load_addr; /* Default Load Address */
  114. /* common/cmd_nvedit.c */
  115. int env_init (void);
  116. void env_relocate (void);
  117. char *getenv (uchar *);
  118. int getenv_r (uchar *name, uchar *buf, unsigned len);
  119. int saveenv (void);
  120. #ifdef CONFIG_PPC /* ARM version to be fixed! */
  121. void inline setenv (char *, char *);
  122. #else
  123. void setenv (char *, char *);
  124. #endif /* CONFIG_PPC */
  125. #ifdef CONFIG_ARM
  126. # include <asm/u-boot-arm.h> /* ARM version to be fixed! */
  127. #endif /* CONFIG_ARM */
  128. #ifdef CONFIG_I386 /* x86 version to be fixed! */
  129. # include <asm/ppcboot-i386.h>
  130. #endif /* CONFIG_I386 */
  131. void pci_init (void);
  132. void pci_init_board(void);
  133. void pciinfo (int, int);
  134. #if defined(CONFIG_PCI) && defined(CONFIG_440)
  135. # if defined(CFG_PCI_PRE_INIT)
  136. int pci_pre_init (struct pci_controller * );
  137. # endif
  138. # if defined(CFG_PCI_TARGET_INIT)
  139. void pci_target_init (struct pci_controller *);
  140. # endif
  141. # if defined(CFG_PCI_MASTER_INIT)
  142. void pci_master_init (struct pci_controller *);
  143. # endif
  144. int is_pci_host (struct pci_controller *);
  145. #endif
  146. int misc_init_f (void);
  147. int misc_init_r (void);
  148. /* $(BOARD)/$(BOARD).c */
  149. void reset_phy (void);
  150. void fdc_hw_init (void);
  151. /* $(BOARD)/eeprom.c */
  152. void eeprom_init (void);
  153. int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  154. int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  155. #ifdef CONFIG_LWMON
  156. extern uchar pic_read (uchar reg);
  157. extern void pic_write (uchar reg, uchar val);
  158. #endif
  159. /*
  160. * Set this up regardless of board
  161. * type, to prevent errors.
  162. */
  163. #if defined(CONFIG_SPI) || !defined(CFG_I2C_EEPROM_ADDR)
  164. # define CFG_DEF_EEPROM_ADDR 0
  165. #else
  166. # define CFG_DEF_EEPROM_ADDR CFG_I2C_EEPROM_ADDR
  167. #endif /* CONFIG_SPI || !defined(CFG_I2C_EEPROM_ADDR) */
  168. #if defined(CONFIG_PCU_E) || defined(CONFIG_CCM)
  169. extern void spi_init_f (void);
  170. extern void spi_init_r (void);
  171. extern ssize_t spi_read (uchar *, int, uchar *, int);
  172. extern ssize_t spi_write (uchar *, int, uchar *, int);
  173. #endif
  174. #ifdef CONFIG_RPXCLASSIC
  175. void rpxclassic_init (void);
  176. #endif
  177. #ifdef CONFIG_MBX
  178. /* $(BOARD)/mbx8xx.c */
  179. void mbx_init (void);
  180. void board_serial_init (void);
  181. void board_ether_init (void);
  182. #endif
  183. #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_MBX) || defined(CONFIG_IAD210)
  184. void board_get_enetaddr (uchar *addr);
  185. #endif
  186. #ifdef CONFIG_HERMES
  187. /* $(BOARD)/hermes.c */
  188. void hermes_start_lxt980 (int speed);
  189. #endif
  190. #ifdef CONFIG_EVB64260
  191. void evb64260_init(void);
  192. void debug_led(int, int);
  193. void display_mem_map(void);
  194. void perform_soft_reset(void);
  195. #endif
  196. void load_sernum_ethaddr (void);
  197. /* $(BOARD)/$(BOARD).c */
  198. int board_pre_init (void);
  199. int board_postclk_init (void); /* after clocks/timebase, before env/serial */
  200. void board_poweroff (void);
  201. #if defined(CFG_DRAM_TEST)
  202. int testdram(void);
  203. #endif /* CFG_DRAM_TEST */
  204. /* $(CPU)/start.S */
  205. #ifdef CONFIG_8xx
  206. uint get_immr (uint);
  207. #endif
  208. uint get_pvr (void);
  209. uint rd_ic_cst (void);
  210. void wr_ic_cst (uint);
  211. void wr_ic_adr (uint);
  212. uint rd_dc_cst (void);
  213. void wr_dc_cst (uint);
  214. void wr_dc_adr (uint);
  215. int icache_status (void);
  216. void icache_enable (void);
  217. void icache_disable(void);
  218. int dcache_status (void);
  219. void dcache_enable (void);
  220. void dcache_disable(void);
  221. void relocate_code (ulong, gd_t *, ulong);
  222. ulong get_endaddr (void);
  223. void trap_init (ulong);
  224. #if defined (CONFIG_4xx) || \
  225. defined (CONFIG_74xx_7xx) || \
  226. defined (CONFIG_74x) || \
  227. defined (CONFIG_75x) || \
  228. defined (CONFIG_74xx)
  229. unsigned char in8(unsigned int);
  230. void out8(unsigned int, unsigned char);
  231. unsigned short in16(unsigned int);
  232. unsigned short in16r(unsigned int);
  233. void out16(unsigned int, unsigned short value);
  234. void out16r(unsigned int, unsigned short value);
  235. unsigned long in32(unsigned int);
  236. unsigned long in32r(unsigned int);
  237. void out32(unsigned int, unsigned long value);
  238. void out32r(unsigned int, unsigned long value);
  239. void ppcDcbf(unsigned long value);
  240. void ppcDcbi(unsigned long value);
  241. void ppcSync(void);
  242. #endif
  243. /* $(CPU)/cpu.c */
  244. int checkcpu (void);
  245. int checkicache (void);
  246. int checkdcache (void);
  247. void upmconfig (unsigned int, unsigned int *, unsigned int);
  248. ulong get_tbclk (void);
  249. /* $(CPU)/serial.c */
  250. int serial_init (void);
  251. void serial_setbrg (void);
  252. void serial_putc (const char);
  253. void serial_puts (const char *);
  254. void serial_addr (unsigned int);
  255. int serial_getc (void);
  256. int serial_tstc (void);
  257. /* $(CPU)/speed.c */
  258. int get_clocks (void);
  259. #if defined(CONFIG_8260)
  260. int prt_8260_clks (void);
  261. #endif
  262. #ifdef CONFIG_4xx
  263. ulong get_OPB_freq (void);
  264. ulong get_PCI_freq (void);
  265. #endif
  266. #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
  267. ulong get_FCLK (void);
  268. ulong get_HCLK (void);
  269. ulong get_PCLK (void);
  270. ulong get_UCLK (void);
  271. #endif
  272. ulong get_bus_freq (ulong);
  273. #if defined(CONFIG_4xx) || defined(CONFIG_IOP480)
  274. # if defined(CONFIG_440)
  275. typedef PPC440_SYS_INFO sys_info_t;
  276. # else
  277. typedef PPC405_SYS_INFO sys_info_t;
  278. # endif
  279. void get_sys_info ( sys_info_t * );
  280. #endif
  281. /* $(CPU)/cpu_init.c */
  282. #if defined(CONFIG_8xx) || defined(CONFIG_8260)
  283. void cpu_init_f (volatile immap_t *immr);
  284. #endif
  285. #ifdef CONFIG_4xx
  286. void cpu_init_f (void);
  287. #endif
  288. int cpu_init_r (void);
  289. #if defined(CONFIG_8260)
  290. int prt_8260_rsr (void);
  291. #endif
  292. /* $(CPU)/interrupts.c */
  293. int interrupt_init (void);
  294. void timer_interrupt (struct pt_regs *);
  295. void external_interrupt (struct pt_regs *);
  296. void irq_install_handler(int, interrupt_handler_t *, void *);
  297. void irq_free_handler (int);
  298. void reset_timer (void);
  299. ulong get_timer (ulong base);
  300. void set_timer (ulong t);
  301. void enable_interrupts (void);
  302. int disable_interrupts (void);
  303. /* $(CPU)/.../commproc.c */
  304. int dpram_init (void);
  305. uint dpram_base(void);
  306. uint dpram_base_align(uint align);
  307. uint dpram_alloc(uint size);
  308. uint dpram_alloc_align(uint size,uint align);
  309. void post_word_store (ulong);
  310. ulong post_word_load (void);
  311. /* $(CPU)/.../<eth> */
  312. void mii_init (void);
  313. /* $(CPU)/.../lcd.c */
  314. ulong lcd_setmem (ulong);
  315. /* $(CPU)/.../vfd.c */
  316. ulong vfd_setmem (ulong);
  317. /* $(CPU)/.../video.c */
  318. ulong video_setmem (ulong);
  319. /* ppc/cache.c */
  320. void flush_cache (unsigned long, unsigned long);
  321. /* ppc/ticks.S */
  322. unsigned long long get_ticks(void);
  323. void wait_ticks (unsigned long);
  324. /* ppc/time.c */
  325. void udelay (unsigned long);
  326. ulong usec2ticks (unsigned long usec);
  327. ulong ticks2usec (unsigned long ticks);
  328. int init_timebase (void);
  329. /* ppc/vsprintf.c */
  330. ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
  331. long simple_strtol(const char *cp,char **endp,unsigned int base);
  332. void panic(const char *fmt, ...);
  333. int sprintf(char * buf, const char *fmt, ...);
  334. int vsprintf(char *buf, const char *fmt, va_list args);
  335. /* ppc/crc32.c */
  336. ulong crc32 (ulong, const unsigned char *, uint);
  337. ulong crc32_no_comp (ulong, const unsigned char *, uint);
  338. /* common/console.c */
  339. extern void **syscall_tbl;
  340. int console_init_f(void); /* Before relocation; uses the serial stuff */
  341. int console_init_r(void); /* After relocation; uses the console stuff */
  342. int console_assign (int file, char *devname); /* Assign the console */
  343. int ctrlc (void);
  344. int had_ctrlc (void); /* have we had a Control-C since last clear? */
  345. void clear_ctrlc (void); /* clear the Control-C condition */
  346. int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */
  347. /*
  348. * STDIO based functions (can always be used)
  349. */
  350. /* serial stuff */
  351. void serial_printf (const char *fmt, ...);
  352. /* stdin */
  353. int getc(void);
  354. int tstc(void);
  355. /* stdout */
  356. void putc(const char c);
  357. void puts(const char *s);
  358. void printf(const char *fmt, ...);
  359. /* stderr */
  360. #define eputc(c) fputc(stderr, c)
  361. #define eputs(s) fputs(stderr, s)
  362. #define eprintf(fmt,args...) fprintf(stderr,fmt ,##args)
  363. /*
  364. * FILE based functions (can only be used AFTER relocation!)
  365. */
  366. #define stdin 0
  367. #define stdout 1
  368. #define stderr 2
  369. #define MAX_FILES 3
  370. void fprintf(int file, const char *fmt, ...);
  371. void fputs(int file, const char *s);
  372. void fputc(int file, const char c);
  373. int ftstc(int file);
  374. int fgetc(int file);
  375. int pcmcia_init (void);
  376. #ifdef CONFIG_SHOW_BOOT_PROGRESS
  377. void show_boot_progress (int status);
  378. #endif
  379. #endif /* __COMMON_H_ */