|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) w6 W% R5 V( N( S$ z- [code]EDMA sample test application
* [6 t9 G, D2 p! r! \ - /*8 N R) R9 N/ c
- * edma_test.c' o& r+ }: Z+ L' C
- *
, C6 [3 L' A3 U! i) V, \ - * brief EDMA3 Test Application
0 @0 H3 s1 _" t6 T0 r3 f - *7 c: \+ _1 l8 b8 Z1 n
- * This file contains EDMA3 Test code.% t; a' S8 p( H- g. t( q9 G6 \, Y
- *
# K/ q* s/ T1 ^0 N9 @9 v+ D - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ u* m. u0 ~& f7 A! s+ i
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 b) U$ V, d% ]5 T9 z; z3 I
- * TO CHANGE.; k& p9 A4 x) ?
- *
! u- p$ t: H, `8 b - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ ?" p' Q1 H; w: d, s$ |1 T% k - *
- {1 c; h, w6 i# x2 }9 g - * This program is free software; you can redistribute it and/or% c p# j9 S; {; {+ o! r
- * modify it under the terms of the GNU General Public License as- V" i5 v' b7 {9 e) y3 Y
- * published by the Free Software Foundation version 2.
8 J5 v; A; x# ]. `/ h& m) {+ ] - *" }/ n( T7 A2 _- ~
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' f4 V/ M& t2 W" B% l4 o; H - * kind, whether express or implied; without even the implied warranty- r9 G: X7 d: E& ]8 ]+ E6 X
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 \+ X% ?' }2 J2 `% x' B
- * GNU General Public License for more details.
8 t( n: q3 ?1 G) P+ }/ \, q - */9 P0 h; _' C3 ?
- / R, u5 U5 ]7 g
- #include <linux/module.h>
0 Q- I# q* q, p6 M - #include <linux/init.h>
" c' [( Q5 d9 e. [" M( k - #include <linux/errno.h>! }- L, s2 u9 h9 p! D5 g
- #include <linux/types.h>
2 v1 p' q% Z5 W% C4 H$ k - #include <linux/interrupt.h>
k2 Q5 Y% b2 C) E, n9 I- L - #include <asm/io.h>" o3 @( D: D5 L, s# ~8 |
- #include <linux/moduleparam.h>
7 [4 K7 v/ M( i% V - #include <linux/sysctl.h>( q' r: c. Z* B/ N$ K {, H
- #include <linux/mm.h>
1 G, _$ U# ], h3 e3 m+ X$ k - #include <linux/dma-mapping.h>
/ c. \' ?; ~0 t3 b5 ]
& @0 A% a9 y) X" T. S# h' z7 A- #include <mach/memory.h>- ~8 J3 z* o; ?+ S) Y: T
- #include <mach/hardware.h>
8 }+ \5 p" ~, `. k8 I, C7 ~+ a - #include <mach/irqs.h>
9 F+ ]! q0 n8 z" q) n/ W - #include <asm/hardware/edma.h>& a. {+ I, Q. y$ r& V
! s5 z% S/ C: ~- c9 i; W6 G2 e, z- #undef EDMA3_DEBUG
9 g- y5 q6 f) Z - /*#define EDMA3_DEBUG*/+ V7 k2 {( A' ]! i' @2 Q& f
- : f" P/ A* H- p$ l8 k% C
- #ifdef EDMA3_DEBUG
# B9 Y0 }' k' j2 X& Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 \* {( i8 w ]1 B; m* e* q# O# x) d, K! y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' e$ c2 z2 T* G9 q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* i$ s' |" P$ \) _" }3 p5 ^
- #else
s8 R. X( \8 Q" a; Q - #define DMA_PRINTK( x... )
/ A+ {( U/ s& H: {% g" `; k - #define DMA_FN_IN
9 h- |% S! D) }# o' |. z4 ` - #define DMA_FN_OUT
' t- h6 I# s' Z - #endif: @9 M5 p4 h; c, }
- 7 J! m9 w' O/ b p5 y# U0 D
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. k3 G3 l' H, M. S$ |: E$ r - #define STATIC_SHIFT 3
& e* x% _# n- c0 T; y @) T8 T% U - #define TCINTEN_SHIFT 20
( r* K/ L' }3 w6 V1 l - #define ITCINTEN_SHIFT 21
. o4 w2 J3 n3 f* Z% S+ f0 M* | - #define TCCHEN_SHIFT 22
" @* m H, g/ U4 N" b - #define ITCCHEN_SHIFT 231 x5 S2 m" M7 b; O3 S
- % g( Z& w- Q2 z
- static volatile int irqraised1 = 0;% m' [! t! `2 I
- static volatile int irqraised2 = 0;5 I' k' S# f+ I3 {
( e# {& ^( W9 m3 b/ B" E( r T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); I K9 A7 M, i0 H* r& n9 v9 ?1 U
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" ~- Y, [% S/ f/ i$ D+ g" v" @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 d1 ]2 q1 X" D! Q5 O5 l9 o - ! y0 S7 o8 c+ B) M" a
- dma_addr_t dmaphyssrc1 = 0;
( M/ X/ T5 V& M. K+ g2 ~! D - dma_addr_t dmaphyssrc2 = 0;" P% L6 @' w' G! m4 T
- dma_addr_t dmaphysdest1 = 0;. J% L8 c$ v- R4 o* R- o
- dma_addr_t dmaphysdest2 = 0;
. e# s. V) i q( f2 y: s4 o
0 ^8 ]+ \* k0 _- char *dmabufsrc1 = NULL;
: C- U/ I. L0 _9 ` - char *dmabufsrc2 = NULL;" W: l6 @+ X9 K! P# N1 G+ O) ?
- char *dmabufdest1 = NULL;, @8 _, X$ q' S9 ?" ]' w
- char *dmabufdest2 = NULL;
. [# k+ K/ ]* H: A3 {2 N - - w( c, g; l! o0 h
- static int acnt = 512;5 u* d Z8 H7 Z9 o! k
- static int bcnt = 8;
9 r& M) k& p1 y! q, C - static int ccnt = 8;
$ Z, b/ \3 P) U - # o% F1 ^0 E# T" R" k6 |/ R; x
- module_param(acnt, int, S_IRUGO);
. \ O" b1 n/ q7 z - module_param(bcnt, int, S_IRUGO);1 \$ H( ^- N$ I. F, h4 \
- module_param(ccnt, int, S_IRUGO);
复制代码 8 Z% ~4 {' g- R, {: f9 Q, n
7 e& ?& X2 m) Y/ y- ?' \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, `9 l3 v. W5 m0 {/ q( Rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' `$ Y+ \: A% J7 @* R: x* `2 a$ h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" l# V6 p ~2 {5 t# n4 ^
7 W- x+ B. a' M3 H6 |! L, r% X* g
# c/ e5 @4 H6 f& |0 o |
|