coh901318.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2007-2013 ST-Ericsson
  4. * DMA driver for COH 901 318
  5. * Author: Per Friden <per.friden@stericsson.com>
  6. */
  7. #ifndef COH901318_H
  8. #define COH901318_H
  9. #define MAX_DMA_PACKET_SIZE_SHIFT 11
  10. #define MAX_DMA_PACKET_SIZE (1 << MAX_DMA_PACKET_SIZE_SHIFT)
  11. struct device;
  12. struct coh901318_pool {
  13. spinlock_t lock;
  14. struct dma_pool *dmapool;
  15. struct device *dev;
  16. #ifdef CONFIG_DEBUG_FS
  17. int debugfs_pool_counter;
  18. #endif
  19. };
  20. /**
  21. * struct coh901318_lli - linked list item for DMAC
  22. * @control: control settings for DMAC
  23. * @src_addr: transfer source address
  24. * @dst_addr: transfer destination address
  25. * @link_addr: physical address to next lli
  26. * @virt_link_addr: virtual address of next lli (only used by pool_free)
  27. * @phy_this: physical address of current lli (only used by pool_free)
  28. */
  29. struct coh901318_lli {
  30. u32 control;
  31. dma_addr_t src_addr;
  32. dma_addr_t dst_addr;
  33. dma_addr_t link_addr;
  34. void *virt_link_addr;
  35. dma_addr_t phy_this;
  36. };
  37. /**
  38. * coh901318_pool_create() - Creates an dma pool for lli:s
  39. * @pool: pool handle
  40. * @dev: dma device
  41. * @lli_nbr: number of lli:s in the pool
  42. * @algin: address alignemtn of lli:s
  43. * returns 0 on success otherwise none zero
  44. */
  45. int coh901318_pool_create(struct coh901318_pool *pool,
  46. struct device *dev,
  47. size_t lli_nbr, size_t align);
  48. /**
  49. * coh901318_pool_destroy() - Destroys the dma pool
  50. * @pool: pool handle
  51. * returns 0 on success otherwise none zero
  52. */
  53. int coh901318_pool_destroy(struct coh901318_pool *pool);
  54. /**
  55. * coh901318_lli_alloc() - Allocates a linked list
  56. *
  57. * @pool: pool handle
  58. * @len: length to list
  59. * return: none NULL if success otherwise NULL
  60. */
  61. struct coh901318_lli *
  62. coh901318_lli_alloc(struct coh901318_pool *pool,
  63. unsigned int len);
  64. /**
  65. * coh901318_lli_free() - Returns the linked list items to the pool
  66. * @pool: pool handle
  67. * @lli: reference to lli pointer to be freed
  68. */
  69. void coh901318_lli_free(struct coh901318_pool *pool,
  70. struct coh901318_lli **lli);
  71. /**
  72. * coh901318_lli_fill_memcpy() - Prepares the lli:s for dma memcpy
  73. * @pool: pool handle
  74. * @lli: allocated lli
  75. * @src: src address
  76. * @size: transfer size
  77. * @dst: destination address
  78. * @ctrl_chained: ctrl for chained lli
  79. * @ctrl_last: ctrl for the last lli
  80. * returns number of CPU interrupts for the lli, negative on error.
  81. */
  82. int
  83. coh901318_lli_fill_memcpy(struct coh901318_pool *pool,
  84. struct coh901318_lli *lli,
  85. dma_addr_t src, unsigned int size,
  86. dma_addr_t dst, u32 ctrl_chained, u32 ctrl_last);
  87. /**
  88. * coh901318_lli_fill_single() - Prepares the lli:s for dma single transfer
  89. * @pool: pool handle
  90. * @lli: allocated lli
  91. * @buf: transfer buffer
  92. * @size: transfer size
  93. * @dev_addr: address of periphal
  94. * @ctrl_chained: ctrl for chained lli
  95. * @ctrl_last: ctrl for the last lli
  96. * @dir: direction of transfer (to or from device)
  97. * returns number of CPU interrupts for the lli, negative on error.
  98. */
  99. int
  100. coh901318_lli_fill_single(struct coh901318_pool *pool,
  101. struct coh901318_lli *lli,
  102. dma_addr_t buf, unsigned int size,
  103. dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl_last,
  104. enum dma_transfer_direction dir);
  105. /**
  106. * coh901318_lli_fill_single() - Prepares the lli:s for dma scatter list transfer
  107. * @pool: pool handle
  108. * @lli: allocated lli
  109. * @sg: scatter gather list
  110. * @nents: number of entries in sg
  111. * @dev_addr: address of periphal
  112. * @ctrl_chained: ctrl for chained lli
  113. * @ctrl: ctrl of middle lli
  114. * @ctrl_last: ctrl for the last lli
  115. * @dir: direction of transfer (to or from device)
  116. * @ctrl_irq_mask: ctrl mask for CPU interrupt
  117. * returns number of CPU interrupts for the lli, negative on error.
  118. */
  119. int
  120. coh901318_lli_fill_sg(struct coh901318_pool *pool,
  121. struct coh901318_lli *lli,
  122. struct scatterlist *sg, unsigned int nents,
  123. dma_addr_t dev_addr, u32 ctrl_chained,
  124. u32 ctrl, u32 ctrl_last,
  125. enum dma_transfer_direction dir, u32 ctrl_irq_mask);
  126. #endif /* COH901318_H */