From: Geert Uytterhoeven <geert+renesas@glider.be> To: Mark Brown <broonie@kernel.org> Cc: Chris Brandt <chris.brandt@renesas.com>, linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven <geert+renesas@glider.be> Subject: [PATCH 6/8] spi: rspi: Increase bit rate range for QSPI Date: Mon, 08 Jun 2020 09:59:38 +0000 [thread overview] Message-ID: <20200608095940.30516-7-geert+renesas@glider.be> (raw) In-Reply-To: <20200608095940.30516-1-geert+renesas@glider.be> 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, 2. Make use of the Bit Rate Frequency Division Setting field in Command Registers, to decrease the lower limit from 191 to 24 kbps. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- 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
WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert+renesas@glider.be> To: Mark Brown <broonie@kernel.org> Cc: Chris Brandt <chris.brandt@renesas.com>, linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven <geert+renesas@glider.be> Subject: [PATCH 6/8] spi: rspi: Increase bit rate range for QSPI Date: Mon, 8 Jun 2020 11:59:38 +0200 [thread overview] Message-ID: <20200608095940.30516-7-geert+renesas@glider.be> (raw) In-Reply-To: <20200608095940.30516-1-geert+renesas@glider.be> 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, 2. Make use of the Bit Rate Frequency Division Setting field in Command Registers, to decrease the lower limit from 191 to 24 kbps. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- 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
next prev parent reply other threads:[~2020-06-08 9:59 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-08 9:59 [PATCH 0/8] spi: rspi: Bit rate improvements Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven 2020-06-08 9:59 ` [PATCH 1/8] spi: rspi: Remove useless .set_config_register() check Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven 2020-06-08 9:59 ` [PATCH 2/8] spi: rspi: Use requested instead of maximum bit rate Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven 2020-06-08 9:59 ` [PATCH 3/8] spi: rspi: Clean up Bit Rate Division Setting handling Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven 2020-06-08 9:59 ` [PATCH 4/8] spi: rspi: Increase bit rate accuracy on RZ/A Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven 2020-06-08 9:59 ` [PATCH 5/8] spi: rspi: Increase bit rate range for RSPI on SH Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven [this message] 2020-06-08 9:59 ` [PATCH 6/8] spi: rspi: Increase bit rate range for QSPI Geert Uytterhoeven 2020-06-08 9:59 ` [PATCH 7/8] spi: rspi: Fill in spi_transfer.effective_speed_hz Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven 2020-06-08 9:59 ` [PATCH 8/8] spi: rspi: Fill in controller speed limits Geert Uytterhoeven 2020-06-08 9:59 ` Geert Uytterhoeven 2020-06-09 12:54 ` [PATCH 0/8] spi: rspi: Bit rate improvements Mark Brown 2020-06-09 12:54 ` Mark Brown
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=20200608095940.30516-7-geert+renesas@glider.be \ --to=geert+renesas@glider.be \ --cc=broonie@kernel.org \ --cc=chris.brandt@renesas.com \ --cc=linux-renesas-soc@vger.kernel.org \ --cc=linux-sh@vger.kernel.org \ --cc=linux-spi@vger.kernel.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.