Skip to content

Commit 6d5cdbb

Browse files
niedzwiecki-dawidkartben
authored andcommitted
drivers: flash: add andes qspi xip flash driver
Add a flash driver that is used to perform flash operations on a flash chip that is connected to an Andes QSPI controller and is used for XIP mode. The driver is as small as possible, because necessary code has to be placed in RAM. It is not possible to fetch code from flash while performing erase/write operations. Signed-off-by: Dawid Niedzwiecki <[email protected]>
1 parent ddc43f0 commit 6d5cdbb

File tree

5 files changed

+577
-0
lines changed

5 files changed

+577
-0
lines changed

drivers/flash/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ zephyr_library_sources_ifdef(CONFIG_USERSPACE flash_handlers.c)
2727
zephyr_library_sources_ifdef(CONFIG_FLASH_ADI_MAX32_SPIXF flash_max32_spixf_nor.c)
2828
zephyr_library_sources_ifdef(CONFIG_FLASH_AMBIQ flash_ambiq.c)
2929
zephyr_library_sources_ifdef(CONFIG_FLASH_ANDES_QSPI flash_andes_qspi.c)
30+
zephyr_library_sources_ifdef(CONFIG_FLASH_ANDES_QSPI_XIP flash_andes_qspi_xip.c)
3031
zephyr_library_sources_ifdef(CONFIG_FLASH_CAD_QSPI_NOR flash_cadence_qspi_nor.c flash_cadence_qspi_nor_ll.c)
3132
zephyr_library_sources_ifdef(CONFIG_FLASH_CDNS_NAND flash_cadence_nand.c flash_cadence_nand_ll.c)
3233
zephyr_library_sources_ifdef(CONFIG_FLASH_INFINEON_CAT1 flash_ifx_cat1.c)
@@ -166,3 +167,6 @@ if(CONFIG_SOC_FLASH_RENESAS_RA_HP)
166167
zephyr_library_sources(soc_flash_renesas_ra_hp.c)
167168
zephyr_library_sources_ifdef(CONFIG_FLASH_EX_OP_ENABLED soc_flash_renesas_ra_hp_ex_op.c)
168169
endif()
170+
171+
# Do not use prologue and epilogue code that uses library function calls
172+
zephyr_library_compile_options_ifdef(CONFIG_FLASH_ANDES_QSPI_XIP -mno-save-restore)

drivers/flash/Kconfig.andes

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ config FLASH_ANDES_QSPI_SFDP_RUNTIME
3939

4040
endchoice
4141

42+
endif
43+
44+
config FLASH_ANDES_QSPI_XIP
45+
bool "Andes FLASH driver for XIP chip"
46+
default y
47+
depends on DT_HAS_ANDESTECH_QSPI_NOR_XIP_ENABLED
48+
select FLASH_HAS_PAGE_LAYOUT
49+
select FLASH_HAS_DRIVER_ENABLED
50+
select FLASH_HAS_EXPLICIT_ERASE
51+
depends on XIP
52+
depends on !SPI_NOR
53+
depends on ARCH_HAS_RAMFUNC_SUPPORT
54+
depends on !SMP
55+
help
56+
Enable minimalistic driver for Andes QSPI that can be used with a
57+
flash chip that is used for XIP execution. The driver places necessary
58+
code in RAM, because code can not be fetched from flash while
59+
performing erase/write operations.
60+
61+
if FLASH_ANDES_QSPI || FLASH_ANDES_QSPI_XIP
62+
4263
config FLASH_ANDES_QSPI_INIT_PRIORITY
4364
int
4465
default 80
@@ -56,3 +77,12 @@ config FLASH_ANDES_QSPI_LAYOUT_PAGE_SIZE
5677
sector size.
5778

5879
endif
80+
81+
if FLASH_ANDES_QSPI_XIP
82+
83+
config FLASH_ANDES_QSPI_XIP_COUNT_REGS
84+
bool "Use separated write/read count registers"
85+
help
86+
The Andes qspi module has separated write/read count registers.
87+
88+
endif

drivers/flash/flash_andes_qspi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#define TFMAT_SLVMODE_MSK BIT(2)
4747
#define TFMAT_DATA_MERGE_MSK BIT(7)
4848
#define TFMAT_DATA_LEN_MSK GENMASK(12, 8)
49+
#define TFMAT_ADDR_LEN_MSK GENMASK(17, 16)
4950

5051
/* Field mask of SPI transfer control register */
5152
#define TCTRL_RD_TCNT_OFFSET (0)

0 commit comments

Comments
 (0)