嵌入式开发者社区

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

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 m0 f2 {: l0 P' o8 h- q
  1. [code]EDMA sample test application
    ' H' d1 n  m* u* O1 E' ?# O
  2. /*6 l: e3 h1 T1 x8 t
  3. * edma_test.c
    / W/ C' c2 P# o! O4 G
  4. *
    6 w6 V- R/ T+ l/ v
  5. * brief  EDMA3 Test Application
    5 R1 {  j# K% s( S8 z$ i" M* b
  6. *
    9 p" D9 g6 r# S
  7. *   This file contains EDMA3 Test code.
    - G7 Y, G2 A/ G' N& x5 S5 K
  8. */ C2 r& q2 x8 J! R; s& ]! ]
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
    ) m8 a! Q( `. a$ T2 O  W( D
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& g6 Q% z/ s6 G- y  v4 g: ^: E) D$ e
  11. *         TO CHANGE.& C# [7 D5 X1 B% d8 n
  12. *( k" ?5 {* g3 C; v3 T5 M7 T' s9 v
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
    5 @0 u; y8 d6 G2 @" y
  14. *
    3 X4 g1 ?+ W- }* S  C6 T2 M4 w
  15. * This program is free software; you can redistribute it and/or& G( y) a3 k! A/ q. t) w
  16. * modify it under the terms of the GNU General Public License as/ k6 L8 E+ ]$ S1 \8 ~& j
  17. * published by the Free Software Foundation version 2.7 R& x. w% C& R5 {4 E5 H9 u$ j- E
  18. *
    & t. @* ]1 y* O0 e
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
    % V" D1 o& I+ l3 P3 t
  20. * kind, whether express or implied; without even the implied warranty, O4 P8 P) A6 o: t0 R' M2 O
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * n4 `5 G& Z1 `9 g9 K8 x5 D3 _
  22. * GNU General Public License for more details.
    $ p2 t4 k8 q2 W  o8 k
  23. */
    3 E' d4 O- \" k* p: `
  24. # F4 G& K1 f! U1 \! Y
  25. #include <linux/module.h>
      v0 N1 L  }# w' `" [
  26. #include <linux/init.h>3 u1 F+ [8 n% y' w
  27. #include <linux/errno.h>' F- Q7 [- K3 e2 }3 b
  28. #include <linux/types.h>
    5 |1 v9 T5 N. ~  L; o( V
  29. #include <linux/interrupt.h>, x$ y6 b' _) E# e) R& n6 S
  30. #include <asm/io.h>
    % X  a' A+ t" w5 h( E
  31. #include <linux/moduleparam.h>
    . T* P9 }( E  F
  32. #include <linux/sysctl.h>
    % K3 M) R# w" _. }" C6 g  ?- t( F
  33. #include <linux/mm.h>+ ~3 ^  W0 `2 h6 J$ |$ ^
  34. #include <linux/dma-mapping.h>
      v) s9 J7 [. F/ o! Z8 ]6 {
  35. * k: x; J5 W* J  e+ Z$ q+ C
  36. #include <mach/memory.h>. }* I" b7 U/ Y/ M' k
  37. #include <mach/hardware.h>
      Q, ~# e% V9 P& M$ |2 A. e
  38. #include <mach/irqs.h>
    # \# T9 }' h% A) _' ^! z4 h- h
  39. #include <asm/hardware/edma.h>
    + u5 }' C* U# k; W

  40. " `9 |, r# \7 \  Y6 U% Y7 z" h
  41. #undef EDMA3_DEBUG
    ) K- b3 |/ Y5 y
  42. /*#define EDMA3_DEBUG*/
    ( s7 ^  O5 i! f, i: }- ^

  43. ; b! L) l& U' h" u' n# j
  44. #ifdef EDMA3_DEBUG( {7 Q( I0 G. `0 q' F
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)  ~$ y2 f. d. S; |. T: r) P
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! c' ]- O2 v) o9 w1 d
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): C! f" O2 E# L3 q  s
  48. #else- f% _& t. [! }& S6 a
  49. #define DMA_PRINTK( x... ); `3 Y+ R) L& k
  50. #define DMA_FN_IN: c5 P" I/ p% t; O! t
  51. #define DMA_FN_OUT
    ; z& @7 @0 e& V1 I- m9 ~0 l
  52. #endif
    6 u( [$ Z$ s! z* k, _
  53. $ G, A  I2 l1 L2 Q# |; o% ~6 n1 W
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)) H! i& P2 g6 u0 H5 A& P, M
  55. #define STATIC_SHIFT                3
    0 \! {0 W9 N$ G' p# p
  56. #define TCINTEN_SHIFT               20- Q4 k: u5 y% c$ ~
  57. #define ITCINTEN_SHIFT              21
    3 `  p/ {3 {/ x5 L7 U
  58. #define TCCHEN_SHIFT                22
    2 B: H7 ~& Y# [, B8 Z3 [+ R
  59. #define ITCCHEN_SHIFT               23
    5 e$ w' [$ {; ~; `  {" T5 i" J, j
  60. * t! z) Q  U; x' e- `1 o( G3 j
  61. static volatile int irqraised1 = 0;
    9 G$ y6 z6 m5 f+ u+ M3 Z
  62. static volatile int irqraised2 = 0;9 z7 A2 W  a' f4 k. @
  63. , W, B2 H+ L% y" I9 }" y& ]
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    0 V5 G/ d7 H; i
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    2 ?$ {& U! a9 X- h
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( }$ s4 r- l  ?+ a; R( s: A$ y& b
  67. . ?) D4 `, K6 ~3 B7 z3 T
  68. dma_addr_t dmaphyssrc1 = 0;6 r+ ?; a  |( A: Q1 U: k; ?) v: _' ^
  69. dma_addr_t dmaphyssrc2 = 0;. d5 }3 T5 e4 k
  70. dma_addr_t dmaphysdest1 = 0;
    # ?/ V$ {' p5 _+ Q& Y+ b
  71. dma_addr_t dmaphysdest2 = 0;
    8 ?3 k% s3 o# S& V$ s
  72. : c: D6 f, n: v
  73. char *dmabufsrc1 = NULL;5 v/ o% i& O5 N: R# o7 \; ~
  74. char *dmabufsrc2 = NULL;
    - i) K7 s& e- b0 |) u/ m
  75. char *dmabufdest1 = NULL;, K+ O9 B3 g1 P9 V
  76. char *dmabufdest2 = NULL;
    / m" f- B/ _6 f3 e$ Z

  77. 5 o) }/ U& }$ O
  78. static int acnt = 512;
    : Y' O: k1 ^$ R7 {
  79. static int bcnt = 8;. ^+ |7 ]9 M1 W4 j- [
  80. static int ccnt = 8;, w8 R4 `' O  U! o7 E

  81. $ N! B* l5 L1 k+ a) W; }
  82. module_param(acnt, int, S_IRUGO);0 c3 Y* ]  C/ r$ n
  83. module_param(bcnt, int, S_IRUGO);, ?- f; H/ z3 F$ N
  84. module_param(ccnt, int, S_IRUGO);
复制代码
- i) x% m$ g) U: U1 a
) u2 Q2 C1 S% f% Q) X
      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& e- d0 Q# ]& f: ^4 Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 V4 }6 j: M9 ^4 V
     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: K( L$ D, `. }2 m" R: \# r# s
4 ]4 W8 Z+ y+ n# P4 L8 P  ~

- y# b! c4 g: V$ p3 I




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