common.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. /*
  2. * (C) Copyright 2000-2009
  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. #ifndef __ASSEMBLY__ /* put C only stuff in this section */
  28. typedef unsigned char uchar;
  29. typedef volatile unsigned long vu_long;
  30. typedef volatile unsigned short vu_short;
  31. typedef volatile unsigned char vu_char;
  32. #include <config.h>
  33. #include <asm-offsets.h>
  34. #include <linux/bitops.h>
  35. #include <linux/types.h>
  36. #include <linux/string.h>
  37. #include <asm/ptrace.h>
  38. #include <stdarg.h>
  39. #if defined(CONFIG_PCI) && (defined(CONFIG_4xx) && !defined(CONFIG_AP1000))
  40. #include <pci.h>
  41. #endif
  42. #if defined(CONFIG_8xx)
  43. #include <asm/8xx_immap.h>
  44. #if defined(CONFIG_MPC852) || defined(CONFIG_MPC852T) || \
  45. defined(CONFIG_MPC859) || defined(CONFIG_MPC859T) || \
  46. defined(CONFIG_MPC859DSL) || \
  47. defined(CONFIG_MPC866) || defined(CONFIG_MPC866T) || \
  48. defined(CONFIG_MPC866P)
  49. # define CONFIG_MPC866_FAMILY 1
  50. #elif defined(CONFIG_MPC870) \
  51. || defined(CONFIG_MPC875) \
  52. || defined(CONFIG_MPC880) \
  53. || defined(CONFIG_MPC885)
  54. # define CONFIG_MPC885_FAMILY 1
  55. #endif
  56. #if defined(CONFIG_MPC860) \
  57. || defined(CONFIG_MPC860T) \
  58. || defined(CONFIG_MPC866_FAMILY) \
  59. || defined(CONFIG_MPC885_FAMILY)
  60. # define CONFIG_MPC86x 1
  61. #endif
  62. #elif defined(CONFIG_5xx)
  63. #include <asm/5xx_immap.h>
  64. #elif defined(CONFIG_MPC5xxx)
  65. #include <mpc5xxx.h>
  66. #elif defined(CONFIG_MPC512X)
  67. #include <asm/immap_512x.h>
  68. #elif defined(CONFIG_MPC8220)
  69. #include <asm/immap_8220.h>
  70. #elif defined(CONFIG_8260)
  71. #if defined(CONFIG_MPC8247) \
  72. || defined(CONFIG_MPC8248) \
  73. || defined(CONFIG_MPC8271) \
  74. || defined(CONFIG_MPC8272)
  75. #define CONFIG_MPC8272_FAMILY 1
  76. #endif
  77. #if defined(CONFIG_MPC8272_FAMILY)
  78. #define CONFIG_MPC8260 1
  79. #endif
  80. #include <asm/immap_8260.h>
  81. #endif
  82. #ifdef CONFIG_MPC86xx
  83. #include <mpc86xx.h>
  84. #include <asm/immap_86xx.h>
  85. #endif
  86. #ifdef CONFIG_MPC85xx
  87. #include <mpc85xx.h>
  88. #include <asm/immap_85xx.h>
  89. #endif
  90. #ifdef CONFIG_MPC83xx
  91. #include <mpc83xx.h>
  92. #include <asm/immap_83xx.h>
  93. #endif
  94. #ifdef CONFIG_4xx
  95. #include <asm/ppc4xx.h>
  96. #endif
  97. #ifdef CONFIG_HYMOD
  98. #include <board/hymod/hymod.h>
  99. #endif
  100. #ifdef CONFIG_ARM
  101. #define asmlinkage /* nothing */
  102. #endif
  103. #ifdef CONFIG_BLACKFIN
  104. #include <asm/blackfin.h>
  105. #endif
  106. #ifdef CONFIG_SOC_DA8XX
  107. #include <asm/arch/hardware.h>
  108. #endif
  109. #include <part.h>
  110. #include <flash.h>
  111. #include <image.h>
  112. #ifdef DEBUG
  113. #define debug(fmt,args...) printf (fmt ,##args)
  114. #define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
  115. #else
  116. #define debug(fmt,args...)
  117. #define debugX(level,fmt,args...)
  118. #endif /* DEBUG */
  119. #define error(fmt, args...) do { \
  120. printf("ERROR: " fmt "\nat %s:%d/%s()\n", \
  121. ##args, __FILE__, __LINE__, __func__); \
  122. } while (0)
  123. #ifndef BUG
  124. #define BUG() do { \
  125. printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
  126. panic("BUG!"); \
  127. } while (0)
  128. #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
  129. #endif /* BUG */
  130. /* Force a compilation error if condition is true */
  131. #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
  132. typedef void (interrupt_handler_t)(void *);
  133. #include <asm/u-boot.h> /* boot information for Linux kernel */
  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. #if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \
  142. defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \
  143. defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M)
  144. # ifndef CONFIG_TQM8xxM
  145. # define CONFIG_TQM8xxM
  146. # endif
  147. #endif
  148. #if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
  149. defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \
  150. defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM) || \
  151. defined(CONFIG_TQM885D)
  152. # ifndef CONFIG_TQM8xxL
  153. # define CONFIG_TQM8xxL
  154. # endif
  155. #endif
  156. #ifndef CONFIG_SERIAL_MULTI
  157. #if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2) \
  158. || defined(CONFIG_8xx_CONS_SCC1) || defined(CONFIG_8xx_CONS_SCC2) \
  159. || defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
  160. #define CONFIG_SERIAL_MULTI 1
  161. #endif
  162. #endif /* CONFIG_SERIAL_MULTI */
  163. /*
  164. * General Purpose Utilities
  165. */
  166. #define min(X, Y) \
  167. ({ typeof (X) __x = (X); \
  168. typeof (Y) __y = (Y); \
  169. (__x < __y) ? __x : __y; })
  170. #define max(X, Y) \
  171. ({ typeof (X) __x = (X); \
  172. typeof (Y) __y = (Y); \
  173. (__x > __y) ? __x : __y; })
  174. #define MIN(x, y) min(x, y)
  175. #define MAX(x, y) max(x, y)
  176. #if defined(CONFIG_ENV_IS_EMBEDDED)
  177. #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
  178. #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
  179. (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
  180. defined(CONFIG_ENV_IS_IN_NVRAM)
  181. #define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
  182. #else
  183. #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
  184. #endif
  185. /**
  186. * container_of - cast a member of a structure out to the containing structure
  187. * @ptr: the pointer to the member.
  188. * @type: the type of the container struct this is embedded in.
  189. * @member: the name of the member within the struct.
  190. *
  191. */
  192. #define container_of(ptr, type, member) ({ \
  193. const typeof( ((type *)0)->member ) *__mptr = (ptr); \
  194. (type *)( (char *)__mptr - offsetof(type,member) );})
  195. /*
  196. * Function Prototypes
  197. */
  198. void hang (void) __attribute__ ((noreturn));
  199. /* */
  200. phys_size_t initdram (int);
  201. int display_options (void);
  202. void print_size(unsigned long long, const char *);
  203. int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);
  204. /* common/main.c */
  205. void main_loop (void);
  206. int run_command (const char *cmd, int flag);
  207. int readline (const char *const prompt);
  208. int readline_into_buffer (const char *const prompt, char * buffer);
  209. int parse_line (char *, char *[]);
  210. void init_cmd_timeout(void);
  211. void reset_cmd_timeout(void);
  212. /* arch/$(ARCH)/lib/board.c */
  213. void board_init_f (ulong) __attribute__ ((noreturn));
  214. void board_init_r (gd_t *, ulong) __attribute__ ((noreturn));
  215. int checkboard (void);
  216. int checkflash (void);
  217. int checkdram (void);
  218. int last_stage_init(void);
  219. extern ulong monitor_flash_len;
  220. int mac_read_from_eeprom(void);
  221. /* common/flash.c */
  222. void flash_perror (int);
  223. /* common/cmd_source.c */
  224. int source (ulong addr, const char *fit_uname);
  225. extern ulong load_addr; /* Default Load Address */
  226. /* common/cmd_doc.c */
  227. void doc_probe(unsigned long physadr);
  228. /* common/cmd_nvedit.c */
  229. int env_init (void);
  230. void env_relocate (void);
  231. int envmatch (uchar *, int);
  232. char *getenv (const char *);
  233. int getenv_f (const char *name, char *buf, unsigned len);
  234. int saveenv (void);
  235. #ifdef CONFIG_PPC /* ARM version to be fixed! */
  236. int inline setenv (const char *, const char *);
  237. #else
  238. int setenv (const char *, const char *);
  239. #endif /* CONFIG_PPC */
  240. #ifdef CONFIG_ARM
  241. # include <asm/mach-types.h>
  242. # include <asm/setup.h>
  243. # include <asm/u-boot-arm.h> /* ARM version to be fixed! */
  244. #endif /* CONFIG_ARM */
  245. #ifdef CONFIG_X86 /* x86 version to be fixed! */
  246. # include <asm/u-boot-x86.h>
  247. #endif /* CONFIG_X86 */
  248. #ifdef CONFIG_AUTO_COMPLETE
  249. int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
  250. #endif
  251. int get_env_id (void);
  252. void pci_init (void);
  253. void pci_init_board(void);
  254. void pciinfo (int, int);
  255. #if defined(CONFIG_PCI) && (defined(CONFIG_4xx) && !defined(CONFIG_AP1000))
  256. int pci_pre_init (struct pci_controller *);
  257. int is_pci_host (struct pci_controller *);
  258. #endif
  259. #if defined(CONFIG_PCI) && (defined(CONFIG_440) || defined(CONFIG_405EX))
  260. # if defined(CONFIG_SYS_PCI_TARGET_INIT)
  261. void pci_target_init (struct pci_controller *);
  262. # endif
  263. # if defined(CONFIG_SYS_PCI_MASTER_INIT)
  264. void pci_master_init (struct pci_controller *);
  265. # endif
  266. #if defined(CONFIG_440SPE) || \
  267. defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
  268. defined(CONFIG_405EX)
  269. void pcie_setup_hoses(int busno);
  270. #endif
  271. #endif
  272. int misc_init_f (void);
  273. int misc_init_r (void);
  274. /* common/exports.c */
  275. void jumptable_init(void);
  276. /* common/kallsysm.c */
  277. const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
  278. /* api/api.c */
  279. void api_init (void);
  280. /* common/memsize.c */
  281. long get_ram_size (long *, long);
  282. /* $(BOARD)/$(BOARD).c */
  283. void reset_phy (void);
  284. void fdc_hw_init (void);
  285. /* $(BOARD)/eeprom.c */
  286. void eeprom_init (void);
  287. #ifndef CONFIG_SPI
  288. int eeprom_probe (unsigned dev_addr, unsigned offset);
  289. #endif
  290. int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  291. int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  292. #ifdef CONFIG_LWMON
  293. extern uchar pic_read (uchar reg);
  294. extern void pic_write (uchar reg, uchar val);
  295. #endif
  296. /*
  297. * Set this up regardless of board
  298. * type, to prevent errors.
  299. */
  300. #if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
  301. # define CONFIG_SYS_DEF_EEPROM_ADDR 0
  302. #else
  303. #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
  304. # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
  305. #endif
  306. #endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */
  307. #if defined(CONFIG_SPI)
  308. extern void spi_init_f (void);
  309. extern void spi_init_r (void);
  310. extern ssize_t spi_read (uchar *, int, uchar *, int);
  311. extern ssize_t spi_write (uchar *, int, uchar *, int);
  312. #endif
  313. #ifdef CONFIG_RPXCLASSIC
  314. void rpxclassic_init (void);
  315. #endif
  316. void rpxlite_init (void);
  317. #ifdef CONFIG_MBX
  318. /* $(BOARD)/mbx8xx.c */
  319. void mbx_init (void);
  320. void board_serial_init (void);
  321. void board_ether_init (void);
  322. #endif
  323. #ifdef CONFIG_HERMES
  324. /* $(BOARD)/hermes.c */
  325. void hermes_start_lxt980 (int speed);
  326. #endif
  327. #ifdef CONFIG_EVB64260
  328. void evb64260_init(void);
  329. void debug_led(int, int);
  330. void display_mem_map(void);
  331. void perform_soft_reset(void);
  332. #endif
  333. /* $(BOARD)/$(BOARD).c */
  334. int board_early_init_f (void);
  335. int board_late_init (void);
  336. int board_postclk_init (void); /* after clocks/timebase, before env/serial */
  337. int board_early_init_r (void);
  338. void board_poweroff (void);
  339. #if defined(CONFIG_SYS_DRAM_TEST)
  340. int testdram(void);
  341. #endif /* CONFIG_SYS_DRAM_TEST */
  342. /* $(CPU)/start.S */
  343. #if defined(CONFIG_5xx) || \
  344. defined(CONFIG_8xx)
  345. uint get_immr (uint);
  346. #endif
  347. uint get_pir (void);
  348. #if defined(CONFIG_MPC5xxx)
  349. uint get_svr (void);
  350. #endif
  351. uint get_pvr (void);
  352. uint get_svr (void);
  353. uint rd_ic_cst (void);
  354. void wr_ic_cst (uint);
  355. void wr_ic_adr (uint);
  356. uint rd_dc_cst (void);
  357. void wr_dc_cst (uint);
  358. void wr_dc_adr (uint);
  359. int icache_status (void);
  360. void icache_enable (void);
  361. void icache_disable(void);
  362. int dcache_status (void);
  363. void dcache_enable (void);
  364. void dcache_disable(void);
  365. void mmu_disable(void);
  366. void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
  367. ulong get_endaddr (void);
  368. void trap_init (ulong);
  369. #if defined (CONFIG_4xx) || \
  370. defined (CONFIG_MPC5xxx) || \
  371. defined (CONFIG_74xx_7xx) || \
  372. defined (CONFIG_74x) || \
  373. defined (CONFIG_75x) || \
  374. defined (CONFIG_74xx) || \
  375. defined (CONFIG_MPC8220) || \
  376. defined (CONFIG_MPC85xx) || \
  377. defined (CONFIG_MPC86xx) || \
  378. defined (CONFIG_MPC83xx)
  379. unsigned char in8(unsigned int);
  380. void out8(unsigned int, unsigned char);
  381. unsigned short in16(unsigned int);
  382. unsigned short in16r(unsigned int);
  383. void out16(unsigned int, unsigned short value);
  384. void out16r(unsigned int, unsigned short value);
  385. unsigned long in32(unsigned int);
  386. unsigned long in32r(unsigned int);
  387. void out32(unsigned int, unsigned long value);
  388. void out32r(unsigned int, unsigned long value);
  389. void ppcDcbf(unsigned long value);
  390. void ppcDcbi(unsigned long value);
  391. void ppcSync(void);
  392. void ppcDcbz(unsigned long value);
  393. #endif
  394. #if defined (CONFIG_MICROBLAZE)
  395. unsigned short in16(unsigned int);
  396. void out16(unsigned int, unsigned short value);
  397. #endif
  398. #if defined (CONFIG_MPC83xx)
  399. void ppcDWload(unsigned int *addr, unsigned int *ret);
  400. void ppcDWstore(unsigned int *addr, unsigned int *value);
  401. void disable_addr_trans(void);
  402. void enable_addr_trans(void);
  403. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  404. void ddr_enable_ecc(unsigned int dram_size);
  405. #endif
  406. #endif
  407. /* $(CPU)/cpu.c */
  408. int cpu_numcores (void);
  409. int probecpu (void);
  410. int checkcpu (void);
  411. int checkicache (void);
  412. int checkdcache (void);
  413. void upmconfig (unsigned int, unsigned int *, unsigned int);
  414. ulong get_tbclk (void);
  415. void reset_cpu (ulong addr);
  416. #if defined (CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
  417. void ft_cpu_setup(void *blob, bd_t *bd);
  418. #ifdef CONFIG_PCI
  419. void ft_pci_setup(void *blob, bd_t *bd);
  420. #endif
  421. #endif
  422. /* $(CPU)/serial.c */
  423. int serial_init (void);
  424. void serial_exit (void);
  425. void serial_setbrg (void);
  426. void serial_putc (const char);
  427. void serial_putc_raw(const char);
  428. void serial_puts (const char *);
  429. int serial_getc (void);
  430. int serial_tstc (void);
  431. void _serial_setbrg (const int);
  432. void _serial_putc (const char, const int);
  433. void _serial_putc_raw(const char, const int);
  434. void _serial_puts (const char *, const int);
  435. int _serial_getc (const int);
  436. int _serial_tstc (const int);
  437. /* $(CPU)/speed.c */
  438. int get_clocks (void);
  439. int get_clocks_866 (void);
  440. int sdram_adjust_866 (void);
  441. int adjust_sdram_tbs_8xx (void);
  442. #if defined(CONFIG_8260)
  443. int prt_8260_clks (void);
  444. #elif defined(CONFIG_MPC5xxx)
  445. int prt_mpc5xxx_clks (void);
  446. #endif
  447. #if defined(CONFIG_MPC512X)
  448. int prt_mpc512xxx_clks (void);
  449. #endif
  450. #if defined(CONFIG_MPC8220)
  451. int prt_mpc8220_clks (void);
  452. #endif
  453. #ifdef CONFIG_4xx
  454. ulong get_OPB_freq (void);
  455. ulong get_PCI_freq (void);
  456. #endif
  457. #if defined(CONFIG_S3C24X0) || \
  458. defined(CONFIG_LH7A40X) || \
  459. defined(CONFIG_S3C6400) || \
  460. defined(CONFIG_EP93XX)
  461. ulong get_FCLK (void);
  462. ulong get_HCLK (void);
  463. ulong get_PCLK (void);
  464. ulong get_UCLK (void);
  465. #endif
  466. #if defined(CONFIG_LH7A40X)
  467. ulong get_PLLCLK (void);
  468. #endif
  469. #if defined CONFIG_INCA_IP
  470. uint incaip_get_cpuclk (void);
  471. #endif
  472. #if defined(CONFIG_IMX)
  473. ulong get_systemPLLCLK(void);
  474. ulong get_FCLK(void);
  475. ulong get_HCLK(void);
  476. ulong get_BCLK(void);
  477. ulong get_PERCLK1(void);
  478. ulong get_PERCLK2(void);
  479. ulong get_PERCLK3(void);
  480. #endif
  481. ulong get_bus_freq (ulong);
  482. int get_serial_clock(void);
  483. #if defined(CONFIG_MPC85xx)
  484. typedef MPC85xx_SYS_INFO sys_info_t;
  485. void get_sys_info ( sys_info_t * );
  486. ulong get_ddr_freq (ulong);
  487. #endif
  488. #if defined(CONFIG_MPC86xx)
  489. typedef MPC86xx_SYS_INFO sys_info_t;
  490. void get_sys_info ( sys_info_t * );
  491. static inline ulong get_ddr_freq(ulong dummy)
  492. {
  493. return get_bus_freq(dummy);
  494. }
  495. #endif
  496. #if defined(CONFIG_4xx) || defined(CONFIG_IOP480)
  497. # if defined(CONFIG_440)
  498. # if defined(CONFIG_440SPE)
  499. unsigned long determine_sysper(void);
  500. unsigned long determine_pci_clock_per(void);
  501. # endif
  502. # endif
  503. typedef PPC4xx_SYS_INFO sys_info_t;
  504. int ppc440spe_revB(void);
  505. void get_sys_info ( sys_info_t * );
  506. #endif
  507. /* $(CPU)/cpu_init.c */
  508. #if defined(CONFIG_8xx) || defined(CONFIG_8260)
  509. void cpu_init_f (volatile immap_t *immr);
  510. #endif
  511. #if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) || defined(CONFIG_MCF52x2) ||defined(CONFIG_MPC86xx)
  512. void cpu_init_f (void);
  513. #endif
  514. int cpu_init_r (void);
  515. #if defined(CONFIG_8260)
  516. int prt_8260_rsr (void);
  517. #elif defined(CONFIG_MPC83xx)
  518. int prt_83xx_rsr (void);
  519. #endif
  520. /* $(CPU)/interrupts.c */
  521. int interrupt_init (void);
  522. void timer_interrupt (struct pt_regs *);
  523. void external_interrupt (struct pt_regs *);
  524. void irq_install_handler(int, interrupt_handler_t *, void *);
  525. void irq_free_handler (int);
  526. void reset_timer (void);
  527. ulong get_timer (ulong base);
  528. void enable_interrupts (void);
  529. int disable_interrupts (void);
  530. /* $(CPU)/.../commproc.c */
  531. int dpram_init (void);
  532. uint dpram_base(void);
  533. uint dpram_base_align(uint align);
  534. uint dpram_alloc(uint size);
  535. uint dpram_alloc_align(uint size,uint align);
  536. void bootcount_store (ulong);
  537. ulong bootcount_load (void);
  538. #define BOOTCOUNT_MAGIC 0xB001C041
  539. /* $(CPU)/.../<eth> */
  540. void mii_init (void);
  541. /* $(CPU)/.../lcd.c */
  542. ulong lcd_setmem (ulong);
  543. /* $(CPU)/.../video.c */
  544. ulong video_setmem (ulong);
  545. /* arch/$(ARCH)/lib/cache.c */
  546. void flush_cache (unsigned long, unsigned long);
  547. void flush_dcache_all(void);
  548. void flush_dcache_range(unsigned long start, unsigned long stop);
  549. void invalidate_dcache_range(unsigned long start, unsigned long stop);
  550. void invalidate_dcache_all(void);
  551. void invalidate_icache_all(void);
  552. /* arch/$(ARCH)/lib/ticks.S */
  553. unsigned long long get_ticks(void);
  554. void wait_ticks (unsigned long);
  555. /* arch/$(ARCH)/lib/time.c */
  556. void __udelay (unsigned long);
  557. ulong usec2ticks (unsigned long usec);
  558. ulong ticks2usec (unsigned long ticks);
  559. int init_timebase (void);
  560. /* lib/gunzip.c */
  561. int gunzip(void *, int, unsigned char *, unsigned long *);
  562. int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
  563. int stoponerr, int offset);
  564. /* lib/net_utils.c */
  565. #include <net.h>
  566. static inline IPaddr_t getenv_IPaddr (char *var)
  567. {
  568. return (string_to_ip(getenv(var)));
  569. }
  570. /* lib/qsort.c */
  571. void qsort(void *base, size_t nmemb, size_t size,
  572. int(*compar)(const void *, const void *));
  573. int strcmp_compar(const void *, const void *);
  574. /* lib/time.c */
  575. void udelay (unsigned long);
  576. /* lib/vsprintf.c */
  577. ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
  578. int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
  579. unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base);
  580. long simple_strtol(const char *cp,char **endp,unsigned int base);
  581. void panic(const char *fmt, ...)
  582. __attribute__ ((format (__printf__, 1, 2), noreturn));
  583. int sprintf(char * buf, const char *fmt, ...)
  584. __attribute__ ((format (__printf__, 2, 3)));
  585. int vsprintf(char *buf, const char *fmt, va_list args);
  586. /* lib/strmhz.c */
  587. char * strmhz(char *buf, unsigned long hz);
  588. /* lib/crc32.c */
  589. #include <u-boot/crc.h>
  590. /* common/console.c */
  591. int console_init_f(void); /* Before relocation; uses the serial stuff */
  592. int console_init_r(void); /* After relocation; uses the console stuff */
  593. int console_assign(int file, const char *devname); /* Assign the console */
  594. int ctrlc (void);
  595. int had_ctrlc (void); /* have we had a Control-C since last clear? */
  596. void clear_ctrlc (void); /* clear the Control-C condition */
  597. int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */
  598. /*
  599. * STDIO based functions (can always be used)
  600. */
  601. /* serial stuff */
  602. int serial_printf (const char *fmt, ...)
  603. __attribute__ ((format (__printf__, 1, 2)));
  604. /* stdin */
  605. int getc(void);
  606. int tstc(void);
  607. /* stdout */
  608. void putc(const char c);
  609. void puts(const char *s);
  610. int printf(const char *fmt, ...)
  611. __attribute__ ((format (__printf__, 1, 2)));
  612. int vprintf(const char *fmt, va_list args);
  613. /* stderr */
  614. #define eputc(c) fputc(stderr, c)
  615. #define eputs(s) fputs(stderr, s)
  616. #define eprintf(fmt,args...) fprintf(stderr,fmt ,##args)
  617. /*
  618. * FILE based functions (can only be used AFTER relocation!)
  619. */
  620. #define stdin 0
  621. #define stdout 1
  622. #define stderr 2
  623. #define MAX_FILES 3
  624. int fprintf(int file, const char *fmt, ...)
  625. __attribute__ ((format (__printf__, 2, 3)));
  626. void fputs(int file, const char *s);
  627. void fputc(int file, const char c);
  628. int ftstc(int file);
  629. int fgetc(int file);
  630. /*
  631. * CONSOLE multiplexing.
  632. */
  633. #ifdef CONFIG_CONSOLE_MUX
  634. #include <iomux.h>
  635. #endif
  636. int pcmcia_init (void);
  637. #ifdef CONFIG_STATUS_LED
  638. # include <status_led.h>
  639. #endif
  640. /*
  641. * Board-specific Platform code can reimplement show_boot_progress () if needed
  642. */
  643. void show_boot_progress(int val);
  644. /* Multicore arch functions */
  645. #ifdef CONFIG_MP
  646. int cpu_status(int nr);
  647. int cpu_reset(int nr);
  648. int cpu_disable(int nr);
  649. int cpu_release(int nr, int argc, char * const argv[]);
  650. #endif
  651. #endif /* __ASSEMBLY__ */
  652. /* Put only stuff here that the assembler can digest */
  653. #ifdef CONFIG_POST
  654. #define CONFIG_HAS_POST
  655. #ifndef CONFIG_POST_ALT_LIST
  656. #define CONFIG_POST_STD_LIST
  657. #endif
  658. #endif
  659. #ifdef CONFIG_INIT_CRITICAL
  660. #error CONFIG_INIT_CRITICAL is deprecated!
  661. #error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
  662. #endif
  663. #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
  664. #define ROUND(a,b) (((a) + (b)) & ~((b) - 1))
  665. #define DIV_ROUND(n,d) (((n) + ((d)/2)) / (d))
  666. #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
  667. #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
  668. #define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)
  669. #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
  670. /* Pull in stuff for the build system */
  671. #ifdef DO_DEPS_ONLY
  672. # include <environment.h>
  673. #endif
  674. #endif /* __COMMON_H_ */