AM62Ax MCU+ SDK  10.00.00
OSPI

Attention
Please note that this driver is supported only on DM R5(WKUP R5) as part SBL examples. It is not supported on MCU-R5.

The Octal Serial Peripheral Interface (OSPI) module is a kind of Serial Peripheral Interface (SPI) module which allows single, dual, quad or octal read and write access to external flash devices. The OSPI module is used to transfer data, either in a memory mapped direct mode (for example a processor wishing to execute code directly from external flash memory), or in an indirect mode where the module is set-up to silently perform some requested operation, signaling its completion via interrupts or status registers.

Features Supported

  • Support for single, dual, quad (QSPI mode) or octal I/O instructions.
  • Supports dual Quad-SPI mode for fast boot applications.
  • Memory mapped ‘direct’ mode of operation for performing flash data transfers and executing code from flash memory.
  • Programmable delays between transactions.
  • Legacy mode allowing software direct access to low level transmit and receive FIFOs, bypassing the higher layer processes.
  • An independent reference clock to decouple bus clock from SPI clock – allows slow system clocks.
  • Programmable baud rate generator to generate OSPI clocks.
  • Supports BOOT mode.
  • Handling ECC errors for flash devices with embedded correction engine.
  • Skip tuning, the ospi driver reads the tuning parameters set in the previous stage, by calculating the read delay value, tuning point is set. This saves the boot time by skipping the search for tuning points.

SysConfig Features

Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
  • OSPI instance name
  • Input clock frequency to be used for OSPI module
  • Input clock divider which decides the baud-rate at which the flash will be read
  • Chip Select
  • Enable skip tuning
  • Enabling of various features like DMA and PHY mode.
    • PHY configuration allows to
      • Enable/disable fast tuning, configuring fast/default window tuning parameters.
      • Set PHY control mode (master/bypass)
      • Determine if master delay line locks in half/full cycle of delay.

OSPI PHY Configurations Syscfg
  • Tuning window parameters,contains various parameters for OSPI tuning
    • Min and Max values for read delays.
    • TxDLL low start and end, defines txDLL window for finding rxLow.
    • TxDLL high start and end, defines txDLL winodw for finding backup rxLow.
    • RxDLL low search start, minimum value for rxLow.
    • RxDLL low search end, maximum value for rxLow.
    • RxDLL high search start, minimum value for rxHigh.
    • RxDLL high search end, maximum value for rxHigh.
    • TxDLL low search start, minimum value for txLow.
    • TxDLL low search end, maximum value for txLow.
    • TxDLL high search start, minimum value for txHigh.
    • TxDLL high search end, maximum value for txHigh.
    • TxDLL search offset, increment in txDLL value while searching rxLow/rxHigh values.
    • RxDL & TxDLL Search Step, step size for finding rx and tx low/high values.
OSPI DEFAULT WINDOW PARAMS
OSPI FAST TUNING WINDOW PARAMS
  • In advanced config, you can choose various parameters like frame format, decoder chip select, read dummy cycles etc.
  • Pinmux configurations for the OSPI instance

OSPI Phy Tuning Algorithm

The ospi NAND tuning algorithm works as follows:

  • Step 1 Fix TxDLL value
    Set txDll value to txDllHighWindowEnd.

  • Step 2 Find Rx window 1
    At fixed TxDLL, find rxStart1 and rxEnd1 in the range rxLowSearchStart and rxHighSearchEnd.
    In the range rdDelayMin to rdDelayMax, rxStart1 and rxEnd1 are found.
    If not found return failure.
    rxWindow1 = rxEnd1 - rxStart1

  • Step 3 Find Rx window 2
    Find rxStart2 and rxEnd2 at fixed TxDLL, in the range readDelay = readDelay of rxWindow1 + 1 to rdDelayMax.
    rxWindow2 = rxEnd2 - rxStart2

  • Step 4 Choose Bigger Rx Window
    Compare rxWindow1 and rxWindow2, select the larger rxWindow.

  • Step 5 Find the Tuning Point
    • txDLL value is set to txDLL value fixed in first step
    • rdDelay value is set to rdDelay value of larger window
    • rxDLL value is set to the midpoint of the rxWindow chosen in step 4.

Features not Supported

  • XIP mode is not supported yet.

Example Usage

Include the below file to access the APIs

#include <stdio.h>
#include <drivers/ospi.h>

Instance Open Example

OSPI_Params ospiParams;
OSPI_Params_init(&ospiParams);
gOspiHandle = OSPI_open(0, &ospiParams);
DebugP_assert(gOspiHandle != NULL);

Instance Close Example

OSPI_close(gOspiHandle);

API

APIs for OSPI

OSPI_Params_init
void OSPI_Params_init(OSPI_Params *ospiParams)
Initialize data structure with defaults.
OSPI_Params
OSPI Parameters.
Definition: ospi/v0/ospi.h:407
OSPI_close
void OSPI_close(OSPI_Handle handle)
Function to close a OSPI peripheral specified by the OSPI handle.
ospi.h
OSPI_open
OSPI_Handle OSPI_open(uint32_t index, const OSPI_Params *openParams)
This function opens a given OSPI peripheral.
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:175