From patchwork Tue Dec 3 10:38:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Rebmann X-Patchwork-Id: 2017685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=w6UfNjJY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y2czc6N5Wz1yR0 for ; Tue, 3 Dec 2024 21:57:00 +1100 (AEDT) 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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jZk32Ngi0N9nkHWsOtu6f4pae+yPDEI3ECAbuNU43G0=; b=w6UfNjJY+AqL0w M4fjwSMNMV2Q6GdgvUBPl4+WwIV50z+gOYHJp42wmZmkYrroW0UWTkjJuqGHq5H+IYLF4TkVjOKb+ h1V1q6+2XgNStQOmyR1yL18JwCt5J4DxEMmfdLTpvyzjY8FRwlwtSX3tI0m2L8UA+Qn83ra9FP+cC FSuW3Xl12kpzSrsLVXAbomPOceWbsxv/njfVHZFFVeTIDizQq0vZnntCmDoWGznbFKaayAaQjEyk/ rxpJvybAzmlJDZkzQPICZ+7pxJlVBM/wDqexrWUmqljuzVks+0S2Ye0va7+lvBiMS2W+jrMSFHMKy dmDHSAUlCAHScGuyA6VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tIQaJ-000000099qf-2Fn6; Tue, 03 Dec 2024 10:56:51 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tIQJH-0000000964H-2l3l for linux-mtd@lists.infradead.org; Tue, 03 Dec 2024 10:39:17 +0000 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1tIQJ6-00012Q-2c; Tue, 03 Dec 2024 11:39:04 +0100 From: Jonas Rebmann Date: Tue, 03 Dec 2024 11:38:35 +0100 Subject: [PATCH v3 1/3] mtd: mchp48l640: make WEL behaviour configurable MIME-Version: 1.0 Message-Id: <20241203-mb85rs128ty-v3-1-79107d54d839@pengutronix.de> References: <20241203-mb85rs128ty-v3-0-79107d54d839@pengutronix.de> In-Reply-To: <20241203-mb85rs128ty-v3-0-79107d54d839@pengutronix.de> To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Schocher Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, David Jander , kernel@pengutronix.de, Jonas Rebmann X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1743; i=jre@pengutronix.de; h=from:subject:message-id; bh=pmKV2DTV1hVzHSifSfG65uDKd3xGW/MuLvE4Vczmd2E=; b=owGbwMvMwCF2ZcYT3onnbjcwnlZLYkj3u39kRrfVeSbBia9O6pavmebx4fPZzxbeURUp7xY5N NstuqHh3FHKwiDGwSArpsgSqyanIGTsf92s0i4WZg4rE8gQBi5OAZjImiBGhov+KzlOrX24eMnM TeHp337E+ddOem10bnf/09x+J9bex4oM/90vdGxy31PVs9mhg2sj44Nf6+dHJhgs0Hh8e7HvxBO GHGwA X-Developer-Key: i=jre@pengutronix.de; a=openpgp; fpr=0B7B750D5D3CD21B3B130DE8B61515E135CD49B5 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::ac X-SA-Exim-Mail-From: jre@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241203_023915_702612_CAFF6DFB X-CRM114-Status: GOOD ( 13.96 ) X-Spam-Score: -4.2 (----) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: David Jander The 48L640 resets the WEL bit (the Write Enable Latch bit in the status register) to zero on the completion of write operations. In preparation to support chips behaving differently, introduce .auto_d [...] Content analysis details: (-4.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [2a0a:edc0:2:b01:1d:0:0:104 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: David Jander The 48L640 resets the WEL bit (the Write Enable Latch bit in the status register) to zero on the completion of write operations. In preparation to support chips behaving differently, introduce .auto_disable_wel capability, and, if it's missing, explicitly reset the WEL bit after writes. Signed-off-by: David Jander Reviewed-by: Heiko Schocher Signed-off-by: Jonas Rebmann --- drivers/mtd/devices/mchp48l640.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/devices/mchp48l640.c b/drivers/mtd/devices/mchp48l640.c index f576e6a890e859e7d20aeeb2ede4ca0acf4850fc..4cdd24aaed416fc7e40a8060b5c7eaf6684fc6d5 100644 --- a/drivers/mtd/devices/mchp48l640.c +++ b/drivers/mtd/devices/mchp48l640.c @@ -27,6 +27,7 @@ struct mchp48_caps { unsigned int size; unsigned int page_size; + bool auto_disable_wel; }; struct mchp48l640_flash { @@ -194,9 +195,15 @@ static int mchp48l640_write_page(struct mtd_info *mtd, loff_t to, size_t len, else goto fail; - ret = mchp48l640_waitforbit(flash, MCHP48L640_STATUS_WEL, false); - if (ret) - goto fail; + if (flash->caps->auto_disable_wel) { + ret = mchp48l640_waitforbit(flash, MCHP48L640_STATUS_WEL, false); + if (ret) + goto fail; + } else { + ret = mchp48l640_write_prepare(flash, false); + if (ret) + goto fail; + } kfree(cmd); return 0; @@ -293,6 +300,7 @@ static int mchp48l640_read(struct mtd_info *mtd, loff_t from, size_t len, static const struct mchp48_caps mchp48l640_caps = { .size = SZ_8K, .page_size = 32, + .auto_disable_wel = true, }; static int mchp48l640_probe(struct spi_device *spi)