Skip to content

Commit 8bc4d5f

Browse files
committed
Merge tag 'for-linus-20160523' of git://git.infradead.org/linux-mtd
Pull MTD updates from Brian Norris: "First cycle with Boris as NAND maintainer! Many (most) bullets stolen from him. Generic: - Migrated NAND LED trigger to be a generic MTD trigger NAND: - Introduction of the "ECC algorithm" concept, to avoid overloading the ECC mode field too much more - Replaced the nand_ecclayout infrastructure with something a little more flexible (finally!) and future proof - Rework of the OMAP GPMC and NAND drivers; the TI folks pulled some of this into their own tree as well - Prepare the sunxi NAND driver to receive DMA support - Handle bitflips in erased pages on GPMI revisions that do not support this in hardware. SPI NOR: - Start using the spi_flash_read() API for SPI drivers that support it (i.e., SPI drivers with special memory-mapped flash modes) And other small scattered improvments" * tag 'for-linus-20160523' of git://git.infradead.org/linux-mtd: (155 commits) mtd: spi-nor: support GigaDevice gd25lq64c mtd: nand_bch: fix spelling of "probably" mtd: brcmnand: respect ECC algorithm set by NAND subsystem gpmi-nand: Handle ECC Errors in erased pages Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value mtd: nand: add support for "nand-ecc-algo" DT property mtd: mtd: drop NAND_ECC_SOFT_BCH enum value mtd: drop support for NAND_ECC_SOFT_BCH as "soft_bch" mapping mtd: nand: read ECC algorithm from the new field mtd: nand: fsmc: validate ECC setup by checking algorithm directly mtd: nand: set ECC algorithm to Hamming on fallback staging: mt29f_spinand: set ECC algorithm explicitly CRIS v32: nand: set ECC algorithm explicitly mtd: nand: atmel: set ECC algorithm explicitly mtd: nand: davinci: set ECC algorithm explicitly mtd: nand: bf5xx: set ECC algorithm explicitly mtd: nand: omap2: Fix high memory dma prefetch transfer mtd: nand: omap2: Start dma request before enabling prefetch mtd: nandsim: add __init attribute mtd: nand: move of_get_nand_xxx() helpers into nand_base.c ...
2 parents 2956729 + e5366a2 commit 8bc4d5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+4338
-2908
lines changed

Documentation/devicetree/bindings/bus/ti-gpmc.txt renamed to Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ Required properties:
3232
bootloader) are used for the physical address decoding.
3333
As this will change in the future, filling correct
3434
values here is a requirement.
35+
- interrupt-controller: The GPMC driver implements and interrupt controller for
36+
the NAND events "fifoevent" and "termcount" plus the
37+
rising/falling edges on the GPMC_WAIT pins.
38+
The interrupt number mapping is as follows
39+
0 - NAND_fifoevent
40+
1 - NAND_termcount
41+
2 - GPMC_WAIT0 pin edge
42+
3 - GPMC_WAIT1 pin edge, and so on.
43+
- interrupt-cells: Must be set to 2
44+
- gpio-controller: The GPMC driver implements a GPIO controller for the
45+
GPMC WAIT pins that can be used as general purpose inputs.
46+
0 maps to GPMC_WAIT0 pin.
47+
- gpio-cells: Must be set to 2
3548

3649
Timing properties for child nodes. All are optional and default to 0.
3750

@@ -130,6 +143,10 @@ Example for an AM33xx board:
130143
#address-cells = <2>;
131144
#size-cells = <1>;
132145
ranges = <0 0 0x08000000 0x10000000>; /* CS0 @addr 0x8000000, size 0x10000000 */
146+
interrupt-controller;
147+
#interrupt-cells = <2>;
148+
gpio-controller;
149+
#gpio-cells = <2>;
133150

