1# SPDX-License-Identifier: Apache-2.0
2
3config SOC_FLASH_MCUX
4	bool "MCUX flash shim driver"
5	depends on (HAS_MCUX_FTFX || HAS_MCUX_IAP)
6	select FLASH_HAS_PAGE_LAYOUT
7	select FLASH_HAS_DRIVER_ENABLED
8	select MPU_ALLOW_FLASH_WRITE if ARM_MPU
9	help
10	  Enables the MCUX flash shim driver.
11	  WARNING: This driver will disable the system interrupts for
12	  the duration of the flash erase/write operations. This will
13	  have an impact on the overall system performance - whether
14	  this is acceptable or not will depend on the use case.
15
16if SOC_FLASH_MCUX
17
18config CHECK_BEFORE_READING
19	bool "Verify area before reading it"
20	default y if SOC_SERIES_LPC55XXX
21	help
22	  Do a margin check flash command before reading an area.
23	  This feature prevents erroneous/forbidden reading. Some ECC enabled
24	  devices will crash when reading an erased or wrongly programmed area.
25
26endif # SOC_FLASH_MCUX
27
28if HAS_MCUX_FLEXSPI
29
30config FLASH_MCUX_FLEXSPI_NOR
31	bool "MCUX FlexSPI NOR driver"
32	select FLASH_HAS_PAGE_LAYOUT
33	select FLASH_HAS_DRIVER_ENABLED
34	select MEMC
35	select MEMC_MCUX_FLEXSPI
36
37config FLASH_MCUX_FLEXSPI_MX25UM51345G
38	bool "MCUX FlexSPI MX25UM51345G driver"
39	select FLASH_HAS_PAGE_LAYOUT
40	select FLASH_HAS_DRIVER_ENABLED
41	select MEMC
42	select MEMC_MCUX_FLEXSPI
43
44config FLASH_MCUX_FLEXSPI_NOR_WRITE_BUFFER
45	bool "MCUX FlexSPI NOR write RAM buffer"
46	default y
47	depends on (FLASH_MCUX_FLEXSPI_NOR || FLASH_MCUX_FLEXSPI_MX25UM51345G)
48	help
49	  Copy the data to a RAM buffer before writing it to the flash.
50	  This prevents faults when the data to write would be located on the
51	  flash itself.
52
53config FLASH_MCUX_FLEXSPI_XIP
54	bool "MCUX FlexSPI flash access with xip"
55	depends on MEMC_MCUX_FLEXSPI
56	depends on (CODE_FLEXSPI || CODE_FLEXSPI2 || SOC_SERIES_IMX_RT6XX)
57	select XIP
58	help
59	  Allows using the flash API while running in XIP.
60	  WARNING: It is possible to overwrite the running application itself.
61
62if FLASH_MCUX_FLEXSPI_XIP
63
64choice FLASH_MCUX_FLEXSPI_XIP_MEM_TARGET
65	prompt "FlexSPI drivers relocation target"
66	default FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
67	help
68	  Select the location to run the FlexSPI drivers when using
69	  the flash API.
70
71config FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
72	bool "ITCM"
73	select CODE_DATA_RELOCATION
74
75config FLASH_MCUX_FLEXSPI_XIP_MEM_SRAM
76	bool "SRAM"
77	select CODE_DATA_RELOCATION_SRAM
78
79endchoice
80
81config FLASH_MCUX_FLEXSPI_XIP_MEM
82	string
83	default "ITCM" if FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
84	default "SRAM" if FLASH_MCUX_FLEXSPI_XIP_MEM_SRAM
85
86endif # FLASH_MCUX_FLEXSPI_XIP
87
88endif # HAS_MCUX_FLEXSPI
89