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 MEMC
44	select MEMC_MCUX_FLEXSPI
45
46config FLASH_MCUX_FLEXSPI_MX25UM51345G
47	bool "MCUX FlexSPI MX25UM51345G driver"
48	default y
49	depends on DT_HAS_NXP_IMX_FLEXSPI_MX25UM51345G_ENABLED
50	select FLASH_HAS_PAGE_LAYOUT
51	select FLASH_HAS_DRIVER_ENABLED
52	select MEMC
53	select MEMC_MCUX_FLEXSPI
54
55config FLASH_MCUX_FLEXSPI_HYPERFLASH
56	bool "MCUX FlexSPI HYPERFLASH driver"
57	default y
58	depends on DT_HAS_NXP_IMX_FLEXSPI_HYPERFLASH_ENABLED
59	select FLASH_HAS_PAGE_LAYOUT
60	select FLASH_HAS_DRIVER_ENABLED
61	select MEMC
62	select MEMC_MCUX_FLEXSPI
63
64endmenu
65
66if FLASH_MCUX_FLEXSPI_MX25UM51345G
67
68choice FLASH_MCUX_FLEXSPI_MX25UM51345G_OPI_MODE
69	prompt "FlexSPI MX25UM51345G OPI mode"
70	default FLASH_MCUX_FLEXSPI_MX25UM51345G_OPI_DTR
71	help
72	  Select the MX25UM51345G octal flash operation mode(Octal I/O STR
73	  or Octal I/O DTR).
74
75config FLASH_MCUX_FLEXSPI_MX25UM51345G_OPI_STR
76	bool "STR"
77
78config FLASH_MCUX_FLEXSPI_MX25UM51345G_OPI_DTR
79	bool "DTR"
80
81endchoice
82
83endif # FLASH_MCUX_FLEXSPI_MX25UM51345G
84
85config FLASH_MCUX_FLEXSPI_NOR_WRITE_BUFFER
86	bool "MCUX FlexSPI NOR write RAM buffer"
87	default y
88	depends on (FLASH_MCUX_FLEXSPI_NOR || FLASH_MCUX_FLEXSPI_MX25UM51345G)
89	help
90	  Copy the data to a RAM buffer before writing it to the flash.
91	  This prevents faults when the data to write would be located on the
92	  flash itself.
93
94config FLASH_MCUX_FLEXSPI_HYPERFLASH_WRITE_BUFFER
95	bool "MCUX FlexSPI HYPERFLASH write RAM buffer"
96	default y
97	depends on FLASH_MCUX_FLEXSPI_HYPERFLASH
98	help
99	  Copy the data to a RAM buffer before writing it to the flash.
100	  This prevents faults when the data to write would be located on the
101	  flash itself.
102
103if FLASH_MCUX_FLEXSPI_XIP
104
105choice FLASH_MCUX_FLEXSPI_XIP_MEM_TARGET
106	prompt "FlexSPI drivers relocation target"
107	default FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
108	help
109	  Select the location to run the FlexSPI drivers when using
110	  the flash API.
111
112config FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
113	bool "ITCM"
114	select CODE_DATA_RELOCATION
115
116config FLASH_MCUX_FLEXSPI_XIP_MEM_SRAM
117	bool "RAM"
118	select CODE_DATA_RELOCATION_SRAM
119
120endchoice
121
122config FLASH_MCUX_FLEXSPI_XIP_MEM
123	string
124	default "ITCM" if FLASH_MCUX_FLEXSPI_XIP_MEM_ITCM
125	default "RAM" if FLASH_MCUX_FLEXSPI_XIP_MEM_SRAM
126
127endif # FLASH_MCUX_FLEXSPI_XIP
128
129endif # HAS_MCUX_FLEXSPI
130