134151
/* child nodes go here */
135152
};

Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Required properties:
2424
brcm,brcmnand-v5.0
2525
brcm,brcmnand-v6.0
2626
brcm,brcmnand-v6.1
27+
brcm,brcmnand-v6.2
2728
brcm,brcmnand-v7.0
2829
brcm,brcmnand-v7.1
2930
brcm,brcmnand

Documentation/devicetree/bindings/mtd/gpmc-nand.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ Documentation/devicetree/bindings/mtd/nand.txt
1313

1414
Required properties:
1515

16-
- reg: The CS line the peripheral is connected to
16+
- compatible: "ti,omap2-nand"
17+
- reg: range id (CS number), base offset and length of the
18+
NAND I/O space
19+
- interrupt-parent: must point to gpmc node
20+
- interrupts: Two interrupt specifiers, one for fifoevent, one for termcount.
1721

1822
Optional properties:
1923

@@ -44,6 +48,7 @@ Optional properties:
4448
locating ECC errors for BCHx algorithms. SoC devices which have
4549
ELM hardware engines should specify this device node in .dtsi
4650
Using ELM for ECC error correction frees some CPU cycles.
51+
- rb-gpios: GPIO specifier for the ready/busy# pin.
4752

4853
For inline partition table parsing (optional):
4954

