嵌入式开发者社区

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

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 O* Z8 p5 k9 [( M4 f
  1. [code]EDMA sample test application. r+ Z/ |3 u8 N8 J# Y( `" W& |& ?
  2. /*
    ! |# q5 }8 l; o$ g/ W8 C; [! B4 _
  3. * edma_test.c" l1 _9 s( B9 P# C9 y
  4. *: h8 F8 Z2 T9 L+ c) X
  5. * brief  EDMA3 Test Application9 g& z" I& F/ o4 s
  6. *3 u6 W+ ~7 r. I" Y2 N) X, j& l7 l
  7. *   This file contains EDMA3 Test code.
    1 T6 J) w  @0 [# x6 \6 _  H
  8. *" c, s/ X# }+ X9 K% F* L
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! T3 S" M2 w( n! D. m0 l+ H! `
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
    ( G+ B) X1 B3 J8 w2 f
  11. *         TO CHANGE.
    , T0 j, i8 |' r! [  D( x- X; r$ E
  12. *
    3 R/ L) f2 T, _1 x, G& D3 \
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
    " K+ @% d9 {* G8 q
  14. *: X/ s. L" b4 P- s! I
  15. * This program is free software; you can redistribute it and/or
    3 G) X! K2 I6 J
  16. * modify it under the terms of the GNU General Public License as1 O8 M5 H0 {6 c8 \: n
  17. * published by the Free Software Foundation version 2.; b) k) E' p% v! o1 Y
  18. *0 B' ^$ h& ]. _. F/ q
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any. ]7 c( _/ e( ~* [8 c! _
  20. * kind, whether express or implied; without even the implied warranty7 T! q( a- `% U/ a+ i
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the. c* x  J0 ?$ k9 G+ O( O
  22. * GNU General Public License for more details.
    7 ]7 b  \9 J$ p4 s$ B" @) P
  23. */
    1 l2 z: l% c" w8 V' J* u! d" I2 w

  24. ! ^, s9 L: X" V( @: }6 G* ^
  25. #include <linux/module.h>! g9 P) t$ k" o
  26. #include <linux/init.h>
    " Q  [1 z9 I' I5 k0 ?; E# W* _% e
  27. #include <linux/errno.h>
    8 A) r3 p1 q4 T" K* G1 P
  28. #include <linux/types.h>
    / p5 u9 `" n5 s9 H" t5 l
  29. #include <linux/interrupt.h>
    6 D# c, @; b2 i: S, I' f
  30. #include <asm/io.h>
      y5 s2 D2 c2 Z1 ^
  31. #include <linux/moduleparam.h>
    4 y7 D  o! C! T8 d1 @4 q* c
  32. #include <linux/sysctl.h>
    8 @3 R+ c% R9 r7 b! ]. V. r; L' V
  33. #include <linux/mm.h>
    : m& r- A  _& D  R; Q) `
  34. #include <linux/dma-mapping.h>8 w1 B6 h5 T! e+ ^' N
  35. 4 T$ |* {, ?9 H5 d7 P7 V
  36. #include <mach/memory.h>
    + G2 Z, \- W6 I7 X  ^/ b- z& O4 K
  37. #include <mach/hardware.h>
    ) `; I4 [' d0 q3 [# x
  38. #include <mach/irqs.h>, K: |$ e) Q8 C* ]1 b4 S
  39. #include <asm/hardware/edma.h># q. j1 p8 g* V% u, `
  40. + O) b0 @5 t2 Z* ~9 P  s4 B
  41. #undef EDMA3_DEBUG
    & C* X9 s) F5 J1 I
  42. /*#define EDMA3_DEBUG*/, S( [% J# `" X
  43. ( T3 c& e! D7 b7 ]9 t( I/ ]7 o
  44. #ifdef EDMA3_DEBUG, P) w1 S# i& D
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 A0 k$ {4 {1 r
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- o: ?. {+ l. C
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): K4 E+ V0 Q: A& t- r) \3 `
  48. #else
    2 w; e! k% F) ]  K5 K  y
  49. #define DMA_PRINTK( x... )
    6 o( ?' C/ ]: x( }  i
  50. #define DMA_FN_IN
    ; h! w, a1 J% G
  51. #define DMA_FN_OUT4 [+ ^( G+ g  o# t) Z3 [
  52. #endif1 q; v$ u3 P6 z
  53. ' E, x. T; B4 w9 m8 l" p& S" i: v
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)
    ' v, }; n9 z+ w. B, X# S. _
  55. #define STATIC_SHIFT                34 P8 X3 o4 t- q7 M' h
  56. #define TCINTEN_SHIFT               20
    3 J/ R  V. c1 F
  57. #define ITCINTEN_SHIFT              21% N# A8 Q& I9 S2 \
  58. #define TCCHEN_SHIFT                22% ~/ a% `" e0 a; f3 v* E  b
  59. #define ITCCHEN_SHIFT               23# t2 I  \8 E* E# a

  60. . W0 Q, e' G/ {) g0 u
  61. static volatile int irqraised1 = 0;* C! }$ \! i  _& L( h5 p: W9 X) p4 H1 w
  62. static volatile int irqraised2 = 0;
    - b* ]/ [1 }9 E# {8 n
  63. " M+ Y7 s+ o5 q  M$ X
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    2 @! ]" W: D* |$ b/ F6 K3 K& r
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' \% D- X3 Q- W4 x
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. d4 k3 k" u7 d7 B9 ^

  67. , s; l* a7 y+ f, G* t$ Z
  68. dma_addr_t dmaphyssrc1 = 0;, U' o9 z! P) u# A
  69. dma_addr_t dmaphyssrc2 = 0;# c. Z3 N. Z' P9 q. J
  70. dma_addr_t dmaphysdest1 = 0;
    & D- b! O0 v+ c6 S1 }# i
  71. dma_addr_t dmaphysdest2 = 0;! Q. b+ s1 G! E7 h, Q
  72. + N' }8 r0 A, j; p: @2 }
  73. char *dmabufsrc1 = NULL;5 J  y5 G  Q; N5 l
  74. char *dmabufsrc2 = NULL;$ V- M  K9 S$ o# w8 C+ }
  75. char *dmabufdest1 = NULL;% A" A$ j3 A8 y9 |( ]0 |
  76. char *dmabufdest2 = NULL;
    6 t7 t  m: [8 X( J8 s
  77. ! v: y( z. [6 G, O
  78. static int acnt = 512;/ W4 I' l2 H0 R5 q
  79. static int bcnt = 8;
    0 ?2 O- k# d8 K- k  C, Y
  80. static int ccnt = 8;
    7 h- `& R) z; {; @
  81. 4 R) t. V0 D& n' }- h) q) A
  82. module_param(acnt, int, S_IRUGO);
    $ }* \5 Y6 ^8 S  |
  83. module_param(bcnt, int, S_IRUGO);
    " C& l8 T& r( \& y' d0 J1 X6 E
  84. module_param(ccnt, int, S_IRUGO);
复制代码

5 H, O: [6 m/ A3 q5 y( r
. c$ e+ a! H5 F% K( C7 d% S      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ o+ L( d8 K$ L$ b/ ^* _; N
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. l3 F* C/ a4 R' C7 e
     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ o8 ]8 _7 [4 b! `+ p$ J# K
' @$ H: ~" N# j5 J) E& F" l- x* X

- _; P0 i0 S7 U9 n# i




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