Skip to content

Commit e413a19

Browse files
committed
Merge tag 'for-linus-20140610' of git://git.infradead.org/linux-mtd
Pull MTD updates from Brian Norris: - refactor m25p80.c driver for use as a general SPI NOR framework for other drivers which may speak to SPI NOR flash without providing full SPI support (i.e., not part of drivers/spi/) - new Freescale QuadSPI driver (utilizing new SPI NOR framework) - updates for the STMicro "FSM" SPI NOR driver - fix sync/flush behavior on mtd_blkdevs - fixup subpage write support on a few NAND drivers - correct the MTD OOB test for odd-sized OOB areas - add BCH-16 support for OMAP NAND - fix warnings and trivial refactoring - utilize new ECC DT bindings in pxa3xx NAND driver - new LPDDR NVM driver - address a few assorted bugs caught by Coverity - add new imx6sx support for GPMI NAND - use a bounce buffer for NAND when non-DMA-able buffers are used * tag 'for-linus-20140610' of git://git.infradead.org/linux-mtd: (77 commits) mtd: gpmi: add gpmi support for imx6sx mtd: maps: remove check for CONFIG_MTD_SUPERH_RESERVE mtd: bf5xx_nand: use the managed version of kzalloc mtd: pxa3xx_nand: make the driver work on big-endian systems mtd: nand: omap: fix omap_calculate_ecc_bch() for-loop error mtd: nand: r852: correct write_buf loop bounds mtd: nand_bbt: handle error case for nand_create_badblock_pattern() mtd: nand_bbt: remove unused variable mtd: maps: sc520cdp: fix warnings mtd: slram: fix unused variable warning mtd: pfow: remove unused variable mtd: lpddr: fix Kconfig dependency, for I/O accessors mtd: nand: pxa3xx: Add supported ECC strength and step size to the DT binding mtd: nand: pxa3xx: Use ECC strength and step size devicetree binding mtd: nand: pxa3xx: Clean pxa_ecc_init() error handling mtd: nand: Warn the user if the selected ECC strength is too weak mtd: nand: omap: Documentation: How to select correct ECC scheme for your device ? mtd: nand: omap: add support for BCH16_ECC - NAND driver updates mtd: nand: omap: add support for BCH16_ECC - ELM driver updates mtd: nand: omap: add support for BCH16_ECC - GPMC driver updates ...
2 parents 8d0304e + f1900c7 commit e413a19

54 files changed

Lines changed: 3759 additions & 1618 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
* Freescale Quad Serial Peripheral Interface(QuadSPI)
2+
3+
Required properties:
4+
- compatible : Should be "fsl,vf610-qspi"
5+
- reg : the first contains the register location and length,
6+
the second contains the memory mapping address and length
7+
- reg-names: Should contain the reg names "QuadSPI" and "QuadSPI-memory"
8+
- interrupts : Should contain the interrupt for the device
9+
- clocks : The clocks needed by the QuadSPI controller
10+
- clock-names : the name of the clocks
11+
12+
Optional properties:
13+
- fsl,qspi-has-second-chip: The controller has two buses, bus A and bus B.
14+
Each bus can be connected with two NOR flashes.
15+
Most of the time, each bus only has one NOR flash
16+
connected, this is the default case.
17+
But if there are two NOR flashes connected to the
18+
bus, you should enable this property.
19+
(Please check the board's schematic.)
20+
21+
Example:
22+
23+
qspi0: quadspi@40044000 {
24+
compatible = "fsl,vf610-qspi";
25+
reg = <0x40044000 0x1000>, <0x20000000 0x10000000>;
26+
reg-names = "QuadSPI", "QuadSPI-memory";
27+
interrupts = <0 24 IRQ_TYPE_LEVEL_HIGH>;
28+
clocks = <&clks VF610_CLK_QSPI0_EN>,
29+
<&clks VF610_CLK_QSPI0>;
30+
clock-names = "qspi_en", "qspi";
31+
32+
flash0: s25fl128s@0 {
33+
....
34+
};
35+
};

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Optional properties:
2828
"ham1" 1-bit Hamming ecc code
2929
"bch4" 4-bit BCH ecc code
3030
"bch8" 8-bit BCH ecc code
31+
"bch16" 16-bit BCH ECC code
32+
Refer below "How to select correct ECC scheme for your device ?"
3133

3234
- ti,nand-xfer-type: A string setting the data transfer type. One of:
3335

@@ -90,3 +92,46 @@ Example for an AM33xx board:
9092
};
9193
};
9294

