|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ N1 }4 ~" f& l4 \0 C- [code]EDMA sample test application. [- m, a- X2 ?! e) Z- P
- /*
/ ~3 v, d6 t# h8 W" q5 f - * edma_test.c5 e+ |$ {5 F0 T0 N3 u; Z
- *
$ T; ]8 m/ R3 b( K2 P# C) ~ - * brief EDMA3 Test Application
- G+ w4 M f1 c- l, \+ f% A - *8 O1 i3 j* K: R! L" R$ Y8 T9 V* [
- * This file contains EDMA3 Test code.$ c) a4 B5 V3 O# G! S
- *# j* X7 a, P& j( h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE c! S9 J4 U+ o! u7 M
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ |& t2 p3 |% j: F& \
- * TO CHANGE.
+ L1 ?2 x9 I& r* N) T/ O" {5 O - */ Z: d1 I! G4 ?. V2 n
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& d A0 ^5 L4 ?% L
- *
4 F7 [, S& N; \, I - * This program is free software; you can redistribute it and/or4 K1 k5 p' V- [: A6 I7 e8 z" i* g9 t
- * modify it under the terms of the GNU General Public License as3 O" V, J0 c& |+ _) w) w" Y* f3 `
- * published by the Free Software Foundation version 2.
' L ]. S. E8 q - *0 [/ y3 m7 d) z2 i- U8 A# ]
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 M8 b( ?, l6 r/ Y$ [+ S - * kind, whether express or implied; without even the implied warranty
6 h0 q' R3 n. N- i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 g" q2 M- y4 S$ I, n+ y5 a" z - * GNU General Public License for more details.
+ I! n1 ~8 B5 G# Q/ {, K - */
) t. Z3 a+ f) K
m" l! _+ W" O+ x' x* F- b- #include <linux/module.h>) s" I/ H/ R* T
- #include <linux/init.h>
( D- k+ n+ S' y - #include <linux/errno.h>
0 A# p- H6 y' i - #include <linux/types.h>; l5 S( Y, n7 W7 v$ j9 a* u: r
- #include <linux/interrupt.h>
; ^3 _2 K0 S- D - #include <asm/io.h>" e8 W, `# F" L8 y l' t t4 P( M3 K
- #include <linux/moduleparam.h>& F( w* u3 f$ }5 K9 `1 x3 n
- #include <linux/sysctl.h>
9 ^3 Z7 X2 [5 g0 O+ |3 [6 | - #include <linux/mm.h>5 S, b! [4 Y* B! R+ q0 _% e; E
- #include <linux/dma-mapping.h>
7 i& z& I5 n" n5 P - % L% D0 z3 J+ a
- #include <mach/memory.h>
5 I! ? p6 |# Y i, B - #include <mach/hardware.h>$ `+ ? { D- T# [2 m# Q
- #include <mach/irqs.h>
# P3 E8 I5 @- l, w* p+ F; g - #include <asm/hardware/edma.h>0 F/ l3 K! w7 T' o2 |! d
2 _6 [ Z- f$ E+ s* f8 F- #undef EDMA3_DEBUG
0 _, _6 \2 b$ y v5 C; \9 i" u/ [ - /*#define EDMA3_DEBUG*/
4 y) Q0 Y# I$ f - $ q$ n! m( ~; q1 ^/ l/ ]
- #ifdef EDMA3_DEBUG
2 D; l9 g; Y* ?3 f& v4 B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: w# ]) h4 g1 d3 ^) [9 p. P9 | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( o$ M7 v/ C6 h0 Y$ S* n6 r2 w
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 P, }$ T/ N8 G
- #else" ^$ \& T% @& F7 x
- #define DMA_PRINTK( x... )
& l- {) c& o" s: u$ I4 S1 A - #define DMA_FN_IN
6 V# O# T2 D1 l7 w3 V - #define DMA_FN_OUT
, I/ v9 u9 J4 E: d- K - #endif
5 E0 V; o' Q% f* T! [( R! @1 V9 [
0 k% \/ y, H- p; l8 {- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% |1 `& k8 o' g+ q! M - #define STATIC_SHIFT 39 J' q% F2 y3 g) K0 t
- #define TCINTEN_SHIFT 20
( ^0 J+ N& w, L$ d! c - #define ITCINTEN_SHIFT 21* G- m. Q9 U# l" |
- #define TCCHEN_SHIFT 22
4 f, r- u2 B% U* t& h# s - #define ITCCHEN_SHIFT 23
1 u" Q& t9 v7 S9 q - 6 G/ j3 U* }$ n
- static volatile int irqraised1 = 0; D5 E( T+ n* M
- static volatile int irqraised2 = 0;) A( w& s8 I# ^$ Q4 R
- . Z. o$ c/ }' m' X* P& }, A
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 w f/ o8 Z- m! p- T8 y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 T* ?# n5 @* K" y1 }4 I: g - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, e9 W, L: g( p
- 6 N# U/ m% @! Z Z9 V+ \! J
- dma_addr_t dmaphyssrc1 = 0;
% u' o9 ` x- y - dma_addr_t dmaphyssrc2 = 0;4 T' a: k' w N9 j% |" G/ s1 ~
- dma_addr_t dmaphysdest1 = 0;
7 _+ }' h& n0 k - dma_addr_t dmaphysdest2 = 0;
z- O- f0 e1 Z T - , o0 Y, T, P+ q2 Y7 `! k2 B
- char *dmabufsrc1 = NULL;
9 @( r/ S8 B. y/ q0 O - char *dmabufsrc2 = NULL;+ C \# a4 K" q" y, m
- char *dmabufdest1 = NULL;1 N: w. a- Z+ ?" ~& ^
- char *dmabufdest2 = NULL;- [9 r ?# h* P
- ) x& B6 S* N4 O0 B! i
- static int acnt = 512;
+ M z' q8 V0 @2 L - static int bcnt = 8;0 Z( m% t0 `9 Q ~5 D+ G
- static int ccnt = 8;' D. m! R+ x! `" d7 X
9 C7 i6 A# c" f' k% x- module_param(acnt, int, S_IRUGO);
2 y8 i6 M# q; B- J. q1 a- e - module_param(bcnt, int, S_IRUGO);
) R% R4 {* Y2 s! ~ - module_param(ccnt, int, S_IRUGO);
复制代码
6 J }9 s G: M# `1 ^, N, F' D) p( x- x& t- w
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 B" ~' v6 u# W1 G/ N4 D3 P; V, marm-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 a1 L4 Y* }* [8 o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, z, B7 j, ^' H1 \
8 l4 B& ?( y8 u. H1 y) \
, G0 @" w- r+ G- G4 O: X5 g2 I |
|