dma-iop32x.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright © 2006, Intel Corporation.
  4. */
  5. #ifndef IOP_ADMA_H
  6. #define IOP_ADMA_H
  7. #include <linux/types.h>
  8. #include <linux/dmaengine.h>
  9. #include <linux/interrupt.h>
  10. #define IOP_ADMA_SLOT_SIZE 32
  11. #define IOP_ADMA_THRESHOLD 4
  12. #ifdef DEBUG
  13. #define IOP_PARANOIA 1
  14. #else
  15. #define IOP_PARANOIA 0
  16. #endif
  17. #define iop_paranoia(x) BUG_ON(IOP_PARANOIA && (x))
  18. #define DMA0_ID 0
  19. #define DMA1_ID 1
  20. #define AAU_ID 2
  21. /**
  22. * struct iop_adma_device - internal representation of an ADMA device
  23. * @pdev: Platform device
  24. * @id: HW ADMA Device selector
  25. * @dma_desc_pool: base of DMA descriptor region (DMA address)
  26. * @dma_desc_pool_virt: base of DMA descriptor region (CPU address)
  27. * @common: embedded struct dma_device
  28. */
  29. struct iop_adma_device {
  30. struct platform_device *pdev;
  31. int id;
  32. dma_addr_t dma_desc_pool;
  33. void *dma_desc_pool_virt;
  34. struct dma_device common;
  35. };
  36. /**
  37. * struct iop_adma_chan - internal representation of an ADMA device
  38. * @pending: allows batching of hardware operations
  39. * @lock: serializes enqueue/dequeue operations to the slot pool
  40. * @mmr_base: memory mapped register base
  41. * @chain: device chain view of the descriptors
  42. * @device: parent device
  43. * @common: common dmaengine channel object members
  44. * @last_used: place holder for allocation to continue from where it left off
  45. * @all_slots: complete domain of slots usable by the channel
  46. * @slots_allocated: records the actual size of the descriptor slot pool
  47. * @irq_tasklet: bottom half where iop_adma_slot_cleanup runs
  48. */
  49. struct iop_adma_chan {
  50. int pending;
  51. spinlock_t lock; /* protects the descriptor slot pool */
  52. void __iomem *mmr_base;
  53. struct list_head chain;
  54. struct iop_adma_device *device;
  55. struct dma_chan common;
  56. struct iop_adma_desc_slot *last_used;
  57. struct list_head all_slots;
  58. int slots_allocated;
  59. struct tasklet_struct irq_tasklet;
  60. };
  61. /**
  62. * struct iop_adma_desc_slot - IOP-ADMA software descriptor
  63. * @slot_node: node on the iop_adma_chan.all_slots list
  64. * @chain_node: node on the op_adma_chan.chain list
  65. * @hw_desc: virtual address of the hardware descriptor chain
  66. * @phys: hardware address of the hardware descriptor chain
  67. * @group_head: first operation in a transaction
  68. * @slot_cnt: total slots used in an transaction (group of operations)
  69. * @slots_per_op: number of slots per operation
  70. * @idx: pool index
  71. * @tx_list: list of descriptors that are associated with one operation
  72. * @async_tx: support for the async_tx api
  73. * @group_list: list of slots that make up a multi-descriptor transaction
  74. * for example transfer lengths larger than the supported hw max
  75. * @xor_check_result: result of zero sum
  76. * @crc32_result: result crc calculation
  77. */
  78. struct iop_adma_desc_slot {
  79. struct list_head slot_node;
  80. struct list_head chain_node;
  81. void *hw_desc;
  82. struct iop_adma_desc_slot *group_head;
  83. u16 slot_cnt;
  84. u16 slots_per_op;
  85. u16 idx;
  86. struct list_head tx_list;
  87. struct dma_async_tx_descriptor async_tx;
  88. union {
  89. u32 *xor_check_result;
  90. u32 *crc32_result;
  91. u32 *pq_check_result;
  92. };
  93. };
  94. struct iop_adma_platform_data {
  95. int hw_id;
  96. dma_cap_mask_t cap_mask;
  97. size_t pool_size;
  98. };
  99. #define to_iop_sw_desc(addr_hw_desc) \
  100. container_of(addr_hw_desc, struct iop_adma_desc_slot, hw_desc)
  101. #define iop_hw_desc_slot_idx(hw_desc, idx) \
  102. ( (void *) (((unsigned long) hw_desc) + ((idx) << 5)) )
  103. #endif