common.h 12 KB

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