base-files: define yes/no as valid boolean options
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0156-mtd-nand-pxa3xx-Use-extended-cmdfunc-only-if-needed.patch
1 From a701d8e1c4c1e31a208dae616ed9067ba4e90191 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Mon, 25 Nov 2013 11:02:51 -0300
4 Subject: [PATCH 156/203] mtd: nand: pxa3xx: Use extended cmdfunc() only if
5  needed
6
7 Currently, we have two different cmdfunc's implementations:
8 one for PXA3xx SoC variant and one for Armada 370/XP SoC variant.
9
10 The former is the legacy one, typically constrained to devices
11 with page sizes smaller or equal to the controller's FIFO buffer.
12 On the other side, the latter _only_ supports the so-called extended
13 command semantics, which allow to handle devices with larger
14 page sizes (4 KiB, 8 KiB, ...).
15
16 This means we currently don't support devices with smaller pages on the
17 A370/XP SoC. Fix it by first renaming the cmdfuncs variants, and then
18 make the choice based on device page size (and SoC variant), rather than
19 SoC variant alone.
20
21 While at it, add a check for page size, to make sure we don't allow larger
22 pages sizes on the PXA3xx variant.
23
24 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
25 ---
26  drivers/mtd/nand/pxa3xx_nand.c | 31 +++++++++++++++++++++----------
27  1 file changed, 21 insertions(+), 10 deletions(-)
28
29 --- a/drivers/mtd/nand/pxa3xx_nand.c
30 +++ b/drivers/mtd/nand/pxa3xx_nand.c
31 @@ -900,8 +900,8 @@ static int prepare_set_command(struct px
32         return exec_cmd;
33  }
34  
35 -static void pxa3xx_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
36 -                               int column, int page_addr)
37 +static void nand_cmdfunc(struct mtd_info *mtd, unsigned command,
38 +                        int column, int page_addr)
39  {
40         struct pxa3xx_nand_host *host = mtd->priv;
41         struct pxa3xx_nand_info *info = host->info_data;
42 @@ -948,9 +948,9 @@ static void pxa3xx_nand_cmdfunc(struct m
43         info->state = STATE_IDLE;
44  }
45  
46 -static void armada370_nand_cmdfunc(struct mtd_info *mtd,
47 -                                  const unsigned command,
48 -                                  int column, int page_addr)
49 +static void nand_cmdfunc_extended(struct mtd_info *mtd,
50 +                                 const unsigned command,
51 +                                 int column, int page_addr)
52  {
53         struct pxa3xx_nand_host *host = mtd->priv;
54         struct pxa3xx_nand_info *info = host->info_data;
55 @@ -1490,6 +1490,21 @@ KEEP_CONFIG:
56                 chip->bbt_md = &bbt_mirror_descr;
57         }
58  
59 +       /*
60 +        * If the page size is bigger than the FIFO size, let's check
61 +        * we are given the right variant and then switch to the extended
62 +        * (aka splitted) command handling,
63 +        */
64 +       if (mtd->writesize > PAGE_CHUNK_SIZE) {
65 +               if (info->variant == PXA3XX_NAND_VARIANT_ARMADA370) {
66 +                       chip->cmdfunc = nand_cmdfunc_extended;
67 +               } else {
68 +                       dev_err(&info->pdev->dev,
69 +                               "unsupported page size on this variant\n");
70 +                       return -ENODEV;
71 +               }
72 +       }
73 +
74         if (info->variant == PXA3XX_NAND_VARIANT_ARMADA370)
75                 ret = armada370_ecc_init(info, &chip->ecc,
76                                    chip->ecc_strength_ds,
77 @@ -1569,11 +1584,7 @@ static int alloc_nand_resource(struct pl
78                 chip->read_buf          = pxa3xx_nand_read_buf;
79                 chip->write_buf         = pxa3xx_nand_write_buf;
80                 chip->options           |= NAND_NO_SUBPAGE_WRITE;
81 -
82 -               if (info->variant == PXA3XX_NAND_VARIANT_ARMADA370)
83 -                       chip->cmdfunc = armada370_nand_cmdfunc;
84 -               else
85 -                       chip->cmdfunc = pxa3xx_nand_cmdfunc;
86 +               chip->cmdfunc           = nand_cmdfunc;
87         }
88  
89         spin_lock_init(&chip->controller->lock);