sprd-mcdt.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // SPDX-License-Identifier: GPL-2.0
  2. #ifndef __SPRD_MCDT_H
  3. #define __SPRD_MCDT_H
  4. enum sprd_mcdt_channel_type {
  5. SPRD_MCDT_DAC_CHAN,
  6. SPRD_MCDT_ADC_CHAN,
  7. SPRD_MCDT_UNKNOWN_CHAN,
  8. };
  9. enum sprd_mcdt_dma_chan {
  10. SPRD_MCDT_DMA_CH0,
  11. SPRD_MCDT_DMA_CH1,
  12. SPRD_MCDT_DMA_CH2,
  13. SPRD_MCDT_DMA_CH3,
  14. SPRD_MCDT_DMA_CH4,
  15. };
  16. struct sprd_mcdt_chan_callback {
  17. void (*notify)(void *data);
  18. void *data;
  19. };
  20. /**
  21. * struct sprd_mcdt_chan - this struct represents a single channel instance
  22. * @mcdt: the mcdt controller
  23. * @id: channel id
  24. * @fifo_phys: channel fifo physical address which is used for DMA transfer
  25. * @type: channel type
  26. * @cb: channel fifo interrupt's callback interface to notify the fifo events
  27. * @dma_enable: indicate if use DMA mode to transfer data
  28. * @int_enable: indicate if use interrupt mode to notify users to read or
  29. * write data manually
  30. * @list: used to link into the global list
  31. *
  32. * Note: users should not modify any members of this structure.
  33. */
  34. struct sprd_mcdt_chan {
  35. struct sprd_mcdt_dev *mcdt;
  36. u8 id;
  37. unsigned long fifo_phys;
  38. enum sprd_mcdt_channel_type type;
  39. enum sprd_mcdt_dma_chan dma_chan;
  40. struct sprd_mcdt_chan_callback *cb;
  41. bool dma_enable;
  42. bool int_enable;
  43. struct list_head list;
  44. };
  45. #if IS_ENABLED(CONFIG_SND_SOC_SPRD_MCDT)
  46. struct sprd_mcdt_chan *sprd_mcdt_request_chan(u8 channel,
  47. enum sprd_mcdt_channel_type type);
  48. void sprd_mcdt_free_chan(struct sprd_mcdt_chan *chan);
  49. int sprd_mcdt_chan_write(struct sprd_mcdt_chan *chan, char *tx_buf, u32 size);
  50. int sprd_mcdt_chan_read(struct sprd_mcdt_chan *chan, char *rx_buf, u32 size);
  51. int sprd_mcdt_chan_int_enable(struct sprd_mcdt_chan *chan, u32 water_mark,
  52. struct sprd_mcdt_chan_callback *cb);
  53. void sprd_mcdt_chan_int_disable(struct sprd_mcdt_chan *chan);
  54. int sprd_mcdt_chan_dma_enable(struct sprd_mcdt_chan *chan,
  55. enum sprd_mcdt_dma_chan dma_chan, u32 water_mark);
  56. void sprd_mcdt_chan_dma_disable(struct sprd_mcdt_chan *chan);
  57. #else
  58. struct sprd_mcdt_chan *sprd_mcdt_request_chan(u8 channel,
  59. enum sprd_mcdt_channel_type type)
  60. {
  61. return NULL;
  62. }
  63. void sprd_mcdt_free_chan(struct sprd_mcdt_chan *chan)
  64. { }
  65. int sprd_mcdt_chan_write(struct sprd_mcdt_chan *chan, char *tx_buf, u32 size)
  66. {
  67. return -EINVAL;
  68. }
  69. int sprd_mcdt_chan_read(struct sprd_mcdt_chan *chan, char *rx_buf, u32 size)
  70. {
  71. return 0;
  72. }
  73. int sprd_mcdt_chan_int_enable(struct sprd_mcdt_chan *chan, u32 water_mark,
  74. struct sprd_mcdt_chan_callback *cb)
  75. {
  76. return -EINVAL;
  77. }
  78. void sprd_mcdt_chan_int_disable(struct sprd_mcdt_chan *chan)
  79. { }
  80. int sprd_mcdt_chan_dma_enable(struct sprd_mcdt_chan *chan,
  81. enum sprd_mcdt_dma_chan dma_chan, u32 water_mark)
  82. {
  83. return -EINVAL;
  84. }
  85. void sprd_mcdt_chan_dma_disable(struct sprd_mcdt_chan *chan)
  86. { }
  87. #endif
  88. #endif /* __SPRD_MCDT_H */