Skip to content

Commit 5bc7c33

Browse files
computersforpeaceDavid Woodhouse
authored andcommitted
mtd: nand: reintroduce NAND_NO_READRDY as NAND_NEED_READRDY
This partially reverts commit 1696e6b ("mtd: nand: kill NAND_NO_READRDY"). In that patch I overlooked a few things. The original documentation for NAND_NO_READRDY included "True for all large page devices, as they do not support autoincrement." I was conflating "not support autoincrement" with the NAND_NO_AUTOINCR option, which was in fact doing nothing. So, when I dropped NAND_NO_AUTOINCR, I concluded that I then could harmlessly drop NAND_NO_READRDY. But of course the fact the NAND_NO_AUTOINCR was doing nothing didn't mean NAND_NO_READRDY was doing nothing... So, NAND_NO_READRDY is re-introduced as NAND_NEED_READRDY and applied only to those few remaining small-page NAND which needed it in the first place. Cc: stable@kernel.org [3.5+] Reported-by: Alexander Shiyan <shc_work@mail.ru> Tested-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 91d542f commit 5bc7c33

3 files changed

Lines changed: 64 additions & 39 deletions

File tree

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,14 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
15231523
oobreadlen -= toread;
15241524
}
15251525
}
1526+
1527+
if (chip->options & NAND_NEED_READRDY) {
1528+
/* Apply delay or wait for ready/busy pin */
1529+
if (!chip->dev_ready)
1530+
udelay(chip->chip_delay);
1531+
else
1532+
nand_wait_ready(mtd);
1533+
}
15261534
} else {
15271535
memcpy(buf, chip->buffers->databuf + col, bytes);
15281536
buf += bytes;
@@ -1787,6 +1795,14 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
17871795
len = min(len, readlen);
17881796
buf = nand_transfer_oob(chip, buf, ops, len);
17891797

1798+
if (chip->options & NAND_NEED_READRDY) {
1799+
/* Apply delay or wait for ready/busy pin */
1800+
if (!chip->dev_ready)
1801+
udelay(chip->chip_delay);
1802+
else
1803+
nand_wait_ready(mtd);
1804+
}
1805+
17901806
readlen -= len;
17911807
if (!readlen)
17921808
break;

‎drivers/mtd/nand/nand_ids.c‎

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,51 @@
2222
* 512 512 Byte page size
2323
*/
2424
struct nand_flash_dev nand_flash_ids[] = {
25+
#define SP_OPTIONS NAND_NEED_READRDY
26+
#define SP_OPTIONS16 (SP_OPTIONS | NAND_BUSWIDTH_16)
2527

2628
#ifdef CONFIG_MTD_NAND_MUSEUM_IDS
27-
{"NAND 1MiB 5V 8-bit", 0x6e, 256, 1, 0x1000, 0},
28-
{"NAND 2MiB 5V 8-bit", 0x64, 256, 2, 0x1000, 0},
29-
{"NAND 4MiB 5V 8-bit", 0x6b, 512, 4, 0x2000, 0},
30-
{"NAND 1MiB 3,3V 8-bit", 0xe8, 256, 1, 0x1000, 0},
31-
{"NAND 1MiB 3,3V 8-bit", 0xec, 256, 1, 0x1000, 0},
32-
{"NAND 2MiB 3,3V 8-bit", 0xea, 256, 2, 0x1000, 0},
33-
{"NAND 4MiB 3,3V 8-bit", 0xd5, 512, 4, 0x2000, 0},
34-
{"NAND 4MiB 3,3V 8-bit", 0xe3, 512, 4, 0x2000, 0},
35-
{"NAND 4MiB 3,3V 8-bit", 0xe5, 512, 4, 0x2000, 0},
36-
{"NAND 8MiB 3,3V 8-bit", 0xd6, 512, 8, 0x2000, 0},
37-
38-
{"NAND 8MiB 1,8V 8-bit", 0x39, 512, 8, 0x2000, 0},
39-
{"NAND 8MiB 3,3V 8-bit", 0xe6, 512, 8, 0x2000, 0},
40-
{"NAND 8MiB 1,8V 16-bit", 0x49, 512, 8, 0x2000, NAND_BUSWIDTH_16},
41-
{"NAND 8MiB 3,3V 16-bit", 0x59, 512, 8, 0x2000, NAND_BUSWIDTH_16},
29+
{"NAND 1MiB 5V 8-bit", 0x6e, 256, 1, 0x1000, SP_OPTIONS},
30+
{"NAND 2MiB 5V 8-bit", 0x64, 256, 2, 0x1000, SP_OPTIONS},
31+
{"NAND 4MiB 5V 8-bit", 0x6b, 512, 4, 0x2000, SP_OPTIONS},
32+
{"NAND 1MiB 3,3V 8-bit", 0xe8, 256, 1, 0x1000, SP_OPTIONS},
33+
{"NAND 1MiB 3,3V 8-bit", 0xec, 256, 1, 0x1000, SP_OPTIONS},
34+
{"NAND 2MiB 3,3V 8-bit", 0xea, 256, 2, 0x1000, SP_OPTIONS},
35+
{"NAND 4MiB 3,3V 8-bit", 0xd5, 512, 4, 0x2000, SP_OPTIONS},
36+
{"NAND 4MiB 3,3V 8-bit", 0xe3, 512, 4, 0x2000, SP_OPTIONS},
37+
{"NAND 4MiB 3,3V 8-bit", 0xe5, 512, 4, 0x2000, SP_OPTIONS},
38+
{"NAND 8MiB 3,3V 8-bit", 0xd6, 512, 8, 0x2000, SP_OPTIONS},
39+
40+
{"NAND 8MiB 1,8V 8-bit", 0x39, 512, 8, 0x2000, SP_OPTIONS},
41+
{"NAND 8MiB 3,3V 8-bit", 0xe6, 512, 8, 0x2000, SP_OPTIONS},
42+
{"NAND 8MiB 1,8V 16-bit", 0x49, 512, 8, 0x2000, SP_OPTIONS16},
43+
{"NAND 8MiB 3,3V 16-bit", 0x59, 512, 8, 0x2000, SP_OPTIONS16},
4244
#endif
4345

44-
{"NAND 16MiB 1,8V 8-bit", 0x33, 512, 16, 0x4000, 0},
45-
{"NAND 16MiB 3,3V 8-bit", 0x73, 512, 16, 0x4000, 0},
46-
{"NAND 16MiB 1,8V 16-bit", 0x43, 512, 16, 0x4000, NAND_BUSWIDTH_16},
47-
{"NAND 16MiB 3,3V 16-bit", 0x53, 512, 16, 0x4000, NAND_BUSWIDTH_16},
48-
49-
{"NAND 32MiB 1,8V 8-bit", 0x35, 512, 32, 0x4000, 0},
50-
{"NAND 32MiB 3,3V 8-bit", 0x75, 512, 32, 0x4000, 0},
51-
{"NAND 32MiB 1,8V 16-bit", 0x45, 512, 32, 0x4000, NAND_BUSWIDTH_16},
52-
{"NAND 32MiB 3,3V 16-bit", 0x55, 512, 32, 0x4000, NAND_BUSWIDTH_16},
53-
54-
{"NAND 64MiB 1,8V 8-bit", 0x36, 512, 64, 0x4000, 0},
55-
{"NAND 64MiB 3,3V 8-bit", 0x76, 512, 64, 0x4000, 0},
56-
{"NAND 64MiB 1,8V 16-bit", 0x46, 512, 64, 0x4000, NAND_BUSWIDTH_16},
57-
{"NAND 64MiB 3,3V 16-bit", 0x56, 512, 64, 0x4000, NAND_BUSWIDTH_16},
58-
59-
{"NAND 128MiB 1,8V 8-bit", 0x78, 512, 128, 0x4000, 0},
60-
{"NAND 128MiB 1,8V 8-bit", 0x39, 512, 128, 0x4000, 0},
61-
{"NAND 128MiB 3,3V 8-bit", 0x79, 512, 128, 0x4000, 0},
62-
{"NAND 128MiB 1,8V 16-bit", 0x72, 512, 128, 0x4000, NAND_BUSWIDTH_16},
63-
{"NAND 128MiB 1,8V 16-bit", 0x49, 512, 128, 0x4000, NAND_BUSWIDTH_16},
64-
{"NAND 128MiB 3,3V 16-bit", 0x74, 512, 128, 0x4000, NAND_BUSWIDTH_16},
65-
{"NAND 128MiB 3,3V 16-bit", 0x59, 512, 128, 0x4000, NAND_BUSWIDTH_16},
66-
67-
{"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, 0},
46+
{"NAND 16MiB 1,8V 8-bit", 0x33, 512, 16, 0x4000, SP_OPTIONS},
47+
{"NAND 16MiB 3,3V 8-bit", 0x73, 512, 16, 0x4000, SP_OPTIONS},
48+
{"NAND 16MiB 1,8V 16-bit", 0x43, 512, 16, 0x4000, SP_OPTIONS16},
49+
{"NAND 16MiB 3,3V 16-bit", 0x53, 512, 16, 0x4000, SP_OPTIONS16},
50+
51+
{"NAND 32MiB 1,8V 8-bit", 0x35, 512, 32, 0x4000, SP_OPTIONS},
52+
{"NAND 32MiB 3,3V 8-bit", 0x75, 512, 32, 0x4000, SP_OPTIONS},
53+
{"NAND 32MiB 1,8V 16-bit", 0x45, 512, 32, 0x4000, SP_OPTIONS16},
54+
{"NAND 32MiB 3,3V 16-bit", 0x55, 512, 32, 0x4000, SP_OPTIONS16},
55+
56+
{"NAND 64MiB 1,8V 8-bit", 0x36, 512, 64, 0x4000, SP_OPTIONS},
57+
{"NAND 64MiB 3,3V 8-bit", 0x76, 512, 64, 0x4000, SP_OPTIONS},
58+
{"NAND 64MiB 1,8V 16-bit", 0x46, 512, 64, 0x4000, SP_OPTIONS16},
59+
{"NAND 64MiB 3,3V 16-bit", 0x56, 512, 64, 0x4000, SP_OPTIONS16},
60+
61+
{"NAND 128MiB 1,8V 8-bit", 0x78, 512, 128, 0x4000, SP_OPTIONS},
62+
{"NAND 128MiB 1,8V 8-bit", 0x39, 512, 128, 0x4000, SP_OPTIONS},
63+
{"NAND 128MiB 3,3V 8-bit", 0x79, 512, 128, 0x4000, SP_OPTIONS},
64+
{"NAND 128MiB 1,8V 16-bit", 0x72, 512, 128, 0x4000, SP_OPTIONS16},
65+
{"NAND 128MiB 1,8V 16-bit", 0x49, 512, 128, 0x4000, SP_OPTIONS16},
66+
{"NAND 128MiB 3,3V 16-bit", 0x74, 512, 128, 0x4000, SP_OPTIONS16},
67+
{"NAND 128MiB 3,3V 16-bit", 0x59, 512, 128, 0x4000, SP_OPTIONS16},
68+
69+
{"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, SP_OPTIONS},
6870

6971
/*
7072
* These are the new chips with large page size. The pagesize and the

‎include/linux/mtd/nand.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ typedef enum {
187187
* This happens with the Renesas AG-AND chips, possibly others.
188188
*/
189189
#define BBT_AUTO_REFRESH 0x00000080
190+
/*
191+
* Chip requires ready check on read (for auto-incremented sequential read).
192+
* True only for small page devices; large page devices do not support
193+
* autoincrement.
194+
*/
195+
#define NAND_NEED_READRDY 0x00000100
196+
190197
/* Chip does not allow subpage writes */
191198
#define NAND_NO_SUBPAGE_WRITE 0x00000200
192199

0 commit comments

Comments
 (0)