From patchwork Fri Nov 17 14:33:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Delaunay X-Patchwork-Id: 166206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp571264vqn; Fri, 17 Nov 2023 06:35:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4q5rltaMYY/yEJmErfr1vU6xHL6ztXJLWDapEVwVJ7cMNF3qzsD1tMgbH7uW4u3xBx1pX X-Received: by 2002:a05:6a21:7890:b0:187:4118:c0ee with SMTP id bf16-20020a056a21789000b001874118c0eemr11796973pzc.46.1700231702653; Fri, 17 Nov 2023 06:35:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700231702; cv=none; d=google.com; s=arc-20160816; b=njOmFrXGkP5QDqekVlsJuF6BPAR0Lrj1YrXrBY/7gpS76/Zs2048EKZRA7URILBP+2 8Qv1+Ie5XpfCqlshUXASr7Cjbbbw1OoHcQ6UpbJsPa1mLqgtVoGv0CAA+LtIgPq8oqnT hYKXvNBNYz4aZySNq7Z18wlqR5mqLDSmKt2BwlT2ttVH9I8o1hy/0IZ6DcryflobnmSZ DkztzGT00ih9N/3n4/lqlukLZ6oiNUQOzf5rrEGpCy7rIpXF7wlJu1YJUujp3AdhIQ1w fgaUrTl7DJ+Zc53ZUIYxl+ozFsp03wR+HhpGUO/qjpgH5QftT4HTtRe5h0oK3e/1MIg8 iJlQ== 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=2kptbLSUBCjfzpDr3d+grhLzBCudtePeEMBFobZJJgo=; fh=/kP+9bdEFz3MKkOcLW/lQIRRJBhKPist974Z6nQv/e4=; b=VG3WfvIVvre/eJNhGQvLU/ppEJyppMaSESAPBxhmSbLVYwJQn2ujzNfsHmefQKJZfV voySAZKgYK+kshwwK3i02sZX9KcWNnxmfgXEv3o2kIaMxyAxGbI6pM91B7dMBC5n0ilw RsOvlHMDKc0Xcf5ZrahN0fSLkSx3L0cmFVraSLiH6ZjoAOmbrTbGZk4IbMyzi+S/CsnY y/eSISQtiLqQdxfAJvLQNx7QYVCvrYg6bL2FramDI/InCpGMfcRgMklAp1sQNS/Gdsvu I26y1v7RVN+xvld+BeaRymtRywyIE+xSGc59u1WujG0LOzqx0Y6ob0cvcbzO6GN3qmr/ yFZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=nb5WDD3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l191-20020a6391c8000000b005be1ee5bde9si1885197pge.295.2023.11.17.06.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 06:35:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=nb5WDD3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 00804809EE28; Fri, 17 Nov 2023 06:34:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232091AbjKQOeQ (ORCPT + 30 others); Fri, 17 Nov 2023 09:34:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231864AbjKQOeN (ORCPT ); Fri, 17 Nov 2023 09:34:13 -0500 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54EAED4E for ; Fri, 17 Nov 2023 06:34:10 -0800 (PST) Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3AH9Mg4v015626; Fri, 17 Nov 2023 15:33:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= selector1; bh=2kptbLSUBCjfzpDr3d+grhLzBCudtePeEMBFobZJJgo=; b=nb 5WDD3paSc2RkhJSUfJJ2/D0CYb3COTreycw9IHutG7jRF4w/xSbj73ZOwamcLVCB L1wNvKb8HBb0SVP9boqYv/bUevAfvPPDMUAN1jighVeMs+erhNXlqv6LxqysSLKB 6qGlc5aQ4cw80s5/Zc3xA9aPacmaUETSvNFsXxpGrFAZhc7V3X6Y5EoUt+r/MF4H 0cMMoT6AQ91PbTXj1qCu4GpxYzAB5dAyOuvC54Q4osREbR/mTHvfHTO7YgPfe35E 8AqqzbM0MA0Lop9FDSqWK53Pxgba215kchdTyuQMf3HQtQNJrr13vONE5iA+clpQ 73mhqBNsdQ+mIrTp67pw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3udn0m4t7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 15:33:53 +0100 (CET) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F26FD100039; Fri, 17 Nov 2023 15:33:48 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id EC6552309C5; Fri, 17 Nov 2023 15:33:48 +0100 (CET) Received: from localhost (10.201.22.165) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 17 Nov 2023 15:33:48 +0100 From: Patrick Delaunay To: Alexandre TORGUE , Srinivas Kandagatla , Maxime Coquelin CC: Patrick Delaunay , , , Subject: [PATCH 2/4] nvmem: stm32: add support for STM32MP25 BSEC to control OTP data Date: Fri, 17 Nov 2023 15:33:35 +0100 Message-ID: <20231117153310.2.I76e50bf760c893b11edfb2ed77388e2939612288@changeid> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231117143338.1173475-1-patrick.delaunay@foss.st.com> References: <20231117143338.1173475-1-patrick.delaunay@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.22.165] X-ClientProxiedBy: SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-17_13,2023-11-17_01,2023-05-22_02 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 17 Nov 2023 06:35:00 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782822157784057466 X-GMAIL-MSGID: 1782822157784057466 On STM32MP25, OTP area may be read/written by using BSEC (boot, security and OTP control). The BSEC internal peripheral is only managed by the secure world. The 12 Kbits of OTP (effective) are organized into the following regions: - lower OTP (OTP0 to OTP127) = 4096 lower OTP bits, bitwise (1-bit) programmable - mid OTP (OTP128 to OTP255) = 4096 middle OTP bits, bulk (32-bit) programmable - upper OTP (OTP256 to OTP383) = 4096 upper OTP bits, bulk (32-bit) programmable, only accessible when BSEC is in closed state. As HWKEY and ECIES key are only accessible by ROM code; only 368 OTP words are managed in this driver (OTP0 to OTP267). This patch adds the STM32MP25 configuration for reading and writing the OTP data using the OP-TEE BSEC TA services. Signed-off-by: Patrick Delaunay --- drivers/nvmem/stm32-romem.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/nvmem/stm32-romem.c b/drivers/nvmem/stm32-romem.c index 8a553b1799a8..82879b1c9eb9 100644 --- a/drivers/nvmem/stm32-romem.c +++ b/drivers/nvmem/stm32-romem.c @@ -269,6 +269,19 @@ static const struct stm32_romem_cfg stm32mp13_bsec_cfg = { .ta = true, }; +/* + * STM32MP25 BSEC OTP: 3 regions of 32-bits data words + * lower OTP (OTP0 to OTP127), bitwise (1-bit) programmable + * mid OTP (OTP128 to OTP255), bulk (32-bit) programmable + * upper OTP (OTP256 to OTP383), bulk (32-bit) programmable + * but no access to HWKEY and ECIES key: limited at OTP367 + */ +static const struct stm32_romem_cfg stm32mp25_bsec_cfg = { + .size = 368 * 4, + .lower = 127, + .ta = true, +}; + static const struct of_device_id stm32_romem_of_match[] __maybe_unused = { { .compatible = "st,stm32f4-otp", }, { .compatible = "st,stm32mp15-bsec", @@ -276,6 +289,9 @@ static const struct of_device_id stm32_romem_of_match[] __maybe_unused = { }, { .compatible = "st,stm32mp13-bsec", .data = (void *)&stm32mp13_bsec_cfg, + }, { + .compatible = "st,stm32mp25-bsec", + .data = (void *)&stm32mp25_bsec_cfg, }, { /* sentinel */ }, };