1# Copyright (c) 2018 Savoir-Faire Linux.
2# Copyright (c) 2024 Nordic Semiconductor ASA
3#
4# SPDX-License-Identifier: Apache-2.0
5
6menuconfig SPI_NOR
7	bool "SPI NOR Flash"
8	default y
9	depends on DT_HAS_JEDEC_SPI_NOR_ENABLED
10	select FLASH_HAS_DRIVER_ENABLED
11	select FLASH_HAS_EXPLICIT_ERASE
12	select FLASH_HAS_PAGE_LAYOUT
13	select FLASH_JESD216
14	select FLASH_HAS_EX_OP
15	select SPI
16
17if SPI_NOR
18
19choice SPI_NOR_SFDP
20	prompt "Source for Serial Flash Discoverable Parameters"
21	default SPI_NOR_SFDP_MINIMAL
22
23config SPI_NOR_SFDP_MINIMAL
24	bool "Fixed flash configuration"
25	help
26	  Synthesize a minimal configuration assuming 256 By page size (or as
27	  set by the page-size devicetree property) and
28	  standard 4 KiBy and 64 KiBy erase instructions.  Requires the size and
29	  jedec-id properties in the devicetree jedec,spi-nor node.
30
31config SPI_NOR_SFDP_DEVICETREE
32	bool "Basic Flash Parameters from devicetree node"
33	help
34	  The JESD216 Basic Flash Parameters table must be provided in the
35	  sfdp-bfp property in devicetree.  The size and jedec-id properties are
36	  also required.
37
38config SPI_NOR_SFDP_RUNTIME
39	bool "Read flash parameters at runtime"
40	help
41	  Read all flash device characteristics from the device at runtime.
42	  This option is the most flexible as it should provide functionality
43	  for all supported JESD216-compatible devices.
44
45endchoice
46
47config SPI_NOR_INIT_PRIORITY
48	int "Init priority"
49	default 80
50	help
51	  Device driver initialization priority.
52	  Device is connected to SPI bus, it has to
53	  be initialized after SPI driver.
54
55config SPI_NOR_CS_WAIT_DELAY
56	int "Delay time in us"
57	default 0
58	help
59	  This is the wait delay (in us) to allow for CS switching to take effect
60
61config SPI_NOR_SLEEP_WHILE_WAITING_UNTIL_READY
62	bool "Sleep while waiting for flash operations to complete"
63	default y
64	help
65	  Flash operations can take anywhere from 1ms to 240 seconds to
66	  complete. Enabling this option adds a delay between polls on the
67	  status register for slow operations. Disabling this option can
68	  result in significant flash savings if this driver is the only user
69	  of "k_sleep". This can be the case when building as a bootloader.
70
71config SPI_NOR_SLEEP_ERASE_MS
72	int "Delay between polls while waiting for an erase operation in ms"
73	default 50
74	depends on SPI_NOR_SLEEP_WHILE_WAITING_UNTIL_READY
75	help
76	  The delay between polling while waiting for the flash to finish
77	  an erase operation.
78
79
80config SPI_NOR_FLASH_LAYOUT_PAGE_SIZE
81	int "Page size to use for FLASH_LAYOUT feature"
82	default 65536
83	help
84	  When CONFIG_FLASH_PAGE_LAYOUT is used this driver will support
85	  that API.  By default the page size corresponds to the block
86	  size (65536).  Other options include the 32K-byte erase size
87	  (32768), the sector size (4096), or any non-zero multiple of the
88	  sector size.
89
90config SPI_NOR_ACTIVE_DWELL_MS
91	int "Dwell period (ms) after last use to stay in active mode"
92	depends on PM_DEVICE_RUNTIME
93	default 10
94	help
95	  Flash accesses commonly occur in bursts, where entering and exiting DPD
96	  mode between each access adds significantly to the total operation time.
97	  This option controls how long to remain in active mode after each API
98	  call, eliminating the active->idle->active transition sequence if another
99	  transaction occurs before the dwell period expires.
100
101endif # SPI_NOR
102