From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.171.202.116 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795629182; b=AfajKMo4pjfCzL6gWrcFDmOT2WhwMsDfUr5ENFDrXfnxk3hz6hBUOHh1BRqysK/+IkIE FZ2ld+ZpH7toOOz4H80oBxB6iKUPDtdrniJdqZpGWN4Wr0OoUZy95qpGyi7Y2cFLTXcoa TOBiXqC298fW+Udf/D0uYyA9V3pePN0sytDuPCL/JHFQbTltwJoyD7VQSEiSNQcVGrsQR qP4toGTW6r0fouYrmPhH6RhntV2BDe5jRfBJOkIRUzVFisEawmKgSfmErldm+FQ6/ypb+ Cbto7OCeWy54Za8s84+bIQzcqElVWwAyQCVFMaP2hIZd27a874m8iHtVZEz/z1MzUiw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795629182; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Last-TLS-Session-Version; bh=JCAVXopcRhsu0R7W2AJRcPS4xlZfnpyxLhZGemjrQaY=; b=E1jONkqb/O26StoMGbkyGaUuzw9XzrOvNo7ZMlrUGTiOIrz4n5D7nXno4n0fkQIr6se2 hox1th0X1Z6drH05DGrBkOWyo8busv7XkAJC8wxpwfvO6kzp0YDFOKG6rNPVL+QRmsc+7 y5X2p+OvRmu4MkOWoylt0RUt79fSjk0Gi8kDre3+hWG9eE/0sPsiERIlw1h4bt7sn/x62 GpXTgKg/8A2QH6jEitGuhdFhTT5MZfG57Gxniov0hKX/DbZwpndqS2GPlUaFUvtA1MS1V EnCrNz4cO/IQ05Wz70bsIijD/KbpxqN2NhngnMiqqDPnd99XXk55JhFJcd4QEWvkBCA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=KYGCCatk; arc=none smtp.remote-ip=185.171.202.116 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72FC6606A32D for ; Wed, 25 Nov 2026 17:53:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 72FC6606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=KYGCCatk Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 03CE9C6221E; Wed, 25 Nov 2026 17:53:08 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0D09660480; Wed, 25 Nov 2026 17:53:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AA5F911E6B0CA; Wed, 25 Nov 2026 18:52:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795629174; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=JCAVXopcRhsu0R7W2AJRcPS4xlZfnpyxLhZGemjrQaY=; b=KYGCCatkpDwAP39xFucHg5OhSZCQx2BzoSiOJhGTIvhyjU0iH9MR3Nou9ORwOoHqcQnXWZ k8WtGng3n56RvyZGJYrcqIQmYvx22XJkDzMlShSyJBKI1pVqipDqav+hHfIZm2R/LFJK3Z R6orNWggySMk4Bc/p8PcSNb1BxXblXaYw9rHsTY/CnCvJeuoEbwAJNPf2WEx0KM/Hyp5pe 0hJTCcMIveklGb7007f++ldutFB9U0ere1MsT+1fGqCRqCdDgCnONrX7FzjaT87hZFmq75 e8h0wMhWaaGOEr+pML/ay1JGJuzjfo0QVZXl39N8Dn+JQqgG8evHxLIQmzJ6BA== From: Miquel Raynal Date: Wed, 25 Nov 2026 18:51:28 +0100 Subject: [PATCH RFC 14/16] spi: stm32-ospi: Consume dummy cycles directly X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261125-macronix-upstreaming-spi-mem-cycles-v1-14-fd036402fd37@bootlin.com> References: <20261125-macronix-upstreaming-spi-mem-cycles-v1-0-fd036402fd37@bootlin.com> In-Reply-To: <20261125-macronix-upstreaming-spi-mem-cycles-v1-0-fd036402fd37@bootlin.com> To: Mark Brown , Liang Yang , Feng Chen , Xianwei Zhao , Han Xu , Conor Dooley , Valentina Fernandez , Daire McNamara , Haibo Chen , Jyan Chou , Yu-Chun Lin , Maxime Coquelin , Alexandre Torgue , Pratyush Yadav , Michael Walle , Takahiro Kuwano , Richard Weinberger , Vignesh Raghavendra Cc: Thomas Petazzoni , Alvin Zhou , Cheng Ming Lin , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, imx@lists.linux.dev, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, Miquel Raynal X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The spi-mem layer is now capable of providing the dummy phase in cycle units rather than bytes, provided that drivers advertize the dummy_cycle capability. Since this controller is consuming cycles and currently converts bytes into cycles, flag it capable to consume cycles directly and drop the extra conversions. Signed-off-by: Miquel Raynal --- drivers/spi/spi-stm32-ospi.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c index fa0e8e83cb1b..9b28d1f24482 100644 --- a/drivers/spi/spi-stm32-ospi.c +++ b/drivers/spi/spi-stm32-ospi.c @@ -492,10 +492,9 @@ static int stm32_ospi_send(struct spi_device *spi, const struct spi_mem_op *op) } tcr = TCR_SSHIFT; - if (op->dummy.buswidth && op->dummy.nbytes) { - tcr |= FIELD_PREP(TCR_DCYC_MASK, - op->dummy.nbytes * 8 / op->dummy.buswidth); - } + if (op->dummy.buswidth && op->dummy.ncycles) + tcr |= FIELD_PREP(TCR_DCYC_MASK, op->dummy.ncycles); + writel_relaxed(tcr, regs_base + OSPI_TCR); if (op->data.nbytes) { @@ -691,7 +690,7 @@ static int stm32_ospi_transfer_one_message(struct spi_controller *ctrl, */ if (transfer->dummy_data) { op.dummy.buswidth = transfer->tx_nbits; - op.dummy.nbytes = transfer->len; + op.dummy.ncycles = transfer->len * 8 / transfer->tx_nbits; dummy_bytes = transfer->len; /* If happens, means that message is not correctly built */ @@ -784,6 +783,10 @@ static const struct spi_controller_mem_ops stm32_ospi_mem_ops = { .poll_status = stm32_ospi_poll_status, }; +static const struct spi_controller_mem_caps stm32_ospi_mem_caps = { + .dummy_cycles = true, +}; + static int stm32_ospi_get_resources(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -933,6 +936,7 @@ static int stm32_ospi_probe(struct platform_device *pdev) ctrl->setup = stm32_ospi_setup; ctrl->bus_num = -1; ctrl->mem_ops = &stm32_ospi_mem_ops; + ctrl->mem_caps = &stm32_ospi_mem_caps; ctrl->use_gpio_descriptors = true; ctrl->transfer_one_message = stm32_ospi_transfer_one_message; ctrl->num_chipselect = STM32_OSPI_MAX_NORCHIP; -- 2.56.0