14
14
#include "nwl_defines.h"
16
int dma_nwl_enable_irq(nwl_dma_t *ctx, pcilib_irq_type_t type) {
16
int dma_nwl_init_irq(nwl_dma_t *ctx, uint32_t val) {
17
if (val&(DMA_INT_ENABLE|DMA_USER_INT_ENABLE)) {
18
if (val&DMA_INT_ENABLE) ctx->irq_preserve |= PCILIB_DMA_IRQ;
19
if (val&DMA_USER_INT_ENABLE) ctx->irq_preserve |= PCILIB_EVENT_IRQ;
26
int dma_nwl_free_irq(nwl_dma_t *ctx) {
28
dma_nwl_disable_irq((pcilib_dma_context_t*)ctx, 0);
29
if (ctx->irq_preserve) dma_nwl_enable_irq((pcilib_dma_context_t*)ctx, ctx->irq_preserve, 0);
36
int dma_nwl_enable_irq(pcilib_dma_context_t *vctx, pcilib_irq_type_t type, pcilib_dma_flags_t flags) {
38
nwl_dma_t *ctx = (nwl_dma_t*)vctx;
40
if (flags&PCILIB_DMA_FLAG_PERMANENT) ctx->irq_preserve |= type;
19
42
if (ctx->irq_enabled == type) return 0;
44
type |= ctx->irq_enabled;
46
nwl_read_register(val, ctx, ctx->base_addr, REG_DMA_CTRL_STATUS);
47
if (!ctx->irq_init) dma_nwl_init_irq(ctx, val);
21
nwl_read_register(val, ctx, ctx->base_addr, REG_DMA_CTRL_STATUS);
22
49
val &= ~(DMA_INT_ENABLE|DMA_USER_INT_ENABLE);
23
50
nwl_write_register(val, ctx, ctx->base_addr, REG_DMA_CTRL_STATUS);
36
int dma_nwl_disable_irq(nwl_dma_t *ctx) {
64
int dma_nwl_disable_irq(pcilib_dma_context_t *vctx, pcilib_dma_flags_t flags) {
66
nwl_dma_t *ctx = (nwl_dma_t*)vctx;
39
68
ctx->irq_enabled = 0;
41
70
nwl_read_register(val, ctx, ctx->base_addr, REG_DMA_CTRL_STATUS);
71
if (!ctx->irq_init) dma_nwl_init_irq(ctx, val);
42
72
val &= ~(DMA_INT_ENABLE|DMA_USER_INT_ENABLE);
43
73
nwl_write_register(val, ctx, ctx->base_addr, REG_DMA_CTRL_STATUS);
75
if (flags&PCILIB_DMA_FLAG_PERMANENT) ctx->irq_preserve = 0;
48
81
int dma_nwl_enable_engine_irq(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
51
dma_nwl_enable_irq(ctx, ctx->irq_enabled|PCILIB_DMA_IRQ);
84
dma_nwl_enable_irq(ctx, ctx->irq_enabled|PCILIB_DMA_IRQ, 0);
53
86
nwl_read_register(val, ctx, ctx->engines[dma].base_addr, REG_DMA_ENG_CTRL_STATUS);
54
87
val |= (DMA_ENG_INT_ENABLE);