|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; N7 `* }( m- h: K
- [code]EDMA sample test application
. U( Q; \/ Z) V) o2 | - /*
' V. { n8 ^+ C0 f/ C8 }# s1 f# p - * edma_test.c" H0 N- Z4 I4 n% l; s. A
- *9 W- m7 e- d, r
- * brief EDMA3 Test Application
/ N1 [2 v; L8 `; p- y - *
$ r' P8 K; i' j3 j9 } - * This file contains EDMA3 Test code., N T5 N0 B$ p4 A
- *
- j' T$ {, A) B: t# t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, x3 D$ J9 }) q/ S. {7 I, `& A1 E. R - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( U" V. }* j# E4 N' f - * TO CHANGE.% |9 p3 e" _5 b# J4 } h
- *
% |6 G6 g4 ?& v8 v, b$ ^, k! Y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ K: P3 T1 M( S5 O1 ^+ i - *& B3 R% y+ r8 N V' w
- * This program is free software; you can redistribute it and/or+ S6 T. o" K, r& h8 a+ u
- * modify it under the terms of the GNU General Public License as- y/ ?$ T8 @ [2 p
- * published by the Free Software Foundation version 2.
5 g1 o% n8 \1 ? H0 S8 C' {$ E% l( E4 @* Z - *3 u T; \0 g( Y7 f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ ~- P1 [' Y4 L - * kind, whether express or implied; without even the implied warranty1 o2 h( C9 ]. _- y7 H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ s, F& _$ K9 a+ S. ]# Z5 e7 X - * GNU General Public License for more details.
6 B: b$ l B0 ~& H3 w+ X# d4 X) } - */2 a0 C+ l2 N. c4 V8 D
7 m5 h2 F1 `8 y# ^- #include <linux/module.h>
* n. a6 K6 s/ O9 ]/ P - #include <linux/init.h>' r, ?8 ~' r& \" N" v
- #include <linux/errno.h>
9 j4 X$ g" A1 V! N - #include <linux/types.h>3 v% G1 i# k9 U
- #include <linux/interrupt.h>$ G3 b+ f; {8 C# }. n- o
- #include <asm/io.h>* u6 n2 k$ i) j4 M
- #include <linux/moduleparam.h>- ^' T/ ^. H& q* g4 Y) V
- #include <linux/sysctl.h>
. Q' w# b0 ]8 m% z) w - #include <linux/mm.h>
: g# y$ o* e$ Q, l - #include <linux/dma-mapping.h>4 t6 P' u; [- T
U3 w- f$ A$ c2 G- #include <mach/memory.h>. N9 v f. N; g1 v
- #include <mach/hardware.h>
3 r1 W8 C7 E/ s% J - #include <mach/irqs.h>
$ _4 K# a) j+ y/ |5 N - #include <asm/hardware/edma.h>
/ f8 O% U: C. g+ ]
" W+ z( F0 u% t4 G- #undef EDMA3_DEBUG, d+ f: n/ A# E, e0 H) X) O9 W
- /*#define EDMA3_DEBUG*/
. V% k6 D6 I7 z& x W* ? - 0 e9 J# u6 r' Q0 B+ a
- #ifdef EDMA3_DEBUG
4 g! d* z3 s! _' P; @ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 w! q6 S* c# X, v
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 x9 k, h5 U* R# E4 B7 ? - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 w" Y: _! L/ N1 V4 V. P+ P R) b
- #else" Q. g! p; L; Z& Q( r
- #define DMA_PRINTK( x... )
: ]7 L x3 l% j* R - #define DMA_FN_IN! B; {. V: O8 b) Y7 x) j
- #define DMA_FN_OUT
* i" R C; P, E- z& q0 o- g/ B - #endif$ V; [, G# `: j; C7 _0 y9 y
6 ~9 z% S0 W2 t7 ?& S: M- #define MAX_DMA_TRANSFER_IN_BYTES (32768) `. H( u( q# N' F5 ^" H
- #define STATIC_SHIFT 3
; j. V$ ^ q0 }/ u' }+ g5 z/ C - #define TCINTEN_SHIFT 20
0 \ p& l3 O& Z, [# v - #define ITCINTEN_SHIFT 21
( J/ T0 Y! t& d4 m5 q3 w& A& r - #define TCCHEN_SHIFT 225 S7 U; T7 ]9 @$ ~ w
- #define ITCCHEN_SHIFT 233 B3 l& g8 v& c
9 k+ ?% m: s1 r Q) E- static volatile int irqraised1 = 0;$ }7 O; F* p! _- f9 J
- static volatile int irqraised2 = 0;
) \2 d+ p* Z& n5 x - # L0 @6 c$ ?% T6 t4 f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 h2 z" a& O M$ _- x% b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# f( r8 v+ d& L, A8 Q6 @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. `% h4 A# Q* B, a
- 3 }1 r5 z- {5 [9 S# x! q
- dma_addr_t dmaphyssrc1 = 0;7 d2 T; v: O# f0 c/ k/ F7 H
- dma_addr_t dmaphyssrc2 = 0;4 Q, d( \% ^! H% {, @3 a- i
- dma_addr_t dmaphysdest1 = 0;
4 }7 J7 b! P9 c, o' D! M - dma_addr_t dmaphysdest2 = 0;
. c* f! s: X1 J) H4 z - $ c! d5 x. |, d( Q8 O7 q* l: U+ Q
- char *dmabufsrc1 = NULL;
% W" _% p2 O3 O" V - char *dmabufsrc2 = NULL;
/ \" x) L' p3 b; H2 G1 `, u1 W+ D - char *dmabufdest1 = NULL;/ R4 v3 \+ G* _7 U( V
- char *dmabufdest2 = NULL; s3 y5 d$ r+ [) A
+ y! Q' }1 ?. [3 e) I/ {8 X- ^2 X- static int acnt = 512;
6 ?5 y/ M5 g2 a( d* K - static int bcnt = 8; m# y7 W0 G7 U# _
- static int ccnt = 8;
. ]. R, t6 r: P: f. [! ~7 ?' s: B - 7 s' t( }1 N% t% p
- module_param(acnt, int, S_IRUGO);
G9 ~* D: a, W# f - module_param(bcnt, int, S_IRUGO);
5 P7 [0 R3 k; c( s5 j - module_param(ccnt, int, S_IRUGO);
复制代码
) g( r' ~ U0 F+ N9 ]$ U2 C3 e4 g! s6 r& E3 c( s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- E( \6 k; ?/ C3 S& N$ }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
Z c c! s6 w% v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 q% G# ?3 k9 c. H7 m! V: z7 w* f3 ]
$ z# ~! [. b" h4 _/ K! s1 b; U2 U* w. |3 X8 v
|
|