1 --- a/drivers/mtd/spi-nor/spi-nor.c
2 +++ b/drivers/mtd/spi-nor/spi-nor.c
3 @@ -611,6 +611,7 @@ const struct spi_device_id spi_nor_ids[]
4 { "m25px32-s0", INFO(0x207316, 0, 64 * 1024, 64, SECT_4K) },
5 { "m25px32-s1", INFO(0x206316, 0, 64 * 1024, 64, SECT_4K) },
6 { "m25px64", INFO(0x207117, 0, 64 * 1024, 128, 0) },
7 + { "m25px80", INFO(0x207114, 0, 64 * 1024, 16, 0) },
9 /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
10 { "w25x10", INFO(0xef3011, 0, 64 * 1024, 2, SECT_4K) },
11 @@ -623,7 +624,6 @@ const struct spi_device_id spi_nor_ids[]
12 { "w25q32dw", INFO(0xef6016, 0, 64 * 1024, 64, SECT_4K) },
13 { "w25x64", INFO(0xef3017, 0, 64 * 1024, 128, SECT_4K) },
14 { "w25q64", INFO(0xef4017, 0, 64 * 1024, 128, SECT_4K) },
15 - { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
16 { "w25q80", INFO(0xef5014, 0, 64 * 1024, 16, SECT_4K) },
17 { "w25q80bl", INFO(0xef4014, 0, 64 * 1024, 16, SECT_4K) },
18 { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
19 @@ -671,11 +671,6 @@ static const struct spi_device_id *spi_n
20 return ERR_PTR(-ENODEV);
23 -static const struct spi_device_id *jedec_probe(struct spi_nor *nor)
25 - return nor->read_id(nor);
28 static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
29 size_t *retlen, u_char *buf)
31 @@ -920,7 +915,6 @@ int spi_nor_scan(struct spi_nor *nor, co
34 struct flash_info *info;
35 - struct flash_platform_data *data;
36 struct device *dev = nor->dev;
37 struct mtd_info *mtd = nor->mtd;
38 struct device_node *np = dev->of_node;
39 @@ -931,34 +925,12 @@ int spi_nor_scan(struct spi_nor *nor, co
43 - /* Platform data helps sort out which chip type we have, as
44 - * well as how this board partitions it. If we don't have
45 - * a chip ID, try the JEDEC id commands; they'll work for most
46 - * newer chips, even if we don't recognize the particular chip.
48 - data = dev_get_platdata(dev);
49 - if (data && data->type) {
50 - const struct spi_device_id *plat_id;
52 - for (i = 0; i < ARRAY_SIZE(spi_nor_ids) - 1; i++) {
53 - plat_id = &spi_nor_ids[i];
54 - if (strcmp(data->type, plat_id->name))
59 - if (i < ARRAY_SIZE(spi_nor_ids) - 1)
62 - dev_warn(dev, "unrecognized id %s\n", data->type);
65 info = (void *)id->driver_data;
68 const struct spi_device_id *jid;
70 - jid = jedec_probe(nor);
71 + jid = nor->read_id(nor);
74 } else if (jid != id) {
75 @@ -990,11 +962,8 @@ int spi_nor_scan(struct spi_nor *nor, co
79 - if (data && data->name)
80 - mtd->name = data->name;
83 mtd->name = dev_name(dev);
85 mtd->type = MTD_NORFLASH;
87 mtd->flags = MTD_CAP_NORFLASH;
88 @@ -1018,6 +987,7 @@ int spi_nor_scan(struct spi_nor *nor, co
89 nor->wait_till_ready == spi_nor_wait_till_ready)
90 nor->wait_till_ready = spi_nor_wait_till_fsr_ready;
92 +#ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS
93 /* prefer "small sector" erase if possible */
94 if (info->flags & SECT_4K) {
95 nor->erase_opcode = SPINOR_OP_BE_4K;
96 @@ -1025,7 +995,9 @@ int spi_nor_scan(struct spi_nor *nor, co
97 } else if (info->flags & SECT_4K_PMC) {
98 nor->erase_opcode = SPINOR_OP_BE_4K_PMC;
99 mtd->erasesize = 4096;
104 nor->erase_opcode = SPINOR_OP_SE;
105 mtd->erasesize = info->sector_size;
107 --- a/drivers/mtd/spi-nor/Kconfig
108 +++ b/drivers/mtd/spi-nor/Kconfig
109 @@ -7,6 +7,20 @@ menuconfig MTD_SPI_NOR
113 +config MTD_SPI_NOR_USE_4K_SECTORS
114 + bool "Use small 4096 B erase sectors"
117 + Many flash memories support erasing small (4096 B) sectors. Depending
118 + on the usage this feature may provide performance gain in comparison
119 + to erasing whole blocks (32/64 KiB).
120 + Changing a small part of the flash's contents is usually faster with
121 + small sectors. On the other hand erasing should be faster when using
122 + 64 KiB block instead of 16 × 4 KiB sectors.
124 + Please note that some tools/drivers/filesystems may not work with
125 + 4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
127 config SPI_FSL_QUADSPI
128 tristate "Freescale Quad SPI controller"