From: Sascha Hauer <s.hauer@pengutronix.de>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>
Cc: Mark Brown <broonie@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <fabio.estevam@nxp.com>,
NXP Linux Team <linux-imx@nxp.com>,
linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org,
linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com,
alexandre.belloni@bootlin.com
Subject: Re: [PATCH RESEND 2/5] spi: imx: Use dynamic bursts only when bits_per_word is 8, 16 or 32
Date: Mon, 6 Aug 2018 11:41:11 +0200 [thread overview]
Message-ID: <20180806094111.uutolczqccm2e2ot@pengutronix.de> (raw)
In-Reply-To: <20180717143154.28241-3-maxime.chevallier@bootlin.com>
On Tue, Jul 17, 2018 at 04:31:51PM +0200, Maxime Chevallier wrote:
> The dynamic bursts mode allows to group together multiple words into a
> single burst. To do so, it's necessary that words can be packed into the
> 32-bits FIFO entries, so we can't allow using this mode with bit_per_words
> different to 8, 16 or 32.
>
> This prevents shitfing out extra clock ticks for transfers with
s/shitfing/shifting/
> bit_per_word values not aligned on 8 bits.
>
> With that , we are sure that only the correct number of bits is
> shifted out at each transfer, so we don't need to mask out the remaining
> parts of the words.
>
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha
> ---
> drivers/spi/spi-imx.c | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index d75153c995af..ecafbda5ec94 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -95,7 +95,6 @@ struct spi_imx_data {
> const void *tx_buf;
> unsigned int txfifo; /* number of words pushed in tx FIFO */
> unsigned int dynamic_burst, read_u32;
> - unsigned int word_mask;
>
> /* Slave mode */
> bool slave_mode;
> @@ -291,7 +290,6 @@ static void spi_imx_buf_rx_swap_u32(struct spi_imx_data *spi_imx)
> else if (bytes_per_word == 2)
> val = (val << 16) | (val >> 16);
> #endif
> - val &= spi_imx->word_mask;
> *(u32 *)spi_imx->rx_buf = val;
> spi_imx->rx_buf += sizeof(u32);
> }
> @@ -322,7 +320,6 @@ static void spi_imx_buf_tx_swap_u32(struct spi_imx_data *spi_imx)
>
> if (spi_imx->tx_buf) {
> val = *(u32 *)spi_imx->tx_buf;
> - val &= spi_imx->word_mask;
> spi_imx->tx_buf += sizeof(u32);
> }
>
> @@ -1102,25 +1099,23 @@ static int spi_imx_setupxfer(struct spi_device *spi,
> spi_imx->bits_per_word = t->bits_per_word;
> spi_imx->speed_hz = t->speed_hz;
>
> - /* Initialize the functions for transfer */
> - if (spi_imx->devtype_data->dynamic_burst && !spi_imx->slave_mode) {
> - u32 mask;
> + /*
> + * Initialize the functions for transfer. To transfer non byte-aligned
> + * words, we have to use multiple word-size bursts, we can't use
> + * dynamic_burst in that case.
> + */
> + if (spi_imx->devtype_data->dynamic_burst && !spi_imx->slave_mode &&
> + (spi_imx->bits_per_word == 8 ||
> + spi_imx->bits_per_word == 16 ||
> + spi_imx->bits_per_word == 32)) {
>
> spi_imx->read_u32 = 1;
>
> - mask = (1 << spi_imx->bits_per_word) - 1;
> spi_imx->rx = spi_imx_buf_rx_swap;
> spi_imx->tx = spi_imx_buf_tx_swap;
> spi_imx->dynamic_burst = 1;
> spi_imx->remainder = t->len;
>
> - if (spi_imx->bits_per_word <= 8)
> - spi_imx->word_mask = mask << 24 | mask << 16
> - | mask << 8 | mask;
> - else if (spi_imx->bits_per_word <= 16)
> - spi_imx->word_mask = mask << 16 | mask;
> - else
> - spi_imx->word_mask = mask;
> } else {
> if (spi_imx->bits_per_word <= 8) {
> spi_imx->rx = spi_imx_buf_rx_u8;
> --
> 2.11.0
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2018-08-06 9:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-17 14:31 [PATCH RESEND 0/5] spi: imx: Improve non 8-bit aligned words and dynamic bursts Maxime Chevallier
2018-07-17 14:31 ` [PATCH RESEND 1/5] spi: imx: Remove duplicate variable assignments Maxime Chevallier
2018-08-06 8:56 ` Sascha Hauer
2018-07-17 14:31 ` [PATCH RESEND 2/5] spi: imx: Use dynamic bursts only when bits_per_word is 8, 16 or 32 Maxime Chevallier
2018-08-06 9:41 ` Sascha Hauer [this message]
2018-07-17 14:31 ` [PATCH RESEND 3/5] spi: imx: Use correct number of bytes per words Maxime Chevallier
2018-08-06 9:21 ` Sascha Hauer
2018-07-17 14:31 ` [PATCH RESEND 4/5] spi: imx: remove unnecessary check in spi_imx_can_dma Maxime Chevallier
2018-08-06 9:17 ` Sascha Hauer
2018-07-17 14:31 ` [PATCH RESEND 5/5] spi: imx: Use the longuest possible burst size when in dynamic_burst Maxime Chevallier
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=20180806094111.uutolczqccm2e2ot@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=alexandre.belloni@bootlin.com \
--cc=broonie@kernel.org \
--cc=fabio.estevam@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=shawnguo@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/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).