嵌入式开发者社区

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

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. m: u4 d1 _8 H; G2 c( C
  1. [code]EDMA sample test application2 ~( a! _" q8 ?3 \# y
  2. /*
    - q! h7 x! L3 A  |7 g2 l
  3. * edma_test.c, j- G4 C# ~0 R& P, P% V. a- s; y
  4. *
    1 H. X3 R' ^, }& m, i7 ~
  5. * brief  EDMA3 Test Application
    1 F% i0 X2 e, b/ v+ B4 m; h  V- I
  6. *, q8 {/ E! m. e% C
  7. *   This file contains EDMA3 Test code.
    7 _; f( N4 A! h8 i
  8. *4 G/ I/ d& R% x/ ]2 _3 ?. f
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( ~( Y- ^: a0 _7 `7 l. ], T
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& b2 X0 c7 @! M+ B' C
  11. *         TO CHANGE.0 x/ Z2 u. `& x9 r+ [( M3 x
  12. *
    . ]9 g; D1 L+ V/ B
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 K( f" q& h2 ?- E  r0 k; P) d. d
  14. *" c9 b' M6 _! B5 V  V9 B
  15. * This program is free software; you can redistribute it and/or* p! E* }, o/ z8 g" J
  16. * modify it under the terms of the GNU General Public License as  Q/ Y6 L, F1 m! U9 U
  17. * published by the Free Software Foundation version 2.
    , f( y" @/ Q8 Y1 S  a
  18. *$ N% B; H1 m  k
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 m4 F, t( G& n5 r
  20. * kind, whether express or implied; without even the implied warranty1 F: Y1 _  w/ _$ v; M6 T  x4 H7 J( E
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    ) t0 X5 A8 G0 e) ]
  22. * GNU General Public License for more details.. J$ V& Y) m. f2 @6 R
  23. */: [: r3 g' a4 q! Q5 |

  24. 8 [/ m  N3 v* f) V' A) D, ~4 W
  25. #include <linux/module.h>3 v: |6 E$ Z% S. |' t7 J$ _
  26. #include <linux/init.h>
    : S. y; n; N* ^# ~& f. d
  27. #include <linux/errno.h>$ n! e# z) G% U; x/ d
  28. #include <linux/types.h>5 z) Q' w3 z' g) d
  29. #include <linux/interrupt.h>
    , c- B$ _/ r: E8 N
  30. #include <asm/io.h>- M  O! c: e! Q1 B4 i
  31. #include <linux/moduleparam.h>
    / ]& w5 H6 v& W5 r, g
  32. #include <linux/sysctl.h>
    & C! i  z. I% b- a: p$ _# o: l. A
  33. #include <linux/mm.h>* T: z: V! j+ W3 _( u$ T& h  E* T
  34. #include <linux/dma-mapping.h>
    & K9 {( P/ X3 W) Y; K: Z! \0 h3 z
  35. + s- e' a. p& Z' n# _) m/ z) q
  36. #include <mach/memory.h>2 m; i8 J2 D, F" M3 _+ L" V6 E/ u2 B' v
  37. #include <mach/hardware.h>' V. _" {8 q+ A( _
  38. #include <mach/irqs.h>2 s# s$ V7 _) e6 F0 J
  39. #include <asm/hardware/edma.h>
    3 e  Q9 \+ {' l1 C
  40. , z4 q, ^  z, }- K7 o& S
  41. #undef EDMA3_DEBUG9 v. w1 [% s3 ]# a, T
  42. /*#define EDMA3_DEBUG*/
    " q: I7 v) m- O; K; v7 b6 V- ?  }
  43. 5 N% ?  X" M; X3 Q
  44. #ifdef EDMA3_DEBUG. L& F5 A6 H# K
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! {) G' h1 o  P
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
    # N& N! Y  a6 j1 o  ~+ n
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
      ]; w& P* J0 m3 x9 c1 x* c
  48. #else
    . W2 Y( M8 k: [! n7 b
  49. #define DMA_PRINTK( x... )' f$ A8 G7 ^7 Y1 h, d% ~  x% {, Y
  50. #define DMA_FN_IN
    " D" j/ ~/ G# M8 B
  51. #define DMA_FN_OUT
    ) [' N8 W, P' \. g$ f% y( L1 z
  52. #endif% r( q6 [2 E' _2 L6 H+ q+ {

  53. 0 i! D/ V  G4 {7 R5 R5 r5 n
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)
    0 l# Q5 z" c* v/ h* U
  55. #define STATIC_SHIFT                3
    - c" v( Q. T0 x: ^- P
  56. #define TCINTEN_SHIFT               20
    % ?  H* f% T( q% o/ T. y  J
  57. #define ITCINTEN_SHIFT              211 m: Y/ N) P) V# x, ?% K
  58. #define TCCHEN_SHIFT                22
    + n0 W% {% l1 o8 ]2 E
  59. #define ITCCHEN_SHIFT               23/ i: n' x5 p' I' a
  60. $ |2 h, p; E; Q1 @' e. G! Y
  61. static volatile int irqraised1 = 0;
    9 D5 X, t. A& i5 p5 p5 u
  62. static volatile int irqraised2 = 0;
    , H, g/ s6 p/ z! H, k; S* b5 X3 F

  63. , s. a, i5 O( P' ~$ j7 \8 \0 w
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 V' s- `2 X' |8 \. e5 ]
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 Q  D; R5 B  K; W; ~! R
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 z$ h" ]$ U/ }! ~3 J. f6 B
  67. & o7 c5 c  A* H; f
  68. dma_addr_t dmaphyssrc1 = 0;
      G" b! r" U4 y, K, v
  69. dma_addr_t dmaphyssrc2 = 0;6 n$ Y( [/ Z3 Z! _7 f& B: ^
  70. dma_addr_t dmaphysdest1 = 0;
    4 h$ X& h2 `1 E% w
  71. dma_addr_t dmaphysdest2 = 0;4 L6 |! w$ r% y8 g; l
  72. ( o. e+ \2 |, L! U* L
  73. char *dmabufsrc1 = NULL;, r# ?( t; [/ Y" s) t, _
  74. char *dmabufsrc2 = NULL;8 A" m2 U, N9 a* U6 g' _. {# t7 V
  75. char *dmabufdest1 = NULL;0 t# t9 Q( h( r
  76. char *dmabufdest2 = NULL;
    ! r% O) A: [: U  W* U/ a

  77. 6 E& F* {8 o( s9 e, S( z; a! X
  78. static int acnt = 512;! ]% H8 m2 O* `; a1 [
  79. static int bcnt = 8;
    " `! g- n2 p5 _& N' b- w$ {
  80. static int ccnt = 8;
    * e6 K; n& H: g6 b

  81. # I4 l9 Y% ]6 I6 u
  82. module_param(acnt, int, S_IRUGO);+ Y0 P/ r& `) q, \7 B
  83. module_param(bcnt, int, S_IRUGO);
    : Z* D) i7 \. c
  84. module_param(ccnt, int, S_IRUGO);
复制代码
( |- O, z# U& q- i9 n1 `

9 F& |7 [% r' m0 o# T      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ u  n* X5 @5 U' C% l  qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 w, r# t; a, x: w0 r     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! v6 f' T3 @; f4 f
  G0 v9 y3 Y! K8 Q2 E2 y' E
  R9 _( M$ n" N9 u6 _9 P





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