adma.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * 2006-2009 (C) DENX Software Engineering.
  4. *
  5. * Author: Yuri Tikhonov <[email protected]>
  6. */
  7. #ifndef _PPC440SPE_ADMA_H
  8. #define _PPC440SPE_ADMA_H
  9. #include <linux/types.h>
  10. #include "dma.h"
  11. #include "xor.h"
  12. #define to_ppc440spe_adma_chan(chan) \
  13. container_of(chan, struct ppc440spe_adma_chan, common)
  14. #define to_ppc440spe_adma_device(dev) \
  15. container_of(dev, struct ppc440spe_adma_device, common)
  16. #define tx_to_ppc440spe_adma_slot(tx) \
  17. container_of(tx, struct ppc440spe_adma_desc_slot, async_tx)
  18. /* Default polynomial (for 440SP is only available) */
  19. #define PPC440SPE_DEFAULT_POLY 0x4d
  20. #define PPC440SPE_ADMA_ENGINES_NUM (XOR_ENGINES_NUM + DMA_ENGINES_NUM)
  21. #define PPC440SPE_ADMA_WATCHDOG_MSEC 3
  22. #define PPC440SPE_ADMA_THRESHOLD 1
  23. #define PPC440SPE_DMA0_ID 0
  24. #define PPC440SPE_DMA1_ID 1
  25. #define PPC440SPE_XOR_ID 2
  26. #define PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT 0xFFFFFFUL
  27. /* this is the XOR_CBBCR width */
  28. #define PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT (1 << 31)
  29. #define PPC440SPE_ADMA_ZERO_SUM_MAX_BYTE_COUNT PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT
  30. #define PPC440SPE_RXOR_RUN 0
  31. #define MQ0_CF2H_RXOR_BS_MASK 0x1FF
  32. #undef ADMA_LL_DEBUG
  33. /**
  34. * struct ppc440spe_adma_device - internal representation of an ADMA device
  35. * @dev: device
  36. * @dma_reg: base for DMAx register access
  37. * @xor_reg: base for XOR register access
  38. * @i2o_reg: base for I2O register access
  39. * @id: HW ADMA Device selector
  40. * @dma_desc_pool_virt: base of DMA descriptor region (CPU address)
  41. * @dma_desc_pool: base of DMA descriptor region (DMA address)
  42. * @pool_size: size of the pool
  43. * @irq: DMAx or XOR irq number
  44. * @err_irq: DMAx error irq number
  45. * @common: embedded struct dma_device
  46. */
  47. struct ppc440spe_adma_device {
  48. struct device *dev;
  49. struct dma_regs __iomem *dma_reg;
  50. struct xor_regs __iomem *xor_reg;
  51. struct i2o_regs __iomem *i2o_reg;
  52. int id;
  53. void *dma_desc_pool_virt;
  54. dma_addr_t dma_desc_pool;
  55. size_t pool_size;
  56. int irq;
  57. int err_irq;
  58. struct dma_device common;
  59. };
  60. /**
  61. * struct ppc440spe_adma_chan - internal representation of an ADMA channel
  62. * @lock: serializes enqueue/dequeue operations to the slot pool
  63. * @device: parent device
  64. * @chain: device chain view of the descriptors
  65. * @common: common dmaengine channel object members
  66. * @all_slots: complete domain of slots usable by the channel
  67. * @pending: allows batching of hardware operations
  68. * @slots_allocated: records the actual size of the descriptor slot pool
  69. * @hw_chain_inited: h/w descriptor chain initialization flag
  70. * @irq_tasklet: bottom half where ppc440spe_adma_slot_cleanup runs
  71. * @needs_unmap: if buffers should not be unmapped upon final processing
  72. * @pdest_page: P destination page for async validate operation
  73. * @qdest_page: Q destination page for async validate operation
  74. * @pdest: P dma addr for async validate operation
  75. * @qdest: Q dma addr for async validate operation
  76. */
  77. struct ppc440spe_adma_chan {
  78. spinlock_t lock;
  79. struct ppc440spe_adma_device *device;
  80. struct list_head chain;
  81. struct dma_chan common;
  82. struct list_head all_slots;
  83. struct ppc440spe_adma_desc_slot *last_used;
  84. int pending;
  85. int slots_allocated;
  86. int hw_chain_inited;
  87. struct tasklet_struct irq_tasklet;
  88. u8 needs_unmap;
  89. struct page *pdest_page;
  90. struct page *qdest_page;
  91. dma_addr_t pdest;
  92. dma_addr_t qdest;
  93. };
  94. struct ppc440spe_rxor {
  95. u32 addrl;
  96. u32 addrh;
  97. int len;
  98. int xor_count;
  99. int addr_count;
  100. int desc_count;
  101. int state;
  102. };
  103. /**
  104. * struct ppc440spe_adma_desc_slot - PPC440SPE-ADMA software descriptor
  105. * @phys: hardware address of the hardware descriptor chain
  106. * @group_head: first operation in a transaction
  107. * @hw_next: pointer to the next descriptor in chain
  108. * @async_tx: support for the async_tx api
  109. * @slot_node: node on the iop_adma_chan.all_slots list
  110. * @chain_node: node on the op_adma_chan.chain list
  111. * @group_list: list of slots that make up a multi-descriptor transaction
  112. * for example transfer lengths larger than the supported hw max
  113. * @unmap_len: transaction bytecount
  114. * @hw_desc: virtual address of the hardware descriptor chain
  115. * @stride: currently chained or not
  116. * @idx: pool index
  117. * @slot_cnt: total slots used in an transaction (group of operations)
  118. * @src_cnt: number of sources set in this descriptor
  119. * @dst_cnt: number of destinations set in the descriptor
  120. * @slots_per_op: number of slots per operation
  121. * @descs_per_op: number of slot per P/Q operation see comment
  122. * for ppc440spe_prep_dma_pqxor function
  123. * @flags: desc state/type
  124. * @reverse_flags: 1 if a corresponding rxor address uses reversed address order
  125. * @xor_check_result: result of zero sum
  126. * @crc32_result: result crc calculation
  127. */
  128. struct ppc440spe_adma_desc_slot {
  129. dma_addr_t phys;
  130. struct ppc440spe_adma_desc_slot *group_head;
  131. struct ppc440spe_adma_desc_slot *hw_next;
  132. struct dma_async_tx_descriptor async_tx;
  133. struct list_head slot_node;
  134. struct list_head chain_node; /* node in channel ops list */
  135. struct list_head group_list; /* list */
  136. unsigned int unmap_len;
  137. void *hw_desc;
  138. u16 stride;
  139. u16 idx;
  140. u16 slot_cnt;
  141. u8 src_cnt;
  142. u8 dst_cnt;
  143. u8 slots_per_op;
  144. u8 descs_per_op;
  145. unsigned long flags;
  146. unsigned long reverse_flags[8];
  147. #define PPC440SPE_DESC_INT 0 /* generate interrupt on complete */
  148. #define PPC440SPE_ZERO_P 1 /* clear P destionaion */
  149. #define PPC440SPE_ZERO_Q 2 /* clear Q destination */
  150. #define PPC440SPE_COHERENT 3 /* src/dst are coherent */
  151. #define PPC440SPE_DESC_WXOR 4 /* WXORs are in chain */
  152. #define PPC440SPE_DESC_RXOR 5 /* RXOR is in chain */
  153. #define PPC440SPE_DESC_RXOR123 8 /* CDB for RXOR123 operation */
  154. #define PPC440SPE_DESC_RXOR124 9 /* CDB for RXOR124 operation */
  155. #define PPC440SPE_DESC_RXOR125 10 /* CDB for RXOR125 operation */
  156. #define PPC440SPE_DESC_RXOR12 11 /* CDB for RXOR12 operation */
  157. #define PPC440SPE_DESC_RXOR_REV 12 /* CDB has srcs in reversed order */
  158. #define PPC440SPE_DESC_PCHECK 13
  159. #define PPC440SPE_DESC_QCHECK 14
  160. #define PPC440SPE_DESC_RXOR_MSK 0x3
  161. struct ppc440spe_rxor rxor_cursor;
  162. union {
  163. u32 *xor_check_result;
  164. u32 *crc32_result;
  165. };
  166. };
  167. #endif /* _PPC440SPE_ADMA_H */