嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& Y- e, l# g2 o! f/ G( k1 m
[code]EDMA sample test application
% ~, t6 Z* k# \% I; `4 t1 y
/*
1 P+ V5 _) \5 n o7 v1 S: x; m" ^8 \
* edma_test.c
9 K1 _. j% E" J; e% X+ Z& T. W. U
*
: r: `5 t3 G: U
* brief EDMA3 Test Application
# [8 K* |/ U( g
*
: j1 Y' p# ]" ~& l6 G5 p+ B% B
* This file contains EDMA3 Test code.
5 s7 U/ k) S/ E
*
# _* h, E3 o; Q
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
K0 d& X+ e% @) q, i
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: ]" v: p: w6 ]$ ^
* TO CHANGE.
3 K( f1 |. p e* |2 ~1 D
*
1 T" ?9 m5 N1 p( l4 I& R$ C
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& o6 |* ]+ t5 o% N E" d3 W
*
& S" U/ K1 ?' m: ^) s
* This program is free software; you can redistribute it and/or
) D1 `( w3 p; A8 n. g6 P
* modify it under the terms of the GNU General Public License as
~. F) i: `7 J2 T4 a8 H/ o
* published by the Free Software Foundation version 2.
0 k8 s6 ^0 v% z" ~: L$ |9 ]" E3 i/ J
*
1 h1 l4 e/ ?' a* S2 e' Z* U
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ F; `9 g7 _9 m8 p% a( v% u
* kind, whether express or implied; without even the implied warranty
# a% M" d/ Z8 V- ^/ n( Q7 Y
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 y0 K& n& S& G2 J
* GNU General Public License for more details.
! L' j( n2 E' k2 ?* Z) H
*/
+ D& o" _$ N0 A% Q
! C3 j2 ` O" B6 g
#include <linux/module.h>
0 F: A5 d' o; t# A! M
#include <linux/init.h>
: T) \! w# e! i- p( W: R
#include <linux/errno.h>
I2 b ^/ w; D' S; J) P* y
#include <linux/types.h>
3 \4 ?4 X. z" Z, y& f
#include <linux/interrupt.h>
2 P7 M. Y4 b' u9 I; C* \+ G
#include <asm/io.h>
4 W- s/ l! Y7 E, C7 \! B! d
#include <linux/moduleparam.h>
- t% ?, \& }; P& k
#include <linux/sysctl.h>
! W7 }7 {$ g/ `; B, v6 E$ e
#include <linux/mm.h>
2 o; K, c7 B- j% i, X! ?# M
#include <linux/dma-mapping.h>
0 A6 b3 ~1 d2 R0 J# o- F
O4 Y2 m, j$ Q+ m: E0 L- ]
#include <mach/memory.h>
. e4 c$ K4 V* Z+ J
#include <mach/hardware.h>
O) u3 k/ U0 Y/ R' u% I4 x
#include <mach/irqs.h>
/ q( L1 T) Y. a8 ^& G
#include <asm/hardware/edma.h>
& p! n+ P+ T7 G* c5 E9 s* t& H; A
+ k1 \8 p- b) q
#undef EDMA3_DEBUG
' J% J8 S( p/ n& i/ g$ T
/*#define EDMA3_DEBUG*/
: s) L0 }; |- \& f$ H/ F# v
9 [ M" b( H. g& N* l1 K
#ifdef EDMA3_DEBUG
, P( j1 j( K! K3 z, O; v2 y& j
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. f1 Z- f# J" u' q
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! G9 S/ ^% T @' [
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ m+ A7 d" O# V
#else
2 V' R8 U; a" T \( l5 ^0 R$ d
#define DMA_PRINTK( x... )
# e: h% t9 j" I! f! l. m6 p5 k' j
#define DMA_FN_IN
+ d& K5 ]- ^2 `- K% D7 y
#define DMA_FN_OUT
& J! B& t* l/ u" t" f& }2 Q' I* a
#endif
$ R9 Y* m3 I8 a# r. g: C" h
- I( ~" s# G" X \% k& n+ ]6 E& J8 c
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 [; G$ e: \0 u: o& N7 d5 J( I' o
#define STATIC_SHIFT 3
2 D7 ~: o1 F& Z7 o
#define TCINTEN_SHIFT 20
5 u* J$ M' F6 U2 |( g9 y* B, l5 b
#define ITCINTEN_SHIFT 21
4 H+ x6 R0 f X2 G1 M! D
#define TCCHEN_SHIFT 22
7 t( E$ y6 |$ H* H, B/ w
#define ITCCHEN_SHIFT 23
q5 D# [# ^* f+ h S! Y8 t( {
\; D* ^: f# ~( ~9 `; v
static volatile int irqraised1 = 0;
0 B6 N" f4 v' Z+ e
static volatile int irqraised2 = 0;
4 M/ _* @; i* H9 G; N& n. k& G
' i4 V% a" B7 d5 ] X2 ~/ _
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, v5 `0 P) e3 T( U8 U
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ R O, t, Q* A% N) n) @
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( L5 f& U ~; @7 k( o- ~
& K4 Y# O5 S$ d' {$ O$ D
dma_addr_t dmaphyssrc1 = 0;
( e' h5 I8 @/ m; K8 l( G" U+ n# q) _
dma_addr_t dmaphyssrc2 = 0;
+ C% T7 K+ h0 a3 c5 |9 x, u/ J
dma_addr_t dmaphysdest1 = 0;
3 L2 E. \5 c) {% P6 T$ L' J5 Z
dma_addr_t dmaphysdest2 = 0;
# ~' r8 H, t C+ N% T) P) F' b
7 b( \; Y( K+ C* Q$ `1 l. p2 \4 R
char *dmabufsrc1 = NULL;
+ z# A, q! J( W3 b1 T: X) N4 y5 H' b
char *dmabufsrc2 = NULL;
& f3 J/ p! Z2 {" } `
char *dmabufdest1 = NULL;
8 y* ^" M" B3 @0 @4 X$ h: w
char *dmabufdest2 = NULL;
V V( y ?' K3 X* C" l% A8 _
7 M* ?" A; N+ \
static int acnt = 512;
: U+ e: D- w& f+ `/ V: T% Z, `
static int bcnt = 8;
/ \" |! j) T e4 s7 P" j7 l$ J
static int ccnt = 8;
2 V# b# T5 K- @
1 `7 u! A/ i6 L2 W c" t9 u
module_param(acnt, int, S_IRUGO);
. x+ |9 x0 o9 I$ m" D( E, W/ O/ i( b) M
module_param(bcnt, int, S_IRUGO);
# w0 A. Z) i z6 o; G+ A1 r
module_param(ccnt, int, S_IRUGO);
复制代码
- N0 W9 ?& h5 D' j# n. Q
1 m0 J1 b: {, V- O1 E% B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ c4 X q$ C" H5 o* g2 h e3 g. L/ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% F5 c& R/ Q; y- |0 `$ I8 M' q& F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' i6 s. j: a9 [
/ S4 P8 U/ x) o, Q) X$ \
; c( O' @, G2 Z' U& v) m
欢迎光临 嵌入式开发者社区 (https://51dsp.net/)
Powered by Discuz! X3.4