嵌入式开发者社区

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

作者: yyj    时间: 2018-1-30 11:01
标题: OMAPL138如何在Linux下使用EDMA3驱动
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, F: {2 M+ X1 r' w. [, `
  1. [code]EDMA sample test application
    ( o0 i- m( X0 b6 R( `& V
  2. /*
    " ~, `/ @4 }5 [8 Q) ^
  3. * edma_test.c
    8 h* a6 U5 L9 p) T( F0 C
  4. *5 a3 }5 Y0 S5 X5 M* t
  5. * brief  EDMA3 Test Application; D! v5 A- S' ]) v$ R: \! c& Q
  6. *$ M. l  r# z6 O1 t1 @
  7. *   This file contains EDMA3 Test code.
    ' o$ U; s, v* }$ f6 i6 T
  8. *1 s5 q( ~- ]8 K& A
  9. *   NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
    % x" [: n/ i0 q8 G
  10. *         REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
    " ^6 G$ p. Y3 x( W4 C; s
  11. *         TO CHANGE.
    ( i- D" c# X1 \" Z) L
  12. *
    , q( D: a1 [0 R6 x8 l. _. X1 j
  13. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
    . }' m7 b6 {5 D. y8 @, @
  14. ** V  ~0 T6 \4 G! D- ^/ n6 B% [
  15. * This program is free software; you can redistribute it and/or8 w: ]' W  b* u2 W, V
  16. * modify it under the terms of the GNU General Public License as
    8 D$ T. H( R; G
  17. * published by the Free Software Foundation version 2.: P/ M$ [9 m" k
  18. *
    ! p  D3 y3 x; S& {& o
  19. * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ \$ G6 H8 d, B( t# w: T0 _
  20. * kind, whether express or implied; without even the implied warranty9 Z% o- A2 F$ [3 N/ R' E+ Z
  21. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    & S6 j5 Q" f) L7 b: Y% W' D4 \
  22. * GNU General Public License for more details.
    ( S4 v& i$ A4 M+ K$ y  i- [- }
  23. */
    ( N$ E( D4 k; f
  24. " f9 [$ h& q( @
  25. #include <linux/module.h>; |. B9 g3 O6 c7 b
  26. #include <linux/init.h>5 Q0 i9 y# p/ _$ k3 p
  27. #include <linux/errno.h>7 n, s& ]) N9 F' S0 L
  28. #include <linux/types.h>5 X! y$ e. j8 E: E( k
  29. #include <linux/interrupt.h>9 m6 S+ K! X2 J  L3 l( L7 h
  30. #include <asm/io.h>. J, G$ x" I& p9 A+ C" k6 X8 `7 [
  31. #include <linux/moduleparam.h>' U% |6 y1 ~2 _
  32. #include <linux/sysctl.h>6 o  K8 p: ~% l9 u1 @, I. F
  33. #include <linux/mm.h>
    7 J4 A* b: m! T/ Y6 R; B
  34. #include <linux/dma-mapping.h>
    ; ^7 Y# J8 U+ x
  35. * `; b8 f9 s2 t  Y+ N* u( o0 a
  36. #include <mach/memory.h>
    " V. U4 Q/ c. x; ^
  37. #include <mach/hardware.h>( x* A1 A  E1 q
  38. #include <mach/irqs.h>
    0 `  G+ ?7 D6 Q
  39. #include <asm/hardware/edma.h>
    . J0 r9 z5 y- i# b% f/ k( {

  40. ) E, C2 s, m) r/ n0 G1 k
  41. #undef EDMA3_DEBUG
    - }0 U; u1 a% I' [4 |" `
  42. /*#define EDMA3_DEBUG*/$ G- C0 K3 ]( C3 f6 W

  43. ) \" @+ Y, ?: o- U4 N
  44. #ifdef EDMA3_DEBUG/ V$ ~& M  M2 I4 v# p  Z2 ]# f) B
  45. #define DMA_PRINTK(ARGS...)  printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 |' o5 C+ }+ H2 [
  46. #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
    6 U: A1 e, ]5 Z" U
  47. #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
    ' s8 D) Y& O8 M* i& c. y. G8 v6 ]
  48. #else) ^7 S# O+ Z2 r/ P
  49. #define DMA_PRINTK( x... )0 l( V! U% J. |" }1 V/ r
  50. #define DMA_FN_IN
    $ D, V8 ]# X/ g6 @
  51. #define DMA_FN_OUT
    4 R4 C& X7 z, o' l' E
  52. #endif
    - i7 \" \; K0 |  F/ a

  53. * ]7 N& H( n4 @% F% k) @
  54. #define MAX_DMA_TRANSFER_IN_BYTES   (32768)
    ( b. E- h2 j& z3 m4 l
  55. #define STATIC_SHIFT                3) X& }+ ]9 k- ]2 I/ g- W% z
  56. #define TCINTEN_SHIFT               207 U' _- L! A! T' O. x" q# m; ]
  57. #define ITCINTEN_SHIFT              213 N! R$ C2 F5 R' e7 N* ^' r. S
  58. #define TCCHEN_SHIFT                22
    " ^1 N2 O5 h3 T( U: u* X
  59. #define ITCCHEN_SHIFT               23
      {3 p+ w( _9 b

  60. 7 _. J- J6 _  q
  61. static volatile int irqraised1 = 0;* ]4 j4 B# v! A! K
  62. static volatile int irqraised2 = 0;0 f. i2 v6 E- T: H9 G$ T

  63. ! n7 n# e( w# @  _( Y3 `7 m
  64. int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    4 ?3 \, z% J; d5 j& M+ \( Z
  65. int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    9 D% h- H: L, I6 |% h
  66. int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
    3 ~9 s; G* t0 g0 M" V# b
  67. $ `% w3 B8 U+ F, Z: \2 C
  68. dma_addr_t dmaphyssrc1 = 0;
      z. x3 F- t, u/ e$ v6 F
  69. dma_addr_t dmaphyssrc2 = 0;
    / F) u: m) H4 z+ S( H
  70. dma_addr_t dmaphysdest1 = 0;
    : y* h" F) }: _' D
  71. dma_addr_t dmaphysdest2 = 0;( c5 i/ l+ Z& w4 S
  72. + K, L- l, W- n0 z' X; r
  73. char *dmabufsrc1 = NULL;7 h% k; s4 a; |$ A" h, P  x
  74. char *dmabufsrc2 = NULL;' ?; f7 N* ]% U3 F0 h& W) T% N
  75. char *dmabufdest1 = NULL;; q, X: r# Y( W+ \% s6 h" \
  76. char *dmabufdest2 = NULL;. B8 k8 [% R6 X

  77. 4 Y% X; v6 X3 H+ S
  78. static int acnt = 512;* D' e( q8 ]/ t- R- r, \6 J6 @- }
  79. static int bcnt = 8;
    # Y) R! j0 y+ l5 O
  80. static int ccnt = 8;
    ; G" x- @- I9 L" y$ w* `9 _5 N
  81. ) l2 i+ a) M" g; R' I# I
  82. module_param(acnt, int, S_IRUGO);
    8 F. U) \0 h! ?4 e9 X
  83. module_param(bcnt, int, S_IRUGO);
    ' _' u/ T1 T2 o! n( e5 l7 V0 X
  84. module_param(ccnt, int, S_IRUGO);
复制代码

0 I; x! V3 K5 s( o! ]# t
+ I  K9 V$ L! j+ _8 H      这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 D( v4 v: D* _! |) K! R3 m
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 R6 d% w. V2 I* s  \. F! o. h     我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; ^5 v5 e# ?2 K3 ^7 P' d6 T
1 f/ k% M1 E* z# |7 h; ^8 T: Z  V) p2 d; |" j. f1 K- Y





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