linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3] soc: imx-scu: Add SoC UID(unique identifier) support
@ 2019-07-02  7:45 Anson.Huang
  2019-07-18  8:22 ` Shawn Guo
  2019-08-12 12:35 ` Shawn Guo
  0 siblings, 2 replies; 4+ messages in thread
From: Anson.Huang @ 2019-07-02  7:45 UTC (permalink / raw)
  To: shawnguo, s.hauer, kernel, festevam, aisheng.dong, abel.vesa,
	linux-arm-kernel, linux-kernel, m.felsch
  Cc: Linux-imx

From: Anson Huang <Anson.Huang@nxp.com>

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>
---
Change since V2:
	- The SCU FW API for getting UID does NOT have response, so we should set
	  imx_scu_call_rpc()'s 3rd parameter as false and still can check the returned
	  value, and comment is no needed any more.
---
 drivers/soc/imx/soc-imx-scu.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/soc/imx/soc-imx-scu.c b/drivers/soc/imx/soc-imx-scu.c
index 676f612..50831eb 100644
--- a/drivers/soc/imx/soc-imx-scu.c
+++ b/drivers/soc/imx/soc-imx-scu.c
@@ -27,6 +27,40 @@ struct imx_sc_msg_misc_get_soc_id {
 	} data;
 } __packed;
 
+struct imx_sc_msg_misc_get_soc_uid {
+	struct imx_sc_rpc_msg hdr;
+	u32 uid_low;
+	u32 uid_high;
+} __packed;
+
+static ssize_t soc_uid_show(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	struct imx_sc_msg_misc_get_soc_uid msg;
+	struct imx_sc_rpc_msg *hdr = &msg.hdr;
+	u64 soc_uid;
+	int ret;
+
+	hdr->ver = IMX_SC_RPC_VERSION;
+	hdr->svc = IMX_SC_RPC_SVC_MISC;
+	hdr->func = IMX_SC_MISC_FUNC_UNIQUE_ID;
+	hdr->size = 1;
+
+	ret = imx_scu_call_rpc(soc_ipc_handle, &msg, false);
+	if (ret) {
+		pr_err("%s: get soc uid failed, ret %d\n", __func__, ret);
+		return ret;
+	}
+
+	soc_uid = msg.uid_high;
+	soc_uid <<= 32;
+	soc_uid |= msg.uid_low;
+
+	return sprintf(buf, "%016llX\n", soc_uid);
+}
+
+static DEVICE_ATTR_RO(soc_uid);
+
 static int imx_scu_soc_id(void)
 {
 	struct imx_sc_msg_misc_get_soc_id msg;
@@ -102,6 +136,11 @@ static int imx_scu_soc_probe(struct platform_device *pdev)
 		goto free_revision;
 	}
 
+	ret = device_create_file(soc_device_to_device(soc_dev),
+				 &dev_attr_soc_uid);
+	if (ret)
+		goto free_revision;
+
 	return 0;
 
 free_revision:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] soc: imx-scu: Add SoC UID(unique identifier) support
  2019-07-02  7:45 [PATCH V3] soc: imx-scu: Add SoC UID(unique identifier) support Anson.Huang
@ 2019-07-18  8:22 ` Shawn Guo
  2019-08-06  6:04   ` Anson Huang
  2019-08-12 12:35 ` Shawn Guo
  1 sibling, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2019-07-18  8:22 UTC (permalink / raw)
  To: Anson.Huang, Marco Felsch
  Cc: s.hauer, kernel, festevam, aisheng.dong, abel.vesa,
	linux-arm-kernel, linux-kernel, Linux-imx

On Tue, Jul 02, 2019 at 03:45:45PM +0800, Anson.Huang@nxp.com wrote:
> From: Anson Huang <Anson.Huang@nxp.com>
> 
> 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>

@Marco, are you happy with it?

Shawn

> ---
> Change since V2:
> 	- The SCU FW API for getting UID does NOT have response, so we should set
> 	  imx_scu_call_rpc()'s 3rd parameter as false and still can check the returned
> 	  value, and comment is no needed any more.
> ---
>  drivers/soc/imx/soc-imx-scu.c | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/drivers/soc/imx/soc-imx-scu.c b/drivers/soc/imx/soc-imx-scu.c
> index 676f612..50831eb 100644
> --- a/drivers/soc/imx/soc-imx-scu.c
> +++ b/drivers/soc/imx/soc-imx-scu.c
> @@ -27,6 +27,40 @@ struct imx_sc_msg_misc_get_soc_id {
>  	} data;
>  } __packed;
>  
> +struct imx_sc_msg_misc_get_soc_uid {
> +	struct imx_sc_rpc_msg hdr;
> +	u32 uid_low;
> +	u32 uid_high;
> +} __packed;
> +
> +static ssize_t soc_uid_show(struct device *dev,
> +			    struct device_attribute *attr, char *buf)
> +{
> +	struct imx_sc_msg_misc_get_soc_uid msg;
> +	struct imx_sc_rpc_msg *hdr = &msg.hdr;
> +	u64 soc_uid;
> +	int ret;
> +
> +	hdr->ver = IMX_SC_RPC_VERSION;
> +	hdr->svc = IMX_SC_RPC_SVC_MISC;
> +	hdr->func = IMX_SC_MISC_FUNC_UNIQUE_ID;
> +	hdr->size = 1;
> +
> +	ret = imx_scu_call_rpc(soc_ipc_handle, &msg, false);
> +	if (ret) {
> +		pr_err("%s: get soc uid failed, ret %d\n", __func__, ret);
> +		return ret;
> +	}
> +
> +	soc_uid = msg.uid_high;
> +	soc_uid <<= 32;
> +	soc_uid |= msg.uid_low;
> +
> +	return sprintf(buf, "%016llX\n", soc_uid);
> +}
> +
> +static DEVICE_ATTR_RO(soc_uid);
> +
>  static int imx_scu_soc_id(void)
>  {
>  	struct imx_sc_msg_misc_get_soc_id msg;
> @@ -102,6 +136,11 @@ static int imx_scu_soc_probe(struct platform_device *pdev)
>  		goto free_revision;
>  	}
>  
> +	ret = device_create_file(soc_device_to_device(soc_dev),
> +				 &dev_attr_soc_uid);
> +	if (ret)
> +		goto free_revision;
> +
>  	return 0;
>  
>  free_revision:
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH V3] soc: imx-scu: Add SoC UID(unique identifier) support
  2019-07-18  8:22 ` Shawn Guo
