mtd: onenand: omap2: Convert to use dmaengine for memcpy
Do not use the legacy and deprecated omap-dma interface for setting up the memcpy. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Acked-by: Roger Quadros <rogerq@ti.com> Tested-by: Tony Lindgren <tony@atomide.com> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
This commit is contained in:
parent
fb25070afd
commit
3ed6a4d1de
|
@ -32,6 +32,7 @@
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/dma-mapping.h>
|
#include <linux/dma-mapping.h>
|
||||||
|
#include <linux/dmaengine.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
|
@ -39,8 +40,6 @@
|
||||||
#include <asm/mach/flash.h>
|
#include <asm/mach/flash.h>
|
||||||
#include <linux/platform_data/mtd-onenand-omap2.h>
|
#include <linux/platform_data/mtd-onenand-omap2.h>
|
||||||
|
|
||||||
#include <linux/omap-dma.h>
|
|
||||||
|
|
||||||
#define DRIVER_NAME "omap2-onenand"
|
#define DRIVER_NAME "omap2-onenand"
|
||||||
|
|
||||||
#define ONENAND_BUFRAM_SIZE (1024 * 5)
|
#define ONENAND_BUFRAM_SIZE (1024 * 5)
|
||||||
|
@ -55,17 +54,15 @@ struct omap2_onenand {
|
||||||
struct onenand_chip onenand;
|
struct onenand_chip onenand;
|
||||||
struct completion irq_done;
|
struct completion irq_done;
|
||||||
struct completion dma_done;
|
struct completion dma_done;
|
||||||
int dma_channel;
|
struct dma_chan *dma_chan;
|
||||||
int freq;
|
int freq;
|
||||||
int (*setup)(void __iomem *base, int *freq_ptr);
|
int (*setup)(void __iomem *base, int *freq_ptr);
|
||||||
u8 flags;
|
u8 flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data)
|
static void omap2_onenand_dma_complete_func(void *completion)
|
||||||
{
|
{
|
||||||
struct omap2_onenand *c = data;
|
complete(completion);
|
||||||
|
|
||||||
complete(&c->dma_done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t omap2_onenand_interrupt(int irq, void *dev_id)
|
static irqreturn_t omap2_onenand_interrupt(int irq, void *dev_id)
|
||||||
|
@ -292,23 +289,31 @@ static inline int omap2_onenand_dma_transfer(struct omap2_onenand *c,
|
||||||
dma_addr_t src, dma_addr_t dst,
|
dma_addr_t src, dma_addr_t dst,
|
||||||
size_t count)
|
size_t count)
|
||||||
{
|
{
|
||||||
int data_type = __ffs((src | dst | count));
|
struct dma_async_tx_descriptor *tx;
|
||||||
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
if (data_type > OMAP_DMA_DATA_TYPE_S32)
|
tx = dmaengine_prep_dma_memcpy(c->dma_chan, dst, src, count, 0);
|
||||||
data_type = OMAP_DMA_DATA_TYPE_S32;
|
if (!tx) {
|
||||||
|
dev_err(&c->pdev->dev, "Failed to prepare DMA memcpy\n");
|
||||||
omap_set_dma_transfer_params(c->dma_channel, data_type,
|
return -EIO;
|
||||||
count / BIT(data_type), 1, 0, 0, 0);
|
}
|
||||||
omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
||||||
src, 0, 0);
|
|
||||||
omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
||||||
dst, 0, 0);
|
|
||||||
|
|
||||||
reinit_completion(&c->dma_done);
|
reinit_completion(&c->dma_done);
|
||||||
omap_start_dma(c->dma_channel);
|
|
||||||
|
tx->callback = omap2_onenand_dma_complete_func;
|
||||||
|
tx->callback_param = &c->dma_done;
|
||||||
|
|
||||||
|
cookie = tx->tx_submit(tx);
|
||||||
|
if (dma_submit_error(cookie)) {
|
||||||
|
dev_err(&c->pdev->dev, "Failed to do DMA tx_submit\n");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
dma_async_issue_pending(c->dma_chan);
|
||||||
|
|
||||||
if (!wait_for_completion_io_timeout(&c->dma_done,
|
if (!wait_for_completion_io_timeout(&c->dma_done,
|
||||||
msecs_to_jiffies(20))) {
|
msecs_to_jiffies(20))) {
|
||||||
omap_stop_dma(c->dma_channel);
|
dmaengine_terminate_sync(c->dma_chan);
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,8 +473,7 @@ static int omap2_onenand_probe(struct platform_device *pdev)
|
||||||
c->flags = pdata->flags;
|
c->flags = pdata->flags;
|
||||||
c->gpmc_cs = pdata->cs;
|
c->gpmc_cs = pdata->cs;
|
||||||
c->gpio_irq = pdata->gpio_irq;
|
c->gpio_irq = pdata->gpio_irq;
|
||||||
c->dma_channel = pdata->dma_channel;
|
if (pdata->dma_channel < 0) {
|
||||||
if (c->dma_channel < 0) {
|
|
||||||
/* if -1, don't use DMA */
|
/* if -1, don't use DMA */
|
||||||
c->gpio_irq = 0;
|
c->gpio_irq = 0;
|
||||||
}
|
}
|
||||||
|
@ -521,25 +525,17 @@ static int omap2_onenand_probe(struct platform_device *pdev)
|
||||||
goto err_release_gpio;
|
goto err_release_gpio;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->dma_channel >= 0) {
|
if (pdata->dma_channel >= 0) {
|
||||||
r = omap_request_dma(0, pdev->dev.driver->name,
|
dma_cap_mask_t mask;
|
||||||
omap2_onenand_dma_cb, (void *) c,
|
|
||||||
&c->dma_channel);
|
dma_cap_zero(mask);
|
||||||
if (r == 0) {
|
dma_cap_set(DMA_MEMCPY, mask);
|
||||||
omap_set_dma_write_mode(c->dma_channel,
|
|
||||||
OMAP_DMA_WRITE_NON_POSTED);
|
c->dma_chan = dma_request_channel(mask, NULL, NULL);
|
||||||
omap_set_dma_src_data_pack(c->dma_channel, 1);
|
if (!c->dma_chan)
|
||||||
omap_set_dma_src_burst_mode(c->dma_channel,
|
|
||||||
OMAP_DMA_DATA_BURST_8);
|
|
||||||
omap_set_dma_dest_data_pack(c->dma_channel, 1);
|
|
||||||
omap_set_dma_dest_burst_mode(c->dma_channel,
|
|
||||||
OMAP_DMA_DATA_BURST_8);
|
|
||||||
} else {
|
|
||||||
dev_info(&pdev->dev,
|
dev_info(&pdev->dev,
|
||||||
"failed to allocate DMA for OneNAND, "
|
"failed to allocate DMA for OneNAND, "
|
||||||
"using PIO instead\n");
|
"using PIO instead\n");
|
||||||
c->dma_channel = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual "
|
dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual "
|
||||||
|
@ -553,7 +549,7 @@ static int omap2_onenand_probe(struct platform_device *pdev)
|
||||||
mtd_set_of_node(&c->mtd, pdata->of_node);
|
mtd_set_of_node(&c->mtd, pdata->of_node);
|
||||||
|
|
||||||
this = &c->onenand;
|
this = &c->onenand;
|
||||||
if (c->dma_channel >= 0) {
|
if (c->dma_chan) {
|
||||||
this->wait = omap2_onenand_wait;
|
this->wait = omap2_onenand_wait;
|
||||||
this->read_bufferram = omap2_onenand_read_bufferram;
|
this->read_bufferram = omap2_onenand_read_bufferram;
|
||||||
this->write_bufferram = omap2_onenand_write_bufferram;
|
this->write_bufferram = omap2_onenand_write_bufferram;
|
||||||
|
@ -573,8 +569,8 @@ static int omap2_onenand_probe(struct platform_device *pdev)
|
||||||
err_release_onenand:
|
err_release_onenand:
|
||||||
onenand_release(&c->mtd);
|
onenand_release(&c->mtd);
|
||||||
err_release_dma:
|
err_release_dma:
|
||||||
if (c->dma_channel != -1)
|
if (c->dma_chan)
|
||||||
omap_free_dma(c->dma_channel);
|
dma_release_channel(c->dma_chan);
|
||||||
if (c->gpio_irq)
|
if (c->gpio_irq)
|
||||||
free_irq(gpio_to_irq(c->gpio_irq), c);
|
free_irq(gpio_to_irq(c->gpio_irq), c);
|
||||||
err_release_gpio:
|
err_release_gpio:
|
||||||
|
@ -595,8 +591,8 @@ static int omap2_onenand_remove(struct platform_device *pdev)
|
||||||
struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
|
struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
|
||||||
|
|
||||||
onenand_release(&c->mtd);
|
onenand_release(&c->mtd);
|
||||||
if (c->dma_channel != -1)
|
if (c->dma_chan)
|
||||||
omap_free_dma(c->dma_channel);
|
dma_release_channel(c->dma_chan);
|
||||||
omap2_onenand_shutdown(pdev);
|
omap2_onenand_shutdown(pdev);
|
||||||
if (c->gpio_irq) {
|
if (c->gpio_irq) {
|
||||||
free_irq(gpio_to_irq(c->gpio_irq), c);
|
free_irq(gpio_to_irq(c->gpio_irq), c);
|
||||||
|
|
Loading…
Reference in New Issue