dma.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _DMA_H_
  14. #define _DMA_H_
  15. /* maximum data transfer block size between BAM and CE */
  16. #define QCE_BAM_BURST_SIZE 64
  17. #define QCE_AUTHIV_REGS_CNT 16
  18. #define QCE_AUTH_BYTECOUNT_REGS_CNT 4
  19. #define QCE_CNTRIV_REGS_CNT 4
  20. struct qce_result_dump {
  21. u32 auth_iv[QCE_AUTHIV_REGS_CNT];
  22. u32 auth_byte_count[QCE_AUTH_BYTECOUNT_REGS_CNT];
  23. u32 encr_cntr_iv[QCE_CNTRIV_REGS_CNT];
  24. u32 status;
  25. u32 status2;
  26. };
  27. #define QCE_IGNORE_BUF_SZ (2 * QCE_BAM_BURST_SIZE)
  28. #define QCE_RESULT_BUF_SZ \
  29. ALIGN(sizeof(struct qce_result_dump), QCE_BAM_BURST_SIZE)
  30. struct qce_dma_data {
  31. struct dma_chan *txchan;
  32. struct dma_chan *rxchan;
  33. struct qce_result_dump *result_buf;
  34. void *ignore_buf;
  35. };
  36. int qce_dma_request(struct device *dev, struct qce_dma_data *dma);
  37. void qce_dma_release(struct qce_dma_data *dma);
  38. int qce_dma_prep_sgs(struct qce_dma_data *dma, struct scatterlist *sg_in,
  39. int in_ents, struct scatterlist *sg_out, int out_ents,
  40. dma_async_tx_callback cb, void *cb_param);
  41. void qce_dma_issue_pending(struct qce_dma_data *dma);
  42. int qce_dma_terminate_all(struct qce_dma_data *dma);
  43. int qce_countsg(struct scatterlist *sg_list, int nbytes, bool *chained);
  44. void qce_unmapsg(struct device *dev, struct scatterlist *sg, int nents,
  45. enum dma_data_direction dir, bool chained);
  46. int qce_mapsg(struct device *dev, struct scatterlist *sg, int nents,
  47. enum dma_data_direction dir, bool chained);
  48. struct scatterlist *
  49. qce_sgtable_add(struct sg_table *sgt, struct scatterlist *sg_add);
  50. #endif /* _DMA_H_ */