-
Notifications
You must be signed in to change notification settings - Fork 7.4k
stm32 qspi driver support sfdp parameters #56279
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
02c7a0c
drivers: flash: stm32 qspi driver with read SFDP ID from quadflash
FRASTM 6c984d6
boards: arm: stm32h747i disco board enables QSPI interface
FRASTM 3186fb5
boards: arm: stm32l496 disco enables the quadspi NOR
FRASTM e89f328
boards: arm: stm32l475 disco yaml has the quadspi NOR
FRASTM aade600
samples: drivers: jesd216 jedec ID and SFDP from quad-flash
FRASTM ba605b8
samples: drivers: quadspi flash of the stm32 boards
FRASTM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ supported: | |
- watchdog | ||
- adc | ||
- dac | ||
- qspi | ||
- dma | ||
ram: 96 | ||
flash: 1024 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ supported: | |
- arduino_spi | ||
- spi | ||
- netif:eth | ||
- qspi | ||
- memc | ||
- usb_cdc | ||
- usb_device |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ supported: | |
- counter | ||
- sdhc | ||
- adc | ||
- qspi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,9 @@ struct flash_stm32_qspi_config { | |
#if STM32_QSPI_RESET_GPIO | ||
const struct gpio_dt_spec reset; | ||
#endif | ||
#if DT_NODE_HAS_PROP(DT_INST(0, st_stm32_qspi_nor), jedec_id) | ||
uint8_t jedec_id[DT_INST_PROP_LEN(0, jedec_id)]; | ||
#endif /* jedec_id */ | ||
}; | ||
|
||
struct flash_stm32_qspi_data { | ||
|
@@ -284,12 +287,57 @@ static int qspi_write_access(const struct device *dev, QSPI_CommandTypeDef *cmd, | |
return dev_data->cmd_status; | ||
} | ||
|
||
#if defined(CONFIG_FLASH_JESD216_API) | ||
/* | ||
* Read Serial Flash ID : | ||
* perform a read access over SPI bus for read Identification (DataMode is already set) | ||
* and compare to the jedec-id from the DTYS table exists | ||
*/ | ||
static int qspi_read_jedec_id(const struct device *dev, uint8_t *id) | ||
{ | ||
struct flash_stm32_qspi_data *dev_data = dev->data; | ||
uint8_t data[JESD216_READ_ID_LEN]; | ||
|
||
QSPI_CommandTypeDef cmd = { | ||
.Instruction = JESD216_CMD_READ_ID, | ||
.AddressSize = QSPI_ADDRESS_NONE, | ||
.DummyCycles = 8, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please see #56848 comments. |
||
.InstructionMode = QSPI_INSTRUCTION_1_LINE, | ||
.AddressMode = QSPI_ADDRESS_1_LINE, | ||
.DataMode = QSPI_DATA_1_LINE, | ||
.NbData = JESD216_READ_ID_LEN, | ||
}; | ||
|
||
HAL_StatusTypeDef hal_ret; | ||
|
||
hal_ret = HAL_QSPI_Command_IT(&dev_data->hqspi, &cmd); | ||
|
||
if (hal_ret != HAL_OK) { | ||
LOG_ERR("%d: Failed to send OSPI instruction", hal_ret); | ||
return -EIO; | ||
} | ||
|
||
hal_ret = HAL_QSPI_Receive(&dev_data->hqspi, data, HAL_QSPI_TIMEOUT_DEFAULT_VALUE); | ||
if (hal_ret != HAL_OK) { | ||
LOG_ERR("%d: Failed to read data", hal_ret); | ||
return -EIO; | ||
} | ||
|
||
dev_data->cmd_status = 0; | ||
id = &data[0]; | ||
|
||
return 0; | ||
} | ||
#endif /* CONFIG_FLASH_JESD216_API */ | ||
|
||
/* | ||
* Read Serial Flash Discovery Parameter | ||
*/ | ||
static int qspi_read_sfdp(const struct device *dev, off_t addr, uint8_t *data, | ||
static int qspi_read_sfdp(const struct device *dev, off_t addr, void *data, | ||
size_t size) | ||
{ | ||
__ASSERT(data != NULL, "null destination"); | ||
|
||
QSPI_CommandTypeDef cmd = { | ||
.Instruction = JESD216_CMD_READ_SFDP, | ||
.Address = addr, | ||
|
@@ -300,7 +348,7 @@ static int qspi_read_sfdp(const struct device *dev, off_t addr, uint8_t *data, | |
.DataMode = QSPI_DATA_1_LINE, | ||
}; | ||
|
||
return qspi_read_access(dev, &cmd, data, size); | ||
return qspi_read_access(dev, &cmd, (uint8_t *)data, size); | ||
} | ||
|
||
static bool qspi_address_is_valid(const struct device *dev, off_t addr, | ||
|
@@ -666,6 +714,10 @@ static const struct flash_driver_api flash_stm32_qspi_driver_api = { | |
#if defined(CONFIG_FLASH_PAGE_LAYOUT) | ||
.page_layout = flash_stm32_qspi_pages_layout, | ||
#endif | ||
#if defined(CONFIG_FLASH_JESD216_API) | ||
.sfdp_read = qspi_read_sfdp, | ||
.read_jedec_id = qspi_read_jedec_id, | ||
#endif /* CONFIG_FLASH_JESD216_API */ | ||
}; | ||
|
||
#if defined(CONFIG_FLASH_PAGE_LAYOUT) | ||
|
@@ -1346,6 +1398,9 @@ static const struct flash_stm32_qspi_config flash_stm32_qspi_cfg = { | |
#if STM32_QSPI_RESET_GPIO | ||
.reset = GPIO_DT_SPEC_INST_GET(0, reset_gpios), | ||
#endif | ||
#if DT_NODE_HAS_PROP(DT_INST(0, st_stm32_qspi_nor), jedec_id) | ||
.jedec_id = DT_INST_PROP(0, jedec_id), | ||
#endif /* jedec_id */ | ||
}; | ||
|
||
static struct flash_stm32_qspi_data flash_stm32_qspi_dev_data = { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_FLASH_STM32_QSPI=y | ||
CONFIG_SPI_NOR_SFDP_RUNTIME=y | ||
CONFIG_SPI_NOR=n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_FLASH_STM32_QSPI=y | ||
CONFIG_SPI_NOR_SFDP_RUNTIME=y | ||
CONFIG_SPI_NOR=n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_FLASH_STM32_QSPI=y | ||
CONFIG_SPI_NOR_SFDP_RUNTIME=y | ||
CONFIG_SPI_NOR=n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not an STM32 expert but shouldn't tis be set to MCU flash-controller?
I guess that some tests/samples use this to access flash (which is probably something we need to fix...), so shouldn't these be part of board overlay for the tests/sample?
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.
That's a board chosen definition, for sure.
That could be a part of the board overlay but most of the other platforms have this in their board.dts file.
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 agree this is a grey area.
Boards porting guidelines states that boards default configuration should take advantage of any "fancy" hardware available in the BSP: "Since an external flash is available, let's take advantage for storage of it an keep internal flash for application binary."
That's debatable of course.