嵌入式开发者社区
标题:
OMAPL138如何在Linux下使用EDMA3驱动
[打印本页]
作者:
yyj
时间:
2018-1-30 11:01
标题:
OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 O* Z8 p5 k9 [( M4 f
[code]EDMA sample test application
. r+ Z/ |3 u8 N8 J# Y( `" W& |& ?
/*
! |# q5 }8 l; o$ g/ W8 C; [! B4 _
* edma_test.c
" l1 _9 s( B9 P# C9 y
*
: h8 F8 Z2 T9 L+ c) X
* brief EDMA3 Test Application
9 g& z" I& F/ o4 s
*
3 u6 W+ ~7 r. I" Y2 N) X, j& l7 l
* This file contains EDMA3 Test code.
1 T6 J) w @0 [# x6 \6 _ H
*
" c, s/ X# }+ X9 K% F* L
* NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! T3 S" M2 w( n! D. m0 l+ H! `
* REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( G+ B) X1 B3 J8 w2 f
* TO CHANGE.
, T0 j, i8 |' r! [ D( x- X; r$ E
*
3 R/ L) f2 T, _1 x, G& D3 \
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" K+ @% d9 {* G8 q
*
: X/ s. L" b4 P- s! I
* This program is free software; you can redistribute it and/or
3 G) X! K2 I6 J
* modify it under the terms of the GNU General Public License as
1 O8 M5 H0 {6 c8 \: n
* published by the Free Software Foundation version 2.
; b) k) E' p% v! o1 Y
*
0 B' ^$ h& ]. _. F/ q
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
. ]7 c( _/ e( ~* [8 c! _
* kind, whether express or implied; without even the implied warranty
7 T! q( a- `% U/ a+ i
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. c* x J0 ?$ k9 G+ O( O
* GNU General Public License for more details.
7 ]7 b \9 J$ p4 s$ B" @) P
*/
1 l2 z: l% c" w8 V' J* u! d" I2 w
! ^, s9 L: X" V( @: }6 G* ^
#include <linux/module.h>
! g9 P) t$ k" o
#include <linux/init.h>
" Q [1 z9 I' I5 k0 ?; E# W* _% e
#include <linux/errno.h>
8 A) r3 p1 q4 T" K* G1 P
#include <linux/types.h>
/ p5 u9 `" n5 s9 H" t5 l
#include <linux/interrupt.h>
6 D# c, @; b2 i: S, I' f
#include <asm/io.h>
y5 s2 D2 c2 Z1 ^
#include <linux/moduleparam.h>
4 y7 D o! C! T8 d1 @4 q* c
#include <linux/sysctl.h>
8 @3 R+ c% R9 r7 b! ]. V. r; L' V
#include <linux/mm.h>
: m& r- A _& D R; Q) `
#include <linux/dma-mapping.h>
8 w1 B6 h5 T! e+ ^' N
4 T$ |* {, ?9 H5 d7 P7 V
#include <mach/memory.h>
+ G2 Z, \- W6 I7 X ^/ b- z& O4 K
#include <mach/hardware.h>
) `; I4 [' d0 q3 [# x
#include <mach/irqs.h>
, K: |$ e) Q8 C* ]1 b4 S
#include <asm/hardware/edma.h>
# q. j1 p8 g* V% u, `
+ O) b0 @5 t2 Z* ~9 P s4 B
#undef EDMA3_DEBUG
& C* X9 s) F5 J1 I
/*#define EDMA3_DEBUG*/
, S( [% J# `" X
( T3 c& e! D7 b7 ]9 t( I/ ]7 o
#ifdef EDMA3_DEBUG
, P) w1 S# i& D
#define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 A0 k$ {4 {1 r
#define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- o: ?. {+ l. C
#define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: K4 E+ V0 Q: A& t- r) \3 `
#else
2 w; e! k% F) ] K5 K y
#define DMA_PRINTK( x... )
6 o( ?' C/ ]: x( } i
#define DMA_FN_IN
; h! w, a1 J% G
#define DMA_FN_OUT
4 [+ ^( G+ g o# t) Z3 [
#endif
1 q; v$ u3 P6 z
' E, x. T; B4 w9 m8 l" p& S" i: v
#define MAX_DMA_TRANSFER_IN_BYTES (32768)
' v, }; n9 z+ w. B, X# S. _
#define STATIC_SHIFT 3
4 P8 X3 o4 t- q7 M' h
#define TCINTEN_SHIFT 20
3 J/ R V. c1 F
#define ITCINTEN_SHIFT 21
% N# A8 Q& I9 S2 \
#define TCCHEN_SHIFT 22
% ~/ a% `" e0 a; f3 v* E b
#define ITCCHEN_SHIFT 23
# t2 I \8 E* E# a
. W0 Q, e' G/ {) g0 u
static volatile int irqraised1 = 0;
* C! }$ \! i _& L( h5 p: W9 X) p4 H1 w
static volatile int irqraised2 = 0;
- b* ]/ [1 }9 E# {8 n
" M+ Y7 s+ o5 q M$ X
int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 @! ]" W: D* |$ b/ F6 K3 K& r
int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' \% D- X3 Q- W4 x
int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. d4 k3 k" u7 d7 B9 ^
, s; l* a7 y+ f, G* t$ Z
dma_addr_t dmaphyssrc1 = 0;
, U' o9 z! P) u# A
dma_addr_t dmaphyssrc2 = 0;
# c. Z3 N. Z' P9 q. J
dma_addr_t dmaphysdest1 = 0;
& D- b! O0 v+ c6 S1 }# i
dma_addr_t dmaphysdest2 = 0;
! Q. b+ s1 G! E7 h, Q
+ N' }8 r0 A, j; p: @2 }
char *dmabufsrc1 = NULL;
5 J y5 G Q; N5 l
char *dmabufsrc2 = NULL;
$ V- M K9 S$ o# w8 C+ }
char *dmabufdest1 = NULL;
% A" A$ j3 A8 y9 |( ]0 |
char *dmabufdest2 = NULL;
6 t7 t m: [8 X( J8 s
! v: y( z. [6 G, O
static int acnt = 512;
/ W4 I' l2 H0 R5 q
static int bcnt = 8;
0 ?2 O- k# d8 K- k C, Y
static int ccnt = 8;
7 h- `& R) z; {; @
4 R) t. V0 D& n' }- h) q) A
module_param(acnt, int, S_IRUGO);
$ }* \5 Y6 ^8 S |
module_param(bcnt, int, S_IRUGO);
" C& l8 T& r( \& y' d0 J1 X6 E
module_param(ccnt, int, S_IRUGO);
复制代码
5 H, O: [6 m/ A3 q5 y( r
. c$ e+ a! H5 F% K( C7 d% S
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ o+ L( d8 K$ L$ b/ ^* _; N
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. l3 F* C/ a4 R' C7 e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ o8 ]8 _7 [4 b! `+ p$ J# K
' @$ H: ~" N# j5 J) E& F" l- x* X
- _; P0 i0 S7 U9 n# i
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4