95+
How to select correct ECC scheme for your device ?
96+
--------------------------------------------------
97+
Higher ECC scheme usually means better protection against bit-flips and
98+
increased system lifetime. However, selection of ECC scheme is dependent
99+
on various other factors also like;
100+
101+
(1) support of built in hardware engines.
102+
Some legacy OMAP SoC do not have ELM harware engine, so those SoC cannot
103+
support ecc-schemes with hardware error-correction (BCHx_HW). However
104+
such SoC can use ecc-schemes with software library for error-correction
105+
(BCHx_HW_DETECTION_SW). The error correction capability with software
106+
library remains equivalent to their hardware counter-part, but there is
107+
slight CPU penalty when too many bit-flips are detected during reads.
108+
109+
(2) Device parameters like OOBSIZE.
110+
Other factor which governs the selection of ecc-scheme is oob-size.
111+
Higher ECC schemes require more OOB/Spare area to store ECC syndrome,
112+
so the device should have enough free bytes available its OOB/Spare
113+
area to accomodate ECC for entire page. In general following expression
114+
helps in determining if given device can accomodate ECC syndrome:
115+
"2 + (PAGESIZE / 512) * ECC_BYTES" >= OOBSIZE"
116+
where
117+
OOBSIZE number of bytes in OOB/spare area
118+
PAGESIZE number of bytes in main-area of device page
119+
ECC_BYTES number of ECC bytes generated to protect
120+
512 bytes of data, which is:
121+
'3' for HAM1_xx ecc schemes
122+
'7' for BCH4_xx ecc schemes
123+
'14' for BCH8_xx ecc schemes
124+
'26' for BCH16_xx ecc schemes
125+
126+
Example(a): For a device with PAGESIZE = 2048 and OOBSIZE = 64 and
127+
trying to use BCH16 (ECC_BYTES=26) ecc-scheme.
128+
Number of ECC bytes per page = (2 + (2048 / 512) * 26) = 106 B
129+
which is greater than capacity of NAND device (OOBSIZE=64)
130+
Hence, BCH16 cannot be supported on given device. But it can
131+
probably use lower ecc-schemes like BCH8.
132+
133+
Example(b): For a device with PAGESIZE = 2048 and OOBSIZE = 128 and
134+
trying to use BCH16 (ECC_BYTES=26) ecc-scheme.
135+
Number of ECC bytes per page = (2 + (2048 / 512) * 26) = 106 B
136+
which can be accomodate in the OOB/Spare area of this device
137+
(OOBSIZE=128). So this device can use BCH16 ecc-scheme.

‎Documentation/devicetree/bindings/mtd/m25p80.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Required properties:
55
representing partitions.
66
- compatible : Should be the manufacturer and the name of the chip. Bear in mind
77
the DT binding is not Linux-only, but in case of Linux, see the
8-
"m25p_ids" table in drivers/mtd/devices/m25p80.c for the list of
9-
supported chips.
8+
"spi_nor_ids" table in drivers/mtd/spi-nor/spi-nor.c for the list
9+
of supported chips.
1010
- reg : Chip-Select number
1111
- spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at
1212

‎Documentation/devicetree/bindings/mtd/pxa3xx-nand.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ Optional properties:
1717
- num-cs: Number of chipselect lines to usw
1818
- nand-on-flash-bbt: boolean to enable on flash bbt option if
1919
not present false
20+
- nand-ecc-strength: number of bits to correct per ECC step
21+
- nand-ecc-step-size: number of data bytes covered by a single ECC step
22+
23+
The following ECC strength and step size are currently supported:
24+
25+
- nand-ecc-strength = <1>, nand-ecc-step-size = <512>
26+
- nand-ecc-strength = <4>, nand-ecc-step-size = <512>
27+
- nand-ecc-strength = <8>, nand-ecc-step-size = <512>
2028

