嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 r* h0 R- S1 J- f
[code]EDMA sample test application
" j5 _1 p- D6 X1 |& ^) d% l
/*
e; G3 a2 p- P
* edma_test.c
" b- x) n. O% ?. N$ R5 v1 U
*
+ ^% G2 s5 p* y* C5 f
* brief EDMA3 Test Application
W- l+ E2 q8 Z# W5 H
*
1 ?+ W: Y5 s+ F" |, @* z
* This file contains EDMA3 Test code.
1 C4 Y4 H+ b0 D# F9 y6 T3 \
*
/ u: J) |' G1 g9 ~/ Q" ?
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 |) R9 [7 [( Z$ j! S( ^
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: a" S) }' e7 p6 P% S
* TO CHANGE.
8 h# L3 H4 T J, J2 v
*
$ P1 m- k/ T1 ~9 }0 O5 B2 N
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 o: F4 `$ G0 A T
*
+ O2 E. N4 x: P7 H/ d/ V
* This program is free software; you can redistribute it and/or
$ B; O6 {- g0 @
* modify it under the terms of the GNU General Public License as
4 w+ S* E) @/ n- E
* published by the Free Software Foundation version 2.
' J: C1 i6 _- @# X7 ]0 N0 W
*
! I, B: s* y9 }6 {8 V
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
- W# L( r; O, l& S( r. I' u8 n
* kind, whether express or implied; without even the implied warranty
- j) g' `/ s7 y3 Q7 `
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 G. H* S% _1 k* }1 u& S
* GNU General Public License for more details.
2 N2 }- u1 |+ f' J$ L8 ~( _
*/
, Z- V7 X' d7 u! t) l
) I+ Z, D5 {+ R% r
#include <linux/module.h>
' x! b& m: b. W3 i6 \0 p: y
#include <linux/init.h>
5 a$ r! I z. y
#include <linux/errno.h>
& E% ?1 N& d& { Z/ G: V
#include <linux/types.h>
) S* i: d9 Y7 D* I
#include <linux/interrupt.h>
5 V* G% ]7 O( k- V
#include <asm/io.h>
5 T! @5 y) @2 M
#include <linux/moduleparam.h>
8 J* Z o. F# ? ?" x
#include <linux/sysctl.h>
- x& T4 J7 p( Q6 q$ Q
#include <linux/mm.h>
! h" \' E0 n# s/ u
#include <linux/dma-mapping.h>
( S8 N z$ m4 T' Y) c+ |* u
$ {2 R# Y/ `* p$ x$ f# M& H
#include <mach/memory.h>
& v. {* w3 M5 |0 i2 D
#include <mach/hardware.h>
4 j' ]4 P# W" T$ F- V3 a2 N; q
#include <mach/irqs.h>
0 t, ]+ } P5 {
#include <asm/hardware/edma.h>
8 `) q% [, c( V7 h: G1 I; u
* p% m& L* b' i) @
#undef EDMA3_DEBUG
9 W+ H1 `9 D F6 Q$ |
/*#define EDMA3_DEBUG*/
" m; F% k# X! U
. ]/ B; K% ~( h1 H- ^, f# g& ~. [% z
#ifdef EDMA3_DEBUG
$ u% r7 a2 _- Q [* o! K
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# k/ ?$ u2 t: q6 a- D
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 O0 U4 d& z: G! G
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ f1 |3 e( p4 G, y7 n' I
#else
`% a8 l( x" V" Y# I" M
#define DMA_PRINTK( x... )
( c) a5 o) ?4 S9 s- ^
#define DMA_FN_IN
" }9 U) l/ p/ V w, J
#define DMA_FN_OUT
" _3 K9 j1 C" r! N* r
#endif
8 K+ [2 E9 [- V4 N' T
C4 e9 X( T5 w) t, D1 K8 T, \
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
! [9 Z% f4 L$ R% s, k
#define STATIC_SHIFT 3
# U! ^& [3 U1 r9 r
#define TCINTEN_SHIFT 20
9 @" W1 S+ a6 m: g
#define ITCINTEN_SHIFT 21
0 l) Q" W: X: Q, v; e- r
#define TCCHEN_SHIFT 22
7 W1 K4 A, H! w. Q; ?0 ]
#define ITCCHEN_SHIFT 23
/ ~+ N- h+ X" ^0 H% D7 F8 Z
, t2 L( g# O a; J1 y
static volatile int irqraised1 = 0;
8 @5 W, \/ l" u* r8 [ Q9 k/ J
static volatile int irqraised2 = 0;
$ P; o* w' A9 `0 j( ?' P) ?
/ x3 O: e! F! L1 G- t7 a
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" {- O# j: K7 @1 g3 Y# S
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, C. V7 O" B5 z7 ~; _: o
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" {% j) K7 z8 T4 N" c
/ E: ?- p4 [6 b3 T9 x
dma_addr_t dmaphyssrc1 = 0;
: G# P) g+ M i" h: A% g+ Q ?1 O
dma_addr_t dmaphyssrc2 = 0;
0 z& A' ]* i, [( u
dma_addr_t dmaphysdest1 = 0;
6 y) d4 B+ R2 x+ G/ i
dma_addr_t dmaphysdest2 = 0;
+ T" ~3 l3 c3 U# p& E
8 K5 o' [/ |- _; g+ Z' Z% E$ T9 [7 ~
char *dmabufsrc1 = NULL;
( [4 d' R/ M, K H6 Y; W
char *dmabufsrc2 = NULL;
( N: x4 N( Y/ j* [. P
char *dmabufdest1 = NULL;
" K1 `) H8 }* U. f- k9 J
char *dmabufdest2 = NULL;
2 `1 v- \. @6 K0 A( q
0 x; P/ |5 {1 L$ R+ R
static int acnt = 512;
5 O' v* T% ]8 t- r4 F/ V8 A& E8 t
static int bcnt = 8;
7 S$ M+ |# Y F3 Z* [
static int ccnt = 8;
% x% \& \2 B3 K: E) J- E
8 i$ @) ~0 f7 G. Q# d: I3 H
module_param(acnt, int, S_IRUGO);
% H# `: q x5 V8 ~, g/ L2 z
module_param(bcnt, int, S_IRUGO);
/ {5 k$ x$ o+ r) u0 y9 Z
module_param(ccnt, int, S_IRUGO);
复制代码
; W. x6 p' r9 i/ u+ L
" N6 n2 K' o) U l/ G% h! W; w: S
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 J) h$ N8 T6 i9 J) ?/ V& V. K
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
: F; J. D4 b( f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 V, ]. v) x+ H3 Z- R* B
- ?! C- J1 N) v# Q0 u3 s5 e
' Y/ s1 o( \1 L7 K) \
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4