Skip to content

Commit eeaf860

Browse files
VitekSTkartben
authored andcommitted
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 4e83888 commit eeaf860

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/dma/dma_mcux_lpc.c

+24
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 && (block_config->source_gather_interval != 0)) {
406410
src_inc = block_config->source_gather_interval / width;
@@ -825,11 +829,30 @@ 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+
case DMA_ATTR_BUFFER_SIZE_ALIGNMENT:
837+
case DMA_ATTR_COPY_ALIGNMENT:
838+
*value = 4;
839+
break;
840+
841+
default:
842+
return -EINVAL;
843+
}
844+
845+
return 0;
846+
}
847+
828848
static int dma_mcux_lpc_init(const struct device *dev)
829849
{
830850
const struct dma_mcux_lpc_config *config = dev->config;
831851
struct dma_mcux_lpc_dma_data *data = dev->data;
832852

853+
data->ctx.magic = DMA_MAGIC;
854+
data->ctx.dma_channels = config->num_of_channels;
855+
833856
/* Indicate that the Otrig Muxes are not connected */
834857
for (int i = 0; i < config->num_of_otrigs; i++) {
835858
data->otrig_array[i].source_channel = EMPTY_OTRIG;
@@ -860,6 +883,7 @@ static DEVICE_API(dma, dma_mcux_lpc_api) = {
860883
.stop = dma_mcux_lpc_stop,
861884
.reload = dma_mcux_lpc_reload,
862885
.get_status = dma_mcux_lpc_get_status,
886+
.get_attribute = dma_mcux_lpc_get_attribute
863887
};
864888

865889
#define DMA_MCUX_LPC_CONFIG_FUNC(n) \

0 commit comments

Comments
 (0)