1*4882a593Smuzhiyun=========================== 2*4882a593SmuzhiyunSoundWire Subsystem Summary 3*4882a593Smuzhiyun=========================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunSoundWire is a new interface ratified in 2015 by the MIPI Alliance. 6*4882a593SmuzhiyunSoundWire is used for transporting data typically related to audio 7*4882a593Smuzhiyunfunctions. SoundWire interface is optimized to integrate audio devices in 8*4882a593Smuzhiyunmobile or mobile inspired systems. 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunSoundWire is a 2-pin multi-drop interface with data and clock line. It 11*4882a593Smuzhiyunfacilitates development of low cost, efficient, high performance systems. 12*4882a593SmuzhiyunBroad level key features of SoundWire interface include: 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun (1) Transporting all of payload data channels, control information, and setup 15*4882a593Smuzhiyun commands over a single two-pin interface. 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun (2) Lower clock frequency, and hence lower power consumption, by use of DDR 18*4882a593Smuzhiyun (Dual Data Rate) data transmission. 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun (3) Clock scaling and optional multiple data lanes to give wide flexibility 21*4882a593Smuzhiyun in data rate to match system requirements. 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun (4) Device status monitoring, including interrupt-style alerts to the Master. 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunThe SoundWire protocol supports up to eleven Slave interfaces. All the 26*4882a593Smuzhiyuninterfaces share the common Bus containing data and clock line. Each of the 27*4882a593SmuzhiyunSlaves can support up to 14 Data Ports. 13 Data Ports are dedicated to audio 28*4882a593Smuzhiyuntransport. Data Port0 is dedicated to transport of Bulk control information, 29*4882a593Smuzhiyuneach of the audio Data Ports (1..14) can support up to 8 Channels in 30*4882a593Smuzhiyuntransmit or receiving mode (typically fixed direction but configurable 31*4882a593Smuzhiyundirection is enabled by the specification). Bandwidth restrictions to 32*4882a593Smuzhiyun~19.2..24.576Mbits/s don't however allow for 11*13*8 channels to be 33*4882a593Smuzhiyuntransmitted simultaneously. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunBelow figure shows an example of connectivity between a SoundWire Master and 36*4882a593Smuzhiyuntwo Slave devices. :: 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun +---------------+ +---------------+ 39*4882a593Smuzhiyun | | Clock Signal | | 40*4882a593Smuzhiyun | Master |-------+-------------------------------| Slave | 41*4882a593Smuzhiyun | Interface | | Data Signal | Interface 1 | 42*4882a593Smuzhiyun | |-------|-------+-----------------------| | 43*4882a593Smuzhiyun +---------------+ | | +---------------+ 44*4882a593Smuzhiyun | | 45*4882a593Smuzhiyun | | 46*4882a593Smuzhiyun | | 47*4882a593Smuzhiyun +--+-------+--+ 48*4882a593Smuzhiyun | | 49*4882a593Smuzhiyun | Slave | 50*4882a593Smuzhiyun | Interface 2 | 51*4882a593Smuzhiyun | | 52*4882a593Smuzhiyun +-------------+ 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunTerminology 56*4882a593Smuzhiyun=========== 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunThe MIPI SoundWire specification uses the term 'device' to refer to a Master 59*4882a593Smuzhiyunor Slave interface, which of course can be confusing. In this summary and 60*4882a593Smuzhiyuncode we use the term interface only to refer to the hardware. We follow the 61*4882a593SmuzhiyunLinux device model by mapping each Slave interface connected on the bus as a 62*4882a593Smuzhiyundevice managed by a specific driver. The Linux SoundWire subsystem provides 63*4882a593Smuzhiyuna framework to implement a SoundWire Slave driver with an API allowing 64*4882a593Smuzhiyun3rd-party vendors to enable implementation-defined functionality while 65*4882a593Smuzhiyuncommon setup/configuration tasks are handled by the bus. 66*4882a593Smuzhiyun 67*4882a593SmuzhiyunBus: 68*4882a593SmuzhiyunImplements SoundWire Linux Bus which handles the SoundWire protocol. 69*4882a593SmuzhiyunPrograms all the MIPI-defined Slave registers. Represents a SoundWire 70*4882a593SmuzhiyunMaster. Multiple instances of Bus may be present in a system. 71*4882a593Smuzhiyun 72*4882a593SmuzhiyunSlave: 73*4882a593SmuzhiyunRegisters as SoundWire Slave device (Linux Device). Multiple Slave devices 74*4882a593Smuzhiyuncan register to a Bus instance. 75*4882a593Smuzhiyun 76*4882a593SmuzhiyunSlave driver: 77*4882a593SmuzhiyunDriver controlling the Slave device. MIPI-specified registers are controlled 78*4882a593Smuzhiyundirectly by the Bus (and transmitted through the Master driver/interface). 79*4882a593SmuzhiyunAny implementation-defined Slave register is controlled by Slave driver. In 80*4882a593Smuzhiyunpractice, it is expected that the Slave driver relies on regmap and does not 81*4882a593Smuzhiyunrequest direct register access. 82*4882a593Smuzhiyun 83*4882a593SmuzhiyunProgramming interfaces (SoundWire Master interface Driver) 84*4882a593Smuzhiyun========================================================== 85*4882a593Smuzhiyun 86*4882a593SmuzhiyunSoundWire Bus supports programming interfaces for the SoundWire Master 87*4882a593Smuzhiyunimplementation and SoundWire Slave devices. All the code uses the "sdw" 88*4882a593Smuzhiyunprefix commonly used by SoC designers and 3rd party vendors. 89*4882a593Smuzhiyun 90*4882a593SmuzhiyunEach of the SoundWire Master interfaces needs to be registered to the Bus. 91*4882a593SmuzhiyunBus implements API to read standard Master MIPI properties and also provides 92*4882a593Smuzhiyuncallback in Master ops for Master driver to implement its own functions that 93*4882a593Smuzhiyunprovides capabilities information. DT support is not implemented at this 94*4882a593Smuzhiyuntime but should be trivial to add since capabilities are enabled with the 95*4882a593Smuzhiyun``device_property_`` API. 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunThe Master interface along with the Master interface capabilities are 98*4882a593Smuzhiyunregistered based on board file, DT or ACPI. 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunFollowing is the Bus API to register the SoundWire Bus: 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun.. code-block:: c 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun int sdw_bus_master_add(struct sdw_bus *bus, 105*4882a593Smuzhiyun struct device *parent, 106*4882a593Smuzhiyun struct fwnode_handle) 107*4882a593Smuzhiyun { 108*4882a593Smuzhiyun sdw_master_device_add(bus, parent, fwnode); 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun mutex_init(&bus->lock); 111*4882a593Smuzhiyun INIT_LIST_HEAD(&bus->slaves); 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun /* Check ACPI for Slave devices */ 114*4882a593Smuzhiyun sdw_acpi_find_slaves(bus); 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun /* Check DT for Slave devices */ 117*4882a593Smuzhiyun sdw_of_find_slaves(bus); 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun return 0; 120*4882a593Smuzhiyun } 121*4882a593Smuzhiyun 122*4882a593SmuzhiyunThis will initialize sdw_bus object for Master device. "sdw_master_ops" and 123*4882a593Smuzhiyun"sdw_master_port_ops" callback functions are provided to the Bus. 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun"sdw_master_ops" is used by Bus to control the Bus in the hardware specific 126*4882a593Smuzhiyunway. It includes Bus control functions such as sending the SoundWire 127*4882a593Smuzhiyunread/write messages on Bus, setting up clock frequency & Stream 128*4882a593SmuzhiyunSynchronization Point (SSP). The "sdw_master_ops" structure abstracts the 129*4882a593Smuzhiyunhardware details of the Master from the Bus. 130*4882a593Smuzhiyun 131*4882a593Smuzhiyun"sdw_master_port_ops" is used by Bus to setup the Port parameters of the 132*4882a593SmuzhiyunMaster interface Port. Master interface Port register map is not defined by 133*4882a593SmuzhiyunMIPI specification, so Bus calls the "sdw_master_port_ops" callback 134*4882a593Smuzhiyunfunction to do Port operations like "Port Prepare", "Port Transport params 135*4882a593Smuzhiyunset", "Port enable and disable". The implementation of the Master driver can 136*4882a593Smuzhiyunthen perform hardware-specific configurations. 137*4882a593Smuzhiyun 138*4882a593SmuzhiyunProgramming interfaces (SoundWire Slave Driver) 139*4882a593Smuzhiyun=============================================== 140*4882a593Smuzhiyun 141*4882a593SmuzhiyunThe MIPI specification requires each Slave interface to expose a unique 142*4882a593Smuzhiyun48-bit identifier, stored in 6 read-only dev_id registers. This dev_id 143*4882a593Smuzhiyunidentifier contains vendor and part information, as well as a field enabling 144*4882a593Smuzhiyunto differentiate between identical components. An additional class field is 145*4882a593Smuzhiyuncurrently unused. Slave driver is written for a specific vendor and part 146*4882a593Smuzhiyunidentifier, Bus enumerates the Slave device based on these two ids. 147*4882a593SmuzhiyunSlave device and driver match is done based on these two ids . Probe 148*4882a593Smuzhiyunof the Slave driver is called by Bus on successful match between device and 149*4882a593Smuzhiyundriver id. A parent/child relationship is enforced between Master and Slave 150*4882a593Smuzhiyundevices (the logical representation is aligned with the physical 151*4882a593Smuzhiyunconnectivity). 152*4882a593Smuzhiyun 153*4882a593SmuzhiyunThe information on Master/Slave dependencies is stored in platform data, 154*4882a593Smuzhiyunboard-file, ACPI or DT. The MIPI Software specification defines additional 155*4882a593Smuzhiyunlink_id parameters for controllers that have multiple Master interfaces. The 156*4882a593Smuzhiyundev_id registers are only unique in the scope of a link, and the link_id 157*4882a593Smuzhiyununique in the scope of a controller. Both dev_id and link_id are not 158*4882a593Smuzhiyunnecessarily unique at the system level but the parent/child information is 159*4882a593Smuzhiyunused to avoid ambiguity. 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun.. code-block:: c 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun static const struct sdw_device_id slave_id[] = { 164*4882a593Smuzhiyun SDW_SLAVE_ENTRY(0x025d, 0x700, 0), 165*4882a593Smuzhiyun {}, 166*4882a593Smuzhiyun }; 167*4882a593Smuzhiyun MODULE_DEVICE_TABLE(sdw, slave_id); 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun static struct sdw_driver slave_sdw_driver = { 170*4882a593Smuzhiyun .driver = { 171*4882a593Smuzhiyun .name = "slave_xxx", 172*4882a593Smuzhiyun .pm = &slave_runtime_pm, 173*4882a593Smuzhiyun }, 174*4882a593Smuzhiyun .probe = slave_sdw_probe, 175*4882a593Smuzhiyun .remove = slave_sdw_remove, 176*4882a593Smuzhiyun .ops = &slave_slave_ops, 177*4882a593Smuzhiyun .id_table = slave_id, 178*4882a593Smuzhiyun }; 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun 181*4882a593SmuzhiyunFor capabilities, Bus implements API to read standard Slave MIPI properties 182*4882a593Smuzhiyunand also provides callback in Slave ops for Slave driver to implement own 183*4882a593Smuzhiyunfunction that provides capabilities information. Bus needs to know a set of 184*4882a593SmuzhiyunSlave capabilities to program Slave registers and to control the Bus 185*4882a593Smuzhiyunreconfigurations. 186*4882a593Smuzhiyun 187*4882a593SmuzhiyunFuture enhancements to be done 188*4882a593Smuzhiyun============================== 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun (1) Bulk Register Access (BRA) transfers. 191*4882a593Smuzhiyun 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun (2) Multiple data lane support. 194*4882a593Smuzhiyun 195*4882a593SmuzhiyunLinks 196*4882a593Smuzhiyun===== 197*4882a593Smuzhiyun 198*4882a593SmuzhiyunSoundWire MIPI specification 1.1 is available at: 199*4882a593Smuzhiyunhttps://members.mipi.org/wg/All-Members/document/70290 200*4882a593Smuzhiyun 201*4882a593SmuzhiyunSoundWire MIPI DisCo (Discovery and Configuration) specification is 202*4882a593Smuzhiyunavailable at: 203*4882a593Smuzhiyunhttps://www.mipi.org/specifications/mipi-disco-soundwire 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun(publicly accessible with registration or directly accessible to MIPI 206*4882a593Smuzhiyunmembers) 207*4882a593Smuzhiyun 208*4882a593SmuzhiyunMIPI Alliance Manufacturer ID Page: mid.mipi.org 209