Skip to content

Commit 357e460

Browse files
committed
Merge tag 'spi-nor/for-7.1' into mtd/next
SPI NOR changes for 7.1 There is only a collection of bugfixes this time around, with no notable changes to the core. Some of the more noteworthy bugfixes listed below. - Enable die erase on MT35XU02GCBA. We knew this flash needed this fixup since 7f77c56 ("mtd: spi-nor: micron-st: add TODO for fixing mt35xu02gcba") but did not add it due to lack of hardware to test on. - Fix locking on some Winbond w25q series flashes. - Fix Auto Address Increment (AAI) writes on SST that flashes that start on odd address. The write enable latch needs to be set again after the single byte program.
2 parents b800359 + cf6788a commit 357e460

6 files changed

Lines changed: 35 additions & 17 deletions

File tree

drivers/mtd/spi-nor/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2393,7 +2393,7 @@ static int spi_nor_spimem_check_readop(struct spi_nor *nor,
23932393
/* convert the dummy cycles to the number of bytes */
23942394
op.dummy.nbytes = (read->num_mode_clocks + read->num_wait_states) *
23952395
op.dummy.buswidth / 8;
2396-
if (spi_nor_protocol_is_dtr(nor->read_proto))
2396+
if (spi_nor_protocol_is_dtr(read->proto))
23972397
op.dummy.nbytes *= 2;
23982398

23992399
return spi_nor_spimem_check_op(nor, &op);

drivers/mtd/spi-nor/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ struct spi_nor_flash_parameter {
413413
* number of dummy cycles in read register ops.
414414
* @smpt_map_id: called after map ID in SMPT table has been determined for the
415415
* case the map ID is wrong and needs to be fixed.
416-
* @post_sfdp: called after SFDP has been parsed (is also called for SPI NORs
416+
* @post_sfdp: called after SFDP has been parsed (is not called for SPI NORs
417417
* that do not support RDSFDP). Typically used to tweak various
418418
* parameters that could not be extracted by other means (i.e.
419419
* when information provided by the SFDP/flash_info tables are

drivers/mtd/spi-nor/micron-st.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ static int mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor)
167167
0, 20, SPINOR_OP_MT_DTR_RD,
168168
SNOR_PROTO_8_8_8_DTR);
169169

170+
/*
171+
* Some batches of mt35xu512aba do not contain the OCT DTR command
172+
* information, but do support OCT DTR mode. Add the settings for
173+
* SNOR_CMD_PP_8_8_8_DTR here. This also makes sure the flash can switch
174+
* to OCT DTR mode.
175+
*/
176+
nor->params->hwcaps.mask |= SNOR_HWCAPS_PP_8_8_8_DTR;
177+
spi_nor_set_pp_settings(&nor->params->page_programs[SNOR_CMD_PP_8_8_8_DTR],
178+
SPINOR_OP_PP_4B, SNOR_PROTO_8_8_8_DTR);
179+
170180
nor->cmd_ext_type = SPI_NOR_EXT_REPEAT;
171181
nor->params->rdsr_dummy = 8;
172182
nor->params->rdsr_addr_nbytes = 0;
@@ -185,7 +195,7 @@ static const struct spi_nor_fixups mt35xu512aba_fixups = {
185195
.post_sfdp = mt35xu512aba_post_sfdp_fixup,
186196
};
187197

188-
static const struct spi_nor_fixups mt35xu01gbba_fixups = {
198+
static const struct spi_nor_fixups mt35_two_die_fixups = {
189199
.post_sfdp = mt35xu512aba_post_sfdp_fixup,
190200
.late_init = micron_st_nor_two_die_late_init,
191201
};
@@ -202,25 +212,16 @@ static const struct flash_info micron_nor_parts[] = {
202212
.id = SNOR_ID(0x2c, 0x5b, 0x1b),
203213
.mfr_flags = USE_FSR,
204214
.fixup_flags = SPI_NOR_IO_MODE_EN_VOLATILE,
205-
.fixups = &mt35xu01gbba_fixups,
215+
.fixups = &mt35_two_die_fixups,
206216
}, {
207-
/*
208-
* The MT35XU02GCBA flash device does not support chip erase,
209-
* according to its datasheet. It supports die erase, which
210-
* means the current driver implementation will likely need to
211-
* be converted to use die erase. Furthermore, similar to the
212-
* MT35XU01GBBA, the SPI_NOR_IO_MODE_EN_VOLATILE flag probably
213-
* needs to be enabled.
214-
*
215-
* TODO: Fix these and test on real hardware.
216-
*/
217217
.id = SNOR_ID(0x2c, 0x5b, 0x1c),
218218
.name = "mt35xu02g",
219219
.sector_size = SZ_128K,
220220
.size = SZ_256M,
221221
.no_sfdp_flags = SECT_4K | SPI_NOR_OCTAL_READ,
222222
.mfr_flags = USE_FSR,
223-
.fixup_flags = SPI_NOR_4B_OPCODES,
223+
.fixup_flags = SPI_NOR_4B_OPCODES | SPI_NOR_IO_MODE_EN_VOLATILE,
224+
.fixups = &mt35_two_die_fixups,
224225
},
225226
};
226227

drivers/mtd/spi-nor/sst.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,26 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
203203

204204
/* Start write from odd address. */
205205
if (to % 2) {
206+
bool needs_write_enable = (len > 1);
207+
206208
/* write one byte. */
207209
ret = sst_nor_write_data(nor, to, 1, buf);
208210
if (ret < 0)
209211
goto out;
210212

211213
to++;
212214
actual++;
215+
216+
/*
217+
* Byte program clears the write enable latch. If more
218+
* data needs to be written using the AAI sequence,
219+
* re-enable writes.
220+
*/
221+
if (needs_write_enable) {
222+
ret = spi_nor_write_enable(nor);
223+
if (ret)
224+
goto out;
225+
}
213226
}
214227

215228
/* Write out most of the data here. */

drivers/mtd/spi-nor/swp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ static u8 spi_nor_get_sr_tb_mask(struct spi_nor *nor)
2828
{
2929
if (nor->flags & SNOR_F_HAS_SR_TB_BIT6)
3030
return SR_TB_BIT6;
31-
else
31+
else if (nor->flags & SNOR_F_HAS_SR_TB)
3232
return SR_TB_BIT5;
33+
else
34+
return 0;
3335
}
3436

3537
static u64 spi_nor_get_min_prot_length_sr(struct spi_nor *nor)

drivers/mtd/spi-nor/winbond.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ static const struct flash_info winbond_nor_parts[] = {
274274
.id = SNOR_ID(0xef, 0x60, 0x19),
275275
.name = "w25q256jw",
276276
.size = SZ_32M,
277+
.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 | SPI_NOR_4BIT_BP,
277278
.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
278279
}, {
279280
.id = SNOR_ID(0xef, 0x60, 0x20),
@@ -295,6 +296,7 @@ static const struct flash_info winbond_nor_parts[] = {
295296
.id = SNOR_ID(0xef, 0x70, 0x17),
296297
.name = "w25q64jvm",
297298
.size = SZ_8M,
299+
.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
298300
.no_sfdp_flags = SECT_4K,
299301
}, {
300302
.id = SNOR_ID(0xef, 0x70, 0x18),
@@ -337,7 +339,7 @@ static const struct flash_info winbond_nor_parts[] = {
337339
.id = SNOR_ID(0xef, 0x80, 0x19),
338340
.name = "w25q256jwm",
339341
.size = SZ_32M,
340-
.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
342+
.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 | SPI_NOR_4BIT_BP,
341343
.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
342344
}, {
343345
.id = SNOR_ID(0xef, 0x80, 0x20),

0 commit comments

Comments
 (0)