嵌入式开发者社区

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

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , L% V+ o# G; t6 C
  1. [code]EDMA sample test application* D4 c$ I8 W5 o  X' ]6 O$ O
  2. /*; E5 y) f7 h& V, o: z" m
  3. * edma_test.c" Z5 e7 }9 B0 H0 F0 U: ^* [  u
  4. *
    7 u; L' P' t, I4 \% S' p0 o
  5. * brief  EDMA3 Test Application# |( G; _# p# ]4 h3 [
  6. *4 z6 u; K3 D) L0 b
  7. *   This file contains EDMA3 Test code.
    0 P( D7 P6 {6 ^' ]% E3 A' a! v8 e5 T
  8. *
    1 X) P* I  T* Y) Y4 p* C) ?
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
    8 k, y4 ^8 h* X9 k
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
      T0 d5 A& z& t$ t) D
  11. *         TO CHANGE.  d0 _0 a5 i, C% ?' s' ^
  12. *
    & r' j4 J, E' k3 Z1 t' ?
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ x' p) x; J5 m$ m* g( N
  14. *
    ; k; P8 m$ C: ^$ S# o* z6 o
  15. * This program is free software; you can redistribute it and/or& o1 o6 b+ x' K
  16. * modify it under the terms of the GNU General Public License as
    " k2 R" E! F# `7 r% F" ?; E  U: [
  17. * published by the Free Software Foundation version 2.
      [8 B) B) C( m# w1 p  e  D
  18. *
      H7 }3 u& d# y  w  _; [
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
    ) A# M2 ~+ [) \& y% @: t8 G
  20. * kind, whether express or implied; without even the implied warranty
      g8 u9 J8 ?5 D( R* ]9 h; T
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the( M) B. g0 {7 y/ J) q0 P
  22. * GNU General Public License for more details.
    / ?; {& y8 c' m2 @7 Z
  23. */
    : A1 W8 |0 q1 o) h- V/ f# X

  24. . k- E. w2 Z% E" [9 E, J
  25. #include <linux/module.h>" J  \7 M2 x7 [7 R8 i
  26. #include <linux/init.h>1 O* N. t! e* [# c/ n8 C5 x
  27. #include <linux/errno.h>, a/ }: h6 U8 p+ G! H
  28. #include <linux/types.h>) g8 J/ d5 h* T/ X' Q; ^
  29. #include <linux/interrupt.h>2 T! p4 I$ T+ y, H# `9 V
  30. #include <asm/io.h>/ @% @" I* Z5 S! T% V, o
  31. #include <linux/moduleparam.h>
    - @# s6 N: s$ |
  32. #include <linux/sysctl.h>
    / m, R" y: ^" _! Q9 y
  33. #include <linux/mm.h>, U/ K2 g, S& {/ m
  34. #include <linux/dma-mapping.h>
    . e$ B2 _! T: E- }* e
  35. , W! j# \$ r6 M* M; [* ]8 _
  36. #include <mach/memory.h>( t5 P6 {3 x" m9 n( |; X
  37. #include <mach/hardware.h>
    ) R- ^/ c6 {) H, m
  38. #include <mach/irqs.h>
    6 z/ U: o2 D. M9 F, O8 w+ W/ s" _
  39. #include <asm/hardware/edma.h>$ A& n  n( z7 @1 U
  40. $ x6 V; S- {8 y  ?
  41. #undef EDMA3_DEBUG* c! `  s0 l# W  b. J
  42. /*#define EDMA3_DEBUG*/( d  U: `% t  o2 _8 n: V7 P3 j2 ]
  43. 6 R* u, g$ H) F) k. H
  44. #ifdef EDMA3_DEBUG- h4 ]2 V4 k% A* d/ n* y
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). O: U* _  |, J" D# n+ }
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
    6 a" r8 ^- @5 j7 Q7 R( t1 b
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
    $ G/ K9 }8 f5 ~( j2 x# z
  48. #else% m/ a) w+ |/ ?) e
  49. #define DMA_PRINTK( x... )2 p3 C; f. |5 g1 m5 P+ j. K' M
  50. #define DMA_FN_IN/ X( A0 k" l2 e$ Y% A2 n- w. q5 L, z
  51. #define DMA_FN_OUT
    % u: H2 i6 Y5 c: ~
  52. #endif0 i! h+ e/ N5 x# \& T5 J+ Z

  53. 2 V1 G+ S* M7 \$ K/ n# `
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)9 |8 j/ @; K" f9 S$ M
  55. #define STATIC_SHIFT                3' R. o, |. e% d) ~, r0 s
  56. #define TCINTEN_SHIFT               20* y$ n' ~5 w5 Q+ J- y* l6 E7 U
  57. #define ITCINTEN_SHIFT              21
    & I6 X' C% l+ M  J+ {
  58. #define TCCHEN_SHIFT                22& ~( |6 Q  V+ i+ g9 c  n
  59. #define ITCCHEN_SHIFT               23. n6 t4 C- m2 c
  60. 7 f; S" b: a6 j! l7 e; C
  61. static volatile int irqraised1 = 0;
    ! l1 }- M1 Y0 C' K) D
  62. static volatile int irqraised2 = 0;7 t. V, E" C* y4 [) E

  63. & f% J7 w  I. `) r8 P' G9 [! Y2 }
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% z* R0 K6 F' f1 H3 w+ V
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! A- G' P, N, U' O9 z
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& A, B' e  i! E" M0 W
  67. ' U  V* \7 x' P& i7 C
  68. dma_addr_t dmaphyssrc1 = 0;' L+ @( G- {* t7 b9 M0 h% u
  69. dma_addr_t dmaphyssrc2 = 0;
    ; f  a& @+ ?% @" I8 [4 I- k9 j/ r
  70. dma_addr_t dmaphysdest1 = 0;
    . h. N' b# m# Q7 k6 r% Z. t
  71. dma_addr_t dmaphysdest2 = 0;
    ; P) ]; f9 G0 t3 b. f

  72. , p% n: V: L: v5 e4 V% D. U% r
  73. char *dmabufsrc1 = NULL;
    4 }  W. F& K: H; M' V3 ]; n
  74. char *dmabufsrc2 = NULL;
    ! D/ D0 i  \2 ?
  75. char *dmabufdest1 = NULL;
    # O* j6 a, U; Z! I2 T& D/ X, V5 [
  76. char *dmabufdest2 = NULL;
    & a1 g$ w' }& c' |6 h; u8 o5 N3 T9 S
  77. 9 j: ]+ A; h* E# h2 T2 F! \2 ~
  78. static int acnt = 512;' p- `, \' y$ I# e! H0 q
  79. static int bcnt = 8;! h5 A  h$ M/ M3 f" V% u
  80. static int ccnt = 8;' S1 t* ]# R. `

  81. 6 ?2 Q) B1 h5 ~1 n2 @3 ?( G
  82. module_param(acnt, int, S_IRUGO);  \4 g+ c( `  i2 G
  83. module_param(bcnt, int, S_IRUGO);6 N5 u; |4 y! I7 d+ }, m1 [; z' t
  84. module_param(ccnt, int, S_IRUGO);
复制代码
& ~9 o! n5 z. t7 ?6 o5 C3 f: B

5 n8 ]4 }! g2 p: v+ t2 U- W# t      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 V4 T7 Z0 w/ V  \& g  i; d
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ D7 [1 E( w& K& u     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ |) d: u6 Z: j# b5 x+ W+ t3 ]( D3 {* E4 }( N1 K
0 D* b& O* @% v% t. L. R/ E





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