嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 |; X4 G% i- b( K$ R& j, b
[code]EDMA sample test application
- X( e: i- W+ F! I4 _
/*
+ n, }6 W' O. B6 x- p
* edma_test.c
% R$ L k3 Y" N. W$ {. i
*
7 F! d6 h. _% C l# g
* brief EDMA3 Test Application
4 j$ c& z* O: k/ p
*
" o0 g( p1 f# o# s4 L; [
* This file contains EDMA3 Test code.
6 e2 v( [, d1 [( @9 @
*
% B5 F! e O5 `% E$ c
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. s. {9 K, M; \# y+ o
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: h' v9 h6 _+ H
* TO CHANGE.
7 O% l2 d% J; ]9 B0 m
*
~+ u" I0 ~1 e# s
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 p6 u- I$ _3 u: R6 X- ]6 X
*
: F! g2 [" x. M: I$ |& O
* This program is free software; you can redistribute it and/or
' ?* Y% H$ x2 K0 o
* modify it under the terms of the GNU General Public License as
& Z! M! Q3 ^3 C
* published by the Free Software Foundation version 2.
/ M* m i- b: f* m/ A- ~
*
6 Q; g! F8 s5 r6 t/ l. _# J
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
) D6 e1 w. B. p0 j2 ?# ~- J) q9 r9 `
* kind, whether express or implied; without even the implied warranty
0 F' P( ]9 M) K. U( A( h
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 H# @1 q6 X8 n5 M+ \& v9 ]" v1 M0 H {
* GNU General Public License for more details.
1 L7 \9 M# i. B0 T: [8 D
*/
) k: |/ q2 Y$ L2 t5 Z
: O0 n. ?. F5 t$ k% G+ K6 y
#include <linux/module.h>
0 j" Z4 Q) T3 g; D
#include <linux/init.h>
9 L" I2 a6 f* `( g$ ?
#include <linux/errno.h>
& [$ F: t1 N/ E+ Z M9 L% r
#include <linux/types.h>
) N( n( M+ h' S' `
#include <linux/interrupt.h>
$ Q9 I7 L, g' E4 M$ V5 `: P* M \
#include <asm/io.h>
; a3 n$ e7 D% n6 ]) w E* \/ ^
#include <linux/moduleparam.h>
+ B/ d X* e3 w% A; \" T2 i8 b* ]
#include <linux/sysctl.h>
' M" f- t6 ^, }; ]. Y5 m' ]
#include <linux/mm.h>
$ H+ ~% \9 v5 _+ i' {1 B
#include <linux/dma-mapping.h>
. A; n6 p6 ]- w8 l# |
( P1 m: I) v) \, s
#include <mach/memory.h>
% K: @" E* j% J7 t
#include <mach/hardware.h>
; o& F$ Q0 M; g5 T/ i4 ?
#include <mach/irqs.h>
* P0 ^: ?) I/ C8 z0 e
#include <asm/hardware/edma.h>
1 q! g0 W# ?0 r& E6 x
% c5 R. @) o) F* b5 @' p
#undef EDMA3_DEBUG
; E( K; r4 C2 w* m: C
/*#define EDMA3_DEBUG*/
. f" p5 W6 V$ d* ~; q
' B0 s1 t4 \7 f7 t
#ifdef EDMA3_DEBUG
" s7 W$ [* M4 e1 k
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) l- z; @ t- H2 q' i
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: }7 i' _' m# X1 I! a" G
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ f I; K: G. d% e
#else
6 ], k7 k0 F3 G. V0 K: R
#define DMA_PRINTK( x... )
1 r+ U3 [% A0 ?5 t3 F% p8 ~ \; C
#define DMA_FN_IN
& Y% s8 O0 I7 `: W4 [! i" _' L. G
#define DMA_FN_OUT
3 P* O7 _& E8 d3 }2 A7 [1 i
#endif
) z3 q3 b; m4 Q6 ?
+ _/ J. T) r5 I2 c6 `' i
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 D% l7 I' u% Z4 G C! a1 \: [ R
#define STATIC_SHIFT 3
# X8 C8 O s: p' K9 A' D
#define TCINTEN_SHIFT 20
% L+ }9 i# g, A' W) ]
#define ITCINTEN_SHIFT 21
/ i' x4 Q+ f' ]' B0 w; `9 y
#define TCCHEN_SHIFT 22
/ z4 A' u: T! w) o4 P
#define ITCCHEN_SHIFT 23
+ X. _! b. P: ~9 B4 q' S* \
5 U- U. u. s$ O6 y5 o. Q
static volatile int irqraised1 = 0;
2 c# Q8 {# `, A/ b) [+ i! E
static volatile int irqraised2 = 0;
, T5 r' K9 ?9 `2 O/ S w
- s* X/ r( K. H6 Q& m
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 o7 l( p7 T: x9 O
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 J/ t! g4 r9 b
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 ]2 u% p" E1 A& M
/ K2 H: U; t/ D& G) O0 V" o
dma_addr_t dmaphyssrc1 = 0;
+ T' o" n. v5 F/ e
dma_addr_t dmaphyssrc2 = 0;
8 i; S+ x3 a5 U% ], w$ Z0 B
dma_addr_t dmaphysdest1 = 0;
. _7 s2 e% u) Z9 i
dma_addr_t dmaphysdest2 = 0;
3 h' k7 K' {; ^2 n# z
" Z" S6 q9 s0 y% o- ?( }. D! x$ |
char *dmabufsrc1 = NULL;
) ]; n, U4 r: w- J# k
char *dmabufsrc2 = NULL;
) M7 X# P% j2 A+ K: j( c1 x3 o
char *dmabufdest1 = NULL;
' z$ f! E5 _/ i9 l: ?
char *dmabufdest2 = NULL;
+ |2 x. l' P- Y9 b
7 N8 c7 ~' W1 K" D9 N$ W3 O
static int acnt = 512;
3 @* A# b7 W$ D4 c2 Z
static int bcnt = 8;
1 B8 P- p W* p+ ^
static int ccnt = 8;
" C( Z" \7 z: ~( a X5 t2 B
6 P5 w# f9 H, J. P8 _3 r! [
module_param(acnt, int, S_IRUGO);
7 Z+ m0 H8 D' e% M# v+ e
module_param(bcnt, int, S_IRUGO);
6 {: p6 j0 ~6 s7 k1 P; ?
module_param(ccnt, int, S_IRUGO);
复制代码
8 ?6 S, Z6 L7 w% S5 o R
% H; z0 i' b; n" v9 p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
v9 Z1 q2 @( _; l$ h
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# t$ y+ j4 m% g& x+ {4 X
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; X# L; \$ A; t
- g( h; v9 ^' M) M
$ X( L: \' W' t. `! o3 b4 G! m3 O
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4