-
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: merger Generic SPI Flash driver #7561
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7561 +/- ##
=======================================
Coverage 53.22% 53.22%
=======================================
Files 217 217
Lines 26668 26668
Branches 5914 5914
=======================================
Hits 14193 14193
Misses 10059 10059
Partials 2416 2416 Continue to review full report at Codecov.
|
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.
Seems fine to me (remove the 'etc' in last patch's commit title).
Note that you don't have to close and create a new PR each time you make changes to your patches: a git push -f will just do, and all will be updated in existing PR.
嗯,我尝试过 |
2bcf0a4
to
cf3b296
Compare
23ad35f
to
10994fe
Compare
@tbursztyka Made more changes in this patch |
10994fe
to
ff2e7ec
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.
you will need to rebase and update that against latest SPI API. Also, add support for CS GPIO (see existing code such as spi_flash_w25qxxdv.c)
drivers/flash/Kconfig
Outdated
default "" | ||
|
||
config SPI_FLASH_SFDP_INIT_PRIORITY | ||
int |
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.
no prompt for that one?
drivers/flash/Kconfig
Outdated
Flash Discoverable Parameters (SFDP). | ||
|
||
config SPI_FLASH_SFDP_SPI_NAME | ||
string |
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.
get rid of prompt and put the prompt message here.
drivers/flash/spi_flash_sfdp.c
Outdated
phdr[i].major_ver, phdr[i].minor_ver, | ||
get_phdr_addr(&phdr[i]), | ||
phdr[i].length); | ||
switch (get_phdr_id(&phdr[i])) { |
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.
why a switch if there is only 1 case?
drivers/flash/spi_flash_sfdp.c
Outdated
wait_for_flash_idle(dev); | ||
i = 0; | ||
hdr[i++] = data->read_opcode; | ||
if (data->addr_len == 4) { |
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.
add an empty line before
drivers/flash/spi_flash_sfdp.c
Outdated
if (data->addr_len == 4) { | ||
hdr[i++] = offset >> 24; | ||
} | ||
hdr[i++] = offset >> 16; |
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.
same
drivers/flash/spi_flash_sfdp.c
Outdated
hdr[i++] = offset >> 16; | ||
hdr[i++] = offset >> 8; | ||
hdr[i++] = offset; | ||
r = spi_transceive(&data->config, txbufs, ARRAY_SIZE(txbufs), |
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.
same
drivers/flash/spi_flash_sfdp.c
Outdated
|
||
SYS_LOG_DBG("write: @%x len %x, opcode %x (page size %d)", | ||
offset, len, | ||
data->write_opcode, data->page_size); |
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.
hum, you can put that on previous line
drivers/flash/spi_flash_sfdp.c
Outdated
|
||
i = 0; | ||
hdr[i++] = data->write_opcode; | ||
if (data->addr_len == 4) { |
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.
add an empty line before (basicall: if assigned value is not used in the if condition: break a line).
drivers/flash/spi_flash_sfdp.c
Outdated
if (data->addr_len == 4) { | ||
hdr[i++] = offset >> 24; | ||
} | ||
hdr[i++] = offset >> 16; |
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.
same here (break a line if it's not another '}' etc...)
88688ce 来自 Merged #5456,我只是让它变得可合并而已,我在 ff2e7ec 中做了自己的工作,包括gpio_cs,几乎重写了。 |
020b1f0
to
88c6f2e
Compare
#define CONFIG_SPI_FLASH_SMPT_SIZE 16 | ||
#endif | ||
|
||
typedef u32_t dword_t; |
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.
why this typedef? Seems unnecessary
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.
dword 是SFDP文档里定义的最小组成单位
From Google Translate
Dword is the smallest unit of definition defined in the SFDP document
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.
Ok
@@ -1,558 +1,993 @@ | |||
/* | |||
* Copyright (c) 2017 Crypta Labs Ltd | |||
* Copyright (c) 2018 Findlay Feng |
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.
Merge this specific modification of sfdp to your first commit.
And this actual commit becomes one for adding microchip table support then.
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.
I will change it
drivers/flash/spi_flash_sfdp.c
Outdated
.frequency = CONFIG_SPI_FLASH_SFDP_SPI_FREQ_0, | ||
.operation = SPI_WORD_SET(8), | ||
}; | ||
#if defined(SPI_FLASH_GPIO_SPI_CS) |
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.
Why not a Kconfig option for this? So it would be CONFIG_ prefixed then.
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.
oh...
This is a lapse
b16d060
to
6068e8a
Compare
Looks interesting and seems to supercede my work. However, is dual/quad supported tested? I don't see any existing SPI driver supporting them, and my CEC QMSPI driver cannot support it until the descriptors are setup properly to indicate direction correctly - in these modes the data flows one direction only per cycle and the code and SPI API needs to support signalling which bytes are to be written and which are to be read. |
Also overriding the configuration SPI freq does not seem right. This happens for reading SFDP table, and when microchip flash is detected. |
I only tried the standard spi, it is estimated that the dual spi is working, the quad spi still needs some extra work, I have left a lot of todo, and can improve it when needed. |
There is a definition of the read frequency that should be used in the SFDP document. This frequency is not necessarily the same as the one specified in the chip documentation. |
I use the nrf5x spi driver, the memory address of the configuration information does not change without modifying the actual configuration of the spi. . . |
It is still normal that lower frequency is needed to be used. I think the configuration provided frequency should be honored. I rebased my spi sfdp driver on top of current head just to get everything I needed working - e.g. seems the microchip global unlock is not yet supported properly. |
My idea about the frequency is that when the device is not found, the speed specified by SFDP can be viewed at https://www.jedec.org/system/files/docs/JESD216B.pdf. Switch to the rate supported by the target device after the type. |
page 3
|
This drivers supports chips with Serial Flash Discoverable Parameters (SFDP) information. Add Kconfig.spi Add spi_flash_sfdp.c Add spi_flash_sfdp.h Support spi dual mode Partial support spi quad mode Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Findlay Feng <i@fengch.me>
Supports Microchip SFDP table Add Kconfig.spi.microchip Add spi_flash_sfdp_microchip.h Add spi_flash_sfdp_microchip.c Signed-off-by: Findlay Feng <i@fengch.me>
id SPI_FLASH_0_ID; name CONFIG_SPI_FLASH_DRV_NAME; Signed-off-by: Findlay Feng <i@fengch.me>
6068e8a
to
ca75a7e
Compare
We have a spi_nor driver in tree. Please update any features like SFDP to that driver. Closing this PR at this point. |
Merged #5456.
Update spi api.
Add the CS/gpio logic.
Independent of spi flash config.