嵌入式开发者社区

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

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 r& S* @. h# h' j- H/ l! Q8 \. N
  1. [code]EDMA sample test application: q/ y1 ~7 a1 R
  2. /*9 d3 u7 C/ r3 b
  3. * edma_test.c( |! B7 @' Q; `# ~. I6 O! C1 h
  4. *$ r' V! r( {6 Y
  5. * brief  EDMA3 Test Application4 M/ w; l/ `( u; t) m
  6. *
    ; r" }8 T6 N0 E2 k; r1 y3 c. S* y
  7. *   This file contains EDMA3 Test code.0 z; F/ ~" ^8 [* v4 s+ y7 n. D
  8. *8 B  |8 A. x2 @$ R0 r
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
    * N- L' w( i! s' k1 C9 e2 k0 o  {
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
    * N+ P! l  J6 o" c" S4 Z4 I, Y
  11. *         TO CHANGE.
    $ f: f1 {; H0 Z
  12. *( E, ^( u6 b& ]$ D' H
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
    2 L" ?: D2 R: t! @5 \( s7 _7 b! U
  14. *
    6 I4 H* L6 Z3 _' C3 \
  15. * This program is free software; you can redistribute it and/or
    + G( J# C3 ]" f
  16. * modify it under the terms of the GNU General Public License as
    % h! u& B; j- P" S- [' z
  17. * published by the Free Software Foundation version 2.) L* M" O0 f* ^9 U
  18. *
      v6 G2 [' I1 q) ~$ a' F
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any& |. |, j/ ^: L6 K1 w# b( H
  20. * kind, whether express or implied; without even the implied warranty! P5 a/ f0 |, @, ?- h
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    % ~! [8 n) i. l' [+ Z  f3 V
  22. * GNU General Public License for more details.. Z- d* S) |6 V# R3 a8 p( w  u
  23. */0 u7 j. G! s, {$ T- J" Q
  24. & d5 N0 G% y+ c  O0 ]1 h) p" D7 w6 F$ K
  25. #include <linux/module.h>- ]( [9 ]! V) b  y$ l3 H9 i, q! J
  26. #include <linux/init.h>
    $ k- R$ |2 ?( U" _
  27. #include <linux/errno.h>
    * T) M$ t/ g' ~8 m9 X7 e$ S) s
  28. #include <linux/types.h>
    ) P% z) R. J* q9 Z9 g$ T, d/ T4 }
  29. #include <linux/interrupt.h>5 H. u- n* y8 l9 A7 O
  30. #include <asm/io.h>+ V6 L$ ~+ ]- i7 P* y# y2 x" x8 g
  31. #include <linux/moduleparam.h>
      v( M- x, }+ b: G5 @  X) ~1 {
  32. #include <linux/sysctl.h>
    0 a  T$ e' v; }7 R$ v/ Z
  33. #include <linux/mm.h>
    " }9 W# G. X- R% @2 {2 S
  34. #include <linux/dma-mapping.h>: z  o* A) l2 P7 |2 S; Z
  35.   `- v8 [" P+ W
  36. #include <mach/memory.h>7 x1 S% J/ A, f+ A0 B
  37. #include <mach/hardware.h>
    0 F' V0 E; }- J/ E1 ?
  38. #include <mach/irqs.h>
    ; V( b- L: f. o( [, g
  39. #include <asm/hardware/edma.h>2 k4 t& w# C5 e, v, B! E$ o
  40. - G" F+ Y# y" z
  41. #undef EDMA3_DEBUG" S& J4 W2 D! J
  42. /*#define EDMA3_DEBUG*/" f! {' K5 U1 A7 w% f+ V  O7 h

  43. ; C" c8 K9 T8 h/ `# s, @
  44. #ifdef EDMA3_DEBUG7 x/ s/ B; l; t0 F; Z8 C( s% n
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! M& T( _; w7 F2 F0 f
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)  r( U8 b+ q/ J) }0 u
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
    % g* I3 r$ c4 i2 t/ a+ q. h  f
  48. #else
    " e! w3 Y9 D! W
  49. #define DMA_PRINTK( x... )
    ! f2 z% e& T; t2 T  \/ X
  50. #define DMA_FN_IN9 Y9 p: ^# m' M" ~4 t/ \# J
  51. #define DMA_FN_OUT
    ( N- C7 Y2 R8 n" @  C9 d
  52. #endif
    ! S* G$ B$ h: `
  53. 6 s7 p% L: I7 s; b
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)
    2 a3 ^, k9 z0 ~( Q/ g
  55. #define STATIC_SHIFT                3
    ' ~5 l% [; M6 g1 H( Y  Y, h
  56. #define TCINTEN_SHIFT               201 ~8 w2 A9 H* u% x- i
  57. #define ITCINTEN_SHIFT              21
    ! [/ c& s* H# C$ j
  58. #define TCCHEN_SHIFT                22, {8 [. T  M% }6 c7 i" _, @% r
  59. #define ITCCHEN_SHIFT               234 \: P" X' j/ J2 Z& L/ Q4 J+ |

  60. ! K8 E7 i1 v: K) b
  61. static volatile int irqraised1 = 0;" V: R. ?. z4 E4 {$ E8 f
  62. static volatile int irqraised2 = 0;# }0 P5 u" h6 @; H; `

  63. + O& {! I* \- `8 r: r
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 U' i) [6 X4 L6 F0 @4 j
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    & S2 V/ o* ?# U# m' ]
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    ! F6 [+ [7 Q3 n

  67. ) }  S( N5 H/ Q9 N+ J5 {; M
  68. dma_addr_t dmaphyssrc1 = 0;' L% Y; ?$ ?+ \6 Q- N. F) C& a
  69. dma_addr_t dmaphyssrc2 = 0;- Z) ~9 `- Y: y" O$ F# [3 \
  70. dma_addr_t dmaphysdest1 = 0;7 R% k$ u% j3 B) L! y8 R
  71. dma_addr_t dmaphysdest2 = 0;
    ' u9 h- g+ v2 i7 S; W4 i  T
  72. ! }  B9 D% a$ v
  73. char *dmabufsrc1 = NULL;; d* G+ g/ N& T8 W+ l
  74. char *dmabufsrc2 = NULL;- R% R) r  i2 T( A
  75. char *dmabufdest1 = NULL;
    7 c+ w7 E2 E1 |" ?& {6 G
  76. char *dmabufdest2 = NULL;
    - s. q/ Q& b" p# s! m2 F

  77. ) k; y2 _# J! g  r0 t
  78. static int acnt = 512;0 S$ W0 o8 r( ?0 f  r8 T+ A7 n
  79. static int bcnt = 8;
    6 z, N$ O- H- I( `& y
  80. static int ccnt = 8;
    8 L1 R8 }2 g5 t" ?  K: A' ^
  81. ; y( @' b. A& W' {- Y6 a
  82. module_param(acnt, int, S_IRUGO);
    * w. B5 C# ~; Z9 T
  83. module_param(bcnt, int, S_IRUGO);
    & |2 \$ z6 c" l+ r$ z
  84. module_param(ccnt, int, S_IRUGO);
复制代码

3 j) ^/ K7 X3 ]# ^$ ~8 j" {
1 g! E9 \- h2 \, `# h. j2 Z$ ^      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ v. D, z% @, t+ `0 N9 G/ barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 K! i* U9 ~" w3 {  D
     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 Y: B- ^* ?! g2 L0 n$ P
; k& k; ?- e; f: m5 h

: N$ O: m4 u4 B$ F0 S




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