* [PATCH] soc: imx8mp: support 128 bits UID
@ 2023-10-08 8:38 Peng Fan (OSS)
2023-10-10 2:38 ` Shawn Guo
2023-10-10 5:20 ` Marco Felsch
0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan (OSS) @ 2023-10-08 8:38 UTC (permalink / raw)
To: shawnguo, s.hauer
Cc: kernel, festevam, linux-imx, linux-arm-kernel, linux-kernel,
Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Current driver only supports 64bits UID for i.MX8MP, but
i.MX8MP UID is actually 128bits, the high 64bits is at 0xE00.
So update driver to support it.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/soc/imx/soc-imx8m.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
index ec87d9d878f3..5dcc227d41c0 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -24,6 +24,7 @@
#define OCOTP_UID_HIGH 0x420
#define IMX8MP_OCOTP_UID_OFFSET 0x10
+#define IMX8MP_OCOTP_UID_HIGH 0xE00
/* Same as ANADIG_DIGPROG_IMX7D */
#define ANADIG_DIGPROG_IMX8MM 0x800
@@ -34,6 +35,7 @@ struct imx8_soc_data {
};
static u64 soc_uid;
+static u64 soc_uid_h;
#ifdef CONFIG_HAVE_ARM_SMCCC
static u32 imx8mq_soc_revision_from_atf(void)
@@ -122,8 +124,15 @@ static void __init imx8mm_soc_uid(void)
soc_uid <<= 32;
soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
+ if (offset) {
+ soc_uid_h = readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH + 0x10);
+ soc_uid_h <<= 32;
+ soc_uid_h |= readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH);
+ }
+
clk_disable_unprepare(clk);
clk_put(clk);
+
iounmap(ocotp_base);
of_node_put(np);
}
@@ -222,7 +231,12 @@ static int __init imx8_soc_init(void)
goto free_soc;
}
- soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
+ if (soc_uid_h) {
+ soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX%016llX",
+ soc_uid_h, soc_uid);
+ } else {
+ soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
+ }
if (!soc_dev_attr->serial_number) {
ret = -ENOMEM;
goto free_rev;
--
2.37.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] soc: imx8mp: support 128 bits UID
2023-10-08 8:38 [PATCH] soc: imx8mp: support 128 bits UID Peng Fan (OSS)
@ 2023-10-10 2:38 ` Shawn Guo
2023-10-10 5:20 ` Marco Felsch
1 sibling, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2023-10-10 2:38 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: s.hauer, kernel, festevam, linux-imx, linux-arm-kernel,
linux-kernel, Peng Fan
On Sun, Oct 08, 2023 at 04:38:08PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Current driver only supports 64bits UID for i.MX8MP, but
> i.MX8MP UID is actually 128bits, the high 64bits is at 0xE00.
> So update driver to support it.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/soc/imx/soc-imx8m.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
> index ec87d9d878f3..5dcc227d41c0 100644
> --- a/drivers/soc/imx/soc-imx8m.c
> +++ b/drivers/soc/imx/soc-imx8m.c
> @@ -24,6 +24,7 @@
> #define OCOTP_UID_HIGH 0x420
>
> #define IMX8MP_OCOTP_UID_OFFSET 0x10
> +#define IMX8MP_OCOTP_UID_HIGH 0xE00
Lowercase for hex values just like other macros in the file?
>
> /* Same as ANADIG_DIGPROG_IMX7D */
> #define ANADIG_DIGPROG_IMX8MM 0x800
> @@ -34,6 +35,7 @@ struct imx8_soc_data {
> };
>
> static u64 soc_uid;
> +static u64 soc_uid_h;
>
> #ifdef CONFIG_HAVE_ARM_SMCCC
> static u32 imx8mq_soc_revision_from_atf(void)
> @@ -122,8 +124,15 @@ static void __init imx8mm_soc_uid(void)
> soc_uid <<= 32;
> soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
>
> + if (offset) {
> + soc_uid_h = readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH + 0x10);
> + soc_uid_h <<= 32;
> + soc_uid_h |= readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH);
> + }
> +
> clk_disable_unprepare(clk);
> clk_put(clk);
> +
Unrelated change.
> iounmap(ocotp_base);
> of_node_put(np);
> }
> @@ -222,7 +231,12 @@ static int __init imx8_soc_init(void)
> goto free_soc;
> }
>
> - soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
> + if (soc_uid_h) {
> + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX%016llX",
> + soc_uid_h, soc_uid);
> + } else {
> + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
> + }
Unnecessary braces for single statement.
Also it would be nice to have a newline here.
Shawn
> if (!soc_dev_attr->serial_number) {
> ret = -ENOMEM;
> goto free_rev;
> --
> 2.37.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] soc: imx8mp: support 128 bits UID
2023-10-08 8:38 [PATCH] soc: imx8mp: support 128 bits UID Peng Fan (OSS)
2023-10-10 2:38 ` Shawn Guo
@ 2023-10-10 5:20 ` Marco Felsch
1 sibling, 0 replies; 3+ messages in thread
From: Marco Felsch @ 2023-10-10 5:20 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: shawnguo, s.hauer, Peng Fan, linux-kernel, linux-imx, kernel,
festevam, linux-arm-kernel
Hi Peng,
On 23-10-08, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Current driver only supports 64bits UID for i.MX8MP, but
> i.MX8MP UID is actually 128bits, the high 64bits is at 0xE00.
> So update driver to support it.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/soc/imx/soc-imx8m.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
> index ec87d9d878f3..5dcc227d41c0 100644
> --- a/drivers/soc/imx/soc-imx8m.c
> +++ b/drivers/soc/imx/soc-imx8m.c
> @@ -24,6 +24,7 @@
> #define OCOTP_UID_HIGH 0x420
>
> #define IMX8MP_OCOTP_UID_OFFSET 0x10
> +#define IMX8MP_OCOTP_UID_HIGH 0xE00
^
0xe00
> /* Same as ANADIG_DIGPROG_IMX7D */
> #define ANADIG_DIGPROG_IMX8MM 0x800
> @@ -34,6 +35,7 @@ struct imx8_soc_data {
> };
>
> static u64 soc_uid;
> +static u64 soc_uid_h;
>
> #ifdef CONFIG_HAVE_ARM_SMCCC
> static u32 imx8mq_soc_revision_from_atf(void)
> @@ -122,8 +124,15 @@ static void __init imx8mm_soc_uid(void)
> soc_uid <<= 32;
> soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
>
> + if (offset) {
> + soc_uid_h = readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH + 0x10);
> + soc_uid_h <<= 32;
> + soc_uid_h |= readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH);
> + }
Since the function is very small and with this addition the shared code
is very limited. So I would rather tend to have a separate
imx8mp_soc_uid() function.
> +
> clk_disable_unprepare(clk);
> clk_put(clk);
> +
> iounmap(ocotp_base);
> of_node_put(np);
> }
> @@ -222,7 +231,12 @@ static int __init imx8_soc_init(void)
> goto free_soc;
> }
>
> - soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
> + if (soc_uid_h) {
We already do have match data can't we do something like this:
if (id->uid_128bit)
soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX%016llX",
soc_uid_h, soc_uid);
else
soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
Regards,
Marco
> + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX%016llX",
> + soc_uid_h, soc_uid);
> + } else {
> + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
> + }
> if (!soc_dev_attr->serial_number) {
> ret = -ENOMEM;
> goto free_rev;
> --
> 2.37.1
>
>
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-10 5:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-08 8:38 [PATCH] soc: imx8mp: support 128 bits UID Peng Fan (OSS)
2023-10-10 2:38 ` Shawn Guo
2023-10-10 5:20 ` Marco Felsch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox