Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! [include]


GPMC_Handle gGpmcHandle;
GPMC_Config* gGpmcHandle;

void open(void)
{
Expand Down
8 changes: 4 additions & 4 deletions source/board/flash/gpmc/flash_nand_gpmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static int32_t Flash_nandGpmcReadId (Flash_Config *config)
{
GPMC_Transaction trans;
GPMC_transactionInit(&trans);
trans.Buf = readId;
trans.Buf = (uint32_t*) readId;
trans.count = devConfig->idCfg.numBytes;
trans.transType = GPMC_TRANSACTION_TYPE_READ_CMDREG;

Expand Down Expand Up @@ -597,7 +597,7 @@ static int32_t Flash_nandGpmcReadPage(Flash_Config *config, uint32_t blockNum,
if(status == SystemP_SUCCESS)
{
GPMC_transactionInit(&trans);
trans.Buf = buf;
trans.Buf = (uint32_t*) buf;
trans.count = config->attrs->pageSize;
trans.transType = GPMC_TRANSACTION_TYPE_READ;
/* Read DATA either using the DMA or CPU prefetch read.
Expand Down Expand Up @@ -630,7 +630,7 @@ static int32_t Flash_nandGpmcReadPage(Flash_Config *config, uint32_t blockNum,
* Read ECC for the sectors in one cycle.
*/
GPMC_transactionInit(&trans);
trans.Buf = pEccData;
trans.Buf = (uint32_t*) pEccData;
trans.count = object->attrs.eccByteCount * object->attrs.eccSteps;
trans.transType = GPMC_TRANSACTION_TYPE_READ;
status += GPMC_nandReadData(object->gpmcHandle, &trans);
Expand Down Expand Up @@ -954,7 +954,7 @@ static int32_t Flash_nandGpmcWritePage(Flash_Config *config,
if(status == SystemP_SUCCESS)
{
GPMC_transactionInit(&trans);
trans.Buf = buf;
trans.Buf = (uint32_t*) buf;
trans.count = config->attrs->pageSize;;
trans.transType = GPMC_TRANSACTION_TYPE_WRITE;

Expand Down
2 changes: 1 addition & 1 deletion source/board/flash/gpmc/flash_nand_gpmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef struct

typedef struct {

GPMC_Handle gpmcHandle;
GPMC_Config *gpmcHandle;
Flash_NandGpmc_Attrs attrs;
uint8_t *dataMemScratch;
uint8_t *eccMemScratch;
Expand Down
2 changes: 1 addition & 1 deletion source/board/ram/gpmc/psram_gpmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" {
#include <drivers/gpmc.h>

typedef struct {
GPMC_Handle gpmcHandle;
GPMC_Config *gpmcHandle;
} Ram_GpmcPsramObject;

/* PSRAM specific externs */
Expand Down
27 changes: 9 additions & 18 deletions source/drivers/gpmc/v0/dma/gpmc_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <kernel/dpl/SystemP.h>
#include <string.h>
#include <drivers/gpmc/v0/dma/gpmc_dma.h>
#include <drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h>

/* ========================================================================== */
/* Macros & Typedefs */
Expand All @@ -60,40 +61,35 @@ extern uint32_t gGpmcDmaConfigNum;
/* Function Definitions */
/* ========================================================================== */

GPMC_DmaHandle GPMC_dmaOpen(int32_t index)
GpmcDma_UdmaArgs* GPMC_dmaOpen(int32_t index)
{
GPMC_DmaConfig *config = NULL;

if((gGpmcDmaConfigNum > 0) && (index >= 0))
{
config = &gGpmcDmaConfig[index];
if((config->fxns) && (config->fxns->dmaOpenFxn) && (config->gpmcDmaArgs))
if(config->gpmcDmaArgs)
{
int32_t status;

status = config->fxns->dmaOpenFxn(config->gpmcDmaArgs);
status = GpmcDma_udmaOpen(config->gpmcDmaArgs);
if(status != SystemP_SUCCESS)
{
config = NULL;
}
}
}

return (GPMC_DmaHandle)config;
return config->gpmcDmaArgs;
}

int32_t GPMC_dmaClose(GPMC_DmaHandle handle)
int32_t GPMC_dmaClose(GpmcDma_UdmaArgs *handle)
{
int32_t status = SystemP_SUCCESS;

if(handle != NULL)
{
GPMC_DmaConfig *config = (GPMC_DmaConfig *)handle;

if((config->fxns) && (config->fxns->dmaCloseFxn))
{
status = config->fxns->dmaCloseFxn(handle, config->gpmcDmaArgs);
}
status = GpmcDma_udmaClose(handle);
}
else
{
Expand All @@ -103,18 +99,13 @@ int32_t GPMC_dmaClose(GPMC_DmaHandle handle)
return status;
}

int32_t GPMC_dmaCopy(GPMC_DmaHandle handle, void* dst, void* src, uint32_t length, uint8_t fifoDrain)
int32_t GPMC_dmaCopy(GpmcDma_UdmaArgs *handle, uint32_t *dst, uint32_t *src, uint32_t length, uint8_t fifoDrain)
{
int32_t status = SystemP_SUCCESS;

if(handle != NULL)
{
GPMC_DmaConfig *config = (GPMC_DmaConfig *)handle;

if((config->fxns) && (config->fxns->dmaCopyFxn))
{
status = config->fxns->dmaCopyFxn(config->gpmcDmaArgs, dst, src, length, fifoDrain);
}
status = GpmcDma_udmaCopy(handle, dst, src, length, fifoDrain);
}
else
{
Expand Down
68 changes: 5 additions & 63 deletions source/drivers/gpmc/v0/dma/gpmc_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <stdint.h>
#include <kernel/dpl/SystemP.h>
#include <drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h>

#ifdef __cplusplus
extern "C"
Expand All @@ -56,71 +57,12 @@ extern "C"
* @{
*/

/**
* \brief Handle to the GPMC DMA Config Object returned by \ref GPMC_dmaOpen
*/
typedef void* GPMC_DmaHandle;

/**
* \brief Driver implementation to open a specific DMA driver channel - UDMA, EDMA etc
*
* Typically this callback is hidden from the end application and is implemented
* when a new DMA driver needs to be supported.
*
* \param gpmcDmaArgs [in] DMA specific arguments, obtained from the config
*
* \return SystemP_SUCCESS on success, else failure
*/
typedef int32_t (*GPMC_dmaOpenFxn)(void *gpmcDmaArgs);

/**
* \brief Driver implementation to close a specific DMA driver channel - UDMA, EDMA etc
*
* Typically this callback is hidden from the end application and is implemented
* when a new DMA driver needs to be supported.
*
* \param GPMC_DmaHandle [in] GPMC DMA Object handle returned from \ref GPMC_dmaOpen
* \param gpmcDmaArgs [in] DMA specific arguments, obtained from the config
*
* \return SystemP_SUCCESS on success, else failure
*/
typedef int32_t (*GPMC_dmaCloseFxn)(GPMC_DmaHandle, void *gpmcDmaArgs);

/**
* \brief Driver implementation to do a DMA copy using a specific DMA driver - UDMA, EDMA etc
*
* Typically this callback is hidden from the end application and is implemented
* when a new DMA driver needs to be supported.
*
* \param gpmcDmaArgs [in] DMA specific arguments, obtained from the config
* \param dst [in] Destination address to which the data is to be copied
* \param src [in] Source address from which the data is to be copied
* \param length [in] Data length
* \param fifoDrain [in] Drain GPMC FIFO
*
* \return SystemP_SUCCESS on success, else failure
*/
typedef int32_t (*GPMC_dmaCopyFxn)(void *gpmcDmaArgs, void *dst, void *src, uint32_t length, uint8_t fifoDrain);

/**
* \brief Driver implementation callbacks
*/
typedef struct GPMC_DmaFxns_s
{
GPMC_dmaOpenFxn dmaOpenFxn;
GPMC_dmaCloseFxn dmaCloseFxn;
GPMC_dmaCopyFxn dmaCopyFxn;

} GPMC_DmaFxns;

/**
* \brief GPMC DMA Configuration, these are filled by SysCfg based on the DMA driver that is selected
*/
typedef struct GPMC_DmaConfig_s
{
GPMC_DmaFxns *fxns;
/* Registered callbacks for a particular DMA driver. This will be set by Sysconfig depending on the DMA driver selected*/
void *gpmcDmaArgs;
GpmcDma_UdmaArgs *gpmcDmaArgs;
/* Arguments specific to a DMA driver. This will be typecasted to the specific DMA driver args struct
* when used by the appropriate callback. This struct will be defined in the specific DMA driver header file.
* Allocation of this struct will be done statically using Sysconfig code generation in the example code
Expand All @@ -137,7 +79,7 @@ typedef struct GPMC_DmaConfig_s
*
* \return Handle to the GPMC DMA Config Object
*/
GPMC_DmaHandle GPMC_dmaOpen(int32_t index);
GpmcDma_UdmaArgs* GPMC_dmaOpen(int32_t index);

/**
* \brief API to close an GPMC DMA channel
Expand All @@ -148,7 +90,7 @@ GPMC_DmaHandle GPMC_dmaOpen(int32_t index);
*
* \return SystemP_SUCCESS on success, else failure
*/
int32_t GPMC_dmaClose(GPMC_DmaHandle handle);
int32_t GPMC_dmaClose(GpmcDma_UdmaArgs *handle);

/**
* \brief API to do a DMA Copy using appropriate DMA Channel opened
Expand All @@ -163,7 +105,7 @@ int32_t GPMC_dmaClose(GPMC_DmaHandle handle);
*
* \return SystemP_SUCCESS on success, else failure
*/
int32_t GPMC_dmaCopy(GPMC_DmaHandle handle, void* dst, void* src, uint32_t length, uint8_t fifoDrain);
int32_t GPMC_dmaCopy(GpmcDma_UdmaArgs *handle, uint32_t *dst, uint32_t *src, uint32_t length, uint8_t fifoDrain);

/** @} */

Expand Down
50 changes: 17 additions & 33 deletions source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@
#include <kernel/dpl/CacheP.h>
#include <drivers/gpmc.h>

static int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs);
static int32_t GpmcDma_udmaClose(GPMC_DmaHandle handle, void* gpmcDmaArgs);
static int32_t GpmcDma_udmaCopy(void* gpmcDmaArgs, void* dst, void* src, uint32_t length, uint8_t fifoDrain);

GPMC_DmaFxns gGpmcDmaUdmaFxns =
{
.dmaOpenFxn = GpmcDma_udmaOpen,
.dmaCloseFxn = GpmcDma_udmaClose,
.dmaCopyFxn = GpmcDma_udmaCopy,
};

static int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs)
int32_t GpmcDma_udmaOpen(GpmcDma_UdmaArgs* gpmcDmaArgs)
{
int32_t status = SystemP_SUCCESS;
int32_t udmaStatus = UDMA_SOK;
Expand All @@ -61,19 +50,17 @@ static int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs)
uint8_t* trpdMem;
uint32_t trpdMemSize;

GpmcDma_UdmaArgs *udmaArgs = (GpmcDma_UdmaArgs *)gpmcDmaArgs;

drvHandle = udmaArgs->drvHandle;
chHandle = udmaArgs->chHandle;
trpdMem = (uint8_t *) udmaArgs->trpdMem;
trpdMemSize = udmaArgs->trpdMemSize;
drvHandle = gpmcDmaArgs->drvHandle;
chHandle = gpmcDmaArgs->chHandle;
trpdMem = (uint8_t *) gpmcDmaArgs->trpdMem;
trpdMemSize = gpmcDmaArgs->trpdMemSize;

/* Init channel parameters */
chType = UDMA_CH_TYPE_TR_BLK_COPY;
UdmaChPrms_init(&chPrms, chType);
chPrms.fqRingPrms.ringMem = udmaArgs->ringMem;
chPrms.fqRingPrms.ringMemSize = udmaArgs->ringMemSize;
chPrms.fqRingPrms.elemCnt = udmaArgs->ringElemCount;
chPrms.fqRingPrms.ringMem = gpmcDmaArgs->ringMem;
chPrms.fqRingPrms.ringMemSize = gpmcDmaArgs->ringMemSize;
chPrms.fqRingPrms.elemCnt = gpmcDmaArgs->ringElemCount;

/* Open channel for block copy */
udmaStatus = Udma_chOpen(drvHandle, chHandle, chType, &chPrms);
Expand Down Expand Up @@ -141,7 +128,7 @@ static int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs)

/* Mapping GPMC local DMA event to Global event for BCDMA trigger*/
UdmaUtils_mapLocaltoGlobalEvent(drvHandle,chHandle,
udmaArgs->localEventID,CSL_INTAGGR_EVT_DETECT_MODE_RISING_EDGE);
gpmcDmaArgs->localEventID,CSL_INTAGGR_EVT_DETECT_MODE_RISING_EDGE);

if (UDMA_SOK == udmaStatus)
{
Expand All @@ -155,14 +142,12 @@ static int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs)
return status;
}

static int32_t GpmcDma_udmaClose(GPMC_DmaHandle handle, void* gpmcDmaArgs)
int32_t GpmcDma_udmaClose(GpmcDma_UdmaArgs* handle)
{
int32_t status = SystemP_SUCCESS;
int32_t udmaStatus = UDMA_SOK;

GpmcDma_UdmaArgs *udmaArgs = (GpmcDma_UdmaArgs *)gpmcDmaArgs;

Udma_ChHandle chHandle = udmaArgs->chHandle;
Udma_ChHandle chHandle = handle->chHandle;

/* Flush any pending request from the free queue */
while(1)
Expand All @@ -188,14 +173,13 @@ static int32_t GpmcDma_udmaClose(GPMC_DmaHandle handle, void* gpmcDmaArgs)

}

static int32_t GpmcDma_udmaUpdateSubmitTR(void* gpmcDmaArgs, void* dst, void* src,
static int32_t GpmcDma_udmaUpdateSubmitTR(GpmcDma_UdmaArgs* gpmcDmaArgs, uint8_t *dst, uint8_t *src,
uint16_t icnt[4], int32_t dim[3], uint8_t fifodrain)
{
int32_t status = UDMA_SOK;
GpmcDma_UdmaArgs *udmaArgs = (GpmcDma_UdmaArgs *)gpmcDmaArgs;
Udma_ChHandle chHandle = udmaArgs->chHandle;
uint8_t *trpdMem = (uint8_t *) udmaArgs->trpdMem;
uint32_t trpdMemSize = udmaArgs->trpdMemSize;
Udma_ChHandle chHandle = gpmcDmaArgs->chHandle;
uint8_t *trpdMem = (uint8_t *) gpmcDmaArgs->trpdMem;
uint32_t trpdMemSize = gpmcDmaArgs->trpdMemSize;
uint64_t pDesc;
uint32_t trRespStatus;
uint64_t trpdMemPhy = (uint64_t) Udma_defaultVirtToPhyFxn(trpdMem, 0U, NULL);
Expand Down Expand Up @@ -261,7 +245,7 @@ static int32_t GpmcDma_udmaUpdateSubmitTR(void* gpmcDmaArgs, void* dst, void* sr
return status;
}

static int32_t GpmcDma_udmaCopy(void* gpmcDmaArgs, void* dst, void* src, uint32_t length, uint8_t fifoDrain)
int32_t GpmcDma_udmaCopy(GpmcDma_UdmaArgs* gpmcDmaArgs, uint32_t *dst, uint32_t *src, uint32_t length, uint8_t fifoDrain)
{
int32_t status = SystemP_SUCCESS;
int32_t udmaStatus = UDMA_SOK;
Expand Down Expand Up @@ -309,7 +293,7 @@ static int32_t GpmcDma_udmaCopy(void* gpmcDmaArgs, void* dst, void* src, uint32_
dim[2] = (int32_t)icnt[0] * (int32_t)icnt[1] * (int32_t)icnt[2];
}

udmaStatus = GpmcDma_udmaUpdateSubmitTR(gpmcDmaArgs, dst, src, icnt, dim, fifoDrain);
udmaStatus = GpmcDma_udmaUpdateSubmitTR(gpmcDmaArgs, (uint8_t*)dst, (uint8_t*)src, icnt, dim, fifoDrain);

if(rmainder != 0)
{
Expand Down
8 changes: 5 additions & 3 deletions source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ typedef struct GpmcDma_UdmaArgs_s
/**< UDMA driver handle */
void *chHandle;
/**< UDMA channel handle */
void *trpdMem;
uint8_t *trpdMem;
/**< UDMA TR PD memory pointers */
uint32_t trpdMemSize;
/**< Size of TR PD memory */
void *ringMem;
uint8_t *ringMem;
/**< UDMA Ring memory pointers */
uint32_t ringMemSize;
/**< Size of Ring Memory */
Expand All @@ -64,7 +64,9 @@ typedef struct GpmcDma_UdmaArgs_s

} GpmcDma_UdmaArgs;

extern GPMC_DmaFxns gGpmcDmaUdmaFxns;
int32_t GpmcDma_udmaOpen(GpmcDma_UdmaArgs* gpmcDmaArgs);
int32_t GpmcDma_udmaClose(GpmcDma_UdmaArgs* handle);
int32_t GpmcDma_udmaCopy(GpmcDma_UdmaArgs* gpmcDmaArgs, uint32_t *dst, uint32_t *src, uint32_t length, uint8_t fifoDrain);

#ifdef __cplusplus
}
Expand Down
Loading
Loading