嵌入式开发者社区

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

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 D0 H( P! B0 k" U/ W
  1. [code]EDMA sample test application
    # X, ]8 ^: ?" Y6 C) C' V- F* u+ o% g+ s
  2. /*
    & d9 v( W% z6 k
  3. * edma_test.c7 C, @- }+ u; E& `
  4. *& I* ~! s3 r) Y  b9 F# W
  5. * brief  EDMA3 Test Application
    : X1 q+ x6 w  e5 T0 c: i* ?
  6. *2 N% D5 U2 g) @
  7. *   This file contains EDMA3 Test code.
    + w+ D3 _" [! n3 {$ a8 n
  8. *) G5 d/ s+ Y' ]5 V6 v. d1 E0 {$ c- t
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
    & p+ L, j( ]2 v5 V4 u+ n
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, A  J. @% Z% i/ c0 H* c3 n! b
  11. *         TO CHANGE.* M: `9 T( w2 J7 I$ |1 {
  12. *, Q3 `- e7 z" L; l- }& g8 w
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
    - u6 h6 h' _" w  O, z7 V/ q
  14. *- K' i" Q% W) i+ `6 u
  15. * This program is free software; you can redistribute it and/or+ M( ]$ k. ^# d
  16. * modify it under the terms of the GNU General Public License as6 _8 C- X2 k. U6 s2 }
  17. * published by the Free Software Foundation version 2.
    7 O0 u$ u0 j4 `: `+ D" ~4 A6 Q* O
  18. *
    3 @0 `/ [7 C' c9 }) g
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 `: u; n# \) E0 p
  20. * kind, whether express or implied; without even the implied warranty# J3 e% @+ g4 B/ _* f  f& W
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the. [& v2 J1 l' i# L! V) B& E
  22. * GNU General Public License for more details.
    ; k/ N4 r7 }! H9 w  S
  23. */
    # q5 P/ |- |5 V! |% L

  24. : Q/ r6 F: h* [4 M! d5 a' P
  25. #include <linux/module.h>. U7 `2 ^% d" a3 A. I
  26. #include <linux/init.h>2 i/ H6 Q1 `3 L+ j! g
  27. #include <linux/errno.h>+ e) u  e% J. Q* U: B& z* `3 P% d
  28. #include <linux/types.h>4 A4 {: r4 e3 n. @+ Z
  29. #include <linux/interrupt.h>
    & o' ]* F% f' f) Z
  30. #include <asm/io.h>
    2 A5 b- D/ I9 [
  31. #include <linux/moduleparam.h>
    3 N. \3 r% u, ?0 \* h# Z
  32. #include <linux/sysctl.h>
    / P  |) r2 @7 _- f9 `  H5 N9 x0 r
  33. #include <linux/mm.h>
    ' \- b8 q4 q1 |% z& z
  34. #include <linux/dma-mapping.h>% F! q2 J. R2 Z
  35. % A$ B- }* Y0 v; }, z! p0 F
  36. #include <mach/memory.h>) c' G0 {1 o0 ], q
  37. #include <mach/hardware.h>
    2 k. p+ F3 F2 ?% p8 V  F! Y
  38. #include <mach/irqs.h>
    2 R$ a. v; O! c/ H1 x
  39. #include <asm/hardware/edma.h>
    , L) Z/ X, Z3 O' k: e
  40. % v) G$ r% k- D$ R" o/ a4 @* y
  41. #undef EDMA3_DEBUG
    % F4 k( W# y; K1 g; ~; N
  42. /*#define EDMA3_DEBUG*/
    8 L% k5 ]$ e- b2 g+ |% U' g- l* @
  43. # n0 k. J" l3 Y9 H0 O' S" U
  44. #ifdef EDMA3_DEBUG
    ; {9 k, z1 E4 d9 h" L
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 g3 Z8 Z, `# Z0 l% E$ X# b
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
    : }9 e  e! k. l# ]" a* A
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). i, t+ i  g; C8 l7 h
  48. #else* l& n/ A5 o, R( T" J
  49. #define DMA_PRINTK( x... )
    # }- X3 ^% k( _. k/ i6 ^5 r
  50. #define DMA_FN_IN
    ; a# C2 H$ F* y  C+ S
  51. #define DMA_FN_OUT
    ; e0 j& \) n5 ^% R
  52. #endif5 ]- h! x# |& d& f/ S! ^

  53. 5 u  z. _9 t  X( T1 m
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)
    , }' `: U* d/ n1 {$ G* K0 O  g# u. `
  55. #define STATIC_SHIFT                3
      J" X2 c  a/ P% x
  56. #define TCINTEN_SHIFT               20: g$ ]0 i# B/ ]" t! |4 y( c0 l
  57. #define ITCINTEN_SHIFT              21$ d5 K9 W  K. ~6 Y6 `/ A
  58. #define TCCHEN_SHIFT                228 z' ]% p# x, ]/ o. d
  59. #define ITCCHEN_SHIFT               23! j7 L8 s  P8 z
  60. 3 L" F% c2 l8 h" W
  61. static volatile int irqraised1 = 0;
    8 n* W& b) z4 h& p* n2 Q
  62. static volatile int irqraised2 = 0;
    ) u3 k6 N# J+ ~; [: h4 K
  63. 4 M% ]+ Z4 g/ U
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 L* ~5 ?" l. @7 D
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) q* B) S4 }" m
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 {& e6 n# h7 P- E* j% [5 p7 @

  67. & w6 T7 }! F7 ~9 r5 v
  68. dma_addr_t dmaphyssrc1 = 0;
    / s% e9 A8 e8 o* n
  69. dma_addr_t dmaphyssrc2 = 0;3 a2 X2 L3 L3 U- S6 G" T
  70. dma_addr_t dmaphysdest1 = 0;
    / w* y0 r8 Z) F8 B
  71. dma_addr_t dmaphysdest2 = 0;' ?# o4 T8 O9 I) A
  72. : G. K( K' h' v/ M& }/ A
  73. char *dmabufsrc1 = NULL;
    ' [' F3 w; L7 F
  74. char *dmabufsrc2 = NULL;8 M: g2 j, }, `$ l: K" k$ p  h& g0 d" b
  75. char *dmabufdest1 = NULL;, e/ U: e0 W% i9 i7 H: z
  76. char *dmabufdest2 = NULL;
    - f& M: Y/ L/ O& i$ ?

  77. - X4 }5 g* ~2 O4 e& j8 L
  78. static int acnt = 512;
    # {4 t, t5 N, I
  79. static int bcnt = 8;$ R" l6 P- f( q
  80. static int ccnt = 8;
    * m8 C0 {# s0 ?) A" R: R

  81. * X, g$ n+ V) j2 `4 B! [* u
  82. module_param(acnt, int, S_IRUGO);! \, {# x' i: A3 x3 {0 w
  83. module_param(bcnt, int, S_IRUGO);
    3 e* N6 Y9 W1 j7 G8 p3 [
  84. module_param(ccnt, int, S_IRUGO);
复制代码
  d2 r" R0 o: M, o# h

2 ?+ f7 s  J" _      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 Q' X. i! L3 |! T3 Xarm-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 x/ Z' g7 \3 e0 r1 @+ z$ _6 y     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 X6 [2 j* K& q% f' M) m2 e- g+ J3 h2 E

; A( \9 i% s* f! i9 a9 o- m1 O




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