1# SPDX-License-Identifier: Apache-2.0
2
3zephyr_syscall_header_ifdef(
4  CONFIG_FLASH_SIMULATOR
5  ${ZEPHYR_BASE}/include/zephyr/drivers/flash/flash_simulator.h
6)
7
8zephyr_syscall_header_ifdef(
9  CONFIG_NORDIC_QSPI_NOR
10  ${ZEPHYR_BASE}/include/zephyr/drivers/flash/nrf_qspi_nor.h
11)
12
13zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/flash.h)
14
15zephyr_library()
16
17zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_CC13XX_CC26XX soc_flash_cc13xx_cc26xx.c)
18zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_TELINK_B91 soc_flash_b91.c)
19zephyr_library_sources_ifdef(CONFIG_SPI_NOR spi_nor.c)
20zephyr_library_sources_ifdef(CONFIG_NORDIC_QSPI_NOR nrf_qspi_nor.c)
21if(CONFIG_FLASH_SIMULATOR)
22  zephyr_library_sources(flash_simulator.c)
23  if(CONFIG_NATIVE_LIBRARY)
24    target_sources(native_simulator INTERFACE flash_simulator_native.c)
25  elseif(CONFIG_ARCH_POSIX)
26    zephyr_library_sources(flash_simulator_native.c)
27  endif()
28endif()
29zephyr_library_sources_ifdef(CONFIG_SPI_FLASH_AT45 spi_flash_at45.c)
30zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_ITE_IT8XXX2 flash_ite_it8xxx2.c)
31zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_NRF soc_flash_nrf.c)
32zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_MCUX soc_flash_mcux.c)
33zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_LPC soc_flash_lpc.c)
34zephyr_library_sources_ifdef(CONFIG_FLASH_PAGE_LAYOUT flash_page_layout.c)
35zephyr_library_sources_ifdef(CONFIG_USERSPACE flash_handlers.c)
36zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_SAM0 flash_sam0.c)
37zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_SAM flash_sam.c)
38zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_NIOS2_QSPI soc_flash_nios2_qspi.c)
39zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_GECKO flash_gecko.c)
40zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_RV32M1 soc_flash_rv32m1.c)
41zephyr_library_sources_ifdef(CONFIG_FLASH_NPCX_FIU_QSPI flash_npcx_fiu_qspi.c)
42zephyr_library_sources_ifdef(CONFIG_FLASH_NPCX_FIU_NOR flash_npcx_fiu_nor.c)
43zephyr_library_sources_ifdef(CONFIG_FLASH_STM32_QSPI flash_stm32_qspi.c)
44zephyr_library_sources_ifdef(CONFIG_FLASH_STM32_OSPI flash_stm32_ospi.c)
45zephyr_library_sources_ifdef(CONFIG_FLASH_MCUX_FLEXSPI_MX25UM51345G flash_mcux_flexspi_mx25um51345g.c)
46zephyr_library_sources_ifdef(CONFIG_FLASH_MCUX_FLEXSPI_NOR flash_mcux_flexspi_nor.c)
47zephyr_library_sources_ifdef(CONFIG_FLASH_MCUX_FLEXSPI_HYPERFLASH flash_mcux_flexspi_hyperflash.c)
48zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_ESP32 flash_esp32.c)
49zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_SMARTBOND flash_smartbond.c)
50zephyr_library_sources_ifdef(CONFIG_FLASH_CAD_QSPI_NOR flash_cadence_qspi_nor.c flash_cadence_qspi_nor_ll.c)
51zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_XMC4XXX soc_flash_xmc4xxx.c)
52zephyr_library_sources_ifdef(CONFIG_FLASH_RPI_PICO flash_rpi_pico.c)
53zephyr_library_sources_ifdef(CONFIG_FLASH_ANDES_QSPI flash_andes_qspi.c)
54zephyr_library_sources_ifdef(CONFIG_FLASH_AMBIQ flash_ambiq.c)
55zephyr_library_sources_ifdef(CONFIG_FLASH_CDNS_NAND flash_cadence_nand.c flash_cadence_nand_ll.c)
56
57if(CONFIG_FLASH_MCUX_FLEXSPI_XIP)
58  dt_chosen(chosen_flash PROPERTY "zephyr,flash")
59  dt_prop(compat_flash PATH ${chosen_flash} PROPERTY compatible)
60  if(compat_flash MATCHES "nxp,imx-flexspi-nor")
61	  zephyr_code_relocate(FILES flash_mcux_flexspi_nor.c LOCATION ${CONFIG_FLASH_MCUX_FLEXSPI_XIP_MEM}_TEXT)
62	  zephyr_code_relocate(FILES jesd216.c LOCATION ${CONFIG_FLASH_MCUX_FLEXSPI_XIP_MEM}_TEXT)
63  elseif(compat_flash MATCHES "nxp,imx-flexspi-mx25um51345g")
64	  zephyr_code_relocate(FILES flash_mcux_flexspi_mx25um51345g.c LOCATION ${CONFIG_FLASH_MCUX_FLEXSPI_XIP_MEM}_TEXT)
65  elseif(compat_flash MATCHES "nxp,imx-flexspi-hyperflash")
66    zephyr_code_relocate(FILES flash_mcux_flexspi_hyperflash.c LOCATION ${CONFIG_FLASH_MCUX_FLEXSPI_XIP_MEM}_TEXT)
67  endif()
68endif()
69
70if(CONFIG_SOC_FLASH_STM32)
71  if(CONFIG_SOC_SERIES_STM32H7X)
72    zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32H7_FLASH_CONTROLLER_ENABLED flash_stm32h7x.c)
73  elseif(CONFIG_SOC_SERIES_STM32WBAX)
74    if(CONFIG_BT_STM32WBA)
75      # BLE is enabled. Use implementation over Flash Manager for coexistence wit RF activities
76      zephyr_library_sources(flash_stm32wba_fm.c)
77    else()
78      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32_FLASH_CONTROLLER_ENABLED flash_stm32.c flash_stm32wbax.c)
79    endif()
80  else()
81    if(CONFIG_DT_HAS_ST_STM32_FLASH_CONTROLLER_ENABLED)
82      zephyr_library_sources(flash_stm32.c)
83      zephyr_library_sources_ifdef(CONFIG_FLASH_EX_OP_ENABLED flash_stm32_ex_op.c)
84
85      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32F1_FLASH_CONTROLLER_ENABLED flash_stm32f1x.c)
86      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32F2_FLASH_CONTROLLER_ENABLED flash_stm32f2x.c)
87      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32F4_FLASH_CONTROLLER_ENABLED flash_stm32f4x.c)
88      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32F7_FLASH_CONTROLLER_ENABLED flash_stm32f7x.c)
89      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32L4_FLASH_CONTROLLER_ENABLED flash_stm32l4x.c)
90      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32L5_FLASH_CONTROLLER_ENABLED flash_stm32l5x.c)
91      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32WB_FLASH_CONTROLLER_ENABLED flash_stm32wbx.c)
92      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32G0_FLASH_CONTROLLER_ENABLED flash_stm32g0x.c)
93      zephyr_library_sources_ifdef(CONFIG_DT_HAS_ST_STM32G4_FLASH_CONTROLLER_ENABLED flash_stm32g4x.c)
94    endif()
95  endif()
96endif()
97
98if(CONFIG_SOC_FLASH_GD32)
99  zephyr_library_sources(flash_gd32.c)
100
101  zephyr_library_sources_ifdef(CONFIG_GD32_NV_FLASH_V1 flash_gd32_v1.c)
102  zephyr_library_sources_ifdef(CONFIG_GD32_NV_FLASH_V2 flash_gd32_v2.c)
103  zephyr_library_sources_ifdef(CONFIG_GD32_NV_FLASH_V3 flash_gd32_v3.c)
104endif()
105
106zephyr_library_include_directories_ifdef(
107  CONFIG_FLASH_MCUX_FLEXSPI_NOR
108  ${ZEPHYR_BASE}/drivers/memc
109)
110
111zephyr_library_include_directories_ifdef(
112  CONFIG_FLASH_MCUX_FLEXSPI_MX25UM51345G
113  ${ZEPHYR_BASE}/drivers/memc
114)
115
116zephyr_library_include_directories_ifdef(
117  CONFIG_FLASH_MCUX_FLEXSPI_HYPERFLASH
118  ${ZEPHYR_BASE}/drivers/memc
119)
120
121zephyr_library_sources_ifdef(CONFIG_FLASH_NXP_S32_QSPI_NOR flash_nxp_s32_qspi_nor.c)
122zephyr_library_include_directories_ifdef(
123  CONFIG_FLASH_NXP_S32_QSPI_NOR
124  ${ZEPHYR_BASE}/drivers/memc
125)
126
127zephyr_library_sources_ifdef(CONFIG_FLASH_SHELL flash_shell.c)
128zephyr_library_sources_ifdef(CONFIG_FLASH_JESD216 jesd216.c)
129zephyr_library_sources_ifdef(CONFIG_FLASH_INFINEON_CAT1 flash_ifx_cat1.c)
130zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_NUMAKER soc_flash_numaker.c)
131