嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, F: {2 M+ X1 r' w. [, `
[code]EDMA sample test application
( o0 i- m( X0 b6 R( `& V
/*
" ~, `/ @4 }5 [8 Q) ^
* edma_test.c
8 h* a6 U5 L9 p) T( F0 C
*
5 a3 }5 Y0 S5 X5 M* t
* brief EDMA3 Test Application
; D! v5 A- S' ]) v$ R: \! c& Q
*
$ M. l r# z6 O1 t1 @
* This file contains EDMA3 Test code.
' o$ U; s, v* }$ f6 i6 T
*
1 s5 q( ~- ]8 K& A
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% x" [: n/ i0 q8 G
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" ^6 G$ p. Y3 x( W4 C; s
* TO CHANGE.
( i- D" c# X1 \" Z) L
*
, q( D: a1 [0 R6 x8 l. _. X1 j
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. }' m7 b6 {5 D. y8 @, @
*
* V ~0 T6 \4 G! D- ^/ n6 B% [
* This program is free software; you can redistribute it and/or
8 w: ]' W b* u2 W, V
* modify it under the terms of the GNU General Public License as
8 D$ T. H( R; G
* published by the Free Software Foundation version 2.
: P/ M$ [9 m" k
*
! p D3 y3 x; S& {& o
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ \$ G6 H8 d, B( t# w: T0 _
* kind, whether express or implied; without even the implied warranty
9 Z% o- A2 F$ [3 N/ R' E+ Z
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& S6 j5 Q" f) L7 b: Y% W' D4 \
* GNU General Public License for more details.
( S4 v& i$ A4 M+ K$ y i- [- }
*/
( N$ E( D4 k; f
" f9 [$ h& q( @
#include <linux/module.h>
; |. B9 g3 O6 c7 b
#include <linux/init.h>
5 Q0 i9 y# p/ _$ k3 p
#include <linux/errno.h>
7 n, s& ]) N9 F' S0 L
#include <linux/types.h>
5 X! y$ e. j8 E: E( k
#include <linux/interrupt.h>
9 m6 S+ K! X2 J L3 l( L7 h
#include <asm/io.h>
. J, G$ x" I& p9 A+ C" k6 X8 `7 [
#include <linux/moduleparam.h>
' U% |6 y1 ~2 _
#include <linux/sysctl.h>
6 o K8 p: ~% l9 u1 @, I. F
#include <linux/mm.h>
7 J4 A* b: m! T/ Y6 R; B
#include <linux/dma-mapping.h>
; ^7 Y# J8 U+ x
* `; b8 f9 s2 t Y+ N* u( o0 a
#include <mach/memory.h>
" V. U4 Q/ c. x; ^
#include <mach/hardware.h>
( x* A1 A E1 q
#include <mach/irqs.h>
0 ` G+ ?7 D6 Q
#include <asm/hardware/edma.h>
. J0 r9 z5 y- i# b% f/ k( {
) E, C2 s, m) r/ n0 G1 k
#undef EDMA3_DEBUG
- }0 U; u1 a% I' [4 |" `
/*#define EDMA3_DEBUG*/
$ G- C0 K3 ]( C3 f6 W
) \" @+ Y, ?: o- U4 N
#ifdef EDMA3_DEBUG
/ V$ ~& M M2 I4 v# p Z2 ]# f) B
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 |' o5 C+ }+ H2 [
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 U: A1 e, ]5 Z" U
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' s8 D) Y& O8 M* i& c. y. G8 v6 ]
#else
) ^7 S# O+ Z2 r/ P
#define DMA_PRINTK( x... )
0 l( V! U% J. |" }1 V/ r
#define DMA_FN_IN
$ D, V8 ]# X/ g6 @
#define DMA_FN_OUT
4 R4 C& X7 z, o' l' E
#endif
- i7 \" \; K0 | F/ a
* ]7 N& H( n4 @% F% k) @
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
( b. E- h2 j& z3 m4 l
#define STATIC_SHIFT 3
) X& }+ ]9 k- ]2 I/ g- W% z
#define TCINTEN_SHIFT 20
7 U' _- L! A! T' O. x" q# m; ]
#define ITCINTEN_SHIFT 21
3 N! R$ C2 F5 R' e7 N* ^' r. S
#define TCCHEN_SHIFT 22
" ^1 N2 O5 h3 T( U: u* X
#define ITCCHEN_SHIFT 23
{3 p+ w( _9 b
7 _. J- J6 _ q
static volatile int irqraised1 = 0;
* ]4 j4 B# v! A! K
static volatile int irqraised2 = 0;
0 f. i2 v6 E- T: H9 G$ T
! n7 n# e( w# @ _( Y3 `7 m
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 ?3 \, z% J; d5 j& M+ \( Z
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 D% h- H: L, I6 |% h
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 ~9 s; G* t0 g0 M" V# b
$ `% w3 B8 U+ F, Z: \2 C
dma_addr_t dmaphyssrc1 = 0;
z. x3 F- t, u/ e$ v6 F
dma_addr_t dmaphyssrc2 = 0;
/ F) u: m) H4 z+ S( H
dma_addr_t dmaphysdest1 = 0;
: y* h" F) }: _' D
dma_addr_t dmaphysdest2 = 0;
( c5 i/ l+ Z& w4 S
+ K, L- l, W- n0 z' X; r
char *dmabufsrc1 = NULL;
7 h% k; s4 a; |$ A" h, P x
char *dmabufsrc2 = NULL;
' ?; f7 N* ]% U3 F0 h& W) T% N
char *dmabufdest1 = NULL;
; q, X: r# Y( W+ \% s6 h" \
char *dmabufdest2 = NULL;
. B8 k8 [% R6 X
4 Y% X; v6 X3 H+ S
static int acnt = 512;
* D' e( q8 ]/ t- R- r, \6 J6 @- }
static int bcnt = 8;
# Y) R! j0 y+ l5 O
static int ccnt = 8;
; G" x- @- I9 L" y$ w* `9 _5 N
) l2 i+ a) M" g; R' I# I
module_param(acnt, int, S_IRUGO);
8 F. U) \0 h! ?4 e9 X
module_param(bcnt, int, S_IRUGO);
' _' u/ T1 T2 o! n( e5 l7 V0 X
module_param(ccnt, int, S_IRUGO);
复制代码
0 I; x! V3 K5 s( o! ]# t
+ I K9 V$ L! j+ _8 H
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 D( v4 v: D* _! |) K! R3 m
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 R6 d% w. V2 I* s \. F! o. h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; ^5 v5 e# ?2 K3 ^7 P' d6 T
1 f/ k% M1 E* z# |7 h; ^8 T
: Z V) p2 d; |" j. f1 K- Y
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4