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 9A1B6C531CB for ; Thu, 23 Jul 2026 06:44:02 +0000 (UTC) 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:Reply-To: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:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P8IOiE/rlS6dZspU7G2/Xh2uHfql/Offt8pntx1Na6k=; b=SjRfKZ18pJRwMU U5VYcgm0c0jgtEQDhVJ8EK+JkuNSl6K7deSA298k3sEQuDrvfwXGeJkCdVYbYHKNeH5u52gdJ+Uft lJ5lzYqVETvUn2wVivWS8tdlW5G+2Uk2uOr+zjsGBAmoQgGCcCstpqTE6XGt9DIjekrDJXlsD90OI OHwRrlm0t+n2+YTqXYm6oeabXdd2tPCZ8tEsss7G+NdBtHYMMUJ1HLICc0ax5as7iEifM2lGSa9+f Wc2vS3lU24BHrTI6T2prLQreA8Hx6SFuowLljiTC9fZcQghgy3z1cGK6TlQ9cwdhCJGreOi77g4fQ HdSfqXeif9zg2zmUwNqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wmn9y-0000000DZIM-0MDV; Thu, 23 Jul 2026 06:43:58 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wmn9w-0000000DZHY-0wM5 for linux-amlogic@lists.infradead.org; Thu, 23 Jul 2026 06:43:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 95E90451B7; Thu, 23 Jul 2026 06:43:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 6D02FC2BCFA; Thu, 23 Jul 2026 06:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1784789035; bh=3M0OnshwTVK0UfKz0PIBYXEPXb40nt8Uug0ad6cJ1QQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lIADCJSwav7DYdpcWivV1Dg/XPEDiN5pi2yJW7lIKgA21mhJnLPmbUgeU8J1HMoOI sppOwplMU3MRVwrihcyqXfLJKGbwbmuoIRPBzOjt1pQ+wu4WwDfJrDmd8j0W7OUPXC 4pugB8A8wHwcLeVCfirAloViNJ0Jkm2DTREzz6tybNoz8IW04XsVp6xggtMTmPhu3i X9Kp3Mm0sI1Z5YDi36CtCKnQMfa2rOyIUb83cTWfVlt/vKzaDt6si+98+zw40yZ4/y h41qpu1AlOG8Y28cRPyF0vRW5b07oW9CRLUkn9X2Aj0XHiFoMiPYzNKjyAFUliyfsi fUR7i8T1nno/Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55C4AC531C7; Thu, 23 Jul 2026 06:43:55 +0000 (UTC) From: Xianwei Zhao via B4 Relay Date: Thu, 23 Jul 2026 06:43:44 +0000 Subject: [PATCH v2 3/4] spi: amlogic: spisg: Fix the incorrect keep_ss of the last descriptor MIME-Version: 1.0 Message-Id: <20260723-a9-spisg-v2-3-9fc39106b7e2@amlogic.com> References: <20260723-a9-spisg-v2-0-9fc39106b7e2@amlogic.com> In-Reply-To: <20260723-a9-spisg-v2-0-9fc39106b7e2@amlogic.com> To: Sunny Luo , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-amlogic@lists.infradead.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Xianwei Zhao X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784789030; l=2503; i=xianwei.zhao@amlogic.com; s=20251216; h=from:subject:message-id; bh=GYCmSYjNwUITh84G97V/SeftRuFlV+MEyMTKnf7GhHw=; b=GkR8HB8K1/PECYh7EuOrs6MPtpCN5QXiQFktK4qOkKRr/LKpLJqc1a5JrBW22QjHi87Vefd/y zNFBqbugbMQAjC3YXxBrkGEO2zthU2go/HYM7SMI+0Fr9nm0vw8V06W X-Developer-Key: i=xianwei.zhao@amlogic.com; a=ed25519; pk=dWwxtWCxC6FHRurOmxEtr34SuBYU+WJowV/ZmRJ7H+k= X-Endpoint-Received: by B4 Relay for xianwei.zhao@amlogic.com/20251216 with auth_id=578 X-Original-From: Xianwei Zhao X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: xianwei.zhao@amlogic.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org From: Sunny Luo The driver currently unconditionally clears CFG_KEEP_SS on the last descriptor, causing the last transfer's cs_change setting to be ignored. Record the cs_change value of the last SPI transfer and use it to program CFG_KEEP_SS on the final descriptor. When a null descriptor is inserted to implement the cs-hold delay, keep CFG_KEEP_SS set on the preceding transfer descriptor and apply the recorded value to the final descriptor instead. This ensures the controller handles chip select correctly for the last transfer regardless of whether a cs-hold delay is required. Fixes: cef9991e04ae ("spi: Add Amlogic SPISG driver") Signed-off-by: Sunny Luo Signed-off-by: Xianwei Zhao --- drivers/spi/spi-amlogic-spisg.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-amlogic-spisg.c b/drivers/spi/spi-amlogic-spisg.c index a6123975a37c..2d66f00dccd4 100644 --- a/drivers/spi/spi-amlogic-spisg.c +++ b/drivers/spi/spi-amlogic-spisg.c @@ -489,6 +489,7 @@ static int aml_spisg_transfer_one_message(struct spi_controller *ctlr, struct spisg_descriptor_extra *exdescs, *exdesc; dma_addr_t descs_paddr; int desc_num = 1, descs_len; + bool last_xfer_keep_ss = false; u32 cs_hold_in_sclk = 0; int ret = -EIO; @@ -529,9 +530,11 @@ static int aml_spisg_transfer_one_message(struct spi_controller *ctlr, spi_delay_to_sclk(xfer->effective_speed_hz, &msg->spi->cs_setup)); /* calculate cs-hold delay with the last xfer speed */ - if (list_is_last(&xfer->transfer_list, &msg->transfers)) + if (list_is_last(&xfer->transfer_list, &msg->transfers)) { cs_hold_in_sclk = spi_delay_to_sclk(xfer->effective_speed_hz, &msg->spi->cs_hold); + last_xfer_keep_ss = xfer->cs_change; + } desc++; exdesc++; @@ -539,13 +542,17 @@ static int aml_spisg_transfer_one_message(struct spi_controller *ctlr, xfer->effective_speed_hz); } - if (cs_hold_in_sclk) + if (cs_hold_in_sclk) { /* additional null-descriptor to achieve the cs-hold delay */ aml_spisg_setup_null_desc(spisg, desc, cs_hold_in_sclk); - else desc--; + desc->cfg_bus |= FIELD_PREP(CFG_KEEP_SS, 1); + desc++; + } else { + desc--; + } - desc->cfg_bus |= FIELD_PREP(CFG_KEEP_SS, 0); + FIELD_MODIFY(CFG_KEEP_SS, &desc->cfg_bus, last_xfer_keep_ss); desc->cfg_start |= FIELD_PREP(CFG_EOC, 1); /* some tolerances */ -- 2.52.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic