X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=arch%2Farm%2Flib%2Fboard.c;h=22a4d9cc0e59d4c877fb8892e2f960b0cad32843;hb=178d0cc1a4c73c3341afbeb2a93b172de8c96bd1;hp=c899839852d9cf5ed4e0e4efd10a71ad4d4ac051;hpb=15c2e2c0ea64a0ab10b6765e2b0ab46d99d9ac34;p=platform%2Fkernel%2Fu-boot.git diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index c899839..22a4d9c 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -48,18 +48,15 @@ #include #include #include +#include +#include +#include +#include #ifdef CONFIG_BITBANGMII #include #endif -#ifdef CONFIG_DRIVER_SMC91111 -#include "../drivers/net/smc91111.h" -#endif -#ifdef CONFIG_DRIVER_LAN91C96 -#include "../drivers/net/lan91c96.h" -#endif - DECLARE_GLOBAL_DATA_PTR; ulong monitor_flash_len; @@ -69,16 +66,11 @@ extern int AT91F_DataflashInit(void); extern void dataflash_print_info(void); #endif -#ifdef CONFIG_DRIVER_RTL8019 -extern void rtl8019_get_enetaddr (uchar * addr); -#endif - #if defined(CONFIG_HARD_I2C) || \ defined(CONFIG_SOFT_I2C) #include #endif - /************************************************************************ * Coloured LED functionality ************************************************************************ @@ -87,22 +79,22 @@ extern void rtl8019_get_enetaddr (uchar * addr); inline void __coloured_LED_init(void) {} void coloured_LED_init(void) __attribute__((weak, alias("__coloured_LED_init"))); -inline void __red_LED_on(void) {} -void red_LED_on(void) __attribute__((weak, alias("__red_LED_on"))); -inline void __red_LED_off(void) {} -void red_LED_off(void) __attribute__((weak, alias("__red_LED_off"))); -inline void __green_LED_on(void) {} -void green_LED_on(void) __attribute__((weak, alias("__green_LED_on"))); -inline void __green_LED_off(void) {} -void green_LED_off(void) __attribute__((weak, alias("__green_LED_off"))); -inline void __yellow_LED_on(void) {} -void yellow_LED_on(void) __attribute__((weak, alias("__yellow_LED_on"))); -inline void __yellow_LED_off(void) {} -void yellow_LED_off(void) __attribute__((weak, alias("__yellow_LED_off"))); -inline void __blue_LED_on(void) {} -void blue_LED_on(void) __attribute__((weak, alias("__blue_LED_on"))); -inline void __blue_LED_off(void) {} -void blue_LED_off(void) __attribute__((weak, alias("__blue_LED_off"))); +inline void __red_led_on(void) {} +void red_led_on(void) __attribute__((weak, alias("__red_led_on"))); +inline void __red_led_off(void) {} +void red_led_off(void) __attribute__((weak, alias("__red_led_off"))); +inline void __green_led_on(void) {} +void green_led_on(void) __attribute__((weak, alias("__green_led_on"))); +inline void __green_led_off(void) {} +void green_led_off(void) __attribute__((weak, alias("__green_led_off"))); +inline void __yellow_led_on(void) {} +void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on"))); +inline void __yellow_led_off(void) {} +void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off"))); +inline void __blue_led_on(void) {} +void blue_led_on(void) __attribute__((weak, alias("__blue_led_on"))); +inline void __blue_led_off(void) {} +void blue_led_off(void) __attribute__((weak, alias("__blue_led_off"))); /* ************************************************************************ @@ -116,16 +108,11 @@ void blue_LED_off(void) __attribute__((weak, alias("__blue_LED_off"))); #if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE) #define CONFIG_BAUDRATE 115200 #endif + static int init_baudrate(void) { - char tmp[64]; /* long enough for environment variables */ - int i = getenv_f("baudrate", tmp, sizeof(tmp)); - - gd->baudrate = (i > 0) - ? (int) simple_strtoul(tmp, NULL, 10) - : CONFIG_BAUDRATE; - - return (0); + gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); + return 0; } static int display_banner(void) @@ -230,14 +217,33 @@ void __dram_init_banksize(void) void dram_init_banksize(void) __attribute__((weak, alias("__dram_init_banksize"))); +int __arch_cpu_init(void) +{ + return 0; +} +int arch_cpu_init(void) + __attribute__((weak, alias("__arch_cpu_init"))); + +int __power_init_board(void) +{ + return 0; +} +int power_init_board(void) + __attribute__((weak, alias("__power_init_board"))); + init_fnc_t *init_sequence[] = { -#if defined(CONFIG_ARCH_CPU_INIT) arch_cpu_init, /* basic arch cpu dependent setup */ -#endif + #if defined(CONFIG_BOARD_EARLY_INIT_F) board_early_init_f, #endif +#ifdef CONFIG_OF_CONTROL + fdtdec_check_fdt, +#endif timer_init, /* initialize timer */ +#ifdef CONFIG_BOARD_POSTCLK_INIT + board_postclk_init, +#endif #ifdef CONFIG_FSL_ESDHC get_clocks, #endif @@ -265,6 +271,13 @@ void board_init_f(ulong bootflag) init_fnc_t **init_fnc_ptr; gd_t *id; ulong addr, addr_sp; +#ifdef CONFIG_PRAM + ulong reg; +#endif + void *new_fdt = NULL; + size_t fdt_size = 0; + + bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f"); /* Pointer is writable since we allocated a register for it */ gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07); @@ -274,6 +287,16 @@ void board_init_f(ulong bootflag) memset((void *)gd, 0, sizeof(gd_t)); gd->mon_len = _bss_end_ofs; +#ifdef CONFIG_OF_EMBED + /* Get a pointer to the FDT */ + gd->fdt_blob = _binary_dt_dtb_start; +#elif defined CONFIG_OF_SEPARATE + /* FDT is at end of image */ + gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE); +#endif + /* Allow the early environment to override the fdt address */ + gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16, + (uintptr_t)gd->fdt_blob); for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) { @@ -281,6 +304,14 @@ void board_init_f(ulong bootflag) } } +#ifdef CONFIG_OF_CONTROL + /* For now, put this check after the console is ready */ + if (fdtdec_prepare_fdt()) { + panic("** CONFIG_OF_CONTROL defined but no FDT - please see " + "doc/README.fdt-control"); + } +#endif + debug("monitor len: %08lX\n", gd->mon_len); /* * Ram is setup, size stored in gd !! @@ -315,9 +346,7 @@ void board_init_f(ulong bootflag) /* * reserve protected RAM */ - i = getenv_r("pram", (char *)tmp, sizeof(tmp)); - reg = (i > 0) ? simple_strtoul((const char *)tmp, NULL, 10) : - CONFIG_PRAM; + reg = getenv_ulong("pram", 10, CONFIG_PRAM); addr -= (reg << 10); /* size is in kB */ debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr); #endif /* CONFIG_PRAM */ @@ -382,6 +411,22 @@ void board_init_f(ulong bootflag) debug("Reserving %zu Bytes for Global Data at: %08lx\n", sizeof (gd_t), addr_sp); +#if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL) + /* + * If the device tree is sitting immediate above our image then we + * must relocate it. If it is embedded in the data section, then it + * will be relocated with other data. + */ + if (gd->fdt_blob) { + fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32); + + addr_sp -= fdt_size; + new_fdt = (void *)addr_sp; + debug("Reserving %zu Bytes for FDT at: %08lx\n", + fdt_size, addr_sp); + } +#endif + /* setup stackpointer for exeptions */ gd->irq_sp = addr_sp; #ifdef CONFIG_USE_IRQ @@ -415,6 +460,10 @@ void board_init_f(ulong bootflag) gd->start_addr_sp = addr_sp; gd->reloc_off = addr - _TEXT_BASE; debug("relocation Offset is: %08lx\n", gd->reloc_off); + if (new_fdt) { + memcpy(new_fdt, gd->fdt_blob, fdt_size); + gd->fdt_blob = new_fdt; + } memcpy(id, (void *)gd, sizeof(gd_t)); relocate_code(addr_sp, id, addr); @@ -439,31 +488,33 @@ static char *failed = "*** failed ***\n"; void board_init_r(gd_t *id, ulong dest_addr) { - char *s; - bd_t *bd; ulong malloc_start; #if !defined(CONFIG_SYS_NO_FLASH) ulong flash_size; #endif gd = id; - bd = gd->bd; gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ + bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r"); monitor_flash_len = _end_ofs; - /* - * Enable D$: - * I$, if needed, must be already enabled in start.S - */ - dcache_enable(); + + /* Enable caches */ + enable_caches(); debug("monitor flash len: %08lX\n", monitor_flash_len); board_init(); /* Setup chipselects */ - -#ifdef CONFIG_SERIAL_MULTI - serial_initialize(); + /* + * TODO: printing of the clock inforamtion of the board is now + * implemented as part of bdinfo command. Currently only support for + * davinci SOC's is added. Remove this check once all the board + * implement this. + */ +#ifdef CONFIG_CLOCKS + set_cpu_clk_info(); /* Setup clock information */ #endif + serial_initialize(); debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); @@ -478,19 +529,25 @@ void board_init_r(gd_t *id, ulong dest_addr) malloc_start = dest_addr - TOTAL_MALLOC_LEN; mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN); +#ifdef CONFIG_ARCH_EARLY_INIT_R + arch_early_init_r(); +#endif + power_init_board(); + #if !defined(CONFIG_SYS_NO_FLASH) puts("Flash: "); flash_size = flash_init(); if (flash_size > 0) { # ifdef CONFIG_SYS_FLASH_CHECKSUM + char *s = getenv("flashchecksum"); + print_size(flash_size, ""); /* * Compute and print flash CRC if flashchecksum is set to 'y' * * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX */ - s = getenv("flashchecksum"); if (s && (*s == 'y')) { printf(" CRC: %08X", crc32(0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, @@ -517,7 +574,7 @@ void board_init_r(gd_t *id, ulong dest_addr) #ifdef CONFIG_GENERIC_MMC puts("MMC: "); - mmc_initialize(bd); + mmc_initialize(gd->bd); #endif #ifdef CONFIG_HAS_DATAFLASH @@ -532,9 +589,6 @@ void board_init_r(gd_t *id, ulong dest_addr) arm_pci_init(); #endif - /* IP Address */ - gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr"); - stdio_init(); /* get the devices list going. */ jumptable_init(); @@ -560,27 +614,10 @@ void board_init_r(gd_t *id, ulong dest_addr) /* enable exceptions */ enable_interrupts(); - /* Perform network card initialisation if necessary */ -#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96) - /* XXX: this needs to be moved to board init */ - if (getenv("ethaddr")) { - uchar enetaddr[6]; - eth_getenv_enetaddr("ethaddr", enetaddr); - smc_set_mac_addr(enetaddr); - } -#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */ - /* Initialize from environment */ - s = getenv("loadaddr"); - if (s != NULL) - load_addr = simple_strtoul(s, NULL, 16); -#if defined(CONFIG_CMD_NET) - s = getenv("bootfile"); - if (s != NULL) - copy_filename(BootFile, s, sizeof(BootFile)); -#endif + load_addr = getenv_ulong("loadaddr", 16, load_addr); -#ifdef BOARD_LATE_INIT +#ifdef CONFIG_BOARD_LATE_INIT board_late_init(); #endif @@ -588,9 +625,7 @@ void board_init_r(gd_t *id, ulong dest_addr) bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) -#if defined(CONFIG_NET_MULTI) puts("Net: "); -#endif eth_initialize(gd->bd); #if defined(CONFIG_RESET_PHY_R) debug("Reset Ethernet PHY\n"); @@ -608,18 +643,11 @@ void board_init_r(gd_t *id, ulong dest_addr) * taking into account the protected RAM at top of memory */ { - ulong pram; + ulong pram = 0; uchar memsz[32]; -#ifdef CONFIG_PRAM - char *s; - s = getenv("pram"); - if (s != NULL) - pram = simple_strtoul(s, NULL, 10); - else - pram = CONFIG_PRAM; -#else - pram = 0; +#ifdef CONFIG_PRAM + pram = getenv_ulong("pram", 10, CONFIG_PRAM); #endif #ifdef CONFIG_LOGBUFFER #ifndef CONFIG_ALT_LB_ADDR