AM243x MCU+ SDK  08.03.00
PCIE

PCIE is a peripheral used for high speed data transfer between devices. The PCIe driver provides API to perform initialization, configuration of End point (EP)and Root complex (RC) mode of operation, configuring and sending interrupts.

Features Supported

Note
PCIe makes use of 2 Ring Accelerators (Rings for IPC), one each for MSI and MSIx to route interrupts to the core.
The actual index for the Ring Accelerator, Global Event and Virtual Interrupt is depended on the Board Config for the soc and core.
  • EP and RC operation
  • Gen 2 operation speed
  • x1 lane support
  • Legacy interrupts
  • MSI (Message Signalled Interrupt)
  • MSIx (Message Signalled Interrupt Extended)

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.

SysConfig can be used to configure below parameters apart from common configuration like Clock,MPU,RAT and others.

  • PCIe operation mode - Root complex (RC) or End point (EP)
  • PCIe instances
  • Operation speed (Gen1, Gen2 or Gen3)
  • Number of lanes
  • Inbound Address Translation Unit (ATU) configuration
  • Outbound Address Translation Unit (ATU) configuration

Features NOT supported

  • Bridge mode of operation
  • Bus enumeration
  • x2 and x4 lanes

Usage Overview

Initializing PCIe driver

Pcie_init() must be called before any other PCIe APIs. This function iterates through the elements of the gPcieConfig[] array, initializing the driver. Please note that initializing of PCIe driver is taken care by the SysConfig generated code.

Opening PCIe driver

After initializing the driver by calling Pcie_init(), the application can open a PCIe instance by calling Pcie_open(). Please note that the opening of PCIe driver is taken care by the SysConfig generated code. This function takes and index into the gPcieConfig[] array, and the PCIe parameters data structure. The PCIe instance is specified by the index of the PCIe in the gPcieConfig[]. Calling Pcie_open() second time with same index, previously passed to Pcie_open() will result in an error.

Important Usage Guidelines

  • Care must be taken so that the ATU address regions does not overlap. The ATU configuration can be done using SysConfig.
  • The zeroth Outbound ATU region for RC device is used for configuration space access of the remote EP.

Example Usage

Include the below file to access the APIs

#include <drivers/pcie.h>

Instance open Example

gPcieHandle = Pcie_open(CONFIG_PCIE0);
DebugP_assert(gPcieHandle != NULL);

Instance close Example

Pcie_close(gPcieHandle);

Outbound ATU config Example

int32_t status;
Pcie_AtuRegionParams regionParams;
uint32_t regionIndex = 1;
regionParams.tlpType = PCIE_TLP_TYPE_MEM;
regionParams.lowerBaseAddr = 0x68000000UL + 0x01000000U;
regionParams.upperBaseAddr = 0x0;
regionParams.regionWindowSize = 0xFFFU;
regionParams.lowerTargetAddr = 0x70000000U;
regionParams.upperTargetAddr = 0x0U;
status = Pcie_atuRegionConfig (gPcieHandle, PCIE_LOCATION_LOCAL, regionIndex, &regionParams);

Inbound ATU config Example

int32_t status;
Pcie_AtuRegionParams regionParams;
uint32_t regionIndex = 1;
regionParams.tlpType = PCIE_TLP_TYPE_MEM;
regionParams.lowerBaseAddr = 0x90000000U;
regionParams.upperBaseAddr = 0x0;
regionParams.regionWindowSize = 0xFFFU;
regionParams.lowerTargetAddr = (uint32_t)dst_buf;
regionParams.upperTargetAddr = 0x0U;
status = Pcie_atuRegionConfig (gPcieHandle, PCIE_LOCATION_LOCAL, regionIndex, &regionParams);

BAR Configuration for EP Example

Pcie_BarCfg barCfg;
int32_t status;
uint32_t regionIndex = 0;
barCfg.mode = PCIE_EP_MODE;
barCfg.barxc = PCIE_BARC_32B_MEM_BAR_NON_PREFETCH;
barCfg.barxa = PCIE_RCBARA_4K;
barCfg.idx = regionIndex;
status = Pcie_cfgBar (object->handle, &barCfg);

API

APIs for PCIE

PCIE_EP_MODE
@ PCIE_EP_MODE
Definition: pcie/pcie.h:89
Pcie_BarCfg::barxc
uint8_t barxc
Definition: pcie/pcie.h:501
Pcie_AtuRegionParams::lowerTargetAddr
uint32_t lowerTargetAddr
Definition: pcie/pcie.h:565
PCIE_TLP_TYPE_MEM
@ PCIE_TLP_TYPE_MEM
Definition: pcie/pcie.h:170
Pcie_close
void Pcie_close(Pcie_Handle handle)
Function to close PCIe peripheral specified by PCIe handle.
PCIE_ATU_REGION_DIR_OUTBOUND
@ PCIE_ATU_REGION_DIR_OUTBOUND
Definition: pcie/pcie.h:160
Pcie_BarCfg::barxa
uint8_t barxa
Definition: pcie/pcie.h:503
Pcie_AtuRegionParams::lowerBaseAddr
uint32_t lowerBaseAddr
Definition: pcie/pcie.h:550
pcie.h
Pcie_BarCfg
PCIe BAR configuration info.
Definition: pcie/pcie.h:485
Pcie_AtuRegionParams::regionWindowSize
uint32_t regionWindowSize
Definition: pcie/pcie.h:560
Pcie_AtuRegionParams::tlpType
Pcie_TlpType tlpType
Definition: pcie/pcie.h:535
Pcie_open
Pcie_Handle Pcie_open(uint32_t index)
This function opens a given PCIe peripheral.
Pcie_AtuRegionParams
This Structure defines the ATU region parameters.
Definition: pcie/pcie.h:530
SystemP_SUCCESS
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
Pcie_AtuRegionParams::upperTargetAddr
uint32_t upperTargetAddr
Definition: pcie/pcie.h:570
Pcie_atuRegionConfig
int32_t Pcie_atuRegionConfig(Pcie_Handle handle, Pcie_Location location, uint32_t atuRegionIndex, const Pcie_AtuRegionParams *atuRegionParams)
Configure address translation registers.
Pcie_AtuRegionParams::regionDir
Pcie_AtuRegionDir regionDir
Definition: pcie/pcie.h:531
Pcie_cfgBar
int32_t Pcie_cfgBar(Pcie_Handle handle, const Pcie_BarCfg *barCfg)
Configure a BAR Register (32 bits)
PCIE_ATU_REGION_DIR_INBOUND
@ PCIE_ATU_REGION_DIR_INBOUND
Definition: pcie/pcie.h:161
Pcie_BarCfg::location
Pcie_Location location
Definition: pcie/pcie.h:487
Pcie_BarCfg::idx
uint8_t idx
Definition: pcie/pcie.h:499
PCIE_LOCATION_LOCAL
@ PCIE_LOCATION_LOCAL
Definition: pcie/pcie.h:429
Pcie_BarCfg::mode
Pcie_Mode mode
Definition: pcie/pcie.h:489
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:159
Pcie_AtuRegionParams::upperBaseAddr
uint32_t upperBaseAddr
Definition: pcie/pcie.h:555