|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' M2 A( Q* M# M @ g: N" B+ H- [code]EDMA sample test application
& K% N H$ i6 y* e6 k7 y - /*
1 B6 _5 P; N6 z - * edma_test.c
' W+ y. R. D) m8 C7 Y2 O* e - *
4 e+ ~2 z5 B9 j - * brief EDMA3 Test Application. {% Q. R2 l9 N2 S$ z, n; p
- *
0 s6 G: G0 p- V9 ^/ }2 Y, M - * This file contains EDMA3 Test code.
* q" i8 f, M, L5 ? - *
6 s% z- J, ~; n5 Z2 a* m - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 h2 [. y( y7 i `: Y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; V; U5 s7 V: l' T - * TO CHANGE.
% s; z3 z5 @0 f8 N5 U1 F0 w) i+ V - ** O$ S. h( }' |) h7 }1 e9 H6 T# J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- n2 w1 U! f0 U( `) h- ^" f
- *6 T0 G0 @+ i1 a, Y0 Y' @
- * This program is free software; you can redistribute it and/or. V! J4 k; X% A3 p
- * modify it under the terms of the GNU General Public License as/ A. U) u% O( V
- * published by the Free Software Foundation version 2.% `+ K: R" l W% i& G
- *' i9 F1 X X! |% |8 H2 O, \: L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& [ K0 D+ G( W9 d" c( r: v- V2 v8 x - * kind, whether express or implied; without even the implied warranty
v9 `* n9 `' D. M i- z - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 }, C4 K) z" l- P* W! Z& B- ^ - * GNU General Public License for more details.8 ~7 X' P, }$ e% ]
- */
2 ?$ V) n) p% w) y1 F" j! B - 8 k- Y3 R. B- K! D4 ?
- #include <linux/module.h>
" Y( H& S/ v$ f" y% X. ]. f4 I - #include <linux/init.h>
; h8 ~+ K0 Z. H; Y# e# p6 E - #include <linux/errno.h>
: c3 r, E; I: H* r; a8 _ - #include <linux/types.h> P N1 E' v2 \1 c( \. j3 \' F
- #include <linux/interrupt.h>. x5 ~4 C' J* T I+ Z0 s9 R
- #include <asm/io.h>) V! q; w1 U' _2 p6 L
- #include <linux/moduleparam.h>
( S- O0 l1 A( {3 [ - #include <linux/sysctl.h>
( J- R+ |8 i" ?- d/ ~ - #include <linux/mm.h>
! @, K# a3 [; w+ S7 _, u! ]/ a2 ? - #include <linux/dma-mapping.h>9 a- }! m2 [& x+ ~' F" @9 q
9 q" D7 G C5 S L2 X6 t3 `- #include <mach/memory.h>
& M! t5 u" B) K# R4 L, } - #include <mach/hardware.h>
Q2 k ~( M7 h8 R5 F - #include <mach/irqs.h>, r" e( ]4 r- i/ K
- #include <asm/hardware/edma.h>
' T4 K: k6 ^ F" V$ F
2 z; D, i# D8 I) X7 H- #undef EDMA3_DEBUG
4 i( i$ |" l7 N; ~7 ` - /*#define EDMA3_DEBUG*/
* c. i1 m3 b: G6 b5 z
* u& S4 a$ z" x- #ifdef EDMA3_DEBUG
2 n) `% m( e3 J4 l - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 ^! _6 R. C$ ]6 v- o1 `" z! A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; M3 b4 t G# f' h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): h: g1 c+ }" C; ?
- #else
! E0 P$ H* b w" v! h; s - #define DMA_PRINTK( x... )
! t. E7 t$ |9 V* B - #define DMA_FN_IN
8 o# I) t- c) h$ v - #define DMA_FN_OUT
: K$ B' n) m6 r3 j" T5 | c* l - #endif
, Q$ U6 ^6 n5 u& O2 {
+ `4 x: b, Y7 r5 h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% T- O6 u5 q- T" {% c: B, o
- #define STATIC_SHIFT 3
* u- h; a) u5 q K$ m* R - #define TCINTEN_SHIFT 20
0 c; m) ?0 [: }5 M: f$ H! u - #define ITCINTEN_SHIFT 219 j+ I9 `% _! |7 A/ w" y# \! A4 y
- #define TCCHEN_SHIFT 22
: Y# }* u% ~0 B# k5 g - #define ITCCHEN_SHIFT 23
* j7 O) A q) Q% _+ X! ^ - ) b# j2 R. x; L1 q! o% @8 P9 |1 T
- static volatile int irqraised1 = 0;2 z- n; w3 q* ?7 ?+ @/ W
- static volatile int irqraised2 = 0;
( L7 \1 D. |0 z' L - ) B' M7 A+ Q+ C7 y) W0 o! i
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 k5 o+ V; v3 y5 l. u; _1 j5 k. z. Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, U3 P1 W! N7 @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 v& s( Q! e( }& p m2 V3 { - 7 s8 @1 y. e7 a8 H; }" d
- dma_addr_t dmaphyssrc1 = 0;
* s! h; t6 g7 k6 i - dma_addr_t dmaphyssrc2 = 0;- z, ]! c* U6 n. y0 v
- dma_addr_t dmaphysdest1 = 0;
, O; w+ T, T+ ~. E5 | - dma_addr_t dmaphysdest2 = 0;( r1 I4 C4 i. ~5 H
- ; G8 z, \9 n- G8 K% z
- char *dmabufsrc1 = NULL;
7 r# F7 f1 B# Z: F) S; g& f9 } - char *dmabufsrc2 = NULL;
6 C/ G, V, n8 E9 v% \ - char *dmabufdest1 = NULL;
. L" A) C. [+ e% F8 F0 Y - char *dmabufdest2 = NULL;
3 b6 X6 ~/ y. w1 u( K. I1 t3 \
# { @, K5 m% o6 m; X [5 y- static int acnt = 512;$ t' K0 Z! n+ N! P2 F% |& j* A& Y
- static int bcnt = 8;6 m* s4 }$ C2 F; r I! b
- static int ccnt = 8;
2 p: K* o; S# F# U
( Q! D" |/ @: P, c7 Z% {0 D! _- m- module_param(acnt, int, S_IRUGO);0 x1 Q4 E: P: e8 S2 y
- module_param(bcnt, int, S_IRUGO);% F1 y3 Z5 |1 Q Z8 Y
- module_param(ccnt, int, S_IRUGO);
复制代码
: ]- L* S$ h7 {/ J# v0 W$ r
& ~% @5 E- _0 g1 L 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 q; I1 }$ z E( E7 s. q! r, W
arm-none-linux-gnueabi-gcc -I /home/tl/omapl138/linux-3.3/arch/arm/include -I /home/tl/omapl138/linux-3.3/include EDMA3test.cpp -o EDMA3这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! f& ]- J# F' @9 a3 X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
v1 a& V$ b: B* d
8 D3 v. v! e+ x9 E# `" Y
; u( x& n7 |* c; W) D+ q |
|