]> git.sur5r.net Git - u-boot/blobdiff - lib_blackfin/board.c
mpc8xx/ether.c: fix warning: unused variable 'bd'
[u-boot] / lib_blackfin / board.c
index 30ffba1c0f25b28c1683f290ab8d68c83fb986d8..49465d2a058a706c543b8f7d989c8a2724e9c143 100644 (file)
@@ -16,6 +16,7 @@
 #include <malloc.h>
 #include <net.h>
 #include <timestamp.h>
+#include <status_led.h>
 #include <version.h>
 
 #include <asm/cplb.h>
@@ -43,50 +44,6 @@ static inline void serial_early_puts(const char *s)
 #endif
 }
 
-/* Get the input voltage */
-static u_long get_vco(void)
-{
-       u_long msel;
-       u_long vco;
-
-       msel = (*pPLL_CTL >> 9) & 0x3F;
-       if (0 == msel)
-               msel = 64;
-
-       vco = CONFIG_CLKIN_HZ;
-       vco >>= (1 & *pPLL_CTL);        /* DF bit */
-       vco = msel * vco;
-       return vco;
-}
-
-/* Get the Core clock */
-u_long get_cclk(void)
-{
-       u_long csel, ssel;
-       if (*pPLL_STAT & 0x1)
-               return CONFIG_CLKIN_HZ;
-
-       ssel = *pPLL_DIV;
-       csel = ((ssel >> 4) & 0x03);
-       ssel &= 0xf;
-       if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */
-               return get_vco() / ssel;
-       return get_vco() >> csel;
-}
-
-/* Get the System clock */
-u_long get_sclk(void)
-{
-       u_long ssel;
-
-       if (*pPLL_STAT & 0x1)
-               return CONFIG_CLKIN_HZ;
-
-       ssel = (*pPLL_DIV & 0xf);
-
-       return get_vco() / ssel;
-}
-
 static void *mem_malloc_start, *mem_malloc_end, *mem_malloc_brk;
 
 static void mem_malloc_init(void)
@@ -113,7 +70,11 @@ void *sbrk(ptrdiff_t increment)
 static int display_banner(void)
 {
        printf("\n\n%s\n\n", version_string);
-       printf("CPU:   ADSP " MK_STR(CONFIG_BFIN_CPU) " (Detected Rev: 0.%d)\n", bfin_revid());
+       printf("CPU:   ADSP " MK_STR(CONFIG_BFIN_CPU) " "
+               "(Detected Rev: 0.%d) "
+               "(%s boot)\n",
+               bfin_revid(),
+               get_bfin_boot_mode(CONFIG_BFIN_BOOT_MODE));
        return 0;
 }
 
@@ -145,10 +106,6 @@ static void display_global_data(void)
        printf(" \\-bd: %x\n", gd->bd);
        printf("   |-bi_baudrate: %x\n", bd->bi_baudrate);
        printf("   |-bi_ip_addr: %x\n", bd->bi_ip_addr);
-       printf("   |-bi_enetaddr: %x %x %x %x %x %x\n",
-              bd->bi_enetaddr[0], bd->bi_enetaddr[1],
-              bd->bi_enetaddr[2], bd->bi_enetaddr[3],
-              bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
        printf("   |-bi_boot_params: %x\n", bd->bi_boot_params);
        printf("   |-bi_memstart: %x\n", bd->bi_memstart);
        printf("   |-bi_memsize: %x\n", bd->bi_memsize);
@@ -278,9 +235,13 @@ void board_init_f(ulong bootflag)
        dcache_enable();
 #endif
 
+#ifdef DEBUG
+       if (CONFIG_SYS_GBL_DATA_SIZE < sizeof(*gd))
+               hang();
+#endif
        serial_early_puts("Init global data\n");
        gd = (gd_t *) (CONFIG_SYS_GBL_DATA_ADDR);
-       memset((void *)gd, 0, sizeof(gd_t));
+       memset((void *)gd, 0, CONFIG_SYS_GBL_DATA_SIZE);
 
        /* Board data initialization */
        addr = (CONFIG_SYS_GBL_DATA_ADDR + sizeof(gd_t));
@@ -330,6 +291,25 @@ void board_init_f(ulong bootflag)
        board_init_r((gd_t *) gd, 0x20000010);
 }
 
