|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + H( N& s( h+ Z3 [% B/ x+ z! h- K( u
- [code]EDMA sample test application
7 I% G/ H+ N) N9 R9 P& _# C - /*# c% f) Z& ?" |7 o ~
- * edma_test.c
8 p5 o( t. I. k2 M. s/ I! t4 a - ** ^5 F0 L; j3 C
- * brief EDMA3 Test Application
& e* R5 O4 F9 T3 |. z' e - *
& ^7 q$ J- T- `, T3 b- e& J( N5 s - * This file contains EDMA3 Test code.
- `7 k0 E" Y2 Y# N/ h! [ - *# k) i0 A8 Q& \/ L- M9 G& p! A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 q5 G. z+ k. v - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
y3 F" z# F+ ]0 h - * TO CHANGE.) Y: y( O1 E/ N! q; N
- *) ]2 \. o6 ^2 \/ q6 O
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' Q1 s8 O0 m7 O1 c; b, ` - *8 {9 D4 \. h; \% V0 u& g/ @; |
- * This program is free software; you can redistribute it and/or4 l, {, n/ D1 ?
- * modify it under the terms of the GNU General Public License as2 o' h% d( l% J. `8 q3 Z+ r& T3 ?
- * published by the Free Software Foundation version 2.
% F( @, D4 K" B - *
9 F& S V4 J7 b" c" z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' B( m& G4 f2 v - * kind, whether express or implied; without even the implied warranty
; s' _% Z9 D9 v4 S. W+ A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. y5 x( y& F1 j: _4 T( I
- * GNU General Public License for more details.9 d) K* p9 t! w7 \7 f
- */7 w( r9 `) M, U, ~: Z
# k F! d" ?/ v- #include <linux/module.h>/ ~% f9 c G* {6 Y& w; P9 a
- #include <linux/init.h>
+ I# c: y( c- _1 ~0 f& G - #include <linux/errno.h>
; b, `& }0 N: T; r. i! S - #include <linux/types.h>
3 L/ b- K* y; s& c - #include <linux/interrupt.h>1 A) k3 E1 K* d7 E
- #include <asm/io.h>
2 W6 m/ I5 s% ]7 K* x* }1 P: Q. S) _ - #include <linux/moduleparam.h>/ c R$ L. E% h- k
- #include <linux/sysctl.h>
2 T; T4 w$ P5 q" W- \! ?2 T - #include <linux/mm.h>! i# d3 D* z, y7 V, d: L: Z5 H
- #include <linux/dma-mapping.h>$ F" D# U* ^, v( w( e; X( x
8 _( c5 \9 A% ^% ~- #include <mach/memory.h>; K$ p4 {, c- o
- #include <mach/hardware.h>
! u0 i" d4 X3 \- s% }$ D - #include <mach/irqs.h>
- r$ M( K2 N6 j. | - #include <asm/hardware/edma.h>4 [2 U2 ` J. d
- / b" ?2 A, L, Q5 r; L
- #undef EDMA3_DEBUG" k1 T, P% K/ L/ b3 `" t% U0 b
- /*#define EDMA3_DEBUG*/
( K9 _. f3 D+ v" L) k; r" E - : V9 `- v6 G. l3 Q% {9 v
- #ifdef EDMA3_DEBUG
/ C+ {5 ^8 z4 T8 K! J - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 [6 r- y2 W' U2 C1 s+ K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 E& B% u) P2 B) ] z7 \ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; D8 ^2 z" R6 D% U3 z4 d - #else
* q0 M( e6 W+ k8 {$ x$ W - #define DMA_PRINTK( x... )
& M0 ^ H! K! J - #define DMA_FN_IN- Y( x# t3 Q1 E6 _+ @# F
- #define DMA_FN_OUT6 _6 _! l- }! a+ k, K5 Y9 D5 K5 Y1 ^, O
- #endif4 \) N# A1 ~/ E0 A2 N0 h- \
; ]; l& V: L0 o" g) t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% g8 A: h+ S4 r
- #define STATIC_SHIFT 39 R8 T: w! x" q
- #define TCINTEN_SHIFT 20
- [& i$ T4 j0 E+ f; ?9 P% V - #define ITCINTEN_SHIFT 21
) J5 t3 H8 K4 o; ?0 l3 O. G+ @ - #define TCCHEN_SHIFT 22
1 q# g. x2 T% n: }5 W. x1 B; }- ]! K - #define ITCCHEN_SHIFT 23
- l u( G, Z- Z. e! |$ d; Z
: U; K$ K' J% E& z3 P8 d0 y- static volatile int irqraised1 = 0;
6 P0 s1 F, i% M/ \6 ? \( |& E) T( T - static volatile int irqraised2 = 0;
5 R$ G2 ~; O9 b* k5 b! e - 3 w( x4 {6 T3 P4 s9 W: D: V
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: I1 c! V7 L# O& z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 s m0 t& V" ^, f' _' C8 K* C - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: R& }' J d' Y5 s
- / `7 L5 m- P' ?: u! Z. v* ~7 O/ m
- dma_addr_t dmaphyssrc1 = 0;8 F( a- ?, M9 |0 \1 w6 h3 I
- dma_addr_t dmaphyssrc2 = 0;
. S) X' g; e: k" N* }. b - dma_addr_t dmaphysdest1 = 0;
: J8 x' ~- V# k- q5 ^ - dma_addr_t dmaphysdest2 = 0;
% H# }. ^6 L7 }" d2 \2 [2 A# e# @ - 0 F/ u6 W, I7 c/ F5 a7 I
- char *dmabufsrc1 = NULL;
* ^/ h8 h* l5 {/ U( ^* A - char *dmabufsrc2 = NULL;' ]9 n" ~3 V+ }# G) e$ F/ h
- char *dmabufdest1 = NULL;
2 V3 }8 a/ {' k$ o* C - char *dmabufdest2 = NULL;1 ~- K9 u& d5 c) w% t- S, ]
; U, f+ ^6 y: r3 T( B' j v/ I7 t- static int acnt = 512;, S w$ n& g X+ L
- static int bcnt = 8;
?' ^7 D3 [+ d - static int ccnt = 8;6 |& h7 `! C D) g, r
, G) G: V# H- ~# `0 p! i% M" x# @, U- module_param(acnt, int, S_IRUGO);
9 H2 ^+ K3 Q& S3 I% g' ` - module_param(bcnt, int, S_IRUGO);
$ W* M+ h0 {9 N+ @2 O; k4 S - module_param(ccnt, int, S_IRUGO);
复制代码
, M0 X5 t- T) B# ]7 }- ?. c
: v1 U' C4 H+ K8 v: L! S" x+ A/ |7 @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 [0 O1 c0 \! e' ^1 l+ M" _3 K
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( W2 E/ i& E, Q' Y# I# o8 F e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% \1 T3 Q/ Z k: C$ f9 p$ j) k0 C
) p2 V# y) j7 c1 Q3 A# j; C5 J8 h: E' `" l. z( p
|
|