 |
AM62L FreeRTOS SDK
11.02.00
|
|
Go to the documentation of this file.
62 #include <drivers/hw_include/cslr_ospi.h>
63 #include "ospi_tuning/ospi_tuning_algo/algo_v1/ospi_phy_tuning.h"
84 #define OSPI_TRANSFER_COMPLETED (0U)
85 #define OSPI_TRANSFER_STARTED (1U)
86 #define OSPI_TRANSFER_CANCELLED (2U)
87 #define OSPI_TRANSFER_FAILED (3U)
88 #define OSPI_TRANSFER_CSN_DEASSERT (4U)
89 #define OSPI_TRANSFER_TIMEOUT (5U)
111 #define OSPI_TRANSFER_MODE_BLOCKING (0U)
116 #define OSPI_TRANSFER_MODE_CALLBACK (1U)
121 #define OSPI_TRANSFER_MODE_POLLING (2U)
138 #define OSPI_FF_POL0_PHA0 (0U)
139 #define OSPI_FF_POL0_PHA1 (CSL_OSPI_FLASH_CFG_CONFIG_REG_SEL_CLK_PHASE_FLD_MASK | 0U)
140 #define OSPI_FF_POL1_PHA0 (0U | CSL_OSPI_FLASH_CFG_CONFIG_REG_SEL_CLK_POL_FLD_MASK)
141 #define OSPI_FF_POL1_PHA1 (CSL_OSPI_FLASH_CFG_CONFIG_REG_SEL_CLK_PHASE_FLD_MASK | \
142 CSL_OSPI_FLASH_CFG_CONFIG_REG_SEL_CLK_POL_FLD_MASK)
153 #define OSPI_CMD_INVALID_OPCODE (0xFFU)
154 #define OSPI_CMD_INVALID_DUMMY (0xFFU)
155 #define OSPI_CMD_INVALID_ADDR (0xFFFFFFFFU)
166 #define OSPI_CMD_EXT_TYPE_REPEAT (0x00U)
167 #define OSPI_CMD_EXT_TYPE_INVERSE (0x01U)
168 #define OSPI_CMD_EXT_TYPE_NONE (0x02U)
179 #define OSPI_FLASH_PROTOCOL(cmd, addr, data, dtr) (uint32_t)(((uint32_t)(dtr) << 24) | \
180 ((uint32_t)(cmd) << 16) | \
181 ((uint32_t)(addr) << 8) | \
182 ((uint32_t)(data) << 0))
183 #define OSPI_FLASH_PROTOCOL_INVALID (uint32_t)(0xFFFFFFFF)
194 #define OSPI_READ_MODE_DAC (0U)
195 #define OSPI_READ_MODE_INDAC (1U)
206 #define OSPI_CS0 (0U)
207 #define OSPI_CS1 (1U)
208 #define OSPI_CS2 (2U)
209 #define OSPI_CS3 (3U)
210 #define OSPI_CHIP_SELECT(x) ((~((1U) << (x))) & 0xFU)
221 #define OSPI_DECODER_SELECT4 ((uint32_t) 0U)
222 #define OSPI_DECODER_SELECT16 ((uint32_t) 1U)
233 #define OSPI_NOR_DMA_COPY_LOWER_LIMIT (1024U)
234 #define OSPI_NAND_DMA_COPY_LOWER_LIMIT (256U)
254 #define OSPI_FLASH_CFG_PHY_MASTER_CONTROL_REG_PHY_MASTER_MODE (0U)
255 #define OSPI_FLASH_CFG_PHY_MASTER_CONTROL_REG_PHY_BYPASS_MODE (1U)
268 #define OSPI_PHY_DLL_FULL_CYCLE_LOCK ((uint16_t) 0U)
269 #define OSPI_PHY_DLL_HALF_CYCLE_LOCK ((uint16_t) 1U)
465 uint32_t devDelays[4];
int32_t OSPI_norFlashWrite(OSPI_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len)
This function writes data to the flash at a specified offset.
void OSPI_setProtocol(OSPI_Handle handle, uint32_t protocol)
This function sets the number of transfer lines in the OSPI driver to set the requested protocol.
uint32_t OSPI_isDacEnable(OSPI_Handle handle)
This function checks if the Direct Access Controller is enabled.
uint32_t regionSize
Definition: ospi/v0/ospi.h:342
void OSPI_setCmdDummyCycles(OSPI_Handle handle, uint32_t cmdDummyCycles)
This function sets appropriate dummy cycles to be used while sending STIG commands to flash.
uint32_t phyDummyCycles
Definition: ospi/v0/ospi.h:519
uint16_t rxDataLen
Definition: ospi/v0/ospi.h:326
uint32_t status
Definition: ospi/v0/ospi.h:290
uint8_t numAddrBytes
Definition: ospi/v0/ospi.h:320
Definition: ospi/v0/ospi.h:314
void OSPI_Transaction_init(OSPI_Transaction *trans)
Function to initialize the OSPI_Transaction structure.
uint32_t deviceSize
Definition: ospi/v0/ospi.h:548
void OSPI_phyWriteTunedVal(OSPI_Handle handle)
This function writes OSPI PHY DLL values if the previous stage has already configured it.
Definition: ospi/v0/ospi.h:299
uint32_t rdDataCapDelay
Definition: ospi/v0/ospi.h:513
int32_t OSPI_disablePhyPipeline(OSPI_Handle handle)
This function disables the PHY Pipeline.
void OSPI_ReadCmdParams_init(OSPI_ReadCmdParams *rdParams)
Function to initialize the OSPI_ReadCmdParams structure.
int32_t OSPI_enableSDR(OSPI_Handle handle)
This function enables the Single Data Rate (SDR)
uint32_t transferTimeout
Definition: ospi/v0/ospi.h:292
uint32_t dacEnable
Definition: ospi/v0/ospi.h:461
int32_t OSPI_norFlashReadSfdp(OSPI_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len)
This function reads SFDP table from the flash from a specified offset.
uint32_t cmdExtType
Definition: ospi/v0/ospi.h:526
Data structure used with OSPI_Transfers - OSPI_readDirect, OSPI_writeDirect, OSPI_readIndirect,...
Definition: ospi/v0/ospi.h:283
uint32_t cmdAddr
Definition: ospi/v0/ospi.h:302
int32_t OSPI_phyReadAttackVector(OSPI_Handle handle, uint32_t offset)
This function checks if the attack vector, or the data used for tuning the PHY is present at an offse...
int32_t OSPI_norFlashRead(OSPI_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len)
This function reads data from the flash from a specified offset.
uint8_t intrPriority
Definition: ospi/v0/ospi.h:453
uint32_t OSPI_getInputClk(OSPI_Handle handle)
This function returns the input clk frequency OSPI was programmed at.
int32_t OSPI_phyTuneSDR(OSPI_Handle handle, uint32_t flashOffset)
This function tunes the OSPI PHY for SDR mode to set optimal PHY parameters.
void OSPI_init(void)
This function initializes the OSPI module.
int32_t OSPI_enableDdrRdCmds(OSPI_Handle handle)
This function sets DDR bit in INSTR_RD register for RD commands.
OSPI PHY Configuration.
Definition: ospi/v0/ospi.h:399
int32_t OSPI_norFlashErase(OSPI_Handle handle, uint32_t address)
This function erases 1 block of data starting from a provided address.
int32_t OSPI_phyValidateTuningPoint(OSPI_Handle handle, uint32_t flashOffset)
Validates a specific tuning point by performing a read operation from the flash memory.
void OSPI_deinit(void)
This function de-initializes the OSPI module.
void OSPI_setDualOpCodeMode(OSPI_Handle handle)
This function sets OSPI controller to use dual byte opcodes.
void OSPI_Params_init(OSPI_Params *ospiParams)
Initialize data structure with defaults.
uint32_t OSPI_isDtrEnable(OSPI_Handle handle)
This function checks if the Dual Transfer Rate (Sampling on both rising and falling edge of the clock...
uint32_t clkId
Definition: ospi/v0/ospi.h:441
OSPI_Handle handle
Definition: ospi/v0/ospi.h:498
int32_t OSPI_setRdDataCaptureDelay(OSPI_Handle handle, uint32_t rdDataCapDelay, uint32_t updatePhyRdDelay)
This function sets read data capture cycles in the OSPI controller.
uint32_t cmdAddr
Definition: ospi/v0/ospi.h:317
uint32_t dataBaseAddr
Definition: ospi/v0/ospi.h:437
uint32_t count
Definition: ospi/v0/ospi.h:284
int32_t txHighSearchStart
Definition: ospi/v0/ospi.h:376
uint32_t rxTxDLLSearchStep
Definition: ospi/v0/ospi.h:382
uint32_t phaseDelayElement
Definition: ospi/v0/ospi.h:475
int32_t rxHighSearchStart
Definition: ospi/v0/ospi.h:368
void OSPI_setDelays(OSPI_Handle handle, uint32_t inputClkFreq)
Sets timing delays for the OSPI interface based on input clock frequency.
OSPI_PhyTuneWindowParams tuningWindowParams
Definition: ospi/v0/ospi.h:404
uint32_t baudRateDiv
Definition: ospi/v0/ospi.h:473
uint32_t dllLockMode
Definition: ospi/v0/ospi.h:402
OSPI Parameters.
Definition: ospi/v0/ospi.h:422
OSPI_phyParams phyParams
Definition: ospi/v0/ospi.h:406
void OSPI_setBaudRateDiv(OSPI_Handle handle, uint32_t baudRateDiv)
Sets the baud rate divider for OSPI communication.
int32_t OSPI_norFlashReadId(OSPI_Handle handle, uint32_t *manufacturerId, uint32_t *deviceId)
This function tries to read the JEDEC ID from the NOR flash connected to the OSPI peripheral.
int32_t OSPI_skipTuning(OSPI_Handle handle)
This function checks if OSPI tuning should be skipped based on user input and if phy bit is set.
void OSPI_setXferOpCodes(OSPI_Handle handle, uint8_t readCmd, uint8_t pageProgCmd)
This function sets the opcodes for reading and page programming the flash.
OSPI_Handle OSPI_getHandle(uint32_t index)
This function returns the handle of an open OSPI Instance from the instance index.
uint32_t OSPI_isOtpValidateEnable(OSPI_Handle handle)
This function checks if OSPI validate tuning point option is enabled.
uint32_t moduleId
Definition: ospi/v0/ospi.h:439
int32_t txDLLSearchOffset
Definition: ospi/v0/ospi.h:380
uint32_t transferMode
Definition: ospi/v0/ospi.h:500
uint32_t txDataLen
Definition: ospi/v0/ospi.h:309
int32_t OSPI_disableDdrRdCmds(OSPI_Handle handle)
This function resets DDR bit in INSTR_RD register for RD commands.
void * txDataBuf
Definition: ospi/v0/ospi.h:307
uint32_t rdDelayMin
Definition: ospi/v0/ospi.h:384
int32_t OSPI_disableDacMode(OSPI_Handle handle)
This function disables the Direct Access Mode.
uint32_t inputClkFreq
Definition: ospi/v0/ospi.h:443
int32_t OSPI_setFrequency(OSPI_Handle handle, uint64_t inputClkFreq)
Sets the operating frequency for the OSPI peripheral.
uint32_t readMode
Definition: ospi/v0/ospi.h:471
uint32_t OSPI_getProtocol(OSPI_Handle handle)
This function returns the current protocol for which the transfer lines in OSPI driver is configured ...
int32_t txDllHighWindowEnd
Definition: ospi/v0/ospi.h:362
void OSPI_setNumAddrBytes(OSPI_Handle handle, uint32_t numAddrBytes)
This function set the number of bytes used to send address while reading or writing to flash memory.
const OSPI_AddrRegion * dmaRestrictedRegions
Definition: ospi/v0/ospi.h:479
This file contains the Register Desciptions for CSL types.
uint32_t cmdDummyCycles
Definition: ospi/v0/ospi.h:511
OSPI instance attributes - used during init time.
Definition: ospi/v0/ospi.h:431
uint32_t OSPI_getFlashDataBaseAddr(OSPI_Handle handle)
This function gets the SOC mapped data base address of the flash.
int32_t txDllHighWindowStart
Definition: ospi/v0/ospi.h:360
OSPI driver object.
Definition: ospi/v0/ospi.h:494
int32_t OSPI_readDirect(OSPI_Handle handle, OSPI_Transaction *trans)
Function to perform direct reads from the flash using DAC controller.
void OSPI_phyGetTuningData(uint32_t *tuningData, uint32_t *tuningDataSize)
This function returns the address to the attack vector buf required for tuning the PHY.
void OSPI_clearDualOpCodeMode(OSPI_Handle handle)
This function sets OSPI controller to not use dual byte opcodes.
uint32_t rdDummyCycles
Definition: ospi/v0/ospi.h:509
uint32_t chipSelect
Definition: ospi/v0/ospi.h:467
uint32_t isOpen
Definition: ospi/v0/ospi.h:532
void * rxDataBuf
Definition: ospi/v0/ospi.h:324
int32_t OSPI_writeIndirect(OSPI_Handle handle, OSPI_Transaction *trans)
Function to perform indirect writes to the flash using INDAC controller.
uint8_t cmd
Definition: ospi/v0/ospi.h:300
int32_t txLowSearchEnd
Definition: ospi/v0/ospi.h:374
void OSPI_phyReadTunedVal(OSPI_Handle handle)
This function reads OSPI PHY values if the previous stage has already configured it.
uint32_t protocol
Definition: ospi/v0/ospi.h:502
int32_t OSPI_enablePhyPipeline(OSPI_Handle handle)
This function enables the PHY Pipeline.
int32_t OSPI_norFlashInit1s1s1s(OSPI_Handle handle)
This function initializes the NOR flash to work in 1-1-1 mode.
uint32_t OSPI_isPhyEnable(OSPI_Handle handle)
This function checks if the OSPI PHY controller is enabled.
uint32_t phySkipTuning
Definition: ospi/v0/ospi.h:459
void OSPI_setDeviceSize(OSPI_Handle handle, uint32_t deviceSize, uint32_t pageSize, uint32_t blkSize)
This function sets the block size and page size of the flash to the device size register in OSPI.
int32_t OSPI_writeCmd(OSPI_Handle handle, OSPI_WriteCmdParams *wrParams)
Function to send specific commands and related data to flash.
void OSPI_setPhyEnableSuccess(OSPI_Handle handle, uint32_t success)
This function sets the phyEnableSuccess field in OSPI_Object. Has to be called from flash driver.
int32_t ospiDmaChIndex
Definition: ospi/v0/ospi.h:423
int32_t OSPI_enablePhy(OSPI_Handle handle)
This function enables the PHY.
void * buf
Definition: ospi/v0/ospi.h:286
uint32_t phyEnableSuccess
Definition: ospi/v0/ospi.h:540
int32_t txLowSearchStart
Definition: ospi/v0/ospi.h:372
int32_t rxLowSearchEnd
Definition: ospi/v0/ospi.h:366
int32_t OSPI_disablePhy(OSPI_Handle handle)
This function disables the PHY.
int32_t OSPI_enableDDR(OSPI_Handle handle)
This function enables the Dual Data Rate (DDR)
Definition: ospi/v0/ospi.h:552
OSPI Address Region.
Definition: ospi/v0/ospi.h:339
uint32_t intrNum
Definition: ospi/v0/ospi.h:449
void OSPI_close(OSPI_Handle handle)
Function to close a OSPI peripheral specified by the OSPI handle.
void OSPI_enableModeBitsRead(OSPI_Handle handle)
This function enables mode bits transmission while reading.
SemaphoreP_Object lockObj
Definition: ospi/v0/ospi.h:534
uint32_t phyCfgVal
Definition: ospi/v0/ospi.h:517
OSPI PHY Tuning Window Parameters.
Definition: ospi/v0/ospi.h:355
uint8_t numAddrBytes
Definition: ospi/v0/ospi.h:305
uint32_t phyControlMode
Definition: ospi/v0/ospi.h:400
uint32_t OSPI_isDmaEnable(OSPI_Handle handle)
This function checks if DMA is enabled for reads.
int32_t rxHighSearchEnd
Definition: ospi/v0/ospi.h:370
uint32_t rdDelayMax
Definition: ospi/v0/ospi.h:386
void OSPI_phyResyncDLL(OSPI_Handle handle)
This function resyncs the DLL values.
void OSPI_enableModeBitsCmd(OSPI_Handle handle)
This function enables mode bits transmission while sending CMDs.
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:93
void OSPI_setRdDummyValPhyMode(OSPI_Handle handle, uint32_t rdDummyValPhyMode)
This function sets value by which read dummy cycles need to be updated for OSPI read in Phy Mode.
HwiP_Object hwiObj
Definition: ospi/v0/ospi.h:538
uint8_t dummyBits
Definition: ospi/v0/ospi.h:322
uint32_t numAddrBytes
Definition: ospi/v0/ospi.h:521
uint32_t phyRdDataCapDelay
Definition: ospi/v0/ospi.h:515
void OSPI_set1sProtocol(OSPI_Handle handle)
Resets the OSPI controller to operate in 1S-1S-1S mode.
void OSPI_norFlashSetCmds(uint8_t rdCmd, uint8_t wrCmd, uint8_t eraseCmd)
This function sets up internal bookkeeping variables for read, write and erase commands....
void OSPI_setReadDummyCycles(OSPI_Handle handle, uint32_t dummyCycles)
This function sets appropriate dummy cycles for flash read.
void * ospiDmaHandle
Definition: ospi/v0/ospi.h:546
OSPI_Config gOspiConfig[]
Externally defined driver configuration array.
int32_t OSPI_phyTuneGrapher(OSPI_Handle handle, uint32_t flashOffset, uint8_t arrays[5][128][128])
This function takes a 4x128x128 array and fills it with TX RX DLL data for graphing purpose.
uint32_t OSPI_isIntrEnable(OSPI_Handle handle)
This function checks if interrupts are enabled.
uint32_t addrOffset
Definition: ospi/v0/ospi.h:288
uint32_t dmaEnable
Definition: ospi/v0/ospi.h:455
uint32_t phyEnable
Definition: ospi/v0/ospi.h:457
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
uint32_t regionStartAddr
Definition: ospi/v0/ospi.h:340
int32_t txHighSearchEnd
Definition: ospi/v0/ospi.h:378
uint32_t dmaCopyLowerLimit
Definition: ospi/v0/ospi.h:294
int32_t rxLowSearchStart
Definition: ospi/v0/ospi.h:364
int32_t txDllLowWindowStart
Definition: ospi/v0/ospi.h:356
uint32_t rdDummyValPhyMode
Definition: ospi/v0/ospi.h:542
void OSPI_WriteCmdParams_init(OSPI_WriteCmdParams *wrParams)
Function to initialize the OSPI_WriteCmdParams structure.
void OSPI_setCmdExtType(OSPI_Handle handle, uint32_t cmdExtType)
This function sets the type of command extension used in dual byte opcode mode.
OSPI_Handle OSPI_open(uint32_t index, const OSPI_Params *openParams)
This function opens a given OSPI peripheral.
OSPI_Transaction * currTrans
Definition: ospi/v0/ospi.h:544
uint32_t intrEnable
Definition: ospi/v0/ospi.h:451
int32_t OSPI_enableDacMode(OSPI_Handle handle)
This function enables the Direct Access Mode.
void * OSPI_Handle
A handle that is returned from a OSPI_open() call.
Definition: ospi/v0/ospi.h:74
uint32_t baseAddr
Definition: ospi/v0/ospi.h:435
uint32_t frmFmt
Definition: ospi/v0/ospi.h:463
uint32_t gOspiConfigNum
Externally defined driver configuration array size.
uint8_t cmd
Definition: ospi/v0/ospi.h:315
int32_t OSPI_writeDirect(OSPI_Handle handle, OSPI_Transaction *trans)
Function to perform direct writes to the flash using DAC controller.
void OSPI_setModeBits(OSPI_Handle handle, uint32_t modeBits)
This function sets mode bits in the mode bit field of OSPI config register.
const OSPI_Attrs * attrs
Definition: ospi/v0/ospi.h:553
uint32_t OSPI_getPhyEnableSuccess(OSPI_Handle handle)
This function fetches the phyEnableSuccess field in OSPI_Object.
int32_t OSPI_phyTuneDDR(OSPI_Handle handle, uint32_t flashOffset)
This function tunes the OSPI PHY for DDR mode to set optimal PHY parameters.
int32_t OSPI_readCmd(OSPI_Handle handle, OSPI_ReadCmdParams *rdParams)
Function to send specific commands and receive related data from flash.
OSPI_PhyConfiguration phyConfiguration
Definition: ospi/v0/ospi.h:484
OSPI_Object * object
Definition: ospi/v0/ospi.h:555
int32_t OSPI_readIndirect(OSPI_Handle handle, OSPI_Transaction *trans)
Function to perform indirect reads from the flash using INDAC controller.
uint8_t validateOtp
Definition: ospi/v0/ospi.h:477
void OSPI_cmdModeBitSet(OSPI_Handle handle, uint32_t enable)
This function sets command mode bit.
uint32_t decChipSelect
Definition: ospi/v0/ospi.h:469
void OSPI_rdModeBitSet(OSPI_Handle handle, uint32_t enable)
This function sets Read mode bit.
SemaphoreP_Object transferSemObj
Definition: ospi/v0/ospi.h:536
int32_t txDllLowWindowEnd
Definition: ospi/v0/ospi.h:358