mvebu: backport mainline patches from kernel 3.12
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0116-mtd-nand-pxa3xx-Allow-to-set-clear-the-spare-enable-.patch
1 From be5f1d59341e48dbe0730253417c52bf79c6c3a7 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Mon, 12 Aug 2013 14:14:49 -0300
4 Subject: [PATCH 116/203] mtd: nand: pxa3xx: Allow to set/clear the 'spare
5  enable' field
6
7 Some commands (such as the ONFI parameter page read) need to
8 clear the 'spare enable' bit. This commit allows to set/clear
9 depending on the prepared command, instead of having it always
10 set.
11
12 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
13 Tested-by: Daniel Mack <zonque@gmail.com>
14 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
15 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
16 ---
17  drivers/mtd/nand/pxa3xx_nand.c | 7 +++++++
18  1 file changed, 7 insertions(+)
19
20 --- a/drivers/mtd/nand/pxa3xx_nand.c
21 +++ b/drivers/mtd/nand/pxa3xx_nand.c
22 @@ -185,6 +185,7 @@ struct pxa3xx_nand_info {
23         int                     cs;
24         int                     use_ecc;        /* use HW ECC ? */
25         int                     use_dma;        /* use DMA ? */
26 +       int                     use_spare;      /* use spare ? */
27         int                     is_ready;
28  
29         unsigned int            page_size;      /* page size of attached chip */
30 @@ -325,6 +326,11 @@ static void pxa3xx_nand_start(struct pxa
31         else
32                 ndcr &= ~NDCR_DMA_EN;
33  
34 +       if (info->use_spare)
35 +               ndcr |= NDCR_SPARE_EN;
36 +       else
37 +               ndcr &= ~NDCR_SPARE_EN;
38 +
39         ndcr |= NDCR_ND_RUN;
40  
41         /* clear status bits and run */
42 @@ -526,6 +532,7 @@ static int prepare_command_pool(struct p
43         info->buf_count         = 0;
44         info->oob_size          = 0;
45         info->use_ecc           = 0;
46 +       info->use_spare         = 1;
47         info->use_dma           = (use_dma) ? 1 : 0;
48         info->is_ready          = 0;
49         info->retcode           = ERR_NONE;