2129
Example:
2230

‎Documentation/mtd/spi-nor.txt‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
SPI NOR framework
2+
============================================
3+
4+
Part I - Why do we need this framework?
5+
---------------------------------------
6+
7+
SPI bus controllers (drivers/spi/) only deal with streams of bytes; the bus
8+
controller operates agnostic of the specific device attached. However, some
9+
controllers (such as Freescale's QuadSPI controller) cannot easily handle
10+
arbitrary streams of bytes, but rather are designed specifically for SPI NOR.
11+
12+
In particular, Freescale's QuadSPI controller must know the NOR commands to
13+
find the right LUT sequence. Unfortunately, the SPI subsystem has no notion of
14+
opcodes, addresses, or data payloads; a SPI controller simply knows to send or
15+
receive bytes (Tx and Rx). Therefore, we must define a new layering scheme under
16+
which the controller driver is aware of the opcodes, addressing, and other
17+
details of the SPI NOR protocol.
18+
19+
Part II - How does the framework work?
20+
--------------------------------------
21+
22+
This framework just adds a new layer between the MTD and the SPI bus driver.
23+
With this new layer, the SPI NOR controller driver does not depend on the
24+
m25p80 code anymore.
25+
26+
Before this framework, the layer is like:
27+
28+
MTD
29+
------------------------
30+
m25p80
31+
------------------------
32+
SPI bus driver
33+
------------------------
34+
SPI NOR chip
35+
36+
After this framework, the layer is like:
37+
MTD
38+
------------------------
39+
SPI NOR framework
40+
------------------------
41+
m25p80
42+
------------------------
43+
SPI bus driver
44+
------------------------
45+
SPI NOR chip
46+
47+
With the SPI NOR controller driver (Freescale QuadSPI), it looks like:
48+
MTD
49+
------------------------
50+
SPI NOR framework
51+
------------------------
52+
fsl-quadSPI
53+
------------------------
54+
SPI NOR chip
55+
56+
Part III - How can drivers use the framework?
57+
---------------------------------------------
58+
59+
The main API is spi_nor_scan(). Before you call the hook, a driver should
60+
initialize the necessary fields for spi_nor{}. Please see
61+
drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c
62+
when you want to write a new driver for a SPI NOR controller.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
#define GPMC_ECC_BCH_RESULT_1 0x244 /* not available on OMAP2 */
6969
#define GPMC_ECC_BCH_RESULT_2 0x248 /* not available on OMAP2 */
7070
#define GPMC_ECC_BCH_RESULT_3 0x24c /* not available on OMAP2 */
71+
#define GPMC_ECC_BCH_RESULT_4 0x300 /* not available on OMAP2 */
72+
#define GPMC_ECC_BCH_RESULT_5 0x304 /* not available on OMAP2 */
73+
#define GPMC_ECC_BCH_RESULT_6 0x308 /* not available on OMAP2 */
7174

7275
/* GPMC ECC control settings */
7376
#define GPMC_ECC_CTRL_ECCCLEAR 0x100
@@ -677,6 +680,12 @@ void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs)
677680
GPMC_BCH_SIZE * i;
678681
reg->gpmc_bch_result3[i] = gpmc_base + GPMC_ECC_BCH_RESULT_3 +
679682
GPMC_BCH_SIZE * i;
683+
reg->gpmc_bch_result4[i] = gpmc_base + GPMC_ECC_BCH_RESULT_4 +
684+
i * GPMC_BCH_SIZE;
685+
reg->gpmc_bch_result5[i] = gpmc_base + GPMC_ECC_BCH_RESULT_5 +
686+
i * GPMC_BCH_SIZE;
687+
reg->gpmc_bch_result6[i] = gpmc_base + GPMC_ECC_BCH_RESULT_6 +
688+
i * GPMC_BCH_SIZE;
680689
}
681690
}
682691

