嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
C( U+ V9 t2 I8 r: G' S% _
[code]EDMA sample test application
0 A O( t. P; @/ R4 N
/*
* F) g' A2 R7 h5 Y) U
* edma_test.c
3 X- j; o( u/ ^) ]) S2 _
*
* b1 [/ E. B- W
* brief EDMA3 Test Application
/ @- x- k! v# W( P" Q9 P2 ?
*
: v! W% \. N& A& k5 @) k) a
* This file contains EDMA3 Test code.
! S: Q4 V! _& ~9 X; L: i
*
. x5 e' G& y! U, Q, W8 _; w
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% t5 {# x- \& q0 _! v `
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 u2 M% }0 \- z; P, n
* TO CHANGE.
$ p8 c! R, ?' j: v: ?
*
' s. h5 h @% d7 G1 r
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 g i* `# t7 S5 f$ M. [9 f( [
*
4 ^ e8 M4 l$ H9 i! {8 t
* This program is free software; you can redistribute it and/or
5 f0 I# o9 n2 J! c( j
* modify it under the terms of the GNU General Public License as
1 ?: \5 X/ I5 h
* published by the Free Software Foundation version 2.
3 ~1 y2 G5 E; G
*
. [( _; ^! \5 h( U- g
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
( d4 X0 s! [+ x: z9 Y9 a
* kind, whether express or implied; without even the implied warranty
. q+ _ N, c) f# r5 G" f
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& k7 r6 u0 L7 x6 u4 h" a) S' p
* GNU General Public License for more details.
: W2 I- x$ v& k* H+ L
*/
D& [. F5 i1 S, b
4 g; x3 Q. x: w2 X& B# P, i
#include <linux/module.h>
5 R) M* |& T( o* `# n
#include <linux/init.h>
& p F/ a- @7 |0 e& J) _# D
#include <linux/errno.h>
2 V1 L0 R, n% p$ V
#include <linux/types.h>
2 |+ n7 P5 A; T f
#include <linux/interrupt.h>
: I4 U3 H1 ]/ E7 b- u
#include <asm/io.h>
|- u2 p' b" ?/ E
#include <linux/moduleparam.h>
! \: g, k' I/ o; l3 w* y
#include <linux/sysctl.h>
* F0 s) e" l, W. U8 |- C( B9 e
#include <linux/mm.h>
: E0 Z( m7 N5 \5 y5 n
#include <linux/dma-mapping.h>
2 K6 p! Y& D" M' E6 l `: H% Z
! |* S. P# \: X: I* O# T' I0 X
#include <mach/memory.h>
' L, f' k1 g5 l6 q$ X
#include <mach/hardware.h>
) T- n% q3 r. f. C
#include <mach/irqs.h>
O# I% n: c% N ~+ @( k5 d
#include <asm/hardware/edma.h>
( ?- Z: N W2 t- N, v
; X. V! n% P" n1 J; L& t
#undef EDMA3_DEBUG
- z1 J- J7 Q# ~+ e- J; W& f8 G
/*#define EDMA3_DEBUG*/
4 u& y o, H( ~$ t3 ]1 M7 E1 q
v+ A, z/ }: j& ]4 L5 k
#ifdef EDMA3_DEBUG
7 ?$ ?- ^. a" q9 h `
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- M5 D7 A: e7 { M
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% f2 f- z( {9 w5 P4 O
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" Z/ K( ?6 V; D! q4 b- n6 m# r
#else
$ G6 s& v# k$ S* h+ U1 H
#define DMA_PRINTK( x... )
0 V5 Y5 @/ @" m" T3 G$ _
#define DMA_FN_IN
6 I4 [4 n4 Z \ q( n% x
#define DMA_FN_OUT
; k" f! J4 h1 N3 H
#endif
( g# |0 P# \: ]! L7 D7 i6 @; k$ N
H! h7 Z) q" L9 y* A j
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ h1 X) l. c+ T
#define STATIC_SHIFT 3
/ Z. y+ @0 f v9 s3 D- F
#define TCINTEN_SHIFT 20
$ q1 t, r8 N+ b
#define ITCINTEN_SHIFT 21
8 c8 [7 Z1 s4 o( K
#define TCCHEN_SHIFT 22
+ a' B9 B" I0 f3 O/ f! p6 z
#define ITCCHEN_SHIFT 23
2 D* m: n$ \, Z5 @2 O" \" L) Y
" [) ]; t' X2 d$ M
static volatile int irqraised1 = 0;
0 q* O9 Y5 O( d. x3 Z
static volatile int irqraised2 = 0;
8 L2 @6 ?! i, c y1 H# n) F/ X
( z" O6 u+ O# U3 u2 b5 }
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" I6 ~% e Y3 i0 ~5 i7 h% F& d) ]; J! S
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 x) d. q& P( |
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 ]6 T' f2 {0 z P, J( N
+ q! l A: X% L! _5 a+ |
dma_addr_t dmaphyssrc1 = 0;
8 K8 a+ d# D. ?. Y& i: `3 [+ w7 c+ X
dma_addr_t dmaphyssrc2 = 0;
" q* n' T3 K( ^* I8 p6 N7 k- Q d
dma_addr_t dmaphysdest1 = 0;
- Z' v6 r- R6 M- E1 Q6 _8 q) y
dma_addr_t dmaphysdest2 = 0;
* K& S2 I$ S* S3 I, S6 ^
5 v+ l$ U+ V. S) m
char *dmabufsrc1 = NULL;
4 B; O, X3 s+ D9 u, K8 B+ x, C
char *dmabufsrc2 = NULL;
/ D. b8 u. t+ _8 G# o
char *dmabufdest1 = NULL;
- `3 Y `$ V' z7 f% z7 x# y% O
char *dmabufdest2 = NULL;
2 r y" u& C& B8 I
+ ?$ H3 d7 @- }( W4 u" [5 D
static int acnt = 512;
6 T5 ]! I& e9 G
static int bcnt = 8;
; H" L& |, o) u. Q
static int ccnt = 8;
, c& l" R, W: Y7 J- X. {+ {' e
5 s: ]; H* M/ A. R8 _+ \3 l
module_param(acnt, int, S_IRUGO);
, R1 r j. X |) B
module_param(bcnt, int, S_IRUGO);
$ ]# a% Z9 ~$ M8 K# t$ i5 Q. t
module_param(ccnt, int, S_IRUGO);
复制代码
. d+ W& q4 W) p! f! Z5 }
) h1 Y/ \: f% x( C1 T9 d" {
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; B: a/ d: B" ?3 Z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 l" U8 K% J6 b0 o5 Q+ E: P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 f6 G6 h9 @0 _: l: Z6 F0 |
* s1 ?1 N* g. H9 _) x0 g8 g- K& ^. o
2 y6 z7 ]7 ]; B" w
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4