Skip to content

drivers: dma_mcux_lpc: Add host directions, integrate DMA driver context, implement dma_mcux_lpc_get_attribute #85742

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

Merged
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
24 changes: 24 additions & 0 deletions drivers/dma/dma_mcux_lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct dma_otrig {
};

struct dma_mcux_lpc_dma_data {
struct dma_context ctx;

struct channel_data *channel_data;
struct dma_otrig *otrig_array;
int8_t *channel_index;
Expand Down Expand Up @@ -401,6 +403,8 @@ static int dma_mcux_lpc_configure(const struct device *dev, uint32_t channel,

switch (config->channel_direction) {
case MEMORY_TO_MEMORY:
case HOST_TO_MEMORY:
case MEMORY_TO_HOST:
is_periph = false;
if (block_config->source_gather_en) {
src_inc = block_config->source_gather_interval / width;
Expand Down Expand Up @@ -825,11 +829,30 @@ static int dma_mcux_lpc_get_status(const struct device *dev, uint32_t channel,
return 0;
}

static int dma_mcux_lpc_get_attribute(const struct device *dev, uint32_t type, uint32_t *value)
Copy link
Collaborator

@Raymond0225 Raymond0225 Feb 14, 2025

Choose a reason for hiding this comment

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

I don't think we need implement this API. As it is introduced for special HW:
"DMA API get attribute function added, added attributes for scatter/gather blocks available to Intel HDA and Intel GPDMA drivers"
Even we implement it, why these values are 4, not 1 ?

Copy link
Contributor Author

@VitekST VitekST Feb 20, 2025

Choose a reason for hiding this comment

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

@Raymond0225 That may be a commit message initially introducing this API, perhaps in a similar fashion like I extended the codec API to support features, at the moment, only utilised by the wm8904 driver (4b3fae8), but the documentation doesn't say anything about the API being specific to a particular piece of hardware (https://docs.zephyrproject.org/apidoc/latest/group__dma__interface.html#ga641f3fa492bfb17cf9f0a0361d429257). And why would it? My view is that it's a generic API for retrieving a selected set of attributes specific for each DMA controller/platform on which it is instantiated.

The change came into existence because SOF uses that API (specifically - host-zephyr.c). I made an attempt to get SOF to work on the RT685's DSP domain. While fully functional SOF on that target is somewhat of a distant goal, this function is groundwork for making SOF run.

About the values - I think it's best to keep data transferred being domains aligned to 4 byte boundaries because of data caches of the two domains. While I haven't touched on that topic, invalidation would be easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Raymond0225 So... any other arguments?

Copy link
Contributor Author

@VitekST VitekST May 2, 2025

Choose a reason for hiding this comment

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

@Raymond0225 Would like to gently nudge this.

{
switch (type) {
case DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT:
case DMA_ATTR_BUFFER_SIZE_ALIGNMENT:
case DMA_ATTR_COPY_ALIGNMENT:
*value = 4;
break;

default:
return -EINVAL;
}

return 0;
}

static int dma_mcux_lpc_init(const struct device *dev)
{
const struct dma_mcux_lpc_config *config = dev->config;
struct dma_mcux_lpc_dma_data *data = dev->data;

data->ctx.magic = DMA_MAGIC;
data->ctx.dma_channels = config->num_of_channels;

/* Indicate that the Otrig Muxes are not connected */
for (int i = 0; i < config->num_of_otrigs; i++) {
data->otrig_array[i].source_channel = EMPTY_OTRIG;
Expand Down Expand Up @@ -860,6 +883,7 @@ static DEVICE_API(dma, dma_mcux_lpc_api) = {
.stop = dma_mcux_lpc_stop,
.reload = dma_mcux_lpc_reload,
.get_status = dma_mcux_lpc_get_status,
.get_attribute = dma_mcux_lpc_get_attribute
};

#define DMA_MCUX_LPC_CONFIG_FUNC(n) \
Expand Down
Loading