Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: imx-scu: Add SoC UID(unique identifier) support

Add i.MX SCU SoC's UID(unique identifier) support, user
can read it from sysfs:

root@imx8qxpmek:~# cat /sys/devices/soc0/soc_uid
7B64280B57AC1898

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>

authored by

Anson Huang and committed by
Shawn Guo
73feb4d0 77266e72

+39
+39
drivers/soc/imx/soc-imx-scu.c
··· 27 27 } data; 28 28 } __packed; 29 29 30 + struct imx_sc_msg_misc_get_soc_uid { 31 + struct imx_sc_rpc_msg hdr; 32 + u32 uid_low; 33 + u32 uid_high; 34 + } __packed; 35 + 36 + static ssize_t soc_uid_show(struct device *dev, 37 + struct device_attribute *attr, char *buf) 38 + { 39 + struct imx_sc_msg_misc_get_soc_uid msg; 40 + struct imx_sc_rpc_msg *hdr = &msg.hdr; 41 + u64 soc_uid; 42 + int ret; 43 + 44 + hdr->ver = IMX_SC_RPC_VERSION; 45 + hdr->svc = IMX_SC_RPC_SVC_MISC; 46 + hdr->func = IMX_SC_MISC_FUNC_UNIQUE_ID; 47 + hdr->size = 1; 48 + 49 + ret = imx_scu_call_rpc(soc_ipc_handle, &msg, false); 50 + if (ret) { 51 + pr_err("%s: get soc uid failed, ret %d\n", __func__, ret); 52 + return ret; 53 + } 54 + 55 + soc_uid = msg.uid_high; 56 + soc_uid <<= 32; 57 + soc_uid |= msg.uid_low; 58 + 59 + return sprintf(buf, "%016llX\n", soc_uid); 60 + } 61 + 62 + static DEVICE_ATTR_RO(soc_uid); 63 + 30 64 static int imx_scu_soc_id(void) 31 65 { 32 66 struct imx_sc_msg_misc_get_soc_id msg; ··· 135 101 ret = PTR_ERR(soc_dev); 136 102 goto free_revision; 137 103 } 104 + 105 + ret = device_create_file(soc_device_to_device(soc_dev), 106 + &dev_attr_soc_uid); 107 + if (ret) 108 + goto free_revision; 138 109 139 110 return 0; 140 111