Commit 11d6f599 authored by Mike Frysinger's avatar Mike Frysinger Committed by Linus Torvalds

Blackfin SPI Driver: get dma working for SPI flashes

When using a BF533-STAMP here with a W25X10 SPI flash.  It works fine when
enable_dma is disabled, but doesn't work at all when turning DMA on.  We
get just 0xff bytes back when trying to read the device.

Change the code around so that it programs the SPI first and then enables
DMA, it seems to work a lot better ...
Signed-off-by: default avatarMike Frysinger <vapier.adi@gmail.com>
Signed-off-by: default avatarBryan Wu <cooloney@kernel.org>
Acked-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4160bde2
...@@ -761,11 +761,10 @@ static void pump_transfers(unsigned long data) ...@@ -761,11 +761,10 @@ static void pump_transfers(unsigned long data)
if (!full_duplex && drv_data->cur_chip->enable_dma if (!full_duplex && drv_data->cur_chip->enable_dma
&& drv_data->len > 6) { && drv_data->len > 6) {
unsigned long dma_start_addr; unsigned long dma_start_addr, flags;
disable_dma(drv_data->dma_channel); disable_dma(drv_data->dma_channel);
clear_dma_irqstat(drv_data->dma_channel); clear_dma_irqstat(drv_data->dma_channel);
bfin_spi_disable(drv_data);
/* config dma channel */ /* config dma channel */
dev_dbg(&drv_data->pdev->dev, "doing dma transfer\n"); dev_dbg(&drv_data->pdev->dev, "doing dma transfer\n");
...@@ -796,8 +795,7 @@ static void pump_transfers(unsigned long data) ...@@ -796,8 +795,7 @@ static void pump_transfers(unsigned long data)
enable_dma(drv_data->dma_channel); enable_dma(drv_data->dma_channel);
/* start SPI transfer */ /* start SPI transfer */
write_CTRL(drv_data, write_CTRL(drv_data, cr | BIT_CTL_TIMOD_DMA_TX);
(cr | BIT_CTL_TIMOD_DMA_TX | BIT_CTL_ENABLE));
/* just return here, there can only be one transfer /* just return here, there can only be one transfer
* in this mode * in this mode
...@@ -842,14 +840,22 @@ static void pump_transfers(unsigned long data) ...@@ -842,14 +840,22 @@ static void pump_transfers(unsigned long data)
} else } else
BUG(); BUG();
/* start dma */ /* oh man, here there be monsters ... and i dont mean the
dma_enable_irq(drv_data->dma_channel); * fluffy cute ones from pixar, i mean the kind that'll eat
set_dma_config(drv_data->dma_channel, dma_config); * your data, kick your dog, and love it all. do *not* try
* and change these lines unless you (1) heavily test DMA
* with SPI flashes on a loaded system (e.g. ping floods),
* (2) know just how broken the DMA engine interaction with
* the SPI peripheral is, and (3) have someone else to blame
* when you screw it all up anyways.
*/
set_dma_start_addr(drv_data->dma_channel, dma_start_addr); set_dma_start_addr(drv_data->dma_channel, dma_start_addr);
set_dma_config(drv_data->dma_channel, dma_config);
local_irq_save(flags);
enable_dma(drv_data->dma_channel); enable_dma(drv_data->dma_channel);
write_CTRL(drv_data, cr);
/* start SPI transfer */ dma_enable_irq(drv_data->dma_channel);
write_CTRL(drv_data, (cr | BIT_CTL_ENABLE)); local_irq_restore(flags);
} else { } else {
/* IO mode write then read */ /* IO mode write then read */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment