|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, J& `' d1 p+ z- [code]EDMA sample test application
. g3 }5 p t6 A2 h. v' u - /*+ Q) u J+ g, j) J2 d* `! a
- * edma_test.c
( E$ r6 U. C; ^! j: r- q - *
, v9 ]4 o; h) ~4 Z8 p - * brief EDMA3 Test Application
$ k% |( Q7 f; P: ^$ {/ T7 w - *1 U& G5 J2 ^3 t7 w F6 o' Y8 q
- * This file contains EDMA3 Test code. c* [8 `8 O) l% }9 _; Q9 U
- *
9 w* F! r2 x% a9 b* w( Z; { - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" p5 v2 ?6 R5 h6 U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: Q! o; R6 F* C# d- c
- * TO CHANGE.
7 v: Q8 @# V- x8 R3 N! x6 E( r - *# E8 e, @1 T2 c, R2 |7 e
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 C6 v9 ^5 u( L& K - *
1 i5 k; Z& {6 }) _ - * This program is free software; you can redistribute it and/or4 _0 b- f. J4 E0 m& P
- * modify it under the terms of the GNU General Public License as; i/ b2 p! o; r0 g! `
- * published by the Free Software Foundation version 2.4 e t- {' w7 g% G0 I; ^0 `
- *
& v: C' W: R* M6 I% J5 v - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; m7 s! q( Z* i - * kind, whether express or implied; without even the implied warranty) Q8 M$ N9 L& c O5 J& u$ q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* s W& M3 X- J2 ~8 U, b- ~# b3 S
- * GNU General Public License for more details.
0 I; Z# S# u$ [. T8 i/ O; e - */
. {. k$ k( a5 q" ~1 ^8 E - 1 Y& l6 s' | M* k( a$ _
- #include <linux/module.h>, p0 z: m! a) E& S
- #include <linux/init.h>; R, Z4 s( a& Q
- #include <linux/errno.h>
% s O, }4 |6 W- G) V - #include <linux/types.h>
) y* e5 d) ^& P2 u - #include <linux/interrupt.h>6 V% Z8 G. [2 m5 d
- #include <asm/io.h>
% j; B0 |; |9 F% i& C0 G f - #include <linux/moduleparam.h>
9 v' S5 N0 K% J# K - #include <linux/sysctl.h>
! n U# s( T! ?8 m0 f/ a& M& z3 E" k - #include <linux/mm.h>- C9 H3 m" F0 B% M
- #include <linux/dma-mapping.h>
. X4 [+ `) N. p9 {5 O& x1 C
' q. O+ w# G. G; c7 K& M/ y- #include <mach/memory.h>2 W$ h# R( A% O& `5 h
- #include <mach/hardware.h>
8 x# ~5 ^5 h0 [6 z - #include <mach/irqs.h>6 l x' t) m2 P i$ T4 s
- #include <asm/hardware/edma.h>
- K$ d' Q7 e1 J3 a5 X; v+ Y; Q
: ?# @2 G! P. ]0 h- #undef EDMA3_DEBUG
, I [9 k: G" L! E4 e - /*#define EDMA3_DEBUG*/5 u9 r4 Q+ B4 z) D$ m% ]) w
- 1 v& j, ?6 W/ O7 y- \ S6 \
- #ifdef EDMA3_DEBUG
0 x8 r( U# N' Z' | - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): w- u8 j) Q( u# l
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 s5 e) S$ n; v$ T, X - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* M) N1 B" `" U' _' d6 O; r# V - #else
/ K& c0 o( J, e1 E' U4 _" O/ e - #define DMA_PRINTK( x... )$ e2 l+ c# g8 f# l
- #define DMA_FN_IN
5 U# h5 @0 n C+ i - #define DMA_FN_OUT1 n- H4 k+ d/ P: I' e1 C- c9 @4 S8 ] Y
- #endif7 O9 Q" J I1 E0 I
- 8 A# t6 `2 V; U4 g6 ]( W* c
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 e- N' m( c/ E- l - #define STATIC_SHIFT 3
" x3 K0 X7 o8 W( ~$ j - #define TCINTEN_SHIFT 20$ _4 R$ p' O' K
- #define ITCINTEN_SHIFT 21/ X' ^5 d- ~7 J
- #define TCCHEN_SHIFT 221 n8 F a, u, R% J; R/ I- _5 s
- #define ITCCHEN_SHIFT 231 h2 V, t9 Z% [
+ E6 \( L7 F% i- static volatile int irqraised1 = 0;( Z/ ]9 e/ Z( [* a8 ]
- static volatile int irqraised2 = 0;
Y0 I, ?$ s3 ?6 |* ?
6 b) ^" Y) z1 D3 ^$ @& y; T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 x) f, V8 A" P& O/ D& ~! v, J6 k3 ^ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; }) N& a8 Z! T2 |( x
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: H/ {+ o/ `: s* W* Q1 i, F+ T% q
: R' H* G. S7 M3 a) S- dma_addr_t dmaphyssrc1 = 0;) Z- o1 T" b0 I- Q" S( m# M( e9 @
- dma_addr_t dmaphyssrc2 = 0;" L" I" [% o: R& a. ^ P. i$ g' {
- dma_addr_t dmaphysdest1 = 0;
: Z( Z! y# H/ } - dma_addr_t dmaphysdest2 = 0;; L D4 t3 K- }& ~- u+ d6 x
$ Z+ m+ ~, n$ ?1 Z8 S- char *dmabufsrc1 = NULL;
: E; L4 c+ q+ \( L& g: u- f% z - char *dmabufsrc2 = NULL;+ A- Y( `6 y; T; V+ ~: J F" d! x; B% c
- char *dmabufdest1 = NULL;0 G, s) ~: F7 X$ D" @
- char *dmabufdest2 = NULL;
' \ Q) A2 u6 j3 G( @0 R - ; O: b0 [ G! T& k: u, K
- static int acnt = 512;
. [% \5 d h w, a7 c( ]9 [ - static int bcnt = 8;
+ t+ I) U* \/ E$ N: s4 Q+ V - static int ccnt = 8;
' K8 ?9 U# V, ]/ j - ( p& l& G0 p8 w, i' f" s6 I( X
- module_param(acnt, int, S_IRUGO);! z* \; q3 z$ e7 H5 ]: Q: {# |* q
- module_param(bcnt, int, S_IRUGO);
: Y5 }& G& r+ f+ z5 i( ]- U5 W - module_param(ccnt, int, S_IRUGO);
复制代码 & c. s( D7 r4 L1 j4 q+ i2 w: g
; w6 R8 b0 P6 I* W7 e6 k; S 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) i# P0 ?1 ?9 G, ^, g) W2 g# Q- U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, t8 o$ n$ U1 W! M' R( l 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 { s5 p: R/ c! c" s
8 s4 v0 R1 [! t* I q9 _. g3 A
1 f0 b- g, N; G8 C |
|