1 | /** @file
|
---|
2 | SPI NOR Flash JEDEC Serial Flash Discoverable Parameters (SFDP)
|
---|
3 | header file.
|
---|
4 |
|
---|
5 | Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
|
---|
6 |
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | @par Revision Reference:
|
---|
10 | - JEDEC Standard, JESD216F.02
|
---|
11 | https://www.jedec.org/document_search?search_api_views_fulltext=JESD216
|
---|
12 |
|
---|
13 | @par Glossary:
|
---|
14 | - SFDP - Serial Flash Discoverable Parameters
|
---|
15 | - PTP - Parameter Table Pointer
|
---|
16 | **/
|
---|
17 |
|
---|
18 | #ifndef SPI_NOR_FLASH_JEDEC_H_
|
---|
19 | #define SPI_NOR_FLASH_JEDEC_H_
|
---|
20 |
|
---|
21 | #include <Base.h>
|
---|
22 |
|
---|
23 | #define SFDP_HEADER_SIGNATURE 0x50444653
|
---|
24 | #define SFDP_SUPPORTED_MAJOR_REVISION 0x1ul
|
---|
25 |
|
---|
26 | /// JEDEC Basic Flash Parameter Header
|
---|
27 | #define SFDP_BASIC_PARAMETER_ID_LSB 0x00
|
---|
28 | #define SFDP_BASIC_PARAMETER_ID_MSB 0xFF
|
---|
29 |
|
---|
30 | ///
|
---|
31 | /// JDEC Sector Map Parameter Header and Table
|
---|
32 | ///
|
---|
33 | #define SFDP_SECTOR_MAP_PARAMETER_ID_LSB 0x81
|
---|
34 | #define SFDP_FOUR_BYTE_ADDRESS_INSTRUCTION_LSB 0x84
|
---|
35 | #define SFDP_SECTOR_MAP_PARAMETER_ID_MSB 0xFF
|
---|
36 |
|
---|
37 | #define SFDP_FLASH_MEMORY_DENSITY_4GBIT 0x80000000
|
---|
38 |
|
---|
39 | #pragma pack (1)
|
---|
40 | typedef struct _SFDP_HEADER {
|
---|
41 | UINT32 Signature;
|
---|
42 | UINT32 MinorRev : 8;
|
---|
43 | UINT32 MajorRev : 8;
|
---|
44 | UINT32 NumParameterHeaders : 8;
|
---|
45 | UINT32 AccessProtocol : 8;
|
---|
46 | } SFDP_HEADER;
|
---|
47 |
|
---|
48 | typedef struct _SFDP_PARAMETER_HEADER {
|
---|
49 | UINT32 IdLsb : 8;
|
---|
50 | UINT32 MinorRev : 8;
|
---|
51 | UINT32 MajorRev : 8;
|
---|
52 | UINT32 Length : 8;
|
---|
53 | UINT32 TablePointer : 24;
|
---|
54 | UINT32 IdMsb : 8;
|
---|
55 | } SFDP_PARAMETER_HEADER;
|
---|
56 |
|
---|
57 | typedef struct _SFDP_BASIC_FLASH_PARAMETER {
|
---|
58 | // DWORD 1
|
---|
59 | UINT32 EraseSizes : 2;
|
---|
60 | UINT32 WriteGranularity : 1;
|
---|
61 | UINT32 VolatileStatusBlockProtect : 1;
|
---|
62 | UINT32 WriteEnableVolatileStatus : 1;
|
---|
63 | UINT32 Unused1Dw1 : 3;
|
---|
64 | UINT32 FourKEraseInstr : 8;
|
---|
65 | UINT32 FastRead112 : 1;
|
---|
66 | UINT32 AddressBytes : 2;
|
---|
67 | UINT32 DtrClocking : 1;
|
---|
68 | UINT32 FastRead122 : 1;
|
---|
69 | UINT32 FastRead144 : 1;
|
---|
70 | UINT32 FastRead114 : 1;
|
---|
71 | UINT32 Unused2Dw1 : 9;
|
---|
72 | // DWORD 2
|
---|
73 | UINT32 Density;
|
---|
74 | // DWORD 3
|
---|
75 | // Fast Read 144
|
---|
76 | UINT32 FastRead144Dummy : 5;
|
---|
77 | UINT32 FastRead144ModeClk : 3;
|
---|
78 | UINT32 FastRead144Instr : 8;
|
---|
79 | // Fast Read 114
|
---|
80 | UINT32 FastRead114Dummy : 5;
|
---|
81 | UINT32 FastRead114ModeClk : 3;
|
---|
82 | UINT32 FastRead114Instr : 8;
|
---|
83 | // DWORD 4
|
---|
84 | // Fast Read 112
|
---|
85 | UINT32 FastRead112Dummy : 5;
|
---|
86 | UINT32 FastRead112ModeClk : 3;
|
---|
87 | UINT32 FastRead112Instr : 8;
|
---|
88 | // Fast Read 122
|
---|
89 | UINT32 FastRead122Dummy : 5;
|
---|
90 | UINT32 FastRead122ModeClk : 3;
|
---|
91 | UINT32 FastRead122Instr : 8;
|
---|
92 | // DWORD 5
|
---|
93 | UINT32 FastRead222 : 1;
|
---|
94 | UINT32 Unused1Dw5 : 3;
|
---|
95 | UINT32 FastRead444 : 1;
|
---|
96 | UINT32 Unused2Dw5 : 27;
|
---|
97 | // DWORD 6
|
---|
98 | UINT32 UnusedDw6 : 16;
|
---|
99 | // Fast Read 222
|
---|
100 | UINT32 FastRead222Dummy : 5;
|
---|
101 | UINT32 FastRead222ModeClk : 3;
|
---|
102 | UINT32 FastRead222Instr : 8;
|
---|
103 | // DWORD 7
|
---|
104 | UINT32 UnusedDw7 : 16;
|
---|
105 | // Fast Read 444
|
---|
106 | UINT32 FastRead444Dummy : 5;
|
---|
107 | UINT32 FastRead444ModeClk : 3;
|
---|
108 | UINT32 FastRead444Instr : 8;
|
---|
109 | // DWORD 8
|
---|
110 | UINT32 Erase1Size : 8;
|
---|
111 | UINT32 Erase1Instr : 8;
|
---|
112 | UINT32 Erase2Size : 8;
|
---|
113 | UINT32 Erase2Instr : 8;
|
---|
114 | // DWORD 9
|
---|
115 | UINT32 Erase3Size : 8;
|
---|
116 | UINT32 Erase3Instr : 8;
|
---|
117 | UINT32 Erase4Size : 8;
|
---|
118 | UINT32 Erase4Instr : 8;
|
---|
119 | // DWORD 10
|
---|
120 | UINT32 EraseMultiplier : 4;
|
---|
121 | UINT32 Erase1Time : 7;
|
---|
122 | UINT32 Erase2Time : 7;
|
---|
123 | UINT32 Erase3Time : 7;
|
---|
124 | UINT32 Erase4Time : 7;
|
---|
125 | // DWORD 11
|
---|
126 | UINT32 ProgramMultiplier : 4;
|
---|
127 | UINT32 PageSize : 4;
|
---|
128 | UINT32 PPTime : 6;
|
---|
129 | UINT32 BPFirstTime : 5;
|
---|
130 | UINT32 BPAdditionalTime : 5;
|
---|
131 | UINT32 ChipEraseTime : 7;
|
---|
132 | UINT32 Unused1Dw11 : 1;
|
---|
133 | // DWORD 12
|
---|
134 | UINT32 ProgSuspendProhibit : 4;
|
---|
135 | UINT32 EraseSuspendProhibit : 4;
|
---|
136 | UINT32 Unused1Dw13 : 1;
|
---|
137 | UINT32 ProgResumeToSuspend : 4;
|
---|
138 | UINT32 ProgSuspendInProgressTime : 7;
|
---|
139 | UINT32 EraseResumeToSuspend : 4;
|
---|
140 | UINT32 EraseSuspendInProgressTime : 7;
|
---|
141 | UINT32 SuspendResumeSupported : 1;
|
---|
142 | // DWORD 13
|
---|
143 | UINT32 Unused13;
|
---|
144 | // DWORD 14
|
---|
145 | UINT32 Unused14;
|
---|
146 | // DWORD 15
|
---|
147 | UINT32 Unused15;
|
---|
148 | // DWORD 16
|
---|
149 | UINT32 Unused16;
|
---|
150 | // DWORD 17
|
---|
151 | UINT32 FastRead188Dummy : 5;
|
---|
152 | UINT32 FastRead188ModeClk : 3;
|
---|
153 | UINT32 FastRead188Instr : 8;
|
---|
154 | UINT32 FastRead118Dummy : 5;
|
---|
155 | UINT32 FastRead118ModeClk : 3;
|
---|
156 | UINT32 FastRead118Instr : 8;
|
---|
157 | //
|
---|
158 | // Don't care about remaining DWORDs
|
---|
159 | // DWORD 18 to DWORD 23
|
---|
160 | //
|
---|
161 | UINT32 Unused18;
|
---|
162 | UINT32 Unused19;
|
---|
163 | UINT32 Unused20;
|
---|
164 | UINT32 Unused21;
|
---|
165 | UINT32 Unused22;
|
---|
166 | UINT32 Unused23;
|
---|
167 | } SFDP_BASIC_FLASH_PARAMETER;
|
---|
168 | #pragma pack ()
|
---|
169 |
|
---|
170 | #define SPI_UNIFORM_4K_ERASE_SUPPORTED 0x01
|
---|
171 | #define SPI_UNIFORM_4K_ERASE_UNSUPPORTED 0x03
|
---|
172 |
|
---|
173 | ///
|
---|
174 | /// Number of address bytes opcode can support
|
---|
175 | ///
|
---|
176 | #define SPI_ADDR_3BYTE_ONLY 0x00
|
---|
177 | #define SPI_ADDR_3OR4BYTE 0x01
|
---|
178 | #define SPI_ADDR_4BYTE_ONLY 0x02
|
---|
179 |
|
---|
180 | #define SFDP_ERASE_TYPES_NUMBER 4
|
---|
181 | #define SFDP_ERASE_TYPE_1 0x0001
|
---|
182 | #define SFDP_ERASE_TYPE_2 0x0002
|
---|
183 | #define SFDP_ERASE_TYPE_3 0x0003
|
---|
184 | #define SFDP_ERASE_TYPE_4 0x0004
|
---|
185 |
|
---|
186 | ///
|
---|
187 | /// Read/Write Array Commands
|
---|
188 | ///
|
---|
189 | #define SPI_FLASH_READ 0x03
|
---|
190 | #define SPI_FLASH_READ_DUMMY 0x00
|
---|
191 | #define SPI_FLASH_READ_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
192 | #define SPI_FLASH_FAST_READ 0x0B
|
---|
193 | #define SPI_FLASH_FAST_READ_DUMMY 0x01
|
---|
194 | #define SPI_FLASH_FAST_READ_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
195 | #define SPI_FLASH_PP 0x02
|
---|
196 | #define SPI_FLASH_PP_DUMMY 0x00
|
---|
197 | #define SPI_FLASH_PP_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
198 | #define SPI_FLASH_PAGE_SIZE 256
|
---|
199 | #define SPI_FLASH_SE 0x20
|
---|
200 | #define SPI_FLASH_SE_DUMMY 0x00
|
---|
201 | #define SPI_FLASH_SE_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
202 | #define SPI_FLASH_BE32K 0x52
|
---|
203 | #define SPI_FLASH_BE32K_DUMMY 0x00
|
---|
204 | #define SPI_FLASH_BE32K_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
205 | #define SPI_FLASH_BE 0xD8
|
---|
206 | #define SPI_FLASH_BE_DUMMY 0x00
|
---|
207 | #define SPI_FLASH_BE_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
208 | #define SPI_FLASH_CE 0x60
|
---|
209 | #define SPI_FLASH_CE_DUMMY 0x00
|
---|
210 | #define SPI_FLASH_CE_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
211 | #define SPI_FLASH_RDID 0x9F
|
---|
212 | #define SPI_FLASH_RDID_DUMMY 0x00
|
---|
213 | #define SPI_FLASH_RDID_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
214 |
|
---|
215 | ///
|
---|
216 | /// Register Setting Commands
|
---|
217 | ///
|
---|
218 | #define SPI_FLASH_WREN 0x06
|
---|
219 | #define SPI_FLASH_WREN_DUMMY 0x00
|
---|
220 | #define SPI_FLASH_WREN_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
221 | #define SPI_FLASH_WRDI 0x04
|
---|
222 | #define SPI_FLASH_WRDI_DUMMY 0x00
|
---|
223 | #define SPI_FLASH_WRDI_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
224 | #define SPI_FLASH_RDSR 0x05
|
---|
225 | #define SPI_FLASH_RDSR_DUMMY 0x00
|
---|
226 | #define SPI_FLASH_RDSR_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
227 | #define SPI_FLASH_SR_NOT_WIP 0x0
|
---|
228 | #define SPI_FLASH_SR_WIP BIT0
|
---|
229 | #define SPI_FLASH_SR_WEL BIT1
|
---|
230 | #define SPI_FLASH_WRSR 0x01
|
---|
231 | #define SPI_FLASH_WRSR_DUMMY 0x00
|
---|
232 | #define SPI_FLASH_WRSR_ADDR_BYTES SPI_ADDR_3OR4BYTE
|
---|
233 | #define SPI_FLASH_WREN_50H 0x50
|
---|
234 | #define SPI_FLASH_RDSFDP 0x5A
|
---|
235 | #define SPI_FLASH_RDSFDP_DUMMY 0x01
|
---|
236 | #define SPI_FLASH_RDSFDP_ADDR_BYTES SPI_ADDR_3BYTE_ONLY
|
---|
237 | #define ERASE_TYPICAL_TIME_UNITS_MASK 0x60
|
---|
238 | #define ERASE_TYPICAL_TIME_BIT_POSITION 5
|
---|
239 | #define ERASE_TYPICAL_TIME_UNIT_1_MS_BITMAP 0x00
|
---|
240 | #define ERASE_TYPICAL_TIME_UNIT_1_MS 1
|
---|
241 | #define ERASE_TYPICAL_TIME_UNIT_16_MS_BITMAP 0x01
|
---|
242 | #define ERASE_TYPICAL_TIME_UNIT_16_MS 16
|
---|
243 | #define ERASE_TYPICAL_TIME_UNIT_128_MS_BITMAP 0x02
|
---|
244 | #define ERASE_TYPICAL_TIME_UNIT_128_MS 128
|
---|
245 | #define ERASE_TYPICAL_TIME_UNIT_1000_MS_BITMAP 0x03
|
---|
246 | #define ERASE_TYPICAL_TIME_UNIT_1000_MS 1000
|
---|
247 | #define ERASE_TYPICAL_TIME_COUNT_MASK 0x1f
|
---|
248 |
|
---|
249 | ///
|
---|
250 | /// Flash Device Configuration Detection Command descriptor.
|
---|
251 | ///
|
---|
252 | typedef struct {
|
---|
253 | // DWORD 1
|
---|
254 | UINT32 DescriptorEnd : 1; ///< Descriptor Sequence End Indicator.
|
---|
255 | UINT32 DescriptorType : 1; ///< Descriptor Type.
|
---|
256 | UINT32 Reserve1 : 6; ///< Bit [7:2] is reserved.
|
---|
257 | UINT32 DetectionInstruction : 8; ///< Sector map configuration detection command.
|
---|
258 | UINT32 DetectionLatency : 4; ///< Configuration detection command read latency.
|
---|
259 | UINT32 Reserve2 : 2; ///< Bit [21:20] is reserved.
|
---|
260 | UINT32 DetectionCommandAddressLen : 2; ///< Configuration detection command address length.
|
---|
261 | UINT32 ReadDataMask : 8; ///< Bit mask of the interst bit of the returned
|
---|
262 | ///< byte read from the detection command.
|
---|
263 | // DWORD 2
|
---|
264 | UINT32 CommandAddress : 32; ///< Sector map configuration detection command address.
|
---|
265 | } SFDP_SECTOR_CONFIGURATION_COMMAND;
|
---|
266 |
|
---|
267 | #define SFDP_SECTOR_MAP_TABLE_ENTRY_TYPE_COMMAND 0
|
---|
268 | #define SFDP_SECTOR_MAP_TABLE_ENTRY_TYPE_MAP 1
|
---|
269 | #define SFDP_SECTOR_MAP_TABLE_ENTRY_LAST 1
|
---|
270 |
|
---|
271 | ///
|
---|
272 | /// Definition of Configuration detection command address length.
|
---|
273 | ///
|
---|
274 | typedef enum {
|
---|
275 | SpdfConfigurationCommandAddressNone = 0,
|
---|
276 | SpdfConfigurationCommandAddress3Byte = 1,
|
---|
277 | SpdfConfigurationCommandAddress4Byte = 2,
|
---|
278 | SpdfConfigurationCommandAddressVariable = 3
|
---|
279 | } SPDF_CONFIGURATION_COMMAND_ADDR_LENGTH;
|
---|
280 |
|
---|
281 | ///
|
---|
282 | /// Flash Device Configuration Map descriptor.
|
---|
283 | ///
|
---|
284 | typedef struct {
|
---|
285 | // DWORD 1
|
---|
286 | UINT32 DescriptorEnd : 1; ///< Descriptor Sequence End Indicator.
|
---|
287 | UINT32 DescriptorType : 1; ///< Descriptor Type.
|
---|
288 | UINT32 Reserve1 : 6; ///< Bit [7:2] is reserved.
|
---|
289 | UINT32 ConfigurationID : 8; ///< ID of this configuration.
|
---|
290 | UINT32 RegionCount : 8; ///< The region count of this configuration.
|
---|
291 | UINT32 Reserve2 : 8; ///< [31:24] is reserved.
|
---|
292 | } SFDP_SECTOR_CONFIGURATION_MAP;
|
---|
293 |
|
---|
294 | typedef struct {
|
---|
295 | UINT32 DescriptorEnd : 1; ///< Descriptor Sequence End Indicator.
|
---|
296 | UINT32 DescriptorType : 1; ///< Descriptor Type.
|
---|
297 | } SFDP_SECTOR_CONFIGURATION_GENERIC_HEADER;
|
---|
298 |
|
---|
299 | ///
|
---|
300 | /// Flash Device Region Definition.
|
---|
301 | ///
|
---|
302 | typedef struct _SFDP_SECTOR_REGION {
|
---|
303 | // DWORD 1
|
---|
304 | UINT32 EraseType1 : 1; ///< Earse type 1 is supported.
|
---|
305 | UINT32 EraseType2 : 1; ///< Earse type 2 is supported.
|
---|
306 | UINT32 EraseType3 : 1; ///< Earse type 3 is supported.
|
---|
307 | UINT32 EraseType4 : 1; ///< Earse type 4 is supported.
|
---|
308 | UINT32 Reserve1 : 4; ///< Bit [7:4] is reserved.
|
---|
309 | UINT32 RegionSize : 24; ///< Region size in 256 Byte unit.
|
---|
310 | } SFDP_SECTOR_REGION;
|
---|
311 | #define SFDP_SECTOR_REGION_SIZE_UNIT 256
|
---|
312 |
|
---|
313 | ///
|
---|
314 | /// Sector Map Table structure, the entry could be
|
---|
315 | /// either Configuration Detection Command descriptor,
|
---|
316 | /// or Configuration Map descriptor.
|
---|
317 | ///
|
---|
318 | typedef union _SFDP_SECTOR_MAP_TABLE {
|
---|
319 | SFDP_SECTOR_CONFIGURATION_GENERIC_HEADER GenericHeader;
|
---|
320 | SFDP_SECTOR_CONFIGURATION_COMMAND ConfigurationCommand; ///< Fash configuration detection command.
|
---|
321 | SFDP_SECTOR_CONFIGURATION_MAP ConfigurationMap; ///< Flash map descriptor.
|
---|
322 | } SFDP_SECTOR_MAP_TABLE;
|
---|
323 |
|
---|
324 | #endif // SPI_NOR_FLASH_JEDEC_H_
|
---|