|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 C6 |5 E# R- k9 |- [code]EDMA sample test application
0 e- y7 R- `6 \, E8 Z" U0 l - /*
; T; p) v: L% a - * edma_test.c
) c2 q# B9 K& S9 R! j - *4 N6 y1 x. Y' S
- * brief EDMA3 Test Application
6 d u$ u$ ?/ J8 t - *
$ A1 z2 l: R D' y# q. d* ?/ b - * This file contains EDMA3 Test code.
4 [3 M- e/ P$ c- K - *; o6 p8 p3 \6 m) V4 S( c! d2 `% G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" U$ X2 D) s3 |. K+ O. ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 y9 r8 N/ S0 E; {+ F0 A
- * TO CHANGE.
. w- F! h% z: H9 O - *9 v* A, R1 D2 }" Z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 S; Q9 B# S/ Y* |3 { - *
7 g4 x; C1 O& O k! |7 @ - * This program is free software; you can redistribute it and/or3 R; S& p( m' ]$ c
- * modify it under the terms of the GNU General Public License as
* m) b( I+ m5 v6 } - * published by the Free Software Foundation version 2.
% S1 e6 i; c* N/ G* @ - ** ~! S- s# H2 T3 U" ~) {/ Y# D% W
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% \$ j/ s0 |# f1 T/ w3 g - * kind, whether express or implied; without even the implied warranty
, D8 E% |; b5 G/ W+ T0 } n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ p0 [: Z. E6 `) A$ v9 }; V - * GNU General Public License for more details.
6 M8 Y2 U' B' r% R) j) B: \ - */7 |, ~( g# V8 _" i/ a; v" f' M3 \( k
- ; Q n3 ]+ t k r2 e& B
- #include <linux/module.h>
/ U1 X$ p1 R0 D7 L- D - #include <linux/init.h>
1 ]3 | A$ c t/ h$ E* u- E) \6 e - #include <linux/errno.h>- X" Z( u: {( {# o8 }
- #include <linux/types.h>
2 [7 z' i5 ?; I - #include <linux/interrupt.h>; g. `& U: N3 m2 t) G. r
- #include <asm/io.h>) E: \6 ^! p% }% P1 C: J
- #include <linux/moduleparam.h>
" s+ _! u B* ? - #include <linux/sysctl.h>: H( ]. U$ f( I4 J& w* u+ j
- #include <linux/mm.h>. Q' q6 _( U- b( g, q8 ~
- #include <linux/dma-mapping.h>
' m! u# g! N0 W% i: X
: \! F8 B" p' ]3 ?# H B* z- #include <mach/memory.h>9 P4 w5 O$ M& Y: i; D2 v
- #include <mach/hardware.h>
3 j5 M# u% A4 l1 O6 f' e; l - #include <mach/irqs.h>
, z1 h# I' a6 v+ [: |( G' t/ a - #include <asm/hardware/edma.h>
t2 h8 {' L3 X' i1 T( \
3 j) z/ N7 b# M& {0 w9 W- #undef EDMA3_DEBUG8 {& A& u. `! p) k, J
- /*#define EDMA3_DEBUG*/
' D) ?+ ?! ]* D6 ^/ u
* M" y' |5 r) z: d, k- #ifdef EDMA3_DEBUG
; u( l- q0 r& |5 V' x7 \; V& B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! F9 h5 b6 T6 H' \7 U - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): L" ?2 ]- [6 e: J, D/ w6 l* w" @- v0 I- q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): m7 ]+ x, L1 n a0 i7 X# a
- #else
9 M. s2 O. o [5 T - #define DMA_PRINTK( x... )
4 Y4 |) p1 J) a) w* a, }! g - #define DMA_FN_IN( A( i9 g+ o! V& ~
- #define DMA_FN_OUT# j6 `2 c7 S( i8 p, C. |4 K
- #endif
( n+ o, T! W, o: w# X6 J - # A/ t4 `; `9 H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 E2 y: c$ t1 C7 y& U& i. S
- #define STATIC_SHIFT 3
* A+ e ?& h4 G3 r/ a9 ~ - #define TCINTEN_SHIFT 20" y" K3 c( m; |0 F1 n
- #define ITCINTEN_SHIFT 21, b- U& y% j6 n9 m0 ]/ [6 T% \2 b1 K
- #define TCCHEN_SHIFT 22
7 X9 ^7 ~: y! ]3 t% ~1 U4 P8 V - #define ITCCHEN_SHIFT 237 q& }$ q" g/ C, J0 q
7 @$ a [* k$ T0 W" W7 w) K6 u- static volatile int irqraised1 = 0;4 ?: s% d! S5 l
- static volatile int irqraised2 = 0;# K/ G3 i$ B. z9 A
- ) u8 _% P% G( l9 Y3 |
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" j0 P3 T" R1 j! c6 b& \7 p( Q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( I5 D, H9 D$ J% h5 i$ h
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 W. J% Z0 _+ h8 k. e% w' G" r) w4 i
* `, z! w6 A: M' b) i) I- dma_addr_t dmaphyssrc1 = 0;5 u, n' U" e s: J- {. l7 t
- dma_addr_t dmaphyssrc2 = 0;
$ X7 E" F8 `! W. M" R - dma_addr_t dmaphysdest1 = 0;* P- S: z+ P/ r8 Y
- dma_addr_t dmaphysdest2 = 0;# s" {8 Z; r' E& Z( h# q
- / J/ D3 G3 {3 V% ^# m! X# M5 F
- char *dmabufsrc1 = NULL;/ @( a3 Z3 O: u( s
- char *dmabufsrc2 = NULL;
! h, H9 G& |- n8 K8 ? - char *dmabufdest1 = NULL;/ \' M# _; u9 ^
- char *dmabufdest2 = NULL;
- N0 S0 B$ l* q S8 k - 8 b9 x3 } v1 j, f2 u
- static int acnt = 512;
+ ]$ H1 ? L; ]8 N4 D7 w8 |9 k - static int bcnt = 8;) g" [4 N- C: `; P
- static int ccnt = 8;) i4 ?/ b i: w
% e' j8 H- }0 x8 b- z1 C( g- module_param(acnt, int, S_IRUGO);: x$ S" X6 I8 [4 b+ Q' V9 m |
- module_param(bcnt, int, S_IRUGO);
2 g' P3 M7 l) u" u - module_param(ccnt, int, S_IRUGO);
复制代码
4 F u: M& i) Y: j& ?& k. d: ~8 M N& X; Y/ V! V9 i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& |5 k7 V7 g F' U' L( a- \. s" @7 ]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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 s3 I) N _# V9 b2 F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 b. t' v* k; O" u" z% a1 o
9 R1 R9 S4 Q9 H! m- \( N+ S, d/ Z% o& O) t) h' S
|
|