-
Notifications
You must be signed in to change notification settings - Fork 8k
riscv: Source flash geometry from Kconfig #97144
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
base: main
Are you sure you want to change the base?
riscv: Source flash geometry from Kconfig #97144
Conversation
DT_CHOSEN_FLASH_PARENT := $(dt_node_parent,$(DT_CHOSEN_FLASH_NODE)) | ||
|
||
config FLASH_SIZE | ||
default $(dt_node_reg_size_int,$(DT_CHOSEN_FLASH_PARENT),9,K) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),$(DT_COMPAT_JEDEC_SPI_NOR))) |
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.
even tho this soc is the only in tree usage of it, we don't want to break behavior for out of tree boards and socs, therefore this should also be part of the Kconfig of riscv.
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.
Maybe update arch/riscv/Kconfig like:
DT_CHOSEN_Z_FLASH := zephyr,flash
DT_COMPAT_JEDEC_SPI_NOR := jedec,spi-nor
+DT_COMPAT_LITEX_SPI_LITESPI := litex,spi-litespi
DT_CHOSEN_FLASH_NODE := $(dt_chosen_path,$(DT_CHOSEN_Z_FLASH))
DT_CHOSEN_FLASH_PARENT := $(dt_node_parent,$(DT_CHOSEN_FLASH_NODE))
config FLASH_SIZE
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_FLASH),0,K) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),soc-nv-flash))
+ default $(dt_node_reg_size_int,$(DT_CHOSEN_FLASH_PARENT),9,K) if (XIP && $(dt_node_has_compat,$(DT_CHOSEN_FLASH_PARENT),$(DT_COMPAT_LITEX_SPI_LITESPI)))
default $(dt_node_reg_size_int,$(DT_CHOSEN_FLASH_PARENT),1,K) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),$(DT_COMPAT_JEDEC_SPI_NOR)))
config FLASH_BASE_ADDRESS
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH)) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),soc-nv-flash))
+ default $(dt_node_reg_addr_hex,$(DT_CHOSEN_FLASH_PARENT),9) if (XIP && $(dt_node_has_compat,$(DT_CHOSEN_FLASH_PARENT),$(DT_COMPAT_LITEX_SPI_LITESPI)))
default $(dt_node_reg_addr_hex,$(DT_CHOSEN_FLASH_PARENT),1) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),$(DT_COMPAT_JEDEC_SPI_NOR)))
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.
modified per the recommendation.
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.
Isn't this already handled by both of these symbols' default values when used in conjunction with zephyr,flash
(with XIP
being y-selected) in the chosen
node?
950c7fc
to
1a56797
Compare
Move the logic for determining flash base address and size from the RISC-V common linker script to Kconfig. The new Kconfig options CONFIG_FLASH_BASE_ADDRESS and CONFIG_FLASH_SIZE are now the source of truth for the linker script. These options are given default values derived from the devicetree, supporting both "soc-nv-flash", "jedec,spi-nor", and "litex,spi-litespi" flash types. This change simplifies the linker script and consolidates the flash geometry configuration within the Kconfig system. Signed-off-by: Firas Sammoura <[email protected]>
1a56797
to
a7335a3
Compare
|
#endif | ||
|
||
#endif /* DT_NODE_HAS_COMPAT_STATUS */ | ||
#endif /* ROM_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.
Looks like this comment is wrong?
#endif /* ROM_SIZE*/ | |
#endif /* CONFIG_XIP */ |
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_FLASH),0,K) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),soc-nv-flash)) | ||
default $(dt_node_reg_size_int,$(DT_CHOSEN_FLASH_PARENT),9,K) if (XIP && $(dt_node_has_compat,$(DT_CHOSEN_FLASH_PARENT),$(DT_COMPAT_LITEX_SPI_LITESPI))) | ||
default $(dt_node_reg_size_int,$(DT_CHOSEN_FLASH_PARENT),1,K) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),$(DT_COMPAT_JEDEC_SPI_NOR))) | ||
|
||
config FLASH_BASE_ADDRESS | ||
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH)) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),soc-nv-flash)) | ||
default $(dt_node_reg_addr_hex,$(DT_CHOSEN_FLASH_PARENT),9) if (XIP && $(dt_node_has_compat,$(DT_CHOSEN_FLASH_PARENT),$(DT_COMPAT_LITEX_SPI_LITESPI))) | ||
default $(dt_node_reg_addr_hex,$(DT_CHOSEN_FLASH_PARENT),1) if (XIP && $(dt_chosen_has_compat,$(DT_CHOSEN_Z_FLASH),$(DT_COMPAT_JEDEC_SPI_NOR))) |
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.
the reg-name ("flash_mmap") has to be checked. The position is completely irrelevant.
in Litex this changed already a few times and it also depends on the configuration.
Also that prop might not be used drom the litex litespi driver in tree, but out of tree users could have also used it for others.
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.
was added here: #73482 for more context
Move the logic for determining flash base address and size from the RISC-V common linker script to Kconfig.
The new Kconfig options CONFIG_FLASH_BASE_ADDRESS and CONFIG_FLASH_SIZE are now the source of truth for the linker script. These options are given default values derived from the devicetree, supporting both "soc-nv-flash" and "jedec,spi-nor" flash types.
SoC-specific defaults for litex_vexriscv with JEDEC SPI NOR flash have also been added.
This change simplifies the linker script and consolidates the flash geometry configuration within the Kconfig system.