]> git.sur5r.net Git - u-boot/commitdiff
omap-common: Common serial and usbethaddr functions based on die id
authorPaul Kocialkowski <contact@paulk.fr>
Thu, 27 Aug 2015 17:37:12 +0000 (19:37 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 22 Oct 2015 18:17:22 +0000 (14:17 -0400)
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>
arch/arm/cpu/armv7/omap-common/utils.c
arch/arm/include/asm/omap_common.h
board/lge/sniper/sniper.c
board/ti/beagle/beagle.c
board/ti/dra7xx/evm.c
board/ti/omap5_uevm/evm.c
board/ti/panda/panda.c

index acff16bd3a028ab9d9b0b805175bd1e8045660f9..28d0f862515fcaeb003ab02e02ca63e59f2366f3 100644 (file)
@@ -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);
        }
 }
index 6e0b8d75d7b8d9fe0928d2b5ad9f9d1cfd99a012..84522ea0c5fd64bfd9788aa0028fe6c18c4baab9 100644 (file)
@@ -603,8 +603,9 @@ void abb_setup(u32 fuse, u32 ldovbb, u32 setup, u32 control,
               u32 txdone, u32 txdone_mask, u32 opp);
 s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb);
 
-void usb_fake_mac_from_die_id(u32 *id);
-void usb_set_serial_num_from_die_id(u32 *id);
+void omap_die_id_serial(void);
+void omap_die_id_usbethaddr(void);
+
 void recalibrate_iodelay(void);
 
 void omap_smc1(u32 service, u32 val);
index ae9fe693466b3578eca0006c8809d0f22522fda9..cdda76bf4ed49e331e508f2372167e2e10b53598 100644 (file)
@@ -92,8 +92,6 @@ int board_init(void)
 int misc_init_r(void)
 {
        unsigned char keypad_matrix[64] = { 0 };
-       unsigned int die_id[4] = { 0 };
-       char serial_string[17] = { 0 };
        char reboot_mode[2] = { 0 };
        unsigned char keys[3];
        unsigned char data = 0;
@@ -140,14 +138,7 @@ int misc_init_r(void)
 
        /* Serial number */
 
-       omap_die_id(die_id);
-
-       if (!getenv("serial#")) {
-               snprintf(serial_string, sizeof(serial_string),
-                       "%08x%08x", die_id[0], die_id[3]);
-
-               setenv("serial#", serial_string);
-       }
+       omap_die_id_serial();
 
        /* MUSB */
 
index b0d06a5f5bc1576c15277008fab98180de3ce80a..149b5dbac70688e4a64133b5d484c28a94ed52a3 100644 (file)
@@ -506,12 +506,8 @@ int misc_init_r(void)
        musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
 #endif
 
-       if (generate_fake_mac) {
-               unsigned int die_id[4] = { 0 };
-
-               omap_die_id(die_id);
-               usb_fake_mac_from_die_id(die_id);
-       }
+       if (generate_fake_mac)
+               omap_die_id_usbethaddr();
 
        return 0;
 }
index d4f507817ac60842f8bb1a228a2a3e6ef67afa0c..eebec881da5e4b572cde373a0b0ee35281b2061f 100644 (file)
@@ -57,15 +57,12 @@ int board_init(void)
 int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-       unsigned int die_id[4] = { 0 };
-
        if (omap_revision() == DRA722_ES1_0)
                setenv("board_name", "dra72x");
        else
                setenv("board_name", "dra7xx");
 
-       omap_die_id(die_id);
-       usb_set_serial_num_from_die_id(die_id);
+       omap_die_id_serial();
 #endif
        return 0;
 }
index 04840875d6d0fa9457f0373ecce341194efcacef..853f1969ef1f5cd700c1d9c22c01724aa4c25109 100644 (file)
@@ -189,14 +189,11 @@ static void enable_host_clocks(void)
  */
 int misc_init_r(void)
 {
-       unsigned int die_id[4] = { 0 };
-
 #ifdef CONFIG_PALMAS_POWER
        palmas_init_settings();
 #endif
 
-       omap_die_id(die_id);
-       usb_fake_mac_from_die_id(die_id);
+       omap_die_id_usbethaddr();
 
        return 0;
 }
index 4de7ea1872b6a74b8d0d963e6ee325bffbeb2ea6..eb9ce630dceb7eabc4bddf24910acaa61d28d761 100644 (file)
@@ -209,7 +209,6 @@ int misc_init_r(void)
 {
        int phy_type;
        u32 auxclk, altclksrc;
-       unsigned int die_id[4] = { 0 };
 
        /* EHCI is not supported on ES1.0 */
        if (omap_revision() == OMAP4430_ES1_0)
@@ -263,8 +262,7 @@ int misc_init_r(void)
 
        writel(altclksrc, &scrm->altclksrc);
 
-       omap_die_id(die_id);
-       usb_fake_mac_from_die_id(die_id);
+       omap_die_id_usbethaddr();
 
        return 0;
 }