From patchwork Fri Sep 20 08:28:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 1987839 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; unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=DzUqEHAi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X96G50Zbfz1xrD for ; Fri, 20 Sep 2024 19:16:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7A9AC89434; Fri, 20 Sep 2024 11:15:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="DzUqEHAi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E2D8789386; Fri, 20 Sep 2024 10:28:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C6DED89379 for ; Fri, 20 Sep 2024 10:28:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bastien.curutchet@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id ED4C0240002; Fri, 20 Sep 2024 08:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1726820889; 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; bh=dtNGLU35uHqRhtq2T6AsPJ/PHc3n6SHvQJud6Vas9vs=; b=DzUqEHAiCxeijt8htt711eG9uh9+tWTT9daLBcX8K/K/+yrGxFy9/RoY/IXN33x6Ucautq +Gwa1/6Se17dQ0M8lnhUxQFUq+iNS11qHyoT/Zgb6zt520f/COh7sDDlqoRap4gCq9n2pR ZKdcJo6gIni3EC6yeMQkMPX5a77jsuqdhvXxg4QmdTrJQVISdxooaHdpCzCYAzk8wq2jTS LJR4bADBO21Duh+xoBm5xlLet8iQzr/oLqhsC9Q4yfz8NgwLQvZE0ue+kGeW0FEo0Ju9q7 TSn3nrd6knqKahWgTAn1RwGc8Jls6cWXaQabUeqyjk02xSEUIEXSQqEjT8tFSg== From: Bastien Curutchet To: Jagan Teki , Tom Rini Cc: u-boot@lists.denx.de, Thomas Petazzoni , Herve Codina , Christopher Cordahi , Bastien Curutchet Subject: [PATCH] spi: davinci: Drop the preload of TX buffer before read/writes operations Date: Fri, 20 Sep 2024 10:28:06 +0200 Message-ID: <20240920082806.74253-1-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-Mailman-Approved-At: Fri, 20 Sep 2024 11:15:35 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean A write to the TX buffer is performed before entering the loop to "avoid clock starvation". This sometimes results in subsequent writes in davinci_spi_xfer_data() to occur while the TXFULL bit is asserted, leading to write failures. Remove the preload of the TX buffer. Signed-off-by: Bastien Curutchet --- Hi all, I've ran into write failures to flash on my platform based on the DAVINCI/OMAP L138. This patch fixes it. drivers/spi/davinci_spi.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index 25f5e9fdeb..07c46b8b66 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -129,9 +129,6 @@ static int davinci_spi_read(struct davinci_spi_slave *ds, unsigned int len, while (readl(&ds->regs->buf) & SPIBUF_TXFULL_MASK) ; - /* preload the TX buffer to avoid clock starvation */ - writel(data1_reg_val, &ds->regs->dat1); - /* keep reading 1 byte until only 1 byte left */ while ((len--) > 1) *rxp++ = davinci_spi_xfer_data(ds, data1_reg_val); @@ -159,12 +156,6 @@ static int davinci_spi_write(struct davinci_spi_slave *ds, unsigned int len, while (readl(&ds->regs->buf) & SPIBUF_TXFULL_MASK) ; - /* preload the TX buffer to avoid clock starvation */ - if (len > 2) { - writel(data1_reg_val | *txp++, &ds->regs->dat1); - len--; - } - /* keep writing 1 byte until only 1 byte left */ while ((len--) > 1) davinci_spi_xfer_data(ds, data1_reg_val | *txp++);