From nobody Fri Dec 19 14:38:29 2025 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB633308F34; Wed, 5 Nov 2025 09:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762334121; cv=none; b=m8vlVO0vRj/HwvaJBZsX5S+I1xIFySqs2pVkWYig5WgSn/nBmz5Y96nUB8XxWYWkFuvKZnmlTiJBdDo43mW7kW/hfoyndPOTkJq0Ma8rKkGravmcRQOySN6fTPYoXIMjpcP2TffKyfTzvZzXTDnHQHfQWrE7VY+JQGzINhG2asQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762334121; c=relaxed/simple; bh=K8n+2283Ka0qajuKOt0v+NTUy7TqbZ8VB4fu6UnhKFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IPh2rYKR7mDRh45bCon3RRtQp9PtY0lfac5ODFQQu6zZZSFgh+c6QT2ucVt5tk6Yv9KtOt7PfTIHigvF/Jy/ccQWaXa2eGR4XB+I1M0YHNDqImGsiH8NfXSadgPizNB3pcwWWlaVZZFP133CxJgnCWE9BUvRTfkDLdAMTHMr9BE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: 3DnIL6DUTgWv9EX7HSZIvQ== X-CSE-MsgGUID: 94edD2dVTcSbouxjVzXqYA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 05 Nov 2025 18:15:19 +0900 Received: from demon-pc.localdomain (unknown [10.226.92.38]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 8EAE741763F1; Wed, 5 Nov 2025 18:15:14 +0900 (JST) From: Cosmin Tanislav To: Cc: Fabrizio Castro , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Michael Turquette , Stephen Boyd , Philipp Zabel , linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Cosmin Tanislav Subject: [PATCH 06/14] spi: rzv2h-rspi: avoid recomputing transfer frequency Date: Wed, 5 Nov 2025 11:13:50 +0200 Message-ID: <20251105091401.1462985-7-cosmin-gabriel.tanislav.xa@renesas.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251105091401.1462985-1-cosmin-gabriel.tanislav.xa@renesas.com> References: <20251105091401.1462985-1-cosmin-gabriel.tanislav.xa@renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Renesas RZ/T2H (R9A09G077) and RZ/N2H (R9A09G087) SoCs have a more complicated algorithm for calculating the optimal SPI transfer frequency compared to RZ/V2H, as the clock from which the SPI frequency is generated supports multiple dividers. Cache the requested transfer frequency and skip calling rzv2h_rspi_setup_clock() if it matches the last used one to prepare for adding support for variable clock frequency handling. Signed-off-by: Cosmin Tanislav --- drivers/spi/spi-rzv2h-rspi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-rzv2h-rspi.c b/drivers/spi/spi-rzv2h-rspi.c index f02f25b98ec6..d7719f3c7b13 100644 --- a/drivers/spi/spi-rzv2h-rspi.c +++ b/drivers/spi/spi-rzv2h-rspi.c @@ -81,6 +81,7 @@ struct rzv2h_rspi_priv { struct clk *tclk; wait_queue_head_t wait; unsigned int bytes_per_word; + u32 last_speed_hz; u32 freq; u16 status; u8 spr; @@ -298,9 +299,13 @@ static int rzv2h_rspi_prepare_message(struct spi_contr= oller *ctlr, =20 rspi->bytes_per_word =3D roundup_pow_of_two(BITS_TO_BYTES(bits_per_word)); =20 - rspi->freq =3D rzv2h_rspi_setup_clock(rspi, speed_hz); - if (!rspi->freq) - return -EINVAL; + if (speed_hz !=3D rspi->last_speed_hz) { + rspi->freq =3D rzv2h_rspi_setup_clock(rspi, speed_hz); + if (!rspi->freq) + return -EINVAL; + + rspi->last_speed_hz =3D speed_hz; + } =20 writeb(rspi->spr, rspi->base + RSPI_SPBR); =20 --=20 2.51.2