|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- L1 C7 c! I, {8 z3 L$ @' j- [code]EDMA sample test application
, t# L; N2 i; n3 H% ^( S - /*" `% D! f5 x# {7 j4 Z4 R# ]. g: q
- * edma_test.c- M' U- b) C! R- L$ c5 t: G1 G
- *
3 G& n. W2 E- p - * brief EDMA3 Test Application
5 @5 G" i; X. h" q9 _ - *: [% r! u+ D4 i2 Q q
- * This file contains EDMA3 Test code.
6 a- {/ ~9 d5 U, M& C# H - *) ]2 [- O2 M( q# s1 M; T1 A& ^
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( e6 S* N; D1 o5 d& @: r3 l - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 c. h2 O- e# m) {# e - * TO CHANGE." ~" ^. U. z; I" A0 i J
- *
. |. O4 r: H- ~9 r" Y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// P: U' H' F2 s' _( l( \% \
- *, k+ f, s: }) f5 n3 O" w0 ^
- * This program is free software; you can redistribute it and/or
C0 K, b- Z& K - * modify it under the terms of the GNU General Public License as& c3 h. c6 D h2 j. u
- * published by the Free Software Foundation version 2.
5 j9 T9 n X' S0 f - *3 p) F. Z# x6 ?) Q) G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ U5 B( @; I" ] {
- * kind, whether express or implied; without even the implied warranty+ g7 Q% V8 H/ l9 h/ g2 s+ T
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& ?3 |; g; N6 r% s, | - * GNU General Public License for more details.; o4 |1 a/ a0 c* I0 e |$ |
- */$ K9 \; d+ s5 s$ ?7 i( v3 d& c
3 J8 a; I6 r& m& \* m$ D- #include <linux/module.h>( w. }9 I* b( g: Q! E
- #include <linux/init.h>
# K* f2 ~0 S- C! O! z+ z5 C - #include <linux/errno.h>: L; C; P* U* k- [" M
- #include <linux/types.h>
# C. L- K5 `, w0 h# z - #include <linux/interrupt.h>
( |: r8 r! `! o8 @ - #include <asm/io.h>
+ R: Z! L5 V* f, J( u; O+ j. B - #include <linux/moduleparam.h>
% a+ I, ~9 h4 g. m - #include <linux/sysctl.h>
7 V: N; Z2 O, F- V' F) m1 X - #include <linux/mm.h>9 j; t1 n- ? z
- #include <linux/dma-mapping.h>" n3 H' r5 F& d! X R
7 |$ Y: b6 E+ M) `- #include <mach/memory.h>
8 P: {: h! ~% w% P - #include <mach/hardware.h>
1 \3 p* |9 o; I& I4 B% h6 ` - #include <mach/irqs.h>
l+ b, I' K/ K* G v% n* i - #include <asm/hardware/edma.h>( p3 C# C+ X9 }3 [7 q3 d! e
- * Q* V0 F" U. o0 g9 E6 o# A5 d* Y
- #undef EDMA3_DEBUG$ I A. o$ d; B$ v% U: l9 L
- /*#define EDMA3_DEBUG*/6 P( Z7 z! p0 H4 t; m/ [/ j
- % y. y4 M; Q+ o$ J3 C2 c4 H
- #ifdef EDMA3_DEBUG4 b$ `: u0 r/ ^' S- q% p) Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 Z1 t4 L4 }6 _. M: G% ]1 v1 {) X& k
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: I; j) S6 H M, O+ F - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! Z! i1 `% T C$ P. ~6 C4 s4 w - #else
2 c+ Z9 T; F* W) N! p - #define DMA_PRINTK( x... )
) ~( a. U( Y/ R$ G v) z - #define DMA_FN_IN
: U5 ~- K& S) q u' ]. R; \) U - #define DMA_FN_OUT
% S4 b$ b0 k# \! }! Z2 [; k3 }" F - #endif
; o# p9 w* ~$ Z: {
/ J% f8 R2 t& T1 }2 G- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ M4 y k2 O& j# v, v - #define STATIC_SHIFT 3( L1 O: P6 q; d+ G- o% |! K) j
- #define TCINTEN_SHIFT 20: u: T# u$ t' Z# ]+ M9 o6 N
- #define ITCINTEN_SHIFT 21
% `( ?3 I" k+ n* V2 u4 v - #define TCCHEN_SHIFT 22
~ p2 V. o. `; {4 f- h! \ - #define ITCCHEN_SHIFT 235 t2 f* P9 M! a8 J3 p, X( s
* m$ f( Y2 x! G9 D7 x$ x- static volatile int irqraised1 = 0;
# f8 J( R$ z* W# ~ - static volatile int irqraised2 = 0;
6 A: _) E Q0 W( G. h - 5 c" X/ T* M3 F8 J" A: f0 z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 t) J" F8 h6 W) P3 S
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 J% d# L; a& x$ X2 F/ X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 P* s: ?# \" X% P
- * R' F: ]0 Q; U
- dma_addr_t dmaphyssrc1 = 0;" [$ y" v! H) T- K. ~. c4 m
- dma_addr_t dmaphyssrc2 = 0;
. P1 A N3 ]% F( u; U - dma_addr_t dmaphysdest1 = 0;
; z* M! ]# |; H. I7 D - dma_addr_t dmaphysdest2 = 0;+ m3 n! U& z2 s+ d. c
- 3 M% w6 Y& A# W9 A' S- v4 ]# w
- char *dmabufsrc1 = NULL;
4 i+ o7 r3 T; `: P - char *dmabufsrc2 = NULL;9 J8 s0 r3 |1 X! Q
- char *dmabufdest1 = NULL;8 h2 c* j% d7 D( r C
- char *dmabufdest2 = NULL;& v) @+ c" A) S6 l
# ]& Y1 f) Y) p# o- t- static int acnt = 512;+ e# U; Y* H) p# {
- static int bcnt = 8;
/ X2 i3 v. i, |- X9 A7 X% H - static int ccnt = 8;- a& e" H1 T6 d; O% M( [
- / f! r$ R: f* F( L3 f6 F d
- module_param(acnt, int, S_IRUGO);
( Y7 q7 i1 [6 d1 n+ p& a8 j - module_param(bcnt, int, S_IRUGO);/ H5 c; H6 b% `. `. r* Y- D
- module_param(ccnt, int, S_IRUGO);
复制代码 * ~+ {/ v$ v5 y8 d4 G: a, K
0 n' v! P7 J/ H7 x
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 \; z( A+ u. i1 r( s/ P+ f/ harm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# p3 u0 e/ |$ G8 U- D1 L, ~2 j j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 z" M% }3 Z5 N2 j0 M6 ]6 m$ b. H5 n: m( W. E; {2 h
1 _4 i$ x: Y/ c* x: a1 A1 w
|
|