Skip to content

Commit de20c22

Browse files
stiggeDavid Woodhouse
authored andcommitted
mtd: lpc32xx_slc: Make driver independent of AMBA DMA engine driver
This patch makes the SLC NAND driver independent of the single AMBA DMA engine driver by using the platform data provided dma_filter callback. Signed-off-by: Roland Stigge <stigge@antcom.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent af69dcd commit de20c22

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎drivers/mtd/nand/lpc32xx_slc.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include <linux/of.h>
3838
#include <linux/of_mtd.h>
3939
#include <linux/of_gpio.h>
40-
#include <linux/amba/pl08x.h>
40+
#include <linux/mtd/lpc32xx_slc.h>
4141

4242
#define LPC32XX_MODNAME "lpc32xx-nand"
4343

@@ -199,6 +199,7 @@ struct lpc32xx_nand_cfg_slc {
199199

200200
struct lpc32xx_nand_host {
201201
struct nand_chip nand_chip;
202+
struct lpc32xx_slc_platform_data *pdata;
202203
struct clk *clk;
203204
struct mtd_info mtd;
204205
void __iomem *io_base;
@@ -719,9 +720,15 @@ static int lpc32xx_nand_dma_setup(struct lpc32xx_nand_host *host)
719720
struct mtd_info *mtd = &host->mtd;
720721
dma_cap_mask_t mask;
721722

723+
if (!host->pdata || !host->pdata->dma_filter) {
724+
dev_err(mtd->dev.parent, "no DMA platform data\n");
725+
return -ENOENT;
726+
}
727+
722728
dma_cap_zero(mask);
723729
dma_cap_set(DMA_SLAVE, mask);
724-
host->dma_chan = dma_request_channel(mask, pl08x_filter_id, "nand-slc");
730+
host->dma_chan = dma_request_channel(mask, host->pdata->dma_filter,
731+
"nand-slc");
725732
if (!host->dma_chan) {
726733
dev_err(mtd->dev.parent, "Failed to request DMA channel\n");
727734
return -EBUSY;
@@ -819,6 +826,8 @@ static int __devinit lpc32xx_nand_probe(struct platform_device *pdev)
819826
}
820827
lpc32xx_wp_disable(host);
821828

829+
host->pdata = pdev->dev.platform_data;
830+
822831
mtd = &host->mtd;
823832
chip = &host->nand_chip;
824833
chip->priv = host;

‎include/linux/mtd/lpc32xx_slc.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Platform data for LPC32xx SoC SLC NAND controller
3+
*
4+
* Copyright © 2012 Roland Stigge
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License version 2 as
8+
* published by the Free Software Foundation.
9+
*/
10+
11+
#ifndef __LINUX_MTD_LPC32XX_SLC_H
12+
#define __LINUX_MTD_LPC32XX_SLC_H
13+
14+
#include <linux/dmaengine.h>
15+
16+
struct lpc32xx_slc_platform_data {
17+
bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
18+
};
19+
20+
#endif /* __LINUX_MTD_LPC32XX_SLC_H */

0 commit comments

Comments
 (0)