|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, L: C& @. ]/ f- [code]EDMA sample test application
, G) `5 ^) ?. y, H9 a - /*
/ e* N, @* s7 B/ Q# H. K - * edma_test.c
6 P& z& Z. ]# ^0 V1 b. F+ s - *
& f. z* v' X1 W+ ] - * brief EDMA3 Test Application3 u8 b$ o2 _7 n! b) D6 Y. W7 M
- *
" L- m s P0 V/ C - * This file contains EDMA3 Test code.
: p* y8 I, Q; U- O8 g" k# y$ B - *
8 e8 s4 t. {: S! K P* x, ]/ Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* g _: l' Z$ c/ r* S - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 Z B% ~' p( F5 |7 H' b0 ^ - * TO CHANGE.7 y* R3 J4 x0 [1 Q2 l. d* i
- * e. N! C8 W4 z' N: ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ c4 V; @ k1 e) X6 U
- *
+ `& l* x! |1 K) r- X - * This program is free software; you can redistribute it and/or% M5 Z7 ^# }/ r: u7 y' M
- * modify it under the terms of the GNU General Public License as# T3 k+ {( c5 ^7 R, U
- * published by the Free Software Foundation version 2.& r1 E. H1 k# a9 `/ p
- *; q- J% X! c0 J6 i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% }7 b1 n9 T/ `; ]8 } - * kind, whether express or implied; without even the implied warranty d' H5 Z* z" u, |; o( V! f: v- N ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 ~* m/ O/ X1 _* r) ?$ H
- * GNU General Public License for more details.
6 } G3 G0 ?* |0 c+ v5 O& e - */
- ^+ C; T% A, S# [, Y# o - ( Y+ L( l& G9 q9 n7 p
- #include <linux/module.h>* O/ @# m- q% G7 v
- #include <linux/init.h>0 i/ Z. s$ M1 C1 Y' n( K9 v
- #include <linux/errno.h>
. ~$ ^# M' P. q - #include <linux/types.h>: d3 d3 T2 Q5 h S
- #include <linux/interrupt.h>$ s% T% A0 L2 g) k" W
- #include <asm/io.h>
' N3 n4 Y4 L: c/ U4 S! j" S! H - #include <linux/moduleparam.h>& x9 D* `) y5 a+ S
- #include <linux/sysctl.h>6 j6 V: P7 h9 y- d
- #include <linux/mm.h>
3 D0 p4 R( ?) [4 l2 B" Y$ X - #include <linux/dma-mapping.h>
& K5 H9 z. E! P1 m4 N" \ - ( u* r! ~0 h* C5 V+ b
- #include <mach/memory.h>/ I' Z, A5 v# h: @0 ~; B
- #include <mach/hardware.h>& F1 F! ]9 a* J" @% `6 N
- #include <mach/irqs.h>: t& {2 j: E) E% e# G8 ]% g+ h5 M
- #include <asm/hardware/edma.h>
/ H9 _9 m/ j4 ?
, j; Z0 A! G4 M- #undef EDMA3_DEBUG
$ K% L% [6 D0 r, z, X - /*#define EDMA3_DEBUG*/
* z7 ]% y! B' P% R( h: P - 5 C+ e5 o9 o6 |8 Y8 x; t. _; u
- #ifdef EDMA3_DEBUG
9 u) l6 A% m4 x: F. L: s5 x2 { - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% `! u9 {5 T) ?7 E
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), g$ \* c; X, }7 \6 j0 C
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) y$ A5 r6 H3 T6 k& x* Y5 u7 W" S; |
- #else
* g1 }: V0 J7 J, l1 G8 O - #define DMA_PRINTK( x... )
4 X; ^; c1 l0 P" s8 X7 x: M) v - #define DMA_FN_IN& g9 B; z4 i1 A5 r0 D
- #define DMA_FN_OUT% U! P6 r6 P1 b5 R- J' V( P( i
- #endif1 ]% [- h" X1 p$ s/ H
- ; L- x( e0 [4 m/ p w8 p
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& a F5 J% @+ N% y
- #define STATIC_SHIFT 3
5 o& t. x3 h9 E - #define TCINTEN_SHIFT 20
% e# Q7 j# h$ z0 a - #define ITCINTEN_SHIFT 21
8 o( K/ |* d& L' m6 ?7 R( j9 k1 _ - #define TCCHEN_SHIFT 221 X$ y, ?8 P6 Z! f
- #define ITCCHEN_SHIFT 23# r8 l! j% C! w
- b4 @4 {7 b8 n# j( Z! {- static volatile int irqraised1 = 0;) W. ]* |4 l9 D; G8 w* V7 i
- static volatile int irqraised2 = 0;
* v* a( c; {! t& o; f6 u- Q: B' z9 F
# } ?) [6 J C& f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; u" p0 z" J9 x0 U! Z- H% u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; X, O! f, b1 M, U& ?
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 e6 V4 M# U) O x( G( J# \3 A" _
' r+ O) d# r8 i) Y& K7 ?( x- dma_addr_t dmaphyssrc1 = 0;
2 u+ O" Z; N' h4 B - dma_addr_t dmaphyssrc2 = 0;
4 O( I: C& ~8 G& h - dma_addr_t dmaphysdest1 = 0;# d/ S/ q5 N4 P" F y% |
- dma_addr_t dmaphysdest2 = 0;
. G* s4 b* A6 ?* q/ r - 2 e8 J9 f" Y0 a( u, v
- char *dmabufsrc1 = NULL;
4 X2 w: M8 v, ~& p+ S - char *dmabufsrc2 = NULL;
) s9 Y o+ D9 s9 M1 f+ B - char *dmabufdest1 = NULL;6 S0 l) n. t8 \: ]! d
- char *dmabufdest2 = NULL;
- [) v9 z* s- P9 g
" J' y9 ^) g& J% Q% y; j- static int acnt = 512;
; a5 x2 `* x2 {( T8 z* T9 C, w - static int bcnt = 8;1 b) }; Y' z) E! \9 N- A
- static int ccnt = 8;: d: g' \% ^' i7 }; H- E2 a* s
- 4 ^: A3 n1 b( r# X' B6 i
- module_param(acnt, int, S_IRUGO);
1 Z" S% [8 `: R6 ~% v5 |5 Y# L - module_param(bcnt, int, S_IRUGO);: Y% ], E. _/ l' [, ~4 Z
- module_param(ccnt, int, S_IRUGO);
复制代码 2 r+ q6 f6 L$ u: e4 }
+ g2 H5 w0 }6 \ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! Z8 j$ @: ~0 T L& e% ]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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 q2 M5 e% F0 ^2 E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ R5 ^$ F) S; }8 Q: A. C' i8 \% {* u2 [! U, ?6 M
' j% ?( `8 w! l, |. {' s |
|