summary.rst 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. ===========================
  2. SoundWire Subsystem Summary
  3. ===========================
  4. SoundWire is a new interface ratified in 2015 by the MIPI Alliance.
  5. SoundWire is used for transporting data typically related to audio
  6. functions. SoundWire interface is optimized to integrate audio devices in
  7. mobile or mobile inspired systems.
  8. SoundWire is a 2-pin multi-drop interface with data and clock line. It
  9. facilitates development of low cost, efficient, high performance systems.
  10. Broad level key features of SoundWire interface include:
  11. (1) Transporting all of payload data channels, control information, and setup
  12. commands over a single two-pin interface.
  13. (2) Lower clock frequency, and hence lower power consumption, by use of DDR
  14. (Dual Data Rate) data transmission.
  15. (3) Clock scaling and optional multiple data lanes to give wide flexibility
  16. in data rate to match system requirements.
  17. (4) Device status monitoring, including interrupt-style alerts to the Master.
  18. The SoundWire protocol supports up to eleven Slave interfaces. All the
  19. interfaces share the common Bus containing data and clock line. Each of the
  20. Slaves can support up to 14 Data Ports. 13 Data Ports are dedicated to audio
  21. transport. Data Port0 is dedicated to transport of Bulk control information,
  22. each of the audio Data Ports (1..14) can support up to 8 Channels in
  23. transmit or receiving mode (typically fixed direction but configurable
  24. direction is enabled by the specification). Bandwidth restrictions to
  25. ~19.2..24.576Mbits/s don't however allow for 11*13*8 channels to be
  26. transmitted simultaneously.
  27. Below figure shows an example of connectivity between a SoundWire Master and
  28. two Slave devices. ::
  29. +---------------+ +---------------+
  30. | | Clock Signal | |
  31. | Master |-------+-------------------------------| Slave |
  32. | Interface | | Data Signal | Interface 1 |
  33. | |-------|-------+-----------------------| |
  34. +---------------+ | | +---------------+
  35. | |
  36. | |
  37. | |
  38. +--+-------+--+
  39. | |
  40. | Slave |
  41. | Interface 2 |
  42. | |
  43. +-------------+
  44. Terminology
  45. ===========
  46. The MIPI SoundWire specification uses the term 'device' to refer to a Master
  47. or Slave interface, which of course can be confusing. In this summary and
  48. code we use the term interface only to refer to the hardware. We follow the
  49. Linux device model by mapping each Slave interface connected on the bus as a
  50. device managed by a specific driver. The Linux SoundWire subsystem provides
  51. a framework to implement a SoundWire Slave driver with an API allowing
  52. 3rd-party vendors to enable implementation-defined functionality while
  53. common setup/configuration tasks are handled by the bus.
  54. Bus:
  55. Implements SoundWire Linux Bus which handles the SoundWire protocol.
  56. Programs all the MIPI-defined Slave registers. Represents a SoundWire
  57. Master. Multiple instances of Bus may be present in a system.
  58. Slave:
  59. Registers as SoundWire Slave device (Linux Device). Multiple Slave devices
  60. can register to a Bus instance.
  61. Slave driver:
  62. Driver controlling the Slave device. MIPI-specified registers are controlled
  63. directly by the Bus (and transmitted through the Master driver/interface).
  64. Any implementation-defined Slave register is controlled by Slave driver. In
  65. practice, it is expected that the Slave driver relies on regmap and does not
  66. request direct register access.
  67. Programming interfaces (SoundWire Master interface Driver)
  68. ==========================================================
  69. SoundWire Bus supports programming interfaces for the SoundWire Master
  70. implementation and SoundWire Slave devices. All the code uses the "sdw"
  71. prefix commonly used by SoC designers and 3rd party vendors.
  72. Each of the SoundWire Master interfaces needs to be registered to the Bus.
  73. Bus implements API to read standard Master MIPI properties and also provides
  74. callback in Master ops for Master driver to implement its own functions that
  75. provides capabilities information. DT support is not implemented at this
  76. time but should be trivial to add since capabilities are enabled with the
  77. ``device_property_`` API.
  78. The Master interface along with the Master interface capabilities are
  79. registered based on board file, DT or ACPI.
  80. Following is the Bus API to register the SoundWire Bus:
  81. .. code-block:: c
  82. int sdw_bus_master_add(struct sdw_bus *bus,
  83. struct device *parent,
  84. struct fwnode_handle)
  85. {
  86. sdw_master_device_add(bus, parent, fwnode);
  87. mutex_init(&bus->lock);
  88. INIT_LIST_HEAD(&bus->slaves);
  89. /* Check ACPI for Slave devices */
  90. sdw_acpi_find_slaves(bus);
  91. /* Check DT for Slave devices */
  92. sdw_of_find_slaves(bus);
  93. return 0;
  94. }
  95. This will initialize sdw_bus object for Master device. "sdw_master_ops" and
  96. "sdw_master_port_ops" callback functions are provided to the Bus.
  97. "sdw_master_ops" is used by Bus to control the Bus in the hardware specific
  98. way. It includes Bus control functions such as sending the SoundWire
  99. read/write messages on Bus, setting up clock frequency & Stream
  100. Synchronization Point (SSP). The "sdw_master_ops" structure abstracts the
  101. hardware details of the Master from the Bus.
  102. "sdw_master_port_ops" is used by Bus to setup the Port parameters of the
  103. Master interface Port. Master interface Port register map is not defined by
  104. MIPI specification, so Bus calls the "sdw_master_port_ops" callback
  105. function to do Port operations like "Port Prepare", "Port Transport params
  106. set", "Port enable and disable". The implementation of the Master driver can
  107. then perform hardware-specific configurations.
  108. Programming interfaces (SoundWire Slave Driver)
  109. ===============================================
  110. The MIPI specification requires each Slave interface to expose a unique
  111. 48-bit identifier, stored in 6 read-only dev_id registers. This dev_id
  112. identifier contains vendor and part information, as well as a field enabling
  113. to differentiate between identical components. An additional class field is
  114. currently unused. Slave driver is written for a specific vendor and part
  115. identifier, Bus enumerates the Slave device based on these two ids.
  116. Slave device and driver match is done based on these two ids . Probe
  117. of the Slave driver is called by Bus on successful match between device and
  118. driver id. A parent/child relationship is enforced between Master and Slave
  119. devices (the logical representation is aligned with the physical
  120. connectivity).
  121. The information on Master/Slave dependencies is stored in platform data,
  122. board-file, ACPI or DT. The MIPI Software specification defines additional
  123. link_id parameters for controllers that have multiple Master interfaces. The
  124. dev_id registers are only unique in the scope of a link, and the link_id
  125. unique in the scope of a controller. Both dev_id and link_id are not
  126. necessarily unique at the system level but the parent/child information is
  127. used to avoid ambiguity.
  128. .. code-block:: c
  129. static const struct sdw_device_id slave_id[] = {
  130. SDW_SLAVE_ENTRY(0x025d, 0x700, 0),
  131. {},
  132. };
  133. MODULE_DEVICE_TABLE(sdw, slave_id);
  134. static struct sdw_driver slave_sdw_driver = {
  135. .driver = {
  136. .name = "slave_xxx",
  137. .pm = &slave_runtime_pm,
  138. },
  139. .probe = slave_sdw_probe,
  140. .remove = slave_sdw_remove,
  141. .ops = &slave_slave_ops,
  142. .id_table = slave_id,
  143. };
  144. For capabilities, Bus implements API to read standard Slave MIPI properties
  145. and also provides callback in Slave ops for Slave driver to implement own
  146. function that provides capabilities information. Bus needs to know a set of
  147. Slave capabilities to program Slave registers and to control the Bus
  148. reconfigurations.
  149. Future enhancements to be done
  150. ==============================
  151. (1) Bulk Register Access (BRA) transfers.
  152. (2) Multiple data lane support.
  153. Links
  154. =====
  155. SoundWire MIPI specification 1.1 is available at:
  156. https://members.mipi.org/wg/All-Members/document/70290
  157. SoundWire MIPI DisCo (Discovery and Configuration) specification is
  158. available at:
  159. https://www.mipi.org/specifications/mipi-disco-soundwire
  160. (publicly accessible with registration or directly accessible to MIPI
  161. members)
  162. MIPI Alliance Manufacturer ID Page: mid.mipi.org