diff options
author | Hans de Goede <hdegoede@redhat.com> | 2014-11-26 00:04:24 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2015-01-14 14:56:36 +0100 |
commit | cac5b1cc0d6daa0c0a037fd24a87d4db4e0a1456 (patch) | |
tree | a24c15323e90e3a930db7c88dcfabfa927547bfb /board | |
parent | f3fba5665b066615a39d157a4a4970824695b91d (diff) | |
download | u-boot-imx-cac5b1cc0d6daa0c0a037fd24a87d4db4e0a1456.zip u-boot-imx-cac5b1cc0d6daa0c0a037fd24a87d4db4e0a1456.tar.gz u-boot-imx-cac5b1cc0d6daa0c0a037fd24a87d4db4e0a1456.tar.bz2 |
sunxi: Add sunxi_get_sid helper function
On sun6i the SID is stored in the pmic, rather then in the SoC itself,
add a helper function to abstract this away.
This makes our MAC address generation code also work on sun6i.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Diffstat (limited to 'board')
-rw-r--r-- | board/sunxi/board.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 4c1c69a..b5dfe95 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -217,22 +217,20 @@ void sunxi_board_init(void) #ifdef CONFIG_MISC_INIT_R int misc_init_r(void) { - if (!getenv("ethaddr")) { - uint32_t reg_val = readl(SUNXI_SID_BASE); + unsigned int sid[4]; - if (reg_val) { - uint8_t mac_addr[6]; + if (!getenv("ethaddr") && sunxi_get_sid(sid) == 0 && + sid[0] != 0 && sid[3] != 0) { + uint8_t mac_addr[6]; - mac_addr[0] = 0x02; /* Non OUI / registered MAC address */ - mac_addr[1] = (reg_val >> 0) & 0xff; - reg_val = readl(SUNXI_SID_BASE + 0x0c); - mac_addr[2] = (reg_val >> 24) & 0xff; - mac_addr[3] = (reg_val >> 16) & 0xff; - mac_addr[4] = (reg_val >> 8) & 0xff; - mac_addr[5] = (reg_val >> 0) & 0xff; + mac_addr[0] = 0x02; /* Non OUI / registered MAC address */ + mac_addr[1] = (sid[0] >> 0) & 0xff; + mac_addr[2] = (sid[3] >> 24) & 0xff; + mac_addr[3] = (sid[3] >> 16) & 0xff; + mac_addr[4] = (sid[3] >> 8) & 0xff; + mac_addr[5] = (sid[3] >> 0) & 0xff; - eth_setenv_enetaddr("ethaddr", mac_addr); - } + eth_setenv_enetaddr("ethaddr", mac_addr); } return 0; |