linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Mark Brown <broonie@kernel.org>
Cc: Maxime Ripard <mripard@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
	linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	kernel@pengutronix.de, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 2/9] spi: spi-sun6i: sun6i_spi_transfer_one(): report effectivly used speed_hz of transfer
Date: Mon,  6 Jul 2020 09:17:54 +0200	[thread overview]
Message-ID: <20200706071801.558394-3-mkl@pengutronix.de> (raw)
In-Reply-To: <20200706071801.558394-1-mkl@pengutronix.de>

This patch implementes the reporting of the effectivly used speed_hz for the
transfer by setting tfr->effective_speed_hz.

See the following patch, which adds this feature to the SPI core for more
information:

    5d7e2b5ed585 spi: core: allow reporting the effectivly used speed_hz for a transfer

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/spi/spi-sun6i.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
index fa11cc0e809b..64b4d8077010 100644
--- a/drivers/spi/spi-sun6i.c
+++ b/drivers/spi/spi-sun6i.c
@@ -291,9 +291,11 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
 	div_cdr2 = DIV_ROUND_UP(div_cdr1, 2);
 	if (div_cdr2 <= (SUN6I_CLK_CTL_CDR2_MASK + 1)) {
 		reg = SUN6I_CLK_CTL_CDR2(div_cdr2 - 1) | SUN6I_CLK_CTL_DRS;
+		tfr->effective_speed_hz = mclk_rate / (2 * div_cdr2);
 	} else {
 		div = min(SUN6I_CLK_CTL_CDR1_MASK, order_base_2(div_cdr1));
 		reg = SUN6I_CLK_CTL_CDR1(div);
+		tfr->effective_speed_hz = mclk_rate / (1 << div);
 	}
 
 	sun6i_spi_write(sspi, SUN6I_CLK_CTL_REG, reg);
-- 
2.27.0


  parent reply	other threads:[~2020-07-06  7:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06  7:17 [PATCH 0/9] spi: spi-sun6i: One fix and some improvements Marc Kleine-Budde
2020-07-06  7:17 ` [PATCH 1/9] spi: spi-sun6i: sun6i_spi_transfer_one(): fix setting of clock rate Marc Kleine-Budde
2020-07-06  7:17 ` Marc Kleine-Budde [this message]
2020-07-06  7:17 ` [PATCH 3/9] spi: spi-sun6i: sun6i_spi_transfer_one(): remove useless goto Marc Kleine-Budde
2020-07-06  7:17 ` [PATCH 4/9] spi: spi-sun6i: sun6i_spi_transfer_one(): remove not needed masking of transfer length Marc Kleine-Budde
2020-07-06  7:17 ` [PATCH 5/9] spi: spi-sun6i: sun6i_spi_drain_fifo(): introduce sun6i_spi_get_rx_fifo_count() and make use of it Marc Kleine-Budde
2020-07-06 12:36   ` Maxime Ripard
2020-07-06 12:37     ` Marc Kleine-Budde
2020-07-06  7:17 ` [PATCH 6/9] spi: spi-sun6i: sun6i_spi_drain_fifo(): remove not needed length argument Marc Kleine-Budde
2020-07-06  7:17 ` [PATCH 7/9] spi: spi-sun6i: sun6i_spi_fill_fifo(): " Marc Kleine-Budde
2020-07-06  7:18 ` [PATCH 8/9] spi: spi-sun6i: sun6i_spi_transfer_one(): collate write to Interrupt Control Register Marc Kleine-Budde
2020-07-06  7:18 ` [PATCH 9/9] spi: spi-sun6i: sun6i_spi_transfer_one(): enable RF_RDY interrupt only if needed Marc Kleine-Budde
2020-07-06 12:43 ` [PATCH 0/9] spi: spi-sun6i: One fix and some improvements Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200706071801.558394-3-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=broonie@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).