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