/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to dma/nwl_irq.c

  • Committer: Suren A. Chilingaryan
  • Date: 2011-07-12 12:39:06 UTC
  • Revision ID: csa@dside.dyndns.org-20110712123906-4tas2h34i0b2tkp8
Provide IRQ enable/disable call

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#include "nwl.h"
14
14
#include "nwl_defines.h"
15
15
 
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;
 
20
    }
 
21
    
 
22
    ctx->irq_init = 1;
 
23
    return 0;
 
24
}
 
25
 
 
26
int dma_nwl_free_irq(nwl_dma_t *ctx) {
 
27
    if (ctx->irq_init) {
 
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);
 
30
        ctx->irq_enabled = 0;
 
31
        ctx->irq_init = 0;
 
32
    }
 
33
    return 0;
 
34
}
 
35
 
 
36
int dma_nwl_enable_irq(pcilib_dma_context_t *vctx, pcilib_irq_type_t type, pcilib_dma_flags_t flags) {
17
37
    uint32_t val;
 
38
    nwl_dma_t *ctx = (nwl_dma_t*)vctx;
18
39
    
 
40
    if (flags&PCILIB_DMA_FLAG_PERMANENT) ctx->irq_preserve |= type;
 
41
 
19
42
    if (ctx->irq_enabled == type) return 0;
 
43
    
 
44
    type |= ctx->irq_enabled;
 
45
    
 
46
    nwl_read_register(val, ctx, ctx->base_addr, REG_DMA_CTRL_STATUS);
 
47
    if (!ctx->irq_init) dma_nwl_init_irq(ctx, val);
20
48
 
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);
24
51
    
33
60
    return 0;
34
61
}
35
62
 
36
 
int dma_nwl_disable_irq(nwl_dma_t *ctx) {
 
63
 
 
64
int dma_nwl_disable_irq(pcilib_dma_context_t *vctx, pcilib_dma_flags_t flags) {
37
65
    uint32_t val;
 
66
    nwl_dma_t *ctx = (nwl_dma_t*)vctx;
38
67
    
39
68
    ctx->irq_enabled = 0;
40
69
    
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);
44
74
    
 
75
    if (flags&PCILIB_DMA_FLAG_PERMANENT) ctx->irq_preserve = 0;
 
76
 
45
77
    return 0;
46
78
}
47
79
 
 
80
 
48
81
int dma_nwl_enable_engine_irq(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
49
82
    uint32_t val;
50
83
    
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);
52
85
 
53
86
    nwl_read_register(val, ctx, ctx->engines[dma].base_addr, REG_DMA_ENG_CTRL_STATUS);
54
87
    val |= (DMA_ENG_INT_ENABLE);
68
101
}
69
102
 
70
103
 
 
104
 
71
105
// ACK