From: Alexander Dahl <ada@thorsis.com>
To: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: Christian Melki <christian.melki@t2data.com>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP
OTPC DRIVER), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v1 12/12] nvmem: microchip-otpc: Expose UID registers as 2nd nvmem device
Date: Wed, 21 Aug 2024 12:59:43 +0200 [thread overview]
Message-ID: <20240821105943.230281-13-ada@thorsis.com> (raw)
In-Reply-To: <20240821105943.230281-1-ada@thorsis.com>
For SAM9X60 the Product UID x Register containing the Unique Product ID
is part of the OTPC registers. We have everything at hand here to just
create a trivial nvmem device for those.
Signed-off-by: Alexander Dahl <ada@thorsis.com>
---
drivers/nvmem/microchip-otpc.c | 41 +++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c
index 047ca5ac6407..52af4c137204 100644
--- a/drivers/nvmem/microchip-otpc.c
+++ b/drivers/nvmem/microchip-otpc.c
@@ -45,6 +45,9 @@
#define MCHP_OTPC_NAME "mchp-otpc"
#define MCHP_OTPC_SIZE (11 * 1024)
+#define MCHP_OTPC_UID_NAME "mchp-uid"
+#define MCHP_OTPC_UID_SIZE 16
+
/**
* struct mchp_otpc - OTPC private data structure
* @base: base address
@@ -249,6 +252,16 @@ static int mchp_otpc_init_packets_list(struct mchp_otpc *otpc, u32 *size)
return 0;
}
+static int mchp_otpc_uid_read(void *priv, unsigned int offset,
+ void *val, size_t bytes)
+{
+ struct mchp_otpc *otpc = priv;
+
+ memcpy_fromio(val, otpc->base + MCHP_OTPC_UID0R + offset, bytes);
+
+ return 0;
+}
+
static struct nvmem_config mchp_nvmem_config = {
.name = MCHP_OTPC_NAME,
.type = NVMEM_TYPE_OTP,
@@ -258,6 +271,15 @@ static struct nvmem_config mchp_nvmem_config = {
.reg_read = mchp_otpc_read,
};
+static struct nvmem_config mchp_otpc_uid_nvmem_config = {
+ .name = MCHP_OTPC_UID_NAME,
+ .read_only = true,
+ .word_size = 4,
+ .stride = 4,
+ .size = MCHP_OTPC_UID_SIZE,
+ .reg_read = mchp_otpc_uid_read,
+};
+
static int mchp_otpc_probe(struct platform_device *pdev)
{
struct nvmem_device *nvmem;
@@ -303,8 +325,25 @@ static int mchp_otpc_probe(struct platform_device *pdev)
mchp_nvmem_config.size = size;
mchp_nvmem_config.priv = otpc;
nvmem = devm_nvmem_register(&pdev->dev, &mchp_nvmem_config);
+ if (IS_ERR(nvmem)) {
+ dev_err(&pdev->dev,
+ "Error (%ld) registering OTP as nvmem device\n",
+ PTR_ERR(nvmem));
+ return PTR_ERR(nvmem);
+ }
- return PTR_ERR_OR_ZERO(nvmem);
+ mchp_otpc_uid_nvmem_config.dev = otpc->dev;
+ mchp_otpc_uid_nvmem_config.priv = otpc;
+
+ nvmem = devm_nvmem_register(&pdev->dev, &mchp_otpc_uid_nvmem_config);
+ if (IS_ERR(nvmem)) {
+ dev_err(&pdev->dev,
+ "Error (%ld) registering UIDxR as nvmem device\n",
+ PTR_ERR(nvmem));
+ return PTR_ERR(nvmem);
+ }
+
+ return 0;
}
static const struct of_device_id __maybe_unused mchp_otpc_ids[] = {
--
2.39.2
next prev parent reply other threads:[~2024-08-21 11:00 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 10:59 [PATCH v1 00/12] Microchip OTPC driver on SAM9X60 exposing UIDxR as additional " Alexander Dahl
2024-08-21 10:59 ` [PATCH v1 01/12] nvmem: microchip-otpc: Avoid writing a write-only register Alexander Dahl
2024-08-24 15:51 ` claudiu beznea
2024-08-21 10:59 ` [PATCH v1 02/12] nvmem: microchip-otpc: Fix swapped 'sleep' and 'timeout' parameters Alexander Dahl
2024-08-24 15:52 ` claudiu beznea
2024-08-21 10:59 ` [PATCH v1 03/12] dt-bindings: nvmem: microchip-otpc: Add compatible for SAM9X60 Alexander Dahl
2024-08-21 12:49 ` Rob Herring (Arm)
2024-08-21 14:55 ` Conor Dooley
2024-08-21 10:59 ` [PATCH v1 04/12] nvmem: microchip-otpc: Add SAM9X60 support Alexander Dahl
2024-08-24 15:53 ` claudiu beznea
2024-08-28 8:09 ` Alexander Dahl
2024-08-31 15:31 ` claudiu beznea
2024-08-21 10:59 ` [PATCH v1 05/12] ARM: dts: microchip: sam9x60: Add OTPC node Alexander Dahl
2024-08-24 15:56 ` claudiu beznea
2024-08-21 10:59 ` [PATCH v1 06/12] ARM: dts: microchip: sam9x60_curiosity: Enable OTP Controller Alexander Dahl
2024-08-21 10:59 ` [PATCH v1 07/12] nvmem: microchip-otpc: Add missing register definitions Alexander Dahl
2024-08-24 15:54 ` claudiu beznea
2024-08-28 8:14 ` Alexander Dahl
2024-08-31 15:33 ` claudiu beznea
2024-09-02 8:08 ` Alexander Dahl
2024-09-07 12:05 ` claudiu beznea
2024-08-21 10:59 ` [PATCH v1 08/12] nvmem: microchip-otpc: Add warnings for bad OTPC conditions on probe Alexander Dahl
2024-08-24 15:51 ` claudiu beznea
2024-08-21 10:59 ` [PATCH v1 09/12] clk: at91: sam9x60: Allow enabling main_rc_osc through DT Alexander Dahl
2024-08-21 15:55 ` Conor Dooley
2024-09-19 12:39 ` Alexander Dahl
2024-09-24 15:52 ` Ryan Wanner
2024-09-25 15:24 ` Nicolas Ferre
2024-09-26 7:42 ` claudiu beznea
2024-10-01 15:04 ` Ryan Wanner
2025-02-07 12:41 ` Alexander Dahl
2024-08-21 10:59 ` [PATCH v1 10/12] ARM: dts: microchip: sam9x60: Add clock properties to OTPC Alexander Dahl
2024-08-24 15:57 ` claudiu beznea
2024-08-28 8:22 ` Alexander Dahl
2024-08-21 10:59 ` [PATCH v1 11/12] nvmem: microchip-otpc: Enable main RC oscillator clock Alexander Dahl
2024-08-22 15:57 ` kernel test robot
2024-08-24 15:53 ` claudiu beznea
2024-08-21 10:59 ` Alexander Dahl [this message]
2024-08-24 15:50 ` [PATCH v1 12/12] nvmem: microchip-otpc: Expose UID registers as 2nd nvmem device claudiu beznea
2024-08-24 16:17 ` [PATCH v1 00/12] Microchip OTPC driver on SAM9X60 exposing UIDxR as additional " claudiu beznea
2024-08-28 7:31 ` Alexander Dahl
2024-08-31 15:38 ` claudiu beznea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240821105943.230281-13-ada@thorsis.com \
--to=ada@thorsis.com \
--cc=christian.melki@t2data.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®