Skip to content

Commit a9bdaf4

Browse files
Finomniskartben
authored andcommitted
drivers: flash: flexspi: Add 4-byte addressing support for MT25 family
Currently, MT25 flashes were running in 3-byte mode. This is not compatible with the chip we use in our project (MT25QU01GBBB), as only 128 Mbit of its 1 Gbit can be addressed. Signed-off-by: Martin Stumpf <[email protected]>
1 parent 7349c85 commit a9bdaf4

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

doc/releases/release-notes-4.1.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ Drivers and Sensors
150150

151151
* Flash
152152

153+
* NXP MCUX FlexSPI: Add support for 4-byte addressing mode of Micron MT25Q flash family (:github:`82532`)
154+
153155
* FPGA
154156

155157
* Extracted from :dtcompatible:`lattice,ice40-fpga` the compatible and driver for

drivers/flash/flash_mcux_flexspi_nor.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
10121012
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_SE_4B,
10131013
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32);
10141014
flexspi_lut[ERASE_BLOCK][0] = FLEXSPI_LUT_SEQ(
1015-
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xDC,
1015+
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_BE_4B,
10161016
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32),
10171017
/* Read instruction used for polling is 0x05 */
10181018
data->legacy_poll = true;
@@ -1043,7 +1043,7 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
10431043
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_SE_4B,
10441044
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32);
10451045
flexspi_lut[ERASE_BLOCK][0] = FLEXSPI_LUT_SEQ(
1046-
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xDC,
1046+
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_BE_4B,
10471047
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32),
10481048
/* Read instruction used for polling is 0x05 */
10491049
data->legacy_poll = true;
@@ -1074,7 +1074,7 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
10741074
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_SE_4B,
10751075
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32);
10761076
flexspi_lut[ERASE_BLOCK][0] = FLEXSPI_LUT_SEQ(
1077-
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xDC,
1077+
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_BE_4B,
10781078
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32),
10791079
/* Read instruction used for polling is 0x05 */
10801080
data->legacy_poll = true;
@@ -1083,6 +1083,43 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data,
10831083
kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x01);
10841084
/* Device uses bit 6 of status reg 1 for QE */
10851085
return flash_flexspi_nor_quad_enable(data, flexspi_lut, JESD216_DW15_QER_VAL_S1B6);
1086+
case 0x19ba20: /* MT25QL256 */
1087+
case 0x20ba20: /* MT25QL512 */
1088+
case 0x21ba20: /* MT25QL01G */
1089+
case 0x22ba20: /* MT25QL02G */
1090+
case 0x19bb20: /* MT25QU256 */
1091+
case 0x20bb20: /* MT25QU512 */
1092+
case 0x21bb20: /* MT25QU01G */
1093+
case 0x22bb20: /* MT25QU02G */
1094+
/* MT25Q flash with more than 32MB, use 4 byte read/write */
1095+
flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ(
1096+
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B,
1097+
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 32);
1098+
/* Flash needs 10 dummy cycles */
1099+
flexspi_lut[READ][1] = FLEXSPI_LUT_SEQ(
1100+
kFLEXSPI_Command_DUMMY_SDR, kFLEXSPI_4PAD, 10,
1101+
kFLEXSPI_Command_READ_SDR, kFLEXSPI_4PAD, 0x04);
1102+
/* Update PROGRAM commands for 4 byte 1S-4S-4S mode */
1103+
flexspi_lut[PAGE_PROGRAM][0] = FLEXSPI_LUT_SEQ(
1104+
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_PP_1_4_4_4B,
1105+
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 32);
1106+
flexspi_lut[PAGE_PROGRAM][1] = FLEXSPI_LUT_SEQ(
1107+
kFLEXSPI_Command_WRITE_SDR, kFLEXSPI_4PAD, 0x4,
1108+
kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0x0);
1109+
/* Update ERASE commands for 4 byte mode */
1110+
flexspi_lut[ERASE_SECTOR][0] = FLEXSPI_LUT_SEQ(
1111+
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_SE_4B,
1112+
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32);
1113+
flexspi_lut[ERASE_BLOCK][0] = FLEXSPI_LUT_SEQ(
1114+
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_BE_4B,
1115+
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32),
1116+
/* Read instruction used for polling is 0x05 */
1117+
data->legacy_poll = true;
1118+
flexspi_lut[READ_STATUS_REG][0] = FLEXSPI_LUT_SEQ(
1119+
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_RDSR,
1120+
kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x01);
1121+
/* Device has no QE bit, 1-4-4 and 1-1-4 is always enabled */
1122+
return 0;
10861123
default:
10871124
return -ENOTSUP;
10881125
}

0 commit comments

Comments
 (0)