iop_adma.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright © 2006, Intel Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. */
  18. #ifndef IOP_ADMA_H
  19. #define IOP_ADMA_H
  20. #include <linux/types.h>
  21. #include <linux/dmaengine.h>
  22. #include <linux/interrupt.h>
  23. #define IOP_ADMA_SLOT_SIZE 32
  24. #define IOP_ADMA_THRESHOLD 4
  25. #ifdef DEBUG
  26. #define IOP_PARANOIA 1
  27. #else
  28. #define IOP_PARANOIA 0
  29. #endif
  30. #define iop_paranoia(x) BUG_ON(IOP_PARANOIA && (x))
  31. /**
  32. * struct iop_adma_device - internal representation of an ADMA device
  33. * @pdev: Platform device
  34. * @id: HW ADMA Device selector
  35. * @dma_desc_pool: base of DMA descriptor region (DMA address)
  36. * @dma_desc_pool_virt: base of DMA descriptor region (CPU address)
  37. * @common: embedded struct dma_device
  38. */
  39. struct iop_adma_device {
  40. struct platform_device *pdev;
  41. int id;
  42. dma_addr_t dma_desc_pool;
  43. void *dma_desc_pool_virt;
  44. struct dma_device common;
  45. };
  46. /**
  47. * struct iop_adma_chan - internal representation of an ADMA device
  48. * @pending: allows batching of hardware operations
  49. * @lock: serializes enqueue/dequeue operations to the slot pool
  50. * @mmr_base: memory mapped register base
  51. * @chain: device chain view of the descriptors
  52. * @device: parent device
  53. * @common: common dmaengine channel object members
  54. * @last_used: place holder for allocation to continue from where it left off
  55. * @all_slots: complete domain of slots usable by the channel
  56. * @slots_allocated: records the actual size of the descriptor slot pool
  57. * @irq_tasklet: bottom half where iop_adma_slot_cleanup runs
  58. */
  59. struct iop_adma_chan {
  60. int pending;
  61. spinlock_t lock; /* protects the descriptor slot pool */
  62. void __iomem *mmr_base;
  63. struct list_head chain;
  64. struct iop_adma_device *device;
  65. struct dma_chan common;
  66. struct iop_adma_desc_slot *last_used;
  67. struct list_head all_slots;
  68. int slots_allocated;
  69. struct tasklet_struct irq_tasklet;
  70. };
  71. /**
  72. * struct iop_adma_desc_slot - IOP-ADMA software descriptor
  73. * @slot_node: node on the iop_adma_chan.all_slots list
  74. * @chain_node: node on the op_adma_chan.chain list
  75. * @hw_desc: virtual address of the hardware descriptor chain
  76. * @phys: hardware address of the hardware descriptor chain
  77. * @group_head: first operation in a transaction
  78. * @slot_cnt: total slots used in an transaction (group of operations)
  79. * @slots_per_op: number of slots per operation
  80. * @idx: pool index
  81. * @tx_list: list of descriptors that are associated with one operation
  82. * @async_tx: support for the async_tx api
  83. * @group_list: list of slots that make up a multi-descriptor transaction
  84. * for example transfer lengths larger than the supported hw max
  85. * @xor_check_result: result of zero sum
  86. * @crc32_result: result crc calculation
  87. */
  88. struct iop_adma_desc_slot {
  89. struct list_head slot_node;
  90. struct list_head chain_node;
  91. void *hw_desc;
  92. struct iop_adma_desc_slot *group_head;
  93. u16 slot_cnt;
  94. u16 slots_per_op;
  95. u16 idx;
  96. struct list_head tx_list;
  97. struct dma_async_tx_descriptor async_tx;
  98. union {
  99. u32 *xor_check_result;
  100. u32 *crc32_result;
  101. u32 *pq_check_result;
  102. };
  103. };
  104. struct iop_adma_platform_data {
  105. int hw_id;
  106. dma_cap_mask_t cap_mask;
  107. size_t pool_size;
  108. };
  109. #define to_iop_sw_desc(addr_hw_desc) \
  110. container_of(addr_hw_desc, struct iop_adma_desc_slot, hw_desc)
  111. #define iop_hw_desc_slot_idx(hw_desc, idx) \
  112. ( (void *) (((unsigned long) hw_desc) + ((idx) << 5)) )
  113. #endif