AM243x MCU+ SDK  08.01.00
ospi_sfdp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
48 #ifndef OSPI_SFDP_H_
49 #define OSPI_SFDP_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 
55 #include <stdint.h>
56 #include <kernel/dpl/SystemP.h>
57 #include <kernel/dpl/HwiP.h>
58 #include <kernel/dpl/SemaphoreP.h>
59 #include <drivers/hw_include/csl_types.h>
60 #include <drivers/hw_include/cslr_ospi.h>
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 /* SFDP Signature DWORD */
67 #define OSPI_SFDP_SIGNATURE (0x50444653U)
68 
69 /* SFDP Revisions */
70 #define OSPI_SFDP_JESD216_MAJOR (1U)
71 #define OSPI_SFDP_JESD216_MINOR (0U)
72 #define OSPI_SFDP_JESD216A_MINOR (5U)
73 #define OSPI_SFDP_JESD216B_MINOR (6U)
74 #define OSPI_SFDP_JESD216C_MINOR (7U)
75 #define OSPI_SFDP_JESD216D_MINOR (8U)
76 
77 /* SFDP Maximum numbers of parameter headers (only JEDEC ones included)*/
78 #define OSPI_SFDP_NPH_MAX (13U)
79 
80 /* SFDP offsets */
81 #define OSPI_SFDP_HEADER_START_OFFSET (0x00U)
82 #define OSPI_SFDP_FIRST_PARAM_HEADER_OFFSET (0x08U)
83 #define OSPI_SFDP_SECOND_PARAM_HEADER_OFFSET (0x10U)
84 
85 /* SFDP Parameter table IDs supported by JEDEC*/
86 #define OSPI_SFDP_BASIC_PARAM_TABLE_ID (0xFF00)
87 #define OSPI_SFDP_SECTOR_MAP_TABLE_ID (0xFF81)
88 #define OSPI_SFDP_RPMC_TABLE_ID (0xFF03)
89 #define OSPI_SFDP_4BYTE_ADDR_INSTR_TABLE_ID (0xFF84)
90 #define OSPI_SFDP_XSPI_PROFILE_TABLE_ID (0xFF05)
91 #define OSPI_SFDP_XSPI_PROFILE_2_TABLE_ID (0xFF06)
92 #define OSPI_SFDP_SCCR_TABLE_ID (0xFF87)
93 #define OSPI_SFDP_SCCR_MULTISPI_OFFSETS_TABLE_ID (0xFF88)
94 #define OSPI_SFDP_SCCR_XSPI_PROFILE_2_TABLE_ID (0xFF09)
95 #define OSPI_SFDP_OCTAL_CMD_SEQ_TABLE_ID (0xFF0A)
96 #define OSPI_SFDP_LONG_LATENCY_NVM_MSP_TABLE_ID (0xFF8B)
97 #define OSPI_SFDP_QUAD_IO_WITH_DS_TABLE_ID (0xFF0C)
98 #define OSPI_SFDP_QUAD_CMD_SEQ_TABLE_ID (0xFF8D)
99 
100 /* SFDP Number of DWORDS in BFPT for different revisions */
101 #define OSPI_SFDP_BFPT_MAX_DWORDS_JESD216 (9)
102 #define OSPI_SFDP_BFPT_MAX_DWORDS_JESD216B (16)
103 
104 /* SFDP read command address type in 8D */
105 #define OSPI_SFDP_OCTAL_READ_ADDR_MSB_0 (0)
106 #define OSPI_SFDP_OCTAL_READ_ADDR_LSB_0 (1)
107 
108 typedef struct OSPI_SfdpMainHeader_s
109 {
110  uint32_t signature;
111  /* SFDP Signature. "SFDP" in ASCII */
112 
113  uint8_t minorRev;
114  /* SFDP minor revision number */
115 
116  uint8_t majorRev;
117  /* SFDP minor revision number */
118 
120  /* Number of param headers. Zero-based. 0 means 1 param header */
121 
122  uint8_t accessProtocol;
123  /* SFDP Access Protocol */
124 
126 
127 typedef struct OSPI_SfdpParamHeader_s
128 {
129  uint8_t paramIdLsb;
130  /* LSB of parameter ID */
131 
133  /* Minor revision number of parameter table */
134 
136  /* Major revision number of parameter table */
137 
139  /* Number of DWORDs in the parameter table. One based field. So 1 means 1 DWORD */
140 
141  uint8_t paramTablePtr[3];
142  /* Start of parameter header's corresponding table. This address should be DWORD aligned */
143 
144  uint8_t paramIdMsb;
145  /* MSB of parameter ID */
146 
148 
149 typedef struct OSPI_SfdpBasicFlashParamTable_s
150 {
151  uint32_t dtrQFRNumAddr;
152  /* 1st DWORD - has info about DTR support, number of address bytes and Quad and Dual Fast read support */
153 
154  uint32_t memoryDensity;
155  /* 2nd DWORD - flash size. If b31 is 0, 30:0 is size in bits. If b31 is 1, 30:0 is N, where 2^N is size in bits */
156 
158  /* 3rd DWORD - 1-1-4 and 1-4-4 fast read wait states, mode bit clocks and instruction */
159 
161  /* 4th DWORD - 1-1-2 and 1-2-2 fast read wait states, mode bit clocks and instruction */
162 
164  /* 5th DWORD - has info on whether 2-2-2 and 4-4-4 mode are supported */
165 
167  /* 6th DWORD - 2-2-2 fast read wait states, mode bit clocks and instruction */
168 
170  /* 7th DWORD - 4-4-4 fast read wait states, mode bit clocks and instruction */
171 
172  uint32_t eraseType_1_2;
173  /* 8th DWORD - erase types 1 and 2 : Sizes and their instructions */
174 
175  uint32_t eraseType_3_4;
176  /* 9th DWORD - erase types 3 and 4 : Sizes and their instructions */
177 
178  uint32_t eraseTimes;
179  /* 10th DWORD - erase times for all 4 types of erases */
180 
181  uint32_t pageSizeTimes;
182  /* 11th DWORD - pageSize, chip erase time, page program time, byte program time */
183 
185  /* 12th DWORD - suspend/resume support, intervals, latency etc */
186 
188  /* 13th DWORD - suspend/resume instructions */
189 
191  /* 14th DWORD - Deep power down support, instructions, status polling supported modes */
192 
193  uint32_t holdResetQeXip;
194  /* 15th DWORD - hold and reset details, quad enable requirements, 0-4-4 and 4-4-4 mode enabling */
195 
197  /* 16th DWORD - 4 byte addressing mode entry/exit, support, soft reset sequences, volatile and non-volatile status register support */
198 
200  /* 17th DWORD - 1-1-8 and 1-8-8 fast read wait states, mode bit clocks and instruction */
201 
203  /* 18th DWORD - DQS support, byte order, command extension type in 8D mode */
204 
205  uint32_t OeXip;
206  /* 19th DWORD - Octal enable requirements, 0-8-8 mode support, entry and exit, 8-8-8 enable disable sequence */
207 
208  uint32_t maxClocks;
209  /* 20th DWORD - Maximum operational speed for 4-4-4 and 8-8-8 modes */
210 
212 
213 typedef struct OSPI_SfdpXspiProfile1ParamTable_s
214 {
215  uint32_t dwords[5];
216 
218 
219 typedef struct OSPI_SfdpSectorMapParamTable_s
220 {
221  uint32_t dwords[2];
222 
224 
225 typedef struct OSPI_SfdpSCCRParamTable_s
226 {
227  uint32_t dwords[28];
228 
230 
231 typedef struct OSPI_Sfdp4ByteAddressingParamTable_s
232 {
233  uint32_t dwords[2];
234 
236 
241 typedef struct OSPI_SfdpHeader_s
242 {
244  /* The SFDP header */
245 
247  /* First and mandatory parameter table header */
248 
250 
251 /* ========================================================================== */
252 /* Function Definitions */
253 /* ========================================================================== */
254 
262 char* OSPI_Sfdp_getParameterTableName(uint32_t paramTableId);
263 
271 uint32_t OSPI_Sfdp_getPtp(OSPI_SfdpParamHeader *paramHeader);
272 
282 int32_t OSPI_Sfdp_parseBfpt(OSPI_SfdpBasicFlashParamTable *bfpt, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords);
283 
293 int32_t OSPI_Sfdp_parseXpt1(OSPI_SfdpXspiProfile1ParamTable *xpt1, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords);
294 
304 int32_t OSPI_Sfdp_parse4bait(OSPI_Sfdp4ByteAddressingParamTable *fourBait, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords);
305 
315 int32_t OSPI_Sfdp_parseSccr(OSPI_SfdpSCCRParamTable *sccr, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords);
316 
326 int32_t OSPI_Sfdp_parseSmpt(OSPI_SfdpSectorMapParamTable *smpt, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords);
327 
329 #ifdef __cplusplus
330 }
331 #endif
332 
333 #endif /* OSPI_SFDP_H_ */
OSPI_SfdpParamHeader::paramTableMinorRev
uint8_t paramTableMinorRev
Definition: ospi_sfdp.h:132
OSPI_SfdpBasicFlashParamTable::fastRead_444_WMI
uint32_t fastRead_444_WMI
Definition: ospi_sfdp.h:169
OSPI_SfdpBasicFlashParamTable::deepPdStatusPoll
uint32_t deepPdStatusPoll
Definition: ospi_sfdp.h:190
OSPI_SfdpBasicFlashParamTable::maxClocks
uint32_t maxClocks
Definition: ospi_sfdp.h:208
OSPI_SfdpParamHeader::paramTableLength
uint8_t paramTableLength
Definition: ospi_sfdp.h:138
OSPI_SfdpBasicFlashParamTable::dtrQFRNumAddr
uint32_t dtrQFRNumAddr
Definition: ospi_sfdp.h:151
SystemP.h
OSPI_SfdpBasicFlashParamTable::fastRead_112_122_WMI
uint32_t fastRead_112_122_WMI
Definition: ospi_sfdp.h:160
OSPI_Sfdp_parse4bait
int32_t OSPI_Sfdp_parse4bait(OSPI_Sfdp4ByteAddressingParamTable *fourBait, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords)
This function parses the 4 Byte Addressing Information Table (4BAIT) and fills the xspiDevDefines str...
OSPI_Sfdp_getParameterTableName
char * OSPI_Sfdp_getParameterTableName(uint32_t paramTableId)
This function returns the name of the parameter table given the table ID.
OSPI_SfdpBasicFlashParamTable::suspendResumeInstr
uint32_t suspendResumeInstr
Definition: ospi_sfdp.h:187
OSPI_SfdpBasicFlashParamTable::fastReadSupport_222_444
uint32_t fastReadSupport_222_444
Definition: ospi_sfdp.h:163
SemaphoreP.h
OSPI_Sfdp_parseBfpt
int32_t OSPI_Sfdp_parseBfpt(OSPI_SfdpBasicFlashParamTable *bfpt, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords)
This function parses the Basic Flash Parameter Table (BFPT) and fills the xspiDevDefines structure wi...
OSPI_SfdpMainHeader::accessProtocol
uint8_t accessProtocol
Definition: ospi_sfdp.h:122
OSPI_SfdpXspiProfile1ParamTable
Definition: ospi_sfdp.h:214
OSPI_SfdpSectorMapParamTable
Definition: ospi_sfdp.h:220
OSPI_SfdpBasicFlashParamTable
Definition: ospi_sfdp.h:150
OSPI_SfdpBasicFlashParamTable::eraseType_3_4
uint32_t eraseType_3_4
Definition: ospi_sfdp.h:175
OSPI_SfdpBasicFlashParamTable::eraseTimes
uint32_t eraseTimes
Definition: ospi_sfdp.h:178
OSPI_SfdpParamHeader
Definition: ospi_sfdp.h:128
OSPI_SfdpSCCRParamTable
Definition: ospi_sfdp.h:226
OSPI_SfdpHeader::sfdpHeader
OSPI_SfdpMainHeader sfdpHeader
Definition: ospi_sfdp.h:243
OSPI_SfdpBasicFlashParamTable::dqsByteOrderCmdExt
uint32_t dqsByteOrderCmdExt
Definition: ospi_sfdp.h:202
OSPI_SfdpBasicFlashParamTable::fastRead_114_144_WMI
uint32_t fastRead_114_144_WMI
Definition: ospi_sfdp.h:157
HwiP.h
OSPI_SfdpBasicFlashParamTable::fastRead_222_WMI
uint32_t fastRead_222_WMI
Definition: ospi_sfdp.h:166
OSPI_SfdpMainHeader::majorRev
uint8_t majorRev
Definition: ospi_sfdp.h:116
OSPI_SfdpParamHeader::paramIdMsb
uint8_t paramIdMsb
Definition: ospi_sfdp.h:144
OSPI_SfdpMainHeader
Definition: ospi_sfdp.h:109
OSPI_SfdpBasicFlashParamTable::holdResetQeXip
uint32_t holdResetQeXip
Definition: ospi_sfdp.h:193
OSPI_Sfdp_parseSmpt
int32_t OSPI_Sfdp_parseSmpt(OSPI_SfdpSectorMapParamTable *smpt, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords)
This function parses the Sector Map Parameter Table (SMPT) and fills the xspiDevDefines structure wit...
OSPI_SfdpBasicFlashParamTable::memoryDensity
uint32_t memoryDensity
Definition: ospi_sfdp.h:154
OSPI_SfdpHeader::firstParamHeader
OSPI_SfdpParamHeader firstParamHeader
Definition: ospi_sfdp.h:246
OSPI_Sfdp_parseSccr
int32_t OSPI_Sfdp_parseSccr(OSPI_SfdpSCCRParamTable *sccr, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords)
This function parses the Status, Control and Configuration Registers (SCCR) Table and fills the xspiD...
OSPI_Sfdp4ByteAddressingParamTable
Definition: ospi_sfdp.h:232
OSPI_SfdpBasicFlashParamTable::eraseType_1_2
uint32_t eraseType_1_2
Definition: ospi_sfdp.h:172
OSPI_SfdpBasicFlashParamTable::fourByteAddressVNvStatusReg
uint32_t fourByteAddressVNvStatusReg
Definition: ospi_sfdp.h:196
OSPI_SfdpBasicFlashParamTable::OeXip
uint32_t OeXip
Definition: ospi_sfdp.h:205
OSPI_SfdpMainHeader::minorRev
uint8_t minorRev
Definition: ospi_sfdp.h:113
OSPI_SfdpBasicFlashParamTable::pageSizeTimes
uint32_t pageSizeTimes
Definition: ospi_sfdp.h:181
OSPI_SfdpBasicFlashParamTable::fastRead_118_188_WMI
uint32_t fastRead_118_188_WMI
Definition: ospi_sfdp.h:199
OSPI_Sfdp_getPtp
uint32_t OSPI_Sfdp_getPtp(OSPI_SfdpParamHeader *paramHeader)
This function returns the Parameter Table Pointer (PTP) of the parameter table given the parameter he...
OSPI_SfdpParamHeader::paramIdLsb
uint8_t paramIdLsb
Definition: ospi_sfdp.h:129
OSPI_SfdpBasicFlashParamTable::suspendResumeSupport
uint32_t suspendResumeSupport
Definition: ospi_sfdp.h:184
OSPI_GenericXspiDevDefines
Definition: ospi/v0/ospi.h:431
OSPI_SfdpParamHeader::paramTableMajorRev
uint8_t paramTableMajorRev
Definition: ospi_sfdp.h:135
OSPI_Sfdp_parseXpt1
int32_t OSPI_Sfdp_parseXpt1(OSPI_SfdpXspiProfile1ParamTable *xpt1, OSPI_GenericXspiDevDefines *xspiDefines, uint32_t numDwords)
This function parses the xSPI Flash Profile 1.0 Table and fills the xspiDevDefines structure with the...
OSPI_SfdpMainHeader::numParamHeaders
uint8_t numParamHeaders
Definition: ospi_sfdp.h:119
OSPI_SfdpMainHeader::signature
uint32_t signature
Definition: ospi_sfdp.h:110
OSPI_SfdpHeader
OSPI SFDP Structure.
Definition: ospi_sfdp.h:242