linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed
@ 2021-01-13 10:19 Geert Uytterhoeven
  2021-01-13 10:19 ` [PATCH 1/2] spi: sh-msiof: Fill in spi_transfer.effective_speed_hz Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2021-01-13 10:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

	Hi Mark,

This patch series makes the Renesas MSIOF SPI driver fill in actual
transfer speeds and controller limits, so the SPI core can take them
into account.

This has been tested on R-Car Gen2 and Gen3.
Thanks!

Geert Uytterhoeven (2):
  spi: sh-msiof: Fill in spi_transfer.effective_speed_hz
  spi: sh-msiof: Fill in controller speed limits

 drivers/spi/spi-sh-msiof.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

-- 
2.25.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] spi: sh-msiof: Fill in spi_transfer.effective_speed_hz
  2021-01-13 10:19 [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed Geert Uytterhoeven
@ 2021-01-13 10:19 ` Geert Uytterhoeven
  2021-01-13 10:19 ` [PATCH 2/2] spi: sh-msiof: Fill in controller speed limits Geert Uytterhoeven
  2021-01-13 15:28 ` [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2021-01-13 10:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

Fill in the effective bit rate used for transfers, so the SPI core can
calculate instead of estimate delays.

Restore "reverse Christmas tree" order of local variables while adding
new variables.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-sh-msiof.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index b2579af0e3eb0e39..90b8aba8a4fd9f32 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -259,11 +259,13 @@ static const u32 sh_msiof_spi_div_array[] = {
 };
 
 static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
-				      unsigned long parent_rate, u32 spi_hz)
+				      struct spi_transfer *t)
 {
+	unsigned long parent_rate = clk_get_rate(p->clk);
+	unsigned int div_pow = p->min_div_pow;
+	u32 spi_hz = t->speed_hz;
 	unsigned long div;
 	u32 brps, scr;
-	unsigned int div_pow = p->min_div_pow;
 
 	if (!spi_hz || !parent_rate) {
 		WARN(1, "Invalid clock rate parameters %lu and %u\n",
@@ -292,6 +294,8 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
 		brps = 32;
 	}
 
+	t->effective_speed_hz = parent_rate / (brps << div_pow);
+
 	scr = sh_msiof_spi_div_array[div_pow] | SISCR_BRPS(brps);
 	sh_msiof_write(p, SITSCR, scr);
 	if (!(p->ctlr->flags & SPI_CONTROLLER_MUST_TX))
@@ -923,7 +927,7 @@ static int sh_msiof_transfer_one(struct spi_controller *ctlr,
 
 	/* setup clocks (clock already enabled in chipselect()) */
 	if (!spi_controller_is_slave(p->ctlr))
-		sh_msiof_spi_set_clk_regs(p, clk_get_rate(p->clk), t->speed_hz);
+		sh_msiof_spi_set_clk_regs(p, t);
 
 	while (ctlr->dma_tx && len > 15) {
 		/*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] spi: sh-msiof: Fill in controller speed limits
  2021-01-13 10:19 [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed Geert Uytterhoeven
  2021-01-13 10:19 ` [PATCH 1/2] spi: sh-msiof: Fill in spi_transfer.effective_speed_hz Geert Uytterhoeven
@ 2021-01-13 10:19 ` Geert Uytterhoeven
  2021-01-13 15:28 ` [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2021-01-13 10:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

Fill in the controller speed limits, so the SPI core can use them for
validating SPI transfers, and adjust or reject transfers when needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-sh-msiof.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 90b8aba8a4fd9f32..41ed9ff8fad0d3b3 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -1262,6 +1262,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 	const struct sh_msiof_chipdata *chipdata;
 	struct sh_msiof_spi_info *info;
 	struct sh_msiof_spi_priv *p;
+	unsigned long clksrc;
 	int i;
 	int ret;
 
@@ -1337,6 +1338,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 	/* init controller code */
 	ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
 	ctlr->mode_bits |= SPI_LSB_FIRST | SPI_3WIRE;
+	clksrc = clk_get_rate(p->clk);
+	ctlr->min_speed_hz = DIV_ROUND_UP(clksrc, 1024);
+	ctlr->max_speed_hz = DIV_ROUND_UP(clksrc, 1 << p->min_div_pow);
 	ctlr->flags = chipdata->ctlr_flags;
 	ctlr->bus_num = pdev->id;
 	ctlr->num_chipselect = p->info->num_chipselect;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed
  2021-01-13 10:19 [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed Geert Uytterhoeven
  2021-01-13 10:19 ` [PATCH 1/2] spi: sh-msiof: Fill in spi_transfer.effective_speed_hz Geert Uytterhoeven
  2021-01-13 10:19 ` [PATCH 2/2] spi: sh-msiof: Fill in controller speed limits Geert Uytterhoeven
@ 2021-01-13 15:28 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2021-01-13 15:28 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-renesas-soc, linux-sh, linux-spi

On Wed, 13 Jan 2021 11:19:14 +0100, Geert Uytterhoeven wrote:
> 	Hi Mark,
> 
> This patch series makes the Renesas MSIOF SPI driver fill in actual
> transfer speeds and controller limits, so the SPI core can take them
> into account.
> 
> This has been tested on R-Car Gen2 and Gen3.
> Thanks!
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/2] spi: sh-msiof: Fill in spi_transfer.effective_speed_hz
      commit: 9a133f7b72f0b8d8896cbc7e4149c763b59168bb
[2/2] spi: sh-msiof: Fill in controller speed limits
      commit: 81f68479ec4ec91c0b0d7fb20db433be28e00497

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-13 15:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 10:19 [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed Geert Uytterhoeven
2021-01-13 10:19 ` [PATCH 1/2] spi: sh-msiof: Fill in spi_transfer.effective_speed_hz Geert Uytterhoeven
2021-01-13 10:19 ` [PATCH 2/2] spi: sh-msiof: Fill in controller speed limits Geert Uytterhoeven
2021-01-13 15:28 ` [PATCH 0/2] spi: sh-msiof: Advertize bit rate limits and actual speed Mark Brown

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).