|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % z% H) P2 ]: ^2 L' v. V) O
- [code]EDMA sample test application
. P( D8 G% I0 p) b/ \9 g - /*$ [/ R( N3 r+ l+ u
- * edma_test.c* c3 d! H$ ^+ e0 N9 p Z9 i
- *" P0 n# e3 A( H' y; M4 F, b I1 k
- * brief EDMA3 Test Application( S$ S& p; l9 g [
- *4 |1 g) Z W1 w
- * This file contains EDMA3 Test code.
& m7 \4 t' h2 V - *
' ]$ _3 @$ O2 w1 J) Q, m" Z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% ~5 V9 F& F; _4 a- F( Q6 F* ?
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; A# m2 O8 G" I - * TO CHANGE. I+ V! [# ^6 h
- *
2 x2 s- _# n; I5 R- m, Y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" ]2 U$ R4 q5 k2 w
- *, G6 ?( w/ `' L5 N, U' ?: n0 Z
- * This program is free software; you can redistribute it and/or( P: Q0 V5 C: x* B% r! S) O
- * modify it under the terms of the GNU General Public License as
& [& i& ]2 h* C" G# d6 B: ] - * published by the Free Software Foundation version 2.
* S; B8 X. {& ^3 c4 c4 Y- q - *
' y5 T% N$ ~" Q- A, p" X' E - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 w$ p' N' T4 Z! E- O - * kind, whether express or implied; without even the implied warranty0 H+ f6 r$ h" R ?8 n/ ^8 f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 f9 d3 x* ^- |% J1 W - * GNU General Public License for more details.
3 N% Y3 ?4 j7 v* N6 _ - */4 g- i0 Y h; L, Q. M2 h o# Y0 F' v
8 X& H: W* @% @! g. S2 E. v! Q- #include <linux/module.h>
$ j" f# a- R; W - #include <linux/init.h>
7 @- }. c9 d7 I* s) F2 } - #include <linux/errno.h>
) @$ s$ u+ `7 C2 W6 m - #include <linux/types.h>& }" C, ~- |' j/ U) _# [7 z
- #include <linux/interrupt.h>7 U/ m4 D0 g. o# U8 q2 X
- #include <asm/io.h>
% ]1 m2 ?1 r& `! h: ~: t - #include <linux/moduleparam.h>3 P$ i+ O8 Q! H* O! ?" M; e; h7 k( u
- #include <linux/sysctl.h>
) c2 w, \' U, l3 }9 c! B - #include <linux/mm.h>8 l6 |4 t4 a& a0 E
- #include <linux/dma-mapping.h># S# N: [$ D+ M% T4 U+ l2 `. W O+ F
- 1 p+ D, t7 w, ^* O* R9 u- ]/ G
- #include <mach/memory.h>/ s! T+ g3 E; d- M/ R
- #include <mach/hardware.h>6 C" v$ t' d: z+ N; z) Y
- #include <mach/irqs.h>
& N# Q$ V/ M7 U2 p2 B - #include <asm/hardware/edma.h>" _$ z+ O1 h" O- _) o2 a# D
# C3 K' {/ R4 S* P$ g* c, g- #undef EDMA3_DEBUG; \# v5 }( y2 Q3 T- b$ g3 }
- /*#define EDMA3_DEBUG*/0 F8 v0 o0 z7 d2 b
# ~3 @) [: m) B% L- @- #ifdef EDMA3_DEBUG
- k' a& O. p0 A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 O+ y, K7 @7 `) ]- `' R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 a( r( _. B' T0 z$ }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* g/ X2 K+ e2 i7 D) U2 H. L - #else% T0 @* H( q' F( Z$ [& M2 X4 R
- #define DMA_PRINTK( x... )
! M6 K/ V, q5 B' S - #define DMA_FN_IN
7 ~! S& s: L# z+ Y, \ - #define DMA_FN_OUT
; f+ ]) \# m p; j - #endif b. E/ T9 v) ?. X
9 X6 B- j- R Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( Y; P3 D% Z# h; T
- #define STATIC_SHIFT 3
" U9 {8 g' Y- K+ N - #define TCINTEN_SHIFT 20 C G9 a$ l! S3 `
- #define ITCINTEN_SHIFT 218 x. ?7 V! B. Q. G* j( p$ t
- #define TCCHEN_SHIFT 224 ^4 m( }; P0 y8 Q
- #define ITCCHEN_SHIFT 23
; T0 X+ T" f7 O0 b" s5 A: f2 l: O4 R
z! t2 V+ t7 }$ Z6 ~- static volatile int irqraised1 = 0;5 |) L% C4 X. m( P0 B1 M$ I
- static volatile int irqraised2 = 0;! m& y3 A5 S- H
^& K/ }- x* z8 u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 z7 b+ J2 V! s8 {& T% I D' D& ^ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, g) G. O6 R3 R' k* m N8 Y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# O) [0 w, [/ s
1 @3 B; V( C4 ]. X- dma_addr_t dmaphyssrc1 = 0;
8 a9 ^9 e' a f5 f - dma_addr_t dmaphyssrc2 = 0;# u0 i7 z7 Q7 Z4 R
- dma_addr_t dmaphysdest1 = 0;
P: }0 U* ]) K* W) b( s8 ?2 \ - dma_addr_t dmaphysdest2 = 0;3 t, R& X0 e$ X7 t' I
# ?9 v* ^) O0 Y4 _1 ]9 d3 T. G- char *dmabufsrc1 = NULL;
1 q4 l; }4 I" v: U: [% S% [ - char *dmabufsrc2 = NULL;8 u: X" g0 u! K* B$ G( X
- char *dmabufdest1 = NULL;
9 `/ D; `4 V; g4 V: M - char *dmabufdest2 = NULL;
) n: Q/ \, Q3 ^- B* q9 Q1 y2 n$ j; | - l" S) ?* R- [4 m
- static int acnt = 512;7 o6 W& J4 T) z* y& {
- static int bcnt = 8;
' o9 R$ t8 X% R, |% y! z ] - static int ccnt = 8;6 P. r3 H6 R- X2 f9 @: R9 I" N r8 o
% @4 t1 y+ d1 z+ P k- module_param(acnt, int, S_IRUGO);7 z# c% C; s/ t# j: u
- module_param(bcnt, int, S_IRUGO);3 L. U5 l! n* e" L, D6 T' h& O- E
- module_param(ccnt, int, S_IRUGO);
复制代码 " T. c# `2 j6 f/ Y
8 f, |1 |/ b% S) W' ` 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 x) n! [! F8 B, r5 \" t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ u7 S0 E; {' Z% g) E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( W7 ~$ g: @$ M' P4 h$ `, }% x- F
3 W W p& M2 D' \! E3 O& a
+ S% d, o, _$ r |
|