From nobody Tue Feb 10 17:31:01 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86B8E3314CC; Tue, 28 Oct 2025 13:33:04 +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=1761658389; cv=none; b=iBRw2FfL8uQziqg0141kQbbbvtXt6m1dyJzlsMtXeAB2WrUjS5WdHKWedhoIv/cQNBS33vTFzaIrpc2zhls8J8yojOmZdASc4iUfL91puxilBoUzLYS+VQ3Yjz0CeyJDCFv8LReD6RCtzCPdoRZqXicHs0DwN/WQRJFtb+D4Cvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761658389; c=relaxed/simple; bh=m22yQ3WQooA+vpLQVH+ph3s0RAn5cUk0wEP6/IF+1oo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LU2rIgm0Yj0mUjV7y+9Ld5KgaNAvoDUjr8634Q0pVjrIpIK5/Vy/DEEXKIPiiKQMWH1D+a4U5hkZ2sGRVVv68N+71DGPeU5sqlTiRDi48OW17f9/mWYTbkchxlajdpc5rNX0weKoqrybs6hGn/V0RI/4lqBFWPVw8WOyAP9i9so= 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: cDSM0R/mQQajfTDO1kDU6Q== X-CSE-MsgGUID: Iwaspnd+TsCZFgBabCdh6Q== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 28 Oct 2025 22:33:03 +0900 Received: from demon-pc.localdomain (unknown [10.226.92.5]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 7F8A941B5F49; Tue, 28 Oct 2025 22:32:58 +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: Tue, 28 Oct 2025 15:31:37 +0200 Message-ID: <20251028133151.1487327-7-cosmin-gabriel.tanislav.xa@renesas.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251028133151.1487327-1-cosmin-gabriel.tanislav.xa@renesas.com> References: <20251028133151.1487327-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 Reviewed-by: Fabrizio Castro --- 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.1