1 From 085ced2b9e159dbeae029e338958b8c8ae9073b9 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Mon, 12 Aug 2013 14:14:56 -0300
4 Subject: [PATCH 123/203] mtd: nand: pxa3xx: Make dma code dependent on dma
7 This patch adds a macro ARCH_HAS_DMA to compile-out arch specific
8 dma code, namely pxa_request_dma() and pxa_free_dma(). These symbols
9 are available only in pxa, which makes impossible to build the driver in
10 other platforms than ARCH_PXA.
12 In order to handle non-dma capable platforms, we implement a fallbacks that
13 allocate buffers as if 'use_dma=false', putting the dma related code
14 under the ARCH_HAS_DMA conditional.
16 Please note that the correct way to handle this is to migrate the
17 dma code to use of the mmp_pdma dmaengine driver. However, currently
18 this is not possible because the two dmaengine drivers can't work together.
20 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
21 Tested-by: Daniel Mack <zonque@gmail.com>
22 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
23 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
25 drivers/mtd/nand/pxa3xx_nand.c | 34 ++++++++++++++++++++++++++++++++++
26 1 file changed, 34 insertions(+)
28 --- a/drivers/mtd/nand/pxa3xx_nand.c
29 +++ b/drivers/mtd/nand/pxa3xx_nand.c
32 #include <linux/of_device.h>
34 +#if defined(CONFIG_ARCH_PXA) || defined(CONFIG_ARCH_MMP)
42 #include <linux/platform_data/mtd-nand-pxa3xx.h>
44 #define CHIP_DELAY_TIMEOUT (2 * HZ/10)
45 @@ -381,6 +388,7 @@ static void handle_data_pio(struct pxa3x
50 static void start_data_dma(struct pxa3xx_nand_info *info)
52 struct pxa_dma_desc *desc = info->data_desc;
53 @@ -427,6 +435,10 @@ static void pxa3xx_nand_data_dma_irq(int
54 enable_int(info, NDCR_INT_MASK);
55 nand_writel(info, NDSR, NDSR_WRDREQ | NDSR_RDDREQ);
58 +static void start_data_dma(struct pxa3xx_nand_info *info)
62 static irqreturn_t pxa3xx_nand_irq(int irq, void *devid)
64 @@ -905,6 +917,7 @@ static int pxa3xx_nand_detect_config(str
66 #define MAX_BUFF_SIZE PAGE_SIZE
69 static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info *info)
71 struct platform_device *pdev = info->pdev;
72 @@ -950,6 +963,20 @@ static void pxa3xx_nand_free_buff(struct
73 kfree(info->data_buff);
77 +static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info *info)
79 + info->data_buff = kmalloc(MAX_BUFF_SIZE, GFP_KERNEL);
80 + if (info->data_buff == NULL)
85 +static void pxa3xx_nand_free_buff(struct pxa3xx_nand_info *info)
87 + kfree(info->data_buff);
91 static int pxa3xx_nand_sensing(struct pxa3xx_nand_info *info)
93 @@ -1265,6 +1292,13 @@ static int pxa3xx_nand_probe(struct plat
94 struct pxa3xx_nand_info *info;
95 int ret, cs, probe_success;
100 + dev_warn(&pdev->dev,
101 + "This platform can't do DMA on this device\n");
104 ret = pxa3xx_nand_probe_dt(pdev);