-
Notifications
You must be signed in to change notification settings - Fork 8.3k
stm32: xspi: Allow flash driver usage in RAM_LOAD mode #99729
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
Open
erwango
wants to merge
3
commits into
zephyrproject-rtos:main
Choose a base branch
from
erwango:fix_n6_flash_ext_app_upstream
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+61
−36
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -997,6 +997,7 @@ static int stm32_xspi_set_memorymap(const struct device *dev) | |||||
| LOG_DBG("MemoryMap mode enabled"); | ||||||
| return 0; | ||||||
| } | ||||||
| #endif /* CONFIG_STM32_MEMMAP */ | ||||||
|
|
||||||
| static int stm32_xspi_abort(const struct device *dev) | ||||||
| { | ||||||
|
|
@@ -1009,18 +1010,14 @@ static int stm32_xspi_abort(const struct device *dev) | |||||
|
|
||||||
| return 0; | ||||||
| } | ||||||
| #endif /* CONFIG_STM32_MEMMAP */ | ||||||
|
|
||||||
|
|
||||||
| #if defined(CONFIG_STM32_MEMMAP) || defined(CONFIG_STM32_APP_IN_EXT_FLASH) | ||||||
| /* Function to return true if the octoflash is in MemoryMapped else false */ | ||||||
| static bool stm32_xspi_is_memorymap(const struct device *dev) | ||||||
| { | ||||||
| struct flash_stm32_xspi_data *dev_data = dev->data; | ||||||
|
|
||||||
| return stm32_reg_read_bits(&dev_data->hxspi.Instance->CR, XSPI_CR_FMODE) == XSPI_CR_FMODE; | ||||||
| } | ||||||
| #endif | ||||||
|
|
||||||
| /* | ||||||
| * Function to erase the flash : chip or sector with possible OCTO/SPI and STR/DTR | ||||||
|
|
@@ -1218,7 +1215,7 @@ static int flash_stm32_xspi_read(const struct device *dev, off_t addr, | |||||
| return 0; | ||||||
| } | ||||||
|
|
||||||
| #if defined(CONFIG_STM32_MEMMAP) || defined(CONFIG_STM32_APP_IN_EXT_FLASH) | ||||||
| #if defined(CONFIG_STM32_MEMMAP) || (defined(CONFIG_STM32_APP_IN_EXT_FLASH) && defined(CONFIG_XIP)) | ||||||
| ARG_UNUSED(dev_cfg); | ||||||
| ARG_UNUSED(dev_data); | ||||||
| /* | ||||||
|
|
@@ -1314,7 +1311,7 @@ static int flash_stm32_xspi_read(const struct device *dev, off_t addr, | |||||
| xspi_unlock_thread(dev); | ||||||
|
|
||||||
| return ret; | ||||||
| #endif /* CONFIG_STM32_MEMMAP || CONFIG_STM32_APP_IN_EXT_FLASH */ | ||||||
| #endif /* CONFIG_STM32_MEMMAP || (CONFIG_STM32_APP_IN_EXT_FLASH && CONFIG_XIP) */ | ||||||
| } | ||||||
|
|
||||||
| /* Function to write the flash (page program) : with possible OCTO/SPI and STR/DTR */ | ||||||
|
|
@@ -2093,7 +2090,7 @@ static int flash_stm32_xspi_init(const struct device *dev) | |||||
| return -ENODEV; | ||||||
| } | ||||||
|
|
||||||
| #ifdef CONFIG_STM32_APP_IN_EXT_FLASH | ||||||
| #if defined(CONFIG_STM32_APP_IN_EXT_FLASH) && defined(CONFIG_XIP) | ||||||
etienne-lms marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| /* If MemoryMapped then configure skip init | ||||||
| * Check clock status first as reading CR register without bus clock doesn't work on N6 | ||||||
| * If clock is off, then MemoryMapped is off too and we do init | ||||||
|
|
@@ -2108,7 +2105,7 @@ static int flash_stm32_xspi_init(const struct device *dev) | |||||
| return 0; | ||||||
| } | ||||||
| } | ||||||
| #endif /* CONFIG_STM32_APP_IN_EXT_FLASH */ | ||||||
| #endif /* CONFIG_STM32_APP_IN_EXT_FLASH && CONFIG_XIP */ | ||||||
|
|
||||||
| /* The SPI/DTR is not a valid config of data_mode/data_rate according to the DTS */ | ||||||
| if ((dev_cfg->data_mode != XSPI_OCTO_MODE) | ||||||
|
|
@@ -2195,13 +2192,30 @@ static int flash_stm32_xspi_init(const struct device *dev) | |||||
| dev_data->hxspi.Init.DelayHoldQuarterCycle = HAL_XSPI_DHQC_ENABLE; | ||||||
| } | ||||||
|
|
||||||
| if (stm32_xspi_is_memorymap(dev)) { | ||||||
| /* Memory map could have been set by previous application */ | ||||||
|
Contributor
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.
Suggested change
|
||||||
| /* Force HAL instance in correct state */ | ||||||
| dev_data->hxspi.State = HAL_XSPI_STATE_BUSY_MEM_MAPPED; | ||||||
| } | ||||||
|
|
||||||
| if (HAL_XSPI_Init(&dev_data->hxspi) != HAL_OK) { | ||||||
| LOG_ERR("XSPI Init failed"); | ||||||
| return -EIO; | ||||||
| } | ||||||
|
|
||||||
| LOG_DBG("XSPI Init'd"); | ||||||
|
|
||||||
| if (stm32_xspi_is_memorymap(dev)) { | ||||||
| /* Memory map could have been set by previous application */ | ||||||
|
Contributor
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.
Suggested change
|
||||||
| /* Abort to allow following card oriented transactions */ | ||||||
|
Contributor
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. card!? |
||||||
| /* If needed by the application, it will be re-enabled just after */ | ||||||
| ret = stm32_xspi_abort(dev); | ||||||
| if (ret != 0) { | ||||||
| LOG_ERR("Failed to abort memory-mapped access before init"); | ||||||
etienne-lms marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| return ret; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| #if defined(HAL_XSPIM_IOPORT_1) || defined(HAL_XSPIM_IOPORT_2) || \ | ||||||
| defined(XSPIM) || defined(XSPIM1) || defined(XSPIM2) | ||||||
| /* XSPI I/O manager init Function */ | ||||||
|
|
||||||
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
Oops, something went wrong.
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.
More of a nit really, but
ospi-nor-flash@0node should not have the aliasmx66uw1g45g, rather something likeext_flash_controller, and consequentlyzephyr,flash-controllershould be changed.