|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 V+ H3 J8 k3 E+ q% {7 y( ~5 O- [code]EDMA sample test application0 a5 D8 D- ?5 H" P- P6 c4 D
- /*# D* K5 o7 G" M# w; G0 X. L, E
- * edma_test.c
, l# {9 D* ?3 a( K8 l% K - *: o0 R' a) J, |7 ?; Y
- * brief EDMA3 Test Application- x. }; n* N" r/ X7 n. K2 `0 h
- */ B5 }9 f* \/ @1 p, u- k
- * This file contains EDMA3 Test code.
( D, ^( [. z2 l; @1 H - *
8 e' g o( u4 |6 G9 q7 |2 S9 T k* }5 C - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 O1 r3 U Y8 Z) V9 r" v w - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 @4 j; I9 P! v* e- @( l% }0 t; m - * TO CHANGE.
/ j# I; G) b" j - *
" h! `7 U: M2 |% |: k$ | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: [8 \) G9 M+ N- a6 } - *) ], q+ p- d- l# I% a O2 x6 z
- * This program is free software; you can redistribute it and/or G! W* w4 C/ j6 d
- * modify it under the terms of the GNU General Public License as
/ I) `# v. T: ^! { - * published by the Free Software Foundation version 2.
: a/ u6 r! ?4 f - * W7 ?7 |+ Y; W! Z7 t& k
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* d" N0 ~0 L. M o) I - * kind, whether express or implied; without even the implied warranty9 W4 k# h! I) p/ F! ~, X6 M/ d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; a5 Y- b/ G) [. m - * GNU General Public License for more details.( v9 i+ E+ N9 k/ C( p; H
- */
# I4 @! t& a" t) O/ e r5 w - 1 j/ I- w+ q2 Z. z+ E$ t
- #include <linux/module.h>
' m! }2 Z% ^0 A7 V! D/ h - #include <linux/init.h>
: R( W/ X0 h' [; h6 {/ w - #include <linux/errno.h>; M7 C7 J% ^& ] H0 R+ [9 G
- #include <linux/types.h>+ x" s# c7 ]- j: y. ]/ Q9 d. ?& u
- #include <linux/interrupt.h>
* o8 M0 `) {3 o9 o) z - #include <asm/io.h>6 O6 }% J$ L' C$ K) `
- #include <linux/moduleparam.h>
( X! T) z( G( v; [" A" L - #include <linux/sysctl.h>
! X6 a# W0 Y0 J8 O2 y% ^ - #include <linux/mm.h>" `5 H) E- I7 [' J/ A' \0 P
- #include <linux/dma-mapping.h>
) k" l+ `" K5 h- J: V - 4 N. |# ~( T* M2 W4 \ y; [+ S
- #include <mach/memory.h>
! {; f# ?# m' P. Y; s- ^ - #include <mach/hardware.h>
! H6 n8 h& F! v6 o' g - #include <mach/irqs.h>
+ A+ o" R/ ^$ m6 K T. x! l - #include <asm/hardware/edma.h>
* t8 c4 l' h% y2 @4 @- C3 R' \ - 5 a4 O0 Q j+ Y) K
- #undef EDMA3_DEBUG
/ d5 d) @( X( r1 N - /*#define EDMA3_DEBUG*/) \+ ]! `" f& t' Z4 k* ^, k, }8 C6 D
- - U: J' f7 d8 M3 b1 M
- #ifdef EDMA3_DEBUG ~: z+ p: P' l% L) J. p
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! Y e) E, V, }/ f( U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% M9 J$ {) ]# ^8 D4 m: X( c6 U5 p6 P - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): I" C* v( ]; z. W8 u
- #else
2 v0 u3 d2 F0 q/ K, K& A9 q - #define DMA_PRINTK( x... )
7 g. ?0 P; E L( Y. U) j; ^0 C - #define DMA_FN_IN
1 q$ s% W p0 j5 m - #define DMA_FN_OUT
2 a# c8 x- I. Z' @0 [2 M - #endif
* O+ @" U% y. i$ T* U2 p
( b. b5 k; b- Y) F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ {; t- H6 v. z% T+ G - #define STATIC_SHIFT 3
7 M& t( h: E# i - #define TCINTEN_SHIFT 20; h$ `0 R$ ?, l; K* f
- #define ITCINTEN_SHIFT 21
" u6 a( e. a0 B1 F - #define TCCHEN_SHIFT 22% k& K- O. z* q3 F4 |+ B6 n
- #define ITCCHEN_SHIFT 23* M! F4 D' X7 S. |+ W
7 k( v$ q, ~" w4 ~% B$ g- static volatile int irqraised1 = 0;7 x3 U2 m# V! \. F
- static volatile int irqraised2 = 0;
) t4 Z5 W0 `: i0 i6 Z - 2 \0 w8 {, Y1 y8 E# Y$ p
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( p) }: o; b4 j% \; ~; h# f! {( R% N
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% H$ ?) ^8 ~! m& H$ E# z/ w1 ~ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; l0 j+ g4 {% t5 Z* q - ( m. c& s3 y+ s, T' R
- dma_addr_t dmaphyssrc1 = 0;
: v% R/ l* |0 b6 g - dma_addr_t dmaphyssrc2 = 0;
5 n6 P" v! x, Q" F: z. w" D - dma_addr_t dmaphysdest1 = 0;: n5 d5 {7 T4 w* Q$ }* b0 l) e) }, r
- dma_addr_t dmaphysdest2 = 0;
: H9 }1 H) Y" a* t, N
! Z3 Y9 r; m& a- char *dmabufsrc1 = NULL;7 S" f& K3 r5 L: A- ~
- char *dmabufsrc2 = NULL;
3 C) L9 q/ f6 Y2 B; _- H* m" w: d - char *dmabufdest1 = NULL;/ d, V, _& i6 n* k1 F* N1 q) L
- char *dmabufdest2 = NULL;
0 {6 a& l9 B& S% r) w - 6 v' F, c( [ `8 h& Z2 p
- static int acnt = 512; [6 Q; f, g; ]* N$ D6 ~* Y# w: n
- static int bcnt = 8;& ^+ ?( o8 G* v% ^) s. e
- static int ccnt = 8;
8 H' b0 E. u; E6 M
5 m% E0 N9 n9 D$ ?. a9 V- module_param(acnt, int, S_IRUGO);
% A9 P& b( y6 [ - module_param(bcnt, int, S_IRUGO);1 J5 `8 W7 n( {# f& _; Q$ u
- module_param(ccnt, int, S_IRUGO);
复制代码
' ^' @3 { A3 i, w0 ]7 b G7 u5 R
. {5 k8 _0 [% @) F- v 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ e# q0 {# G G2 f' F; ~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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& g3 b( T- Y9 n! t5 n8 `. n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 u; E/ \2 \# H4 p8 l
, [) A2 F9 g2 g4 v5 ~5 e+ Y
' ^* |9 S2 I4 M- r2 h& P |
|