]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.140/mtd-rawnand-mxc-set-spare-area-size-register-explicitly.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.140 / mtd-rawnand-mxc-set-spare-area-size-register-explicitly.patch
CommitLineData
c55ac56b
GKH
1From 3f77f244d8ec28e3a0a81240ffac7d626390060c Mon Sep 17 00:00:00 2001
2From: Martin Kaiser <martin@kaiser.cx>
3Date: Mon, 18 Jun 2018 22:41:03 +0200
4Subject: mtd: rawnand: mxc: set spare area size register explicitly
5
6From: Martin Kaiser <martin@kaiser.cx>
7
8commit 3f77f244d8ec28e3a0a81240ffac7d626390060c upstream.
9
10The v21 version of the NAND flash controller contains a Spare Area Size
11Register (SPAS) at offset 0x10. Its setting defaults to the maximum
12spare area size of 218 bytes. The size that is set in this register is
13used by the controller when it calculates the ECC bytes internally in
14hardware.
15
16Usually, this register is updated from settings in the IIM fuses when
17the system is booting from NAND flash. For other boot media, however,
18the SPAS register remains at the default setting, which may not work for
19the particular flash chip on the board. The same goes for flash chips
20whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
21sector size and 128 bytes spare area size can't be configured in the IIM
22fuses on imx25 systems).
23
24Set the SPAS register explicitly during the preset operation. Derive the
25register value from mtd->oobsize that was detected during probe by
26decoding the flash chip's ID bytes.
27
28While at it, rename the define for the spare area register's offset to
29NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
30different from the register on v21 controllers.
31
32Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset")
33Cc: stable@vger.kernel.org
34Signed-off-by: Martin Kaiser <martin@kaiser.cx>
35Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
36Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
37Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
38Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
39
40
41---
42 drivers/mtd/nand/mxc_nand.c | 5 ++++-
43 1 file changed, 4 insertions(+), 1 deletion(-)
44
45--- a/drivers/mtd/nand/mxc_nand.c
46+++ b/drivers/mtd/nand/mxc_nand.c
47@@ -49,7 +49,7 @@
48 #define NFC_V1_V2_CONFIG (host->regs + 0x0a)
49 #define NFC_V1_V2_ECC_STATUS_RESULT (host->regs + 0x0c)
50 #define NFC_V1_V2_RSLTMAIN_AREA (host->regs + 0x0e)
51-#define NFC_V1_V2_RSLTSPARE_AREA (host->regs + 0x10)
52+#define NFC_V21_RSLTSPARE_AREA (host->regs + 0x10)
53 #define NFC_V1_V2_WRPROT (host->regs + 0x12)
54 #define NFC_V1_UNLOCKSTART_BLKADDR (host->regs + 0x14)
55 #define NFC_V1_UNLOCKEND_BLKADDR (host->regs + 0x16)
56@@ -1034,6 +1034,9 @@ static void preset_v2(struct mtd_info *m
57 writew(config1, NFC_V1_V2_CONFIG1);
58 /* preset operation */
59
60+ /* spare area size in 16-bit half-words */
61+ writew(mtd->oobsize / 2, NFC_V21_RSLTSPARE_AREA);
62+
63 /* Unlock the internal RAM Buffer */
64 writew(0x2, NFC_V1_V2_CONFIG);
65