嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, L% V+ o# G; t6 C
[code]EDMA sample test application
* D4 c$ I8 W5 o X' ]6 O$ O
/*
; E5 y) f7 h& V, o: z" m
* edma_test.c
" Z5 e7 }9 B0 H0 F0 U: ^* [ u
*
7 u; L' P' t, I4 \% S' p0 o
* brief EDMA3 Test Application
# |( G; _# p# ]4 h3 [
*
4 z6 u; K3 D) L0 b
* This file contains EDMA3 Test code.
0 P( D7 P6 {6 ^' ]% E3 A' a! v8 e5 T
*
1 X) P* I T* Y) Y4 p* C) ?
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 k, y4 ^8 h* X9 k
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
T0 d5 A& z& t$ t) D
* TO CHANGE.
d0 _0 a5 i, C% ?' s' ^
*
& r' j4 J, E' k3 Z1 t' ?
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ x' p) x; J5 m$ m* g( N
*
; k; P8 m$ C: ^$ S# o* z6 o
* This program is free software; you can redistribute it and/or
& o1 o6 b+ x' K
* modify it under the terms of the GNU General Public License as
" k2 R" E! F# `7 r% F" ?; E U: [
* published by the Free Software Foundation version 2.
[8 B) B) C( m# w1 p e D
*
H7 }3 u& d# y w _; [
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
) A# M2 ~+ [) \& y% @: t8 G
* kind, whether express or implied; without even the implied warranty
g8 u9 J8 ?5 D( R* ]9 h; T
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( M) B. g0 {7 y/ J) q0 P
* GNU General Public License for more details.
/ ?; {& y8 c' m2 @7 Z
*/
: A1 W8 |0 q1 o) h- V/ f# X
. k- E. w2 Z% E" [9 E, J
#include <linux/module.h>
" J \7 M2 x7 [7 R8 i
#include <linux/init.h>
1 O* N. t! e* [# c/ n8 C5 x
#include <linux/errno.h>
, a/ }: h6 U8 p+ G! H
#include <linux/types.h>
) g8 J/ d5 h* T/ X' Q; ^
#include <linux/interrupt.h>
2 T! p4 I$ T+ y, H# `9 V
#include <asm/io.h>
/ @% @" I* Z5 S! T% V, o
#include <linux/moduleparam.h>
- @# s6 N: s$ |
#include <linux/sysctl.h>
/ m, R" y: ^" _! Q9 y
#include <linux/mm.h>
, U/ K2 g, S& {/ m
#include <linux/dma-mapping.h>
. e$ B2 _! T: E- }* e
, W! j# \$ r6 M* M; [* ]8 _
#include <mach/memory.h>
( t5 P6 {3 x" m9 n( |; X
#include <mach/hardware.h>
) R- ^/ c6 {) H, m
#include <mach/irqs.h>
6 z/ U: o2 D. M9 F, O8 w+ W/ s" _
#include <asm/hardware/edma.h>
$ A& n n( z7 @1 U
$ x6 V; S- {8 y ?
#undef EDMA3_DEBUG
* c! ` s0 l# W b. J
/*#define EDMA3_DEBUG*/
( d U: `% t o2 _8 n: V7 P3 j2 ]
6 R* u, g$ H) F) k. H
#ifdef EDMA3_DEBUG
- h4 ]2 V4 k% A* d/ n* y
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. O: U* _ |, J" D# n+ }
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 a" r8 ^- @5 j7 Q7 R( t1 b
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ G/ K9 }8 f5 ~( j2 x# z
#else
% m/ a) w+ |/ ?) e
#define DMA_PRINTK( x... )
2 p3 C; f. |5 g1 m5 P+ j. K' M
#define DMA_FN_IN
/ X( A0 k" l2 e$ Y% A2 n- w. q5 L, z
#define DMA_FN_OUT
% u: H2 i6 Y5 c: ~
#endif
0 i! h+ e/ N5 x# \& T5 J+ Z
2 V1 G+ S* M7 \$ K/ n# `
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 |8 j/ @; K" f9 S$ M
#define STATIC_SHIFT 3
' R. o, |. e% d) ~, r0 s
#define TCINTEN_SHIFT 20
* y$ n' ~5 w5 Q+ J- y* l6 E7 U
#define ITCINTEN_SHIFT 21
& I6 X' C% l+ M J+ {
#define TCCHEN_SHIFT 22
& ~( |6 Q V+ i+ g9 c n
#define ITCCHEN_SHIFT 23
. n6 t4 C- m2 c
7 f; S" b: a6 j! l7 e; C
static volatile int irqraised1 = 0;
! l1 }- M1 Y0 C' K) D
static volatile int irqraised2 = 0;
7 t. V, E" C* y4 [) E
& f% J7 w I. `) r8 P' G9 [! Y2 }
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% z* R0 K6 F' f1 H3 w+ V
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! A- G' P, N, U' O9 z
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& A, B' e i! E" M0 W
' U V* \7 x' P& i7 C
dma_addr_t dmaphyssrc1 = 0;
' L+ @( G- {* t7 b9 M0 h% u
dma_addr_t dmaphyssrc2 = 0;
; f a& @+ ?% @" I8 [4 I- k9 j/ r
dma_addr_t dmaphysdest1 = 0;
. h. N' b# m# Q7 k6 r% Z. t
dma_addr_t dmaphysdest2 = 0;
; P) ]; f9 G0 t3 b. f
, p% n: V: L: v5 e4 V% D. U% r
char *dmabufsrc1 = NULL;
4 } W. F& K: H; M' V3 ]; n
char *dmabufsrc2 = NULL;
! D/ D0 i \2 ?
char *dmabufdest1 = NULL;
# O* j6 a, U; Z! I2 T& D/ X, V5 [
char *dmabufdest2 = NULL;
& a1 g$ w' }& c' |6 h; u8 o5 N3 T9 S
9 j: ]+ A; h* E# h2 T2 F! \2 ~
static int acnt = 512;
' p- `, \' y$ I# e! H0 q
static int bcnt = 8;
! h5 A h$ M/ M3 f" V% u
static int ccnt = 8;
' S1 t* ]# R. `
6 ?2 Q) B1 h5 ~1 n2 @3 ?( G
module_param(acnt, int, S_IRUGO);
\4 g+ c( ` i2 G
module_param(bcnt, int, S_IRUGO);
6 N5 u; |4 y! I7 d+ }, m1 [; z' t
module_param(ccnt, int, S_IRUGO);
复制代码
& ~9 o! n5 z. t7 ?6 o5 C3 f: B
5 n8 ]4 }! g2 p: v+ t2 U- W# t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 V4 T7 Z0 w/ V \& g i; d
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ D7 [1 E( w& K& u
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ |) d: u6 Z: j
# b5 x+ W+ t3 ]( D3 {* E4 }( N1 K
0 D* b& O* @% v% t. L. R/ E
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4