@@ -55,20 +60,26 @@ Example for an AM33xx board:
5560
gpmc: gpmc@50000000 {
5661
compatible = "ti,am3352-gpmc";
5762
ti,hwmods = "gpmc";
58-
reg = <0x50000000 0x1000000>;
63+
reg = <0x50000000 0x36c>;
5964
interrupts = <100>;
6065
gpmc,num-cs = <8>;
6166
gpmc,num-waitpins = <2>;
6267
#address-cells = <2>;
6368
#size-cells = <1>;
64-
ranges = <0 0 0x08000000 0x2000>; /* CS0: NAND */
69+
ranges = <0 0 0x08000000 0x1000000>; /* CS0 space, 16MB */
6570
elm_id = <&elm>;
71+
interrupt-controller;
72+
#interrupt-cells = <2>;
6673

6774
nand@0,0 {
68-
reg = <0 0 0>; /* CS0, offset 0 */
75+
compatible = "ti,omap2-nand";
76+
reg = <0 0 4>; /* CS0, offset 0, NAND I/O window 4 */
77+
interrupt-parent = <&gpmc>;
78+
interrupts = <0 IRQ_TYPE_NONE>, <1 IRQ_TYPE NONE>;
6979
nand-bus-width = <16>;
7080
ti,nand-ecc-opt = "bch8";
7181
ti,nand-xfer-type = "polled";
82+
rb-gpios = <&gpmc 0 GPIO_ACTIVE_HIGH>; /* gpmc_wait0 */
7283

7384
gpmc,sync-clk-ps = <0>;
7485
gpmc,cs-on-ns = <0>;

Documentation/devicetree/bindings/mtd/nand.txt

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1-
* MTD generic binding
1+
* NAND chip and NAND controller generic binding
2+
3+
NAND controller/NAND chip representation:
4+
5+
The NAND controller should be represented with its own DT node, and all
6+
NAND chips attached to this controller should be defined as children nodes
7+
of the NAND controller. This representation should be enforced even for
8+
simple controllers supporting only one chip.
9+
10+
Mandatory NAND controller properties:
11+
- #address-cells: depends on your controller. Should at least be 1 to
12+
encode the CS line id.
13+
- #size-cells: depends on your controller. Put zero unless you need a
14+
mapping between CS lines and dedicated memory regions
15+
16+
Optional NAND controller properties
17+
- ranges: only needed if you need to define a mapping between CS lines and
18+
memory regions
19+
20+
Optional NAND chip properties:
221

322
- nand-ecc-mode : String, operation mode of the NAND ecc mode.
4-
Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
5-
"soft_bch".
23+
Supported values are: "none", "soft", "hw", "hw_syndrome",
24+
"hw_oob_first".
25+
Deprecated values:
26+
"soft_bch": use "soft" and nand-ecc-algo instead
27+
- nand-ecc-algo: string, algorithm of NAND ECC.
28+
Supported values are: "hamming", "bch".
629
- nand-bus-width : 8 or 16 bus width if not present 8
730
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
831

@@ -19,3 +42,19 @@ errors per {size} bytes".
1942
The interpretation of these parameters is implementation-defined, so not all
2043
implementations must support all possible combinations. However, implementations
2144
are encouraged to further specify the value(s) they support.
45+
46+
Example:
47+
48+
nand-controller {
49+
#address-cells = <1>;
50+
#size-cells = <0>;
51+
52+
/* controller specific properties */
53+
54+
nand@0 {
55+
reg = <0>;
56+
nand-ecc-mode = "soft_bch";
57+
58+
/* controller specific properties */
59+
};
60+
};

arch/arm/mach-omap2/gpmc-nand.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ int gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data,
9797
gpmc_nand_res[2].start = gpmc_get_client_irq(GPMC_IRQ_COUNT_EVENT);
9898

9999
memset(&s, 0, sizeof(struct gpmc_settings));
100-
if (gpmc_nand_data->of_node)
101-
gpmc_read_settings_dt(gpmc_nand_data->of_node, &s);
102-
else
103-
gpmc_set_legacy(gpmc_nand_data, &s);
100+
gpmc_set_legacy(gpmc_nand_data, &s);
104101

105102
s.device_nand = true;
106103

@@ -121,8 +118,6 @@ int gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data,
121118
if (err < 0)
122119
goto out_free_cs;
123120

124-
gpmc_update_nand_reg(&gpmc_nand_data->reg, gpmc_nand_data->cs);
125-
126121
if (!gpmc_hwecc_bch_capable(gpmc_nand_data->ecc_opt)) {
127122
pr_err("omap2-nand: Unsupported NAND ECC scheme selected\n");
128123
err = -EINVAL;

arch/arm/mach-pxa/spitz.c

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -763,14 +763,49 @@ static struct nand_bbt_descr spitz_nand_bbt = {
763763
.pattern = scan_ff_pattern
764764
};
765765

766-
static struct nand_ecclayout akita_oobinfo = {
767-
.oobfree = { {0x08, 0x09} },
768-
.eccbytes = 24,
769-
.eccpos = {
770-
0x05, 0x01, 0x02, 0x03, 0x06, 0x07, 0x15, 0x11,
771-
0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
772-
0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37,
773-
},
766+
static int akita_ooblayout_ecc(struct mtd_info *mtd, int section,
767+
struct mtd_oob_region *oobregion)
768+
{
769+
if (section > 12)
770+
return -ERANGE;
771+
772+
switch (section % 3) {
773+
case 0:
774+
oobregion->offset = 5;
775+
oobregion->length = 1;
776+
break;
777+
778+
case 1:
779+
oobregion->offset = 1;
780+
oobregion->length = 3;
781+
break;
782+
783+
case 2:
784+
oobregion->offset = 6;
785+
oobregion->length = 2;
786+
break;
787+
}
788+
789+
oobregion->offset += (section / 3) * 0x10;
790+
791+
return 0;
792+
}
793+
794+
static int akita_ooblayout_free(struct mtd_info *mtd, int section,
795+
struct mtd_oob_region *oobregion)
796+
{
797+
if (section)
798+
return -ERANGE;
799+
800+
oobregion->offset = 8;
801+
oobregion->length = 9;
802+
803+
return 0;
804+
}
805+
806+
static const struct mtd_ooblayout_ops akita_ooblayout_ops = {
807+
.ecc = akita_ooblayout_ecc,
808+
.free = akita_ooblayout_free,
774809
};
775810

776811
static struct sharpsl_nand_platform_data spitz_nand_pdata = {
@@ -804,11 +839,11 @@ static void __init spitz_nand_init(void)
804839
} else if (machine_is_akita()) {
805840
spitz_nand_partitions[1].size = 58 * 1024 * 1024;
806841
spitz_nand_bbt.len = 1;
807-
spitz_nand_pdata.ecc_layout = &akita_oobinfo;
842+
spitz_nand_pdata.ecc_layout = &akita_ooblayout_ops;
808843
} else if (machine_is_borzoi()) {
809844
spitz_nand_partitions[1].size = 32 * 1024 * 1024;
810845
spitz_nand_bbt.len = 1;
811-
spitz_nand_pdata.ecc_layout = &akita_oobinfo;
846+
spitz_nand_pdata.ecc_layout = &akita_ooblayout_ops;
812847
}
813848

814849
platform_device_register(&spitz_nand_device);

arch/cris/arch-v32/drivers/mach-a3/nandflash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
157157
/* 20 us command delay time */
158158
this->chip_delay = 20;
159159
this->ecc.mode = NAND_ECC_SOFT;
160+
this->ecc.algo = NAND_ECC_HAMMING;
160161

161162
/* Enable the following for a flash based bad block table */
162163
/* this->bbt_options = NAND_BBT_USE_FLASH; */

arch/cris/arch-v32/drivers/mach-fs/nandflash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
148148
/* 20 us command delay time */
149149
this->chip_delay = 20;
150150
this->ecc.mode = NAND_ECC_SOFT;
151+
this->ecc.algo = NAND_ECC_HAMMING;
151152

152153
/* Enable the following for a flash based bad block table */
153154
/* this->bbt_options = NAND_BBT_USE_FLASH; */

arch/mips/include/asm/mach-jz4740/jz4740_nand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct jz_nand_platform_data {
2727

2828
unsigned char banks[JZ_NAND_NUM_BANKS];
2929

30-
void (*ident_callback)(struct platform_device *, struct nand_chip *,
30+
void (*ident_callback)(struct platform_device *, struct mtd_info *,
3131
struct mtd_partition **, int *num_partitions);
3232
};
3333

arch/mips/jz4740/board-qi_lb60.c

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,6 @@
4848
#define QI_LB60_GPIO_KEYIN8 JZ_GPIO_PORTD(26)
4949

5050
/* NAND */
51-
static struct nand_ecclayout qi_lb60_ecclayout_1gb = {
52-
.eccbytes = 36,
53-
.eccpos = {
54-
6, 7, 8, 9, 10, 11, 12, 13,
55-
14, 15, 16, 17, 18, 19, 20, 21,
56-
22, 23, 24, 25, 26, 27, 28, 29,
57-
30, 31, 32, 33, 34, 35, 36, 37,
58-
38, 39, 40, 41
59-
},
60-
.oobfree = {
61-
{ .offset = 2, .length = 4 },
62-
{ .offset = 42, .length = 22 }
63-
},
64-
};
6551

6652
/* Early prototypes of the QI LB60 had only 1GB of NAND.
6753
* In order to support these devices as well the partition and ecc layout is
@@ -84,25 +70,6 @@ static struct mtd_partition qi_lb60_partitions_1gb[] = {
8470
},
8571
};
8672

87-
static struct nand_ecclayout qi_lb60_ecclayout_2gb = {
88-
.eccbytes = 72,
89-
.eccpos = {
90-
12, 13, 14, 15, 16, 17, 18, 19,
91-
20, 21, 22, 23, 24, 25, 26, 27,
92-
28, 29, 30, 31, 32, 33, 34, 35,
93-
36, 37, 38, 39, 40, 41, 42, 43,
94-
44, 45, 46, 47, 48, 49, 50, 51,
95-
52, 53, 54, 55, 56, 57, 58, 59,
96-
60, 61, 62, 63, 64, 65, 66, 67,
97-
68, 69, 70, 71, 72, 73, 74, 75,
98-
76, 77, 78, 79, 80, 81, 82, 83
99-
},
100-
.oobfree = {
101-
{ .offset = 2, .length = 10 },
102-
{ .offset = 84, .length = 44 },
103-
},
104-
};
105-
10673
static struct mtd_partition qi_lb60_partitions_2gb[] = {
10774
{
10875
.name = "NAND BOOT partition",
@@ -121,19 +88,67 @@ static struct mtd_partition qi_lb60_partitions_2gb[] = {
12188
},
12289
};
12390

91+
static int qi_lb60_ooblayout_ecc(struct mtd_info *mtd, int section,
92+
struct mtd_oob_region *oobregion)
93+
{
94+
if (section)
95+
return -ERANGE;
96+
97+
oobregion->length = 36;
98+
oobregion->offset = 6;
99+
100+
if (mtd->oobsize == 128) {
101+
oobregion->length *= 2;
102+
oobregion->offset *= 2;
103+
}
104+
105+
return 0;
106+
}
107+
108+
static int qi_lb60_ooblayout_free(struct mtd_info *mtd, int section,
109+
struct mtd_oob_region *oobregion)
110+
{
111+
int eccbytes = 36, eccoff = 6;
112+
113+
if (section > 1)
114+
return -ERANGE;
115+
116+
if (mtd->oobsize == 128) {
117+
eccbytes *= 2;
118+
eccoff *= 2;
119+
}
120+
121+
if (!section) {
122+
oobregion->offset = 2;
123+
oobregion->length = eccoff - 2;
124+
} else {
125+
oobregion->offset = eccoff + eccbytes;
126+
oobregion->length = mtd->oobsize - oobregion->offset;
127+
}
128+
129+
return 0;
130+
}
131+
132+
static const struct mtd_ooblayout_ops qi_lb60_ooblayout_ops = {
133+
.ecc = qi_lb60_ooblayout_ecc,
134+
.free = qi_lb60_ooblayout_free,
135+
};
136+
124137
static void qi_lb60_nand_ident(struct platform_device *pdev,
125-
struct nand_chip *chip, struct mtd_partition **partitions,
138+
struct mtd_info *mtd, struct mtd_partition **partitions,
126139
int *num_partitions)
127140
{
141+
struct nand_chip *chip = mtd_to_nand(mtd);
142+
128143
if (chip->page_shift == 12) {
129-
chip->ecc.layout = &qi_lb60_ecclayout_2gb;
130144
*partitions = qi_lb60_partitions_2gb;
131145
*num_partitions = ARRAY_SIZE(qi_lb60_partitions_2gb);
132146
} else {
133-
chip->ecc.layout = &qi_lb60_ecclayout_1gb;
134147
*partitions = qi_lb60_partitions_1gb;
135148
*num_partitions = ARRAY_SIZE(qi_lb60_partitions_1gb);
136149
}
150+
151+
mtd_set_ooblayout(mtd, &qi_lb60_ooblayout_ops);
137152
}
138153

139154
static struct jz_nand_platform_data qi_lb60_nand_pdata = {

drivers/bcma/driver_chipcommon_sflash.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ int bcma_sflash_init(struct bcma_drv_cc *cc)
146146
return -ENOTSUPP;
147147
}
148148

149-
sflash->window = BCMA_SOC_FLASH2;
150149
sflash->blocksize = e->blocksize;
151150
sflash->numblocks = e->numblocks;
152151
sflash->size = sflash->blocksize * sflash->numblocks;

drivers/memory/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ config TI_EMIF
5151

5252
config OMAP_GPMC
5353
bool
54+
select GPIOLIB
5455
help
5556
This driver is for the General Purpose Memory Controller (GPMC)
5657
present on Texas Instruments SoCs (e.g. OMAP2+). GPMC allows

0 commit comments

Comments
 (0)