qcom_bam_dma.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _QCOM_BAM_DMA_H
  6. #define _QCOM_BAM_DMA_H
  7. #include <asm/byteorder.h>
  8. /*
  9. * This data type corresponds to the native Command Element
  10. * supported by BAM DMA Engine.
  11. *
  12. * @cmd_and_addr - upper 8 bits command and lower 24 bits register address.
  13. * @data - for write command: content to be written into peripheral register.
  14. * for read command: dest addr to write peripheral register value.
  15. * @mask - register mask.
  16. * @reserved - for future usage.
  17. *
  18. */
  19. struct bam_cmd_element {
  20. __le32 cmd_and_addr;
  21. __le32 data;
  22. __le32 mask;
  23. __le32 reserved;
  24. };
  25. /*
  26. * This enum indicates the command type in a command element
  27. */
  28. enum bam_command_type {
  29. BAM_WRITE_COMMAND = 0,
  30. BAM_READ_COMMAND,
  31. };
  32. /*
  33. * prep_bam_ce_le32 - Wrapper function to prepare a single BAM command
  34. * element with the data already in le32 format.
  35. *
  36. * @bam_ce: bam command element
  37. * @addr: target address
  38. * @cmd: BAM command
  39. * @data: actual data for write and dest addr for read in le32
  40. */
  41. static inline void
  42. bam_prep_ce_le32(struct bam_cmd_element *bam_ce, u32 addr,
  43. enum bam_command_type cmd, __le32 data)
  44. {
  45. bam_ce->cmd_and_addr =
  46. cpu_to_le32((addr & 0xffffff) | ((cmd & 0xff) << 24));
  47. bam_ce->data = data;
  48. bam_ce->mask = cpu_to_le32(0xffffffff);
  49. }
  50. /*
  51. * bam_prep_ce - Wrapper function to prepare a single BAM command element
  52. * with the data.
  53. *
  54. * @bam_ce: BAM command element
  55. * @addr: target address
  56. * @cmd: BAM command
  57. * @data: actual data for write and dest addr for read
  58. */
  59. static inline void
  60. bam_prep_ce(struct bam_cmd_element *bam_ce, u32 addr,
  61. enum bam_command_type cmd, u32 data)
  62. {
  63. bam_prep_ce_le32(bam_ce, addr, cmd, cpu_to_le32(data));
  64. }
  65. #endif