|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 l2 t6 Y' a$ S: F
- [code]EDMA sample test application" M) j+ [! F5 D& w. ^
- /*
# y! n1 m' a# O5 g, |( p - * edma_test.c9 h$ M& J5 C" C) r
- */ F, g1 `. c+ V" Z; h
- * brief EDMA3 Test Application, P1 [: b1 S% u& L7 S+ T' |
- *) h2 o4 `' c1 n9 q1 c2 b
- * This file contains EDMA3 Test code.! s3 F& ]& i6 [3 L
- *( F, g5 J3 K2 @3 a4 H
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 ? j9 n0 ^' l( N6 h) Y) a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' o, U6 x( _3 x8 L6 N1 M
- * TO CHANGE.6 b$ Z, ?$ ~" `% P" [4 l0 A" h
- */ p$ P" a1 @, M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 z, {' T7 @0 U" F8 B+ Y7 p - *& {: s8 t7 v, N5 K: S7 A+ M3 V* E
- * This program is free software; you can redistribute it and/or
. z; V: b* m) b b2 w - * modify it under the terms of the GNU General Public License as5 B n9 |# u6 f& t' ?$ L
- * published by the Free Software Foundation version 2.
. I8 W' m* o. ^6 U5 z - *) m/ i% I ?# \" {7 ?0 q6 x
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. y5 l5 y$ G- X1 n - * kind, whether express or implied; without even the implied warranty
1 |8 }& i1 r" I+ ~5 z" H o - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ z1 r. W" H* @/ s+ q8 I7 k* I
- * GNU General Public License for more details.2 ]* Z! {/ b5 ]8 ?* c; @
- */
& ~9 r& @3 C8 a6 P- O1 a# J - B: p1 m: x' r7 P, \! C( D. |
- #include <linux/module.h>: b! h6 v' K: p* F
- #include <linux/init.h>% p! J& V) r6 M5 N5 z0 ^
- #include <linux/errno.h>
3 P2 T: L7 _: n$ q# Q" o3 K - #include <linux/types.h>
) q' Z+ w" l! V! U' g( D - #include <linux/interrupt.h>2 P$ C- ~; T% r' a7 H9 ?
- #include <asm/io.h>
. b7 ~0 e7 D3 i& R - #include <linux/moduleparam.h>; H' m* I' Y3 y( Q) H
- #include <linux/sysctl.h>3 M- t i+ w! ^- H1 |' c3 u0 H
- #include <linux/mm.h>' a! i" B5 | m8 S, R% r
- #include <linux/dma-mapping.h>
+ x" u( I l$ i3 w6 H* |$ B
) G T7 M# P' H s1 I: Y. Q2 i. H- #include <mach/memory.h>& W& ^/ g3 t" q, P
- #include <mach/hardware.h>" O( ^: G- }& Z
- #include <mach/irqs.h>
* L, L4 a$ b& o- B$ t - #include <asm/hardware/edma.h>
) t; y5 P" \% Z2 V8 D
7 ]8 ?9 ~" ]1 ^0 V% c* Y- #undef EDMA3_DEBUG
+ r" O3 F, `7 U5 Q - /*#define EDMA3_DEBUG*/3 P% \9 v, o0 E! O$ E9 a
- 6 I% h8 e& h; F$ @6 A. O
- #ifdef EDMA3_DEBUG% ]8 U' ^! e# e2 M
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* b: [. N! E# H# V$ E4 v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 m7 z" R5 t( B B5 N0 |
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' R3 }$ s; f1 @6 O# d
- #else% ]) n' R7 w9 X. a: i! K/ h6 A" F
- #define DMA_PRINTK( x... )7 N( T0 f, d8 o% [( A% g( V
- #define DMA_FN_IN
9 Y6 i- D/ @* d, ?0 e - #define DMA_FN_OUT
8 f$ @ f, _4 Z( ], ?. `3 G - #endif
0 W; `8 d' x0 n6 A& F. L3 @; h: A
7 m% y2 U1 ]) _7 J# |& y8 _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% s- S* o& G2 Q9 |+ t Q' T - #define STATIC_SHIFT 3: i6 B. _' V+ z: F$ u; P+ l4 N |
- #define TCINTEN_SHIFT 20/ J* }3 ^+ N8 s
- #define ITCINTEN_SHIFT 21
! A/ q7 @) j# L2 j5 p4 I - #define TCCHEN_SHIFT 22
6 O4 }& j0 O# d+ T$ _4 w6 B - #define ITCCHEN_SHIFT 23
2 T# T( v# Y! ^7 Q1 r1 Z - - ]3 n1 w8 E7 `
- static volatile int irqraised1 = 0;
% z t6 F- l: a, B K - static volatile int irqraised2 = 0;
" `4 _4 T% H* e) |' V. g
* _3 V4 `1 i9 {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. B! E @* W8 | - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. d+ b+ H( H* d* |8 K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 J! W6 N" J0 ^1 @: I
, B8 H1 Q$ t" h- dma_addr_t dmaphyssrc1 = 0;; @3 Z% J7 @9 A. j6 ~
- dma_addr_t dmaphyssrc2 = 0;
$ N5 Q! N2 L w$ h - dma_addr_t dmaphysdest1 = 0;8 n9 g+ w* J. r& @ d+ J
- dma_addr_t dmaphysdest2 = 0;
; Q% P5 {8 h o7 ]5 A4 K$ t
( L5 {6 | Z$ e! R9 t# z- char *dmabufsrc1 = NULL;
, C9 |7 I7 g7 V! O - char *dmabufsrc2 = NULL;
: |+ @7 h k5 }8 ~& H9 c - char *dmabufdest1 = NULL;
& }, g$ b7 I5 O - char *dmabufdest2 = NULL;( r, S+ h" p! F: I y* N% L& e
- ! N1 d, ^/ i/ {( \4 Z
- static int acnt = 512;
" w n# R" ~: \% l* d# Y8 [8 V2 a. V - static int bcnt = 8;
1 g+ c3 g) M" U% ]! \3 F - static int ccnt = 8;) k" w; R. C% T7 j
, c0 c+ _# _* a. h" ]) t8 X0 d& r- module_param(acnt, int, S_IRUGO);
' n9 o) @' T2 |% A; ?$ ] - module_param(bcnt, int, S_IRUGO);
* v0 L! b# _! }, Z' l - module_param(ccnt, int, S_IRUGO);
复制代码
" W6 q+ v: d; ^, }' T E
6 ^( e+ O, Y/ B) x& f" N 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 X& p& J+ L5 R s% }3 a+ _' J: b. Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) e4 q! a: C2 I8 T2 U 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( S u/ _! a) u: U$ b, f0 j2 t
) k+ V. M, w: o9 P' Q
" f3 o9 f5 s7 C0 L/ A
|
|