|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . Q6 ?( m; X) e9 u
- [code]EDMA sample test application
% A8 v4 [4 |4 V S4 j& O - /*
6 r- j5 i5 L& d4 ?4 A - * edma_test.c
4 [* S9 ?# q/ [" J! v, W - *
# Y8 ^# a! O2 M9 d3 ? - * brief EDMA3 Test Application8 V. N/ G! I) M1 X- Q" \$ s
- *
! v3 @- p/ J/ t: x - * This file contains EDMA3 Test code.
2 E* C# i2 f' p - *0 I7 B- r. e* S( f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- h& n$ Y" y/ j& M/ d+ M# F. M9 u
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 v' H0 `1 k& o
- * TO CHANGE.- t" Q; p' F. M: Z4 B0 W
- *# O* j* w+ m( j. z/ a7 [& |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
F2 A( R) H% [ W0 u - *
8 o: Z. m o: [1 V& k7 E - * This program is free software; you can redistribute it and/or" s. Y V% |% z
- * modify it under the terms of the GNU General Public License as
. ?, ^# f; `1 { - * published by the Free Software Foundation version 2.
: D- W( [, K- F7 k3 j5 T - *
% g3 Z) m, l, Y4 v$ a5 @ H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 n$ @" T0 q i( H+ h$ T7 Q( ]
- * kind, whether express or implied; without even the implied warranty/ i% M8 ?3 `" {, Z8 k5 J
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" p8 z4 u+ D* X: `/ h/ A' | - * GNU General Public License for more details.
: q7 R( |$ p5 ]) F3 a - */+ h! u! |2 ?* g& N5 [
) g0 k& [2 e9 y H J0 B9 }( Y- #include <linux/module.h>
/ {! U" i$ Y2 C! m - #include <linux/init.h>5 w# q p! |9 @8 V$ O% {* E# k
- #include <linux/errno.h>
" {2 h- B( x' U7 U4 V - #include <linux/types.h>
% Y' L: L0 r3 W* V: i - #include <linux/interrupt.h>
6 V: Y. p$ p% F - #include <asm/io.h>: p! l7 E7 n3 V9 ^' I
- #include <linux/moduleparam.h>
$ X% T) D" \! o, D9 Q5 D - #include <linux/sysctl.h>
, T9 [2 r1 M/ {: w( ?5 [6 B - #include <linux/mm.h>- z- f( \! m \1 G" \
- #include <linux/dma-mapping.h>
! u( m" ?/ s" A! O& U: g - ( x6 J: W! o& S1 c! [: J+ D0 p
- #include <mach/memory.h>
# G) ]1 y7 O2 H- V - #include <mach/hardware.h>
; O4 i- {: ^7 i9 |% o; }( ] - #include <mach/irqs.h>
1 F) [9 \. j, |2 x5 w% q - #include <asm/hardware/edma.h>
+ n2 r. o1 B, p2 P; \+ v
9 u; b6 M* c; P+ `3 H+ A5 S1 f% j6 W- #undef EDMA3_DEBUG
9 \" e" x4 `; r: e/ d - /*#define EDMA3_DEBUG*/, P p1 g3 c% m( [+ k; _6 _( ^2 M
- 6 H. k7 s! {2 q% M5 R. d) E1 V
- #ifdef EDMA3_DEBUG
9 J( Z# h# T" \' E J! U - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 X) E1 h# l$ R8 c. o - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( R- o) t6 U" x1 n8 _9 N$ `5 C - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! f/ t* N9 s4 ^( ^ - #else
4 J7 x3 N9 k- U6 Y L1 g - #define DMA_PRINTK( x... )
6 A& D+ G1 Z6 D" k, l4 D - #define DMA_FN_IN
0 p* _& a6 h' q1 G - #define DMA_FN_OUT
7 |0 S$ v _6 o9 j - #endif
) O. O J- g# t' k) }6 z; d - ; a a' B$ g$ `5 p2 j: z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
# ?- A7 p# a5 n E# h - #define STATIC_SHIFT 3, _3 o% N' y5 K- D; Z
- #define TCINTEN_SHIFT 20% ]4 a8 w5 w4 L2 S
- #define ITCINTEN_SHIFT 214 H! W& C$ S2 [/ k' X' ^) b
- #define TCCHEN_SHIFT 22
; q; v, `/ x0 k/ z3 i - #define ITCCHEN_SHIFT 23$ P; V1 i$ ^2 c$ p) z! x
- 0 D U: M6 E6 F3 k
- static volatile int irqraised1 = 0;
7 q4 {9 r6 K6 y$ G0 b9 v$ b" s - static volatile int irqraised2 = 0;6 @! [8 v2 I& u% i$ _) d
- . R% x3 z- |" E3 i5 n. p
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. T! G9 W8 l+ M - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! j! D* I8 c T* U& h/ x4 @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
R0 U) \% x5 X6 o. l9 I) H1 ~/ P
0 l f! x; A8 Q7 s/ g: e' m) u- dma_addr_t dmaphyssrc1 = 0;, N+ P% S+ _6 p X
- dma_addr_t dmaphyssrc2 = 0;7 d/ N& c$ W p2 e
- dma_addr_t dmaphysdest1 = 0;* x7 t5 F& _1 E; j1 v2 B5 x
- dma_addr_t dmaphysdest2 = 0;0 f$ I }3 J6 D5 K; ~
- 6 \% @# _, q, l* N
- char *dmabufsrc1 = NULL;
7 ?) T4 Y# i. D1 n - char *dmabufsrc2 = NULL;* ]9 x" y. c1 `
- char *dmabufdest1 = NULL;
$ t, M, U) D# q s4 g0 C - char *dmabufdest2 = NULL;) ~; { P. x! l; |8 m
- ; o1 |$ T0 ^6 m6 S8 A/ {
- static int acnt = 512;/ Q9 G8 m8 a0 U( |! X
- static int bcnt = 8;% _3 S4 E- x+ |/ U7 D
- static int ccnt = 8;. O0 G+ {3 C" D" n0 d
5 u2 ~* }& S! R" W# }- z- module_param(acnt, int, S_IRUGO);0 [+ ?; S4 Q' C/ S
- module_param(bcnt, int, S_IRUGO);
- {* r% H' q# p, d2 G2 [1 L- Z - module_param(ccnt, int, S_IRUGO);
复制代码 & z; k4 {/ p" a
9 n# A$ K, I$ ?% K$ ~) H) c3 p 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* T1 I0 e" o0 y! R
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 @+ t1 k, r9 j+ v3 P 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 P9 E1 L* z1 O. U- I8 J" D) ~% U" d, `8 s
# x# I( m2 \. } |
|