Skip to content

Commit 9e151f2

Browse files
committed
dma_mcux_lpc: add host directions, DMA driver ctx, getter func
Add support for HOST_TO_MEMORY, MEMORY_TO_HOST directions (aliases of MEMORY_TO_MEMORY). Implement dma_mcux_lpc_get_attribute function. Fix missing DMA driver context. Signed-off-by: Vit Stanicek <[email protected]>
1 parent 5ebb04f commit 9e151f2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/dma/dma_mcux_lpc.c

+30
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ struct dma_otrig {
5656
};
5757

5858
struct dma_mcux_lpc_dma_data {
59+
struct dma_context ctx;
60+
5961
struct channel_data *channel_data;
6062
struct dma_otrig *otrig_array;
6163
int8_t *channel_index;
@@ -401,6 +403,8 @@ static int dma_mcux_lpc_configure(const struct device *dev, uint32_t channel,
401403

402404
switch (config->channel_direction) {
403405
case MEMORY_TO_MEMORY:
406+
case HOST_TO_MEMORY:
407+
case MEMORY_TO_HOST:
404408
is_periph = false;
405409
if (block_config->source_gather_en) {
406410
src_inc = block_config->source_gather_interval / width;
@@ -825,11 +829,36 @@ static int dma_mcux_lpc_get_status(const struct device *dev, uint32_t channel,
825829
return 0;
826830
}
827831

832+
static int dma_mcux_lpc_get_attribute(const struct device *dev, uint32_t type, uint32_t *value)
833+
{
834+
switch (type) {
835+
case DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT:
836+
*value = 4;
837+
break;
838+
839+
case DMA_ATTR_BUFFER_SIZE_ALIGNMENT:
840+
*value = 4;
841+
break;
842+
843+
case DMA_ATTR_COPY_ALIGNMENT:
844+
*value = 4;
845+
break;
846+
847+
default:
848+
return -EINVAL;
849+
}
850+
851+
return 0;
852+
}
853+
828854
static int dma_mcux_lpc_init(const struct device *dev)
829855
{
830856
const struct dma_mcux_lpc_config *config = dev->config;
831857
struct dma_mcux_lpc_dma_data *data = dev->data;
832858

859+
data->ctx.magic = DMA_MAGIC;
860+
data->ctx.dma_channels = config->num_of_channels;
861+
833862
/* Indicate that the Otrig Muxes are not connected */
834863
for (int i = 0; i < config->num_of_otrigs; i++) {
835864
data->otrig_array[i].source_channel = EMPTY_OTRIG;
@@ -860,6 +889,7 @@ static DEVICE_API(dma, dma_mcux_lpc_api) = {
860889
.stop = dma_mcux_lpc_stop,
861890
.reload = dma_mcux_lpc_reload,
862891
.get_status = dma_mcux_lpc_get_status,
892+
.get_attribute = dma_mcux_lpc_get_attribute
863893
};
864894

865895
#define DMA_MCUX_LPC_CONFIG_FUNC(n) \

0 commit comments

Comments
 (0)