|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# n/ l1 w x* q1 H9 I: B. [- [code]EDMA sample test application, k" X" K4 n% N& A: F/ B2 d
- /*4 g% |' S0 w! g5 B; n k0 p
- * edma_test.c
, S! r o5 t2 E9 I - *
% n( Y. u4 e& L- r& E. H5 _: r - * brief EDMA3 Test Application
0 D% h! w' e4 J/ V, h! k& u - *
! L, V& n8 U( s4 D+ ]) W) m, ~ - * This file contains EDMA3 Test code.: K+ }. c) T( ?+ b
- *
; J( A$ `: x/ |0 x* D8 a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ u ^! _% h& S' ~2 H/ V - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- y; b8 L0 Y0 S1 E$ b - * TO CHANGE.- i3 D# o- `. S% w, L% n
- *- N. k Q: y4 \3 |7 D2 b1 W
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, |$ q2 {4 A( z |6 H) O9 x" j1 h. @
- */ C$ p9 [* L, p* @" c; Q
- * This program is free software; you can redistribute it and/or
$ j+ `1 g0 K I - * modify it under the terms of the GNU General Public License as
' [0 H0 p* x/ Y$ Z0 [$ n - * published by the Free Software Foundation version 2.. @. m* d! F5 D0 g6 q8 s$ H
- *: `" v4 {. J& E# p6 l( W" t& ~# V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 r9 {; L% n+ t
- * kind, whether express or implied; without even the implied warranty
# M. w q' f8 }7 S% v - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ X; A/ A4 |+ i6 P& Q+ ` - * GNU General Public License for more details.% g; r/ u+ R7 u1 l8 J
- */
/ _+ M3 f$ n5 }' C, C
! W6 x- d4 [" C2 r1 g- ^: |- #include <linux/module.h>' v( G7 L+ i6 O
- #include <linux/init.h>; D1 }) [: |9 L; @
- #include <linux/errno.h>
9 s/ A% |+ ^3 W - #include <linux/types.h>
- A( B P% K5 N, \3 o& w - #include <linux/interrupt.h>
% b+ a! p5 W5 _ v+ X - #include <asm/io.h>8 |6 d ?+ {) W! \4 k% r
- #include <linux/moduleparam.h>
" N1 O! ^* @, e - #include <linux/sysctl.h>
9 f$ o% t+ F2 n `# M' u4 M) c - #include <linux/mm.h># p; @5 Z0 k7 Z. g
- #include <linux/dma-mapping.h>
& ]0 I3 `2 S) v1 v) U$ O - 7 ~' z# C% R) A3 w m4 O0 ?) f& d. ?
- #include <mach/memory.h>
% Z6 b `8 F7 e! L, L - #include <mach/hardware.h>
- _8 v2 m x1 w8 v/ }9 S) F - #include <mach/irqs.h>
7 b8 T* n$ u9 y - #include <asm/hardware/edma.h>
# H- T" X2 f) I/ x
0 z( x0 r) G" J" d- #undef EDMA3_DEBUG+ ]- v; a# V9 } h
- /*#define EDMA3_DEBUG*/' e1 p" B* Z% Y0 T; u
- ( X' I9 _1 E# P
- #ifdef EDMA3_DEBUG
3 t) D7 l4 s7 }: G1 a, y( o - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ q6 q) s: D/ F) s: D$ w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* G7 G' e6 ~% v7 ?7 t8 f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% |' ~- `" `; Q! y) U# \3 V/ R
- #else
% D6 E4 y9 Y, l2 M' t0 Z( h, S5 X - #define DMA_PRINTK( x... )
7 K. F6 k/ |* m - #define DMA_FN_IN
: M/ h& ^6 O4 e+ v3 \ z* C - #define DMA_FN_OUT1 j- N* k2 J. Z" {0 o, D/ }' t# f# P
- #endif$ Y4 I R2 P. O" u0 N
- 9 x1 x* j4 o$ K) E! I" r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, @& k' x% S- Y1 g, f( o' | - #define STATIC_SHIFT 3
9 Z+ |9 _+ r$ ~- ^( D A - #define TCINTEN_SHIFT 20" b/ q4 s% g/ @: Q5 V: p* _
- #define ITCINTEN_SHIFT 211 |4 n4 K- ]0 c% ?
- #define TCCHEN_SHIFT 22
# F) {, k/ o9 E* h" k4 D - #define ITCCHEN_SHIFT 234 \2 a3 u* C- {9 R
* s; _3 z- F1 G- static volatile int irqraised1 = 0;
4 P5 k9 o5 v+ U - static volatile int irqraised2 = 0;; V ]5 N J) W/ F) s
- 1 V7 v5 R4 A/ l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 z! ^3 i5 _) b* i - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; W2 T8 y% N8 Z# f& ~ x4 A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( k/ u% u9 ?5 ^2 T. v1 y+ r - 8 [* _: S8 u6 O+ H, v) ?/ K4 r
- dma_addr_t dmaphyssrc1 = 0;
6 g! T6 E% |- _$ B& {+ F7 \% N - dma_addr_t dmaphyssrc2 = 0;( ^+ O% s l u3 A
- dma_addr_t dmaphysdest1 = 0;3 K6 o W7 {% R+ ~+ ?5 c) i
- dma_addr_t dmaphysdest2 = 0;
; e) |1 h) t. K' f3 h6 S) e - 6 ~1 a% c2 ~6 q. v! A' [/ q
- char *dmabufsrc1 = NULL;
* m7 V& H( w3 G0 }& S; c5 q - char *dmabufsrc2 = NULL;
: `! f9 B$ d" y - char *dmabufdest1 = NULL;" |+ d0 G/ H0 b6 S$ e# t4 Y6 k
- char *dmabufdest2 = NULL;9 _' c9 h# c. F
- ( Z$ q' r7 @- @8 z$ ^7 P1 i. \ H
- static int acnt = 512; P! v: _: p' z
- static int bcnt = 8;
: f8 Z3 J8 X( o+ C7 {7 L - static int ccnt = 8;
5 l* _0 x. b& U6 h - 8 \* s5 N) |" K/ T" b- ~' a. b
- module_param(acnt, int, S_IRUGO);8 j1 b5 ~& T8 f$ H) }/ M/ P2 v! a. R" f
- module_param(bcnt, int, S_IRUGO);
& U' C! v( @' t* v7 M( E - module_param(ccnt, int, S_IRUGO);
复制代码 " W/ ?3 O9 E3 h( G! C( ^" L
4 p5 _ p2 y% I8 \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. {* ^* E4 |1 O" X9 warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 Z4 H+ t. u! D8 E+ Z' g) }
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 j* e# x; T0 `; E7 _! g" v' `! U3 e; z2 H, ]6 Q U
, J) {* V" K+ g2 C% T |
|