Skip to content

Commit

Permalink
simplicity_sdk: Patch dmadrv to support cross channel allocator
Browse files Browse the repository at this point in the history
Patch needed to remain synchronize between zephyr DMA channels allocator
and dmadrv channel allocator.

Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
  • Loading branch information
Martinhoff-maker authored and jhedberg committed Feb 11, 2025
1 parent c089682 commit 1e60d97
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions simplicity_sdk/platform/emdrv/dmadrv/inc/dmadrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ typedef bool (*DMADRV_Callback_t)(unsigned int channel,

Ecode_t DMADRV_AllocateChannel(unsigned int *channelId,
void *capabilities);
Ecode_t DMADRV_AllocateChannelById(unsigned int channelId,
void *capabilities);
Ecode_t DMADRV_DeInit(void);
Ecode_t DMADRV_FreeChannel(unsigned int channelId);
Ecode_t DMADRV_Init(void);
Expand Down
38 changes: 38 additions & 0 deletions simplicity_sdk/platform/emdrv/dmadrv/src/dmadrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,44 @@ Ecode_t DMADRV_AllocateChannel(unsigned int *channelId, void *capabilities)
return ECODE_EMDRV_DMADRV_CHANNELS_EXHAUSTED;
}

/***************************************************************************//**
* @brief
* Allocate (reserve) the given DMA channel if he is free.
*
* @param[out] channelId
* The channel ID to be assigned by DMADRV.
*
* @param[in] capabilities
* Not used.
*
* @return
* @ref ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate
* DMADRV @ref Ecode_t is returned.
******************************************************************************/
Ecode_t DMADRV_AllocateChannelById(unsigned int channelId, void *capabilities)
{
(void)capabilities;
CORE_DECLARE_IRQ_STATE;

if ( !initialized ) {
return ECODE_EMDRV_DMADRV_NOT_INITIALIZED;
}

if ( channelId >= EMDRV_DMADRV_DMA_CH_COUNT ) {
return ECODE_EMDRV_DMADRV_PARAM_ERROR;
}

CORE_ENTER_ATOMIC();
if ( !chTable[channelId].allocated ) {
chTable[channelId].allocated = true;
chTable[channelId].callback = NULL;
CORE_EXIT_ATOMIC();
return ECODE_EMDRV_DMADRV_OK;
}
CORE_EXIT_ATOMIC();
return ECODE_EMDRV_DMADRV_IN_USE;
}

/***************************************************************************//**
* @brief
* Deinitialize DMADRV.
Expand Down

0 comments on commit 1e60d97

Please # to comment.