1 | /////////////////////////////////////////////////////////////////////////////////// |
---|
2 | // File : cma_driver.c |
---|
3 | // Date : 01/03/2014 |
---|
4 | // Author : alain greiner |
---|
5 | // Copyright (c) UPMC-LIP6 |
---|
6 | /////////////////////////////////////////////////////////////////////////////////// |
---|
7 | |
---|
8 | #include <cma_driver.h> |
---|
9 | #include <hard_config.h> |
---|
10 | #include <utils.h> |
---|
11 | |
---|
12 | #if !defined(SEG_CMA_BASE) |
---|
13 | # error: You must define SEG_CMA_BASE in the hard_config.h file |
---|
14 | #endif |
---|
15 | |
---|
16 | ///////////////////////////////////////////////////// |
---|
17 | unsigned int _cma_get_register( unsigned int channel, |
---|
18 | unsigned int index ) |
---|
19 | { |
---|
20 | unsigned int* vaddr = (unsigned int*)SEG_CMA_BASE + |
---|
21 | CHBUF_CHANNEL_SPAN*channel + index; |
---|
22 | return _io_extended_read( vaddr ); |
---|
23 | } |
---|
24 | |
---|
25 | ///////////////////////////////////////////// |
---|
26 | void _cma_set_register( unsigned int channel, |
---|
27 | unsigned int index, |
---|
28 | unsigned int value ) |
---|
29 | { |
---|
30 | unsigned int* vaddr = (unsigned int*)SEG_CMA_BASE + |
---|
31 | CHBUF_CHANNEL_SPAN*channel + index; |
---|
32 | _io_extended_write( vaddr, value ); |
---|
33 | } |
---|
34 | |
---|
35 | //////////////////////////////////////////////////// |
---|
36 | void _cma_start_channel( unsigned int channel, |
---|
37 | unsigned long long src_paddr, |
---|
38 | unsigned int src_nbufs, |
---|
39 | unsigned long long dst_paddr, |
---|
40 | unsigned int dst_nbufs, |
---|
41 | unsigned int buf_length ) |
---|
42 | { |
---|
43 | _cma_set_register( channel, CHBUF_SRC_DESC , (unsigned int)(src_paddr & 0xFFFFFFFF) ); |
---|
44 | _cma_set_register( channel, CHBUF_SRC_EXT , (unsigned int)(src_paddr >> 32) ); |
---|
45 | _cma_set_register( channel, CHBUF_SRC_NBUFS, src_nbufs ); |
---|
46 | _cma_set_register( channel, CHBUF_DST_DESC , (unsigned int)(dst_paddr & 0xFFFFFFFF) ); |
---|
47 | _cma_set_register( channel, CHBUF_DST_EXT , (unsigned int)(dst_paddr >> 32) ); |
---|
48 | _cma_set_register( channel, CHBUF_DST_NBUFS, dst_nbufs ); |
---|
49 | _cma_set_register( channel, CHBUF_BUF_SIZE , buf_length ); |
---|
50 | _cma_set_register( channel, CHBUF_PERIOD , 300 ); |
---|
51 | _cma_set_register( channel, CHBUF_RUN , 1 ); |
---|
52 | } |
---|
53 | |
---|
54 | ////////////////////////////////////////////// |
---|
55 | void _cma_stop_channel( unsigned int channel ) |
---|
56 | { |
---|
57 | _cma_set_register( channel, CHBUF_RUN , 0 ); |
---|
58 | } |
---|
59 | |
---|
60 | ////////////////////////////////////// |
---|
61 | void _cma_isr( unsigned int irq_type, |
---|
62 | unsigned int irq_id, |
---|
63 | unsigned int channel ) |
---|
64 | { |
---|
65 | _puts("\n[GIET ERROR] _cma_isr() not implemented\n"); |
---|
66 | _exit(); |
---|
67 | } |
---|
68 | |
---|
69 | // Local Variables: |
---|
70 | // tab-width: 4 |
---|
71 | // c-basic-offset: 4 |
---|
72 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
73 | // indent-tabs-mode: nil |
---|
74 | // End: |
---|
75 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
76 | |
---|