From nobody Wed Apr 15 19:44:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D631EC4332F for ; Mon, 21 Nov 2022 08:14:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbiKUIOo (ORCPT ); Mon, 21 Nov 2022 03:14:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbiKUIOn (ORCPT ); Mon, 21 Nov 2022 03:14:43 -0500 X-Greylist: delayed 434 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 21 Nov 2022 00:14:40 PST Received: from smtp.outgoing.loopia.se (smtp.outgoing.loopia.se [93.188.3.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E65E8F5A6 for ; Mon, 21 Nov 2022 00:14:40 -0800 (PST) Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id A31092F5F567 for ; Mon, 21 Nov 2022 09:07:23 +0100 (CET) Received: from s979.loopia.se (unknown [172.22.191.5]) by s807.loopia.se (Postfix) with ESMTP id 949642E2BDE1; Mon, 21 Nov 2022 09:07:23 +0100 (CET) Received: from s898.loopia.se (unknown [172.22.191.6]) by s979.loopia.se (Postfix) with ESMTP id 928F710BC45C; Mon, 21 Nov 2022 09:07:23 +0100 (CET) X-Virus-Scanned: amavisd-new at amavis.loopia.se Received: from s899.loopia.se ([172.22.191.6]) by s898.loopia.se (s898.loopia.se [172.22.190.17]) (amavisd-new, port 10024) with LMTP id B5vEprsRdhwL; Mon, 21 Nov 2022 09:07:23 +0100 (CET) X-Loopia-Auth: user X-Loopia-User: richard@bit42.se X-Loopia-Originating-IP: 178.174.130.84 Received: from hypercube.. (h-178-174-130-84.A444.priv.bahnhof.se [178.174.130.84]) (Authenticated sender: richard@bit42.se) by s899.loopia.se (Postfix) with ESMTPSA id 02B032C8BAD4; Mon, 21 Nov 2022 09:07:22 +0100 (CET) From: Richard Alpe To: srinivas.kandagatla@linaro.org Cc: linux-kernel@vger.kernel.org, Richard Alpe Subject: [PATCH v1] nvmem: add new NXP QorIQ eFuse driver Date: Mon, 21 Nov 2022 09:06:12 +0100 Message-Id: <20221121080612.11485-1-richard@bit42.se> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add SFP (Security Fuse Processor) read support for NXP (Freescale) QorIQ series SOC's. This patch adds support for the T1023 SOC using the SFP offset from the existing T1023 device tree. In theory this should also work for T1024, T1014 and T1013 which uses the same SFP base offset. Signed-off-by: Richard Alpe --- drivers/nvmem/Kconfig | 12 ++++++ drivers/nvmem/Makefile | 2 + drivers/nvmem/qoriq-efuse.c | 80 +++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 drivers/nvmem/qoriq-efuse.c diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 755f551426b5..6907b0b68b3f 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -367,4 +367,16 @@ config NVMEM_ZYNQMP =20 If sure, say yes. If unsure, say no. =20 +config NVMEM_QORIQ_EFUSE + tristate "NXP QorIQ eFuse support" + depends on PPC_85xx || COMPILE_TEST + depends on HAS_IOMEM + help + This driver provides read support for the eFuses (SFP) on NXP QorIQ + series SoC's. This includes secure boot settings, the globally unique + NXP ID 'FUIDR' and the OEM unique ID 'OUIDR'. + + This driver can also be built as a module. If so, the module + will be called nvmem_qoriq_efuse. + endif diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index fa80fe17e567..635a5c03274b 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -73,3 +73,5 @@ obj-$(CONFIG_NVMEM_VF610_OCOTP) +=3D nvmem-vf610-ocotp.o nvmem-vf610-ocotp-y :=3D vf610-ocotp.o obj-$(CONFIG_NVMEM_ZYNQMP) +=3D nvmem_zynqmp_nvmem.o nvmem_zynqmp_nvmem-y :=3D zynqmp_nvmem.o +obj-$(CONFIG_NVMEM_QORIQ_EFUSE) +=3D nvmem-qoriq-efuse.o +nvmem-qoriq-efuse-y :=3D qoriq-efuse.o diff --git a/drivers/nvmem/qoriq-efuse.c b/drivers/nvmem/qoriq-efuse.c new file mode 100644 index 000000000000..a332bb603e7a --- /dev/null +++ b/drivers/nvmem/qoriq-efuse.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Westermo Network Technologies AB + */ + +#include +#include +#include +#include +#include +#include + +struct qoriq_efuse_priv { + void __iomem *base; +}; + +static int qoriq_efuse_read(void *context, unsigned int offset, void *val, + size_t bytes) +{ + struct qoriq_efuse_priv *priv =3D context; + u32 *_val =3D val; + + while (bytes >=3D sizeof(u32)) { + *_val++ =3D readl_relaxed(priv->base + offset); + offset +=3D sizeof(u32); + bytes -=3D sizeof(u32); + } + + return 0; +} + +static int qoriq_efuse_probe(struct platform_device *pdev) +{ + struct nvmem_config config =3D { + .dev =3D &pdev->dev, + .read_only =3D true, + .reg_read =3D qoriq_efuse_read, + .stride =3D sizeof(u32), + .word_size =3D sizeof(u32), + .name =3D "qoriq_efuse_read", + .id =3D NVMEM_DEVID_AUTO, + .root_only =3D true, + }; + struct qoriq_efuse_priv *priv; + struct nvmem_device *nvmem; + struct resource *res; + + priv =3D devm_kzalloc(config.dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->base =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + config.size =3D resource_size(res); + config.priv =3D priv; + nvmem =3D devm_nvmem_register(config.dev, &config); + + return PTR_ERR_OR_ZERO(nvmem); +} + +static const struct of_device_id qoriq_efuse_of_match[] =3D { + { .compatible =3D "fsl,t1023-sfp", }, + {/* sentinel */}, +}; +MODULE_DEVICE_TABLE(of, qoriq_efuse_of_match); + +static struct platform_driver qoriq_efuse_driver =3D { + .probe =3D qoriq_efuse_probe, + .driver =3D { + .name =3D "qoriq-efuse", + .of_match_table =3D qoriq_efuse_of_match, + }, +}; +module_platform_driver(qoriq_efuse_driver); + +MODULE_AUTHOR("Richard Alpe "); +MODULE_DESCRIPTION("NXP QorIQ Security Fuse Processor (SFP) Reader"); +MODULE_LICENSE("GPL"); --=20 2.34.1