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: dma_cavs: DMA driver support for per-channel callbacks #7980

Merged
merged 1 commit into from
May 31, 2018
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
36 changes: 19 additions & 17 deletions drivers/dma/dma_cavs.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,29 @@ static void dw_dma_isr(void *arg)
dw_write(dev_cfg->base, DW_CLEAR_TFR, status_tfr);

/* Dispatch ISRs for channels depending upon the bit set */
if (dev_data->dma_blkcallback) {
while (status_block) {
channel = find_lsb_set(status_block) - 1;
status_block &= ~(1 << channel);
while (status_block) {
channel = find_lsb_set(status_block) - 1;
status_block &= ~(1 << channel);
chan_data = &dev_data->chan[channel];

if (chan_data->dma_blkcallback) {

/* Ensure the linked list (chan_data->lli) is
* freed in the user callback function once
* all the blocks are transferred.
*/
dev_data->dma_blkcallback(dev, channel, 0);
chan_data->dma_blkcallback(dev, channel, 0);
}
}

if (dev_data->dma_tfrcallback) {
while (status_tfr) {
channel = find_lsb_set(status_tfr) - 1;
status_tfr &= ~(1 << channel);
chan_data = &dev_data->chan[channel];
k_free(chan_data->lli);
chan_data->lli = NULL;
dev_data->dma_tfrcallback(dev, channel, 0);
while (status_tfr) {
channel = find_lsb_set(status_tfr) - 1;
status_tfr &= ~(1 << channel);
chan_data = &dev_data->chan[channel];
k_free(chan_data->lli);
chan_data->lli = NULL;
if (chan_data->dma_tfrcallback) {
chan_data->dma_tfrcallback(dev, channel, 0);
}
}
}
Expand Down Expand Up @@ -250,9 +252,9 @@ static int dw_dma_config(struct device *dev, u32_t channel,
* at the end of each block.
*/
if (cfg->complete_callback_en) {
dev_data->dma_blkcallback = cfg->dma_callback;
chan_data->dma_blkcallback = cfg->dma_callback;
} else {
dev_data->dma_tfrcallback = cfg->dma_callback;
chan_data->dma_tfrcallback = cfg->dma_callback;
}

return 0;
Expand All @@ -270,11 +272,11 @@ static int dw_dma_transfer_start(struct device *dev, u32_t channel)

chan_data = &dev_data->chan[channel];

if (dev_data->dma_tfrcallback) {
if (chan_data->dma_tfrcallback) {
dw_write(dev_cfg->base, DW_MASK_TFR, INT_UNMASK(channel));
}

if (dev_data->dma_blkcallback) {
if (chan_data->dma_blkcallback) {
dw_write(dev_cfg->base, DW_MASK_BLOCK, INT_UNMASK(channel));
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/dma/dma_cavs.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ struct dma_chan_data {
struct dw_lli2 *lli;
u32_t cfg_lo;
u32_t cfg_hi;
void (*dma_blkcallback)(struct device *dev, u32_t channel,
int error_code);
void (*dma_tfrcallback)(struct device *dev, u32_t channel,
int error_code);
};

#define DW_MAX_CHAN 8
Expand Down Expand Up @@ -111,10 +115,6 @@ struct dw_drv_plat_data {

/* Device run time data */
struct dw_dma_dev_data {
void (*dma_blkcallback)(struct device *dev, u32_t channel,
int error_code);
void (*dma_tfrcallback)(struct device *dev, u32_t channel,
int error_code);
struct dw_drv_plat_data *channel_data;
struct dma_chan_data chan[DW_MAX_CHAN];
};
Expand Down