|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 s# Y$ \# R7 e; v: {9 w
- [code]EDMA sample test application
8 g" D( \4 x5 S - /*
" P m: | N0 a; E - * edma_test.c5 s3 f+ v# s5 w/ O
- *
. a. F m3 s% K, W# N - * brief EDMA3 Test Application
& n) o' X b! o4 y: }' y - *
5 Q3 F& x5 G3 R' q' ] A - * This file contains EDMA3 Test code.
& I5 \$ Z2 O- ?! O" P- s( z - *
' S) X b" O/ W3 u( U- y" M2 p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 {3 J9 \4 R3 b1 |7 d u+ v - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ g) r9 F$ u% J) d
- * TO CHANGE.7 z, l) U' M1 @3 \- E; J
- *
2 S: y2 s5 ^2 ^: b( B1 i; y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 Q) p) Z+ O5 u" g# t( ~
- *, }2 t: f# A5 a! u2 u. Q6 ]
- * This program is free software; you can redistribute it and/or* w; f' Z( K; Q
- * modify it under the terms of the GNU General Public License as
) Q' v0 h* x' _ - * published by the Free Software Foundation version 2.
5 o& K2 h( m, a - *
2 q, a% r3 g" u: g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& |5 x( q) K. \; S
- * kind, whether express or implied; without even the implied warranty. r' K+ Y& C, J2 p& F9 Q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 L. F: ]2 P. r; G
- * GNU General Public License for more details.3 b+ I0 L( e6 s$ W3 ~8 R" l+ |
- */
: n( L; V' h- \* C7 i9 P! e9 @ - " {+ `* E; e9 v" P. N& }* w
- #include <linux/module.h>
! a. ~- W$ d2 B0 h - #include <linux/init.h>, p5 E" y- ]& b4 r
- #include <linux/errno.h>
" ?& m' C; I- O: C+ I - #include <linux/types.h>
1 ^, l1 X% k+ D5 W - #include <linux/interrupt.h>6 s8 A9 ~ f& J/ B- m
- #include <asm/io.h>- _$ T2 L0 d- |# n& G9 F0 M
- #include <linux/moduleparam.h>
+ E* y# j4 {; J& }0 _ - #include <linux/sysctl.h>! s% I# S. g$ D1 p
- #include <linux/mm.h>1 Z% Y( x: ~5 G3 ]3 f( l# r! q
- #include <linux/dma-mapping.h>
7 G/ [& p% P" j8 a/ z6 o1 p, q: }/ H
# k$ C% j! _' R: P) q( g& h# J- #include <mach/memory.h>& H3 a! v g; R1 _$ ` B
- #include <mach/hardware.h>7 W$ N5 ?* F7 p* _
- #include <mach/irqs.h>
4 q$ e2 d6 L# C) o1 ^6 E3 m" x - #include <asm/hardware/edma.h>
$ \( Q `; c8 n$ Q) L" O" a6 P+ u
9 P% ]5 F9 Q! H. ^8 o- #undef EDMA3_DEBUG2 g! m( e6 D6 f# z- d6 ?
- /*#define EDMA3_DEBUG*/7 `% o) Q( V! F8 `9 o+ b/ l' X
- 2 A* e0 F0 {: `6 W0 v1 `9 B
- #ifdef EDMA3_DEBUG
; Y. m' T0 U4 a6 b5 {. p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 Z& Q* W9 p7 l0 }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& @, L2 [! ?, i0 I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: U' d+ o' \; @! I - #else
- G# L0 ]3 n' q - #define DMA_PRINTK( x... )( v5 i4 ^9 x5 x0 z! x& m
- #define DMA_FN_IN
5 ^3 f- n! _9 |, Q! K( e2 d5 ^ - #define DMA_FN_OUT
+ w' j$ ]# I+ q. N! j, W" @. d - #endif: D! A4 q$ X5 p. O" o8 e
$ I. ~. b8 E" a8 m( q% L8 w- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" u4 u7 @7 ^1 t1 X6 l - #define STATIC_SHIFT 32 O; J; E0 w+ l" i
- #define TCINTEN_SHIFT 20- u+ ~% C! [& D, P
- #define ITCINTEN_SHIFT 211 z0 Y- B. H! f1 h U9 q
- #define TCCHEN_SHIFT 225 H4 f3 ~( n, o! {- D0 J; s
- #define ITCCHEN_SHIFT 23
3 b' B* o/ F2 P# t! r" p - " z! u i8 W: K8 h$ T
- static volatile int irqraised1 = 0;
M$ @9 k" W5 m - static volatile int irqraised2 = 0;' f4 U, N, w! g7 O- |
# V; d! Y( W9 |7 z4 n; d# z7 j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ \+ ~$ }* m" A* F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 h4 h5 M' D" A9 ~( \+ _ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' X9 C, R/ Z5 V
% R2 N# {, G, q g. Y+ o4 j0 J- dma_addr_t dmaphyssrc1 = 0;
" @3 u7 l) j* T6 ? - dma_addr_t dmaphyssrc2 = 0;
$ a( k4 Y& Z8 R" F - dma_addr_t dmaphysdest1 = 0;
; J) q9 X9 U) m S p - dma_addr_t dmaphysdest2 = 0;; X8 g5 N3 u( b, n. j: S6 F9 v
- $ {5 \* n8 }1 b- y% j
- char *dmabufsrc1 = NULL;* Z0 F1 f2 @! o
- char *dmabufsrc2 = NULL;
/ J, C1 l2 I0 b6 ]) m, u4 t - char *dmabufdest1 = NULL;( f3 G. K3 h% q% o( H+ Y, L& ~
- char *dmabufdest2 = NULL;: _' u7 H" J0 h; U6 I
4 {. O* L' z! {, p1 f- static int acnt = 512;6 b# O, v# W$ Z' _
- static int bcnt = 8;
; C3 X9 z! `3 e, o9 b& \8 S" Y0 T2 Z - static int ccnt = 8;
7 M! L& j7 I6 ^: C" y! G" B) e' _# ` - $ o* @+ X6 w) h1 m
- module_param(acnt, int, S_IRUGO);$ |9 E' V) D: Z
- module_param(bcnt, int, S_IRUGO);
* e. r$ Q7 ?, \3 ~$ f2 h# T6 l1 f - module_param(ccnt, int, S_IRUGO);
复制代码 ' c+ p$ t; s0 @! p6 A
- `9 R8 B; O9 v* h: d( \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* r9 q. G- s" |( D9 A' C
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# b5 _# R* [0 \/ j" @- _
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 i/ c8 C+ Z& P% c) W4 U. b, N
2 K% V7 ], m; y1 \
; G+ m+ }* ~8 G |
|