Skip to content

Commit c861286

Browse files
danieldegrassedkalowsk
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 <[email protected]> (cherry picked from commit c12030a)
1 parent 3f4037b commit c861286

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
@@ -944,8 +944,10 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
944944
}
945945

946946
/* Switch on manufacturer and vendor ID */
947-
switch (vendor_id & 0xFFFF) {
948-
case 0x609d: /* IS25LP flash, needs P[4:3] cleared with same method as IS25WP */
947+
switch (vendor_id & 0xFFFFFF) {
948+
case 0x16609d: /* IS25LP032 flash, needs P[4:3] cleared with same method as IS25WP */
949+
case 0x17609d: /* IS25LP064 */
950+
case 0x18609d: /* IS25LP128 */
949951
read_params = 0xE0U;
950952
ret = flash_flexspi_nor_is25_clear_read_param(data, flexspi_lut, &read_params);
951953
if (ret < 0) {
@@ -959,7 +961,9 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
959961
}
960962
/* Still return an error- we want the JEDEC configuration to run */
961963
return -ENOTSUP;
962-
case 0x709d:
964+
case 0x16709d: /* IS25WP032 */
965+
case 0x17709d: /* IS25WP064 */
966+
case 0x18709d: /* IS25WP128 */
963967
/*
964968
* IS25WP flash. We can support this flash with the JEDEC probe,
965969
* but we need to insure P[6:3] are at the default value
@@ -977,15 +981,8 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
977981
}
978982
/* Still return an error- we want the JEDEC configuration to run */
979983
return -ENOTSUP;
980-
case 0x40ef:
981-
if ((vendor_id & 0xFFFFFF) != 0x2040ef) {
982-
/*
983-
* This is not the correct flash chip, and will not
984-
* support the LUT table. Return here
985-
*/
986-
return -ENOTSUP;
987-
}
988-
/* W25Q512JV flash, use 4 byte read/write */
984+
case 0x2040ef:
985+
/* W25Q512JV-IQ/IN flash, use 4 byte read/write */
989986
flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ(
990987
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B,
991988
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 32);
@@ -1015,14 +1012,7 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
10151012
/* Device uses bit 1 of status reg 2 for QE */
10161013
return flash_flexspi_nor_quad_enable(data, flexspi_lut,
10171014
JESD216_DW15_QER_VAL_S2B1v5);
1018-
case 0x60ef:
1019-
if ((vendor_id & 0xFFFFFF) != 0x2060ef) {
1020-
/*
1021-
* This is not the correct flash chip, and will not
1022-
* support the LUT table. Return here
1023-
*/
1024-
return -ENOTSUP;
1025-
}
1015+
case 0x2060ef:
10261016
/* W25Q512NW-IQ/IN flash, use 4 byte read/write */
10271017
flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ(
10281018
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B,
@@ -1053,8 +1043,8 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
10531043
/* Device uses bit 1 of status reg 2 for QE */
10541044
return flash_flexspi_nor_quad_enable(data, flexspi_lut,
10551045
JESD216_DW15_QER_VAL_S2B1v5);
1056-
case 0x25C2:
1057-
/* MX25 flash, use 4 byte read/write */
1046+
case 0x3A25C2:
1047+
/* MX25U51245G flash, use 4 byte read/write */
10581048
flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ(
10591049
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B,
10601050
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 32);

0 commit comments

Comments
 (0)