嵌入式开发者社区

标题: OMAPL138如何在Linux下使用EDMA3驱动 [打印本页]

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & Y- e, l# g2 o! f/ G( k1 m
  1. [code]EDMA sample test application
    % ~, t6 Z* k# \% I; `4 t1 y
  2. /*1 P+ V5 _) \5 n  o7 v1 S: x; m" ^8 \
  3. * edma_test.c
    9 K1 _. j% E" J; e% X+ Z& T. W. U
  4. *: r: `5 t3 G: U
  5. * brief  EDMA3 Test Application
    # [8 K* |/ U( g
  6. *
    : j1 Y' p# ]" ~& l6 G5 p+ B% B
  7. *   This file contains EDMA3 Test code.
    5 s7 U/ k) S/ E
  8. *
    # _* h, E3 o; Q
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE  K0 d& X+ e% @) q, i
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
    : ]" v: p: w6 ]$ ^
  11. *         TO CHANGE.3 K( f1 |. p  e* |2 ~1 D
  12. *1 T" ?9 m5 N1 p( l4 I& R$ C
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
    & o6 |* ]+ t5 o% N  E" d3 W
  14. *& S" U/ K1 ?' m: ^) s
  15. * This program is free software; you can redistribute it and/or
    ) D1 `( w3 p; A8 n. g6 P
  16. * modify it under the terms of the GNU General Public License as
      ~. F) i: `7 J2 T4 a8 H/ o
  17. * published by the Free Software Foundation version 2.
    0 k8 s6 ^0 v% z" ~: L$ |9 ]" E3 i/ J
  18. *1 h1 l4 e/ ?' a* S2 e' Z* U
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
    $ F; `9 g7 _9 m8 p% a( v% u
  20. * kind, whether express or implied; without even the implied warranty
    # a% M" d/ Z8 V- ^/ n( Q7 Y
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the5 y0 K& n& S& G2 J
  22. * GNU General Public License for more details.
    ! L' j( n2 E' k2 ?* Z) H
  23. */+ D& o" _$ N0 A% Q
  24. ! C3 j2 `  O" B6 g
  25. #include <linux/module.h>0 F: A5 d' o; t# A! M
  26. #include <linux/init.h>: T) \! w# e! i- p( W: R
  27. #include <linux/errno.h>
      I2 b  ^/ w; D' S; J) P* y
  28. #include <linux/types.h>
    3 \4 ?4 X. z" Z, y& f
  29. #include <linux/interrupt.h>
    2 P7 M. Y4 b' u9 I; C* \+ G
  30. #include <asm/io.h>
    4 W- s/ l! Y7 E, C7 \! B! d
  31. #include <linux/moduleparam.h>- t% ?, \& }; P& k
  32. #include <linux/sysctl.h>! W7 }7 {$ g/ `; B, v6 E$ e
  33. #include <linux/mm.h>
    2 o; K, c7 B- j% i, X! ?# M
  34. #include <linux/dma-mapping.h>0 A6 b3 ~1 d2 R0 J# o- F
  35.   O4 Y2 m, j$ Q+ m: E0 L- ]
  36. #include <mach/memory.h>
    . e4 c$ K4 V* Z+ J
  37. #include <mach/hardware.h>
      O) u3 k/ U0 Y/ R' u% I4 x
  38. #include <mach/irqs.h>/ q( L1 T) Y. a8 ^& G
  39. #include <asm/hardware/edma.h>
    & p! n+ P+ T7 G* c5 E9 s* t& H; A

  40. + k1 \8 p- b) q
  41. #undef EDMA3_DEBUG' J% J8 S( p/ n& i/ g$ T
  42. /*#define EDMA3_DEBUG*/
    : s) L0 }; |- \& f$ H/ F# v
  43. 9 [  M" b( H. g& N* l1 K
  44. #ifdef EDMA3_DEBUG
    , P( j1 j( K! K3 z, O; v2 y& j
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
    . f1 Z- f# J" u' q
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! G9 S/ ^% T  @' [
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ m+ A7 d" O# V
  48. #else
    2 V' R8 U; a" T  \( l5 ^0 R$ d
  49. #define DMA_PRINTK( x... )# e: h% t9 j" I! f! l. m6 p5 k' j
  50. #define DMA_FN_IN+ d& K5 ]- ^2 `- K% D7 y
  51. #define DMA_FN_OUT
    & J! B& t* l/ u" t" f& }2 Q' I* a
  52. #endif$ R9 Y* m3 I8 a# r. g: C" h

  53. - I( ~" s# G" X  \% k& n+ ]6 E& J8 c
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)
    2 [; G$ e: \0 u: o& N7 d5 J( I' o
  55. #define STATIC_SHIFT                32 D7 ~: o1 F& Z7 o
  56. #define TCINTEN_SHIFT               205 u* J$ M' F6 U2 |( g9 y* B, l5 b
  57. #define ITCINTEN_SHIFT              214 H+ x6 R0 f  X2 G1 M! D
  58. #define TCCHEN_SHIFT                227 t( E$ y6 |$ H* H, B/ w
  59. #define ITCCHEN_SHIFT               23  q5 D# [# ^* f+ h  S! Y8 t( {

  60.   \; D* ^: f# ~( ~9 `; v
  61. static volatile int irqraised1 = 0;
    0 B6 N" f4 v' Z+ e
  62. static volatile int irqraised2 = 0;4 M/ _* @; i* H9 G; N& n. k& G

  63. ' i4 V% a" B7 d5 ]  X2 ~/ _
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    , v5 `0 P) e3 T( U8 U
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    $ R  O, t, Q* A% N) n) @
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( L5 f& U  ~; @7 k( o- ~

  67. & K4 Y# O5 S$ d' {$ O$ D
  68. dma_addr_t dmaphyssrc1 = 0;( e' h5 I8 @/ m; K8 l( G" U+ n# q) _
  69. dma_addr_t dmaphyssrc2 = 0;
    + C% T7 K+ h0 a3 c5 |9 x, u/ J
  70. dma_addr_t dmaphysdest1 = 0;
    3 L2 E. \5 c) {% P6 T$ L' J5 Z
  71. dma_addr_t dmaphysdest2 = 0;
    # ~' r8 H, t  C+ N% T) P) F' b
  72. 7 b( \; Y( K+ C* Q$ `1 l. p2 \4 R
  73. char *dmabufsrc1 = NULL;+ z# A, q! J( W3 b1 T: X) N4 y5 H' b
  74. char *dmabufsrc2 = NULL;& f3 J/ p! Z2 {" }  `
  75. char *dmabufdest1 = NULL;8 y* ^" M" B3 @0 @4 X$ h: w
  76. char *dmabufdest2 = NULL;  V  V( y  ?' K3 X* C" l% A8 _
  77. 7 M* ?" A; N+ \
  78. static int acnt = 512;: U+ e: D- w& f+ `/ V: T% Z, `
  79. static int bcnt = 8;
    / \" |! j) T  e4 s7 P" j7 l$ J
  80. static int ccnt = 8;2 V# b# T5 K- @

  81. 1 `7 u! A/ i6 L2 W  c" t9 u
  82. module_param(acnt, int, S_IRUGO);
    . x+ |9 x0 o9 I$ m" D( E, W/ O/ i( b) M
  83. module_param(bcnt, int, S_IRUGO);# w0 A. Z) i  z6 o; G+ A1 r
  84. module_param(ccnt, int, S_IRUGO);
复制代码
- N0 W9 ?& h5 D' j# n. Q

1 m0 J1 b: {, V- O1 E% B      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ c4 X  q$ C" H5 o* g2 h  e3 g. L/ karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% F5 c& R/ Q; y- |0 `$ I8 M' q& F
     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' i6 s. j: a9 [

/ S4 P8 U/ x) o, Q) X$ \
; c( O' @, G2 Z' U& v) m




欢迎光临 嵌入式开发者社区 (https://51dsp.net/) Powered by Discuz! X3.4