AM62x MCU+ SDK  09.02.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-M4.

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.

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
  • 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 tuning algorithm works as follows:

  • Step 1 Find Golden Primary RxLow
    To find the RxDLL boundaries, we fix a valid TxDLL and search through RxDLL range, rdDelay values.
    As we are not sure of a valid TxDLL we use a window of TxDLL values to find the RxDLL boundaries.
                Rx_DLL
                  ▲
                  │   ++++++++++++++++
              127 │     ++++++++++++++
                  │   x   ++++++++++++
                  │   xx   +++++++++++
                  │   xxx   ++++++++++
                  │   xxxx   +++++++++
                  │   xxxxx   ++++++++
                  │ │ xxx│xx   +++++++
                  │ │ xxx│xxx   ++++++
                  │ │ xxx│xxxx   +++++
                  │ │ xxx│xxxxx   ++++
                  │ │ xxx│xxxxxx   +++
         Search   │ │ xxx│xxxxxxx   ++
         Rx_Low ──┼─┤►xxx│xxxxxxxx   +
                  │ │    │
                 ─┼─┼────┼------────►  Tx_DLL
                 0│ │    │           127
                    │    │
                    │    │
    
                Tx_Low   Tx_Low
                Start    End
    

  • Step 2 Find Golden Secondary RxLow
    Search for one more rxLow at different txDl, To find Secondary rxHigh we use the txDLL + Search_offset value of rxLow.

  • Step 3 Select minimum of primary rxLow and secondary rxLow Value
    • Pick minimum value of rxDLL between rxLow and sec_rxLow.
    • Pick Minimum value of rdDelay(read_delay) between rxLow and sec_rxLow.
      Primary
      Search
      Secondary
      Search
      Final Point
      Fail Fail Return Fail
      Fail Pass Return Fail
      Pass Fail Return Fail
      Pass Pass RxDll = Min(Primary, Secondary)
      RdDelay = Min(Primary, Secondary)
      TxDll = Primary

  • Step 4 Find Golden Primary Rx High
    To find rxHigh we use the txDLL values of rxLow.
    Start the rdDelay (Read delay) from maximum and decrement it.
    As these are valid values and rxHigh rdDelay is always >= rxLow rdDelay.
                Rx_DLL
                  ▲
              127 │   ▲+++++++++++++++
        Search    │   │ ++++++++++++++
       Rx_High────┼──►│   ++++++++++++
       on Fixed   │   │x   +++++++++++
        Tx_DLL    │   │xx   ++++++++++
                  │   │xxx   +++++++++
                  │   │xxxx   ++++++++
                  │   ▼xxxxx   +++++++
                  │   Xxxxxxx   ++++++
                  │   Xxxxxxxx   +++++
                  │   Xxxxxxxxx   ++++
                  │   Xxxxxxxxxx   +++
                  │   Xxxxxxxxxxx   ++
                  │   Xxxxxxxxxxxx   +
                  │
                 ─┼------------───►  Tx_DLL
                 0│                  127
    

  • Step 5 Find Golden Secondary Rx High
    To find Secondary rxHigh we use the txDLL + Search_offset value of rxLow.
    Start the rdDelay (Read delay) from maximum and decrement it.
    As these are valid values and rxHigh rdDelay is always >= rxLow rdDelay.

  • Step 6 Select maximum of primary and secondary rxHigh value
    • Compare the Primary and Secondary point.
    • Pick the point which has passing maximum rxDll.
      Primary
      Search
      Secondary
      Search
      Final Point
      Fail Fail Return Fail
      Fail Pass Return Fail
      Pass Fail Return Fail
      Pass Pass If(secondary.rxDll > primary.rxDll)
      Pick Secondary search point
      Else
      Pick Primary search point

  • Step 7 Do a backup Search in case rxLow and rx High has same read delay values
    Check a different point if the rxLow and rxHigh are on the same rdDelay.
    This avoids mistaking the metastability gap for an rxDLL boundary.
    • Find backup rx Low Find the rxDLL boundaries using the TxDLL window at the higher end .
      We start the window_end and decrement the TxDLL value until we find the valid point.
             Rx_DLL
              ▲
              │   ++++++++++++++++
          127 │   ++++++++++++++++
              │   ++++++++++++++++
              │    +++++++++++++++
              │     +++++++++│++++│
              │      ++++++++│++++│
              │   x   +++++++│++++│
              │   xx   ++++++│++++│
              │   xxx   +++++│++++│
              │   xxxx   ++++│++++│
              │   xxxxx   +++│++++│
              │   xxxxxx   ++│++++│
              │   xxxxxxx   +│++++│         Search
              │   xxxxxxxx   │++++◄───────  Rx_Low
              │              │    │
             ─┼──────────────┼────┤► Tx_DLL
             0│              │    │   127
                             │    │
                     Tx_High        Tx_High
                     Start          End
      
    • Find backup sec rxLow
      Search for one more rxLow at different txDll, we use the txDLL - Search_offset value of rxLow.
    • Select minimum of backup rxLow and backup sec rxLow
      • Pick minimum value of rxDLL between rxLow and sec_rxLow.
      • Pick Minimum value of rdDelay(read_delay) between rxLow and sec_rxLow.
    • Find backup primary rxHigh search Find rxDLL Max
      Start the rdDelay (Read delay) from maximum and decrement it.
              Rx_DLL
      127 ▲
          │   +++++++++++++++▲                Search Rx_High
          │   +++++++++++++++│◄────────────   on Fixed Tx_DLL
          │   +++++++++++++++│
          │    ++++++++++++++│
          │     +++++++++++++│
          │      ++++++++++++│
          │   x   +++++++++++▼
          │   xx   +++++++++++
          │   xxx   ++++++++++
          │   xxxx   +++++++++
          │   xxxxx   ++++++++
          │   xxxxxx   +++++++
          │   xxxxxxx   ++++++
          │   xxxxxxxx    ++++
          │
         ─┼────────────────────► Tx_DLL
         0│                       127
      
    • Find backup secondary rxHigh search
      Search for one more rxHigh at different txDll, we use the txDLL - Search_offset value of rxLow.
    • Select maximum of backup primary and secondary rxhigh
      Compare the Primary and Secondary point.
      Pick the point which has passing maximum rxDll.
      Primary
      Search
      Secondary
      Search
      Final Point
      Fail Fail Return Fail
      Fail Pass Return Fail
      Pass Fail Return Fail
      Pass Pass If(secondary.rxDll > primary.rxDll)
      Pick Secondary search point
      Else
      Pick Primary search point

  • Step 8 Find golden TxLow Look for txDLL boundaries at 1/4 of rxDLL window.
    Find txDLL Min.
                          Rx_DLL
                     127 ▲
                         │   ++++++++++++++++
              Rx_High    │     ++++++++++++++
                  ───────┼──►x   ++++++++++++
                         │   xx   +++++++++++
                         │   xxx   ++++++++++
                         │   xxxx   +++++++++
           Fix Rx_DLL    │   xxxxx   ++++++++
          1/4 between    │   xxxxxx   +++++++
          Rx_High and    │   xxxxxxx   ++++++
            Rx_Low       │   xxxxxxxx   +++++
                   ──────┼─► ◄───┬──►    ++++
                         │   xxxx│xxxxx   +++
               Rx_Low    │   xxxx│xxxxxx   ++
                   ──────┼──►xxxx│xxxxxxx   +
                         │       │
                        ─┼───────┼───────────►  Tx_DLL
                        0│       │          127
                                 │
                            Search Tx_Low
    

  • Step 9 Find golden TxHigh
    Find txDLL Max.
    Start the rdDelay (Read delay) from maximum and decrement it.
            Rx_DLL
               127 ▲
                   │   +++++++++++++++++
        Rx_High    │     +++++++++++++++
            ───────┼──►x   +++++++++++++
                   │   xx   ++++++++++++
                   │   xxx   +++++++++++
                   │   xxxx   ++++++++++
     Fix Rx_DLL    │   xxxxx   +++++++++
    1/4 between    │   xxxxxx   ++++++++
    Rx_High and    │   xxxxxxx   +++++++
       Rx_Low      │   xxxxxxxx   ++++++
             ──────┼─► xxxxxxxxx   ◄─┬─►
                   │   xxxxxxxxxx   +│++
         Rx_Low    │   xxxxxxxxxxx   │++
             ──────┼──►xxxxxxxxxxxx  │++
                   │                 │
                  ─┼─────────────────┼─►  Tx_DLL
                  0│                 │127
                                  Search Tx_Max
    

  • Step 10 Do a backup Search in case rxLow and rx High has same read delay values
    Check a different point if the txLow and txHigh are on the same rdDelay.
    This avoids mistaking the metastability gap for a txDLL boundary.
    • Find a backup primary txLow
      Look for txDLL boundaries at 3/4 of rxDLL window.
      Find txDLL Min.
               Rx_DLL
              127 ▲
                  │
         Rx_High──┼──►+++++++++++++++++
      Fix Rx_DLL  │   +++++++++++++++++
         3/4 of   │   +++++++++++++++++
        Rx_High  ─┼─► ◄───┬───►++++++++
      and Rx_Low  │     ++│++++++++++++
                  │      +│++++++++++++
                  │   x   │++++++++++++
                  │   xx  │++++++++++++
                  │   xxx │ +++++++++++
                  │   xxxx│  ++++++++++
                  │   xxxx│   +++++++++
                  │   xxxx│x   ++++++++
                  │   xxxx│xx   +++++++
          Rx_Low──┼──►xxxx│xxx   ++++++
                  │       │
                 ─┼───────┼────────────► Tx_DLL
                 0│       │               127
                     Search Tx_Min
      
    • Find a backup primary txHigh
      Find txDLL Max.
      Start the rdDelay (Read delay) from maximum and decrement it.
               Rx_DLL
                127
                  ▲
                  │
         Rx_High──┼──►+++++++++++++++++
                  │   +++++++++++++++++
       Fix Rx_DLL │   +++++++++++++++++
       3/4 of ────┼─► +++++++◄────┬───►
        Rx_High   │     ++++++++++│++++
         and      │      +++++++++│++++
        Rx_Low    │   x   ++++++++│++++
                  │   xx   +++++++│++++
                  │   xxx   ++++++│++++
                  │   xxxx   +++++│++++
                  │   xxxxx   ++++│++++
                  │   xxxxxx   +++│++++
                  │   xxxxxxx   ++│++++
          Rx_Low──┼──►xxxxxxxx   +│++++
                  │               │
                 ─┼───────────────┼────► Tx_DLL
                 0│               │       127
                               Search Tx_Max
      

  • Step 11 Find bottom left and top right corners
    These are theoretical corners. They may not actually be "good" points.
    But the longest diagonal of the shmoo will be between these corners.

  • Step 12 Find the tuning point
    • Step1 Find the equation of diagonal between topRight(rxHigh,txHigh) and bottomLeft(rxLow,txLow) points.
    • Step2 Find gapLow, last point along the slope of bottom left read delay region.
    • Step3 If top right and bottom left have same read delay, put tuning point in the middle and adjust for temperature.
    • Step4 If top right and bottom left have different read delays, find gapHigh, the starting point along the slope of top left read delay region.
    • Step5 Find len1 = gapLow - topLeft, len2 = topRight - gapHigh.
    • Step6 Choose the read Delay region with maximum length.
    • Step7 Place the Phy tuning point in the corner farthest from the gap.

Features not Supported

  • PHY mode is not supported yet.
  • 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