@@ -1412,6 +1421,12 @@ static int gpmc_probe_nand_child(struct platform_device *pdev,
14121421
else
14131422
gpmc_nand_data->ecc_opt =
14141423
OMAP_ECC_BCH8_CODE_HW_DETECTION_SW;
1424+
else if (!strcmp(s, "bch16"))
1425+
if (gpmc_nand_data->elm_of_node)
1426+
gpmc_nand_data->ecc_opt =
1427+
OMAP_ECC_BCH16_CODE_HW;
1428+
else
1429+
pr_err("%s: BCH16 requires ELM support\n", __func__);
14151430
else
14161431
pr_err("%s: ti,nand-ecc-opt invalid value\n", __func__);
14171432

‎drivers/mtd/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ source "drivers/mtd/onenand/Kconfig"
321321

322322
source "drivers/mtd/lpddr/Kconfig"
323323

324+
source "drivers/mtd/spi-nor/Kconfig"
325+
324326
source "drivers/mtd/ubi/Kconfig"
325327

326328
endif # MTD

‎drivers/mtd/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ inftl-objs := inftlcore.o inftlmount.o
3232

3333
obj-y += chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/
3434

35+
obj-$(CONFIG_MTD_SPI_NOR) += spi-nor/
3536
obj-$(CONFIG_MTD_UBI) += ubi/

‎drivers/mtd/chips/Kconfig‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,33 +169,33 @@ config MTD_OTP
169169
in the programming of OTP bits will waste them.
170170

171171
config MTD_CFI_INTELEXT
172-
tristate "Support for Intel/Sharp flash chips"
172+
tristate "Support for CFI command set 0001 (Intel/Sharp chips)"
173173
depends on MTD_GEN_PROBE
174174
select MTD_CFI_UTIL
175175
help
176176
The Common Flash Interface defines a number of different command
177177
sets which a CFI-compliant chip may claim to implement. This code
178-
provides support for one of those command sets, used on Intel
179-
StrataFlash and other parts.
178+
provides support for command set 0001, used on Intel StrataFlash
179+
and other parts.
180180

181181
config MTD_CFI_AMDSTD
182-
tristate "Support for AMD/Fujitsu/Spansion flash chips"
182+
tristate "Support for CFI command set 0002 (AMD/Fujitsu/Spansion chips)"
183183
depends on MTD_GEN_PROBE
184184
select MTD_CFI_UTIL
185185
help
186186
The Common Flash Interface defines a number of different command
187187
sets which a CFI-compliant chip may claim to implement. This code
188-
provides support for one of those command sets, used on chips
189-
including the AMD Am29LV320.
188+
provides support for command set 0002, used on chips including
189+
the AMD Am29LV320.
190190

191191
config MTD_CFI_STAA
192-
tristate "Support for ST (Advanced Architecture) flash chips"
192+
tristate "Support for CFI command set 0020 (ST (Advanced Architecture) chips)"
193193
depends on MTD_GEN_PROBE
194194
select MTD_CFI_UTIL
195195
help
196196
The Common Flash Interface defines a number of different command
197197
sets which a CFI-compliant chip may claim to implement. This code
198-
provides support for one of those command sets.
198+
provides support for command set 0020.
199199

200200
config MTD_CFI_UTIL
201201
tristate

‎drivers/mtd/chips/cfi_cmdset_0020.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ static int cfi_staa_erase_varsize(struct mtd_info *mtd,
961961
chipnum++;
962962

963963
if (chipnum >= cfi->numchips)
964-
break;
964+
break;
965965
}
966966
}
967967

@@ -1170,7 +1170,7 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
11701170
chipnum++;
11711171

11721172
if (chipnum >= cfi->numchips)
1173-
break;
1173+
break;
11741174
}
11751175
}
11761176
return 0;

0 commit comments

Comments
 (0)