* [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx.
@ 2013-03-04 7:20 Sonic Zhang
2013-03-04 7:20 ` [U-Boot] [PATCH v1 2/2] bfin: discard invalid data and clear RXS in bf5xx spi driver Sonic Zhang
2013-03-12 11:19 ` [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx Mike Frysinger
0 siblings, 2 replies; 4+ messages in thread
From: Sonic Zhang @ 2013-03-04 7:20 UTC (permalink / raw)
To: u-boot
From: Scott Jiang <scott.jiang.linux@gmail.com>
BF5xx rx dma causes spi flash random read error.
Accually spi controller has problems both on tx and rx dma.
So remove spi dma support in u-boot.
Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
drivers/spi/bfin_spi.c | 103 +-----------------------------------------------
1 files changed, 1 insertions(+), 102 deletions(-)
diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c
index e080bec..fff384a 100644
--- a/drivers/spi/bfin_spi.c
+++ b/drivers/spi/bfin_spi.c
@@ -13,7 +13,6 @@
#include <spi.h>
#include <asm/blackfin.h>
-#include <asm/dma.h>
#include <asm/gpio.h>
#include <asm/portmux.h>
#include <asm/mach-common/bits/spi.h>
@@ -244,106 +243,10 @@ void spi_release_bus(struct spi_slave *slave)
SSYNC();
}
-#ifdef __ADSPBF54x__
-# define SPI_DMA_BASE DMA4_NEXT_DESC_PTR
-#elif defined(__ADSPBF533__) || defined(__ADSPBF532__) || defined(__ADSPBF531__) || \
- defined(__ADSPBF538__) || defined(__ADSPBF539__)
-# define SPI_DMA_BASE DMA5_NEXT_DESC_PTR
-#elif defined(__ADSPBF561__)
-# define SPI_DMA_BASE DMA2_4_NEXT_DESC_PTR
-#elif defined(__ADSPBF537__) || defined(__ADSPBF536__) || defined(__ADSPBF534__) || \
- defined(__ADSPBF52x__) || defined(__ADSPBF51x__)
-# define SPI_DMA_BASE DMA7_NEXT_DESC_PTR
-# elif defined(__ADSPBF50x__)
-# define SPI_DMA_BASE DMA6_NEXT_DESC_PTR
-#else
-# error "Please provide SPI DMA channel defines"
-#endif
-static volatile struct dma_register *dma = (void *)SPI_DMA_BASE;
-
#ifndef CONFIG_BFIN_SPI_IDLE_VAL
# define CONFIG_BFIN_SPI_IDLE_VAL 0xff
#endif
-#ifdef CONFIG_BFIN_SPI_NO_DMA
-# define SPI_DMA 0
-#else
-# define SPI_DMA 1
-#endif
-
-static int spi_dma_xfer(struct bfin_spi_slave *bss, const u8 *tx, u8 *rx,
- uint bytes)
-{
- int ret = -1;
- u16 ndsize, spi_config, dma_config;
- struct dmasg dmasg[2];
- const u8 *buf;
-
- if (tx) {
- debug("%s: doing half duplex TX\n", __func__);
- buf = tx;
- spi_config = TDBR_DMA;
- dma_config = 0;
- } else {
- debug("%s: doing half duplex RX\n", __func__);
- buf = rx;
- spi_config = RDBR_DMA;
- dma_config = WNR;
- }
-
- dmasg[0].start_addr = (unsigned long)buf;
- dmasg[0].x_modify = 1;
- dma_config |= WDSIZE_8 | DMAEN;
- if (bytes <= 65536) {
- blackfin_dcache_flush_invalidate_range(buf, buf + bytes);
- ndsize = NDSIZE_5;
- dmasg[0].cfg = NDSIZE_0 | dma_config | FLOW_STOP | DI_EN;
- dmasg[0].x_count = bytes;
- } else {
- blackfin_dcache_flush_invalidate_range(buf, buf + 65536 - 1);
- ndsize = NDSIZE_7;
- dmasg[0].cfg = NDSIZE_5 | dma_config | FLOW_ARRAY | DMA2D;
- dmasg[0].x_count = 0; /* 2^16 */
- dmasg[0].y_count = bytes >> 16; /* count / 2^16 */
- dmasg[0].y_modify = 1;
- dmasg[1].start_addr = (unsigned long)(buf + (bytes & ~0xFFFF));
- dmasg[1].cfg = NDSIZE_0 | dma_config | FLOW_STOP | DI_EN;
- dmasg[1].x_count = bytes & 0xFFFF; /* count % 2^16 */
- dmasg[1].x_modify = 1;
- }
-
- dma->cfg = 0;
- dma->irq_status = DMA_DONE | DMA_ERR;
- dma->curr_desc_ptr = dmasg;
- write_SPI_CTL(bss, (bss->ctl & ~TDBR_CORE));
- write_SPI_STAT(bss, -1);
- SSYNC();
-
- write_SPI_TDBR(bss, CONFIG_BFIN_SPI_IDLE_VAL);
- dma->cfg = ndsize | FLOW_ARRAY | DMAEN;
- write_SPI_CTL(bss, (bss->ctl & ~TDBR_CORE) | spi_config);
- SSYNC();
-
- /*
- * We already invalidated the first 64k,
- * now while we just wait invalidate the remaining part.
- * Its not likely that the DMA is going to overtake
- */
- if (bytes > 65536)
- blackfin_dcache_flush_invalidate_range(buf + 65536, buf + bytes);
-
- while (!(dma->irq_status & DMA_DONE))
- if (ctrlc())
- goto done;
-
- dma->cfg = 0;
-
- ret = 0;
- done:
- write_SPI_CTL(bss, bss->ctl);
- return ret;
-}
-
static int spi_pio_xfer(struct bfin_spi_slave *bss, const u8 *tx, u8 *rx,
uint bytes)
{
@@ -395,11 +298,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
if (flags & SPI_XFER_BEGIN)
spi_cs_activate(slave);
- /* TX DMA doesn't work quite right */
- if (SPI_DMA && bytes > 6 && (!tx /*|| !rx*/))
- ret = spi_dma_xfer(bss, tx, rx, bytes);
- else
- ret = spi_pio_xfer(bss, tx, rx, bytes);
+ ret = spi_pio_xfer(bss, tx, rx, bytes);
done:
if (flags & SPI_XFER_END)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v1 2/2] bfin: discard invalid data and clear RXS in bf5xx spi driver
2013-03-04 7:20 [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx Sonic Zhang
@ 2013-03-04 7:20 ` Sonic Zhang
2013-03-12 11:19 ` [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx Mike Frysinger
1 sibling, 0 replies; 4+ messages in thread
From: Sonic Zhang @ 2013-03-04 7:20 UTC (permalink / raw)
To: u-boot
From: Scott Jiang <scott.jiang.linux@gmail.com>
There may be dirty data in RDBR, so we should discard invalid data.
This operation also clears RXS bit in STAT register.
Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
drivers/spi/bfin_spi.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c
index fff384a..1845e4f 100644
--- a/drivers/spi/bfin_spi.c
+++ b/drivers/spi/bfin_spi.c
@@ -250,6 +250,8 @@ void spi_release_bus(struct spi_slave *slave)
static int spi_pio_xfer(struct bfin_spi_slave *bss, const u8 *tx, u8 *rx,
uint bytes)
{
+ /* discard invalid data and clear RXS */
+ read_SPI_RDBR(bss);
/* todo: take advantage of hardware fifos */
while (bytes--) {
u8 value = (tx ? *tx++ : CONFIG_BFIN_SPI_IDLE_VAL);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx.
2013-03-04 7:20 [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx Sonic Zhang
2013-03-04 7:20 ` [U-Boot] [PATCH v1 2/2] bfin: discard invalid data and clear RXS in bf5xx spi driver Sonic Zhang
@ 2013-03-12 11:19 ` Mike Frysinger
2013-03-13 3:13 ` Scott Jiang
1 sibling, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2013-03-12 11:19 UTC (permalink / raw)
To: u-boot
On Monday 04 March 2013 02:20:08 Sonic Zhang wrote:
> From: Scott Jiang <scott.jiang.linux@gmail.com>
>
> BF5xx rx dma causes spi flash random read error.
> Accually spi controller has problems both on tx and rx dma.
> So remove spi dma support in u-boot.
this is wrong, and imo, unnecessary. it's wrong because using DMA gains a lot
of speed increases, and works for in many cases (i haven't seen cases where it
didn't work, but i haven't been actively developing in the last year of
course). it's unnecessary because there's already a CONFIG_xxx option to
disable it if your platform is having problems and you can't figure things out,
and don't need the speed gains.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130312/635c7fdb/attachment.pgp>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx.
2013-03-12 11:19 ` [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx Mike Frysinger
@ 2013-03-13 3:13 ` Scott Jiang
0 siblings, 0 replies; 4+ messages in thread
From: Scott Jiang @ 2013-03-13 3:13 UTC (permalink / raw)
To: u-boot
Mike,
test case is [#6887], if you save data and read out to compare it
sometimes fail.
I agree that we can keep this patch, but it introduces problems to
test engineer.
This is a random error, she is difficult to know which board and which case we
should enable this function.
2013/3/12 Mike Frysinger <vapier@gentoo.org>:
> On Monday 04 March 2013 02:20:08 Sonic Zhang wrote:
>> From: Scott Jiang <scott.jiang.linux@gmail.com>
>>
>> BF5xx rx dma causes spi flash random read error.
>> Accually spi controller has problems both on tx and rx dma.
>> So remove spi dma support in u-boot.
>
> this is wrong, and imo, unnecessary. it's wrong because using DMA gains a lot
> of speed increases, and works for in many cases (i haven't seen cases where it
> didn't work, but i haven't been actively developing in the last year of
> course). it's unnecessary because there's already a CONFIG_xxx option to
> disable it if your platform is having problems and you can't figure things out,
> and don't need the speed gains.
> -mike
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-13 3:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-04 7:20 [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx Sonic Zhang
2013-03-04 7:20 ` [U-Boot] [PATCH v1 2/2] bfin: discard invalid data and clear RXS in bf5xx spi driver Sonic Zhang
2013-03-12 11:19 ` [U-Boot] [PATCH v1 1/2] bfin: Remove spi dma function in bf5xx Mike Frysinger
2013-03-13 3:13 ` Scott Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox