cadence_master.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
  2. // Copyright(c) 2015-17 Intel Corporation.
  3. #ifndef __SDW_CADENCE_H
  4. #define __SDW_CADENCE_H
  5. /**
  6. * struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
  7. *
  8. * @assigned: pdi assigned
  9. * @num: pdi number
  10. * @intel_alh_id: link identifier
  11. * @l_ch_num: low channel for PDI
  12. * @h_ch_num: high channel for PDI
  13. * @ch_count: total channel count for PDI
  14. * @dir: data direction
  15. * @type: stream type, PDM or PCM
  16. */
  17. struct sdw_cdns_pdi {
  18. bool assigned;
  19. int num;
  20. int intel_alh_id;
  21. int l_ch_num;
  22. int h_ch_num;
  23. int ch_count;
  24. enum sdw_data_direction dir;
  25. enum sdw_stream_type type;
  26. };
  27. /**
  28. * struct sdw_cdns_port: Cadence port structure
  29. *
  30. * @num: port number
  31. * @assigned: port assigned
  32. * @ch: channel count
  33. * @direction: data port direction
  34. * @pdi: pdi for this port
  35. */
  36. struct sdw_cdns_port {
  37. unsigned int num;
  38. bool assigned;
  39. unsigned int ch;
  40. enum sdw_data_direction direction;
  41. struct sdw_cdns_pdi *pdi;
  42. };
  43. /**
  44. * struct sdw_cdns_streams: Cadence stream data structure
  45. *
  46. * @num_bd: number of bidirectional streams
  47. * @num_in: number of input streams
  48. * @num_out: number of output streams
  49. * @num_ch_bd: number of bidirectional stream channels
  50. * @num_ch_bd: number of input stream channels
  51. * @num_ch_bd: number of output stream channels
  52. * @num_pdi: total number of PDIs
  53. * @bd: bidirectional streams
  54. * @in: input streams
  55. * @out: output streams
  56. */
  57. struct sdw_cdns_streams {
  58. unsigned int num_bd;
  59. unsigned int num_in;
  60. unsigned int num_out;
  61. unsigned int num_ch_bd;
  62. unsigned int num_ch_in;
  63. unsigned int num_ch_out;
  64. unsigned int num_pdi;
  65. struct sdw_cdns_pdi *bd;
  66. struct sdw_cdns_pdi *in;
  67. struct sdw_cdns_pdi *out;
  68. };
  69. /**
  70. * struct sdw_cdns_stream_config: stream configuration
  71. *
  72. * @pcm_bd: number of bidirectional PCM streams supported
  73. * @pcm_in: number of input PCM streams supported
  74. * @pcm_out: number of output PCM streams supported
  75. * @pdm_bd: number of bidirectional PDM streams supported
  76. * @pdm_in: number of input PDM streams supported
  77. * @pdm_out: number of output PDM streams supported
  78. */
  79. struct sdw_cdns_stream_config {
  80. unsigned int pcm_bd;
  81. unsigned int pcm_in;
  82. unsigned int pcm_out;
  83. unsigned int pdm_bd;
  84. unsigned int pdm_in;
  85. unsigned int pdm_out;
  86. };
  87. /**
  88. * struct sdw_cdns - Cadence driver context
  89. * @dev: Linux device
  90. * @bus: Bus handle
  91. * @instance: instance number
  92. * @response_buf: SoundWire response buffer
  93. * @tx_complete: Tx completion
  94. * @defer: Defer pointer
  95. * @ports: Data ports
  96. * @num_ports: Total number of data ports
  97. * @pcm: PCM streams
  98. * @pdm: PDM streams
  99. * @registers: Cadence registers
  100. * @link_up: Link status
  101. * @msg_count: Messages sent on bus
  102. */
  103. struct sdw_cdns {
  104. struct device *dev;
  105. struct sdw_bus bus;
  106. unsigned int instance;
  107. u32 response_buf[0x80];
  108. struct completion tx_complete;
  109. struct sdw_defer *defer;
  110. struct sdw_cdns_port *ports;
  111. int num_ports;
  112. struct sdw_cdns_streams pcm;
  113. struct sdw_cdns_streams pdm;
  114. void __iomem *registers;
  115. bool link_up;
  116. unsigned int msg_count;
  117. };
  118. #define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus)
  119. /* Exported symbols */
  120. int sdw_cdns_probe(struct sdw_cdns *cdns);
  121. extern struct sdw_master_ops sdw_cdns_master_ops;
  122. irqreturn_t sdw_cdns_irq(int irq, void *dev_id);
  123. irqreturn_t sdw_cdns_thread(int irq, void *dev_id);
  124. int sdw_cdns_init(struct sdw_cdns *cdns);
  125. int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
  126. struct sdw_cdns_stream_config config);
  127. int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns);
  128. enum sdw_command_response
  129. cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
  130. enum sdw_command_response
  131. cdns_xfer_msg_defer(struct sdw_bus *bus,
  132. struct sdw_msg *msg, struct sdw_defer *defer);
  133. enum sdw_command_response
  134. cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
  135. int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
  136. #endif /* __SDW_CADENCE_H */