base-files: define yes/no as valid boolean options
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0123-mtd-nand-pxa3xx-Make-dma-code-dependent-on-dma-capab.patch
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
5  capable platforms
6
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.
11
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.
15
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.
19
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>
24 ---
25  drivers/mtd/nand/pxa3xx_nand.c | 34 ++++++++++++++++++++++++++++++++++
26  1 file changed, 34 insertions(+)
27
28 --- a/drivers/mtd/nand/pxa3xx_nand.c
29 +++ b/drivers/mtd/nand/pxa3xx_nand.c
30 @@ -25,7 +25,14 @@
31  #include <linux/of.h>
32  #include <linux/of_device.h>
33  
34 +#if defined(CONFIG_ARCH_PXA) || defined(CONFIG_ARCH_MMP)
35 +#define ARCH_HAS_DMA
36 +#endif
37 +
38 +#ifdef ARCH_HAS_DMA
39  #include <mach/dma.h>
40 +#endif
41 +
42  #include <linux/platform_data/mtd-nand-pxa3xx.h>
43  
44  #define        CHIP_DELAY_TIMEOUT      (2 * HZ/10)
45 @@ -381,6 +388,7 @@ static void handle_data_pio(struct pxa3x
46         }
47  }
48  
49 +#ifdef ARCH_HAS_DMA
50  static void start_data_dma(struct pxa3xx_nand_info *info)
51  {
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);
56  }
57 +#else
58 +static void start_data_dma(struct pxa3xx_nand_info *info)
59 +{}
60 +#endif
61  
62  static irqreturn_t pxa3xx_nand_irq(int irq, void *devid)
63  {
64 @@ -905,6 +917,7 @@ static int pxa3xx_nand_detect_config(str
65   */
66  #define MAX_BUFF_SIZE  PAGE_SIZE
67  
68 +#ifdef ARCH_HAS_DMA
69  static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info *info)
70  {
71         struct platform_device *pdev = info->pdev;
72 @@ -950,6 +963,20 @@ static void pxa3xx_nand_free_buff(struct
73                 kfree(info->data_buff);
74         }
75  }
76 +#else
77 +static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info *info)
78 +{
79 +       info->data_buff = kmalloc(MAX_BUFF_SIZE, GFP_KERNEL);
80 +       if (info->data_buff == NULL)
81 +               return -ENOMEM;
82 +       return 0;
83 +}
84 +
85 +static void pxa3xx_nand_free_buff(struct pxa3xx_nand_info *info)
86 +{
87 +       kfree(info->data_buff);
88 +}
89 +#endif
90  
91  static int pxa3xx_nand_sensing(struct pxa3xx_nand_info *info)
92  {
93 @@ -1265,6 +1292,13 @@ static int pxa3xx_nand_probe(struct plat
94         struct pxa3xx_nand_info *info;
95         int ret, cs, probe_success;
96  
97 +#ifndef ARCH_HAS_DMA
98 +       if (use_dma) {
99 +               use_dma = 0;
100 +               dev_warn(&pdev->dev,
101 +                        "This platform can't do DMA on this device\n");
102 +       }
103 +#endif
104         ret = pxa3xx_nand_probe_dt(pdev);
105         if (ret)
106                 return ret;