|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ Q3 G/ A6 ?* ^# i. _
- [code]EDMA sample test application
9 _' }7 N( w' h! y - /*
4 t& a; n) b6 g! R - * edma_test.c& N) y! F- |7 s" n$ H, j" K
- *
& r8 w0 `( ~: n: o* I: ]& g - * brief EDMA3 Test Application
$ l2 N0 O& Q/ e* t$ Q - *
9 \1 [3 o; B/ n' N9 O - * This file contains EDMA3 Test code.
( ~0 W. }2 ]2 E0 M( |, Y4 U9 `" E - *! ~+ b4 k$ d" u- h& H, m. z( L& Q2 ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- p6 N9 y; j% x7 a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. G0 @2 r% U7 _$ [8 h/ o* ?: _8 e- D - * TO CHANGE.% Z" _& O( h$ n# b5 m3 M
- *
# t$ }) g8 s& U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
h% ]. ^0 ~& |4 h9 Q. f4 w! Z8 {6 E - *% x# n8 h6 L a& d* T& X' A
- * This program is free software; you can redistribute it and/or
5 j) i- ]7 C2 W; T5 M - * modify it under the terms of the GNU General Public License as! ^" l N% i8 y+ o' G
- * published by the Free Software Foundation version 2.
5 a) Q9 Q, G, k/ o' V- @$ } - *
" e1 h# N: {4 V9 K9 ] k* d# N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& Z/ r7 x$ M) `# K) m+ t
- * kind, whether express or implied; without even the implied warranty6 P1 j, K9 g7 {% S: ]/ a7 u7 t
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the U+ T3 P- q0 p4 u2 O
- * GNU General Public License for more details." y: g; |8 c. c! ?
- */
& L+ v) E' z) j7 s" [" a8 | - # J9 p0 j" q3 M2 L
- #include <linux/module.h>
: Q% J M: r) {6 o9 ~ I7 g1 I - #include <linux/init.h>
5 x( M9 [4 M" G W - #include <linux/errno.h>
0 ]: \2 ~4 A* F- A) w9 P - #include <linux/types.h>8 p8 H5 N# M4 K+ k& @! R8 C, s+ S
- #include <linux/interrupt.h>
- w* |; T* x' h - #include <asm/io.h>
' S* v+ z# G" V6 _' J: @' v - #include <linux/moduleparam.h>
& Q( g2 I3 W9 G9 @7 l l; \9 Z; s - #include <linux/sysctl.h>
! O h: q) K/ I/ @ - #include <linux/mm.h>
4 h5 w5 u/ ~2 J5 k - #include <linux/dma-mapping.h>
0 I/ n7 b5 _0 X# U d
E# M. t; \8 F- #include <mach/memory.h>
2 g2 D5 k1 x! c) t9 q3 k. X+ r2 ~ - #include <mach/hardware.h>
2 J" e1 Y+ v/ F+ ?5 s/ n% W - #include <mach/irqs.h>1 a& O/ ^+ h# l% Q2 K
- #include <asm/hardware/edma.h>
+ \. |% ^6 h. ?, D! m4 f - 5 R7 j. ?% V% ]$ H+ Q
- #undef EDMA3_DEBUG
' a& Y& k2 C) \8 ~# h - /*#define EDMA3_DEBUG*/6 |! F/ p Z5 Y6 c" M) W
% k" J5 k! t! l4 }1 J5 u- #ifdef EDMA3_DEBUG
$ H( g. t) H: q- v1 e: T1 K2 {/ p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 \% D$ J, P& i6 o
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( g: Y& n3 x y$ M. I: h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 C6 w/ K; P# d: m
- #else
; F% }/ k$ N9 f R4 h2 N - #define DMA_PRINTK( x... )
0 N: Z' X2 Y% a0 F5 q5 u - #define DMA_FN_IN2 d0 v- ~: c9 v1 M
- #define DMA_FN_OUT* L. W; Y; Q Y/ }. T g1 s' d: o9 A
- #endif6 d1 j& v5 Z* u6 G% Z8 b
- . {7 i3 c# n$ N7 A
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& d( o& k3 \1 c - #define STATIC_SHIFT 36 f" v' ~) a% F/ y
- #define TCINTEN_SHIFT 20
4 D% D0 L! q% T$ ?' @8 V# C - #define ITCINTEN_SHIFT 21' J; r8 i4 v6 m5 ]2 k
- #define TCCHEN_SHIFT 22
e* s/ y7 A" t: |9 S+ i; X - #define ITCCHEN_SHIFT 23
. e; J# o( s3 T( G4 D/ W - 5 f5 _- N4 u. Y* T3 Q
- static volatile int irqraised1 = 0;
+ M! ?0 B6 m( h7 N9 Q - static volatile int irqraised2 = 0;7 S2 G; u' b- Z, S$ m. i
- 4 ~( @4 ]4 k- U) x( K
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& G6 y) X% t* r7 v$ c - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! J7 U' F8 t' V0 w# I
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 J9 w- C: U$ j! f* i) b
- ( H4 V7 L% j% E
- dma_addr_t dmaphyssrc1 = 0;
$ L& L& l) `0 X' y - dma_addr_t dmaphyssrc2 = 0;
: u3 H) ]; }' X" M: ~$ Q& s* m- i - dma_addr_t dmaphysdest1 = 0;
. c* Z: T& k% i) u - dma_addr_t dmaphysdest2 = 0;
4 ~' O3 Y' {! |: X# v6 S
( K3 |$ i8 @7 `4 e* z/ }/ x" I- char *dmabufsrc1 = NULL;
% _# @' A" C( v# Q - char *dmabufsrc2 = NULL;; Y* N8 r X# ?# Q( I8 y$ [1 [! Z
- char *dmabufdest1 = NULL;; y, ~% C6 k' S/ \& N) y
- char *dmabufdest2 = NULL;! w8 `9 u7 M+ P0 S6 M8 [9 I. k: X
3 H7 }! H. U m' w- static int acnt = 512;9 V# ?4 ^8 Y5 D! D" n
- static int bcnt = 8;
B$ D+ @& b0 ^, U/ q# j7 j - static int ccnt = 8;
$ u R( G; r$ j1 [! f- R$ u( v9 m
6 O4 E6 b% U4 [* c- module_param(acnt, int, S_IRUGO);
( H* g4 c$ z) m. A( g6 N - module_param(bcnt, int, S_IRUGO);! s, ?- w6 ^ Y& w w
- module_param(ccnt, int, S_IRUGO);
复制代码 ; Z5 \) X, J B. f5 s( Y: l2 H- {
' u; `* P1 H" H4 E5 H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 y3 ~+ a7 k* v4 T* ]
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* @4 z( | }: q2 N/ Q" b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 i5 P% i" f+ v9 \/ v. Y8 f- j$ K, _9 L
3 g/ z* @! a4 p/ S/ z |
|