aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2013-02-25 22:44:28 -0500
committerShawn Guo <shawn.guo@linaro.org>2013-04-04 09:22:45 -0400
commit5fac0e18bd3dbd7e23276efa0e5d2b945b1165e8 (patch)
treedadf4b3c3d138fcfb7274b26f963035d6b76626a /drivers/mtd
parente5aba13da0cc598a5573ea059717949fbd7536ad (diff)
mtd: gpmi: move to use generic DMA helper
With the generic DMA device tree helper supported by mxs-dma driver, client devices only need to call dma_request_slave_channel() for requesting a DMA channel from dmaengine. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c51
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.h3
2 files changed, 2 insertions, 52 deletions
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 717881a3d1b8..25ecfa1822a8 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -36,7 +36,6 @@
36#define GPMI_NAND_GPMI_REGS_ADDR_RES_NAME "gpmi-nand" 36#define GPMI_NAND_GPMI_REGS_ADDR_RES_NAME "gpmi-nand"
37#define GPMI_NAND_BCH_REGS_ADDR_RES_NAME "bch" 37#define GPMI_NAND_BCH_REGS_ADDR_RES_NAME "bch"
38#define GPMI_NAND_BCH_INTERRUPT_RES_NAME "bch" 38#define GPMI_NAND_BCH_INTERRUPT_RES_NAME "bch"
39#define GPMI_NAND_DMA_INTERRUPT_RES_NAME "gpmi-dma"
40 39
41/* add our owner bbt descriptor */ 40/* add our owner bbt descriptor */
42static uint8_t scan_ff_pattern[] = { 0xff }; 41static uint8_t scan_ff_pattern[] = { 0xff };
@@ -420,28 +419,6 @@ static void release_bch_irq(struct gpmi_nand_data *this)
420 free_irq(i, this); 419 free_irq(i, this);
421} 420}
422 421
423static bool gpmi_dma_filter(struct dma_chan *chan, void *param)
424{
425 struct gpmi_nand_data *this = param;
426 int dma_channel = (int)this->private;
427
428 if (!mxs_dma_is_apbh(chan))
429 return false;
430 /*
431 * only catch the GPMI dma channels :
432 * for mx23 : MX23_DMA_GPMI0 ~ MX23_DMA_GPMI3
433 * (These four channels share the same IRQ!)
434 *
435 * for mx28 : MX28_DMA_GPMI0 ~ MX28_DMA_GPMI7
436 * (These eight channels share the same IRQ!)
437 */
438 if (dma_channel == chan->chan_id) {
439 chan->private = &this->dma_data;
440 return true;
441 }
442 return false;
443}
444
445static void release_dma_channels(struct gpmi_nand_data *this) 422static void release_dma_channels(struct gpmi_nand_data *this)
446{ 423{
447 unsigned int i; 424 unsigned int i;
@@ -455,36 +432,10 @@ static void release_dma_channels(struct gpmi_nand_data *this)
455static int acquire_dma_channels(struct gpmi_nand_data *this) 432static int acquire_dma_channels(struct gpmi_nand_data *this)
456{ 433{
457 struct platform_device *pdev = this->pdev; 434 struct platform_device *pdev = this->pdev;
458 struct resource *r_dma;
459 struct device_node *dn;
460 u32 dma_channel;
461 int ret;
462 struct dma_chan *dma_chan; 435 struct dma_chan *dma_chan;
463 dma_cap_mask_t mask;
464
465 /* dma channel, we only use the first one. */
466 dn = pdev->dev.of_node;
467 ret = of_property_read_u32(dn, "fsl,gpmi-dma-channel", &dma_channel);
468 if (ret) {
469 pr_err("unable to get DMA channel from dt.\n");
470 goto acquire_err;
471 }
472 this->private = (void *)dma_channel;
473
474 /* gpmi dma interrupt */
475 r_dma = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
476 GPMI_NAND_DMA_INTERRUPT_RES_NAME);
477 if (!r_dma) {
478 pr_err("Can't get resource for DMA\n");
479 goto acquire_err;
480 }
481 this->dma_data.chan_irq = r_dma->start;
482 436
483 /* request dma channel */ 437 /* request dma channel */
484 dma_cap_zero(mask); 438 dma_chan = dma_request_slave_channel(&pdev->dev, "rx-tx");
485 dma_cap_set(DMA_SLAVE, mask);
486
487 dma_chan = dma_request_channel(mask, gpmi_dma_filter, this);
488 if (!dma_chan) { 439 if (!dma_chan) {
489 pr_err("Failed to request DMA channel.\n"); 440 pr_err("Failed to request DMA channel.\n");
490 goto acquire_err; 441 goto acquire_err;
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
index 072947731277..a7685e3a8748 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
@@ -20,7 +20,7 @@
20#include <linux/mtd/nand.h> 20#include <linux/mtd/nand.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/dma-mapping.h> 22#include <linux/dma-mapping.h>
23#include <linux/fsl/mxs-dma.h> 23#include <linux/dmaengine.h>
24 24
25#define GPMI_CLK_MAX 5 /* MX6Q needs five clocks */ 25#define GPMI_CLK_MAX 5 /* MX6Q needs five clocks */
26struct resources { 26struct resources {
@@ -180,7 +180,6 @@ struct gpmi_nand_data {
180 /* DMA channels */ 180 /* DMA channels */
181#define DMA_CHANS 8 181#define DMA_CHANS 8
182 struct dma_chan *dma_chans[DMA_CHANS]; 182 struct dma_chan *dma_chans[DMA_CHANS];
183 struct mxs_dma_data dma_data;
184 enum dma_ops_type last_dma_type; 183 enum dma_ops_type last_dma_type;
185 enum dma_ops_type dma_type; 184 enum dma_ops_type dma_type;
186 struct completion dma_done; 185 struct completion dma_done;