[mvebu]: preliminary support for the WRT1900AC (work in progress)
[openwrt/svn-archive/archive.git] / target / linux / mvebu / patches-3.14 / 012-pxa3xx_nand_use_ecc_info_from_dt.patch
1 From 5b3e507820c6e120bc2680c0d35f9d9d81fcb98d Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Wed, 14 May 2014 14:58:08 -0300
4 Subject: mtd: nand: pxa3xx: Use ECC strength and step size devicetree binding
5
6 This commit adds support for the user to specify the ECC strength
7 and step size through the devicetree. We keep the previous behavior,
8 when there is no DT parameter provided.
9
10 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
11 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
12
13 --- a/drivers/mtd/nand/pxa3xx_nand.c
14 +++ b/drivers/mtd/nand/pxa3xx_nand.c
15 @@ -1520,8 +1520,13 @@ KEEP_CONFIG:
16 }
17 }
18
19 - ecc_strength = chip->ecc_strength_ds;
20 - ecc_step = chip->ecc_step_ds;
21 + if (pdata->ecc_strength && pdata->ecc_step_size) {
22 + ecc_strength = pdata->ecc_strength;
23 + ecc_step = pdata->ecc_step_size;
24 + } else {
25 + ecc_strength = chip->ecc_strength_ds;
26 + ecc_step = chip->ecc_step_ds;
27 + }
28
29 /* Set default ECC strength requirements on non-ONFI devices */
30 if (ecc_strength < 1 && ecc_step < 1) {
31 @@ -1730,6 +1735,14 @@ static int pxa3xx_nand_probe_dt(struct p
32 of_property_read_u32(np, "num-cs", &pdata->num_cs);
33 pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
34
35 + pdata->ecc_strength = of_get_nand_ecc_strength(np);
36 + if (pdata->ecc_strength < 0)
37 + pdata->ecc_strength = 0;
38 +
39 + pdata->ecc_step_size = of_get_nand_ecc_step_size(np);
40 + if (pdata->ecc_step_size < 0)
41 + pdata->ecc_step_size = 0;
42 +
43 pdev->dev.platform_data = pdata;
44
45 return 0;
46 --- a/include/linux/platform_data/mtd-nand-pxa3xx.h
47 +++ b/include/linux/platform_data/mtd-nand-pxa3xx.h
48 @@ -58,6 +58,9 @@ struct pxa3xx_nand_platform_data {
49 /* use an flash-based bad block table */
50 bool flash_bbt;
51
52 + /* requested ECC strength and ECC step size */
53 + int ecc_strength, ecc_step_size;
54 +
55 const struct mtd_partition *parts[NUM_CHIP_SELECT];
56 unsigned int nr_parts[NUM_CHIP_SELECT];
57