]> git.sur5r.net Git - u-boot/commitdiff
da850evm: read mac address from I2C EEPROM on AM18x EVM
authorHadli, Manjunath <manjunath.hadli@ti.com>
Thu, 9 Feb 2012 20:22:25 +0000 (20:22 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Mon, 27 Feb 2012 20:19:24 +0000 (21:19 +0100)
add support to read mac address for AM18x EVM manufactured from
Spectrum digital which have mac address stored in I2C EEPROM manufactured
by WINBOND. This patch reads mac address from I2C EEPROM and sets the
environment variable if not set, If mac address is already present in
environment compare it with the mac address in EEPROM and warn on
mismatch.Introduced a config option CONFIG_MAC_ADDR_IN_EEPROM to where
to look for the mac address.

Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com>
Cc: Tom Rini <trini@ti.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Wolfgang Denk <wd@denx.de>
board/davinci/da8xxevm/da850evm.c
boards.cfg

index beb56575e3bffe4e5b5382b24687517bd259d756..004d5ad6d493d80229865c09aee505a2b6c9936c 100644 (file)
@@ -132,13 +132,17 @@ int misc_init_r(void)
 {
        dspwake();
 
-#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+#if defined(CONFIG_MAC_ADDR_IN_SPIFLASH) || defined(CONFIG_MAC_ADDR_IN_EEPROM)
+
        uchar env_enetaddr[6];
        int enetaddr_found;
+
+       enetaddr_found = eth_getenv_enetaddr("ethaddr", env_enetaddr);
+
+#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
        int spi_mac_read;
        uchar buff[6];
 
-       enetaddr_found = eth_getenv_enetaddr("ethaddr", env_enetaddr);
        spi_mac_read = get_mac_addr(buff);
 
        /*
@@ -169,6 +173,33 @@ int misc_init_r(void)
                                        "with the MAC address in the environment\n");
                        printf("Default using MAC address from environment\n");
        }
+#endif
+       uint8_t enetaddr[8];
+       int eeprom_mac_read;
+
+       /* Read Ethernet MAC address from EEPROM */
+       eeprom_mac_read = dvevm_read_mac_address(enetaddr);
+
+       /*
+        * MAC address not present in the environment
+        * try and read the MAC address from EEPROM flash
+        * and set it.
+        */
+       if (!enetaddr_found) {
+               if (eeprom_mac_read)
+                       /* Set Ethernet MAC address from EEPROM */
+                       davinci_sync_env_enetaddr(enetaddr);
+       } else {
+               /*
+                * MAC address present in environment compare it with
+                * the MAC address in EEPROM and warn on mismatch
+                */
+               if (eeprom_mac_read && memcmp(enetaddr, env_enetaddr, 6))
+                       printf("Warning: MAC address in EEPROM don't match "
+                                       "with the MAC address in the environment\n");
+                       printf("Default using MAC address from environment\n");
+       }
+
 #endif
        return 0;
 }
index 5610dafac60817694fd5b35ec990368bee9a37c7..a61422b84c124640dcb2a4cc4bf90c151a145ca4 100644 (file)
@@ -120,7 +120,7 @@ pm9263                       arm         arm926ejs   pm9263              ronetix
 pm9g45                       arm         arm926ejs   pm9g45              ronetix        at91        pm9g45:AT91SAM9G45
 cam_enc_4xx                  arm         arm926ejs   cam_enc_4xx         ait            davinci     cam_enc_4xx
 da830evm                     arm         arm926ejs   da8xxevm            davinci        davinci
-da850_am18xxevm              arm         arm926ejs   da8xxevm            davinci        davinci     da850evm:DA850_AM18X_EVM
+da850_am18xxevm              arm         arm926ejs   da8xxevm            davinci        davinci     da850evm:DA850_AM18X_EVM,MAC_ADDR_IN_EEPROM,SYS_I2C_EEPROM_ADDR_LEN=2,SYS_I2C_EEPROM_ADDR=0x50
 da850evm                     arm         arm926ejs   da8xxevm            davinci        davinci     da850evm:MAC_ADDR_IN_SPIFLASH
 davinci_dm355evm             arm         arm926ejs   dm355evm            davinci        davinci
 davinci_dm355leopard         arm         arm926ejs   dm355leopard        davinci        davinci