linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] spi: rspi: Bit rate improvements
@ 2020-08-19 12:58 Geert Uytterhoeven
  2020-08-19 12:58 ` [PATCH v2 1/7] spi: rspi: Remove useless .set_config_register() check Geert Uytterhoeven
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2020-08-19 12:58 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chris Brandt, linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

	Hi Mark,

This patch series contains several improvements for the Renesas SPI/QSPI
driver related to bit rate configuration.

Changes compared to v1
(https://lore.kernel.org/r/20200608095940.30516-1-geert+renesas@glider.be):
  - Drop accepted patch.

This has been tested on RSK+RZA1 (RSPI) and R-Car M2-W/Koelsch (QSPI),
using a scope and logic analyzer, except for the by-one divider on QSPI.
This has not been tested on legacy SuperH, due to lack of hardware.

Thanks for your comments!

Geert Uytterhoeven (7):
  spi: rspi: Remove useless .set_config_register() check
  spi: rspi: Clean up Bit Rate Division Setting handling
  spi: rspi: Increase bit rate accuracy on RZ/A
  spi: rspi: Increase bit rate range for RSPI on SH
  spi: rspi: Increase bit rate range for QSPI
  spi: rspi: Fill in spi_transfer.effective_speed_hz
  spi: rspi: Fill in controller speed limits

 drivers/spi/spi-rspi.c | 81 +++++++++++++++++++++++++++---------------
 1 file changed, 52 insertions(+), 29 deletions(-)

-- 
2.17.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] 9+ messages in thread

* [PATCH v2 1/7] spi: rspi: Remove useless .set_config_register() check
  2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
@ 2020-08-19 12:58 ` Geert Uytterhoeven
  2020-08-19 12:58 ` [PATCH v2 2/7] spi: rspi: Clean up Bit Rate Division Setting handling Geert Uytterhoeven
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2020-08-19 12:58 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chris Brandt, linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

Not implementing spi_ops.set_config_register() is a driver bug that
would prevent the driver from working at all.
Hence remove the run-time check.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - No changes.

 drivers/spi/spi-rspi.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index cbc2387d450cd4c2..1b635d6b7881f5b9 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -1261,13 +1261,6 @@ static int rspi_probe(struct platform_device *pdev)
 			ctlr->num_chipselect = 2; /* default */
 	}
 
-	/* ops parameter check */
-	if (!ops->set_config_register) {
-		dev_err(&pdev->dev, "there is no set_config_register\n");
-		ret = -ENODEV;
-		goto error1;
-	}
-
 	rspi = spi_controller_get_devdata(ctlr);
 	platform_set_drvdata(pdev, rspi);
 	rspi->ops = ops;
-- 
2.17.1

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

* [PATCH v2 2/7] spi: rspi: Clean up Bit Rate Division Setting handling
  2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
  2020-08-19 12:58 ` [PATCH v2 1/7] spi: rspi: Remove useless .set_config_register() check Geert Uytterhoeven
@ 2020-08-19 12:58 ` Geert Uytterhoeven
  2020-08-19 12:59 ` [PATCH v2 3/7] spi: rspi: Increase bit rate accuracy on RZ/A Geert Uytterhoeven
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2020-08-19 12:58 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chris Brandt, linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

Add a macro for configuring the Bit Rate Division Setting field in
Command Registers, instead of open-coding the same operation using a
hardcoded shift.
Rename "div" to "brdv", as it is not a plain divider value, but controls
a power-of-two divider.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - No changes.

 drivers/spi/spi-rspi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 1b635d6b7881f5b9..450a42ec2141a895 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -161,6 +161,7 @@
 #define SPCMD_SPRW		0x0010	/* SPI Read/Write Access (Dual/Quad) */
 #define SPCMD_SSLA(i)		((i) << 4)	/* SSL Assert Signal Setting */
 #define SPCMD_BRDV_MASK		0x000c	/* Bit Rate Division Setting */
+#define SPCMD_BRDV(brdv)	((brdv) << 2)
 #define SPCMD_CPOL		0x0002	/* Clock Polarity Setting */
 #define SPCMD_CPHA		0x0001	/* Clock Phase Setting */
 
