]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sunxi: Add sunxi_get_sid helper function
authorHans de Goede <hdegoede@redhat.com>
Tue, 25 Nov 2014 23:04:24 +0000 (00:04 +0100)
committerHans de Goede <hdegoede@redhat.com>
Wed, 14 Jan 2015 13:56:36 +0000 (14:56 +0100)
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>
arch/arm/cpu/armv7/sunxi/cpu_info.c
arch/arm/include/asm/arch-sunxi/cpu.h
board/sunxi/board.c

index 5146dc422f6c911e400d35b6f61b642da838c1f1..7a3a4ca81bf6b048adaeb7157fcb4f9271269aaa 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/clock.h>
+#include <axp221.h>
 
 #ifdef CONFIG_MACH_SUN6I
 int sunxi_get_ss_bonding_id(void)
@@ -72,3 +73,21 @@ int print_cpuinfo(void)
        return 0;
 }
 #endif
+
+int sunxi_get_sid(unsigned int *sid)
+{
+#ifdef CONFIG_MACH_SUN6I
+#ifdef CONFIG_AXP221_POWER
+       return axp221_get_sid(sid);
+#else
+       return -ENODEV;
+#endif
+#else
+       int i;
+
+       for (i = 0; i< 4; i++)
+               sid[i] = readl(SUNXI_SID_BASE + 4 * i);
+
+       return 0;
+#endif
+}
index 8aeed2fc726dfe7c1f5a0846fa2e7056f35d8069..9500262ca93ac79a4eb78aed2f6c58f53669afaa 100644 (file)
 void sunxi_board_init(void);
 void sunxi_reset(void);
 int sunxi_get_ss_bonding_id(void);
+int sunxi_get_sid(unsigned int *sid);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _CPU_H */
index 4c1c69a6ae1381fafc9b0c2b6f1117377ee5c3aa..b5dfe958ad82b3461944abb9c59db66ef3273d4c 100644 (file)
@@ -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;