base-files: define yes/no as valid boolean options
[openwrt/staging/mkresin.git] / target / linux / mvebu / patches-3.10 / 0154-mtd-nand-pxa3xx-make-ECC-configuration-checks-more-e.patch
1 From c312e183e96bed3b727888673d4b6b54b8e6283e Mon Sep 17 00:00:00 2001
2 From: Brian Norris <computersforpeace@gmail.com>
3 Date: Thu, 14 Nov 2013 14:41:32 -0800
4 Subject: [PATCH 154/203] mtd: nand: pxa3xx: make ECC configuration checks more
5 explicit
6
7 The Armada BCH configuration in this driver uses one of the two
8 following ECC schemes:
9
10 16-bit correction per 2048 bytes
11 16-bit correction per 1024 bytes
12
13 These are sufficient for mapping to the 4-bit per 512-bytes and 8-bit
14 per 512-bytes (respectively) minimum correctability requirements of many
15 common NAND.
16
17 The current code only checks for the required strength (4-bit or 8-bit)
18 without checking the ECC step size that is associated with that strength
19 (and simply assumes it is 512). While that is often a safe assumption to
20 make, let's make it explicit, since we have that information.
21
22 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
23 Acked-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
24 Tested-by: Daniel Mack <zonque@gmail.com>
25 ---
26 drivers/mtd/nand/pxa3xx_nand.c | 15 ++++++++++++---
27 1 file changed, 12 insertions(+), 3 deletions(-)
28
29 --- a/drivers/mtd/nand/pxa3xx_nand.c
30 +++ b/drivers/mtd/nand/pxa3xx_nand.c
31 @@ -1364,9 +1364,13 @@ static int pxa_ecc_init(struct pxa3xx_na
32
33 static int armada370_ecc_init(struct pxa3xx_nand_info *info,
34 struct nand_ecc_ctrl *ecc,
35 - int strength, int page_size)
36 + int strength, int ecc_stepsize, int page_size)
37 {
38 - if (strength == 4 && page_size == 4096) {
39 + /*
40 + * Required ECC: 4-bit correction per 512 bytes
41 + * Select: 16-bit correction per 2048 bytes
42 + */
43 + if (strength == 4 && ecc_stepsize == 512 && page_size == 4096) {
44 info->ecc_bch = 1;
45 info->chunk_size = 2048;
46 info->spare_size = 32;
47 @@ -1377,7 +1381,11 @@ static int armada370_ecc_init(struct pxa
48 ecc->strength = 16;
49 return 1;
50
51 - } else if (strength == 8 && page_size == 4096) {
52 + /*
53 + * Required ECC: 8-bit correction per 512 bytes
54 + * Select: 16-bit correction per 1024 bytes
55 + */
56 + } else if (strength == 8 && ecc_stepsize == 512 && page_size == 4096) {
57 info->ecc_bch = 1;
58 info->chunk_size = 1024;
59 info->spare_size = 0;
60 @@ -1485,6 +1493,7 @@ KEEP_CONFIG:
61 if (info->variant == PXA3XX_NAND_VARIANT_ARMADA370)
62 ret = armada370_ecc_init(info, &chip->ecc,
63 chip->ecc_strength_ds,
64 + chip->ecc_step_ds,
65 mtd->writesize);
66 else
67 ret = pxa_ecc_init(info, &chip->ecc,