+static void board_net_init_r(bd_t *bd)
+{
+#ifdef CONFIG_CMD_NET
+       uchar enetaddr[6];
+       char *s;
+
+       if ((s = getenv("bootfile")) != NULL)
+               copy_filename(BootFile, s, sizeof(BootFile));
+
+       bd->bi_ip_addr = getenv_IPaddr("ipaddr");
+
+       printf("Net:   ");
+       eth_initialize(gd->bd);
+
+       eth_getenv_enetaddr("ethaddr", enetaddr);
+       printf("MAC:   %pM\n", enetaddr);
+#endif
+}
+
 void board_init_r(gd_t * id, ulong dest_addr)
 {
        extern void malloc_bin_reloc(void);
@@ -345,14 +325,14 @@ void board_init_r(gd_t * id, ulong dest_addr)
 #endif
 
 #if    !defined(CONFIG_SYS_NO_FLASH)
-       /* There are some other pointer constants we must deal with */
-       /* configure available FLASH banks */
+       /* Initialize the flash and protect u-boot by default */
        extern flash_info_t flash_info[];
-       ulong size = flash_init();
        puts("Flash: ");
+       ulong size = flash_init();
        print_size(size, "\n");
        flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE,
-                     CONFIG_SYS_FLASH_BASE + 0x1ffff, &flash_info[0]);
+               CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN - 1,
+               &flash_info[0]);
        bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
        bd->bi_flashsize = size;
        bd->bi_flashoffset = 0;
@@ -373,35 +353,6 @@ void board_init_r(gd_t * id, ulong dest_addr)
        /* relocate environment function pointers etc. */
        env_relocate();
 
-#ifdef CONFIG_CMD_NET
-       /* board MAC address */
-       s = getenv("ethaddr");
-       if (s == NULL) {
-# ifndef CONFIG_ETHADDR
-#  if 0
-               if (!board_get_enetaddr(bd->bi_enetaddr)) {
-                       char nid[20];
-                       sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",
-                               bd->bi_enetaddr[0], bd->bi_enetaddr[1],
-                               bd->bi_enetaddr[2], bd->bi_enetaddr[3],
-                               bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
-                       setenv("ethaddr", nid);
-               }
-#  endif
-# endif
-       } else {
-               int i;
-               char *e;
-               for (i = 0; i < 6; ++i) {
-                       bd->bi_enetaddr[i] = simple_strtoul(s, &e, 16);
-                       s = (*e) ? e + 1 : e;
-               }
-       }
-
-       /* IP Address */
-       bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-#endif
-
        /* Initialize devices */
        devices_init();
        jumptable_init();
@@ -409,27 +360,21 @@ void board_init_r(gd_t * id, ulong dest_addr)
        /* Initialize the console (after the relocation and devices init) */
        console_init_r();
 
+#ifdef CONFIG_STATUS_LED
+       status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
+       status_led_set(STATUS_LED_CRASH, STATUS_LED_OFF);
+#endif
+
        /* Initialize from environment */
        if ((s = getenv("loadaddr")) != NULL)
                load_addr = simple_strtoul(s, NULL, 16);
-#ifdef CONFIG_CMD_NET
-       if ((s = getenv("bootfile")) != NULL)
-               copy_filename(BootFile, s, sizeof(BootFile));
-#endif
 
 #if defined(CONFIG_MISC_INIT_R)
        /* miscellaneous platform dependent initialisations */
        misc_init_r();
 #endif
 
-#ifdef CONFIG_CMD_NET
-       printf("Net:   ");
-       eth_initialize(gd->bd);
-       if (getenv("ethaddr"))
-               printf("MAC:   %02X:%02X:%02X:%02X:%02X:%02X\n",
-                       bd->bi_enetaddr[0], bd->bi_enetaddr[1], bd->bi_enetaddr[2],
-                       bd->bi_enetaddr[3], bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
-#endif
+       board_net_init_r(bd);
 
        display_global_data();
 
@@ -445,6 +390,10 @@ void board_init_r(gd_t * id, ulong dest_addr)
 
 void hang(void)
 {
+#ifdef CONFIG_STATUS_LED
+       status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
+       status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
+#endif
        puts("### ERROR ### Please RESET the board ###\n");
        while (1)
                /* If a JTAG emulator is hooked up, we'll automatically trigger