PDK API Guide for J721E
OSPI_v0.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 - 2020 Texas Instruments Incorporated - http://www.ti.com/
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  */
56 #ifndef OSPI_V0_H
57 #define OSPI_V0_H
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 #include <stdint.h>
64 #include <ti/drv/spi/SPI.h>
65 #include <ti/csl/src/ip/ospi/V0/cslr_ospi.h>
67 
73 #define OSPI_V0_CMD_SET_CFG_MODE (OSPI_CMD_RESERVED + 0U)
74 
75 
81 #define OSPI_V0_CMD_SET_XFER_MODE (OSPI_CMD_RESERVED + 1U)
82 
91 #define OSPI_V0_CMD_XFER_MODE_RW (OSPI_CMD_RESERVED + 2U)
92 
97 #define OSPI_V0_CMD_XFER_OPCODE (OSPI_CMD_RESERVED + 3U)
98 
103 #define OSPI_V0_CMD_SET_XFER_LINES (OSPI_CMD_RESERVED + 4U)
104 
109 #define OSPI_V0_CMD_RD_DUMMY_CLKS (OSPI_CMD_RESERVED + 5U)
110 
115 #define OSPI_V0_CMD_CFG_PHY (OSPI_CMD_RESERVED + 6U)
116 
121 #define OSPI_V0_CMD_ENABLE_DDR (OSPI_CMD_RESERVED + 7U)
122 
127 #define OSPI_V0_CMD_CFG_XIP (OSPI_CMD_RESERVED + 8U)
128 
133 #define OSPI_V0_CMD_ENABLE_SDR (OSPI_CMD_RESERVED + 9U)
134 
139 #define OSPI_V0_CMD_XFER_OPCODE_EXT (OSPI_CMD_RESERVED + 10U)
140 
145 #define OSPI_V0_CMD_EXT_RD_DUMMY_CLKS (OSPI_CMD_RESERVED + 11U)
146 
151 #define OSPI_V0_CMD_CFG_RD_DELAY (OSPI_CMD_RESERVED + 12U)
152 
157 #define OSPI_V0_CMD_CFG_DUMMY_CYCLE (OSPI_CMD_RESERVED + 13U)
158 
163 #define OSPI_V0_CMD_EXT_RD_CMD_LEN (OSPI_CMD_RESERVED + 14U)
164 
165 /* SPI function table pointer */
166 extern const OSPI_FxnTable OSPI_FxnTable_v0;
167 
171 typedef enum SPI_TransactionType_e {
175 
179 typedef enum OSPI_OperMode_e {
183 } OSPI_OperMode;
184 
185 
189 typedef enum OSPI_xferLines_e {
195 
199 typedef struct OSPI_dmaInfo_s {
201  void *drvHandle;
203  void *chHandle;
205  void *ringMem;
207  void *cqRingMem;
209  void *tdCqRingMem;
211  void *tprdMem;
213  void *eventHandle;
214 
215 } OSPI_dmaInfo;
216 
220 typedef struct OSPI_v0_HwAttrs_s {
222  uint32_t instNum;
224  uintptr_t baseAddr;
226  uintptr_t dataAddr;
228  uint32_t phyOpMode;
230  uint32_t phyLockCycle;
232  uint32_t funcClk;
234  uint32_t intrNum;
236  uint32_t eventId;
240  uint32_t chipSelect;
244  uint32_t devDelays[4];
246  uint32_t pageSize;
248  uint32_t blkSize;
254  bool dacEnable;
256  bool dmaEnable;
260  bool phyEnable;
262  uint32_t rdDataCapDelay;
264  bool dtrEnable;
266  bool xipEnable;
268  uint32_t csSotDelay;
270  uint32_t baudRateDiv;
273 
275 
281 typedef struct OSPI_v0_Object_s {
282  void *mutex; /* instance lock */
283  void *transferComplete; /* Transfer complete lock */
284  void *hwi; /* Hardware interrupt object */
285  uint32_t waitTimeout; /* Wait time out */
286 
287  OSPI_Params ospiParams; /* input parameters */
288 
289  uint32_t transactionType; /* Read or Write Transaction */
290  uint32_t transferCmd; /* Transfer command */
291  uint32_t ospiMode; /* Config or Memory map mode */
292  uint32_t xferLines; /* Number of transfer Lines */
293  uint32_t rdDummyClks; /* Number of dummy clock cycles for read op */
294  uint32_t extRdDummyClks; /* Number of dummy clock cycles for extended opcode command read op */
295  uint32_t extRdCmdLen; /* command length for extended opcode command read op */
296  uint32_t intrPollMode; /* Interrupt or polling mode */
297 
298  OSPI_TransferMode transferMode; /* Transfer mode */
299  OSPI_Transaction *transaction; /* Transaction structure */
300 
301  uint8_t *writeBufIdx; /* Internal inc. writeBuf index */
302  uint32_t writeCountIdx; /* Internal dec. writeCounter */
303  uint8_t *readBufIdx; /* Internal inc. readBuf index */
304  uint32_t readCountIdx; /* Internal dec. readCounter */
305 
306  bool isOpen; /* flag to indicate module is open */
307 
308  uint32_t rdStatusCmd; /* flash command to read status register */
309  uint32_t rdStatusAddr; /* flash status register address */
310 
312 
313 #ifdef SPI_DMA_ENABLE
314 extern int32_t OSPI_dmaConfig(OSPI_Handle handle);
315 extern void OSPI_dmaTransfer(OSPI_Handle handle, const OSPI_Transaction *spiTrans);
316 extern void OSPI_dmaDisableChannel(OSPI_Handle handle, bool txCha);
317 extern void OSPI_dmaFreeChannel(OSPI_Handle handle);
318 #endif
319 
320 extern uint32_t OSPI_getReadDataCapDelay(SPI_Handle handle);
321 
322 #ifdef __cplusplus
323 }
324 #endif
325 
326 #endif /* _OSPI_V0_H */
327 
328 /* @} */
bool isOpen
Definition: OSPI_v0.h:306
Definition: OSPI_v0.h:192
uint32_t OSPI_getReadDataCapDelay(SPI_Handle handle)
uint32_t funcClk
Definition: OSPI_v0.h:232
Definition: OSPI_v0.h:182
bool dtrEnable
Definition: OSPI_v0.h:264
OSPI_OperMode operMode
Definition: OSPI_v0.h:238
uint32_t rdDummyClks
Definition: OSPI_v0.h:293
Definition: OSPI_v0.h:181
bool xipEnable
Definition: OSPI_v0.h:266
uint32_t blkSize
Definition: OSPI_v0.h:248
uint32_t rdDataCapDelay
Definition: OSPI_v0.h:262
uint32_t phyLockCycle
Definition: OSPI_v0.h:230
uint32_t xferLines
Definition: OSPI_v0.h:292
OSPI_OperMode
OSPI controller modes.
Definition: OSPI_v0.h:179
bool dmaEnable
Definition: OSPI_v0.h:256
uintptr_t baseAddr
Definition: OSPI_v0.h:224
Definition: OSPI_v0.h:190
uint32_t extRdDummyClks
Definition: OSPI_v0.h:294
OSPI_TransferMode transferMode
Definition: OSPI_v0.h:298
void * eventHandle
Definition: OSPI_v0.h:213
void * tdCqRingMem
Definition: OSPI_v0.h:209
uint32_t instNum
Definition: OSPI_v0.h:222
struct SPI_Config_s * SPI_Handle
A handle that is returned from a SPI_open() call.
Definition: SPI.h:135
void * cqRingMem
Definition: OSPI_v0.h:207
uint8_t * writeBufIdx
Definition: OSPI_v0.h:301
OSPI_xferLines xferLines
Definition: OSPI_v0.h:250
uint32_t transactionType
Definition: OSPI_v0.h:289
uint32_t baudRateDiv
Definition: OSPI_v0.h:270
void * hwi
Definition: OSPI_v0.h:284
void * drvHandle
Definition: OSPI_v0.h:201
OSPI_Params ospiParams
Definition: OSPI_v0.h:287
uint32_t rdStatusAddr
Definition: OSPI_v0.h:309
uint32_t eventId
Definition: OSPI_v0.h:236
void * transferComplete
Definition: OSPI_v0.h:283
Definition: OSPI_v0.h:180
const OSPI_FxnTable OSPI_FxnTable_v0
SPI driver interface.
uint32_t pageSize
Definition: OSPI_v0.h:246
CSL_OspiClkMode frmFmt
Definition: OSPI_v0.h:242
Header file containing various enumerations, macro definitions and function.
uint32_t CSL_OspiClkMode
Definition: csl_ospi.h:91
SPI_TransactionType
Type of the SPI transaction.
Definition: OSPI_v0.h:171
OSPI Parameters.
Definition: SPI.h:448
OSPI IP V0 driver object.
Definition: OSPI_v0.h:281
OSPI_dmaInfo * dmaInfo
Definition: OSPI_v0.h:258
void * chHandle
Definition: OSPI_v0.h:203
A SPI_Transaction data structure is used with OSPI_transfer(). It indicates how many SPI_FrameFormat ...
Definition: SPI.h:368
Definition: OSPI_v0.h:172
bool phyEnable
Definition: OSPI_v0.h:260
uint32_t ospiMode
Definition: OSPI_v0.h:291
The definition of a SPI function table that contains the required set of functions to control a speci...
Definition: SPI.h:514
bool intrEnable
Definition: OSPI_v0.h:252
bool dacEnable
Definition: OSPI_v0.h:254
Definition: OSPI_v0.h:193
void * mutex
Definition: OSPI_v0.h:282
uint32_t extRdCmdLen
Definition: OSPI_v0.h:295
void * ringMem
Definition: OSPI_v0.h:205
Definition: OSPI_v0.h:191
OSPI UDMA info structure.
Definition: OSPI_v0.h:199
uint32_t intrPollMode
Definition: OSPI_v0.h:296
Definition: OSPI_v0.h:173
void * tprdMem
Definition: OSPI_v0.h:211
uint32_t chipSelect
Definition: OSPI_v0.h:240
uint32_t transferCmd
Definition: OSPI_v0.h:290
struct OSPI_Config_s * OSPI_Handle
A handle that is returned from a SPI_open() call.
Definition: SPI.h:384
OSPI_TransferMode
SPI transfer mode determines the whether the SPI controller operates synchronously or asynchronously....
Definition: SPI.h:427
uintptr_t dataAddr
Definition: OSPI_v0.h:226
uint32_t readCountIdx
Definition: OSPI_v0.h:304
OSPI_xferLines
Number of lines used for OSPI read/write transaction.
Definition: OSPI_v0.h:189
OSPI_Transaction * transaction
Definition: OSPI_v0.h:299
uint32_t intrNum
Definition: OSPI_v0.h:234
uint32_t phyOpMode
Definition: OSPI_v0.h:228
uint32_t waitTimeout
Definition: OSPI_v0.h:285
uint32_t rdStatusCmd
Definition: OSPI_v0.h:308
uint8_t * readBufIdx
Definition: OSPI_v0.h:303
uint32_t writeCountIdx
Definition: OSPI_v0.h:302
uint32_t csSotDelay
Definition: OSPI_v0.h:268
bool cacheEnable
Definition: OSPI_v0.h:272
OSPI IP V0 Hardware attributes.
Definition: OSPI_v0.h:220