From: Bryan Wu <cooloney@kernel.org>
To: dbrownell@users.sourceforge.net, akpm@linux-foundation.org
Cc: spi-devel-general@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Yi Li <yi.li@analog.com>,
Bryan Wu <cooloney@kernel.org>
Subject: [PATCH 16/20] Blackfin SPI Driver: fix bug - correct usage of struct spi_transfer.cs_change
Date: Fri, 6 Feb 2009 15:13:04 +0800 [thread overview]
Message-ID: <1233904388-5765-17-git-send-email-cooloney@kernel.org> (raw)
In-Reply-To: <1233904388-5765-1-git-send-email-cooloney@kernel.org>
From: Yi Li <yi.li@analog.com>
According to comments in linux/spi/spi.h:
* All SPI transfers start with the relevant chipselect active. Normally
* it stays selected until after the last transfer in a message. Drivers
* can affect the chipselect signal using cs_change.
*
* (i) If the transfer isn't the last one in the message, this flag is
* used to make the chipselect briefly go inactive in the middle of the
* message. Toggling chipselect in this way may be needed to terminate
* a chip command, letting a single spi_message perform all of group of
* chip transactions together.
*
* (ii) When the transfer is the last one in the message, the chip may
* stay selected until the next transfer. On multi-device SPI busses
* with nothing blocking messages going to other devices, this is just
* a performance hint; starting a message to another device deselects
* this one. But in other cases, this can be used to ensure correctness.
* Some devices need protocol transactions to be built from a series of
* spi_message submissions, where the content of one message is determined
* by the results of previous messages and where the whole transaction
* ends when the chipselect goes intactive.
Signed-off-by: Yi Li <yi.li@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
---
drivers/spi/spi_bfin5xx.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index ed6a4c1..811a305 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -540,15 +540,13 @@ static void giveback(struct driver_data *drv_data)
msg->state = NULL;
- /* disable chip select signal. And not stop spi in autobuffer mode */
- if (drv_data->tx_dma != 0xFFFF) {
- cs_deactive(drv_data, chip);
- bfin_spi_disable(drv_data);
- }
-
if (!drv_data->cs_change)
cs_deactive(drv_data, chip);
+ /* Not stop spi in autobuffer mode */
+ if (drv_data->tx_dma != 0xFFFF)
+ bfin_spi_disable(drv_data);
+
if (msg->complete)
msg->complete(msg->context);
}
@@ -757,7 +755,8 @@ static void pump_transfers(unsigned long data)
write_STAT(drv_data, BIT_STAT_CLR);
cr = (read_CTRL(drv_data) & (~BIT_CTL_TIMOD));
- cs_active(drv_data, chip);
+ if (drv_data->cs_change)
+ cs_active(drv_data, chip);
dev_dbg(&drv_data->pdev->dev,
"now pumping a transfer: width is %d, len is %d\n",
@@ -919,11 +918,11 @@ static void pump_transfers(unsigned long data)
} else {
/* Update total byte transfered */
message->actual_length += drv_data->len_in_bytes;
-
/* Move to next transfer of this msg */
message->state = next_transfer(drv_data);
+ if (drv_data->cs_change)
+ cs_deactive(drv_data, chip);
}
-
/* Schedule next transfer tasklet */
tasklet_schedule(&drv_data->pump_transfers);
--
1.5.6.3
next prev parent reply other threads:[~2009-02-06 7:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-06 7:12 [PATCH 00/20] Blackfin SPI Driver fixing and updates Bryan Wu
2009-02-06 7:12 ` [PATCH 01/20] Blackfin SPI Driver: ensure cache coherency before doing DMA Bryan Wu
2009-02-06 7:12 ` [PATCH 02/20] Blackfin SPI Driver: Fix erroneous SPI Clock divisor calculation Bryan Wu
2009-02-06 7:12 ` [PATCH 03/20] Blackfin SPI Driver: remove useless <asm/cplbinit.h> Bryan Wu
2009-02-06 7:12 ` [PATCH 04/20] Blackfin SPI Driver: use len_in_bytes when we care about the number of bytes transferred Bryan Wu
2009-02-06 7:12 ` [PATCH 05/20] Blackfin SPI Driver: pass DMA overflow error to the higher level Bryan Wu
2009-02-06 7:12 ` [PATCH 06/20] Blackfin SPI Driver: unify duplicated code in dma read/write paths Bryan Wu
2009-02-06 7:12 ` [PATCH 07/20] Blackfin SPI Driver: drop bogus cast and touchup dma label Bryan Wu
2009-02-06 7:12 ` [PATCH 08/20] Blackfin SPI Driver: add a few more DMA debug messages Bryan Wu
2009-02-06 7:12 ` [PATCH 09/20] Blackfin SPI Driver: do not check for SPI errors if DMA itself did not flag any Bryan Wu
2009-02-06 7:12 ` [PATCH 10/20] Blackfin SPI Driver: use the properl BIT_CTL_xxx defines Bryan Wu
2009-02-06 7:12 ` [PATCH 11/20] Blackfin SPI Driver: SPI slave select code cleanup Bryan Wu
2009-02-06 7:13 ` [PATCH 12/20] Blackfin SPI Driver: get dma working for SPI flashes Bryan Wu
2009-02-06 7:13 ` [PATCH 13/20] Blackfin SPI Driver: add timeout while waiting for SPIF in dma irq handler Bryan Wu
2009-02-06 7:13 ` [PATCH 14/20] Blackfin SPI Driver: tweak magic spi dma sequence to get it working on BF54x Bryan Wu
2009-02-06 7:13 ` [PATCH 15/20] Blackfin SPI Driver: fix bug - spi controller driver does not assert/deassert CS correctly Bryan Wu
2009-02-06 7:13 ` Bryan Wu [this message]
2009-02-06 7:13 ` [PATCH 17/20] Blackfin SPI Driver: use bfin_spi_ prefix on all functions Bryan Wu
2009-02-06 7:13 ` [PATCH 18/20] Blackfin SPI Driver: fix NULL pointer crash Bryan Wu
2009-02-06 7:13 ` [PATCH 19/20] Blackfin SPI Driver: Add GPIO controlled SPI Slave Select support Bryan Wu
2009-02-06 7:13 ` [PATCH 20/20] Blackfin SPI Driver: Make mmc_spi driver work on Blackfin Bryan Wu
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=1233904388-5765-17-git-send-email-cooloney@kernel.org \
--to=cooloney@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dbrownell@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=spi-devel-general@lists.sourceforge.net \
--cc=yi.li@analog.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