| Message ID | 20260423174001.2797797-2-km@kevinmehall.net (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-22927-sunxi=pue.re@lists.linux.dev>
X-Original-To: noreply@patchwork.local
Delivered-To: noreply@patchwork.local
Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mxe881.netcup.net (Postfix) with ESMTPS id C6D741C0063
for <noreply@patchwork.local>; Thu, 23 Apr 2026 19:40:51 +0200 (CEST)
Authentication-Results: mxe881;
dkim=pass header.d=kevinmehall.net;
dkim=pass header.d=messagingengine.com;
spf=pass (sender IP is 172.232.135.74)
smtp.mailfrom=linux-sunxi+bounces-22927-noreply=patchwork.local@lists.linux.dev
smtp.helo=sto.lore.kernel.org
Received-SPF: pass (mxe881: domain of lists.linux.dev designates
172.232.135.74 as permitted sender) client-ip=172.232.135.74;
envelope-from=linux-sunxi+bounces-22927-noreply=patchwork.local@lists.linux.dev;
helo=sto.lore.kernel.org;
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org
[100.90.174.1])
by sto.lore.kernel.org (Postfix) with ESMTP id C8C363014B83
for <noreply@patchwork.local>; Thu, 23 Apr 2026 17:40:43 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id B113E3A960A;
Thu, 23 Apr 2026 17:40:38 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=kevinmehall.net header.i=@kevinmehall.net
header.b="lpnRw64x";
dkim=pass (2048-bit key) header.d=messagingengine.com
header.i=@messagingengine.com header.b="S9Z3l2eE"
X-Original-To: linux-sunxi@lists.linux.dev
Received: from fout-a4-smtp.messagingengine.com
(fout-a4-smtp.messagingengine.com [103.168.172.147])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2941B3A875E
for <linux-sunxi@lists.linux.dev>; Thu, 23 Apr 2026 17:40:36 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=103.168.172.147
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1776966038; cv=none;
b=Mc6NXrzZYhbNoMKxyiZeUoUz+8cpDiLbCdiHcyTBo40OE/TeISNX3yCQJMeamrm6zaw3cFuakjjv0Kr730ev//8MtEcR5aojQcSoa7SxPHyq9AnI4osoLOAYv2XvQrC/OAVIDOkCsIh1aNW26rNciv8ahn0akEhlr340DFgwyWA=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1776966038; c=relaxed/simple;
bh=8WHRE7PsKgt1I1RbMZATFo5T1e9JAAGj4qCpgvPY1c4=;
h=From:To:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version;
b=tgk9ref4E/vBFRQwBF6NsXOK3Dct9K55IAEiJaQFkvMYtYWZxzo1g3TutA5Ns1PCQY2Ou8y2fx6Pf449h0MNrVcs95Jd5TcV8CL8Nd7bTfJjhRVMmA4W6MCIpupRbsAZ66+TFdn9VkrTpB8UJvOS7aKM6QAyX3QciI7xAABNB/o=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass (p=reject dis=none) header.from=kevinmehall.net;
spf=pass smtp.mailfrom=kevinmehall.net;
dkim=pass (2048-bit key) header.d=kevinmehall.net header.i=@kevinmehall.net
header.b=lpnRw64x;
dkim=pass (2048-bit key) header.d=messagingengine.com
header.i=@messagingengine.com
header.b=S9Z3l2eE; arc=none smtp.client-ip=103.168.172.147
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=reject dis=none) header.from=kevinmehall.net
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=kevinmehall.net
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: <xms:klnqaW4w-wFXcOJ8jd55NWYVkt17yjyd5iuCG5VVx1E-rv9dJz4PnQ>
<xme:klnqaYGDUFHMJDOWNwfI76WitXOhkT80VtGHyfcrbDGvl-0fHtF-hThwzQarraPeJ
Uir36Su5SXpqwThXGEY3gYkaAQJnqdKtbdTXi6xew8QvD-37Lne>
X-ME-Received:
<xmr:klnqaRCm1JdkTz3BKNRlfQHwLetS-ru2oX9kFga_1rNt9ODJS5z07p4_867V>
X-ME-Proxy-Cause:
gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeijeejjecutefuodetggdotefrod
ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr
ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug
hrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfgvvhhinhcuofgv
hhgrlhhluceokhhmsehkvghvihhnmhgvhhgrlhhlrdhnvghtqeenucggtffrrghtthgvrh
hnpeduhfeljeetgfeiheetieelveejhfdtledutedvgffgveeihffhkefguedvffegvden
ucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc
frrghrrghmpehmrghilhhfrhhomhepkhhmsehkvghvihhnmhgvhhgrlhhlrdhnvghtpdhn
sggprhgtphhtthhopedutddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsghroh
honhhivgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfigvnhhssehkvghrnhgvlhdr
ohhrghdprhgtphhtthhopehjvghrnhgvjhdrshhkrhgrsggvtgesghhmrghilhdrtghomh
dprhgtphhtthhopehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgpdhrtghpthhtohep
mhhirhhkohdquggvvhiklhhinhhugiesnhgrnhhlrdguvgdprhgtphhtthhopehrshgtse
hruhhnthhugidrtghomhdprhgtphhtthhopehlihhnuhigqdhsphhisehvghgvrhdrkhgv
rhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrghrmhdqkhgvrhhnvghlsehlih
hsthhsrdhinhhfrhgruggvrggurdhorhhgpdhrtghpthhtoheplhhinhhugidqshhunhig
iheslhhishhtshdrlhhinhhugidruggvvh
X-ME-Proxy: <xmx:klnqadya9QuSMRBI5kpgADidSfj9UD08sfWocPE2IcHvXLX-VM5aXA>
<xmx:klnqaV7b0kIxonyFIxf-2yUiLVO49TAZi6M16So9qHYUFTTRW1EvFA>
<xmx:klnqaeytaprLT87dvg3dsp72KcnZvzmx95n8olx17KjhwBOr0wpLIA>
<xmx:klnqaZcwCWUj410nNXcjLeuua-8tBuXRUdiftgd7cQQ0xrle7BQ1kg>
<xmx:k1nqaQNsaeS4dI4SYBZeWkSPWlL9CKsy0MNlHX3DfET4hHX5OnxfNhVJ>
Feedback-ID: i421842c8:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu,
23 Apr 2026 13:40:33 -0400 (EDT)
From: Kevin Mehall <km@kevinmehall.net>
To: Mark Brown <broonie@kernel.org>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Mirko Vogt <mirko-dev|linux@nanl.de>,
Ralf Schlatterbeck <rsc@runtux.com>,
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>
Precedence: bulk
X-Mailing-List: linux-sunxi@lists.linux.dev
List-Id: <linux-sunxi.lists.linux.dev>
List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Rspamd-Server: rspamd-worker-8404
X-Spamd-Result: default: False [-0.66 / 15.00];
BAYES_HAM(-5.50)[100.00%];
RBL_SENDERSCORE(2.00)[172.232.135.74:from];
SUSPICIOUS_RECIPS(1.50)[];
MID_CONTAINS_FROM(1.00)[];
R_MISSING_CHARSET(0.50)[];
MAILLIST(-0.15)[generic];
MIME_GOOD(-0.10)[text/plain];
BAD_REP_POLICIES(0.10)[];
HAS_LIST_UNSUB(-0.01)[];
R_DKIM_ALLOW(0.00)[kevinmehall.net:s=fm1,messagingengine.com:s=fm2];
FROM_HAS_DN(0.00)[];
PRECEDENCE_BULK(0.00)[];
RCVD_VIA_SMTP_AUTH(0.00)[];
DBL_BLOCKED_OPENRESOLVER(0.00)[kevinmehall.net:email,kevinmehall.net:dkim,messagingengine.com:dkim,sto.lore.kernel.org:rdns,sto.lore.kernel.org:helo];
TAGGED_RCPT(0.00)[];
RCVD_COUNT_SEVEN(0.00)[7];
FUZZY_BLOCKED(0.00)[rspamd.com];
FROM_NEQ_ENVFROM(0.00)[km@kevinmehall.net,linux-sunxi@lists.linux.dev];
ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1];
ASN(0.00)[asn:63949, ipnet:172.232.128.0/19, country:SG];
R_SPF_ALLOW(0.00)[+ip4:172.232.135.74:c];
DKIM_TRACE(0.00)[kevinmehall.net:+,messagingengine.com:+];
TO_DN_SOME(0.00)[];
FORGED_SENDER_MAILLIST(0.00)[];
RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.90.174.1:received];
TAGGED_FROM(0.00)[bounces-22927-noreply=patchwork.local];
DMARC_POLICY_ALLOW(0.00)[kevinmehall.net,reject];
FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,nanl.de,runtux.com,vger.kernel.org,lists.infradead.org,lists.linux.dev];
RCVD_TLS_LAST(0.00)[];
RCPT_COUNT_SEVEN(0.00)[10];
MIME_TRACE(0.00)[0:+];
FORGED_RECIPIENTS_MAILLIST(0.00)[];
RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.232.135.74:from]
X-Rspamd-Queue-Id: C6D741C0063
X-MORS-Enabled: yes
X-MORS-DOMAIN: patchwork.local
X-MORS-HOSTING: hosting172546
X-MORS-USER: hosting172546
X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?=
|
| Series |
spi: sun6i: Fix chip select handling around autosuspend
|
|
Commit Message
Kevin Mehall
April 23, 2026, 5:40 p.m. UTC
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 <km@kevinmehall.net>
---
drivers/spi/spi-sun6i.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Comments
I realized this is incorrect. With a GPIO chip select, sun6i_spi_set_cs() is not called, thus CS_MANUAL would not be set, and the hardware would then automatically assert native CS 0 during the transfer. My testing was with native CS 1 and a second GPIO chip select, so I didn't see this because native CS 0 is not used on the Orange Pi Zero 3. Therefore, I think the best place to set CS_MANUAL is in sun6i_spi_prepare_message as I had in my original patch [1], unless you think it should be duplicated in both places or have a better suggestion of where to set it. sun6i_spi_prepare_message() is still called before set_cs(), so it still fixes the skipped delay. [1]: https://lore.kernel.org/linux-spi/20260420164755.1131645-1-km@kevinmehall.net/
On Thu, Apr 23, 2026 at 12:40:34PM -0600, Kevin Mehall wrote: > I realized this is incorrect. With a GPIO chip select, sun6i_spi_set_cs() is not called, > thus CS_MANUAL would not be set, and the hardware would then automatically > assert native CS 0 during the transfer. My testing was with native CS 1 and a second GPIO chip select, > so I didn't see this because native CS 0 is not used on the Orange Pi Zero 3. > Therefore, I think the best place to set CS_MANUAL is in sun6i_spi_prepare_message > as I had in my original patch [1], unless you think it should be duplicated in both places > or have a better suggestion of where to set it. sun6i_spi_prepare_message() is still called > before set_cs(), so it still fixes the skipped delay. That sounds about right, the other option would be SPI_CONTROLLER_GPIO_SS but I don't think this controller needs it.
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) {