From: Srinivas Kandagatla <srini@kernel.org>
To: Christian Marangi <ansuelsmth@gmail.com>,
Srinivas Kandagatla <srini@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] nvmem: airoha: Add support for SMC eFUSE
Date: Tue, 19 May 2026 15:27:24 +0100 [thread overview]
Message-ID: <245d49ac-7b9d-45b1-833d-437984716db5@kernel.org> (raw)
In-Reply-To: <20260518142042.8331-3-ansuelsmth@gmail.com>
On 5/18/26 3:20 PM, Christian Marangi wrote:
> Add support for SMC eFUSE on AN7581 SoC. The SoC have 2 set of 2048 bits of
> eFUSE that are used to read calibration value for PCIe, Thermal, USB and
> other specific info of the SoC like revision and HW device present.
>
> eFuse value are taken by sending SMC command. ATF is responsible of
> validaing the data and rejecting reading protected data (like Private
> Key). In such case the SMC command will return non-zero value on a0
> register.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
> drivers/nvmem/Kconfig | 13 ++++
> drivers/nvmem/Makefile | 2 +
> drivers/nvmem/airoha-smc-efuses.c | 118 ++++++++++++++++++++++++++++++
> 3 files changed, 133 insertions(+)
> create mode 100644 drivers/nvmem/airoha-smc-efuses.c
>
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index 74ddbd0f79b0..95a399258538 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -28,6 +28,19 @@ source "drivers/nvmem/layouts/Kconfig"
>
> # Devices
>
> +config NVMEM_AIROHA_SMC_EFUSES
> + tristate "Airoha SMC eFuse support"
> + depends on ARCH_AIROHA || COMPILE_TEST
> + depends on HAVE_ARM_SMCCC
> + default ARCH_AIROHA
> + help
> + Say y here to enable support for reading eFuses on Airoha AN7581
> + SoCs. These are e.g. used to store factory programmed
> + calibration data required for the PCIe or the USB-C PHY or Thermal.
> +
> + This driver can also be built as a module. If so, the module will
> + be called nvmem-airoha-smc-efuses.
> +
> config NVMEM_AN8855_EFUSE
> tristate "Airoha AN8855 eFuse support"
> depends on COMPILE_TEST
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
> index 7252b8ec88d4..f6f2bc51dee1 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -10,6 +10,8 @@ nvmem_layouts-y := layouts.o
> obj-y += layouts/
>
> # Devices
> +obj-$(CONFIG_NVMEM_AIROHA_SMC_EFUSES) += nvmem-airoha-smc-efuses.o
> +nvmem-airoha-smc-efuses-y := airoha-smc-efuses.o
> obj-$(CONFIG_NVMEM_AN8855_EFUSE) += nvmem-an8855-efuse.o
> nvmem-an8855-efuse-y := an8855-efuse.o
> obj-$(CONFIG_NVMEM_APPLE_EFUSES) += nvmem-apple-efuses.o
> diff --git a/drivers/nvmem/airoha-smc-efuses.c b/drivers/nvmem/airoha-smc-efuses.c
> new file mode 100644
> index 000000000000..bb279d149519
> --- /dev/null
> +++ b/drivers/nvmem/airoha-smc-efuses.c
> @@ -0,0 +1,118 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Author: Christian Marangi <ansuelsmth@gmail.com>
> + */
> +
> +#include <linux/arm-smccc.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/nvmem-provider.h>
> +#include <linux/platform_device.h>
> +#include <linux/of.h>
> +#include <linux/regmap.h>
> +
> +#define AIROHA_SMC_EFUSE_FID 0x82000001
> +#define AIROHA_SMC_EFUSE_SUB_ID_READ 0x44414552
> +
> +#define AIROHA_EFUSE_CELLS 64
> +
> +struct airoha_efuse_bank_priv {
> + u8 bank_index;
> +};
> +
> +static int airoha_efuse_read(void *context, unsigned int offset,
> + void *val, size_t bytes)
> +{
> + struct regmap *regmap = context;
> +
> + return regmap_bulk_read(regmap, offset,
> + val, bytes / sizeof(u32));
> +}
> +
> +static int airoha_efuse_reg_read(void *context, unsigned int offset,
> + unsigned int *val)
> +{
> + struct airoha_efuse_bank_priv *priv = context;
> + struct arm_smccc_res res;
> +
> + arm_smccc_1_1_invoke(AIROHA_SMC_EFUSE_FID,
> + AIROHA_SMC_EFUSE_SUB_ID_READ,
> + priv->bank_index, offset, 0, 0, 0, 0, &res);
> +
> + /* check if SMC reported an error */
> + if (res.a0)
> + return -EIO;
> +
> + *val = res.a1;
> + return 0;
> +}
> +
> +static const struct regmap_config airoha_efuse_regmap_config = {
> + .reg_read = airoha_efuse_reg_read,
> + .reg_bits = 32,
> + .val_bits = 32,
> + .reg_stride = 4,
> +};
> +
> +static int airoha_efuse_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + int ret;
> +
> + for_each_child_of_node_scoped(dev->of_node, child) {
> + struct nvmem_config airoha_nvmem_config = {
> + .name = "airoha-efuse",
> + .size = AIROHA_EFUSE_CELLS * sizeof(u32),
> + .stride = sizeof(u32),
> + .word_size = sizeof(u32),
> + .reg_read = airoha_efuse_read,
> + };
> + struct airoha_efuse_bank_priv *priv;
> + struct nvmem_device *nvmem;
> + struct regmap *regmap;
> + u32 bank;
> +
> + ret = of_property_read_u32(child, "reg", &bank);
> + if (ret)
> + return ret;
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->bank_index = bank;
bank is 32 bit value now stored in 8 bit variable.
can we make bank_index 32 bit wide?
prev parent reply other threads:[~2026-05-19 14:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 14:20 [PATCH v3 0/2] " Christian Marangi
2026-05-18 14:20 ` [PATCH v3 1/2] dt-bindings: nvmem: airoha: add SMC eFuses schema Christian Marangi
2026-05-18 14:20 ` [PATCH v3 2/2] nvmem: airoha: Add support for SMC eFUSE Christian Marangi
2026-05-19 14:27 ` Srinivas Kandagatla [this message]
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=245d49ac-7b9d-45b1-833d-437984716db5@kernel.org \
--to=srini@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.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®