coh901318_lli.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. #include <mach/coh901318.h>
  12. struct device;
  13. struct coh901318_pool {
  14. spinlock_t lock;
  15. struct dma_pool *dmapool;
  16. struct device *dev;
  17. #ifdef CONFIG_DEBUG_FS
  18. int debugfs_pool_counter;
  19. #endif
  20. };
  21. struct device;
  22. /**
  23. * coh901318_pool_create() - Creates an dma pool for lli:s
  24. * @pool: pool handle
  25. * @dev: dma device
  26. * @lli_nbr: number of lli:s in the pool
  27. * @algin: address alignemtn of lli:s
  28. * returns 0 on success otherwise none zero
  29. */
  30. int coh901318_pool_create(struct coh901318_pool *pool,
  31. struct device *dev,
  32. size_t lli_nbr, size_t align);
  33. /**
  34. * coh901318_pool_destroy() - Destroys the dma pool
  35. * @pool: pool handle
  36. * returns 0 on success otherwise none zero
  37. */
  38. int coh901318_pool_destroy(struct coh901318_pool *pool);
  39. /**
  40. * coh901318_lli_alloc() - Allocates a linked list
  41. *
  42. * @pool: pool handle
  43. * @len: length to list
  44. * return: none NULL if success otherwise NULL
  45. */
  46. struct coh901318_lli *
  47. coh901318_lli_alloc(struct coh901318_pool *pool,
  48. unsigned int len);
  49. /**
  50. * coh901318_lli_free() - Returns the linked list items to the pool
  51. * @pool: pool handle
  52. * @lli: reference to lli pointer to be freed
  53. */
  54. void coh901318_lli_free(struct coh901318_pool *pool,
  55. struct coh901318_lli **lli);
  56. /**
  57. * coh901318_lli_fill_memcpy() - Prepares the lli:s for dma memcpy
  58. * @pool: pool handle
  59. * @lli: allocated lli
  60. * @src: src address
  61. * @size: transfer size
  62. * @dst: destination address
  63. * @ctrl_chained: ctrl for chained lli
  64. * @ctrl_last: ctrl for the last lli
  65. * returns number of CPU interrupts for the lli, negative on error.
  66. */
  67. int
  68. coh901318_lli_fill_memcpy(struct coh901318_pool *pool,
  69. struct coh901318_lli *lli,
  70. dma_addr_t src, unsigned int size,
  71. dma_addr_t dst, u32 ctrl_chained, u32 ctrl_last);
  72. /**
  73. * coh901318_lli_fill_single() - Prepares the lli:s for dma single transfer
  74. * @pool: pool handle
  75. * @lli: allocated lli
  76. * @buf: transfer buffer
  77. * @size: transfer size
  78. * @dev_addr: address of periphal
  79. * @ctrl_chained: ctrl for chained lli
  80. * @ctrl_last: ctrl for the last lli
  81. * @dir: direction of transfer (to or from device)
  82. * returns number of CPU interrupts for the lli, negative on error.
  83. */
  84. int
  85. coh901318_lli_fill_single(struct coh901318_pool *pool,
  86. struct coh901318_lli *lli,
  87. dma_addr_t buf, unsigned int size,
  88. dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl_last,
  89. enum dma_transfer_direction dir);
  90. /**
  91. * coh901318_lli_fill_single() - Prepares the lli:s for dma scatter list transfer
  92. * @pool: pool handle
  93. * @lli: allocated lli
  94. * @sg: scatter gather list
  95. * @nents: number of entries in sg
  96. * @dev_addr: address of periphal
  97. * @ctrl_chained: ctrl for chained lli
  98. * @ctrl: ctrl of middle lli
  99. * @ctrl_last: ctrl for the last lli
  100. * @dir: direction of transfer (to or from device)
  101. * @ctrl_irq_mask: ctrl mask for CPU interrupt
  102. * returns number of CPU interrupts for the lli, negative on error.
  103. */
  104. int
  105. coh901318_lli_fill_sg(struct coh901318_pool *pool,
  106. struct coh901318_lli *lli,
  107. struct scatterlist *sg, unsigned int nents,
  108. dma_addr_t dev_addr, u32 ctrl_chained,
  109. u32 ctrl, u32 ctrl_last,
  110. enum dma_transfer_direction dir, u32 ctrl_irq_mask);
  111. #endif /* COH901318_LLI_H */