hal_dma.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. * Copyright (c) 2020-2021 Rockchip Electronics Co., Ltd.
  4. */
  5. /** @addtogroup RK_HAL_Driver
  6. * @{
  7. */
  8. /** @addtogroup DMA
  9. * @{
  10. */
  11. #ifndef _HAL_DMA_H
  12. #define _HAL_DMA_H
  13. #include "hal_def.h"
  14. /***************************** MACRO Definition ******************************/
  15. /** @defgroup DMA_Exported_Definition_Group1 Basic Definition
  16. * @{
  17. */
  18. /***************************** Structure Definition **************************/
  19. /**
  20. * enum DMA_TRANSFER_DIRECTION - dma transfer mode and direction indicator
  21. */
  22. typedef enum {
  23. DMA_MEM_TO_MEM, /**< Async/Memcpy mode */
  24. DMA_MEM_TO_DEV, /**< Slave mode & From Memory to Device */
  25. DMA_DEV_TO_MEM, /**< Slave mode & From Device to Memory */
  26. DMA_DEV_TO_DEV, /**< Slave mode & From Device to Device */
  27. DMA_TRANS_NONE,
  28. } eDMA_TRANSFER_DIRECTION;
  29. /**
  30. * enum DMA_SLAVE_BUSWIDTH - defines bus width of the DMA slave
  31. * device, source or target buses
  32. */
  33. typedef enum {
  34. DMA_SLAVE_BUSWIDTH_UNDEFINED = 0,
  35. DMA_SLAVE_BUSWIDTH_1_BYTE = 1,
  36. DMA_SLAVE_BUSWIDTH_2_BYTES = 2,
  37. DMA_SLAVE_BUSWIDTH_3_BYTES = 3,
  38. DMA_SLAVE_BUSWIDTH_4_BYTES = 4,
  39. DMA_SLAVE_BUSWIDTH_8_BYTES = 8,
  40. DMA_SLAVE_BUSWIDTH_16_BYTES = 16,
  41. DMA_SLAVE_BUSWIDTH_32_BYTES = 32,
  42. DMA_SLAVE_BUSWIDTH_64_BYTES = 64,
  43. } eDMA_SLAVE_BUSWIDTH;
  44. /**
  45. * struct DMA_SLAVE_CONFIG - dma slave channel runtime config
  46. */
  47. struct DMA_SLAVE_CONFIG {
  48. eDMA_TRANSFER_DIRECTION direction; /**< Transfer direction. */
  49. eDMA_SLAVE_BUSWIDTH srcAddrWidth; /**< The width in bytes of the source,
  50. * Legal values: 1, 2, 4, 8.
  51. */
  52. eDMA_SLAVE_BUSWIDTH dstAddrWidth; /**< The same as srcAddrWidth. */
  53. uint32_t srcAddr; /**< The source physical address. */
  54. uint32_t dstAddr; /**< The destination physical address. */
  55. uint16_t srcMaxBurst; /**< The maximum number of words (note: words, as in
  56. * units of the srcAddrWidth member, not bytes) that
  57. * can be sent in one burst to the device, Typically
  58. * something like half the FIFO depth on I/O peri so
  59. * you don't overflow it.
  60. */
  61. uint16_t dstMaxBurst; /**< The same as srcMaxBurst for destination. */
  62. uint16_t srcInterlaceSize; /**< The interlace size for src mem increase */
  63. uint16_t dstInterlaceSize; /**< The interlace size for dst mem increase */
  64. };
  65. /**
  66. * dma complete callback.
  67. */
  68. typedef void (*DMA_Callback)(void *cparam);
  69. /** @} */
  70. /********************* Public Function Definition ****************************/
  71. /** @defgroup DMA_Exported_Functions_Group5 Other Functions
  72. * @{
  73. */
  74. __STATIC_INLINE bool HAL_DMA_IsSlaveDirection(eDMA_TRANSFER_DIRECTION direction)
  75. {
  76. return (direction == DMA_MEM_TO_DEV) || (direction == DMA_DEV_TO_MEM);
  77. }
  78. /** @} */
  79. #endif
  80. /** @} */
  81. /** @} */