嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 r& S* @. h# h' j- H/ l! Q8 \. N
[code]EDMA sample test application
: q/ y1 ~7 a1 R
/*
9 d3 u7 C/ r3 b
* edma_test.c
( |! B7 @' Q; `# ~. I6 O! C1 h
*
$ r' V! r( {6 Y
* brief EDMA3 Test Application
4 M/ w; l/ `( u; t) m
*
; r" }8 T6 N0 E2 k; r1 y3 c. S* y
* This file contains EDMA3 Test code.
0 z; F/ ~" ^8 [* v4 s+ y7 n. D
*
8 B |8 A. x2 @$ R0 r
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* N- L' w( i! s' k1 C9 e2 k0 o {
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* N+ P! l J6 o" c" S4 Z4 I, Y
* TO CHANGE.
$ f: f1 {; H0 Z
*
( E, ^( u6 b& ]$ D' H
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 L" ?: D2 R: t! @5 \( s7 _7 b! U
*
6 I4 H* L6 Z3 _' C3 \
* This program is free software; you can redistribute it and/or
+ G( J# C3 ]" f
* modify it under the terms of the GNU General Public License as
% h! u& B; j- P" S- [' z
* published by the Free Software Foundation version 2.
) L* M" O0 f* ^9 U
*
v6 G2 [' I1 q) ~$ a' F
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
& |. |, j/ ^: L6 K1 w# b( H
* kind, whether express or implied; without even the implied warranty
! P5 a/ f0 |, @, ?- h
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% ~! [8 n) i. l' [+ Z f3 V
* GNU General Public License for more details.
. Z- d* S) |6 V# R3 a8 p( w u
*/
0 u7 j. G! s, {$ T- J" Q
& d5 N0 G% y+ c O0 ]1 h) p" D7 w6 F$ K
#include <linux/module.h>
- ]( [9 ]! V) b y$ l3 H9 i, q! J
#include <linux/init.h>
$ k- R$ |2 ?( U" _
#include <linux/errno.h>
* T) M$ t/ g' ~8 m9 X7 e$ S) s
#include <linux/types.h>
) P% z) R. J* q9 Z9 g$ T, d/ T4 }
#include <linux/interrupt.h>
5 H. u- n* y8 l9 A7 O
#include <asm/io.h>
+ V6 L$ ~+ ]- i7 P* y# y2 x" x8 g
#include <linux/moduleparam.h>
v( M- x, }+ b: G5 @ X) ~1 {
#include <linux/sysctl.h>
0 a T$ e' v; }7 R$ v/ Z
#include <linux/mm.h>
" }9 W# G. X- R% @2 {2 S
#include <linux/dma-mapping.h>
: z o* A) l2 P7 |2 S; Z
`- v8 [" P+ W
#include <mach/memory.h>
7 x1 S% J/ A, f+ A0 B
#include <mach/hardware.h>
0 F' V0 E; }- J/ E1 ?
#include <mach/irqs.h>
; V( b- L: f. o( [, g
#include <asm/hardware/edma.h>
2 k4 t& w# C5 e, v, B! E$ o
- G" F+ Y# y" z
#undef EDMA3_DEBUG
" S& J4 W2 D! J
/*#define EDMA3_DEBUG*/
" f! {' K5 U1 A7 w% f+ V O7 h
; C" c8 K9 T8 h/ `# s, @
#ifdef EDMA3_DEBUG
7 x/ s/ B; l; t0 F; Z8 C( s% n
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! M& T( _; w7 F2 F0 f
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
r( U8 b+ q/ J) }0 u
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% g* I3 r$ c4 i2 t/ a+ q. h f
#else
" e! w3 Y9 D! W
#define DMA_PRINTK( x... )
! f2 z% e& T; t2 T \/ X
#define DMA_FN_IN
9 Y9 p: ^# m' M" ~4 t/ \# J
#define DMA_FN_OUT
( N- C7 Y2 R8 n" @ C9 d
#endif
! S* G$ B$ h: `
6 s7 p% L: I7 s; b
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 a3 ^, k9 z0 ~( Q/ g
#define STATIC_SHIFT 3
' ~5 l% [; M6 g1 H( Y Y, h
#define TCINTEN_SHIFT 20
1 ~8 w2 A9 H* u% x- i
#define ITCINTEN_SHIFT 21
! [/ c& s* H# C$ j
#define TCCHEN_SHIFT 22
, {8 [. T M% }6 c7 i" _, @% r
#define ITCCHEN_SHIFT 23
4 \: P" X' j/ J2 Z& L/ Q4 J+ |
! K8 E7 i1 v: K) b
static volatile int irqraised1 = 0;
" V: R. ?. z4 E4 {$ E8 f
static volatile int irqraised2 = 0;
# }0 P5 u" h6 @; H; `
+ O& {! I* \- `8 r: r
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 U' i) [6 X4 L6 F0 @4 j
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& S2 V/ o* ?# U# m' ]
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! F6 [+ [7 Q3 n
) } S( N5 H/ Q9 N+ J5 {; M
dma_addr_t dmaphyssrc1 = 0;
' L% Y; ?$ ?+ \6 Q- N. F) C& a
dma_addr_t dmaphyssrc2 = 0;
- Z) ~9 `- Y: y" O$ F# [3 \
dma_addr_t dmaphysdest1 = 0;
7 R% k$ u% j3 B) L! y8 R
dma_addr_t dmaphysdest2 = 0;
' u9 h- g+ v2 i7 S; W4 i T
! } B9 D% a$ v
char *dmabufsrc1 = NULL;
; d* G+ g/ N& T8 W+ l
char *dmabufsrc2 = NULL;
- R% R) r i2 T( A
char *dmabufdest1 = NULL;
7 c+ w7 E2 E1 |" ?& {6 G
char *dmabufdest2 = NULL;
- s. q/ Q& b" p# s! m2 F
) k; y2 _# J! g r0 t
static int acnt = 512;
0 S$ W0 o8 r( ?0 f r8 T+ A7 n
static int bcnt = 8;
6 z, N$ O- H- I( `& y
static int ccnt = 8;
8 L1 R8 }2 g5 t" ? K: A' ^
; y( @' b. A& W' {- Y6 a
module_param(acnt, int, S_IRUGO);
* w. B5 C# ~; Z9 T
module_param(bcnt, int, S_IRUGO);
& |2 \$ z6 c" l+ r$ z
module_param(ccnt, int, S_IRUGO);
复制代码
3 j) ^/ K7 X3 ]# ^$ ~8 j" {
1 g! E9 \- h2 \, `# h. j2 Z$ ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ v. D, z% @, t+ `0 N9 G/ b
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 K! i* U9 ~" w3 { D
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 Y: B- ^* ?! g2 L0 n$ P
; k& k; ?- e; f: m5 h
: N$ O: m4 u4 B$ F0 S
欢迎光临 嵌入式开发者社区 (https://51ele.net/)
Powered by Discuz! X3.4