summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Goger <klaus.goger@theobroma-systems.com>2015-07-30 10:03:51 +0200
committerKlaus Goger <klaus.goger@theobroma-systems.com>2015-07-30 18:44:09 +0200
commit4339646911db35aadfaf2ef17a70b871ad3dd1a3 (patch)
treea99061123e49bcccfc85a7090802e363f5722eca
parentcea17058280a34c9b74affaea053e80fc63c57fd (diff)
ARM: sunxi: pangolin: base mac and serial on eMMC
We have seen axp221 with all zeros in the sid registers. Therefore we base our mac address and serial number on the eMMC serial number as this is the only unique id on the board. Signed-off-by: Klaus Goger <klaus.goger@theobroma-systems.com>
-rw-r--r--board/sunxi/board.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 302a72443b..8e05bc9f4b 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -604,9 +604,45 @@ int last_stage_init(void)
int misc_init_r(void)
{
char serial_string[17] = { 0 };
- unsigned int sid[4];
uint8_t mac_addr[6];
int ret;
+#ifdef CONFIG_SUNXI_PANGOLIN
+ struct mmc *mmc0;
+ struct sunxi_mmc_host {
+ unsigned mmc_no;
+ uint32_t *mclkreg;
+ unsigned fatal_err;
+ struct sunxi_mmc *reg;
+ struct mmc_config cfg;
+ };
+
+ mmc0 = find_mmc_device(1);
+
+ struct sunxi_mmc_host *mmchost = mmc0->priv;
+ /* lookup the real device number to get the eMMC */
+ if(mmchost->mmc_no != 2)
+ mmc0 = find_mmc_device(0);
+
+ if(mmc0->has_init==0)
+ mmc_init(mmc0);
+
+ if (!getenv("ethaddr")) {
+ /* Non OUI / registered MAC address */
+ mac_addr[0] = 0x02;
+ mac_addr[1] = (mmc0->cid[0] >> 24) & 0xff;
+ mac_addr[2] = (mmc0->cid[2] >> 0) & 0xff;
+ mac_addr[3] = (mmc0->cid[3] >> 24) & 0xff;
+ mac_addr[4] = (mmc0->cid[3] >> 16) & 0xff;
+ mac_addr[5] = (mmc0->cid[3] >> 8) & 0xff;
+
+ eth_setenv_enetaddr("ethaddr", mac_addr);
+ }
+
+ snprintf(serial_string, sizeof(serial_string), "%08x%02x%06x",
+ mmc0->cid[0]>>24,mmc0->cid[2]&0xff,mmc0->cid[3]>>8);
+ setenv("serial#", serial_string);
+#else
+ unsigned int sid[4];
ret = sunxi_get_sid(sid);
if (ret == 0 && sid[0] != 0 && sid[3] != 0) {
@@ -629,7 +665,7 @@ int misc_init_r(void)
setenv("serial#", serial_string);
}
}
-
+#endif
#ifndef CONFIG_MACH_SUN9I
ret = sunxi_usb_phy_probe();
if (ret)