|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 z1 V- J5 T8 q- G7 A. O8 o
- [code]EDMA sample test application
' C& p2 Z8 n5 ?, c - /*5 `% _; X1 ^$ o: ^4 ~. |. e
- * edma_test.c
* B' |% A2 u' U8 @" F( d - *+ |1 Q1 z( Z' T/ a- T. H
- * brief EDMA3 Test Application
* y; z% k1 `( l) k9 x5 ` - *
, V+ u$ o) Y [# ^ - * This file contains EDMA3 Test code.
( ?7 y/ a6 E' A - *
! Z, T% N# y& { - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- g4 r5 D: o- }1 B - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
J, g0 X/ n( R- \" l - * TO CHANGE.
1 B, |7 q2 K: A& G - *
" O6 g, D5 K! V - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' |* c0 v" s) n - *
, C1 U. T3 Q& g! z4 t: q: w - * This program is free software; you can redistribute it and/or
8 X: S1 p6 q9 U% f+ C/ ` - * modify it under the terms of the GNU General Public License as2 i, z/ _$ b# ?; W) P* l: E* |
- * published by the Free Software Foundation version 2.8 v, E m1 e r0 M0 N
- * S- B. b, k2 t6 u' U4 l
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- W" i; n. ~* s5 a$ b
- * kind, whether express or implied; without even the implied warranty
3 `! j+ w7 E U7 N8 s0 N/ O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 `/ W' { n, v& l
- * GNU General Public License for more details.
% E! e+ K, C4 f. B# v) m - */
% c3 S, D# n5 L% w8 a/ W
! |: P& N4 G: m- #include <linux/module.h>4 ?$ C9 K& h8 k
- #include <linux/init.h>0 a+ B/ b8 F0 f. _4 a
- #include <linux/errno.h>
5 M4 D9 B2 }- w, q S - #include <linux/types.h>2 W+ x; d7 Q C" c1 C
- #include <linux/interrupt.h>+ S M0 O7 I& M2 E0 _. e
- #include <asm/io.h>
1 l' ]0 F' D1 a ^! a; L6 X - #include <linux/moduleparam.h>
: A' _" n2 H9 \* y - #include <linux/sysctl.h>
* i6 ?, q) y5 c' h" j2 z8 E - #include <linux/mm.h>
; v! I+ T3 J, {; L# _- d - #include <linux/dma-mapping.h>
$ V. N" l2 Y- |" @3 T2 f! o. c - _ ~" D/ R! U& F8 g- \/ G
- #include <mach/memory.h>
0 V1 n! @- _ o+ m2 i# _1 ]8 y! f - #include <mach/hardware.h>" v3 S4 A4 @, r. X% U; |
- #include <mach/irqs.h>
! ^5 ^ l7 y1 d) ?" H5 c - #include <asm/hardware/edma.h>* v) w' a( _5 l% j- x# G! h3 S
- 1 k* s9 X# t* n# t* E
- #undef EDMA3_DEBUG. }6 z" t8 k! R! k% i8 l
- /*#define EDMA3_DEBUG*/3 e: f+ h. L- E$ r
- , d3 _' S5 ?" H( c' n" ?7 b
- #ifdef EDMA3_DEBUG4 p& Q1 l' O( [9 x3 Y+ G5 r
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! [* q$ a) ~' q4 R1 g+ k" D$ u - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 L- h4 r3 T! U2 C$ ?3 y0 S: Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 d- _+ K: e ~
- #else# z* w( b6 {3 t5 V5 W
- #define DMA_PRINTK( x... )
/ i5 ], u6 J/ p4 f" X! h - #define DMA_FN_IN
% A1 j5 W' @8 D" O5 v - #define DMA_FN_OUT
* Q# ~9 r$ Y w& k% J( C5 M - #endif+ `6 e5 {. W* n! `9 _
4 y- z8 r9 {; S- i7 M: x- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 F/ {' F. n0 Q: {
- #define STATIC_SHIFT 3. e5 M0 K1 S3 q
- #define TCINTEN_SHIFT 20
9 F; R6 F1 H2 P2 z - #define ITCINTEN_SHIFT 21* Y" F. Q2 C9 l" b( g0 F8 u
- #define TCCHEN_SHIFT 228 [1 c& o# K* s( S1 J8 x; }
- #define ITCCHEN_SHIFT 234 A7 N3 L% l9 n" F/ P
- , i Q, |% S/ l3 d, Q9 g0 R
- static volatile int irqraised1 = 0;) H/ b. {5 r7 x% F0 `. Q
- static volatile int irqraised2 = 0;
4 p$ S, E1 [9 }8 h- E
# V3 P: `7 l: [/ L# E* N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- N4 l8 \. ~) n5 U8 H& L
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% w6 w. R0 i5 R! k5 }9 s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' W) V _% n/ i - + ~, z4 M6 e- i- T
- dma_addr_t dmaphyssrc1 = 0;
; M: b+ a- z, M: K7 e1 H - dma_addr_t dmaphyssrc2 = 0;. p8 L1 Z+ |; }4 O H+ N
- dma_addr_t dmaphysdest1 = 0;7 {) P5 p5 j4 t9 p" m1 l# K6 V
- dma_addr_t dmaphysdest2 = 0;
* Z! p T* H; U) p - - ]& Q8 V9 n- X
- char *dmabufsrc1 = NULL;
$ C4 \+ S. X5 g$ p; k) z" \ - char *dmabufsrc2 = NULL;
) L3 e5 i, ~' L% l1 E - char *dmabufdest1 = NULL;9 Y& t* a& \9 a8 `7 U! c2 ?
- char *dmabufdest2 = NULL;, b% Q: v" r3 J! _; I+ [
- 2 e8 g" b) x2 q9 K3 @
- static int acnt = 512;+ }! s8 @8 t- d3 q/ Y
- static int bcnt = 8;4 P' R0 Q& u: C
- static int ccnt = 8;
( Y, j1 J3 f- h# {3 w$ c
1 M- `" P( | R" _, e# l- module_param(acnt, int, S_IRUGO);
5 z( M5 m' c) ], b. _% }. s - module_param(bcnt, int, S_IRUGO);
# P' X" |$ q8 ^- G# x- n - module_param(ccnt, int, S_IRUGO);
复制代码 w- O6 r# h" _1 }
; ]5 m. s( _3 K 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 T- M( @$ r: `* K; T/ c$ ^) narm-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 _( S* n# {3 b, ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! L( Q, b. C, m! W' {! F( Z& _# ~$ b; s4 t2 j$ J3 U% _
; U" P$ p* d0 q2 \ |
|