summaryrefslogtreecommitdiff
path: root/arch/arm/cpu/armv7/omap-common/utils.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2015-08-27 19:37:12 +0200
committerTom Rini <trini@konsulko.com>2015-10-22 14:17:22 -0400
commit07815eb9f3f742237085e3eda947e095926212b0 (patch)
treeeee6f6372237c7c288f7b59944a38e2ffc2c7756 /arch/arm/cpu/armv7/omap-common/utils.c
parent9fd5401659c34b9b07f5d729ad35611b002830ff (diff)
omap-common: Common serial and usbethaddr functions based on die id
Now that we have a common prototype to grab the omap die id, functions to figure out a serial number and usb ethernet address can use it directly. Those also get an omap_die_id prefix for better consistency. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'arch/arm/cpu/armv7/omap-common/utils.c')
-rw-r--r--arch/arm/cpu/armv7/omap-common/utils.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/arch/arm/cpu/armv7/omap-common/utils.c b/arch/arm/cpu/armv7/omap-common/utils.c
index acff16bd3a..28d0f86251 100644
--- a/arch/arm/cpu/armv7/omap-common/utils.c
+++ b/arch/arm/cpu/armv7/omap-common/utils.c
@@ -46,35 +46,40 @@ __weak void omap_die_id(unsigned int *die_id)
die_id[0] = die_id[1] = die_id[2] = die_id[3] = 0;
}
-void __weak usb_fake_mac_from_die_id(u32 *id)
+void omap_die_id_serial(void)
{
- uint8_t device_mac[6];
+ unsigned int die_id[4] = { 0 };
+ char serial_string[17] = { 0 };
- if (!getenv("usbethaddr")) {
- /*
- * create a fake MAC address from the processor ID code.
- * first byte is 0x02 to signify locally administered.
- */
- device_mac[0] = 0x02;
- device_mac[1] = id[3] & 0xff;
- device_mac[2] = id[2] & 0xff;
- device_mac[3] = id[1] & 0xff;
- device_mac[4] = id[0] & 0xff;
- device_mac[5] = (id[0] >> 8) & 0xff;
+ omap_die_id((unsigned int *)&die_id);
- eth_setenv_enetaddr("usbethaddr", device_mac);
+ if (!getenv("serial#")) {
+ snprintf(serial_string, sizeof(serial_string),
+ "%08x%08x", die_id[0], die_id[3]);
+
+ setenv("serial#", serial_string);
}
}
-void __weak usb_set_serial_num_from_die_id(u32 *id)
+void omap_die_id_usbethaddr(void)
{
- char serialno[72];
- uint32_t serialno_lo, serialno_hi;
+ unsigned int die_id[4] = { 0 };
+ unsigned char mac[6] = { 0 };
- if (!getenv("serial#")) {
- serialno_hi = id[0];
- serialno_lo = id[1];
- sprintf(serialno, "%08x%08x", serialno_hi, serialno_lo);
- setenv("serial#", serialno);
+ omap_die_id((unsigned int *)&die_id);
+
+ if (!getenv("usbethaddr")) {
+ /*
+ * Create a fake MAC address from the processor ID code.
+ * First byte is 0x02 to signify locally administered.
+ */
+ mac[0] = 0x02;
+ mac[1] = die_id[3] & 0xff;
+ mac[2] = die_id[2] & 0xff;
+ mac[3] = die_id[1] & 0xff;
+ mac[4] = die_id[0] & 0xff;
+ mac[5] = (die_id[0] >> 8) & 0xff;
+
+ eth_setenv_enetaddr("usbethaddr", mac);
}
}