Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp96426rdb; Mon, 14 Aug 2023 10:30:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQQGEWmogXA2pZtDWQ3lFM9SlINmGV0ULNT4EAN2x6vkfV4It5fgRhr0XGl1XuEBikPa5B X-Received: by 2002:a05:6a21:3399:b0:140:a6ec:b55f with SMTP id yy25-20020a056a21339900b00140a6ecb55fmr15200126pzb.16.1692034258477; Mon, 14 Aug 2023 10:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692034258; cv=none; d=google.com; s=arc-20160816; b=wf4xhKHgC9Q0ADb0kDwtGh2ieGsgNYr+83QWrokQ2z8qVNjimMWURyOijbTuEcwOb6 pFncWeoT0IsGEGqy6QVtgYd7XWujG7FXJhwtV/ohLGwwBdW/eCN/M0I73JODPBKEWWNB 1fk2g94phgQbqin0KLiuqbQ4kDmkZbIjbCHzNpcr+YOU3grb+WcmMl2hV47+fVNLXMI+ mtSDfXWwpfvCU85q1KQiKSGFbHayX7hSaVEoWw+7vHocWoJkzlTVq0UxNzONJ9LItms5 sBvINnV9pSLQ9DEN25Xf9kyDYoomueWTB+EXvJ7ClAHTyn6f9z4O4EafcKiOwXm7MVMF n7dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QMjewjbqgRLUDOfDr2fvd0INz7ulNUEmSWxMy1iHfM4=; fh=e+q1eHpABW6OgxEh5MA4w82CGBSEZqf/Rst4jNg15qc=; b=AfIEi5/zh4YjI3CZ7xiYfwru5LRb8z7bKttCkDMQSkgAj7dVvS3/CY51Oh97YQC93I 3Urjubd2oy472ciGmmmj6U9FKHL+wvXI3q84dnVrUGGfj/QF0aU5GnIduUJGnVBFGAOD xehl5ZQ6dFlkQt7UL2uagmg5q7Z9msWZh293ju2n64zUwReoDcOyOoFGCMLt2GudRVlw 2At4XTv4w2ycDmR+rVe6xOwTva9oTd+YZQwuEpFEcN2fnr4tJw1AGwE5L/Yd4b7M5VAL FMp03ZFROWkZO+WgjYZ9UZmrv1B+yJ1ibg4jByoKfygjQ22plf9V8TEWuBEsDicBr4f7 L0gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wKDCtymG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020a63f218000000b0055c4c9cbfedsi8467165pgh.862.2023.08.14.10.30.44; Mon, 14 Aug 2023 10:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wKDCtymG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232367AbjHNQyA (ORCPT + 99 others); Mon, 14 Aug 2023 12:54:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232233AbjHNQxv (ORCPT ); Mon, 14 Aug 2023 12:53:51 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 574A8E63 for ; Mon, 14 Aug 2023 09:53:50 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4ff72830927so2107075e87.3 for ; Mon, 14 Aug 2023 09:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692032028; x=1692636828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QMjewjbqgRLUDOfDr2fvd0INz7ulNUEmSWxMy1iHfM4=; b=wKDCtymGZvhmrgg0EjhBbGS86WUfzsrx1EZ4hEYSE3qcrsYcX4NK8MsBtXWt77cc+Z Is1DIr/6IRGuuRiqGwl5v6UoCi2FcL5npQ95BNGUH7A1Z4lkRX/7FfD3W5MFiB2WPmT9 XmKA8cLseHFxxPAUzLm4OqzIEsweP+f5+nbBl/ZQfRYWukNihI+kvYLPbzT/NkIiZkV6 pHwbwAxs2rq6cSs35nCoiP2Oh/jemy8pymxcPHcqKTlXyr6gZ0sXrn75nSAfIbz3TYlb rhgdKdHRGbmUufKLwfbE9XCL09SV6zPmNjzMbNSFpipG730wc6gfkxxiDDcCSconaVq0 WD1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692032028; x=1692636828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QMjewjbqgRLUDOfDr2fvd0INz7ulNUEmSWxMy1iHfM4=; b=eytS8IepgjDknsTnWfoXwZNuwWtZyqTVtJ8gk4R02rfn1Gr02PTdAqVzV8aHM8PRT9 MIqIjUTRd3kjqEbx9JvLSsvbWhAEi2E2vcrBgvLsL/+JYbbPosx3itM1bpP5F2nrmtTa aeT+SraQwp+11rQajC4cenGsaWhpc32LA37loRPYbE85KUNHxqT23aeStVokMTVyLmwq 0q8adt5wzbtSvxtSwRj0ytBNJ+3CM8S6PFGw24xaa36OGRx1ephfFH7km3g6UZw/IZaI /Fy5C8hj4alboYfem+jnHWx2PxwsmgD7ecykzFL+bSLZHKy+laoRu1QZfzwfWTuc3oJ8 YJ+A== X-Gm-Message-State: AOJu0YyS+N4dLKb1KC90rqnIBfxVYmamOqALSZPi1Fqb1JvcdLsqDMP8 wNGGg+p5hg2AUObwE5XyfLMXBw== X-Received: by 2002:a05:6512:3190:b0:4fe:9f2f:f766 with SMTP id i16-20020a056512319000b004fe9f2ff766mr6335618lfe.3.1692032028593; Mon, 14 Aug 2023 09:53:48 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id n5-20020aa7c785000000b0052338f5b2a4sm5811267eds.86.2023.08.14.09.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:53:47 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Richard Alpe , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Srinivas Kandagatla Subject: [PATCH 12/22] nvmem: add new NXP QorIQ eFuse driver Date: Mon, 14 Aug 2023 17:52:42 +0100 Message-Id: <20230814165252.93422-13-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230814165252.93422-1-srinivas.kandagatla@linaro.org> References: <20230814165252.93422-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Richard Alpe 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 Reviewed-by: Niklas Söderlund Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/Kconfig | 12 ++++++ drivers/nvmem/Makefile | 2 + drivers/nvmem/qoriq-efuse.c | 78 +++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 drivers/nvmem/qoriq-efuse.c diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index da9befa3d6c4..5c5d7414f78c 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -392,4 +392,16 @@ config NVMEM_ZYNQMP If sure, say yes. If unsure, say no. +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 cc23ce4ffb1f..e0e67a942c4f 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -77,3 +77,5 @@ obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o nvmem-vf610-ocotp-y := vf610-ocotp.o obj-$(CONFIG_NVMEM_ZYNQMP) += nvmem_zynqmp_nvmem.o nvmem_zynqmp_nvmem-y := zynqmp_nvmem.o +obj-$(CONFIG_NVMEM_QORIQ_EFUSE) += nvmem-qoriq-efuse.o +nvmem-qoriq-efuse-y := qoriq-efuse.o diff --git a/drivers/nvmem/qoriq-efuse.c b/drivers/nvmem/qoriq-efuse.c new file mode 100644 index 000000000000..e7fd04d6dd94 --- /dev/null +++ b/drivers/nvmem/qoriq-efuse.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 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 = context; + + /* .stride = 4 so offset is guaranteed to be aligned */ + __ioread32_copy(val, priv->base + offset, bytes / 4); + + /* Ignore trailing bytes (there shouldn't be any) */ + + return 0; +} + +static int qoriq_efuse_probe(struct platform_device *pdev) +{ + struct nvmem_config config = { + .dev = &pdev->dev, + .read_only = true, + .reg_read = qoriq_efuse_read, + .stride = sizeof(u32), + .word_size = sizeof(u32), + .name = "qoriq_efuse_read", + .id = NVMEM_DEVID_AUTO, + .root_only = true, + }; + struct qoriq_efuse_priv *priv; + struct nvmem_device *nvmem; + struct resource *res; + + priv = devm_kzalloc(config.dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + config.size = resource_size(res); + config.priv = priv; + nvmem = devm_nvmem_register(config.dev, &config); + + return PTR_ERR_OR_ZERO(nvmem); +} + +static const struct of_device_id qoriq_efuse_of_match[] = { + { .compatible = "fsl,t1023-sfp", }, + {/* sentinel */}, +}; +MODULE_DEVICE_TABLE(of, qoriq_efuse_of_match); + +static struct platform_driver qoriq_efuse_driver = { + .probe = qoriq_efuse_probe, + .driver = { + .name = "qoriq-efuse", + .of_match_table = 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"); -- 2.25.1