From mboxrd@z Thu Jan 1 00:00:00 1970 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 C10E5FDEE32 for ; Thu, 23 Apr 2026 17:40:42 +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:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XFfXl4/GQbW6GPX8t/YkBYX4DbIwbw9iQSWalhVhYcE=; b=JvlVF/frfdRuH4tbX1wYfDi/OD 7ZXsTF+lcdIe1cc12Rge5m1ReRHy4v4zbzSVXI8HBDP8MBfUH0UNDXErvvBERf3q9hPohRO2t8xpa n7hjcUCVJcqF0Q9Gbrk3XW4siBMEVs3Ku3KY2Mf4Yu454Z+DV/KHL5NDgVhpIBjUNb+V0cKVeC6SD arKrkkPVbFXEHAer5WtZ2NSRiloxlmQ4AczL08/VLJ+rlC5QZvk0I4dS3lGLRROccsfVvlnkoG8Pj B4ruqeDkcH0xCAblK6KzUdHrpIf/DABm9QdaYoLaNdX/hvIO1kl0zmJS/yeqYPfz7Z2MSdK3Is33p Sc3jj0Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wFy2Y-0000000C45f-47m4; Thu, 23 Apr 2026 17:40:38 +0000 Received: from fout-a4-smtp.messagingengine.com ([103.168.172.147]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wFy2W-0000000C455-1Lln for linux-arm-kernel@lists.infradead.org; Thu, 23 Apr 2026 17:40:37 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 4B4AAEC05C0; Thu, 23 Apr 2026 13:40:35 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 23 Apr 2026 13:40:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kevinmehall.net; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1776966035; x= 1777052435; bh=XFfXl4/GQbW6GPX8t/YkBYX4DbIwbw9iQSWalhVhYcE=; b=l pnRw64xa6RXfvS8Km3M+XHQo9aJ2zZIzDtgAF7wkS/uMsyNdNYMMYgJBXprxwLYZ 6wmgqmKzJcOVEOraO4/2fAsd+LTx+S4vZ7YEr34dGP/YSHCVLJv7fmM8czXlWoMT kUeF6TDPXvWH2kdG/HMd8KTSkHpTr3wa1TkuZC+2t2nZrt2G65RneuOtMl2+LrgU hY5jYQ7PKH3PSjdJpd5H/w9uIpSfIGIDw5HABfC6R+oWuY+Y3gXvQcDrLIv7J/3I hI/6jNuvxWNxugEJo6jwaNb1zz1Qhha5/kngufct/iC6VCqrmwPeWa6iFoaRQBEx m565R/a4UEnY+cAOvSFiw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1776966035; x=1777052435; bh=XFfXl4/GQbW6GPX8t/YkBYX4DbIw bw9iQSWalhVhYcE=; b=S9Z3l2eEX7kTyTFrqRqiZXCz+DZPq/EcS7H/umYt9zg5 9d0LPH7CvgKx1sWETULB8uFvOJbVVFlJCWvQ1YgSD6DgfUWNkftDqFLI493PK3OQ v05U8je5zWtt0akV2BXWzxEmarGHN9qhhdiODriodg0A/Hf5H+r1iAfWqCHi8PEK EACuPvBpsOzE+l6Yen5HBrmr+tOFzAe7FztxkhZVUf1fwsO/C8uvkI0/mKzGBTLp 6OAButVZ0NXXvyz00iwsMBpJTSkyq78x+Cn5IBIjVgCNviSvDYJpjQVUh3hjruZL vVG75gunLisUBqzpGWJTtt2+OHK9vgMZupncmSRkTw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeijeejjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfgvvhhinhcuofgv hhgrlhhluceokhhmsehkvghvihhnmhgvhhgrlhhlrdhnvghtqeenucggtffrrghtthgvrh hnpeduhfeljeetgfeiheetieelveejhfdtledutedvgffgveeihffhkefguedvffegvden ucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepkhhmsehkvghvihhnmhgvhhgrlhhlrdhnvghtpdhn sggprhgtphhtthhopedutddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsghroh honhhivgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfigvnhhssehkvghrnhgvlhdr ohhrghdprhgtphhtthhopehjvghrnhgvjhdrshhkrhgrsggvtgesghhmrghilhdrtghomh dprhgtphhtthhopehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgpdhrtghpthhtohep mhhirhhkohdquggvvhiklhhinhhugiesnhgrnhhlrdguvgdprhgtphhtthhopehrshgtse hruhhnthhugidrtghomhdprhgtphhtthhopehlihhnuhigqdhsphhisehvghgvrhdrkhgv rhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrghrmhdqkhgvrhhnvghlsehlih hsthhsrdhinhhfrhgruggvrggurdhorhhgpdhrtghpthhtoheplhhinhhugidqshhunhig iheslhhishhtshdrlhhinhhugidruggvvh X-ME-Proxy: Feedback-ID: i421842c8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Apr 2026 13:40:33 -0400 (EDT) From: Kevin Mehall To: Mark Brown , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Mirko Vogt , Ralf Schlatterbeck , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] spi: sun6i: Honor CS setup delay on the first transfer with native CS Date: Thu, 23 Apr 2026 11:40:00 -0600 Message-ID: <20260423174001.2797797-2-km@kevinmehall.net> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260423174001.2797797-1-km@kevinmehall.net> References: <20260423174001.2797797-1-km@kevinmehall.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260423_104036_425860_F756ACC2 X-CRM114-Status: GOOD ( 11.26 ) 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 Move SUN6I_TFR_CTL_CS_MANUAL to sun6i_spi_set_cs. The CS_MANUAL bit is required for CS_LEVEL to affect the CS pin state. Set it in the same place as other CS bits to ensure that set_cs takes effect immediately, and to make it easier to reason about CS behavior. Previously, this bit was not set until the first transfer's sun6i_spi_transfer_one. That meant that on the first transfer, set_cs would have no immediate effect, and the CS falling edge was deferred until the bit is set in transfer_one. As any configured cs_setup delay happens between those two steps, the configured delay would have effectively been ignored on the very first transfer. This change makes the first transfer work like subsequent ones. Link: https://lore.kernel.org/linux-spi/d199f72a-093b-41bb-b33e-b6685563f704@app.fastmail.com/ Fixes: 3558fe900e8a ("spi: sunxi: Add Allwinner A31 SPI controller driver") Signed-off-by: Kevin Mehall --- drivers/spi/spi-sun6i.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c index 240e46f84f7b..fc228574ed38 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c @@ -185,6 +185,10 @@ static void sun6i_spi_set_cs(struct spi_device *spi, bool enable) u32 reg; reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG); + + /* SUN6I_TFR_CTL_CS_LEVEL sets CS rather than the controller doing it automatically */ + reg |= SUN6I_TFR_CTL_CS_MANUAL; + reg &= ~SUN6I_TFR_CTL_CS_MASK; reg |= SUN6I_TFR_CTL_CS(spi_get_chipselect(spi, 0)); @@ -364,9 +368,6 @@ static int sun6i_spi_transfer_one(struct spi_controller *host, reg |= SUN6I_TFR_CTL_DHB; } - /* We want to control the chip select manually */ - reg |= SUN6I_TFR_CTL_CS_MANUAL; - sun6i_spi_write(sspi, SUN6I_TFR_CTL_REG, reg); if (sspi->cfg->has_clk_ctl) { -- 2.53.0