Skip to content

Commit c12030a

Browse files
danieldegrassekartben
authored andcommitted
drivers: flash: flash_mcux_flexspi_nor: check all 3 bytes of JEDEC ID
The FlexSPI NOR driver should verify all 3 bytes of the JEDEC ID match the expected value before attempting to use a custom LUT table with a flash chip. This reduces the odds that an incompatible LUT will be used with a flash chip, as some flash chips may share the same first byte of their device ID but not be compatible with the custom LUT table. Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
1 parent c6700e8 commit c12030a

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

drivers/flash/flash_mcux_flexspi_nor.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,10 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
954954
}
955955

956956
/* Switch on manufacturer and vendor ID */
957-
switch (vendor_id & 0xFFFF) {
958-
case 0x609d: /* IS25LP flash, needs P[4:3] cleared with same method as IS25WP */
957+
switch (vendor_id & 0xFFFFFF) {
958+
case 0x16609d: /* IS25LP032 flash, needs P[4:3] cleared with same method as IS25WP */
959+
case 0x17609d: /* IS25LP064 */
960+
case 0x18609d: /* IS25LP128 */
959961
read_params = 0xE0U;
960962
ret = flash_flexspi_nor_is25_clear_read_param(data, flexspi_lut, &read_params);
961963
if (ret < 0) {
@@ -969,7 +971,9 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
969971
}
970972
/* Still return an error- we want the JEDEC configuration to run */
971973
return -ENOTSUP;
972-
case 0x709d:
974+
case 0x16709d: /* IS25WP032 */
975+
case 0x17709d: /* IS25WP064 */
976+
case 0x18709d: /* IS25WP128 */
973977
/*
974978
* IS25WP flash. We can support this flash with the JEDEC probe,
975979
* but we need to insure P[6:3] are at the default value
@@ -987,15 +991,8 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
987991
}
988992
/* Still return an error- we want the JEDEC configuration to run */
989993
return -ENOTSUP;
990-
case 0x40ef:
991-
if ((vendor_id & 0xFFFFFF) != 0x2040ef) {
992-
/*
993-
* This is not the correct flash chip, and will not
994-
* support the LUT table. Return here
995-
*/
996-
return -ENOTSUP;
997-
}
998-
/* W25Q512JV flash, use 4 byte read/write */
994+
case 0x2040ef:
995+
/* W25Q512JV-IQ/IN flash, use 4 byte read/write */
999996
flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ(
1000997
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B,
1001998
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 32);
@@ -1025,14 +1022,7 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
10251022
/* Device uses bit 1 of status reg 2 for QE */
10261023
return flash_flexspi_nor_quad_enable(data, flexspi_lut,
10271024
JESD216_DW15_QER_VAL_S2B1v5);
1028-
case 0x60ef:
1029-
if ((vendor_id & 0xFFFFFF) != 0x2060ef) {
1030-
/*
1031-
* This is not the correct flash chip, and will not
1032-
* support the LUT table. Return here
1033-
*/
1034-
return -ENOTSUP;
1035-
}
1025+
case 0x2060ef:
10361026
/* W25Q512NW-IQ/IN flash, use 4 byte read/write */
10371027
flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ(
10381028
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B,
@@ -1063,8 +1053,8 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
10631053
/* Device uses bit 1 of status reg 2 for QE */
10641054
return flash_flexspi_nor_quad_enable(data, flexspi_lut,
10651055
JESD216_DW15_QER_VAL_S2B1v5);
1066-
case 0x25C2:
1067-
/* MX25 flash, use 4 byte read/write */
1056+
case 0x3A25C2:
1057+
/* MX25U51245G flash, use 4 byte read/write */
10681058
flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ(
10691059
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B,
10701060
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 32);

0 commit comments

Comments
 (0)