From patchwork Thu Jan 27 16:37:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12727070 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EB39C433F5 for ; Thu, 27 Jan 2022 16:39:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=deFZr0WO81H98t7gWkIYGQsGhj6aOUnseidVwe8IP0k=; b=kGDVA4ytVL5JSW P12Gwhw3UOSZkeDVxSByKPL7GAGWlY0GH5lmFgiljPQYb+18ckVvJohRMbZDCOZ32+nVYX9OmizB5 ihwcD6Ckay2LNVUb4X60ZEWMb2zQZgssKAVqm5KgUgT96Yv7Ot8UeOeMEHbcMaJJ7vRqV/CjlGl6D hKYFrtpC7mWw21K4qRPQoUieX9QaiUz2GkZjtmw8NdvENa6K0flKr6kVehlguCgzPpIvRvlfYuBwq c5e3gifFzSXSN1qUkO122risTwtOXcAQsr9UEykPlappfMHqHR7G004eQvFq5ThQgrhoRTJHbH+ID TNJSCgPNomzFVzQ91uUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD7mc-00GZFZ-Ct; Thu, 27 Jan 2022 16:38:02 +0000 Received: from ssl.serverraum.org ([2a01:4f8:151:8464::1:2]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD7mC-00GZ6z-LO for linux-arm-kernel@lists.infradead.org; Thu, 27 Jan 2022 16:37:38 +0000 Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 2F2D2223EA; Thu, 27 Jan 2022 17:37:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1643301454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S51ZapZnYq1k6n2qxYfSXh5MaRdNceh6NgrFguI6b6s=; b=am4VRjOnPRhCEqV8KcvKa3taiD2k+m8rnygSVEatXNpj/m7QbYsB1/h8l7FA9nguJ1tyKf p+kyoJjCAIXlTkuTdDD3l0Q2coCVKNgyszQjzjEaLSc/EW8iZQ9ABepUiqRHbdM2zIFlGD M1gjAl+9YccVsgwDCV6le91WvZNKxBk= From: Michael Walle To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Srinivas Kandagatla , Rob Herring , Shawn Guo , Li Yang , Michael Walle Subject: [PATCH v1 1/3] dt-bindings: nvmem: add fsl,layerscape-sfp binding Date: Thu, 27 Jan 2022 17:37:26 +0100 Message-Id: <20220127163728.3650648-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220127163728.3650648-1-michael@walle.cc> References: <20220127163728.3650648-1-michael@walle.cc> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220127_083736_882402_12B94D49 X-CRM114-Status: GOOD ( 12.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Security Fuse Processor provides efuses and is responsible for reading it at SoC startup and configuring it accordingly. Signed-off-by: Michael Walle Reviewed-by: Rob Herring --- .../bindings/nvmem/fsl,layerscape-sfp.yaml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml diff --git a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml new file mode 100644 index 000000000000..80914b93638e --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/fsl,layerscape-sfp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Freescale Layerscape Security Fuse Processor + +maintainers: + - Michael Walle + +description: | + SFP is the security fuse processor which among other things provide a + unique identifier per part. + +allOf: + - $ref: "nvmem.yaml#" + +properties: + compatible: + enum: + - fsl,ls1028a-sfp + + reg: + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + efuse@1e80000 { + compatible = "fsl,ls1028a-sfp"; + reg = <0x1e80000 0x8000>; + }; From patchwork Thu Jan 27 16:37:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12727073 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93236C433F5 for ; Thu, 27 Jan 2022 16:39:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PG8KO14VywEA9ZnPufORV4eSQYYzW/aYBv+0utVnAZs=; b=BYx8OGHTjf1O+b DL1P6qj2kLfS37JeeaHIGFgbpsYQa5BVAqUKhi52keYibbAx4Tp6iznxnG/96lqJSf2CiLSNzAS0J a8iyKtiC84zag793zRdW8tSVv82E0vJpzdKIPFYRtGB8cZ4HIeYyH6Ju0gjrYEzF21v/HvnCJ+6Vc 8Y4LmdeH/gZnMD2mf7on9Le7HTFVrbw43UkADvvq5nDWpWCFFy/U/0KYEwMIAERj2HiaInMUabQ9r YnjTVnOM9jR4LjRVWmFWki5r02KKwIf5HIIZf2ixJiQJuGXb5CN/iUTse5Oc9ekQVVdVynGLJwK1O 8poebbK5ktcxrsQETiZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD7n6-00GZOS-Ie; Thu, 27 Jan 2022 16:38:32 +0000 Received: from ssl.serverraum.org ([2a01:4f8:151:8464::1:2]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD7mC-00GZ7J-LM for linux-arm-kernel@lists.infradead.org; Thu, 27 Jan 2022 16:37:40 +0000 Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id A7A9D223ED; Thu, 27 Jan 2022 17:37:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1643301454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ev64DGxSvnK1yZphS6yzvPXpxJGjZjwv4zeS/CYmiVg=; b=OI7vQXQEZEzzwNgGmt4QSE5H99ePZIeNMeTASTV5OJEFwop/ixZTNXKjNv6u8jqxdEi2PZ YUNZExZhfSAA3lyTWYF+H/PV5im1zgcQMqaQHoo+QX6UBm5+OtbLF263e896pBQJVPdZq3 D2mdLdg/iRC4q4f29DR/gbJIkR4TDH8= From: Michael Walle To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Srinivas Kandagatla , Rob Herring , Shawn Guo , Li Yang , Michael Walle Subject: [PATCH v1 2/3] nvmem: add driver for Layerscape SFP (Security Fuse Processor) Date: Thu, 27 Jan 2022 17:37:27 +0100 Message-Id: <20220127163728.3650648-3-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220127163728.3650648-1-michael@walle.cc> References: <20220127163728.3650648-1-michael@walle.cc> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220127_083737_070665_0EC17327 X-CRM114-Status: GOOD ( 21.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for the Security Fuse Processor found on Layerscape SoCs. This driver implements basic read access. Signed-off-by: Michael Walle --- drivers/nvmem/Kconfig | 12 +++++ drivers/nvmem/Makefile | 2 + drivers/nvmem/layerscape-sfp.c | 91 ++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 drivers/nvmem/layerscape-sfp.c diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 94dd60b2654e..63792082e476 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -307,4 +307,16 @@ config NVMEM_BRCM_NVRAM This driver provides support for Broadcom's NVRAM that can be accessed using I/O mapping. +config NVMEM_LAYERSCAPE_SFP + tristate "Layerscape SFP (Security Fuse Processor) support" + depends on ARCH_LAYERSCAPE || COMPILE_TEST + depends on HAS_IOMEM + help + This driver provides support to read the eFuses on Freescale + Layerscape SoC's. For example, the vendor provides a per part + unique ID there. + + This driver can also be built as a module. If so, the module + will be called layerscape-sfp. + endif diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 4e6d877fdfaf..914358fcdb37 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -62,3 +62,5 @@ obj-$(CONFIG_NVMEM_RMEM) += nvmem-rmem.o nvmem-rmem-y := rmem.o obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o nvmem_brcm_nvram-y := brcm_nvram.o +obj-$(CONFIG_NVMEM_LAYERSCAPE_SFP) += nvmem-layerscape-sfp.o +nvmem-layerscape-sfp-y := layerscape-sfp.o diff --git a/drivers/nvmem/layerscape-sfp.c b/drivers/nvmem/layerscape-sfp.c new file mode 100644 index 000000000000..4aa94e03d8d1 --- /dev/null +++ b/drivers/nvmem/layerscape-sfp.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Layerscape SFP driver + * + * Copyright (c) 2022 Michael Walle + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LAYERSCAPE_SFP_OTP_OFFSET 0x0200 + +struct layerscape_sfp_priv { + void __iomem *base; +}; + +struct layerscape_sfp_data { + int size; +}; + +static int layerscape_sfp_read(void *context, unsigned int offset, void *val, + size_t bytes) +{ + struct layerscape_sfp_priv *priv = context; + + memcpy_fromio(val, priv->base + LAYERSCAPE_SFP_OTP_OFFSET + offset, bytes); + + return 0; +} + +static struct nvmem_config layerscape_sfp_nvmem_config = { + .name = "fsl-sfp", + .reg_read = layerscape_sfp_read, +}; + +static int layerscape_sfp_probe(struct platform_device *pdev) +{ + const struct layerscape_sfp_data *data; + struct layerscape_sfp_priv *priv; + struct nvmem_device *nvmem; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + data = device_get_match_data(&pdev->dev); + + layerscape_sfp_nvmem_config.size = data->size; + layerscape_sfp_nvmem_config.dev = &pdev->dev; + layerscape_sfp_nvmem_config.priv = priv; + + nvmem = devm_nvmem_register(&pdev->dev, &layerscape_sfp_nvmem_config); + + return PTR_ERR_OR_ZERO(nvmem); +} + +static const struct layerscape_sfp_data ls1028a_data = { + .size = 0x88, +}; + +static const struct of_device_id layerscape_sfp_dt_ids[] = { + { .compatible = "fsl,ls1028a-sfp", .data = &ls1028a_data }, + {}, +}; +MODULE_DEVICE_TABLE(of, layerscape_sfp_dt_ids); + +static struct platform_driver layerscape_sfp_driver = { + .probe = layerscape_sfp_probe, + .driver = { + .name = "layerscape_sfp", + .of_match_table = layerscape_sfp_dt_ids, + }, +}; +module_platform_driver(layerscape_sfp_driver); + +MODULE_AUTHOR("Michael Walle "); +MODULE_DESCRIPTION("Layerscape Security Fuse Processor driver"); +MODULE_LICENSE("GPL v2"); From patchwork Thu Jan 27 16:37:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12727072 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE269C433F5 for ; Thu, 27 Jan 2022 16:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GwWnoXd3ae+PGA/nPytS4WBrPSr7k8SJ/8ir0s9Tv0E=; b=w+FMzt3RFyNJnT VBtRXJOUAlQxtJSoPAOOsaNx7dbvP63IWxVNdSzSuVcV/G7qlfZB8wRlpDvPij6cfXW8d842f6n5f wdwoVuHZjrIVxDz+FIXsk/SaxrRLnQa9gIA5h2wfDTzhRfQz+gCmbbT7gq1sjQoUalECd2lts4k/1 bPd0XzrHa/ivG4E8/uFWGIOKlYzdXjMJ0lYfcsN1S5nWk1LfOC2puXt+iRSjIvIazxxHbFo4vcOaD Wis7UCU/hZO6sRxPfNP+mvheobVoFTePrDe3D/1KKnH9FsxRNbdz2WWEfPErBPxgFg+Ze+3SQ+LLN EzWeJoBqp0ZhUi61to4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD7ms-00GZJl-0e; Thu, 27 Jan 2022 16:38:18 +0000 Received: from ssl.serverraum.org ([176.9.125.105]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD7mD-00GZ7O-7t for linux-arm-kernel@lists.infradead.org; Thu, 27 Jan 2022 16:37:39 +0000 Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 200D4223EF; Thu, 27 Jan 2022 17:37:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1643301455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Lgm3+ejR5iCeubB0LLMdHYvyTni/SmF/Frp1FWA+zQ=; b=N7MkleU7MH65Ylw+E3wXvQlrSPAYLtG9X+bqa/5ZS1OgKkzI5+MIzLvEnfSEi0jvcJh5Jp NeQrKXwbQCwDuzZOnxZD6capkLl4AnMk+sTJnExlRt8VbWkWe/B2KhVzMyUt6aNEUV/yAc gOh5uaX59wo8iyUJkTqvqB4ORl/reYM= From: Michael Walle To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Srinivas Kandagatla , Rob Herring , Shawn Guo , Li Yang , Michael Walle Subject: [PATCH v1 3/3] arm64: dts: ls1028a: add efuse node Date: Thu, 27 Jan 2022 17:37:28 +0100 Message-Id: <20220127163728.3650648-4-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220127163728.3650648-1-michael@walle.cc> References: <20220127163728.3650648-1-michael@walle.cc> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220127_083737_452970_A4D72664 X-CRM114-Status: GOOD ( 10.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Layerscape SoCs contain a Security Fuse Processor which is basically a efuse controller. Add the node, so userspace can read the efuses. Signed-off-by: Michael Walle --- arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi index 7d44102d9c6c..4b248cee830a 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi @@ -224,6 +224,17 @@ rst: syscon@1e60000 { little-endian; }; + efuse@1e80000 { + compatible = "fsl,ls1028a-sfp"; + reg = <0x0 0x1e80000 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <1>; + + ls1028a_uid: unique-id@1c { + reg = <0x1c 0x8>; + }; + }; + scfg: syscon@1fc0000 { compatible = "fsl,ls1028a-scfg", "syscon"; reg = <0x0 0x1fc0000 0x0 0x10000>;