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 v2 2/7] spi: rspi: Clean up Bit Rate Division Setting handling
Date: Wed, 19 Aug 2020 12:58:59 +0000 [thread overview]
Message-ID: <20200819125904.20938-3-geert+renesas@glider.be> (raw)
In-Reply-To: <20200819125904.20938-1-geert+renesas@glider.be>
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
next prev parent reply other threads:[~2020-08-19 12:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20200819125904.20938-3-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: 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).