嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 D0 H( P! B0 k" U/ W
[code]EDMA sample test application
# X, ]8 ^: ?" Y6 C) C' V- F* u+ o% g+ s
/*
& d9 v( W% z6 k
* edma_test.c
7 C, @- }+ u; E& `
*
& I* ~! s3 r) Y b9 F# W
* brief EDMA3 Test Application
: X1 q+ x6 w e5 T0 c: i* ?
*
2 N% D5 U2 g) @
* This file contains EDMA3 Test code.
+ w+ D3 _" [! n3 {$ a8 n
*
) G5 d/ s+ Y' ]5 V6 v. d1 E0 {$ c- t
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& p+ L, j( ]2 v5 V4 u+ n
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, A J. @% Z% i/ c0 H* c3 n! b
* TO CHANGE.
* M: `9 T( w2 J7 I$ |1 {
*
, Q3 `- e7 z" L; l- }& g8 w
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- u6 h6 h' _" w O, z7 V/ q
*
- K' i" Q% W) i+ `6 u
* This program is free software; you can redistribute it and/or
+ M( ]$ k. ^# d
* modify it under the terms of the GNU General Public License as
6 _8 C- X2 k. U6 s2 }
* published by the Free Software Foundation version 2.
7 O0 u$ u0 j4 `: `+ D" ~4 A6 Q* O
*
3 @0 `/ [7 C' c9 }) g
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 `: u; n# \) E0 p
* kind, whether express or implied; without even the implied warranty
# J3 e% @+ g4 B/ _* f f& W
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. [& v2 J1 l' i# L! V) B& E
* GNU General Public License for more details.
; k/ N4 r7 }! H9 w S
*/
# q5 P/ |- |5 V! |% L
: Q/ r6 F: h* [4 M! d5 a' P
#include <linux/module.h>
. U7 `2 ^% d" a3 A. I
#include <linux/init.h>
2 i/ H6 Q1 `3 L+ j! g
#include <linux/errno.h>
+ e) u e% J. Q* U: B& z* `3 P% d
#include <linux/types.h>
4 A4 {: r4 e3 n. @+ Z
#include <linux/interrupt.h>
& o' ]* F% f' f) Z
#include <asm/io.h>
2 A5 b- D/ I9 [
#include <linux/moduleparam.h>
3 N. \3 r% u, ?0 \* h# Z
#include <linux/sysctl.h>
/ P |) r2 @7 _- f9 ` H5 N9 x0 r
#include <linux/mm.h>
' \- b8 q4 q1 |% z& z
#include <linux/dma-mapping.h>
% F! q2 J. R2 Z
% A$ B- }* Y0 v; }, z! p0 F
#include <mach/memory.h>
) c' G0 {1 o0 ], q
#include <mach/hardware.h>
2 k. p+ F3 F2 ?% p8 V F! Y
#include <mach/irqs.h>
2 R$ a. v; O! c/ H1 x
#include <asm/hardware/edma.h>
, L) Z/ X, Z3 O' k: e
% v) G$ r% k- D$ R" o/ a4 @* y
#undef EDMA3_DEBUG
% F4 k( W# y; K1 g; ~; N
/*#define EDMA3_DEBUG*/
8 L% k5 ]$ e- b2 g+ |% U' g- l* @
# n0 k. J" l3 Y9 H0 O' S" U
#ifdef EDMA3_DEBUG
; {9 k, z1 E4 d9 h" L
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 g3 Z8 Z, `# Z0 l% E$ X# b
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: }9 e e! k. l# ]" a* A
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. i, t+ i g; C8 l7 h
#else
* l& n/ A5 o, R( T" J
#define DMA_PRINTK( x... )
# }- X3 ^% k( _. k/ i6 ^5 r
#define DMA_FN_IN
; a# C2 H$ F* y C+ S
#define DMA_FN_OUT
; e0 j& \) n5 ^% R
#endif
5 ]- h! x# |& d& f/ S! ^
5 u z. _9 t X( T1 m
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
, }' `: U* d/ n1 {$ G* K0 O g# u. `
#define STATIC_SHIFT 3
J" X2 c a/ P% x
#define TCINTEN_SHIFT 20
: g$ ]0 i# B/ ]" t! |4 y( c0 l
#define ITCINTEN_SHIFT 21
$ d5 K9 W K. ~6 Y6 `/ A
#define TCCHEN_SHIFT 22
8 z' ]% p# x, ]/ o. d
#define ITCCHEN_SHIFT 23
! j7 L8 s P8 z
3 L" F% c2 l8 h" W
static volatile int irqraised1 = 0;
8 n* W& b) z4 h& p* n2 Q
static volatile int irqraised2 = 0;
) u3 k6 N# J+ ~; [: h4 K
4 M% ]+ Z4 g/ U
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 L* ~5 ?" l. @7 D
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) q* B) S4 }" m
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 {& e6 n# h7 P- E* j% [5 p7 @
& w6 T7 }! F7 ~9 r5 v
dma_addr_t dmaphyssrc1 = 0;
/ s% e9 A8 e8 o* n
dma_addr_t dmaphyssrc2 = 0;
3 a2 X2 L3 L3 U- S6 G" T
dma_addr_t dmaphysdest1 = 0;
/ w* y0 r8 Z) F8 B
dma_addr_t dmaphysdest2 = 0;
' ?# o4 T8 O9 I) A
: G. K( K' h' v/ M& }/ A
char *dmabufsrc1 = NULL;
' [' F3 w; L7 F
char *dmabufsrc2 = NULL;
8 M: g2 j, }, `$ l: K" k$ p h& g0 d" b
char *dmabufdest1 = NULL;
, e/ U: e0 W% i9 i7 H: z
char *dmabufdest2 = NULL;
- f& M: Y/ L/ O& i$ ?
- X4 }5 g* ~2 O4 e& j8 L
static int acnt = 512;
# {4 t, t5 N, I
static int bcnt = 8;
$ R" l6 P- f( q
static int ccnt = 8;
* m8 C0 {# s0 ?) A" R: R
* X, g$ n+ V) j2 `4 B! [* u
module_param(acnt, int, S_IRUGO);
! \, {# x' i: A3 x3 {0 w
module_param(bcnt, int, S_IRUGO);
3 e* N6 Y9 W1 j7 G8 p3 [
module_param(ccnt, int, S_IRUGO);
复制代码
d2 r" R0 o: M, o# h
2 ?+ f7 s J" _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 Q' X. i! L3 |! T3 X
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 x/ Z' g7 \3 e0 r1 @+ z$ _6 y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 X6 [2 j* K& q% f' M) m
2 e- g+ J3 h2 E
; A( \9 i% s* f! i9 a9 o- m1 O
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4