|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 z2 z7 T7 i j! N; U- h
- [code]EDMA sample test application
* D% E, t3 X( o, M - /*
4 G- g! [7 q& q2 G/ q3 m! M6 [ - * edma_test.c) \6 y/ t- i5 `! R" h
- *+ r5 f2 b2 [2 K! t
- * brief EDMA3 Test Application
1 r6 \& U, I1 w% S: s - *- W% W5 t7 [* C
- * This file contains EDMA3 Test code.7 i: g0 o; \- [- a, m6 e' k
- *
: c& d- u8 i7 f2 u3 C& @/ P# c7 p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% N! H0 n- W8 k& ?1 Y: O* h9 M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ F, A# Y, I& x$ ^6 o* o - * TO CHANGE.
1 b8 |# h9 C( J - ** s Z- R c0 }0 h: c2 X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( Y" P. ?' V. S, P$ o. _. ?0 _
- *! F5 W, `/ ]0 y4 T& B
- * This program is free software; you can redistribute it and/or
( d2 O* ]" k0 w+ N- r3 x - * modify it under the terms of the GNU General Public License as
( ^, w; t" j* o! J/ N - * published by the Free Software Foundation version 2./ s+ l m0 ]; f
- ** d5 A4 h( v: e1 C0 j- o
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ H, m! f2 @5 J: k) P: E - * kind, whether express or implied; without even the implied warranty5 m$ f, T: I! F' B7 c6 P- e
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 w8 t4 r8 ?5 g6 t1 G8 P" O8 l
- * GNU General Public License for more details.) W3 ?& b4 E) [1 D/ `' C! G! D- c4 Q
- */3 o4 C7 G; H5 U
- ' P* i) c8 l: C" T# S
- #include <linux/module.h>. r& L4 O! z7 S0 d. Y0 h
- #include <linux/init.h>* ^& @ ^' @( j0 {! ?, f' i
- #include <linux/errno.h>
0 K# T; \+ P0 T2 i' m! [ - #include <linux/types.h>
! v2 o" g# R5 C4 m' t - #include <linux/interrupt.h>4 u t- Z2 [6 |2 V) D
- #include <asm/io.h>3 e, Q& O* C; _2 o2 u% q
- #include <linux/moduleparam.h>
( d- r2 m" K7 h: |5 v. D# { - #include <linux/sysctl.h>
* S1 l7 ~' B5 }# T: f - #include <linux/mm.h>
, \" I9 n/ B: r! v - #include <linux/dma-mapping.h>
+ @- \9 k9 n5 M - ( m/ X, M4 t3 @" F, ~/ _8 C& k
- #include <mach/memory.h>
. C$ A/ G' v4 K1 s4 S% u - #include <mach/hardware.h>
+ J: ]* g- f; z8 f! y - #include <mach/irqs.h>
, \4 Q4 k4 Z+ p - #include <asm/hardware/edma.h>' u0 g( m' P6 Y- L
- ; X* M# P/ C5 X4 e% {6 d
- #undef EDMA3_DEBUG
" s, h1 L- U4 v- l, b - /*#define EDMA3_DEBUG*/
' N! G3 d; L6 Y2 h$ L% R* m
- q+ s% g" B/ a2 I3 D- j+ r/ v! p$ E- #ifdef EDMA3_DEBUG; C2 b U8 r& E/ F1 V& Z$ [ ?
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- Q9 r5 g% ~' {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 I I% N% G( Y2 j- s+ r+ D - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ E3 b* U: D% h# x6 o7 ^1 \
- #else
% ]. B, A a+ |9 V5 @6 ^ - #define DMA_PRINTK( x... )1 y: a& _ R/ z+ ?: S: I: R
- #define DMA_FN_IN* d% t3 K4 k& X8 F) b g
- #define DMA_FN_OUT
/ T T) I; \) F - #endif
2 R+ T. U) {7 s4 a/ S* d - & C. k3 }: W$ `6 {/ ?. D
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ @ G$ l! C U. h: A; o: G - #define STATIC_SHIFT 3# f% ^2 E7 `4 f# T% w# L
- #define TCINTEN_SHIFT 20
; q4 Y8 X5 a m0 y - #define ITCINTEN_SHIFT 218 n' E+ v1 e( D# Z" B4 H4 L
- #define TCCHEN_SHIFT 22& Z0 M+ X; s& f! c0 N3 I
- #define ITCCHEN_SHIFT 237 T5 {8 ]2 Q8 j( [
- 3 [( F3 r( z; \' Q0 z G
- static volatile int irqraised1 = 0;
* F& L; X" U' v7 f - static volatile int irqraised2 = 0;
' V" A4 z; W# ]! q% b3 S
" T+ D8 `" t$ k9 C i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 m& a' V' c/ _/ w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 T1 d K% `% W2 [/ h - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& Z* w5 j* C5 x- Q" r
# \3 q6 `: y0 w- dma_addr_t dmaphyssrc1 = 0;0 J7 J3 X- v* E. S: b4 j; T; {
- dma_addr_t dmaphyssrc2 = 0;
3 I* Z' I6 m( U" f - dma_addr_t dmaphysdest1 = 0; e1 h; g/ _: C$ l; W. @! I
- dma_addr_t dmaphysdest2 = 0;
1 _+ P( ~9 l+ k- ^6 O( H - $ m8 W' ?$ Z3 v! p3 Z
- char *dmabufsrc1 = NULL;' d2 G3 W* l( J& u& h6 ?2 v; ^
- char *dmabufsrc2 = NULL;$ P9 f) O; @9 O* {
- char *dmabufdest1 = NULL;
2 t8 A& h5 |% t0 o% y/ K. g8 x - char *dmabufdest2 = NULL;' g8 w; t% ~; t1 ]; ]! P% ^
# x( [7 E* s$ G+ `& N- static int acnt = 512;2 P6 }& n2 N1 r: q6 U
- static int bcnt = 8;
6 j7 {0 H; {9 S7 n p/ { - static int ccnt = 8;+ u0 C* q- D D, a, f, Z
; d, h( }8 O. ], W9 c3 A- module_param(acnt, int, S_IRUGO);
$ q3 P1 U+ e1 L' G- ~+ `' n6 _ - module_param(bcnt, int, S_IRUGO);! Z2 R) x# x4 `, x' _7 ^+ v) X
- module_param(ccnt, int, S_IRUGO);
复制代码
; i6 ~) _0 T2 M# v3 v* [5 ~5 d
! O# `# ?3 {; r$ ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 ?2 m' R! R+ j0 B
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; z# k4 B H' _ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 P0 b2 r9 R( v- b( d
, R& n; B+ h: f* P1 W k! m2 A+ {3 Y, f* ?) {% C
|
|