|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 g/ @7 k1 B7 _+ I# q2 @- [code]EDMA sample test application2 M3 x4 b8 V8 A" q
- /*4 `$ r9 D. [8 W* w# w6 a, M6 t
- * edma_test.c
% K. ~# l/ K/ n% V4 F - *( n! d3 p' {) l& f! g
- * brief EDMA3 Test Application- m& Z- R; v0 F9 X
- *! ]9 A! \2 [ {: y/ ~6 }# [
- * This file contains EDMA3 Test code.
~6 I# X9 N6 l: y - *
_# R$ Z8 }- u' ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 {( k9 H; Y# t. ~) u
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 r) ?9 E; O: J9 l6 E3 ?7 E8 b
- * TO CHANGE.
: _( h" j* I+ ]( t/ `7 P - *4 j7 {1 p; b7 e, G9 W% l, P( B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; U2 Q1 h& S( U" ?. [: U
- *! i, A; J" c- D$ j5 j7 ^% ]
- * This program is free software; you can redistribute it and/or
0 Z9 y* W! a R' K2 n# e( ?* y - * modify it under the terms of the GNU General Public License as$ j& U( s7 e8 f" _
- * published by the Free Software Foundation version 2." c8 }% k* _( b$ [& F9 P* p
- *
0 h# N9 h* a6 f F/ f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; a" w2 @. L, v4 \+ Y4 ]# v% J
- * kind, whether express or implied; without even the implied warranty
' q0 `& ]7 }9 H& l( E2 G3 Z - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- s( N& L' u* w4 F7 z: ? - * GNU General Public License for more details.
. E- _5 [1 w$ c" z - */* C/ G( T' L$ D9 M4 l
- , Z) F4 q6 k) j; D
- #include <linux/module.h>
9 |% m3 O7 V6 M9 C. @* _ - #include <linux/init.h>
3 [6 Y! X! T& P( q - #include <linux/errno.h>
* f* j# T- C& s4 x8 w: n/ d( D7 I - #include <linux/types.h>$ G4 p0 \: b) s2 W7 H6 }2 v
- #include <linux/interrupt.h>
$ f: y) a. I8 ]* f" L' s - #include <asm/io.h>
4 J2 X; m' Q' t - #include <linux/moduleparam.h>
+ Y6 {* q2 B3 G - #include <linux/sysctl.h>7 X3 n! k# d7 Z
- #include <linux/mm.h>" m, N- @; \" i k, L
- #include <linux/dma-mapping.h>" K% D0 G! ~& R+ [
- $ Y( u! {3 p: ?8 Q: ]6 g
- #include <mach/memory.h>! T- q2 T1 M3 {1 R" m
- #include <mach/hardware.h>) U4 f9 d8 ]; ^9 C4 s9 }3 U
- #include <mach/irqs.h>
; O% _1 l" ]* Q! {4 p - #include <asm/hardware/edma.h>
+ b# q- q% M: ^0 a+ X1 V/ |4 m; ^% a - % h" F% z1 M% T- c4 I% h$ m
- #undef EDMA3_DEBUG5 \9 T. S0 [( A9 Q
- /*#define EDMA3_DEBUG*/
+ _8 V4 D m1 x( r0 ]2 w" @+ n) a
- S, d5 p! `1 F2 {2 y- #ifdef EDMA3_DEBUG( C: z: f; d- H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
B, F; d3 U1 {7 h- I - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 @2 }# i w6 g/ L4 ]2 J
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 {* l, g; o! N* n - #else) }3 f, T' @# Z
- #define DMA_PRINTK( x... )
! Y1 d j& t6 _% D& j& H - #define DMA_FN_IN- k& H1 S+ Z0 a6 ~$ W/ c" v$ c
- #define DMA_FN_OUT
5 X# R# j: ?8 p3 B$ T+ H7 E - #endif
i" [1 W; S5 @5 Q) G - , `1 A f l7 v3 C# _7 P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). Z8 f0 D9 ^/ N8 q& A$ E- \
- #define STATIC_SHIFT 3
3 E" f& a' F/ x% } - #define TCINTEN_SHIFT 20" t& f% l: ^# I5 f& o7 q
- #define ITCINTEN_SHIFT 216 D; [/ q# s3 M: Y
- #define TCCHEN_SHIFT 226 d3 U# n( X. {$ @7 f! r7 w) y! J
- #define ITCCHEN_SHIFT 23# W$ F* z/ k3 O7 e+ o. P) X
- ) }/ h5 E. E; V1 g
- static volatile int irqraised1 = 0;
3 p+ [; i3 s2 y6 V4 f - static volatile int irqraised2 = 0;; A- e# l( K: u' V; b6 T5 c
- 6 N) r7 X: W2 f% C0 B7 J0 u; ?
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ S& W) l- _3 Q! O - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 C) ]5 T" D& z" W - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 c2 R' d+ N. s Y
- 4 q. l5 f5 V4 d1 {
- dma_addr_t dmaphyssrc1 = 0;
; R& J# C( C4 S+ F" |. d - dma_addr_t dmaphyssrc2 = 0;# C9 J( o; J6 e6 I" X: \
- dma_addr_t dmaphysdest1 = 0;
+ W# p6 _5 o& f2 |5 W4 p - dma_addr_t dmaphysdest2 = 0;
7 b# @: {) \1 \( f - 4 [( ]. D4 x @
- char *dmabufsrc1 = NULL;
" o) r! D! p9 @ - char *dmabufsrc2 = NULL;( O+ i: J) o$ v- r5 _8 N
- char *dmabufdest1 = NULL;
% t8 Z8 w8 u) d4 l9 s - char *dmabufdest2 = NULL;6 S- M9 N4 d; {9 q' ?3 P
* X! }# ^5 ~1 X( K- static int acnt = 512;
2 V2 F/ `4 u- Y9 c$ G - static int bcnt = 8;9 q! u1 o3 j8 K7 Y2 W
- static int ccnt = 8;
$ j: z% Z! p, J! H% y6 X
4 o7 Y/ Y, H2 S$ l2 t- module_param(acnt, int, S_IRUGO);
5 K8 S W2 `0 h8 j' l - module_param(bcnt, int, S_IRUGO);2 |& g% Q# Z0 Q6 t
- module_param(ccnt, int, S_IRUGO);
复制代码 & J, D; P2 }; w P7 F; t
' ^# x9 r; |: Q" ~2 J/ p! H6 ~6 J2 z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 ^( B" c" g) R$ b9 [3 marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) l3 M4 X- s& S9 x- Y4 F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; y5 Y B) M6 X0 u" `/ p, s% v
, l; }- g5 k" ^! y
( u9 w3 c2 A4 q+ b( ~$ P) j8 p, ^8 W |
|