@@ -290,24 +291,24 @@ static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
 static int rspi_rz_set_config_register(struct rspi_data *rspi, int access_size)
 {
 	int spbr;
-	int div = 0;
+	int brdv = 0;
 	unsigned long clksrc;
 
 	/* Sets output mode, MOSI signal, and (optionally) loopback */
 	rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
 
 	clksrc = clk_get_rate(rspi->clk);
-	while (div < 3) {
+	while (brdv < 3) {
 		if (rspi->speed_hz >= clksrc/4) /* 4=(CLK/2)/2 */
 			break;
-		div++;
+		brdv++;
 		clksrc /= 2;
 	}
 
 	/* Sets transfer bit rate */
 	spbr = DIV_ROUND_UP(clksrc, 2 * rspi->speed_hz) - 1;
 	rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
-	rspi->spcmd |= div << 2;
+	rspi->spcmd |= SPCMD_BRDV(brdv);
 
 	/* Disable dummy transmission, set byte access */
 	rspi_write8(rspi, SPDCR_SPLBYTE, RSPI_SPDCR);
-- 
2.17.1

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

* [PATCH v2 3/7] spi: rspi: Increase bit rate accuracy on RZ/A
  2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
  2020-08-19 12:58 ` [PATCH v2 1/7] spi: rspi: Remove useless .set_config_register() check Geert Uytterhoeven
  2020-08-19 12:58 ` [PATCH v2 2/7] spi: rspi: Clean up Bit Rate Division Setting handling Geert Uytterhoeven
@ 2020-08-19 12:59 ` Geert Uytterhoeven
  2020-08-19 12:59 ` [PATCH v2 4/7] spi: rspi: Increase bit rate range for RSPI on SH Geert Uytterhoeven
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2020-08-19 12:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chris Brandt, linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

rspi_rz_set_config_register() favors high values of "brdv" over high
values of "spbr".  As "brdv" is not a plain divider, but controls a
power-of-two divider, this may cause the selection of non-optimal
divider values.  E.g. on RSK+RZA1, when 3.8 MHz is requested, the actual
configured bit rate is 2.08 MHz (spbr = 1, brdv = 3), while 3.7 MHz
would be possible (spbr = 8, brdv = 0).

Fix this by only resorting to higher "brdv" values when really needed.
This makes the driver always pick optimal divider values on RZ/A.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - No changes.

 drivers/spi/spi-rspi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 450a42ec2141a895..ad4ac867170b101a 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -298,15 +298,13 @@ static int rspi_rz_set_config_register(struct rspi_data *rspi, int access_size)
 	rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
 
 	clksrc = clk_get_rate(rspi->clk);
-	while (brdv < 3) {
-		if (rspi->speed_hz >= clksrc/4) /* 4=(CLK/2)/2 */
-			break;
+	spbr = DIV_ROUND_UP(clksrc, 2 * rspi->speed_hz) - 1;
+	while (spbr > 255 && brdv < 3) {
 		brdv++;
-		clksrc /= 2;
+		spbr = DIV_ROUND_UP(spbr + 1, 2) - 1;
 	}
 
 	/* Sets transfer bit rate */
-	spbr = DIV_ROUND_UP(clksrc, 2 * rspi->speed_hz) - 1;
 	rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
 	rspi->spcmd |= SPCMD_BRDV(brdv);
 
-- 
2.17.1

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

* [PATCH v2 4/7] spi: rspi: Increase bit rate range for RSPI on SH
  2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2020-08-19 12:59 ` [PATCH v2 3/7] spi: rspi: Increase bit rate accuracy on RZ/A Geert Uytterhoeven
@ 2020-08-19 12:59 ` Geert Uytterhoeven
  2020-08-19 12:59 ` [PATCH v2 5/7] spi: rspi: Increase bit rate range for QSPI Geert Uytterhoeven
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2020-08-19 12:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chris Brandt, linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

Increase bit rate range for RSPI on legacy SH by making use of the Bit
Rate Frequency Division Setting field in Command Registers, just like is
already done on RZ/A.  This decreases the lower limit by a factor of 8.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Untested due to lack of hardware, but the formulas in the datasheets for
SH7753, RZ/A1H, and RZ/A2M are the same.

v2:
  - No changes.

---
 drivers/spi/spi-rspi.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index ad4ac867170b101a..ea3f2680d3c13e02 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -248,19 +248,32 @@ struct spi_ops {
 	u8 num_hw_ss;
 };
 
+static void rspi_set_rate(struct rspi_data *rspi)
+{
+	unsigned long clksrc;
+	int brdv = 0, spbr;
+
+	clksrc = clk_get_rate(rspi->clk);
+	spbr = DIV_ROUND_UP(clksrc, 2 * rspi->speed_hz) - 1;
+	while (spbr > 255 && brdv < 3) {
+		brdv++;
+		spbr = DIV_ROUND_UP(spbr + 1, 2) - 1;
+	}
+
+	rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
+	rspi->spcmd |= SPCMD_BRDV(brdv);
+}
+
 /*
  * functions for RSPI on legacy SH
  */
 static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
 {
-	int spbr;
-
 	/* Sets output mode, MOSI signal, and (optionally) loopback */
 	rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
 
 	/* Sets transfer bit rate */
-	spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk), 2 * rspi->speed_hz) - 1;
-	rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
+	rspi_set_rate(rspi);
 
 	/* Disable dummy transmission, set 16-bit word access, 1 frame */
 	rspi_write8(rspi, 0, RSPI_SPDCR);
@@ -290,23 +303,11 @@ static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
  */
 static int rspi_rz_set_config_register(struct rspi_data *rspi, int access_size)
 {
-	int spbr;
-	int brdv = 0;
-	unsigned long clksrc;
-
 	/* Sets output mode, MOSI signal, and (optionally) loopback */
 	rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
 
-	clksrc = clk_get_rate(rspi->clk);
-	spbr = DIV_ROUND_UP(clksrc, 2 * rspi->speed_hz) - 1;
-	while (spbr > 255 && brdv < 3) {
-		brdv++;
-		spbr = DIV_ROUND_UP(spbr + 1, 2) - 1;
-	}
-
 	/* Sets transfer bit rate */
-	rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
-	rspi->spcmd |= SPCMD_BRDV(brdv);
+	rspi_set_rate(rspi);
 
 	/* Disable dummy transmission, set byte access */
 	rspi_write8(rspi, SPDCR_SPLBYTE, RSPI_SPDCR);
-- 
2.17.1

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

* [PATCH v2 5/7] spi: rspi: Increase bit rate range for QSPI
  2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
                   ` (3 preceding siblings ...)
  2020-08-19 12:59 ` [PATCH v2 4/7] spi: rspi: Increase bit rate range for RSPI on SH Geert Uytterhoeven
@ 2020-08-19 12:59 ` Geert Uytterhoeven
  2020-08-19 12:59 ` [PATCH v2 6/7] spi: rspi: Fill in spi_transfer.effective_speed_hz Geert Uytterhoeven
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2020-08-19 12:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chris Brandt, linux-spi, linux-renesas-soc, linux-sh, Geert Uytterhoeven

Increase bit rate range for QSPI by extending the range of supported
dividers:
  1. QSPI supports a divider of 1, by setting SPBR to zero, increasing
     the upper limit from 48.75 to 97.5 MHz on R-Car Gen2,
  2. Make use of the Bit Rate Frequency Division Setting field in
     Command Registers, to decrease the lower limit from 191 to 24 kbps
     on R-Car Gen2.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - No changes.

 drivers/spi/spi-rspi.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index ea3f2680d3c13e02..38c0cd7febabf114 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -334,14 +334,26 @@ static int rspi_rz_set_config_register(struct rspi_data *rspi, int access_size)
  */
 static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
 {
-	int spbr;
+	unsigned long clksrc;
+	int brdv = 0, spbr;
 
 	/* Sets output mode, MOSI signal, and (optionally) loopback */
 	rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
 
 	/* Sets transfer bit rate */
-	spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk), 2 * rspi->speed_hz);
-	rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
+	clksrc = clk_get_rate(rspi->clk);
+	if (rspi->speed_hz >= clksrc) {
+		spbr = 0;
+	} else {
+		spbr = DIV_ROUND_UP(clksrc, 2 * rspi->speed_hz);
+		while (spbr > 255 && brdv < 3) {
+			brdv++;
+			spbr = DIV_ROUND_UP(spbr, 2);
+		}
+		spbr = clamp(spbr, 0, 255);
+	}
+	rspi_write8(rspi, spbr, RSPI_SPBR);
+	rspi->spcmd |= SPCMD_BRDV(brdv);
 
 	/* Disable dummy transmission, set byte access */
 	rspi_write8(rspi, 0, RSPI_SPDCR);
-- 
2.17.1

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

* [PATCH v2 6/7] spi: rspi: Fill in spi_transfer.effective_speed_hz
  2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
                   ` (4 preceding siblings ...)
  2020-08-19 12:59 ` [PATCH v2 5/7] spi: rspi: Increase bit rate range for QSPI Geert Uytterhoeven
@ 2020-08-19 12:59 ` Geert Uytterhoeven
  2020-08-19 12:59 ` [PATCH v2 7/7] spi: rspi: Fill in controller speed limits Geert Uytterhoeven
  2020-08-20 21:48 ` [PATCH v2 0/7] spi: rspi: Bit rate improvements Mark Brown
  7 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2020-08-19 12:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chris Brandt, 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.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - No changes.

 drivers/spi/spi-rspi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 38c0cd7febabf114..2b5334e22ae421b5 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -262,6 +262,7 @@ static void rspi_set_rate(struct rspi_data *rspi)
 
 	rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
 	rspi->spcmd |= SPCMD_BRDV(brdv);
+	rspi->speed_hz = DIV_ROUND_UP(clksrc, (2U << brdv) * (spbr + 1));
 }
 
 /*
@@ -344,6 +345,7 @@ static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
 	clksrc = clk_get_rate(rspi->clk);
 	if (rspi->speed_hz >= clksrc) {
 		spbr = 0;
+		rspi->speed_hz = clksrc;
 	} else {
 		spbr = DIV_ROUND_UP(clksrc, 2 * rspi->speed_hz);
 		while (spbr > 255 && brdv < 3) {
@@ -351,6 +353,7 @@ static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
 			spbr = DIV_ROUND_UP(spbr, 2);
 		}
 		spbr = clamp(spbr, 0, 255);
+		rspi->speed_hz = DIV_ROUND_UP(clksrc, (2U << brdv) * spbr);
 	}
 	rspi_write8(rspi, spbr, RSPI_SPBR);
 	rspi->spcmd |= SPCMD_BRDV(brdv);
@@ -698,6 +701,8 @@ static int rspi_common_transfer(struct rspi_data *rspi,
 {
 	int ret;
 
+	xfer->effective_speed_hz = rspi->speed_hz;
+
 	ret = rspi_dma_check_then_transfer(rspi, xfer);
 	if (ret != -EAGAIN)
 		return ret;
@@ -853,6 +858,7 @@ static int qspi_transfer_one(struct spi_controller *ctlr,
 {
 	struct rspi_data *rspi = spi_controller_get_devdata(ctlr);
 
+	xfer->effective_speed_hz = rspi->speed_hz;
 	if (spi->mode & SPI_LOOP) {
 		return qspi_transfer_out_in(rspi, xfer);
 	} else if (xfer->tx_nbits > SPI_NBITS_SINGLE) {
-- 
2.17.1

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

* [PATCH v2 7/7] spi: rspi: Fill in controller speed limits
  2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
                   ` (5 preceding siblings ...)
  2020-08-19 12:59 ` [PATCH v2 6/7] spi: rspi: Fill in spi_transfer.effective_speed_hz Geert Uytterhoeven
@ 2020-08-19 12:59 ` Geert Uytterhoeven
  2020-08-20 21:48 ` [PATCH v2 0/7] spi: rspi: Bit rate improvements Mark Brown
  7 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2020-08-19 12:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chris Brandt, 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 adjusting them where needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - No changes.

 drivers/spi/spi-rspi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 2b5334e22ae421b5..e39fd38f5180efb3 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -243,6 +243,8 @@ struct spi_ops {
 	int (*transfer_one)(struct spi_controller *ctlr,
 			    struct spi_device *spi, struct spi_transfer *xfer);
 	u16 extra_mode_bits;
+	u16 min_div;
+	u16 max_div;
 	u16 flags;
 	u16 fifo_size;
 	u8 num_hw_ss;
@@ -1181,6 +1183,8 @@ static int rspi_remove(struct platform_device *pdev)
 static const struct spi_ops rspi_ops = {
 	.set_config_register =	rspi_set_config_register,
 	.transfer_one =		rspi_transfer_one,
+	.min_div =		2,
+	.max_div =		4096,
 	.flags =		SPI_CONTROLLER_MUST_TX,
 	.fifo_size =		8,
 	.num_hw_ss =		2,
@@ -1189,6 +1193,8 @@ static const struct spi_ops rspi_ops = {
 static const struct spi_ops rspi_rz_ops = {
 	.set_config_register =	rspi_rz_set_config_register,
 	.transfer_one =		rspi_rz_transfer_one,
+	.min_div =		2,
+	.max_div =		4096,
 	.flags =		SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX,
 	.fifo_size =		8,	/* 8 for TX, 32 for RX */
 	.num_hw_ss =		1,
@@ -1199,6 +1205,8 @@ static const struct spi_ops qspi_ops = {
 	.transfer_one =		qspi_transfer_one,
 	.extra_mode_bits =	SPI_TX_DUAL | SPI_TX_QUAD |
 				SPI_RX_DUAL | SPI_RX_QUAD,
+	.min_div =		1,
+	.max_div =		4080,
 	.flags =		SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX,
 	.fifo_size =		32,
 	.num_hw_ss =		1,
@@ -1260,6 +1268,7 @@ static int rspi_probe(struct platform_device *pdev)
 	int ret;
 	const struct rspi_plat_data *rspi_pd;
 	const struct spi_ops *ops;
+	unsigned long clksrc;
 
 	ctlr = spi_alloc_master(&pdev->dev, sizeof(struct rspi_data));
 	if (ctlr = NULL)
@@ -1312,6 +1321,9 @@ static int rspi_probe(struct platform_device *pdev)
 	ctlr->unprepare_message = rspi_unprepare_message;
 	ctlr->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST |
 			  SPI_LOOP | ops->extra_mode_bits;
+	clksrc = clk_get_rate(rspi->clk);
+	ctlr->min_speed_hz = DIV_ROUND_UP(clksrc, ops->max_div);
+	ctlr->max_speed_hz = DIV_ROUND_UP(clksrc, ops->min_div);
 	ctlr->flags = ops->flags;
 	ctlr->dev.of_node = pdev->dev.of_node;
 	ctlr->use_gpio_descriptors = true;
-- 
2.17.1

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

* Re: [PATCH v2 0/7] spi: rspi: Bit rate improvements
  2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
                   ` (6 preceding siblings ...)
  2020-08-19 12:59 ` [PATCH v2 7/7] spi: rspi: Fill in controller speed limits Geert Uytterhoeven
@ 2020-08-20 21:48 ` Mark Brown
  7 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2020-08-20 21:48 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Chris Brandt, linux-renesas-soc, linux-sh, linux-spi

On Wed, 19 Aug 2020 14:58:57 +0200, Geert Uytterhoeven wrote:
> 	Hi Mark,
> 
> This patch series contains several improvements for the Renesas SPI/QSPI
> driver related to bit rate configuration.
> 
> Changes compared to v1
> (https://lore.kernel.org/r/20200608095940.30516-1-geert+renesas@glider.be):
>   - Drop accepted patch.
> 
> [...]

Applied to

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

Thanks!

[1/7] spi: rspi: Remove useless .set_config_register() check
      commit: 7ffe363bb2a25f0760127657f88243647f49bd5c
[2/7] spi: rspi: Clean up Bit Rate Division Setting handling
      commit: 8dd71698607f822c3675c366a8a79bc82f7621f8
[3/7] spi: rspi: Increase bit rate accuracy on RZ/A
      commit: feace90233a8cd44a18902216657279c3932d471
[4/7] spi: rspi: Increase bit rate range for RSPI on SH
      commit: 4e71d926abbe9ec23415f2ec8685a7bc26c1ceed
[5/7] spi: rspi: Increase bit rate range for QSPI
      commit: 6a195f24f3e88b9242268da79547fe4a61f30910
[6/7] spi: rspi: Fill in spi_transfer.effective_speed_hz
      commit: cb588254140802dbef0b29e4d0a1212cbe5e61e3
[7/7] spi: rspi: Fill in controller speed limits
      commit: c31979747b7090e8d255caecf5bb314436dd90ef

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] 9+ messages in thread

end of thread, other threads:[~2020-08-20 21:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 12:58 [PATCH v2 0/7] spi: rspi: Bit rate improvements Geert Uytterhoeven
2020-08-19 12:58 ` [PATCH v2 1/7] spi: rspi: Remove useless .set_config_register() check Geert Uytterhoeven
2020-08-19 12:58 ` [PATCH v2 2/7] spi: rspi: Clean up Bit Rate Division Setting handling Geert Uytterhoeven
2020-08-19 12:59 ` [PATCH v2 3/7] spi: rspi: Increase bit rate accuracy on RZ/A Geert Uytterhoeven
2020-08-19 12:59 ` [PATCH v2 4/7] spi: rspi: Increase bit rate range for RSPI on SH Geert Uytterhoeven
2020-08-19 12:59 ` [PATCH v2 5/7] spi: rspi: Increase bit rate range for QSPI Geert Uytterhoeven
2020-08-19 12:59 ` [PATCH v2 6/7] spi: rspi: Fill in spi_transfer.effective_speed_hz Geert Uytterhoeven
2020-08-19 12:59 ` [PATCH v2 7/7] spi: rspi: Fill in controller speed limits Geert Uytterhoeven
2020-08-20 21:48 ` [PATCH v2 0/7] spi: rspi: Bit rate improvements 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).