Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: dma: silabs: Implementation of chan_filter and chan_release API with DMADRV functions. #85402

Merged
Merged
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
27 changes: 20 additions & 7 deletions drivers/dma/dma_silabs_ldma.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <zephyr/sys/mem_blocks.h>

#include "em_ldma.h"
#include "dmadrv.h"

#define DT_DRV_COMPAT silabs_ldma

Expand Down Expand Up @@ -480,17 +481,27 @@ static int dma_silabs_get_status(const struct device *dev, uint32_t channel,
return 0;
}

bool dma_silabs_chan_filter(const struct device *dev, int channel, void *filter_param)
{
ARG_UNUSED(dev);
ARG_UNUSED(filter_param);
return (DMADRV_AllocateChannelById(channel, 0) == ECODE_EMDRV_DMADRV_OK);
}

void dma_silabs_chan_release(const struct device *dev, uint32_t channel)
{
ARG_UNUSED(dev);
Ecode_t err = DMADRV_FreeChannel(channel);

__ASSERT_NO_MSG(err == ECODE_EMDRV_DMADRV_OK);
}

static int dma_silabs_init(const struct device *dev)
{
const struct dma_silabs_config *config = dev->config;
LDMA_Init_t dmaInit = {
/* 0x7 indicate that the 8 channels have round robin priority. */
.ldmaInitCtrlNumFixed = 0x7,
.ldmaInitIrqPriority = DMA_IRQ_PRIORITY,
};

/* Clock is managed by em_ldma */
LDMA_Init(&dmaInit);
DMADRV_Init();

/* LDMA_Init configure IRQ but we want IRQ to match with configured one in the dts*/
config->config_irq(dev);
Expand All @@ -502,7 +513,9 @@ static DEVICE_API(dma, dma_funcs) = {
.config = dma_silabs_configure,
.start = dma_silabs_start,
.stop = dma_silabs_stop,
.get_status = dma_silabs_get_status
.get_status = dma_silabs_get_status,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review and ensure the requirements have been met for these APIs, I have no insight into the HAL implementation of these functions so I can't definitively say if the requirements have been met.

.chan_filter = dma_silabs_chan_filter,
.chan_release = dma_silabs_chan_release
};

int silabs_ldma_append_block(const struct device *dev, uint32_t channel, struct dma_config *config)
Expand Down
8 changes: 8 additions & 0 deletions modules/hal_silabs/simplicity_sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# SPDX-License-Identifier: Apache-2.0

set(EMLIB_DIR ${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib)
set(EMDRV_DIR ${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emdrv)
set(COMMON_DIR ${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/common)
set(DEVICE_DIR ${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/Device)
set(DRIVER_DIR ${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/driver)
Expand Down Expand Up @@ -99,6 +100,10 @@ zephyr_include_directories(
${COMMON_DIR}/config
${COMMON_DIR}/inc
${DRIVER_DIR}/gpio/inc
${EMDRV_DIR}/common/inc
${EMDRV_DIR}/dmadrv/config/s2_8ch/
${EMDRV_DIR}/dmadrv/inc
${EMDRV_DIR}/dmadrv/inc/s2_signals/
${EMLIB_DIR}/inc
${PERIPHERAL_DIR}/inc
${SERVICE_DIR}/clock_manager/inc
Expand Down Expand Up @@ -226,6 +231,9 @@ if(CONFIG_SOC_GECKO_GPIO)
SL_CODE_COMPONENT_HAL_GPIO=hal_gpio
)
endif()

zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_LDMA ${EMDRV_DIR}/dmadrv/src/dmadrv.c)

zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_I2C ${EMLIB_DIR}/src/em_i2c.c)
zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_LETIMER ${EMLIB_DIR}/src/em_letimer.c)
zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_LEUART ${EMLIB_DIR}/src/em_leuart.c)
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ manifest:
groups:
- hal
- name: hal_silabs
revision: 2e64a70dbb6396271a8eb8b9ee3f57dc747b5997
revision: 1e60d972b2d05de620ece65cfa48ec33c5f38bac
path: modules/hal/silabs
groups:
- hal
Expand Down
Loading