@ 2019-08-06  6:04   ` Anson Huang
  0 siblings, 0 replies; 4+ messages in thread
From: Anson Huang @ 2019-08-06  6:04 UTC (permalink / raw)
  To: Shawn Guo, Marco Felsch
  Cc: s.hauer, kernel, festevam, Aisheng Dong, Abel Vesa,
	linux-arm-kernel, linux-kernel, dl-linux-imx

Hi, Marco
	Are you OK with this patch?

Thanks,
Anson.

> On Tue, Jul 02, 2019 at 03:45:45PM +0800, Anson.Huang@nxp.com wrote:
> > From: Anson Huang <Anson.Huang@nxp.com>
> >
> > 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>
> 
> @Marco, are you happy with it?
> 
> Shawn
> 
> > ---
> > Change since V2:
> > 	- The SCU FW API for getting UID does NOT have response, so we
> should set
> > 	  imx_scu_call_rpc()'s 3rd parameter as false and still can check the
> returned
> > 	  value, and comment is no needed any more.
> > ---
> >  drivers/soc/imx/soc-imx-scu.c | 39
> > +++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 39 insertions(+)
> >
> > diff --git a/drivers/soc/imx/soc-imx-scu.c
> > b/drivers/soc/imx/soc-imx-scu.c index 676f612..50831eb 100644
> > --- a/drivers/soc/imx/soc-imx-scu.c
> > +++ b/drivers/soc/imx/soc-imx-scu.c
> > @@ -27,6 +27,40 @@ struct imx_sc_msg_misc_get_soc_id {
> >  	} data;
> >  } __packed;
> >
> > +struct imx_sc_msg_misc_get_soc_uid {
> > +	struct imx_sc_rpc_msg hdr;
> > +	u32 uid_low;
> > +	u32 uid_high;
> > +} __packed;
> > +
> > +static ssize_t soc_uid_show(struct device *dev,
> > +			    struct device_attribute *attr, char *buf) {
> > +	struct imx_sc_msg_misc_get_soc_uid msg;
> > +	struct imx_sc_rpc_msg *hdr = &msg.hdr;
> > +	u64 soc_uid;
> > +	int ret;
> > +
> > +	hdr->ver = IMX_SC_RPC_VERSION;
> > +	hdr->svc = IMX_SC_RPC_SVC_MISC;
> > +	hdr->func = IMX_SC_MISC_FUNC_UNIQUE_ID;
> > +	hdr->size = 1;
> > +
> > +	ret = imx_scu_call_rpc(soc_ipc_handle, &msg, false);
> > +	if (ret) {
> > +		pr_err("%s: get soc uid failed, ret %d\n", __func__, ret);
> > +		return ret;
> > +	}
> > +
> > +	soc_uid = msg.uid_high;
> > +	soc_uid <<= 32;
> > +	soc_uid |= msg.uid_low;
> > +
> > +	return sprintf(buf, "%016llX\n", soc_uid); }
> > +
> > +static DEVICE_ATTR_RO(soc_uid);
> > +
> >  static int imx_scu_soc_id(void)
> >  {
> >  	struct imx_sc_msg_misc_get_soc_id msg; @@ -102,6 +136,11 @@
> static
> > int imx_scu_soc_probe(struct platform_device *pdev)
> >  		goto free_revision;
> >  	}
> >
> > +	ret = device_create_file(soc_device_to_device(soc_dev),
> > +				 &dev_attr_soc_uid);
> > +	if (ret)
> > +		goto free_revision;
> > +
> >  	return 0;
> >
> >  free_revision:
> > --
> > 2.7.4
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] soc: imx-scu: Add SoC UID(unique identifier) support
  2019-07-02  7:45 [PATCH V3] soc: imx-scu: Add SoC UID(unique identifier) support Anson.Huang
  2019-07-18  8:22 ` Shawn Guo
@ 2019-08-12 12:35 ` Shawn Guo
  1 sibling, 0 replies; 4+ messages in thread
From: Shawn Guo @ 2019-08-12 12:35 UTC (permalink / raw)
  To: Anson.Huang
  Cc: s.hauer, kernel, festevam, aisheng.dong, abel.vesa,
	linux-arm-kernel, linux-kernel, m.felsch, Linux-imx

On Tue, Jul 02, 2019 at 03:45:45PM +0800, Anson.Huang@nxp.com wrote:
> From: Anson Huang <Anson.Huang@nxp.com>
> 
> 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-12 12:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02  7:45 [PATCH V3] soc: imx-scu: Add SoC UID(unique identifier) support Anson.Huang
2019-07-18  8:22 ` Shawn Guo
2019-08-06  6:04   ` Anson Huang
2019-08-12 12:35 ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).