From ce3c08892ecdd493f5fa1da90ba866a51870f19c Mon Sep 17 00:00:00 2001 From: Nithyaa shri R B Date: Fri, 2 May 2025 17:01:30 +0530 Subject: [PATCH 1/2] am64/am24: gpmc: Code cleanup - Remove DMA function pointers and replace with absolute function calls. Fixes: SITSW-7155 Signed-off-by: Nithyaa shri R B --- source/drivers/gpmc/v0/dma/gpmc_dma.c | 13 ++--- source/drivers/gpmc/v0/dma/gpmc_dma.h | 54 ------------------- .../drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c | 17 ++---- .../drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h | 4 +- 4 files changed, 13 insertions(+), 75 deletions(-) diff --git a/source/drivers/gpmc/v0/dma/gpmc_dma.c b/source/drivers/gpmc/v0/dma/gpmc_dma.c index b3260aad5fa..1b43f4a6aa1 100644 --- a/source/drivers/gpmc/v0/dma/gpmc_dma.c +++ b/source/drivers/gpmc/v0/dma/gpmc_dma.c @@ -43,6 +43,7 @@ #include #include #include +#include /* ========================================================================== */ /* Macros & Typedefs */ @@ -67,11 +68,11 @@ GPMC_DmaHandle GPMC_dmaOpen(int32_t index) 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; @@ -90,9 +91,9 @@ int32_t GPMC_dmaClose(GPMC_DmaHandle handle) { GPMC_DmaConfig *config = (GPMC_DmaConfig *)handle; - if((config->fxns) && (config->fxns->dmaCloseFxn)) + if(config->gpmcDmaArgs) { - status = config->fxns->dmaCloseFxn(handle, config->gpmcDmaArgs); + status = GpmcDma_udmaClose(handle, config->gpmcDmaArgs); } } else @@ -111,9 +112,9 @@ int32_t GPMC_dmaCopy(GPMC_DmaHandle handle, void* dst, void* src, uint32_t lengt { GPMC_DmaConfig *config = (GPMC_DmaConfig *)handle; - if((config->fxns) && (config->fxns->dmaCopyFxn)) + if(config->gpmcDmaArgs) { - status = config->fxns->dmaCopyFxn(config->gpmcDmaArgs, dst, src, length, fifoDrain); + status = GpmcDma_udmaCopy(config->gpmcDmaArgs, dst, src, length, fifoDrain); } } else diff --git a/source/drivers/gpmc/v0/dma/gpmc_dma.h b/source/drivers/gpmc/v0/dma/gpmc_dma.h index 7672ab2d192..2cfa32573d1 100644 --- a/source/drivers/gpmc/v0/dma/gpmc_dma.h +++ b/source/drivers/gpmc/v0/dma/gpmc_dma.h @@ -61,65 +61,11 @@ extern "C" */ 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; /* 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. diff --git a/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c b/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c index f64559ebab7..e3bdcd823e5 100644 --- a/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c +++ b/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c @@ -37,18 +37,7 @@ #include #include -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(void* gpmcDmaArgs) { int32_t status = SystemP_SUCCESS; int32_t udmaStatus = UDMA_SOK; @@ -155,7 +144,7 @@ static int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs) return status; } -static int32_t GpmcDma_udmaClose(GPMC_DmaHandle handle, void* gpmcDmaArgs) +int32_t GpmcDma_udmaClose(GPMC_DmaHandle handle, void* gpmcDmaArgs) { int32_t status = SystemP_SUCCESS; int32_t udmaStatus = UDMA_SOK; @@ -261,7 +250,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(void* gpmcDmaArgs, void* dst, void* src, uint32_t length, uint8_t fifoDrain) { int32_t status = SystemP_SUCCESS; int32_t udmaStatus = UDMA_SOK; diff --git a/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h b/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h index dc7367ae0ea..0d9ec16b8f0 100644 --- a/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h +++ b/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h @@ -64,7 +64,9 @@ typedef struct GpmcDma_UdmaArgs_s } GpmcDma_UdmaArgs; -extern GPMC_DmaFxns gGpmcDmaUdmaFxns; +int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs); +int32_t GpmcDma_udmaClose(GPMC_DmaHandle handle, void* gpmcDmaArgs); +int32_t GpmcDma_udmaCopy(void* gpmcDmaArgs, void* dst, void* src, uint32_t length, uint8_t fifoDrain); #ifdef __cplusplus } From 9b631b2f7eea9ee6ff7c4686e1997156f7a30184 Mon Sep 17 00:00:00 2001 From: Nithyaa shri R B Date: Tue, 6 May 2025 11:00:52 +0530 Subject: [PATCH 2/2] am64/am24: gpmc: Code cleanup - Remove DMA void* pointers and use fixed DMA_config type. - Include necessary headers to use the appropriate structure pointer. Fixes: SITSW-7155 Signed-off-by: Nithyaa shri R B --- .../doxy_samples/drivers/Gpmc_sample_v0.c | 2 +- source/board/flash/gpmc/flash_nand_gpmc.c | 8 +- source/board/flash/gpmc/flash_nand_gpmc.h | 2 +- source/board/ram/gpmc/psram_gpmc.h | 2 +- source/drivers/gpmc/v0/dma/gpmc_dma.c | 22 +--- source/drivers/gpmc/v0/dma/gpmc_dma.h | 14 +-- .../drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c | 39 +++--- .../drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h | 10 +- source/drivers/gpmc/v0/gpmc.h | 70 +++++------ source/drivers/gpmc/v0/gpmc_nandlike_v0.c | 114 +++++++++--------- source/drivers/gpmc/v0/gpmc_norlike_v0.c | 16 +-- source/drivers/gpmc/v0/gpmc_priv_v0.c | 20 +-- source/drivers/gpmc/v0/gpmc_priv_v0.h | 6 +- source/drivers/gpmc/v0/gpmc_v0.c | 65 +++++----- 14 files changed, 178 insertions(+), 212 deletions(-) diff --git a/docs_src/docs/api_guide/doxy_samples/drivers/Gpmc_sample_v0.c b/docs_src/docs/api_guide/doxy_samples/drivers/Gpmc_sample_v0.c index 92a0603ab96..fac327f172b 100644 --- a/docs_src/docs/api_guide/doxy_samples/drivers/Gpmc_sample_v0.c +++ b/docs_src/docs/api_guide/doxy_samples/drivers/Gpmc_sample_v0.c @@ -4,7 +4,7 @@ //! [include] -GPMC_Handle gGpmcHandle; +GPMC_Config* gGpmcHandle; void open(void) { diff --git a/source/board/flash/gpmc/flash_nand_gpmc.c b/source/board/flash/gpmc/flash_nand_gpmc.c index 88aabd3143a..9bb6f9222b7 100644 --- a/source/board/flash/gpmc/flash_nand_gpmc.c +++ b/source/board/flash/gpmc/flash_nand_gpmc.c @@ -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; @@ -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. @@ -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); @@ -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; diff --git a/source/board/flash/gpmc/flash_nand_gpmc.h b/source/board/flash/gpmc/flash_nand_gpmc.h index 6b52da3dcc5..a4374ff41f0 100644 --- a/source/board/flash/gpmc/flash_nand_gpmc.h +++ b/source/board/flash/gpmc/flash_nand_gpmc.h @@ -50,7 +50,7 @@ typedef struct typedef struct { - GPMC_Handle gpmcHandle; + GPMC_Config *gpmcHandle; Flash_NandGpmc_Attrs attrs; uint8_t *dataMemScratch; uint8_t *eccMemScratch; diff --git a/source/board/ram/gpmc/psram_gpmc.h b/source/board/ram/gpmc/psram_gpmc.h index 8539bcf7c1d..56077289f2a 100644 --- a/source/board/ram/gpmc/psram_gpmc.h +++ b/source/board/ram/gpmc/psram_gpmc.h @@ -40,7 +40,7 @@ extern "C" { #include typedef struct { - GPMC_Handle gpmcHandle; + GPMC_Config *gpmcHandle; } Ram_GpmcPsramObject; /* PSRAM specific externs */ diff --git a/source/drivers/gpmc/v0/dma/gpmc_dma.c b/source/drivers/gpmc/v0/dma/gpmc_dma.c index 1b43f4a6aa1..bc5f75d621b 100644 --- a/source/drivers/gpmc/v0/dma/gpmc_dma.c +++ b/source/drivers/gpmc/v0/dma/gpmc_dma.c @@ -61,7 +61,7 @@ extern uint32_t gGpmcDmaConfigNum; /* Function Definitions */ /* ========================================================================== */ -GPMC_DmaHandle GPMC_dmaOpen(int32_t index) +GpmcDma_UdmaArgs* GPMC_dmaOpen(int32_t index) { GPMC_DmaConfig *config = NULL; @@ -80,21 +80,16 @@ GPMC_DmaHandle GPMC_dmaOpen(int32_t index) } } - 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->gpmcDmaArgs) - { - status = GpmcDma_udmaClose(handle, config->gpmcDmaArgs); - } + status = GpmcDma_udmaClose(handle); } else { @@ -104,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->gpmcDmaArgs) - { - status = GpmcDma_udmaCopy(config->gpmcDmaArgs, dst, src, length, fifoDrain); - } + status = GpmcDma_udmaCopy(handle, dst, src, length, fifoDrain); } else { diff --git a/source/drivers/gpmc/v0/dma/gpmc_dma.h b/source/drivers/gpmc/v0/dma/gpmc_dma.h index 2cfa32573d1..66508934147 100644 --- a/source/drivers/gpmc/v0/dma/gpmc_dma.h +++ b/source/drivers/gpmc/v0/dma/gpmc_dma.h @@ -41,6 +41,7 @@ #include #include +#include #ifdef __cplusplus extern "C" @@ -56,17 +57,12 @@ extern "C" * @{ */ -/** - * \brief Handle to the GPMC DMA Config Object returned by \ref GPMC_dmaOpen - */ -typedef void* GPMC_DmaHandle; - /** * \brief GPMC DMA Configuration, these are filled by SysCfg based on the DMA driver that is selected */ typedef struct GPMC_DmaConfig_s { - 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 @@ -83,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 @@ -94,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 @@ -109,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); /** @} */ diff --git a/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c b/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c index e3bdcd823e5..d8f031d28c0 100644 --- a/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c +++ b/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.c @@ -37,7 +37,7 @@ #include #include -int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs) +int32_t GpmcDma_udmaOpen(GpmcDma_UdmaArgs* gpmcDmaArgs) { int32_t status = SystemP_SUCCESS; int32_t udmaStatus = UDMA_SOK; @@ -50,19 +50,17 @@ 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); @@ -130,7 +128,7 @@ 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) { @@ -144,14 +142,12 @@ int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs) return status; } -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) @@ -177,14 +173,13 @@ 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); @@ -250,7 +245,7 @@ static int32_t GpmcDma_udmaUpdateSubmitTR(void* gpmcDmaArgs, void* dst, void* sr return status; } -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; @@ -298,7 +293,7 @@ int32_t GpmcDma_udmaCopy(void* gpmcDmaArgs, void* dst, void* src, uint32_t lengt 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) { diff --git a/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h b/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h index 0d9ec16b8f0..6449c84eded 100644 --- a/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h +++ b/source/drivers/gpmc/v0/dma/udma/gpmc_dma_udma.h @@ -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 */ @@ -64,9 +64,9 @@ typedef struct GpmcDma_UdmaArgs_s } GpmcDma_UdmaArgs; -int32_t GpmcDma_udmaOpen(void* gpmcDmaArgs); -int32_t GpmcDma_udmaClose(GPMC_DmaHandle handle, void* gpmcDmaArgs); -int32_t GpmcDma_udmaCopy(void* gpmcDmaArgs, void* dst, void* src, uint32_t length, uint8_t fifoDrain); +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 } diff --git a/source/drivers/gpmc/v0/gpmc.h b/source/drivers/gpmc/v0/gpmc.h index a0266c7ce7e..4980855cf18 100644 --- a/source/drivers/gpmc/v0/gpmc.h +++ b/source/drivers/gpmc/v0/gpmc.h @@ -65,6 +65,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -473,9 +474,6 @@ extern "C" { #define GPMC_MEM_TYPE_PSRAM (1) #define GPMC_MEM_TYPE_NORLIKE (1) //Same as pSRAM -/** \brief A handle that is returned from a #GPMC_open() call */ -typedef void* GPMC_Handle; - /* ========================================================================== */ /* Structure Declarations */ /* ========================================================================== */ @@ -593,7 +591,7 @@ typedef struct GPMC_Transaction_s { /**< Transaction type : GPMC_TransactionType */ uint32_t count; /**< Number of bytes for this transaction */ - void *Buf; + uint32_t *Buf; /**< void * to a buffer to receive/send data */ void *arg; /**< Argument to be passed to the callback function */ @@ -610,8 +608,7 @@ typedef struct GPMC_Transaction_s { * \param handle GPMC_Handle * \param transaction* GPMC_Transaction* */ -typedef void (*GPMC_CallbackFxn)(GPMC_Handle handle, - GPMC_Transaction * transaction); +typedef void (*GPMC_CallbackFxn)(SemaphoreP_Object *obj); /** @@ -670,11 +667,6 @@ typedef struct * */ typedef struct GPMC_Object_s { - - GPMC_Handle handle; - /**< Instance handle */ - GPMC_CallbackFxn transferCallbackFxn; - /**< Callback function pointer */ GPMC_Params params; /**< Driver user configurable params structure */ GPMC_OperatingMode operMode; @@ -692,7 +684,7 @@ typedef struct GPMC_Object_s { /**< Transfer Sync Semaphore object */ GPMC_Transaction *transaction; /**< Pointer to current transaction struct */ - void* gpmcDmaHandle; + GpmcDma_UdmaArgs* gpmcDmaHandle; /**< DMA configuration handle */ } GPMC_Object; @@ -865,7 +857,7 @@ void GPMC_deinit(void); * \sa #GPMC_init() * \sa #GPMC_close() */ -GPMC_Handle GPMC_open(uint32_t index, const GPMC_Params *prms); +GPMC_Config* GPMC_open(uint32_t index, const GPMC_Params *prms); /** * \brief Function to close a GPMC peripheral specified by the GPMC handle @@ -876,7 +868,7 @@ GPMC_Handle GPMC_open(uint32_t index, const GPMC_Params *prms); * * \sa #GPMC_open() */ -void GPMC_close(GPMC_Handle handle); +void GPMC_close(GPMC_Config *handle); /** * \brief This function returns the input clk frequency GPMC was programmed at @@ -887,7 +879,7 @@ void GPMC_close(GPMC_Handle handle); * * \return GPMC RCLK in Hertz */ -uint32_t GPMC_getInputClk(GPMC_Handle handle); +uint32_t GPMC_getInputClk(GPMC_Config *handle); /** * \brief This function returns the handle of an open GPMC Instance from the instance index @@ -901,7 +893,7 @@ uint32_t GPMC_getInputClk(GPMC_Handle handle); * \sa #GPMC_init() * \sa #GPMC_open() */ -GPMC_Handle GPMC_getHandle(uint32_t driverInstanceIndex); +GPMC_Config* GPMC_getHandle(uint32_t driverInstanceIndex); /** * \brief Function to initialise #GPMC_nandCmdParams structure to default values. @@ -922,7 +914,7 @@ void GPMC_writeNandCommandParamsInit(GPMC_nandCmdParams *cmdParams); * \return SystemP_SUCCESS or SystemP_FAILURE * */ -int32_t GPMC_writeNandCommand(GPMC_Handle handle, GPMC_nandCmdParams *cmdParams); +int32_t GPMC_writeNandCommand(GPMC_Config *handle, GPMC_nandCmdParams *cmdParams); /** * \brief Function to initialise #GPMC_Transaction structure to default values. @@ -943,7 +935,7 @@ void GPMC_transactionInit(GPMC_Transaction *trans); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_nandReadData(GPMC_Handle handle, GPMC_Transaction *trans); +int32_t GPMC_nandReadData(GPMC_Config *handle, GPMC_Transaction *trans); /** * \brief Function to write data to NANDflash using CPU prefetch/post write engine. @@ -954,7 +946,7 @@ int32_t GPMC_nandReadData(GPMC_Handle handle, GPMC_Transaction *trans); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_nandWriteData(GPMC_Handle handle, GPMC_Transaction *trans); +int32_t GPMC_nandWriteData(GPMC_Config *handle, GPMC_Transaction *trans); /** * \brief Function to set device width for GPMC instance connected to external @@ -965,7 +957,7 @@ int32_t GPMC_nandWriteData(GPMC_Handle handle, GPMC_Transaction *trans); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_setDeviceSize(GPMC_Handle handle); +int32_t GPMC_setDeviceSize(GPMC_Config *handle); /** * \brief Function to set device type (NANDLIKE OR NORLIKE) for GPMC instance connected @@ -976,7 +968,7 @@ int32_t GPMC_setDeviceSize(GPMC_Handle handle); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_setDeviceType(GPMC_Handle handle); +int32_t GPMC_setDeviceType(GPMC_Config *handle); /** * \brief Function to configure GPMC timing parameters. @@ -986,7 +978,7 @@ int32_t GPMC_setDeviceType(GPMC_Handle handle); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_configureTimingParameters(GPMC_Handle handle); +int32_t GPMC_configureTimingParameters(GPMC_Config *handle); /** * \brief Function to set ECC used and unused bytes size in nibbles. @@ -1000,7 +992,7 @@ int32_t GPMC_configureTimingParameters(GPMC_Handle handle); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccValueSizeSet(GPMC_Handle handle, uint32_t eccSize, uint32_t eccSizeVal); +int32_t GPMC_eccValueSizeSet(GPMC_Config *handle, uint32_t eccSize, uint32_t eccSizeVal); /** * \brief Function to configure ELM module for error correction. @@ -1012,7 +1004,7 @@ int32_t GPMC_eccValueSizeSet(GPMC_Handle handle, uint32_t eccSize, uint32_t eccS * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccBchConfigureElm(GPMC_Handle handle, uint8_t numSectors); +int32_t GPMC_eccBchConfigureElm(GPMC_Config *handle, uint8_t numSectors); /** * \brief Function to configure GPMC ECC engine for BCH algorithm @@ -1024,7 +1016,7 @@ int32_t GPMC_eccBchConfigureElm(GPMC_Handle handle, uint8_t numSectors); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccEngineBCHConfig (GPMC_Handle handle, uint32_t eccSteps); +int32_t GPMC_eccEngineBCHConfig (GPMC_Config *handle, uint32_t eccSteps); /** * \brief Function to enable GPMC ECC engine. @@ -1033,7 +1025,7 @@ int32_t GPMC_eccEngineBCHConfig (GPMC_Handle handle, uint32_t eccSteps); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccEngineEnable(GPMC_Handle handle); +int32_t GPMC_eccEngineEnable(GPMC_Config *handle); /** * \brief Function to clear GPMC ECC result register. @@ -1041,7 +1033,7 @@ int32_t GPMC_eccEngineEnable(GPMC_Handle handle); * \param handle An #GPMC_Handle returned from an #GPMC_open() * */ -void GPMC_eccResultRegisterClear(GPMC_Handle handle); +void GPMC_eccResultRegisterClear(GPMC_Config *handle); /** * \brief Function to fill BCH syndrome value per sector to ELM module. @@ -1055,7 +1047,7 @@ void GPMC_eccResultRegisterClear(GPMC_Handle handle); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccBchFillSyndromeValue(GPMC_Handle handle, uint32_t sector, uint32_t *bchData); +int32_t GPMC_eccBchFillSyndromeValue(GPMC_Config *handle, uint32_t sector, uint32_t *bchData); /** * \brief Function to start error processing for a sector by ELM module. @@ -1068,7 +1060,7 @@ int32_t GPMC_eccBchFillSyndromeValue(GPMC_Handle handle, uint32_t sector, uint32 * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccBchStartErrorProcessing(GPMC_Handle handle, uint8_t sector); +int32_t GPMC_eccBchStartErrorProcessing(GPMC_Config *handle, uint8_t sector); /** * \brief Function to get error processing status for a sector by ELM module. @@ -1079,7 +1071,7 @@ int32_t GPMC_eccBchStartErrorProcessing(GPMC_Handle handle, uint8_t sector); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccBchCheckErrorProcessingStatus(GPMC_Handle handle, uint32_t sector); +int32_t GPMC_eccBchCheckErrorProcessingStatus(GPMC_Config *handle, uint32_t sector); /** * \brief Function to get number of errors per sector by ELM module. @@ -1094,7 +1086,7 @@ int32_t GPMC_eccBchCheckErrorProcessingStatus(GPMC_Handle handle, uint32_t secto * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccBchSectorGetError(GPMC_Handle handle, uint32_t sector, uint32_t *errCount, uint32_t *errLoc); +int32_t GPMC_eccBchSectorGetError(GPMC_Config *handle, uint32_t sector, uint32_t *errCount, uint32_t *errLoc); /** * \brief Function to compute BCH syndrome polynomial for NAND write operation. @@ -1107,7 +1099,7 @@ int32_t GPMC_eccBchSectorGetError(GPMC_Handle handle, uint32_t sector, uint32_t * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccCalculateBchSyndromePolynomial(GPMC_Handle handle, uint8_t *pEccdata, uint32_t sector); +int32_t GPMC_eccCalculateBchSyndromePolynomial(GPMC_Config *handle, uint8_t *pEccdata, uint32_t sector); /** * \brief Function to get BCH syndrome polynomial per sector NAND read operation. @@ -1120,7 +1112,7 @@ int32_t GPMC_eccCalculateBchSyndromePolynomial(GPMC_Handle handle, uint8_t *pEcc * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_eccGetBchSyndromePolynomial(GPMC_Handle handle, uint32_t sector, uint32_t *bchData); +int32_t GPMC_eccGetBchSyndromePolynomial(GPMC_Config *handle, uint32_t sector, uint32_t *bchData); /** * \brief Function to configure GPMC PREFETCH read and POST write engine. @@ -1130,7 +1122,7 @@ int32_t GPMC_eccGetBchSyndromePolynomial(GPMC_Handle handle, uint32_t sector, ui * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_configurePrefetchPostWriteEngine(GPMC_Handle handle); +int32_t GPMC_configurePrefetchPostWriteEngine(GPMC_Config *handle); /** * \brief Function to disable WRITE protect line. @@ -1140,7 +1132,7 @@ int32_t GPMC_configurePrefetchPostWriteEngine(GPMC_Handle handle); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_disableFlashWriteProtect(GPMC_Handle handle); +int32_t GPMC_disableFlashWriteProtect(GPMC_Config *handle); /** * \brief Function to disable WRITE protect line. @@ -1150,7 +1142,7 @@ int32_t GPMC_disableFlashWriteProtect(GPMC_Handle handle); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_enableFlashWriteProtect(GPMC_Handle handle); +int32_t GPMC_enableFlashWriteProtect(GPMC_Config *handle); /** * \brief Function to create correct address based on bus width. @@ -1176,7 +1168,7 @@ uint8_t *GPMC_norMakeAddr(uint8_t busWidth,uint32_t blkAddr,uint32_t offset); * \param cmdBuf Buffer pointer to store the modified cmd. * */ -void GPMC_norMakeCmd(uint8_t busWidth, uint32_t cmd, void *cmdBuf); +void GPMC_norMakeCmd(uint8_t busWidth, uint32_t cmd, uint8_t *cmdBuf); /** * \brief Function to read data from norlike device. @@ -1192,7 +1184,7 @@ void GPMC_norMakeCmd(uint8_t busWidth, uint32_t cmd, void *cmdBuf); * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_norReadData(GPMC_Handle handle, uint32_t offset,uint8_t *buf, uint32_t len); +int32_t GPMC_norReadData(GPMC_Config *handle, uint32_t offset,uint8_t *buf, uint32_t len); /** * \brief Function to write data to norlike device. @@ -1208,7 +1200,7 @@ int32_t GPMC_norReadData(GPMC_Handle handle, uint32_t offset,uint8_t *buf, uint3 * * \return SystemP_SUCCESS or SystemP_FAILURE */ -int32_t GPMC_norWriteData(GPMC_Handle handle,uint32_t offset,uint8_t *buf, uint32_t len); +int32_t GPMC_norWriteData(GPMC_Config *handle,uint32_t offset,uint8_t *buf, uint32_t len); /* ========================================================================== */ /* Static Function Definitions */ diff --git a/source/drivers/gpmc/v0/gpmc_nandlike_v0.c b/source/drivers/gpmc/v0/gpmc_nandlike_v0.c index 5286a9014d5..44bd96837f4 100644 --- a/source/drivers/gpmc/v0/gpmc_nandlike_v0.c +++ b/source/drivers/gpmc/v0/gpmc_nandlike_v0.c @@ -53,28 +53,28 @@ /* ========================================================================== */ /* Internal functions */ -static uint32_t GPMC_eccBchResultGet(GPMC_Handle handle, uint32_t resIndex, uint32_t sector); -static void GPMC_eccResultSizeSelect(GPMC_Handle handle, uint32_t eccResReg, +static uint32_t GPMC_eccBchResultGet(GPMC_Config *handle, uint32_t resIndex, uint32_t sector); +static void GPMC_eccResultSizeSelect(GPMC_Config *handle, uint32_t eccResReg, uint32_t eccSize); -static void GPMC_nandAddressWrite(GPMC_Handle handle, uint32_t address); -static void GPMC_nandCommandWrite(GPMC_Handle handle, uint32_t cmd); -static int32_t GPMC_prefetchPostWriteConfigEnable(GPMC_Handle handle, uint8_t mode, +static void GPMC_nandAddressWrite(GPMC_Config *handle, uint32_t address); +static void GPMC_nandCommandWrite(GPMC_Config *handle, uint32_t cmd); +static int32_t GPMC_prefetchPostWriteConfigEnable(GPMC_Config *handle, uint8_t mode, uint32_t transferCount, uint8_t modeDMA); -static int32_t GPMC_prefetchPostWriteConfigDisable(GPMC_Handle handle); +static int32_t GPMC_prefetchPostWriteConfigDisable(GPMC_Config *handle); /* ========================================================================== */ /* Function Definitions */ /* ========================================================================== */ -int32_t GPMC_configurePrefetchPostWriteEngine(GPMC_Handle handle) +int32_t GPMC_configurePrefetchPostWriteEngine(GPMC_Config *handle) { int32_t status = SystemP_SUCCESS; /* Input parameter validation */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; - GPMC_Object *object = ((GPMC_Config*)handle)->object; + const GPMC_HwAttrs *attrs = handle->attrs; + GPMC_Object *object = handle->object; /*Disable and stop the prefetch engine*/ CSL_REG32_FINS(attrs->gpmcBaseAddr + CSL_GPMC_PREFETCH_CONTROL, GPMC_PREFETCH_CONTROL_STARTENGINE, \ @@ -99,15 +99,15 @@ int32_t GPMC_configurePrefetchPostWriteEngine(GPMC_Handle handle) return status; } -int32_t GPMC_nandReadData(GPMC_Handle handle, GPMC_Transaction *trans) +int32_t GPMC_nandReadData(GPMC_Config *handle, GPMC_Transaction *trans) { int32_t status = SystemP_SUCCESS; /* Input parameter validation */ if(handle != NULL && trans != NULL) { - GPMC_Object *object = ((GPMC_Config*)handle)->object; - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + GPMC_Object *object = handle->object; + const GPMC_HwAttrs *attrs = handle->attrs; uint32_t byteCount = trans->count; uint32_t threshold = 0; @@ -127,7 +127,7 @@ int32_t GPMC_nandReadData(GPMC_Handle handle, GPMC_Transaction *trans) if(status == SystemP_SUCCESS) { /* Perform DMA copy. */ - GPMC_dmaCopy(object->gpmcDmaHandle, trans->Buf, (void*)attrs->chipSelBaseAddr, trans->count, TRUE); + GPMC_dmaCopy(object->gpmcDmaHandle, trans->Buf, (uint32_t*) attrs->chipSelBaseAddr, trans->count, TRUE); } /* Disable prefetch read engine. */ status += GPMC_prefetchPostWriteConfigDisable(handle); @@ -141,7 +141,7 @@ int32_t GPMC_nandReadData(GPMC_Handle handle, GPMC_Transaction *trans) if(status == SystemP_SUCCESS) { - uint32_t *ptr = (uint32_t *)trans->Buf; + uint32_t *ptr = trans->Buf; while(byteCount) { @@ -165,7 +165,7 @@ int32_t GPMC_nandReadData(GPMC_Handle handle, GPMC_Transaction *trans) else if(trans->transType == GPMC_TRANSACTION_TYPE_READ_CMDREG) { /* Read data from GPMC command register. */ - uint32_t *bufPtr = (uint32_t*)trans->Buf; + uint32_t *bufPtr = trans->Buf; *bufPtr = CSL_REG32_RD(attrs->gpmcBaseAddr + CSL_GPMC_NAND_DATA(object->params.chipSel)); } @@ -189,15 +189,15 @@ int32_t GPMC_nandReadData(GPMC_Handle handle, GPMC_Transaction *trans) return status; } -int32_t GPMC_nandWriteData(GPMC_Handle handle, GPMC_Transaction *trans) +int32_t GPMC_nandWriteData(GPMC_Config *handle, GPMC_Transaction *trans) { int32_t status = SystemP_SUCCESS; /* Input parameter validation */ if(handle != NULL && trans != NULL) { - GPMC_Object *object = ((GPMC_Config*)handle)->object; - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + GPMC_Object *object = handle->object; + const GPMC_HwAttrs *attrs = handle->attrs; uint32_t byteCount = trans->count; uint32_t threshold = 0; uint32_t remainBytes = 0; @@ -211,7 +211,7 @@ int32_t GPMC_nandWriteData(GPMC_Handle handle, GPMC_Transaction *trans) if(trans->transType == GPMC_TRANSACTION_TYPE_WRITE) { /* Perform write using post write engine with CPU. */ - uint32_t *bufPtr = (uint32_t*)trans->Buf; + uint32_t *bufPtr = trans->Buf; /* Enable post write engine. */ status += GPMC_prefetchPostWriteConfigEnable(handle, GPMC_PREFETCH_ACCESSMODE_WRITE, byteCount, FALSE); /* Enable FIFO event interupt. */ @@ -252,7 +252,7 @@ int32_t GPMC_nandWriteData(GPMC_Handle handle, GPMC_Transaction *trans) else if(trans->transType == GPMC_TRANSACTION_TYPE_WRITE_CMDREG) { /* Write data using GPMC command register. */ - uint32_t *bufPtr = (uint32_t*)trans->Buf; + uint32_t *bufPtr = trans->Buf; CSL_REG32_WR(attrs->gpmcBaseAddr + CSL_GPMC_NAND_DATA(object->params.chipSel), *bufPtr); } @@ -288,7 +288,7 @@ void GPMC_writeNandCommandParamsInit(GPMC_nandCmdParams *cmdParams) cmdParams->checkReadypin = TRUE; } -int32_t GPMC_writeNandCommand(GPMC_Handle handle, GPMC_nandCmdParams *cmdParams) +int32_t GPMC_writeNandCommand(GPMC_Config *handle, GPMC_nandCmdParams *cmdParams) { int32_t status = SystemP_SUCCESS; @@ -299,7 +299,7 @@ int32_t GPMC_writeNandCommand(GPMC_Handle handle, GPMC_nandCmdParams *cmdParams) uint32_t colAddress = 0; uint32_t rowAddress = 0; - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *hwAttrs = handle->attrs; if(hwAttrs->waitPinNum == CSL_GPMC_CONFIG1_WAITPINSELECT_W0) { @@ -373,7 +373,7 @@ int32_t GPMC_writeNandCommand(GPMC_Handle handle, GPMC_nandCmdParams *cmdParams) } -int32_t GPMC_eccValueSizeSet(GPMC_Handle handle, uint32_t eccSize, +int32_t GPMC_eccValueSizeSet(GPMC_Config *handle, uint32_t eccSize, uint32_t eccSizeVal) { int32_t status = SystemP_SUCCESS; @@ -382,7 +382,7 @@ int32_t GPMC_eccValueSizeSet(GPMC_Handle handle, uint32_t eccSize, if(handle != NULL) { /* Set ECC used and unused bytes size in nibbles. */ - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *hwAttrs = handle->attrs; if (eccSize == GPMC_ECC_SIZE_0) { @@ -412,14 +412,14 @@ int32_t GPMC_eccValueSizeSet(GPMC_Handle handle, uint32_t eccSize, } -int32_t GPMC_eccBchConfigureElm(GPMC_Handle handle, uint8_t numSectors) +int32_t GPMC_eccBchConfigureElm(GPMC_Config *handle, uint8_t numSectors) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *hwAttrs = handle->attrs; /* Configure ELM module.*/ ELM_moduleReset(hwAttrs->elmBaseAddr); @@ -445,15 +445,15 @@ int32_t GPMC_eccBchConfigureElm(GPMC_Handle handle, uint8_t numSectors) return status; } -int32_t GPMC_eccEngineBCHConfig (GPMC_Handle handle , uint32_t eccSteps) +int32_t GPMC_eccEngineBCHConfig (GPMC_Config *handle , uint32_t eccSteps) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; - GPMC_Object *object = ((GPMC_Config*)handle)->object; + const GPMC_HwAttrs *hwAttrs = handle->attrs; + GPMC_Object *object = handle->object; /* Select ECC result register */ CSL_REG32_FINS(hwAttrs->gpmcBaseAddr + CSL_GPMC_ECC_CONTROL, GPMC_ECC_CONTROL_ECCPOINTER, GPMC_ECCPOINTER_RESULT_1); @@ -487,14 +487,14 @@ int32_t GPMC_eccEngineBCHConfig (GPMC_Handle handle , uint32_t eccSteps) return status; } -int32_t GPMC_eccEngineEnable(GPMC_Handle handle) +int32_t GPMC_eccEngineEnable(GPMC_Config *handle) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *hwAttrs = handle->attrs; /* Enable ECC engine. */ CSL_REG32_FINS(hwAttrs->gpmcBaseAddr + CSL_GPMC_ECC_CONTROL, GPMC_ECC_CONTROL_ECCPOINTER, GPMC_ECCPOINTER_RESULT_1); @@ -509,19 +509,19 @@ int32_t GPMC_eccEngineEnable(GPMC_Handle handle) return status; } -void GPMC_eccResultRegisterClear(GPMC_Handle handle) +void GPMC_eccResultRegisterClear(GPMC_Config *handle) { /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; /* Clear all the ECC result registers. */ CSL_REG32_FINS(attrs->gpmcBaseAddr + CSL_GPMC_ECC_CONTROL, GPMC_ECC_CONTROL_ECCCLEAR, CSL_GPMC_ECC_CONTROL_ECCCLEAR_MAX); } } -int32_t GPMC_eccGetBchSyndromePolynomial(GPMC_Handle handle, uint32_t sector, uint32_t *bchData) +int32_t GPMC_eccGetBchSyndromePolynomial(GPMC_Config *handle, uint32_t sector, uint32_t *bchData) { int32_t status = SystemP_SUCCESS; @@ -542,14 +542,14 @@ int32_t GPMC_eccGetBchSyndromePolynomial(GPMC_Handle handle, uint32_t sector, ui return status; } -int32_t GPMC_eccBchFillSyndromeValue(GPMC_Handle handle, uint32_t sector, uint32_t *bchData) +int32_t GPMC_eccBchFillSyndromeValue(GPMC_Config *handle, uint32_t sector, uint32_t *bchData) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; /* Fill BCH syndrome polynomial to ELM module per sector. */ ELM_setSyndromeFragment(attrs->elmBaseAddr, ELM_SYNDROME_FRGMT_0, bchData[0], sector); @@ -566,14 +566,14 @@ int32_t GPMC_eccBchFillSyndromeValue(GPMC_Handle handle, uint32_t sector, uint32 return status; } -int32_t GPMC_eccBchStartErrorProcessing(GPMC_Handle handle, uint8_t sector) +int32_t GPMC_eccBchStartErrorProcessing(GPMC_Config *handle, uint8_t sector) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; /* Start ELM error processing. */ ELM_errorLocationProcessingStart(attrs->elmBaseAddr, sector); @@ -586,7 +586,7 @@ int32_t GPMC_eccBchStartErrorProcessing(GPMC_Handle handle, uint8_t sector) return status; } -int32_t GPMC_eccBchCheckErrorProcessingStatus(GPMC_Handle handle, uint32_t sector) +int32_t GPMC_eccBchCheckErrorProcessingStatus(GPMC_Config *handle, uint32_t sector) { int32_t status = SystemP_SUCCESS; uint64_t curTime; @@ -594,7 +594,7 @@ int32_t GPMC_eccBchCheckErrorProcessingStatus(GPMC_Handle handle, uint32_t secto /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; curTime = ClockP_getTimeUsec(); @@ -622,7 +622,7 @@ int32_t GPMC_eccBchCheckErrorProcessingStatus(GPMC_Handle handle, uint32_t secto return status; } -int32_t GPMC_eccBchSectorGetError(GPMC_Handle handle, uint32_t sector, uint32_t *errCount, uint32_t *errLoc) +int32_t GPMC_eccBchSectorGetError(GPMC_Config *handle, uint32_t sector, uint32_t *errCount, uint32_t *errLoc) { int32_t status = SystemP_SUCCESS; @@ -630,7 +630,7 @@ int32_t GPMC_eccBchSectorGetError(GPMC_Handle handle, uint32_t sector, uint32_t if(handle != NULL) { /* Get number of errors located by ELM per sector. */ - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; if(status == SystemP_SUCCESS) { @@ -658,7 +658,7 @@ int32_t GPMC_eccBchSectorGetError(GPMC_Handle handle, uint32_t sector, uint32_t return status; } -int32_t GPMC_eccCalculateBchSyndromePolynomial(GPMC_Handle handle, uint8_t *pEccdata, uint32_t sector) +int32_t GPMC_eccCalculateBchSyndromePolynomial(GPMC_Config *handle, uint8_t *pEccdata, uint32_t sector) { int32_t status = SystemP_SUCCESS; @@ -702,7 +702,7 @@ int32_t GPMC_eccCalculateBchSyndromePolynomial(GPMC_Handle handle, uint8_t *pEcc /* Internal function definitions */ /* ========================================================================== */ -static int32_t GPMC_prefetchPostWriteConfigEnable(GPMC_Handle handle, uint8_t mode, +static int32_t GPMC_prefetchPostWriteConfigEnable(GPMC_Config *handle, uint8_t mode, uint32_t transferCount, uint8_t modeDMA) { int32_t status = SystemP_SUCCESS; @@ -710,7 +710,7 @@ static int32_t GPMC_prefetchPostWriteConfigEnable(GPMC_Handle handle, uint8_t mo /* Input parameter validation */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; if(mode == GPMC_PREFETCH_ACCESSMODE_READ) { @@ -764,14 +764,14 @@ static int32_t GPMC_prefetchPostWriteConfigEnable(GPMC_Handle handle, uint8_t mo return status; } -static int32_t GPMC_prefetchPostWriteConfigDisable(GPMC_Handle handle) +static int32_t GPMC_prefetchPostWriteConfigDisable(GPMC_Config *handle) { int32_t status = SystemP_SUCCESS; /* Input parameter validation */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; /*Disable and stop the prefetch engine*/ CSL_REG32_FINS(attrs->gpmcBaseAddr + CSL_GPMC_PREFETCH_CONTROL, GPMC_PREFETCH_CONTROL_STARTENGINE, \ @@ -794,36 +794,36 @@ static int32_t GPMC_prefetchPostWriteConfigDisable(GPMC_Handle handle) return status; } -static void GPMC_nandCommandWrite(GPMC_Handle handle, uint32_t cmd) +static void GPMC_nandCommandWrite(GPMC_Config *handle, uint32_t cmd) { /* Input parameter validation */ if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; - GPMC_Object *object = ((GPMC_Config*)handle)->object; + const GPMC_HwAttrs *hwAttrs = handle->attrs; + GPMC_Object *object = handle->object; /* Set NAND command. */ CSL_REG8_WR(hwAttrs->gpmcBaseAddr + CSL_GPMC_NAND_COMMAND(object->params.chipSel), cmd); } } -static void GPMC_nandAddressWrite(GPMC_Handle handle, uint32_t address) +static void GPMC_nandAddressWrite(GPMC_Config *handle, uint32_t address) { /* Input parameter validation */ if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; - GPMC_Object *object = ((GPMC_Config*)handle)->object; + const GPMC_HwAttrs *hwAttrs = handle->attrs; + GPMC_Object *object = handle->object; /* Set NAND address. */ CSL_REG8_WR(hwAttrs->gpmcBaseAddr + CSL_GPMC_NAND_ADDRESS(object->params.chipSel), address); } } -static void GPMC_eccResultSizeSelect(GPMC_Handle handle, uint32_t eccResReg, +static void GPMC_eccResultSizeSelect(GPMC_Config *handle, uint32_t eccResReg, uint32_t eccSize) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *hwAttrs = handle->attrs; /* Set ECC size for ECC result register. */ switch (eccResReg) @@ -879,14 +879,14 @@ static void GPMC_eccResultSizeSelect(GPMC_Handle handle, uint32_t eccResReg, } } -static uint32_t GPMC_eccBchResultGet(GPMC_Handle handle, uint32_t resIndex , uint32_t sector) +static uint32_t GPMC_eccBchResultGet(GPMC_Config *handle, uint32_t resIndex , uint32_t sector) { uint32_t result = 0; /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; /* Get BCH syndrome polynomial per sector. */ switch (resIndex) diff --git a/source/drivers/gpmc/v0/gpmc_norlike_v0.c b/source/drivers/gpmc/v0/gpmc_norlike_v0.c index 3849715dd19..f071612043f 100644 --- a/source/drivers/gpmc/v0/gpmc_norlike_v0.c +++ b/source/drivers/gpmc/v0/gpmc_norlike_v0.c @@ -64,10 +64,10 @@ uint8_t *GPMC_norMakeAddr(uint8_t busWidth,uint32_t blkAddr,uint32_t offset) return ((uint8_t *) addr); } -void GPMC_norMakeCmd(uint8_t busWidth, uint32_t cmd, void *cmdBuf) +void GPMC_norMakeCmd(uint8_t busWidth, uint32_t cmd, uint8_t *cmdBuf) { uint32_t i; - uint8_t *cmdPtr = (uint8_t *)cmdBuf; + uint8_t *cmdPtr = cmdBuf; for (i = (1 << busWidth); i > 0; i--) { @@ -76,7 +76,7 @@ void GPMC_norMakeCmd(uint8_t busWidth, uint32_t cmd, void *cmdBuf) } } -int32_t GPMC_norWriteData(GPMC_Handle handle,uint32_t offset, +int32_t GPMC_norWriteData(GPMC_Config *handle,uint32_t offset, uint8_t *buf, uint32_t len) { @@ -85,8 +85,8 @@ int32_t GPMC_norWriteData(GPMC_Handle handle,uint32_t offset, if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; - GPMC_Object *obj = ((GPMC_Config*)handle)->object; + const GPMC_HwAttrs *hwAttrs = handle->attrs; + GPMC_Object *obj = handle->object; uint32_t devSize = obj->params.devSize; uint32_t baseAddress = hwAttrs->dataBaseAddr; @@ -129,7 +129,7 @@ int32_t GPMC_norWriteData(GPMC_Handle handle,uint32_t offset, } -int32_t GPMC_norReadData(GPMC_Handle handle, uint32_t offset, +int32_t GPMC_norReadData(GPMC_Config *handle, uint32_t offset, uint8_t *buf, uint32_t len) { int32_t status = SystemP_SUCCESS; @@ -137,8 +137,8 @@ int32_t GPMC_norReadData(GPMC_Handle handle, uint32_t offset, if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; - GPMC_Object *obj = ((GPMC_Config*)handle)->object; + const GPMC_HwAttrs *hwAttrs = handle->attrs; + GPMC_Object *obj = handle->object; uint32_t devSize = obj->params.devSize; uint32_t baseAddress = hwAttrs->dataBaseAddr; diff --git a/source/drivers/gpmc/v0/gpmc_priv_v0.c b/source/drivers/gpmc/v0/gpmc_priv_v0.c index 3d62fb4ff6e..dfa0310a0bd 100644 --- a/source/drivers/gpmc/v0/gpmc_priv_v0.c +++ b/source/drivers/gpmc/v0/gpmc_priv_v0.c @@ -181,14 +181,14 @@ uint32_t GPMC_interuptStatusGet(uint32_t baseAddr, uint32_t interupt) return (retVal); } -int32_t GPMC_disableFlashWriteProtect(GPMC_Handle handle) +int32_t GPMC_disableFlashWriteProtect(GPMC_Config *handle) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; /* Disable write protect. */ CSL_REG32_FINS(attrs->gpmcBaseAddr + CSL_GPMC_CONFIG, GPMC_CONFIG_WRITEPROTECT, \ CSL_GPMC_CONFIG_WRITEPROTECT_WPHIGH); @@ -202,14 +202,14 @@ int32_t GPMC_disableFlashWriteProtect(GPMC_Handle handle) return status; } -int32_t GPMC_enableFlashWriteProtect(GPMC_Handle handle) +int32_t GPMC_enableFlashWriteProtect(GPMC_Config *handle) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - const GPMC_HwAttrs *attrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; /* Enable Write protect. */ CSL_REG32_FINS(attrs->gpmcBaseAddr + CSL_GPMC_CONFIG, GPMC_CONFIG_WRITEPROTECT, \ @@ -223,7 +223,7 @@ int32_t GPMC_enableFlashWriteProtect(GPMC_Handle handle) return status; } -int32_t GPMC_waitPinInteruptStatusReadyWaitTimeout(GPMC_Handle handle, uint32_t timeOut) +int32_t GPMC_waitPinInteruptStatusReadyWaitTimeout(GPMC_Config *handle, uint32_t timeOut) { int32_t status = SystemP_SUCCESS; uint32_t waitPinInterupt = 0; @@ -231,7 +231,7 @@ int32_t GPMC_waitPinInteruptStatusReadyWaitTimeout(GPMC_Handle handle, uint32_t if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *hwAttrs = handle->attrs; if(hwAttrs->waitPinNum == CSL_GPMC_CONFIG1_WAITPINSELECT_W0) { @@ -285,7 +285,7 @@ int32_t GPMC_waitPinInteruptStatusReadyWaitTimeout(GPMC_Handle handle, uint32_t } -int32_t GPMC_waitPinStatusReadyWaitTimeout(GPMC_Handle handle, uint32_t timeOut) +int32_t GPMC_waitPinStatusReadyWaitTimeout(GPMC_Config *handle, uint32_t timeOut) { int32_t status = SystemP_SUCCESS; @@ -294,7 +294,7 @@ int32_t GPMC_waitPinStatusReadyWaitTimeout(GPMC_Handle handle, uint32_t timeOut) if(handle != NULL) { - hwAttrs = ((GPMC_Config*)handle)->attrs; + hwAttrs = handle->attrs; if(timeOut != 0) { @@ -338,10 +338,10 @@ int32_t GPMC_waitPinStatusReadyWaitTimeout(GPMC_Handle handle, uint32_t timeOut) } -int32_t GPMC_isDmaRestrictedRegion(GPMC_Handle handle, uint32_t addr) +int32_t GPMC_isDmaRestrictedRegion(GPMC_Config *handle, uint32_t addr) { int32_t isRestricted = FALSE; - const GPMC_HwAttrs *attrs = ((GPMC_Config *)handle)->attrs; + const GPMC_HwAttrs *attrs = handle->attrs; if(NULL != attrs->dmaRestrictedRegions) { diff --git a/source/drivers/gpmc/v0/gpmc_priv_v0.h b/source/drivers/gpmc/v0/gpmc_priv_v0.h index 63070eadd9c..168a0e90f31 100644 --- a/source/drivers/gpmc/v0/gpmc_priv_v0.h +++ b/source/drivers/gpmc/v0/gpmc_priv_v0.h @@ -131,10 +131,10 @@ void GPMC_interuptStatusClear(uint32_t baseAddr, uint32_t interupt); */ uint32_t GPMC_interuptStatusGet(uint32_t baseAddr, uint32_t interupt); -int32_t GPMC_waitPinInteruptStatusReadyWaitTimeout(GPMC_Handle handle, +int32_t GPMC_waitPinInteruptStatusReadyWaitTimeout(GPMC_Config *handle, uint32_t timeOut); -int32_t GPMC_waitPinStatusReadyWaitTimeout(GPMC_Handle handle, +int32_t GPMC_waitPinStatusReadyWaitTimeout(GPMC_Config *handle, uint32_t timeOut); /** @@ -146,7 +146,7 @@ int32_t GPMC_waitPinStatusReadyWaitTimeout(GPMC_Handle handle, * * \return TRUE or FALSE */ -int32_t GPMC_isDmaRestrictedRegion(GPMC_Handle handle, uint32_t addr); +int32_t GPMC_isDmaRestrictedRegion(GPMC_Config *handle, uint32_t addr); /** * \brief Function to check WAIT pin status. diff --git a/source/drivers/gpmc/v0/gpmc_v0.c b/source/drivers/gpmc/v0/gpmc_v0.c index e041a63b488..8366a87ada5 100644 --- a/source/drivers/gpmc/v0/gpmc_v0.c +++ b/source/drivers/gpmc/v0/gpmc_v0.c @@ -57,7 +57,7 @@ typedef struct { - void *openLock; + SemaphoreP_Object *openLock; /**< Lock to protect GPMC open*/ SemaphoreP_Object lockObj; /**< Lock object */ @@ -69,9 +69,9 @@ typedef struct /* Internal functions */ static void GPMC_isr(void *arg); -static void GPMC_transferCallback(GPMC_Handle handle, GPMC_Transaction *msg); +static void GPMC_transferCallback(SemaphoreP_Object *transferComplete); static int32_t GPMC_programInstance(GPMC_Config *config); -static void GPMC_waitPinPolaritySelect(GPMC_Handle handle, uint32_t pin, +static void GPMC_waitPinPolaritySelect(GPMC_Config *handle, uint32_t pin, uint32_t polarity); static int32_t GPMC_moduleResetStatusWaitTimeout(GPMC_Config *config, uint32_t timeOut); @@ -125,15 +125,15 @@ void GPMC_deinit(void) return; } -int32_t GPMC_configureTimingParameters(GPMC_Handle handle) +int32_t GPMC_configureTimingParameters(GPMC_Config *handle) { int32_t status = SystemP_SUCCESS; uint32_t timeConfig = 0; if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; - GPMC_Object *object = ((GPMC_Config*)handle)->object; + const GPMC_HwAttrs *hwAttrs = handle->attrs; + GPMC_Object *object = handle->object; uint32_t devType = object->params.devType; /* CONFIG2 reister timing config, no extra delay */ @@ -206,13 +206,13 @@ int32_t GPMC_configureTimingParameters(GPMC_Handle handle) return status; } -int32_t GPMC_setDeviceType(GPMC_Handle handle) +int32_t GPMC_setDeviceType(GPMC_Config *handle) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - GPMC_Config *config = (GPMC_Config*)handle; + GPMC_Config *config = handle; const GPMC_HwAttrs *attrs = config->attrs; GPMC_Object *object = config->object; /* Set Device type interfaced with GPMC. */ @@ -228,14 +228,14 @@ int32_t GPMC_setDeviceType(GPMC_Handle handle) return status; } -int32_t GPMC_setDeviceSize(GPMC_Handle handle) +int32_t GPMC_setDeviceSize(GPMC_Config *handle) { int32_t status = SystemP_SUCCESS; /* Input parameter validation. */ if(handle != NULL) { - GPMC_Config *config = (GPMC_Config*)handle; + GPMC_Config *config = handle; const GPMC_HwAttrs *attrs = config->attrs; GPMC_Object *object = config->object; /* Set device width interfaced with GPMC. */ @@ -251,10 +251,10 @@ int32_t GPMC_setDeviceSize(GPMC_Handle handle) return status; } -GPMC_Handle GPMC_open(uint32_t index, const GPMC_Params *prms) +GPMC_Config* GPMC_open(uint32_t index, const GPMC_Params *prms) { int32_t status = SystemP_SUCCESS; - GPMC_Handle handle = NULL; + GPMC_Config *handle = NULL; GPMC_Config *config = NULL; GPMC_Object *object = NULL; const GPMC_HwAttrs *hwAttrs = NULL; @@ -289,8 +289,6 @@ GPMC_Handle GPMC_open(uint32_t index, const GPMC_Params *prms) if(status == SystemP_SUCCESS) { - object->handle = (GPMC_Handle)config; - if(prms != NULL) { memcpy((void*)&object->params, (void*)prms, sizeof(GPMC_Params)); @@ -367,7 +365,7 @@ GPMC_Handle GPMC_open(uint32_t index, const GPMC_Params *prms) if(status == SystemP_SUCCESS) { object->isOpen = 1; - handle = (GPMC_Handle)config; + handle = config; } SemaphoreP_post(&gGpmcDrvObj.lockObj); @@ -377,14 +375,14 @@ GPMC_Handle GPMC_open(uint32_t index, const GPMC_Params *prms) { if(NULL != config) { - GPMC_close((GPMC_Handle) config); + GPMC_close(config); } } return(handle); } -void GPMC_close(GPMC_Handle handle) +void GPMC_close(GPMC_Config *handle) { /* Input parameter validation */ if (handle != NULL) @@ -392,8 +390,8 @@ void GPMC_close(GPMC_Handle handle) GPMC_Object *object = NULL; const GPMC_HwAttrs *hwAttrs = NULL; /* Get the pointer to the object and hwAttrs */ - object = ((GPMC_Config*)handle)->object; - hwAttrs = ((GPMC_Config*)handle)->attrs; + object = handle->object; + hwAttrs = handle->attrs; /* Disable all interupts associated to GPMC. */ GPMC_disableInterupt(hwAttrs->gpmcBaseAddr,GPMC_FIFOEVENT_INT); @@ -439,9 +437,9 @@ void GPMC_transactionInit(GPMC_Transaction *trans) trans->transferTimeout = SystemP_WAIT_FOREVER; } -GPMC_Handle GPMC_getHandle(uint32_t driverInstanceIndex) +GPMC_Config* GPMC_getHandle(uint32_t driverInstanceIndex) { - GPMC_Handle handle = NULL; + GPMC_Config* handle = NULL; /* Check index */ if(driverInstanceIndex < gGpmcConfigNum) { @@ -451,13 +449,13 @@ GPMC_Handle GPMC_getHandle(uint32_t driverInstanceIndex) if(obj && (TRUE == obj->isOpen)) { /* valid handle */ - handle = obj->handle; + handle = &gGpmcConfig[driverInstanceIndex]; } } return handle; } -uint32_t GPMC_getInputClk(GPMC_Handle handle) +uint32_t GPMC_getInputClk(GPMC_Config *handle) { uint32_t retVal = 0U; @@ -465,7 +463,7 @@ uint32_t GPMC_getInputClk(GPMC_Handle handle) if(handle != NULL) { /* Get GPMC interface clock. */ - const GPMC_HwAttrs* attrs = ((GPMC_Config *)handle)->attrs; + const GPMC_HwAttrs* attrs = handle->attrs; retVal = attrs->inputClkFreq; } return retVal; @@ -514,12 +512,12 @@ static int32_t GPMC_moduleResetStatusWaitTimeout(GPMC_Config *config, uint32_t t } -static void GPMC_waitPinPolaritySelect(GPMC_Handle handle, uint32_t pin, +static void GPMC_waitPinPolaritySelect(GPMC_Config *handle, uint32_t pin, uint32_t polarity) { if(handle != NULL) { - const GPMC_HwAttrs *hwAttrs = ((GPMC_Config*)handle)->attrs; + const GPMC_HwAttrs *hwAttrs = handle->attrs; /* Select WAIT PIN polarity. */ if (pin == CSL_GPMC_CONFIG1_WAITPINSELECT_W0) { @@ -631,7 +629,7 @@ static int32_t GPMC_programInstance(GPMC_Config *config) if(devType == CSL_GPMC_CONFIG1_DEVICETYPE_NANDLIKE) /* Set Wait pin polarity*/ { - GPMC_waitPinPolaritySelect((GPMC_Handle*)config, hwAttrs->waitPinNum, hwAttrs->waitPinPol); + GPMC_waitPinPolaritySelect(config, hwAttrs->waitPinNum, hwAttrs->waitPinPol); GPMC_interuptStatusClear(hwAttrs->gpmcBaseAddr,GPMC_WAIT0EDGEDETECTION_STATUS); /* Enable interupt for the WAIT PIN*/ @@ -640,7 +638,7 @@ static int32_t GPMC_programInstance(GPMC_Config *config) CSL_REG32_FINS(hwAttrs->gpmcBaseAddr + CSL_GPMC_CONFIG7(object->params.chipSel), \ GPMC_CONFIG7_CSVALID, CSL_GPMC_CONFIG7_CSVALID_CSENABLED); - status += GPMC_waitPinStatusReadyWaitTimeout((GPMC_Handle)config, GPMC_WAIT_PIN_STATUS_WAIT_TIME_MAX); + status += GPMC_waitPinStatusReadyWaitTimeout(config, GPMC_WAIT_PIN_STATUS_WAIT_TIME_MAX); } } @@ -651,17 +649,12 @@ static int32_t GPMC_programInstance(GPMC_Config *config) -static void GPMC_transferCallback(GPMC_Handle handle, GPMC_Transaction *msg) +static void GPMC_transferCallback(SemaphoreP_Object *transferComplete) { - GPMC_Object *object; /* GPMC object */ - /* Input parameter validation */ - if (handle != NULL) + if (transferComplete != NULL) { - /* Get the pointer to the object. */ - object = ((GPMC_Config*)handle)->object; - /* Indicate transfer complete. */ - SemaphoreP_post(&object->transferComplete); + SemaphoreP_post(transferComplete); } }