]>
Commit | Line | Data |
---|---|---|
c55ac56b GKH |
1 | From 3f77f244d8ec28e3a0a81240ffac7d626390060c Mon Sep 17 00:00:00 2001 |
2 | From: Martin Kaiser <martin@kaiser.cx> | |
3 | Date: Mon, 18 Jun 2018 22:41:03 +0200 | |
4 | Subject: mtd: rawnand: mxc: set spare area size register explicitly | |
5 | ||
6 | From: Martin Kaiser <martin@kaiser.cx> | |
7 | ||
8 | commit 3f77f244d8ec28e3a0a81240ffac7d626390060c upstream. | |
9 | ||
10 | The v21 version of the NAND flash controller contains a Spare Area Size | |
11 | Register (SPAS) at offset 0x10. Its setting defaults to the maximum | |
12 | spare area size of 218 bytes. The size that is set in this register is | |
13 | used by the controller when it calculates the ECC bytes internally in | |
14 | hardware. | |
15 | ||
16 | Usually, this register is updated from settings in the IIM fuses when | |
17 | the system is booting from NAND flash. For other boot media, however, | |
18 | the SPAS register remains at the default setting, which may not work for | |
19 | the particular flash chip on the board. The same goes for flash chips | |
20 | whose configuration cannot be set in the IIM fuses (e.g. chips with 2k | |
21 | sector size and 128 bytes spare area size can't be configured in the IIM | |
22 | fuses on imx25 systems). | |
23 | ||
24 | Set the SPAS register explicitly during the preset operation. Derive the | |
25 | register value from mtd->oobsize that was detected during probe by | |
26 | decoding the flash chip's ID bytes. | |
27 | ||
28 | While at it, rename the define for the spare area register's offset to | |
29 | NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is | |
30 | different from the register on v21 controllers. | |
31 | ||
32 | Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset") | |
33 | Cc: stable@vger.kernel.org | |
34 | Signed-off-by: Martin Kaiser <martin@kaiser.cx> | |
35 | Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de> | |
36 | Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> | |
37 | Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> | |
38 | Signed-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 |