From: Bryan Wu <cooloney@kernel.org>
To: dbrownell@users.sourceforge.net, spi-devel-general@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, Yi Li <yi.li@analog.com>,
Bryan Wu <cooloney@kernel.org>
Subject: [PATCH 15/16] Blackfin SPI Driver: fix bug - spi controller driver does not assert/deassert CS correctly
Date: Tue, 18 Nov 2008 15:52:39 +0800 [thread overview]
Message-ID: <1226994760-4301-16-git-send-email-cooloney@kernel.org> (raw)
In-Reply-To: <1226994760-4301-1-git-send-email-cooloney@kernel.org>
From: Yi Li <yi.li@analog.com>
This bug can be observed when two SPI devices are sharing the spi bus:
One device is set as SPI CS 7, another one is using SPI CS 4.
In spi_bfin5xx.c: cs_active(), cs_deactive() are used to control SPI_FLG
register. From the debug bellow:
cs_active: flag: 0x7f91, chip->flag: 0x7f80, cs: 7
cs_active: flag: 0xef91, chip->flag: 0xef10, cs: 4
When device A (cs_7) activate CS 7, SPI_FLG is set as 0x7f91 (however,
SPI_FLG should be set as 0x7f80, or 0x6f91 if in broadcast mode).
Due to some HW bug (very possibly), if SPI_FLG is set as 0x7f91,
SPISSEL7 is asserted, however SPISSEL4 will be asserted too (I can see
this using the scope). This is unreasonable according to HRM.
Signed-off-by: Yi Li <yi.li@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
drivers/spi/spi_bfin5xx.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 9c602ad..8cf5d6e 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -189,6 +189,7 @@ static void cs_deactive(struct driver_data *drv_data, struct chip_data *chip)
{
u16 flag = read_FLAG(drv_data);
+ flag &= ~chip->flag;
flag |= (chip->flag << 8);
write_FLAG(drv_data, flag);
@@ -1032,7 +1033,6 @@ static int setup(struct spi_device *spi)
struct bfin5xx_spi_chip *chip_info = NULL;
struct chip_data *chip;
struct driver_data *drv_data = spi_master_get_devdata(spi->master);
- u8 spi_flg;
/* Abort device setup if requested features are not supported */
if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST)) {
@@ -1115,8 +1115,7 @@ static int setup(struct spi_device *spi)
* SPI_BAUD, not the real baudrate
*/
chip->baud = hz_to_spi_baud(spi->max_speed_hz);
- spi_flg = ~(1 << (spi->chip_select));
- chip->flag = ((u16) spi_flg << 8) | (1 << (spi->chip_select));
+ chip->flag = 1 << (spi->chip_select);
chip->chip_select_num = spi->chip_select;
switch (chip->bits_per_word) {
--
1.5.6.3
next prev parent reply other threads:[~2008-11-18 7:56 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-18 7:52 Bryan Wu
2008-11-18 7:52 ` [PATCH 01/16] Blackfin SPI Driver: ensure cache coherency before doing DMA Bryan Wu
2008-11-20 20:24 ` David Brownell
2008-11-20 20:58 ` Mike Frysinger
2008-11-20 21:47 ` David Brownell
2008-11-20 21:57 ` Mike Frysinger
2008-11-20 22:05 ` David Brownell
2009-02-05 9:30 ` Bryan Wu
2009-02-05 23:51 ` David Brownell
2009-02-06 2:31 ` Bryan Wu
2008-11-18 7:52 ` [PATCH 02/16] Blackfin SPI Driver: Fix erroneous SPI Clock divisor calculation Bryan Wu
2008-11-20 20:25 ` David Brownell
2008-11-18 7:52 ` [PATCH 03/16] Blackfin SPI Driver: move bfin_addr_dcachable() and friends into the cacheflush header where it belongs Bryan Wu
2008-11-20 20:26 ` David Brownell
2008-11-18 7:52 ` [PATCH 04/16] Blackfin SPI Driver: use len_in_bytes when we care about the number of bytes transferred Bryan Wu
2008-11-20 20:25 ` David Brownell
2008-11-18 7:52 ` [PATCH 05/16] Blackfin SPI Driver: pass DMA overflow error to the higher level Bryan Wu
2008-11-20 20:29 ` David Brownell
2008-11-18 7:52 ` [PATCH 06/16] Blackfin SPI Driver: unify duplicated code in dma read/write paths Bryan Wu
2008-11-20 20:32 ` David Brownell
2008-11-18 7:52 ` [PATCH 07/16] Blackfin SPI Driver: drop bogus cast and touchup dma label Bryan Wu
2008-11-20 20:34 ` David Brownell
2008-11-18 7:52 ` [PATCH 08/16] Blackfin SPI Driver: add a few more debug messages in useful places Bryan Wu
2008-11-20 20:35 ` David Brownell
2008-11-18 7:52 ` [PATCH 09/16] Blackfin SPI Driver: do not check for SPI errors if DMA itself did not flag any Bryan Wu
2008-11-18 7:52 ` [PATCH 10/16] Blackfin SPI Driver: use the properl BIT_CTL_xxx defines Bryan Wu
2008-11-20 20:37 ` David Brownell
2008-11-18 7:52 ` [PATCH 11/16] Blackfin SPI Driver: remove duplicated MAX_SPI_SSEL and remove unnecessary array size Bryan Wu
2008-11-18 7:52 ` [PATCH 12/16] Blackfin SPI Driver: get dma working for SPI flashes Bryan Wu
2008-11-20 20:43 ` David Brownell
2008-11-18 7:52 ` [PATCH 13/16] Blackfin SPI Driver: add timeout while waiting for SPIF in dma irq handler Bryan Wu
2008-11-18 7:52 ` [PATCH 14/16] Blackfin SPI Driver: tweak magic spi dma sequence to get it working on BF54x Bryan Wu
2008-11-18 7:52 ` Bryan Wu [this message]
2008-11-20 20:47 ` [PATCH 15/16] Blackfin SPI Driver: fix bug - spi controller driver does not assert/deassert CS correctly David Brownell
2008-11-18 7:52 ` [PATCH 16/16] Blackfin SPI Driver: fix bug - correct usage of struct spi_transfer.cs_change Bryan Wu
2008-11-20 20:51 ` David Brownell
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=1226994760-4301-16-git-send-email-cooloney@kernel.org \
--to=cooloney@kernel.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