-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: flash: flexspi: Add 4-byte addressing support for MT25 family #82532
Conversation
7a5f297
to
d2416e2
Compare
d2416e2
to
344500d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor nits, but the LUT table looks right.
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_SE_4B, | ||
kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 32); | ||
flexspi_lut[ERASE_BLOCK][0] = FLEXSPI_LUT_SEQ( | ||
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xDC, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit- can use SPI_NOR_CMD_BE_4B
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_RDSR, | ||
kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x01); | ||
/* Device has no QE bit, 1-4-4 and 1-1-4 is always enabled */ | ||
return flash_flexspi_nor_quad_enable(data, flexspi_lut, JESD216_DW15_QER_NONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is effectively a NOP, right? We can probably drop this call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just drop it then, and leave a comment there so that developers aren't confused in the future as to why this is skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -1093,6 +1093,36 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data, | |||
kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x01); | |||
/* Device uses bit 6 of status reg 1 for QE */ | |||
return flash_flexspi_nor_quad_enable(data, flexspi_lut, JESD216_DW15_QER_VAL_S1B6); | |||
case 0xbb20: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI- I have this PR open: #82448. If this merges first I can update the value here- I would expect it to be 0x18bb20
, but could you verify that on your end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ours is 0x21bb20
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. So I guess we could add 0x19
to 0x22
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should be able to add them all to the switch statement pretty safely :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, NNba20 and NNbb20 are the same devices 0xba and 0xbb are voltages for these specific devices.
NN == 0x18 means that you have 128Mbit device, which works with 24 bit addressing everything above 0x18 will require 4 byte.
Although, I do not see any comments that the 0x18 type devices would not work with 4 byte addressing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@de-nordic Meaning, we should add a case 0xba20:
there as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can, because both should be covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
779affa
to
f3e0e56
Compare
@danieldegrasse We are getting weird erase/write issues on our device, which are fixed if we add a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing all the other usages of 0xDC
:)
Very odd- just a note, I would be very careful calling kernel APIs within the driver. If you are executing in place from this flash chip (I assume so, given the board you are using), then attempting to run code stored in flash while the flash device is programming can cause issues- the sequence that happens is something like so:
|
You are absolutely right, of course. But we only did that for testing purposes, and it made our functional write/read tests succeed. Very odd. |
@danieldegrasse It works with a 10MHz clock, but fails with everything larger. Might be a cs setup/hold time issue on our side or similar. Still wanna make sure it's not an issue in the LUT before merging this. It feels like the 'Write Finished' register flag gets cleared too early, or at least it's perceived by the CPU that way. I already checked the LUT for it though and it seems fine. I'm not sure what the issue is. |
@danieldegrasse Btw, what's the reason that |
Very strange. I've been looking at the datasheet as well, the LUT really seems correct to me. Is it possible there is some other bit that needs to be checked? I'm looking at the flag status register and wonder how bit 7 behaves |
Page 19, note 2: |
@danieldegrasse We currently assume it's a bug on our side, so I put this PR back to non-draft. Ready to be reviewed and merged. |
So generally the reason is that The Currently, this driver has a few issues (as you've pointed out):
Now there is an API in upstream for interfacing with parallel SPI controllers, the MSPI API. The path forwards is likely the following:
Long term, we can also implement drivers for specific flash chips using the MSPI API as well. This will allow us to move away from the flash_mcux_flexspi_xxx drivers that are specific to the FlexSPI only |
f4e131f
f3e0e56
to
f4e131f
Compare
Since #82448 merged, this PR now needs to encode 3 bytes of the JEDEC ID rather than 2 |
f4e131f
to
b7cd010
Compare
@de-nordic Would you mind verifying that I don't have a typo in my JEDEC IDs or Product Package Codes? |
3cfb082
to
3d37180
Compare
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]>
3d37180
to
c3debf1
Compare
@danieldegrasse Sorry, just fixed the wording of a comment, will stop editing now. |
Currently, MT25 flashes are 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.
The new LUT configuration is identical to the one used in other projects of ours, based on Azure RTOS. Of course, I still always appreciate more people testing it on their devices, in case someone else has a MT25 chip somewhere.
Link to datasheet for LUT reviews: https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/2293/MT25QU01GBBB_DS.pdf