From patchwork Wed Aug 21 10:59:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771233 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 03525C5320E for ; Wed, 21 Aug 2024 11:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=crou9icPFQt6qy3frq3zWNsDVrBMyW0y4VXPpAGZ1pA=; b=MGzyOCgQTKTD/3aI1d8n+Hl/Kz 8/rjWH3uHURKKwLZh0HykFWjlkFKwdQ2cBSEaomwV9BtwXd5BEo3Sawi9USPFbEIr7vax0xdCPmzq Smd9pDwxpfxEdqLZa/saJXHqe8UyNNm5wnu8nUEBQGy/CiwxALITjY/PyZrmp7OEA5+zIRRQ06DtB YKWAdwvfZgk2C0HTKENr+Z32oXdpXGv94Zc1Mfr7JrpwdKt5QUQw7SoIsjtyX64oi9TXGUL+oDEPM cfRmPTfslDpYdVhoB1d9AtSFAtgiSpG/dqm5fr6w5LhtdEdTnnc4ylfA2o2sS8kniCjjbxIgzlBGG VGaBx1qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj6Z-00000008YL5-3fWV; Wed, 21 Aug 2024 11:02:19 +0000 Received: from mail.thorsis.com ([217.92.40.78]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4E-00000008XRU-0A1v for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 10:59:56 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 106881483DEE; Wed, 21 Aug 2024 12:59:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237991; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=crou9icPFQt6qy3frq3zWNsDVrBMyW0y4VXPpAGZ1pA=; b=qRaGUGE1xf+8Ul3ZG4giMuFfKzm0Ur44w+zplS6CK3K0tR1Rg40kPZbPFkaXPNMG597iw3 FNo4ZWHVG+NgvzZiaYlYvstoscl+7CRgPtH+blxo6W87OCaNnVe4vZGvH2igzN2ZrzMB3E aobBwsu65a4qFAL9mlIhVXzvCCKGkMcn76HoEskvuR5yNCfVR77mu5fJmrMF6iV1QrwXrS aj+APQQOvlC/p2Jv7Rm5ZKmh+EJdEF0+tYOnwdBqbdRrl057mnRu7fhmPKXEES6ibcANLx a0nsNH1N4cMXy8vkOiLrY4xFdD2R2IXcnsR+dhkESfZVSZzPy71p0YzMBEaGtw== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 01/12] nvmem: microchip-otpc: Avoid writing a write-only register Date: Wed, 21 Aug 2024 12:59:32 +0200 Message-Id: <20240821105943.230281-2-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035954_323866_191BE02A X-CRM114-Status: GOOD ( 10.19 ) 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 OTPC Control Register (OTPC_CR) has just write-only members. Reading from that register leads to a warning in OTPC Write Protection Status Register (OTPC_WPSR) in field Software Error Type (SWETYP) of type READ_WO (A write-only register has been read (warning).) Just create the register write content from scratch is sufficient here. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index 7cf81738a3e0..03e60b99f2c9 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -82,7 +82,7 @@ static int mchp_otpc_prepare_read(struct mchp_otpc *otpc, writel_relaxed(tmp, otpc->base + MCHP_OTPC_MR); /* Set read. */ - tmp = readl_relaxed(otpc->base + MCHP_OTPC_CR); + tmp = 0; tmp |= MCHP_OTPC_CR_READ; writel_relaxed(tmp, otpc->base + MCHP_OTPC_CR); From patchwork Wed Aug 21 10:59:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771232 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 BEB09C52D7C for ; Wed, 21 Aug 2024 11:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=82Txq8wjdCnYwZ4j95zlkdbSO+k6QphWbvjQj7xx3Mw=; b=PHOmFVttEymmOGXQtLy3lEmL8B 58lLCMKVRXA6l9u/eE8uJIJdjxCAFoacbVQikc9ebmAjCyvSvxXxEd/xhi92NOMiaEW0i3o8Ssag3 srYxnUaeWFoKV+SQbIX2qTn4LMYv4rI1Kfi6L/M2/wbxLw14FnVX4ypr7PwjkDkSCtzL1U6DvclX5 l9UkUcxw+efUw2YEaFMtU45wmewnNtMA2IOahKJQv+6EfYLJD3sSZ8pjVvrDe1ybZcKGlFeSLXhHW 67oVdblSP363YRii4frlYAZhiGYsuuRFNJ7DEHnN9/8mW5XiR8P4EZJchK/txD3GVQ+V+/2FxYyHL 6ER9MN0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj5s-00000008Y6B-3Rad; Wed, 21 Aug 2024 11:01:36 +0000 Received: from mail.thorsis.com ([217.92.40.78]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4E-00000008XRi-0AGY for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 10:59:56 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D30F31483DF2; Wed, 21 Aug 2024 12:59:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237991; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=82Txq8wjdCnYwZ4j95zlkdbSO+k6QphWbvjQj7xx3Mw=; b=qTbTlp5JakJrsN0woUsh5s94nZgneFmNAoyviJMtzyfQ0lInYveVm/gdfwHGfPgESSmPYW Mk6ZhapHCM68T+FfA9eNyNmySbp1/6JUp4A9ugeAq5W/PTdWnQFoc1BvylP3E+nh8EwmOC ZzW/hf5duBG8wm2soyTi+ab8E24paU3MREzfXecY+H7wXklmCkdFlaPgz38FI4qLNsOzub Dmln7iBA3+5/qu7W4X6EM6ge9O4E6p403K6PpmyNX4kpk1FdHQH2r7wWkqC/+FaLUcqg7+ mIjeKBJcujk2+BGLeuZdrBGxlvV5c9joAOCYkiJbXcf+Qk98aPqTe5FbGGxR8A== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 02/12] nvmem: microchip-otpc: Fix swapped 'sleep' and 'timeout' parameters Date: Wed, 21 Aug 2024 12:59:33 +0200 Message-Id: <20240821105943.230281-3-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035954_316214_E65FA734 X-CRM114-Status: GOOD ( 11.32 ) 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 Makes no sense to have a timeout shorter than the sleep time, it would run into timeout right after the first sleep already. While at it, use a more specific macro instead of the generic one, which does exactly the same, but needs less parameters. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index 03e60b99f2c9..bd3383eabdf6 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -87,8 +87,8 @@ static int mchp_otpc_prepare_read(struct mchp_otpc *otpc, writel_relaxed(tmp, otpc->base + MCHP_OTPC_CR); /* Wait for packet to be transferred into temporary buffers. */ - return read_poll_timeout(readl_relaxed, tmp, !(tmp & MCHP_OTPC_SR_READ), - 10000, 2000, false, otpc->base + MCHP_OTPC_SR); + return readl_relaxed_poll_timeout(otpc->base + MCHP_OTPC_SR, tmp, + !(tmp & MCHP_OTPC_SR_READ), 2000, 10000); } /* From patchwork Wed Aug 21 10:59:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771234 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 0799CC52D6F for ; Wed, 21 Aug 2024 11:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vc+ZNqDqtDjunBZp8r2rWXp9yJg3iRJrNVvLS3A0AHU=; b=3eRhGIEnZDTCaFPrud+d5B1vAr b4sI8TmdqLTia1avmIOOqTADCKtYhACxHEZoOROjWpm5GVTT3ToMhobHIDGwm+ZLo9WV2dazJfYzX 5yKrfxD4PQEXb6F8h6N3EqQ6+azmmFdsc3ikveQLXKP0Cub87A7UcvkZSbjez2yEYlXbyga8pBK/r ZjhvGDpm7r0zwlDFXMIv143tLAUdELnL0G5J2UeMUX3PisVyU3h3dEwc//WXQqKHgTCWsAlGQwrRO iQjmOZrfoRZLc4wSyyuBSkHJH2gHo6snqQOTd2DBBERftbc7qOK1CSJMrq3OQXRJTWVogIjQRVTn2 1hwzPbrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj7H-00000008Yaj-1HGE; Wed, 21 Aug 2024 11:03:03 +0000 Received: from mail.thorsis.com ([217.92.40.78]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4E-00000008XRo-0U0l for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 10:59:57 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 334771483DF3; Wed, 21 Aug 2024 12:59:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237992; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=vc+ZNqDqtDjunBZp8r2rWXp9yJg3iRJrNVvLS3A0AHU=; b=MqXjlRaGpeliknT7/fXfpDP3ZLqCTYlPXXl618rXz38QxZTqKCZoV53B5btH7ZNTIrVBXE kwGwoyEpE4GWjvIuiEEx+BxV+VkZzrKz3JDN87ees/0qIfaLWWnEjpMR+/I8b+5RKpkO3V NNJVhQVkdBWi72PEIOxvKm+pJuh6a8B/OGzG3LyZS3TL/o/Pjch7rFzIYryGDT++6dU/YG OZ8o3epf/A0u3cDEgPKAXbWmMcY1EhI5KwoKOznoiQ9LtkunCpOEzmrIqiSuxc9uPogmsj AHQAHwptUiIdiO8g1xfY/FZ50KDxBt/ORWrZbDwk5KJsu8l/f8s50Rk29WYHGA== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 03/12] dt-bindings: nvmem: microchip-otpc: Add compatible for SAM9X60 Date: Wed, 21 Aug 2024 12:59:34 +0200 Message-Id: <20240821105943.230281-4-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035954_526992_E21FE478 X-CRM114-Status: UNSURE ( 7.21 ) X-CRM114-Notice: Please train this message. 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 SAM9X60 SoC family has a similar OTPC to the SAMA7G5 family. Signed-off-by: Alexander Dahl --- .../devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml b/Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml index cc25f2927682..d98b6711bdfd 100644 --- a/Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml +++ b/Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml @@ -21,6 +21,7 @@ allOf: properties: compatible: items: + - const: microchip,sam9x60-otpc - const: microchip,sama7g5-otpc - const: syscon From patchwork Wed Aug 21 10:59:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771235 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 A8BB4C52D6F for ; Wed, 21 Aug 2024 11:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=i/ckHEQYfw6TnDB+9CVHZLVZThux547JhXou9MWo738=; b=jWJV5P4CE63L28Pe2raUouAB4f ipE+qFoE3fqma/En8YhCKigTmPvDlsOQQ5a9ZUz3WCrmN6iGufHQI6UVLRB69zOBChScMwnpz0Vgy SVz6FRp63ajJtq2COLlbvxm4NMzq+BvEzN1an5GDPkOmfTJcWVMlTpshJ210F7OhC3TV8pfwuagYw P44a0k9NUqARqfDoWycdVrmIsmdBRFm0jv43lpgBXJQ+zy5KpXkxyXOOJQVkSBXqvJJeBpSlQNkur 7ttV/VnCj95nAYvkLcrLnPGiaWIB+Q82I58IS9We40EhrAtpGFyVN4xWti7dakmN2Qa61RrHhN7QS fxO4xBXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj7x-00000008Ypu-06OG; Wed, 21 Aug 2024 11:03:45 +0000 Received: from mail.thorsis.com ([217.92.40.78]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4E-00000008XSB-26tu for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 10:59:57 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DAD6F1483DF5; Wed, 21 Aug 2024 12:59:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237993; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=i/ckHEQYfw6TnDB+9CVHZLVZThux547JhXou9MWo738=; b=rGG9LCDSm0fkhl56SGjODNpBKWm1V8D5PrYK2UCtQV43tq4Nrps/v/0kiT85fvlCWA/pVe vSZgNKWIF5+vU4Qi1W57x/BRaPRQt6M022rPdRX6PNFrMD8VbRiYGLHU9aeJc8Kl1DwRz4 mR9oQ+H3VpO5HxB2KVIgh4Ak2+yS+M7+xe3hh6d1W8GR22q7mNq48KBv8lFG+iKss4sn8O y3QbFqDKIgnIgUELUP1kBzwnd3Oy23gXGWXZKp3XDZArYqa8HB2NWqSfAu3y5SWTFoQp2K AMyITMJp+eSh+6cnAYMpbIHpsvtNGXoapzEFN4nGOCOczaZq+NaYyW0D3FDY1w== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 04/12] nvmem: microchip-otpc: Add SAM9X60 support Date: Wed, 21 Aug 2024 12:59:35 +0200 Message-Id: <20240821105943.230281-5-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035954_727415_FAFA9882 X-CRM114-Status: UNSURE ( 9.11 ) X-CRM114-Notice: Please train this message. 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 Register layout is almost identical to sama7g5 OTPC. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index bd3383eabdf6..b8ed7412dbca 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -271,6 +271,7 @@ static int mchp_otpc_probe(struct platform_device *pdev) static const struct of_device_id __maybe_unused mchp_otpc_ids[] = { { .compatible = "microchip,sama7g5-otpc", }, + { .compatible = "microchip,sam9x60-otpc", }, { }, }; MODULE_DEVICE_TABLE(of, mchp_otpc_ids); From patchwork Wed Aug 21 10:59:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771236 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 60DEAC52D7C for ; Wed, 21 Aug 2024 11:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date :Subject:To:From:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=16XwRQ9Fnf5UaoUkVrP6/gJBIWPHHwI4pGVmwBYvBoM=; b=gjlakUMnsizzgJ dAomJrrjOateMfUe8rgLXsvHYX+hilHjgGZVk2elKjD6sw0aRHXWjCIzc+4kvRDL029IPczZnMLuo V6fwzEtlPj0qCfUWDfpq0YFrUCWDRjNMLE9MtOoOjfvxjAE/lNOWtg5PzJpfQze7ilf+THqGleNWe VHOixY8sBxKv/yUfBExJqPbqZOwmC5lQVX628otPUImobpn3J1g7r/zFmWs2bO8Lzv/IPDtykhEyS HsmcW9Ba9DzkXQnpvXT3KCGohMg4PD/xJt/TNLrL0nChk7Kg/84o+eVhzdm34WRQKRMUDwelY/HsD 5DXAdTqqHgGfhLFeRqIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj8g-00000008ZCD-1azO; Wed, 21 Aug 2024 11:04:30 +0000 Received: from mail.thorsis.com ([2003:a:e28:26e4::10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4G-00000008XUA-2zVj for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 10:59:59 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 697211483DF6; Wed, 21 Aug 2024 12:59:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237995; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=16XwRQ9Fnf5UaoUkVrP6/gJBIWPHHwI4pGVmwBYvBoM=; b=kUIOuA1VyC34Wteyyw80TGEFtsL048BEsSLab6Q79E3iie5zLTNXdlTHmXcJzB/dxzRYhJ 0a5sX98oqWlLFzN+clu5sCSF1QjGEdAz+6usFZ8GU9hGgeIn0GJOhSA1H6OdttAHxTDa24 SvowOrwbgIe2KeSDSjAgMW7whNiZ/GUY3iJBpC165rc19kMXOQJWmgcc7NlRKpeUbSo9J+ cTsYkZYxzKp59yurJ7cWNRIjb3cp0TGzqf3Ba5TEo2e/mlCLyLE5Ep51ZqtZ8Las581yUD HnGFvXB8wLhwqFeTzXTv1rQWd5U6guNB2nFoNNJYX2jIeQtQVadLKp+sTlaV7Q== From: Alexander Dahl To: Claudiu Beznea Subject: [PATCH v1 06/12] ARM: dts: microchip: sam9x60_curiosity: Enable OTP Controller Date: Wed, 21 Aug 2024 12:59:37 +0200 Message-Id: <20240821105943.230281-7-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035957_001261_8CDFA106 X-CRM114-Status: UNSURE ( 7.92 ) X-CRM114-Notice: Please train this message. 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: , Cc: Rob Herring , Conor Dooley , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list , Christian Melki , Alexandre Belloni , Krzysztof Kozlowski , "moderated list:ARM/Microchip AT91 SoC support" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allows to access the OTP memory now, and Product UID later. Signed-off-by: Alexander Dahl --- arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts b/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts index c6fbdd29019f..754ce8134f73 100644 --- a/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts +++ b/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts @@ -254,6 +254,10 @@ ethernet-phy@0 { }; }; +&otpc { + status = "okay"; +}; + &pinctrl { adc { pinctrl_adc_default: adc-default { From patchwork Wed Aug 21 10:59:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771240 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 E77D4C52D7C for ; Wed, 21 Aug 2024 11:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TJAnNoD40VE5kpvISU24IPj7vHBlSQ5pDs+zABOQSs0=; b=BAOq6CY8qFMQYcy/sI7aQ6FXSH kFDMUI7GWO6lRZC+ot9SjAi5/LoLh267FF6+65FPsD8rahhFIaz//zsMMZ5i3Z3uH/NJJCoz1asWN TclIhycqDDtVz82fYI1DqXZx4w/8AHNGlGZtuylS7FI2/peWgOjB8SjtJc9XZx46EDdoH6XcnKQtQ Z4CWS3L9Kzlam7ebKCHUAv2bMdS3qPaA7Kt3LMvSO8vdZJdESmgtzy7JU8Lj5JE2JZa1ZuHRnzo/e bg/2v/L2rVbkAQMBek0K/8umeZE9dyd2bDwqogS7XitkvsPTLdCv0etENsL6+QE9FIUTXfemF9IbQ sL/N3g1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj9N-00000008ZUJ-1X1y; Wed, 21 Aug 2024 11:05:13 +0000 Received: from mail.thorsis.com ([217.92.40.78]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4H-00000008XUW-0or7 for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 11:00:06 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 87DDB1483DF7; Wed, 21 Aug 2024 12:59:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237995; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=TJAnNoD40VE5kpvISU24IPj7vHBlSQ5pDs+zABOQSs0=; b=YMTL7SeQM64uKQNcWd8bzFevbMhV0oqgifu10n6KA86rdiPH5/XtLyoqVc+EjgRrO042ZV WspHsUoaxdQq2QWugRBxsls/7Lr67GHSs4My+YXTlAWDHxnAO71iIh1hQNfQwz22PC9Xb7 VFt8vRJbDCBibIR5iHN95fGK2EdFn3g2yAr7zDjHfDL/8WF7Ee/PcbuTenMYgRw/EJ90k8 AYoiuABeJ1Qz8Zg4W8Q+Zoq3o3UwsFXw5iWE7tlW7fXqPdiWycUMIYkYy16Cy9dOQbywCK t5eOW43r8s7ziqZyRRTWZ7q7pax4+IRdh2JtBQWCJ44zTUryvP/r7L5kvwG0Vg== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 07/12] nvmem: microchip-otpc: Add missing register definitions Date: Wed, 21 Aug 2024 12:59:38 +0200 Message-Id: <20240821105943.230281-8-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035957_804506_2742AFB6 X-CRM114-Status: UNSURE ( 6.68 ) X-CRM114-Notice: Please train this message. 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 According to datasheets DS60001765B for SAMA7G5 and DS60001579G for SAM9X60. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index b8ed7412dbca..4630e96243ac 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -21,9 +21,24 @@ #define MCHP_OTPC_AR (0x8) #define MCHP_OTPC_SR (0xc) #define MCHP_OTPC_SR_READ BIT(6) +#define MCHP_OTPC_IER (0x10) +#define MCHP_OTPC_IDR (0x14) +#define MCHP_OTPC_IMR (0x18) +#define MCHP_OTPC_ISR (0x1C) +#define MCHP_OTPC_ISR_COERR BIT(13) #define MCHP_OTPC_HR (0x20) #define MCHP_OTPC_HR_SIZE GENMASK(15, 8) #define MCHP_OTPC_DR (0x24) +#define MCHP_OTPC_BAR (0x30) +#define MCHP_OTPC_CAR (0x34) +#define MCHP_OTPC_UHC0R (0x50) +#define MCHP_OTPC_UHC1R (0x54) +#define MCHP_OTPC_UID0R (0x60) +#define MCHP_OTPC_UID1R (0x64) +#define MCHP_OTPC_UID2R (0x68) +#define MCHP_OTPC_UID3R (0x6C) +#define MCHP_OTPC_WPMR (0xE4) +#define MCHP_OTPC_WPSR (0xE8) #define MCHP_OTPC_NAME "mchp-otpc" #define MCHP_OTPC_SIZE (11 * 1024) From patchwork Wed Aug 21 10:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771241 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 643B1C52D6F for ; Wed, 21 Aug 2024 11:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+hE4Oaa/+RDBODWq0UJM3XXnYgcGWlBIKzul9txp90I=; b=TrNkuKPAlyxN38GomnaPYmRArd 1nuZQnXfIv4R4LVCkq2MC1Y/kwFimJEHH1OKtRz3y8pubqnvbquifqglmIXFEAMAYEMJb9Ldpczap tN78+OWAgazAaeumSyPEPTfCkymuzeaOrtBpaZk6J+pJ6MMEWmUG4gVFyNs9FYxD6RDyxu+ZWwdFy vTPFp9Sjt/l5LVXzH1hFJwo4VT6SdCQD3IMhtwf9+1v+VrS2BtH8KVgOtGEGQBnz6erkpbRLILJVF 29bTBQ8xDMyvoou04OpkYXvZ2e0nK5Ta0OE6fBrB45fn3WCIDmx8iUpKuELZLvC3G9wNYotsiSt2P L3/Nv54A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgjAC-00000008Zsb-3Xdq; Wed, 21 Aug 2024 11:06:04 +0000 Received: from mail.thorsis.com ([2003:a:e28:26e4::10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4I-00000008XV9-0Gm4 for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 11:00:07 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DDC611483DF8; Wed, 21 Aug 2024 12:59:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237996; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=+hE4Oaa/+RDBODWq0UJM3XXnYgcGWlBIKzul9txp90I=; b=H4An3j4CsF/zMsyyX616M0lmcq0coy9KfP0i1tuxNvh/Z3qtjzQZj4E8+44XU3I4+U8a+R JXtT0A/0TVrbPuMyC0RcSC+pYUXX9tNsx1CGkCKslwBH/fkXRl1LGucosKHd/u5aG0cA7j grkIE4uQFVAWFkdKAmP5POGgyzMuUFZU1RywA98xK33WEmzh8FP/D5yBA20WureSPre/V4 pmdaRkH31phg35fxpBCZl5CEu34UV5Y0SZUJK282z2JkVD43gC485p6KzyBhvYYwCxEpJR Mf76kaXaYmIq6ZA8Ix2biACBKaMub9I6Ajx6A9S7jlyNNJsQ+wcobMb6/5mV3w== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 08/12] nvmem: microchip-otpc: Add warnings for bad OTPC conditions on probe Date: Wed, 21 Aug 2024 12:59:39 +0200 Message-Id: <20240821105943.230281-9-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035958_364592_41DBCB1A X-CRM114-Status: GOOD ( 10.40 ) 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 These conditions could affect correct function of the driver. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index 4630e96243ac..a80535c3d162 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -260,6 +261,7 @@ static int mchp_otpc_probe(struct platform_device *pdev) struct nvmem_device *nvmem; struct mchp_otpc *otpc; u32 size; + u32 reg; int ret; otpc = devm_kzalloc(&pdev->dev, sizeof(*otpc), GFP_KERNEL); @@ -270,6 +272,16 @@ static int mchp_otpc_probe(struct platform_device *pdev) if (IS_ERR(otpc->base)) return PTR_ERR(otpc->base); + reg = readl_relaxed(otpc->base + MCHP_OTPC_WPSR); + if (reg) + dev_warn(&pdev->dev, + "Write Protection Status Register Bit set: 0x%08x\n", reg); + + reg = readl_relaxed(otpc->base + MCHP_OTPC_ISR); + if (reg & MCHP_OTPC_ISR_COERR) + dev_warn(&pdev->dev, + "A corruption occurred since the last read of OTPC_ISR.\n"); + otpc->dev = &pdev->dev; ret = mchp_otpc_init_packets_list(otpc, &size); if (ret) From patchwork Wed Aug 21 10:59:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771242 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 2621FC52D6F for ; Wed, 21 Aug 2024 11:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date :Subject:To:From:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f3c3Rb0MaGLfvzOor2+zbB5i0hEP30uww3c4MW+lsbw=; b=taJ1nRZqn+NSxZ TzC5SVIVMUHnds5zBa49CAnrECRXy2E3J1Dr+3fVR0rHc6FgvRQx12XFDLjkfmGx83Sv6CVMe2z2Q cuD+sq4jHzWhT+K9biuuiNFJwdtJpV4vKiDqI76GrgFh4oj9DKCqdmLw59fq9MqA/StKclzVE8jD2 ORkRwk0heoN/hXuMpWxm3Owt7bYxk5TLJMUD8AWOw7sAdrDm7RALhN+CT8e7N8yk+sJClwh5lrlQp Lzp0iiOi9zf7sjMhLuWb57YoHk5qY+H5hRzs08EXrSVxtpbK4wKORMXXXXyeUyk8YrxibC89g8m25 l4TQPmjwNvnkqIG+gIXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgjBe-00000008aSC-1mEq; Wed, 21 Aug 2024 11:07:34 +0000 Received: from mail.thorsis.com ([217.92.40.78]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4I-00000008XW5-3zpd for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 11:00:09 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D8D5B1483DED; Wed, 21 Aug 2024 12:59:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237997; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=f3c3Rb0MaGLfvzOor2+zbB5i0hEP30uww3c4MW+lsbw=; b=YmOGDdOgxWvh/GWC/OCxBEmVYsKO3lJkNsRx3guhWR1wIDL1qcFGNbGznSRMKndM1od4RH SYnWCBbfaXD2k3JeMbj7dDMWL+4w48QEdz1GyFdd4A5j5w8qj2PU0sqwDZFZkl+7W4R3R6 dn0SDIUkNJ1RbW2wmTQ9JCNQZHKHrj5IzvExaqyT++6suwhJX3rsvRq+DAAxQhKehlS1Un 2dcVNNj9a5/5SfJQvOGzNZCwu5AX7L+sfxGPHJJnIzxTp8xnV68f7pw83ATU4ibQPqQATT eX55ep9Gll/Mk++jVEPZcoyM5RrV+Y6Zn1I7dZFfNx7zxVlrzPLQMU554RMn6Q== From: Alexander Dahl To: Claudiu Beznea Subject: [PATCH v1 09/12] clk: at91: sam9x60: Allow enabling main_rc_osc through DT Date: Wed, 21 Aug 2024 12:59:40 +0200 Message-Id: <20240821105943.230281-10-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035959_280074_B069BF12 X-CRM114-Status: GOOD ( 13.66 ) 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: , Cc: Conor Dooley , Rob Herring , Alexandre Belloni , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Stephen Boyd , open list , Christian Melki , "open list:COMMON CLK FRAMEWORK" , Krzysztof Kozlowski , Michael Turquette , "moderated list:ARM/Microchip AT91 SoC support" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org SAM9X60 Datasheet (DS60001579G) Section "23.4 Product Dependencies" says: "The OTPC is clocked through the Power Management Controller (PMC). The user must power on the main RC oscillator and enable the peripheral clock of the OTPC prior to reading or writing the OTP memory." The code for enabling/disabling that clock is already present, it was just not possible to hook into DT anymore, after at91 clk devicetree binding rework back in 2018 for kernel v4.19. Signed-off-by: Alexander Dahl --- drivers/clk/at91/sam9x60.c | 3 ++- include/dt-bindings/clock/at91.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/at91/sam9x60.c b/drivers/clk/at91/sam9x60.c index e309cbf3cb9a..4d5ee20b8fc4 100644 --- a/drivers/clk/at91/sam9x60.c +++ b/drivers/clk/at91/sam9x60.c @@ -207,7 +207,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np) if (IS_ERR(regmap)) return; - sam9x60_pmc = pmc_data_allocate(PMC_PLLACK + 1, + sam9x60_pmc = pmc_data_allocate(PMC_MAIN_RC + 1, nck(sam9x60_systemck), nck(sam9x60_periphck), nck(sam9x60_gck), 8); @@ -218,6 +218,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np) 50000000); if (IS_ERR(hw)) goto err_free; + sam9x60_pmc->chws[PMC_MAIN_RC] = hw; hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL, 0); if (IS_ERR(hw)) diff --git a/include/dt-bindings/clock/at91.h b/include/dt-bindings/clock/at91.h index 3e3972a814c1..f957625cb3ac 100644 --- a/include/dt-bindings/clock/at91.h +++ b/include/dt-bindings/clock/at91.h @@ -25,6 +25,7 @@ #define PMC_PLLBCK 8 #define PMC_AUDIOPLLCK 9 #define PMC_AUDIOPINCK 10 +#define PMC_MAIN_RC 11 /* SAMA7G5 */ #define PMC_CPUPLL (PMC_MAIN + 1) From patchwork Wed Aug 21 10:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771243 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 E27D0C52D7C for ; Wed, 21 Aug 2024 11:08: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jovbb058QzzCeFDP4Da8Wb3JHly5Xy6YvCLwu8Ic6q4=; b=JyEIzkFazafl14FIitg46LkJfx 4RqaJ3t7Q9rO4D5jloU6jZ/iOVZhc9IbC/r7X5cFV8GbLs/vPk2azwK0xnE8H3eX1IHjWIKdlCv72 LUdFaml7Kssmobk5BfiOUg9cjHQ5eXgvtYemfl3pg1h0t37Y3Lv8iKaQp+sHcDtUg0YxUUTX7b2JH x5+S7MBaMDKiostVgBPJMdbsExpNc9gu7uVJMKPI+k6g4KGK9zU9BU9usZsYgOyz110YBAtskSVrS N3z1UoOnONyQJUXnvlqJ+KyNpPSTE9ko1JdGrWcRBR3CA3FSxjgXhCutxm8daDxOSt9uhOhhAum/A eAHJwucw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgjCL-00000008ahe-1pqi; Wed, 21 Aug 2024 11:08:17 +0000 Received: from mail.thorsis.com ([217.92.40.78]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4K-00000008XXk-2mMz for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 11:00:10 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1EFAA1483DF2; Wed, 21 Aug 2024 12:59:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237999; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=jovbb058QzzCeFDP4Da8Wb3JHly5Xy6YvCLwu8Ic6q4=; b=vBc/BFZPkHoTOZP55cWp8jIcwt2YXJwPdq0Zk3/yQHb06gka0w8sOFpxXT3RYBpDw73D7f IxKKLjFxrDTticjvnANOv6RIRKzqRqJpaDjZrL2Nq65z4K64/o5Q/azqfms4KPsCnSQECW pR6Y4w6MlJKoacR6z9p7hEEhwJulCg+/wDcYCB2Ayg8fehf5DYPGWx0+7GrW6MsQJ6Aw4D Zsan9FH9auUf3k/suXz2EDAoMI4G284/YeHGF9u4qiHunWMzDggWfJbCDNXqIIayEIGAoV PbWg+pxA5tkvoKw075F2xMN5E35BP8ML+unevBlaleYvWD11N1Z6q+YKkY6qLg== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 11/12] nvmem: microchip-otpc: Enable main RC oscillator clock Date: Wed, 21 Aug 2024 12:59:42 +0200 Message-Id: <20240821105943.230281-12-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_040004_204002_63594FBF X-CRM114-Status: GOOD ( 11.56 ) 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 Without enabling that clock, initializing the packet list leads to a read timeout on the first packet. According to SAM9X60 datasheet (DS60001579G) section "23.4 Product Dependencies" the clock must be enabled for reading and writing. Tested on sam9x60-curiosity board. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index a80535c3d162..047ca5ac6407 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -54,6 +55,7 @@ struct mchp_otpc { void __iomem *base; struct device *dev; + struct clk *clk; struct list_head packets; u32 npackets; }; @@ -272,6 +274,15 @@ static int mchp_otpc_probe(struct platform_device *pdev) if (IS_ERR(otpc->base)) return PTR_ERR(otpc->base); + // NOTE: Maybe make this optional, especially if sama7g5 testing + // shows the clock is not required there? + otpc->clk = devm_clk_get_enabled(&pdev->dev, "main_rc_osc"); + if (IS_ERR(otpc->clk)) { + dev_err(&pdev->dev, "Error (%ld) getting clock!\n", + PTR_ERR(otpc->clk)); + return PTR_ERR(otpc->clk); + } + reg = readl_relaxed(otpc->base + MCHP_OTPC_WPSR); if (reg) dev_warn(&pdev->dev, From patchwork Wed Aug 21 10:59:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771244 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 3440FC52D6F for ; Wed, 21 Aug 2024 11:09:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7R+I3eWvRMVL77L44Gt897N18NavS4Wc92V6aQKadT8=; b=d4RxBnGm9K1N5JskBs/HLEGl9R OYny3sm37ZX5V0j89XMt6w9OckaBuDGYDALX5Hs+ENo2CS5qLNiSmIp9q90g7MTrRN2glMciOoI0q ihms2Gc5k6wbXSxkZ9uMsyVuxO1kY8xfRX8E4avk4yAeUwZe+awnnK8LhNq8uY1IytLNesrENJUS+ ZaizXImKCllQaTNG+YiHXXI4ZecR4hvW+ZWipx4ALKlKd3XPvYADxZvS7ZTqfZzzcD99vLaGRsyll ZMGLiJnsS9n5M7Ez8NDbFC1b4TNTgUKIoS4DFV6smKU9JlypOWYZ3imDrpRSNppQugFpG4hhZ3RJT Y6SW1tmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgjD2-00000008awD-0tU7; Wed, 21 Aug 2024 11:09:00 +0000 Received: from mail.thorsis.com ([2003:a:e28:26e4::10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4N-00000008XXt-41Wh for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 11:00:11 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8F3A11483DF3; Wed, 21 Aug 2024 12:59:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237999; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=7R+I3eWvRMVL77L44Gt897N18NavS4Wc92V6aQKadT8=; b=KVp4uR8Ro7N7VsYnYCe7XQW9iovUZvzIxkjmraWg6QtT5tIdFvmg1TaDL2MdPL5cco68jN nQWP5krf94zjpxKBG/OF5ZZkvbJ4mkLHaZebnUVJ1k4QIpc1jCnj3ERK0O4thIb2bJMHhq j3HJBWWtGCGna5vefOmbNA/TMj6GlsJnBRDWRrrR0lU1l7z6pFRYusz/b++dYL4IJj08ay 0/YQmSPtbGij9AmB6NNTPT5pRZ1vXHBXwHh/hZc/PC3FvNTKThDGiOjedgeufu5lPbUJ0y yjTDVY7XPPJYoDXOkECg5awvIbh02hRaqhAWPNbmDbS84fs6UndhWNDiwaNHYA== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 12/12] nvmem: microchip-otpc: Expose UID registers as 2nd nvmem device Date: Wed, 21 Aug 2024 12:59:43 +0200 Message-Id: <20240821105943.230281-13-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_040004_909673_007D106A X-CRM114-Status: GOOD ( 13.78 ) 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 For SAM9X60 the Product UID x Register containing the Unique Product ID is part of the OTPC registers. We have everything at hand here to just create a trivial nvmem device for those. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 41 +++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index 047ca5ac6407..52af4c137204 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -45,6 +45,9 @@ #define MCHP_OTPC_NAME "mchp-otpc" #define MCHP_OTPC_SIZE (11 * 1024) +#define MCHP_OTPC_UID_NAME "mchp-uid" +#define MCHP_OTPC_UID_SIZE 16 + /** * struct mchp_otpc - OTPC private data structure * @base: base address @@ -249,6 +252,16 @@ static int mchp_otpc_init_packets_list(struct mchp_otpc *otpc, u32 *size) return 0; } +static int mchp_otpc_uid_read(void *priv, unsigned int offset, + void *val, size_t bytes) +{ + struct mchp_otpc *otpc = priv; + + memcpy_fromio(val, otpc->base + MCHP_OTPC_UID0R + offset, bytes); + + return 0; +} + static struct nvmem_config mchp_nvmem_config = { .name = MCHP_OTPC_NAME, .type = NVMEM_TYPE_OTP, @@ -258,6 +271,15 @@ static struct nvmem_config mchp_nvmem_config = { .reg_read = mchp_otpc_read, }; +static struct nvmem_config mchp_otpc_uid_nvmem_config = { + .name = MCHP_OTPC_UID_NAME, + .read_only = true, + .word_size = 4, + .stride = 4, + .size = MCHP_OTPC_UID_SIZE, + .reg_read = mchp_otpc_uid_read, +}; + static int mchp_otpc_probe(struct platform_device *pdev) { struct nvmem_device *nvmem; @@ -303,8 +325,25 @@ static int mchp_otpc_probe(struct platform_device *pdev) mchp_nvmem_config.size = size; mchp_nvmem_config.priv = otpc; nvmem = devm_nvmem_register(&pdev->dev, &mchp_nvmem_config); + if (IS_ERR(nvmem)) { + dev_err(&pdev->dev, + "Error (%ld) registering OTP as nvmem device\n", + PTR_ERR(nvmem)); + return PTR_ERR(nvmem); + } - return PTR_ERR_OR_ZERO(nvmem); + mchp_otpc_uid_nvmem_config.dev = otpc->dev; + mchp_otpc_uid_nvmem_config.priv = otpc; + + nvmem = devm_nvmem_register(&pdev->dev, &mchp_otpc_uid_nvmem_config); + if (IS_ERR(nvmem)) { + dev_err(&pdev->dev, + "Error (%ld) registering UIDxR as nvmem device\n", + PTR_ERR(nvmem)); + return PTR_ERR(nvmem); + } + + return 0; } static const struct of_device_id __maybe_unused mchp_otpc_ids[] = {