bcm_vk_sg.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright 2018-2020 Broadcom.
  4. */
  5. #ifndef BCM_VK_SG_H
  6. #define BCM_VK_SG_H
  7. #include <linux/dma-mapping.h>
  8. struct bcm_vk_dma {
  9. /* for userland buffer */
  10. struct page **pages;
  11. int nr_pages;
  12. /* common */
  13. dma_addr_t handle;
  14. /*
  15. * sglist is of the following LE format
  16. * [U32] num_sg = number of sg addresses (N)
  17. * [U32] totalsize = totalsize of data being transferred in sglist
  18. * [U32] size[0] = size of data in address0
  19. * [U32] addr_l[0] = lower 32-bits of address0
  20. * [U32] addr_h[0] = higher 32-bits of address0
  21. * ..
  22. * [U32] size[N-1] = size of data in addressN-1
  23. * [U32] addr_l[N-1] = lower 32-bits of addressN-1
  24. * [U32] addr_h[N-1] = higher 32-bits of addressN-1
  25. */
  26. u32 *sglist;
  27. #define SGLIST_NUM_SG 0
  28. #define SGLIST_TOTALSIZE 1
  29. #define SGLIST_VKDATA_START 2
  30. int sglen; /* Length (bytes) of sglist */
  31. int direction;
  32. };
  33. struct _vk_data {
  34. u32 size; /* data size in bytes */
  35. u64 address; /* Pointer to data */
  36. } __packed;
  37. /*
  38. * Scatter-gather DMA buffer API.
  39. *
  40. * These functions provide a simple way to create a page list and a
  41. * scatter-gather list from userspace address and map the memory
  42. * for DMA operation.
  43. */
  44. int bcm_vk_sg_alloc(struct device *dev,
  45. struct bcm_vk_dma *dma,
  46. int dir,
  47. struct _vk_data *vkdata,
  48. int num);
  49. int bcm_vk_sg_free(struct device *dev, struct bcm_vk_dma *dma, int num,
  50. int *proc_cnt);
  51. #endif