1# SPDX-License-Identifier: Apache-2.0
2
3config SOC_FLASH_MCUX
4	bool "MCUX flash shim driver"
5	default y
6	depends on DT_HAS_NXP_KINETIS_FTFA_ENABLED || \
7		   DT_HAS_NXP_KINETIS_FTFE_ENABLED || \
8		   DT_HAS_NXP_KINETIS_FTFL_ENABLED || \
9		   DT_HAS_NXP_IAP_FMC55_ENABLED || \
10		   DT_HAS_NXP_IAP_FMC553_ENABLED
11	select FLASH_HAS_PAGE_LAYOUT
12	select FLASH_HAS_DRIVER_ENABLED
13	select MPU_ALLOW_FLASH_WRITE if ARM_MPU
14	help
15	  Enables the MCUX flash shim driver.
16	  WARNING: This driver will disable the system interrupts for
17	  the duration of the flash erase/write operations. This will
18	  have an impact on the overall system performance - whether
19	  this is acceptable or not will depend on the use case.
20
21if SOC_FLASH_MCUX
22
23config CHECK_BEFORE_READING
24	bool "Verify area before reading it"
25	default y if SOC_SERIES_LPC55XXX
26	help
27	  Do a margin check flash command before reading an area.
28	  This feature prevents erroneous/forbidden reading. Some ECC enabled
29	  devices will crash when reading an erased or wrongly programmed area.
30
31endif # SOC_FLASH_MCUX
32
33if DT_HAS_NXP_IMX_FLEXSPI_ENABLED
34
35menu "Flexspi flash driver"
36
37config FLASH_MCUX_FLEXSPI_NOR
38	bool "MCUX FlexSPI NOR driver"
39	default y
40	depends on DT_HAS_NXP_IMX_FLEXSPI_NOR_ENABLED
41	select FLASH_HAS_PAGE_LAYOUT
42	select FLASH_HAS_DRIVER_ENABLED
43	select FLASH_JESD216
44	select MEMC
45	select MEMC_MCUX_FLEXSPI
46
47config FLASH_MCUX_FLEXSPI_MX25UM51345G
48	bool "MCUX FlexSPI MX25UM51345G driver"
49	default y
50	depends on DT_HAS_NXP_IMX_FLEXSPI_MX25UM51345G_ENABLED
51	select FLASH_HAS_PAGE_LAYOUT
52	select FLASH_HAS_DRIVER_ENABLED
53	select MEMC
54	select MEMC_MCUX_FLEXSPI
55
56config FLASH_MCUX_FLEXSPI_HYPERFLASH
57	bool "MCUX FlexSPI HYPERFLASH driver"
58	default y
59	depends on DT_HAS_NXP_IMX_FLEXSPI_HYPERFLASH_ENABLED
60	select FLASH_HAS_PAGE_LAYOUT
61	select FLASH_HAS_DRIVER_ENABLED
62	select MEMC
63	select MEMC_MCUX_FLEXSPI
64
65endmenu
66
67if FLASH_MCUX_FLEXSPI_MX25UM51345G
68
69choice FLASH_MCUX_FLEXSPI_MX25UM51345G_OPI_MODE
70	prompt "FlexSPI MX25UM51345G OPI mode"
71	default FLASH_MCUX_FLEXSPI_MX25UM51345G_OPI_DTR
72	help
73	  Select the MX25UM51345G octal flash operation mode(Octal I/O STR
74	  or Octal I/O DTR).
75
76config FLASH_MCUX_FLEXSPI_MX25UM51345G_OPI_STR
77	bool "STR"
78
79config FLASH_MCUX_FLEXSPI_MX25UM51345G_OPI_DTR
80	bool "DTR"
81
82endchoice
83
84endif # FLASH_MCUX_FLEXSPI_MX25UM51345G
85
86config FLASH_MCUX_FLEXSPI_NOR_WRITE_BUFFER
87	bool "MCUX FlexSPI NOR write RAM buffer"
88	default y
89	depends on (FLASH_MCUX_FLEXSPI_NOR || FLASH_MCUX_FLEXSPI_MX25UM51345G)
90	help
91	  Copy the data to a RAM buffer before writing it to the flash.
92	  This prevents faults when the data to write would be located on the
93	  flash itself.
94
95config FLASH_MCUX_FLEXSPI_HYPERFLASH_WRITE_BUFFER
96	bool "MCUX FlexSPI HYPERFLASH write RAM buffer"
97	default y
98	depends on FLASH_MCUX_FLEXSPI_HYPERFLASH
99	help
100	  Copy the data to a RAM buffer before writing it to the flash.
101	  This prevents faults when the data to write would be located on the
102	  flash itself.
103
104if FLASH_MCUX_FLEXSPI_XIP
105
106choice FLASH_MCUX_FLEXSPI_XIP_MEM_TARGET
107	prompt "FlexSPI drivers relocation target"
108	default FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
109	help
110	  Select the location to run the FlexSPI drivers when using
111	  the flash API.
112
113config FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
114	bool "ITCM"
115	select CODE_DATA_RELOCATION
116
117config FLASH_MCUX_FLEXSPI_XIP_MEM_SRAM
118	bool "RAM"
119	select CODE_DATA_RELOCATION_SRAM
120
121endchoice
122
123config FLASH_MCUX_FLEXSPI_XIP_MEM
124	string
125	default "ITCM" if FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
126	default "RAM" if FLASH_MCUX_FLEXSPI_XIP_MEM_SRAM
127
128endif # FLASH_MCUX_FLEXSPI_XIP
129
130endif # HAS_MCUX_FLEXSPI
131