ARM: rockchip: rk3288 set system serial when efuse init
author黄涛 <huangtao@rock-chips.com>
Tue, 16 Sep 2014 11:51:43 +0000 (19:51 +0800)
committer黄涛 <huangtao@rock-chips.com>
Tue, 16 Sep 2014 11:52:02 +0000 (19:52 +0800)
arch/arm/mach-rockchip/efuse.c

index 18eeaa423a07970737d0d27eb13d7a5e79ccc878..d988b313cd1e6ae1f7fb3a0e532ba5f657cc4329 100644 (file)
@@ -6,9 +6,11 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/crc32.h>
 #include <linux/delay.h>
 #include <linux/rockchip/cpu.h>
 #include <linux/rockchip/iomap.h>
+#include <asm/system_info.h>
 #include "efuse.h"
 
 #define efuse_readl(offset) readl_relaxed(RK_EFUSE_VIRT + offset)
@@ -73,6 +75,20 @@ static int rk3288_get_leakage(int ch)
        return efuse_buf[23+ch];
 }
 
+static void __init rk3288_set_system_serial(void)
+{
+       int i;
+       u8 buf[16];
+
+       for (i = 0; i < 8; i++) {
+               buf[i] = efuse_buf[8 + (i << 1)];
+               buf[i + 8] = efuse_buf[7 + (i << 1)];
+       }
+
+       system_serial_low = crc32(0, buf, 8);
+       system_serial_high = crc32(system_serial_low, buf + 8, 8);
+}
+
 int rockchip_efuse_version(void)
 {
        return efuse.efuse_version;
@@ -95,6 +111,7 @@ void __init rockchip_efuse_init(void)
                        efuse.get_leakage = rk3288_get_leakage;
                        efuse.efuse_version = rk3288_get_efuse_version();
                        rockchip_set_cpu_version((efuse_buf[6] >> 4) & 3);
+                       rk3288_set_system_serial();
                } else {
                        pr_err("failed to read eFuse, return %d\n", ret);
                }