aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Rigby <john.rigby@linaro.org>2011-10-23 22:55:22 -0600
committerJohn Rigby <john.rigby@linaro.org>2012-12-06 12:16:44 -0700
commitc2232c71a01a2483f966b3618b30477583e75c71 (patch)
tree067a63c28c1277141e2bb14ae341deaf24c76e16
parent2f493573627169f1d01f88239811815d5dd61125 (diff)
downloadu-boot-linaro-stable-c2232c71a01a2483f966b3618b30477583e75c71.tar.gz
OMAP3: Beagle: set mac addr from dieid
TODO: share dieid<-->mac addr code between OMAP3 and OMAP4 Signed-off-by: John Rigby <john.rigby@linaro.org>
-rw-r--r--arch/arm/cpu/armv7/omap3/sys_info.c35
-rw-r--r--arch/arm/include/asm/arch-omap3/sys_proto.h1
-rw-r--r--board/ti/beagle/beagle.c23
3 files changed, 59 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv7/omap3/sys_info.c b/arch/arm/cpu/armv7/omap3/sys_info.c
index 3c8011350..10808e5b1 100644
--- a/arch/arm/cpu/armv7/omap3/sys_info.c
+++ b/arch/arm/cpu/armv7/omap3/sys_info.c
@@ -79,6 +79,8 @@ void dieid_num_r(void)
printf("Die ID #%s\n", uid_s);
}
+
+
/******************************************
* get_cpu_type(void) - extract cpu info
******************************************/
@@ -366,3 +368,36 @@ int print_cpuinfo (void)
return 0;
}
#endif /* CONFIG_DISPLAY_CPUINFO */
+
+void omap3_die_id_to_ethernet_mac(u8 *mac, int subtype)
+{
+ struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
+ u32 idcode;
+ u32 id[4];
+
+ idcode = readl(&id_base->idcode);
+ id[0] = readl(&id_base->die_id_0);
+ id[1] = readl(&id_base->die_id_1);
+ id[2] = readl(&id_base->die_id_2);
+ id[3] = readl(&id_base->die_id_3);
+
+ mac[0] = id[2];
+ mac[1] = id[2] >> 8;
+ mac[2] = id[1];
+ mac[3] = id[1] >> 8;
+ mac[4] = id[1] >> 16;
+ mac[5] = id[1] >> 24;
+ /* XOR other chip-specific data with ID */
+ idcode ^= id[3];
+
+ mac[0] ^= idcode;
+ mac[1] ^= idcode >> 8;
+ mac[2] ^= idcode >> 16;
+ mac[3] ^= idcode >> 24;
+
+ /* allow four MACs from this same basic data */
+ mac[1] = (mac[1] & ~0xc0) | ((subtype & 3) << 6);
+
+ /* mark it as not multicast and outside official 80211 MAC namespace */
+ mac[0] = (mac[0] & ~1) | 2;
+}
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 9e52b12aa..f48b17ae8 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -75,4 +75,5 @@ void dieid_num_r(void);
void do_omap3_emu_romcode_call(u32 service_id, u32 parameters);
void omap3_gp_romcode_call(u32 service_id, u32 parameter);
u32 warm_reset(void);
+void omap3_die_id_to_ethernet_mac(u8 *, int);
#endif
diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 6175e1d1a..4e80d6488 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -100,6 +100,29 @@ int board_init(void)
}
/*
+ * Beagle-xM has a usb nic with no ethernet rom so generate a macaddr
+ * from the SOC die-id and set the usbethaddr env var to that
+ * value.
+ */
+int board_eth_init(bd_t *bis)
+{
+ u8 macaddr[6];
+ char usbethaddr[20];
+
+ /*
+ * NB: The 1 here has been found to generate an address
+ * consistent with the kernel.
+ */
+ omap3_die_id_to_ethernet_mac(macaddr, 1);
+ sprintf (usbethaddr, "%02X:%02X:%02X:%02X:%02X:%02X",
+ macaddr[0], macaddr[1],
+ macaddr[2], macaddr[3],
+ macaddr[4], macaddr[5]) ;
+ setenv ("usbethaddr", usbethaddr);
+ return 0;
+}
+
+/*
* Routine: get_board_revision
* Description: Detect if we are running on a Beagle revision Ax/Bx,
* C1/2/3, C4 or xM. This can be done by reading