嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 m0 f2 {: l0 P' o8 h- q
[code]EDMA sample test application
' H' d1 n m* u* O1 E' ?# O
/*
6 l: e3 h1 T1 x8 t
* edma_test.c
/ W/ C' c2 P# o! O4 G
*
6 w6 V- R/ T+ l/ v
* brief EDMA3 Test Application
5 R1 { j# K% s( S8 z$ i" M* b
*
9 p" D9 g6 r# S
* This file contains EDMA3 Test code.
- G7 Y, G2 A/ G' N& x5 S5 K
*
/ C2 r& q2 x8 J! R; s& ]! ]
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) m8 a! Q( `. a$ T2 O W( D
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& g6 Q% z/ s6 G- y v4 g: ^: E) D$ e
* TO CHANGE.
& C# [7 D5 X1 B% d8 n
*
( k" ?5 {* g3 C; v3 T5 M7 T' s9 v
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 @0 u; y8 d6 G2 @" y
*
3 X4 g1 ?+ W- }* S C6 T2 M4 w
* This program is free software; you can redistribute it and/or
& G( y) a3 k! A/ q. t) w
* modify it under the terms of the GNU General Public License as
/ k6 L8 E+ ]$ S1 \8 ~& j
* published by the Free Software Foundation version 2.
7 R& x. w% C& R5 {4 E5 H9 u$ j- E
*
& t. @* ]1 y* O0 e
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
% V" D1 o& I+ l3 P3 t
* kind, whether express or implied; without even the implied warranty
, O4 P8 P) A6 o: t0 R' M2 O
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* n4 `5 G& Z1 `9 g9 K8 x5 D3 _
* GNU General Public License for more details.
$ p2 t4 k8 q2 W o8 k
*/
3 E' d4 O- \" k* p: `
# F4 G& K1 f! U1 \! Y
#include <linux/module.h>
v0 N1 L }# w' `" [
#include <linux/init.h>
3 u1 F+ [8 n% y' w
#include <linux/errno.h>
' F- Q7 [- K3 e2 }3 b
#include <linux/types.h>
5 |1 v9 T5 N. ~ L; o( V
#include <linux/interrupt.h>
, x$ y6 b' _) E# e) R& n6 S
#include <asm/io.h>
% X a' A+ t" w5 h( E
#include <linux/moduleparam.h>
. T* P9 }( E F
#include <linux/sysctl.h>
% K3 M) R# w" _. }" C6 g ?- t( F
#include <linux/mm.h>
+ ~3 ^ W0 `2 h6 J$ |$ ^
#include <linux/dma-mapping.h>
v) s9 J7 [. F/ o! Z8 ]6 {
* k: x; J5 W* J e+ Z$ q+ C
#include <mach/memory.h>
. }* I" b7 U/ Y/ M' k
#include <mach/hardware.h>
Q, ~# e% V9 P& M$ |2 A. e
#include <mach/irqs.h>
# \# T9 }' h% A) _' ^! z4 h- h
#include <asm/hardware/edma.h>
+ u5 }' C* U# k; W
" `9 |, r# \7 \ Y6 U% Y7 z" h
#undef EDMA3_DEBUG
) K- b3 |/ Y5 y
/*#define EDMA3_DEBUG*/
( s7 ^ O5 i! f, i: }- ^
; b! L) l& U' h" u' n# j
#ifdef EDMA3_DEBUG
( {7 Q( I0 G. `0 q' F
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
~$ y2 f. d. S; |. T: r) P
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! c' ]- O2 v) o9 w1 d
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: C! f" O2 E# L3 q s
#else
- f% _& t. [! }& S6 a
#define DMA_PRINTK( x... )
; `3 Y+ R) L& k
#define DMA_FN_IN
: c5 P" I/ p% t; O! t
#define DMA_FN_OUT
; z& @7 @0 e& V1 I- m9 ~0 l
#endif
6 u( [$ Z$ s! z* k, _
$ G, A I2 l1 L2 Q# |; o% ~6 n1 W
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
) H! i& P2 g6 u0 H5 A& P, M
#define STATIC_SHIFT 3
0 \! {0 W9 N$ G' p# p
#define TCINTEN_SHIFT 20
- Q4 k: u5 y% c$ ~
#define ITCINTEN_SHIFT 21
3 ` p/ {3 {/ x5 L7 U
#define TCCHEN_SHIFT 22
2 B: H7 ~& Y# [, B8 Z3 [+ R
#define ITCCHEN_SHIFT 23
5 e$ w' [$ {; ~; ` {" T5 i" J, j
* t! z) Q U; x' e- `1 o( G3 j
static volatile int irqraised1 = 0;
9 G$ y6 z6 m5 f+ u+ M3 Z
static volatile int irqraised2 = 0;
9 z7 A2 W a' f4 k. @
, W, B2 H+ L% y" I9 }" y& ]
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 V5 G/ d7 H; i
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 ?$ {& U! a9 X- h
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( }$ s4 r- l ?+ a; R( s: A$ y& b
. ?) D4 `, K6 ~3 B7 z3 T
dma_addr_t dmaphyssrc1 = 0;
6 r+ ?; a |( A: Q1 U: k; ?) v: _' ^
dma_addr_t dmaphyssrc2 = 0;
. d5 }3 T5 e4 k
dma_addr_t dmaphysdest1 = 0;
# ?/ V$ {' p5 _+ Q& Y+ b
dma_addr_t dmaphysdest2 = 0;
8 ?3 k% s3 o# S& V$ s
: c: D6 f, n: v
char *dmabufsrc1 = NULL;
5 v/ o% i& O5 N: R# o7 \; ~
char *dmabufsrc2 = NULL;
- i) K7 s& e- b0 |) u/ m
char *dmabufdest1 = NULL;
, K+ O9 B3 g1 P9 V
char *dmabufdest2 = NULL;
/ m" f- B/ _6 f3 e$ Z
5 o) }/ U& }$ O
static int acnt = 512;
: Y' O: k1 ^$ R7 {
static int bcnt = 8;
. ^+ |7 ]9 M1 W4 j- [
static int ccnt = 8;
, w8 R4 `' O U! o7 E
$ N! B* l5 L1 k+ a) W; }
module_param(acnt, int, S_IRUGO);
0 c3 Y* ] C/ r$ n
module_param(bcnt, int, S_IRUGO);
, ?- f; H/ z3 F$ N
module_param(ccnt, int, S_IRUGO);
复制代码
- i) x% m$ g) U: U1 a
) u2 Q2 C1 S% f% Q) X
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& e- d0 Q# ]& f: ^4 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 V4 }6 j: M9 ^4 V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: K( L$ D, `. }2 m" R: \# r# s
4 ]4 W8 Z+ y+ n# P4 L8 P ~
- y# b! c4 g: V$ p3 I
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4