|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 g6 M \' ~5 E" G, f- [code]EDMA sample test application( j* ^# h! e- C
- /*
; t& j. X/ B4 [5 F - * edma_test.c
% E- g% b) C; l' d$ u! ]2 v+ H - *' g- I" G7 e: J
- * brief EDMA3 Test Application! J3 L/ N6 w n; p7 q
- */ J: {0 a. O+ d2 L, e; @
- * This file contains EDMA3 Test code.
+ L- L6 Y( B V+ T) n* A& l! K - *# l% l" ?2 b! ], S7 z* w
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% U T. b6 W9 g' \, g) l% e
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! u, ?. T1 R0 H - * TO CHANGE.
& N2 P/ J5 S. |* e - *
4 r" |4 i) e+ F3 i8 u+ z3 q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. x/ L O8 n% ^
- *1 f# s H8 }/ ]# n+ G
- * This program is free software; you can redistribute it and/or
& ~4 s% b& i* I/ A$ o% i# l - * modify it under the terms of the GNU General Public License as
- q" x) ?7 Q$ k. s- O8 Q+ W9 [0 Q) u - * published by the Free Software Foundation version 2.
$ s4 Z0 S3 e: s, }5 G - *& H$ k8 s; ^+ D" K1 Q1 q( D
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- [! [; j+ ]5 Y5 B* W% }. k& M0 j
- * kind, whether express or implied; without even the implied warranty
; n2 s; b3 `5 k( \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 {9 X0 Z: L# H - * GNU General Public License for more details.
$ j v% f8 a7 t0 @1 M3 } - */8 {- ]4 O# V' F' W# N
! P/ f6 c9 u+ N: I' K% m# ]- #include <linux/module.h>
: T; J' n9 L# P, y - #include <linux/init.h>. R4 K( s3 `/ W: u# c, Q: X
- #include <linux/errno.h>% l Z. Q" t. H
- #include <linux/types.h>2 L# ` T) r' }& m4 I
- #include <linux/interrupt.h>
. s. K) r; Z. m& o; ~, n: E - #include <asm/io.h>* G9 j- Y) |% |6 D, M& g6 v6 D0 x
- #include <linux/moduleparam.h>
6 v* G. a! E4 w- U: B - #include <linux/sysctl.h># y8 p5 |. q9 z
- #include <linux/mm.h>
2 b4 `; l' H# F I+ v& F, A+ z - #include <linux/dma-mapping.h>
4 ^' `) y( F. u8 a) t2 l
3 j+ T4 Y; k) q# D& s: N8 P- #include <mach/memory.h>
2 X7 J/ T1 L: i$ X6 u1 }- Z - #include <mach/hardware.h>
* o1 C$ d& C2 S6 R - #include <mach/irqs.h>1 v, k n& }0 ^
- #include <asm/hardware/edma.h>- C( J1 @4 U2 j7 V3 N0 ?& ?
- 3 _) p8 ] P; j
- #undef EDMA3_DEBUG
; J C( l- @6 v3 r/ I - /*#define EDMA3_DEBUG*/8 P' z/ J$ k( }; j8 v
- 6 h( k% h7 S" A9 ~
- #ifdef EDMA3_DEBUG
- A7 J/ C. p- j: Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 j' r( [ e& w# ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 ]; g! d: t' L8 G }- a - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ H) H7 m, `8 }' j, A9 Z% E" W6 r - #else
# e$ k6 q, H4 m+ i* W - #define DMA_PRINTK( x... )
5 m& G5 N+ A" _3 E& q" k& B - #define DMA_FN_IN
6 c6 e, u' O5 G& l. q) Z - #define DMA_FN_OUT1 D$ t0 ?6 x; k. \) c' _/ l
- #endif
; E, q7 ~/ C0 r& M! | - ! q( U" @, z/ D6 u7 e
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 ~# [ A/ X0 y5 P - #define STATIC_SHIFT 3! }0 T2 {" F5 t; j# Y
- #define TCINTEN_SHIFT 20
" e+ J2 r/ i8 J2 X3 S, R6 S - #define ITCINTEN_SHIFT 21% L. j" y2 D) f' ?+ j* R
- #define TCCHEN_SHIFT 228 x8 m/ T, Q ^! d6 d
- #define ITCCHEN_SHIFT 23
- H2 j( Y& [1 W: s* }( W - ; m% o2 D+ l4 P
- static volatile int irqraised1 = 0;# T) m0 ?% F$ @5 b. V# p
- static volatile int irqraised2 = 0;3 F, s. l# P8 c0 x
- ; C! N$ K. v4 S9 b0 ]; j$ w4 m! S3 @
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 n+ I& w7 y2 Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, ^ l0 K' i) \) q) k, v - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! W7 c3 s3 U3 {* a' w
- $ ] O( i8 h+ q( w
- dma_addr_t dmaphyssrc1 = 0;$ K; C" t! I1 y, |4 U" p. W# q/ A
- dma_addr_t dmaphyssrc2 = 0;
8 ^9 l5 L+ i- O - dma_addr_t dmaphysdest1 = 0;* r8 d, y+ W, V" c
- dma_addr_t dmaphysdest2 = 0;5 X# |# [+ Z) y9 j c. f
% x6 r' Z/ ]* t8 e3 n, r- char *dmabufsrc1 = NULL;
, I) j5 {- Q" L8 @3 i) f - char *dmabufsrc2 = NULL;
" |' \5 r: ?5 J/ J4 ^1 y7 Y - char *dmabufdest1 = NULL;( H+ n3 G9 ]" H- @! ` _
- char *dmabufdest2 = NULL;5 x. h: ~, `$ i
- : ~0 v4 E% k) D! g6 B
- static int acnt = 512;9 ]3 |8 A+ S" V9 D4 S+ H- _
- static int bcnt = 8;# o8 m/ R8 f2 g0 K8 Z, L
- static int ccnt = 8;
. d, V% P9 e9 l4 ]! n
; L. M& `% e9 W/ o- module_param(acnt, int, S_IRUGO);
6 Q y; B4 g3 A, W - module_param(bcnt, int, S_IRUGO);
: f, d% U- @! z* K2 i - module_param(ccnt, int, S_IRUGO);
复制代码 + C ~; v( J K
! ?) X, f' Y1 f: {% c: w 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% X# s! f! O. N- ^2 Y9 Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 Y7 g! m3 o. U0 C% I
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 a2 |$ L- s S6 u0 Y' S
( D* e U% r7 t& S) s p' `) j' K
7 X8 | v* A' g6 M+ O4 \ |
|