drivers: dma: dma_nxp_edma: add function for channel filtering

The point of this commit is to allow users to request specific
channels. The following code snippet shows how this may now be
achieved:

	int requested_channel = 5;
	int ret = dma_request_channel(dev, &requested_channel);

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
This commit is contained in:
Laurentiu Mihalcea 2024-02-07 16:38:44 +02:00 committed by Fabio Baltieri
parent 4ff5e29cfe
commit 41289dac06

View file

@ -573,6 +573,23 @@ static int edma_get_attribute(const struct device *dev, uint32_t type, uint32_t
return 0; return 0;
} }
static bool edma_channel_filter(const struct device *dev, int chan_id, void *param)
{
int *requested_channel;
if (!param) {
return false;
}
requested_channel = param;
if (*requested_channel == chan_id && lookup_channel(dev, chan_id)) {
return true;
}
return false;
}
static const struct dma_driver_api edma_api = { static const struct dma_driver_api edma_api = {
.reload = edma_reload, .reload = edma_reload,
.config = edma_config, .config = edma_config,
@ -582,6 +599,7 @@ static const struct dma_driver_api edma_api = {
.resume = edma_start, .resume = edma_start,
.get_status = edma_get_status, .get_status = edma_get_status,
.get_attribute = edma_get_attribute, .get_attribute = edma_get_attribute,
.chan_filter = edma_channel_filter,
}; };
static int edma_init(const struct device *dev) static int edma_init(const struct device *dev)