Merge tag 'timers-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / arch / arm / mach-mxs / mach-mxs.c
index c109f47..25c9d18 100644 (file)
@@ -22,6 +22,7 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
+#include <asm/system_info.h>
 #include <asm/system_misc.h>
 
 #include "pm.h"
@@ -51,6 +52,9 @@
 #define MXS_CLR_ADDR           0x8
 #define MXS_TOG_ADDR           0xc
 
+#define HW_OCOTP_OPS2          19      /* offset 0x150 */
+#define HW_OCOTP_OPS3          20      /* offset 0x160 */
+
 static u32 chipid;
 static u32 socid;
 
@@ -379,6 +383,8 @@ static void __init mxs_machine_init(void)
        struct device *parent;
        struct soc_device *soc_dev;
        struct soc_device_attribute *soc_dev_attr;
+       u64 soc_uid = 0;
+       const u32 *ocotp = mxs_get_ocotp();
        int ret;
 
        soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
@@ -394,8 +400,21 @@ static void __init mxs_machine_init(void)
        soc_dev_attr->soc_id = mxs_get_soc_id();
        soc_dev_attr->revision = mxs_get_revision();
 
+       if (socid == HW_DIGCTL_CHIPID_MX23) {
+               soc_uid = system_serial_low = ocotp[HW_OCOTP_OPS3];
+       } else if (socid == HW_DIGCTL_CHIPID_MX28) {
+               soc_uid = system_serial_high = ocotp[HW_OCOTP_OPS2];
+               soc_uid <<= 32;
+               system_serial_low = ocotp[HW_OCOTP_OPS3];
+               soc_uid |= system_serial_low;
+       }
+
+       if (soc_uid)
+               soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
+
        soc_dev = soc_device_register(soc_dev_attr);
        if (IS_ERR(soc_dev)) {
+               kfree(soc_dev_attr->serial_number);
                kfree(soc_dev_attr->revision);
                kfree(soc_dev_attr);
                return;