嵌入式开发者社区

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

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
  C( U+ V9 t2 I8 r: G' S% _
  1. [code]EDMA sample test application0 A  O( t. P; @/ R4 N
  2. /** F) g' A2 R7 h5 Y) U
  3. * edma_test.c
    3 X- j; o( u/ ^) ]) S2 _
  4. ** b1 [/ E. B- W
  5. * brief  EDMA3 Test Application
    / @- x- k! v# W( P" Q9 P2 ?
  6. *: v! W% \. N& A& k5 @) k) a
  7. *   This file contains EDMA3 Test code.
    ! S: Q4 V! _& ~9 X; L: i
  8. *
    . x5 e' G& y! U, Q, W8 _; w
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
    % t5 {# x- \& q0 _! v  `
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 u2 M% }0 \- z; P, n
  11. *         TO CHANGE.
    $ p8 c! R, ?' j: v: ?
  12. *' s. h5 h  @% d7 G1 r
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 g  i* `# t7 S5 f$ M. [9 f( [
  14. *
    4 ^  e8 M4 l$ H9 i! {8 t
  15. * This program is free software; you can redistribute it and/or5 f0 I# o9 n2 J! c( j
  16. * modify it under the terms of the GNU General Public License as
    1 ?: \5 X/ I5 h
  17. * published by the Free Software Foundation version 2.
    3 ~1 y2 G5 E; G
  18. *. [( _; ^! \5 h( U- g
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any( d4 X0 s! [+ x: z9 Y9 a
  20. * kind, whether express or implied; without even the implied warranty
    . q+ _  N, c) f# r5 G" f
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the& k7 r6 u0 L7 x6 u4 h" a) S' p
  22. * GNU General Public License for more details.: W2 I- x$ v& k* H+ L
  23. */  D& [. F5 i1 S, b

  24. 4 g; x3 Q. x: w2 X& B# P, i
  25. #include <linux/module.h>5 R) M* |& T( o* `# n
  26. #include <linux/init.h>
    & p  F/ a- @7 |0 e& J) _# D
  27. #include <linux/errno.h>
    2 V1 L0 R, n% p$ V
  28. #include <linux/types.h>
    2 |+ n7 P5 A; T  f
  29. #include <linux/interrupt.h>: I4 U3 H1 ]/ E7 b- u
  30. #include <asm/io.h>
      |- u2 p' b" ?/ E
  31. #include <linux/moduleparam.h>
    ! \: g, k' I/ o; l3 w* y
  32. #include <linux/sysctl.h>
    * F0 s) e" l, W. U8 |- C( B9 e
  33. #include <linux/mm.h>: E0 Z( m7 N5 \5 y5 n
  34. #include <linux/dma-mapping.h>
    2 K6 p! Y& D" M' E6 l  `: H% Z

  35. ! |* S. P# \: X: I* O# T' I0 X
  36. #include <mach/memory.h>' L, f' k1 g5 l6 q$ X
  37. #include <mach/hardware.h>) T- n% q3 r. f. C
  38. #include <mach/irqs.h>
      O# I% n: c% N  ~+ @( k5 d
  39. #include <asm/hardware/edma.h>( ?- Z: N  W2 t- N, v
  40. ; X. V! n% P" n1 J; L& t
  41. #undef EDMA3_DEBUG
    - z1 J- J7 Q# ~+ e- J; W& f8 G
  42. /*#define EDMA3_DEBUG*/
    4 u& y  o, H( ~$ t3 ]1 M7 E1 q
  43.   v+ A, z/ }: j& ]4 L5 k
  44. #ifdef EDMA3_DEBUG
    7 ?$ ?- ^. a" q9 h  `
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- M5 D7 A: e7 {  M
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% f2 f- z( {9 w5 P4 O
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
    " Z/ K( ?6 V; D! q4 b- n6 m# r
  48. #else
    $ G6 s& v# k$ S* h+ U1 H
  49. #define DMA_PRINTK( x... )0 V5 Y5 @/ @" m" T3 G$ _
  50. #define DMA_FN_IN
    6 I4 [4 n4 Z  \  q( n% x
  51. #define DMA_FN_OUT
    ; k" f! J4 h1 N3 H
  52. #endif
    ( g# |0 P# \: ]! L7 D7 i6 @; k$ N
  53.   H! h7 Z) q" L9 y* A  j
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)+ h1 X) l. c+ T
  55. #define STATIC_SHIFT                3
    / Z. y+ @0 f  v9 s3 D- F
  56. #define TCINTEN_SHIFT               20
    $ q1 t, r8 N+ b
  57. #define ITCINTEN_SHIFT              21
    8 c8 [7 Z1 s4 o( K
  58. #define TCCHEN_SHIFT                22+ a' B9 B" I0 f3 O/ f! p6 z
  59. #define ITCCHEN_SHIFT               232 D* m: n$ \, Z5 @2 O" \" L) Y

  60. " [) ]; t' X2 d$ M
  61. static volatile int irqraised1 = 0;
    0 q* O9 Y5 O( d. x3 Z
  62. static volatile int irqraised2 = 0;8 L2 @6 ?! i, c  y1 H# n) F/ X

  63. ( z" O6 u+ O# U3 u2 b5 }
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" I6 ~% e  Y3 i0 ~5 i7 h% F& d) ]; J! S
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    0 x) d. q& P( |
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 ]6 T' f2 {0 z  P, J( N

  67. + q! l  A: X% L! _5 a+ |
  68. dma_addr_t dmaphyssrc1 = 0;8 K8 a+ d# D. ?. Y& i: `3 [+ w7 c+ X
  69. dma_addr_t dmaphyssrc2 = 0;
    " q* n' T3 K( ^* I8 p6 N7 k- Q  d
  70. dma_addr_t dmaphysdest1 = 0;
    - Z' v6 r- R6 M- E1 Q6 _8 q) y
  71. dma_addr_t dmaphysdest2 = 0;* K& S2 I$ S* S3 I, S6 ^
  72. 5 v+ l$ U+ V. S) m
  73. char *dmabufsrc1 = NULL;
    4 B; O, X3 s+ D9 u, K8 B+ x, C
  74. char *dmabufsrc2 = NULL;/ D. b8 u. t+ _8 G# o
  75. char *dmabufdest1 = NULL;- `3 Y  `$ V' z7 f% z7 x# y% O
  76. char *dmabufdest2 = NULL;2 r  y" u& C& B8 I
  77. + ?$ H3 d7 @- }( W4 u" [5 D
  78. static int acnt = 512;6 T5 ]! I& e9 G
  79. static int bcnt = 8;; H" L& |, o) u. Q
  80. static int ccnt = 8;, c& l" R, W: Y7 J- X. {+ {' e

  81. 5 s: ]; H* M/ A. R8 _+ \3 l
  82. module_param(acnt, int, S_IRUGO);, R1 r  j. X  |) B
  83. module_param(bcnt, int, S_IRUGO);$ ]# a% Z9 ~$ M8 K# t$ i5 Q. t
  84. module_param(ccnt, int, S_IRUGO);
复制代码
. d+ W& q4 W) p! f! Z5 }

) h1 Y/ \: f% x( C1 T9 d" {      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; B: a/ d: B" ?3 Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 l" U8 K% J6 b0 o5 Q+ E: P
     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 f6 G6 h9 @0 _: l: Z6 F0 |

* s1 ?1 N* g. H9 _) x0 g8 g- K& ^. o2 y6 z7 ]7 ]; B" w





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