mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] nvmem: imx-ocotp-ele: provide machine_id
@ 2024-02-05 13:56 Sascha Hauer
  2024-02-08  7:13 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2024-02-05 13:56 UTC (permalink / raw)
  To: Barebox List

The i.MX93 fusemap has a unique machine id. Use that for providing a
machine_id.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/nvmem/imx-ocotp-ele.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/nvmem/imx-ocotp-ele.c b/drivers/nvmem/imx-ocotp-ele.c
index b748a30b1f..9708d3f4bb 100644
--- a/drivers/nvmem/imx-ocotp-ele.c
+++ b/drivers/nvmem/imx-ocotp-ele.c
@@ -9,6 +9,10 @@
 #include <linux/nvmem-provider.h>
 #include <linux/regmap.h>
 #include <mach/imx/ele.h>
+#include <machine_id.h>
+
+#define UNIQUE_ID_NUM 4
+#define OCOTP_UNIQUE_ID(n) (0xc0 + (n) * 4)
 
 enum fuse_type {
 	FUSE_FSB = 1,
@@ -113,7 +117,20 @@ static int imx_ocotp_cell_pp(void *context, const char *id, unsigned int offset,
 
 static struct regmap_bus imx_ocotp_regmap_bus = {
 	.reg_read = imx_ocotp_reg_read,
-};      
+};
+
+static void imx_ocotp_set_unique_machine_id(struct imx_ocotp_priv *priv)
+{
+	uint32_t unique_id_parts[UNIQUE_ID_NUM];
+	int i;
+
+	for (i = 0; i < UNIQUE_ID_NUM; i++)
+		if (imx_ocotp_reg_read(priv, OCOTP_UNIQUE_ID(i),
+					 &unique_id_parts[i]))
+			return;
+
+	machine_id_set_hashable(unique_id_parts, sizeof(unique_id_parts));
+}
 
 static int imx_ele_ocotp_probe(struct device *dev)
 {
@@ -145,6 +162,9 @@ static int imx_ele_ocotp_probe(struct device *dev)
 	if (IS_ERR(priv->map))
 		return PTR_ERR(priv->map);
 
+	if (IS_ENABLED(CONFIG_MACHINE_ID))
+		imx_ocotp_set_unique_machine_id(priv);
+
 	nvmem = nvmem_regmap_register_with_pp(priv->map, "imx-ocotp",
 					      imx_ocotp_cell_pp);
 	if (IS_ERR(nvmem))
-- 
2.39.2




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

* Re: [PATCH] nvmem: imx-ocotp-ele: provide machine_id
  2024-02-05 13:56 [PATCH] nvmem: imx-ocotp-ele: provide machine_id Sascha Hauer
@ 2024-02-08  7:13 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-02-08  7:13 UTC (permalink / raw)
  To: Barebox List, Sascha Hauer


On Mon, 05 Feb 2024 14:56:42 +0100, Sascha Hauer wrote:
> The i.MX93 fusemap has a unique machine id. Use that for providing a
> machine_id.
> 
> 

Applied, thanks!

[1/1] nvmem: imx-ocotp-ele: provide machine_id
      https://git.pengutronix.de/cgit/barebox/commit/?id=31a6cc5f0936 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-02-08  7:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 13:56 [PATCH] nvmem: imx-ocotp-ele: provide machine_id Sascha Hauer
2024-02-08  7:13 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox