coh901318_lli.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * driver/dma/coh901318_lli.h
  3. *
  4. * Copyright (C) 2007-2009 ST-Ericsson
  5. * License terms: GNU General Public License (GPL) version 2
  6. * Support functions for handling lli for coh901318
  7. * Author: Per Friden <per.friden@stericsson.com>
  8. */
  9. #ifndef COH901318_LLI_H
  10. #define COH901318_LLI_H
  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. struct device;
  21. /**
  22. * coh901318_pool_create() - Creates an dma pool for lli:s
  23. * @pool: pool handle
  24. * @dev: dma device
  25. * @lli_nbr: number of lli:s in the pool
  26. * @algin: address alignemtn of lli:s
  27. * returns 0 on success otherwise none zero
  28. */
  29. int coh901318_pool_create(struct coh901318_pool *pool,
  30. struct device *dev,
  31. size_t lli_nbr, size_t align);
  32. /**
  33. * coh901318_pool_destroy() - Destroys the dma pool
  34. * @pool: pool handle
  35. * returns 0 on success otherwise none zero
  36. */
  37. int coh901318_pool_destroy(struct coh901318_pool *pool);
  38. /**
  39. * coh901318_lli_alloc() - Allocates a linked list
  40. *
  41. * @pool: pool handle
  42. * @len: length to list
  43. * return: none NULL if success otherwise NULL
  44. */
  45. struct coh901318_lli *
  46. coh901318_lli_alloc(struct coh901318_pool *pool,
  47. unsigned int len);
  48. /**
  49. * coh901318_lli_free() - Returns the linked list items to the pool
  50. * @pool: pool handle
  51. * @lli: reference to lli pointer to be freed
  52. */
  53. void coh901318_lli_free(struct coh901318_pool *pool,
  54. struct coh901318_lli **lli);
  55. /**
  56. * coh901318_lli_fill_memcpy() - Prepares the lli:s for dma memcpy
  57. * @pool: pool handle
  58. * @lli: allocated lli
  59. * @src: src address
  60. * @size: transfer size
  61. * @dst: destination address
  62. * @ctrl_chained: ctrl for chained lli
  63. * @ctrl_last: ctrl for the last lli
  64. * returns number of CPU interrupts for the lli, negative on error.
  65. */
  66. int
  67. coh901318_lli_fill_memcpy(struct coh901318_pool *pool,
  68. struct coh901318_lli *lli,
  69. dma_addr_t src, unsigned int size,
  70. dma_addr_t dst, u32 ctrl_chained, u32 ctrl_last);
  71. /**
  72. * coh901318_lli_fill_single() - Prepares the lli:s for dma single transfer
  73. * @pool: pool handle
  74. * @lli: allocated lli
  75. * @buf: transfer buffer
  76. * @size: transfer size
  77. * @dev_addr: address of periphal
  78. * @ctrl_chained: ctrl for chained lli
  79. * @ctrl_last: ctrl for the last lli
  80. * @dir: direction of transfer (to or from device)
  81. * returns number of CPU interrupts for the lli, negative on error.
  82. */
  83. int
  84. coh901318_lli_fill_single(struct coh901318_pool *pool,
  85. struct coh901318_lli *lli,
  86. dma_addr_t buf, unsigned int size,
  87. dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl_last,
  88. enum dma_transfer_direction dir);
  89. /**
  90. * coh901318_lli_fill_single() - Prepares the lli:s for dma scatter list transfer
  91. * @pool: pool handle
  92. * @lli: allocated lli
  93. * @sg: scatter gather list
  94. * @nents: number of entries in sg
  95. * @dev_addr: address of periphal
  96. * @ctrl_chained: ctrl for chained lli
  97. * @ctrl: ctrl of middle lli
  98. * @ctrl_last: ctrl for the last lli
  99. * @dir: direction of transfer (to or from device)
  100. * @ctrl_irq_mask: ctrl mask for CPU interrupt
  101. * returns number of CPU interrupts for the lli, negative on error.
  102. */
  103. int
  104. coh901318_lli_fill_sg(struct coh901318_pool *pool,
  105. struct coh901318_lli *lli,
  106. struct scatterlist *sg, unsigned int nents,
  107. dma_addr_t dev_addr, u32 ctrl_chained,
  108. u32 ctrl, u32 ctrl_last,
  109. enum dma_transfer_direction dir, u32 ctrl_irq_mask);
  110. #endif /* COH901318_LLI_H */