treewide: drop executable file attrib for non-executable files
[oweals/u-boot_mod.git] / u-boot / lib_mips / board.c
old mode 100755 (executable)
new mode 100644 (file)
index eebff3c..68a95eb
@@ -43,6 +43,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define        TOTAL_MALLOC_LEN        CFG_MALLOC_LEN
 #endif
 
+#define CHECK_BIT(var,pos)     ((var) & (1<<(pos)))
+
 extern ulong uboot_end_data;
 extern ulong uboot_end;
 
@@ -55,7 +57,7 @@ extern void ar7240_sys_frequency(u32 *cpu_freq, u32 *ddr_freq, u32 *ahb_freq);
 
 ulong monitor_flash_len;
 
-const char version_string[] = U_BOOT_VERSION"  (" __DATE__ ")";
+const char version_string[] = U_BOOT_VERSION"  (" __DATE__ ", " __TIME__ ")";
 
 // Begin and End of memory area for malloc(), and current "brk"
 static ulong mem_malloc_start;
@@ -85,7 +87,15 @@ void *sbrk(ptrdiff_t increment){
 }
 
 static int display_banner(void){
-       printf("\n\n*********************************************\n*        %s        *\n*********************************************\n\n", version_string);
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+       printf("\n\n*********************************************\n*   %s   *\n*********************************************\n\n", version_string);
+#else
+       printf("\n\n*********************************************\n");
+       printf("*                                           *\n");
+       printf("*                RAM VERSION                *\n");
+       printf("*                                           *\n");
+       printf("*********************************************\n*   %s   *\n*********************************************\n\n", version_string);
+#endif
        return(0);
 }
 
@@ -99,7 +109,12 @@ static int init_func_ram(void){
        puts("DRAM:   ");
 
        if((gd->ram_size = initdram()) > 0){
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
                print_size(gd->ram_size, print_mem_type());
+#else
+               // TODO: fix me!
+               print_size(gd->ram_size + 1024*1024, print_mem_type());
+#endif
                puts("\n");
                return(0);
        }
@@ -301,9 +316,10 @@ void board_init_r(gd_t *id, ulong dest_addr){
        extern char * env_name_spec;
 #endif
        bd_t *bd;
-       int i;
        char *s;
+#if defined(OFFSET_MAC_ADDRESS)
        unsigned char buffer[6];
+#endif
        unsigned int ahb_freq, ddr_freq, cpu_freq, spi_freq;
 
        gd = id;
@@ -392,21 +408,37 @@ void board_init_r(gd_t *id, ulong dest_addr){
        /* board MAC address */
 #if defined(OFFSET_MAC_ADDRESS)
        memcpy(buffer, (void *)(CFG_FLASH_BASE + OFFSET_MAC_DATA_BLOCK + OFFSET_MAC_ADDRESS), 6);
+
+       /*
+        * check first LSBit (I/G bit) and second LSBit (U/L bit) in MSByte of vendor part
+        * both of them should be 0:
+        * I/G bit == 0 -> Individual MAC address (unicast address)
+        * U/L bit == 0 -> Burned-In-Address (BIA) MAC address
+        */
+       if(CHECK_BIT((buffer[0] & 0xFF), 0) != 0 || CHECK_BIT((buffer[0] & 0xFF), 1) != 0){
+               // 00-03-7F (Atheros Communications, Inc.)
+               bd->bi_enetaddr[0] = 0x00;
+               bd->bi_enetaddr[1] = 0x03;
+               bd->bi_enetaddr[2] = 0x7f;
+               bd->bi_enetaddr[3] = 0x09;
+               bd->bi_enetaddr[4] = 0x0b;
+               bd->bi_enetaddr[5] = 0xad;
+
+               printf("## Error: MAC is invalid, using fixed!\n\n");
+       }
 #else
        // fake MAC
        // 00-03-7F (Atheros Communications, Inc.)
-       buffer[0] = 0x00;
-       buffer[1] = 0x03;
-       buffer[2] = 0x7f;
-       buffer[3] = 0x09;
-       buffer[4] = 0x0b;
-       buffer[5] = 0xad;
+       bd->bi_enetaddr[0] = 0x00;
+       bd->bi_enetaddr[1] = 0x03;
+       bd->bi_enetaddr[2] = 0x7f;
+       bd->bi_enetaddr[3] = 0x09;
+       bd->bi_enetaddr[4] = 0x0b;
+       bd->bi_enetaddr[5] = 0xad;
+
+       printf("** Warning: using fixed MAC address!\n\n");
 #endif
 
-       for(i = 0; i < 6; ++i){
-               bd->bi_enetaddr[i] = buffer[i];
-       }
-
        /* IP Address */
        bd->bi_ip_addr = getenv_IPaddr("ipaddr");