162306a36Sopenharmony_ci=========================== 262306a36Sopenharmony_ciSoundWire Subsystem Summary 362306a36Sopenharmony_ci=========================== 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciSoundWire is a new interface ratified in 2015 by the MIPI Alliance. 662306a36Sopenharmony_ciSoundWire is used for transporting data typically related to audio 762306a36Sopenharmony_cifunctions. SoundWire interface is optimized to integrate audio devices in 862306a36Sopenharmony_cimobile or mobile inspired systems. 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciSoundWire is a 2-pin multi-drop interface with data and clock line. It 1162306a36Sopenharmony_cifacilitates development of low cost, efficient, high performance systems. 1262306a36Sopenharmony_ciBroad level key features of SoundWire interface include: 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci (1) Transporting all of payload data channels, control information, and setup 1562306a36Sopenharmony_ci commands over a single two-pin interface. 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci (2) Lower clock frequency, and hence lower power consumption, by use of DDR 1862306a36Sopenharmony_ci (Dual Data Rate) data transmission. 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci (3) Clock scaling and optional multiple data lanes to give wide flexibility 2162306a36Sopenharmony_ci in data rate to match system requirements. 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci (4) Device status monitoring, including interrupt-style alerts to the Master. 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ciThe SoundWire protocol supports up to eleven Slave interfaces. All the 2662306a36Sopenharmony_ciinterfaces share the common Bus containing data and clock line. Each of the 2762306a36Sopenharmony_ciSlaves can support up to 14 Data Ports. 13 Data Ports are dedicated to audio 2862306a36Sopenharmony_citransport. Data Port0 is dedicated to transport of Bulk control information, 2962306a36Sopenharmony_cieach of the audio Data Ports (1..14) can support up to 8 Channels in 3062306a36Sopenharmony_citransmit or receiving mode (typically fixed direction but configurable 3162306a36Sopenharmony_cidirection is enabled by the specification). Bandwidth restrictions to 3262306a36Sopenharmony_ci~19.2..24.576Mbits/s don't however allow for 11*13*8 channels to be 3362306a36Sopenharmony_citransmitted simultaneously. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciBelow figure shows an example of connectivity between a SoundWire Master and 3662306a36Sopenharmony_citwo Slave devices. :: 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci +---------------+ +---------------+ 3962306a36Sopenharmony_ci | | Clock Signal | | 4062306a36Sopenharmony_ci | Master |-------+-------------------------------| Slave | 4162306a36Sopenharmony_ci | Interface | | Data Signal | Interface 1 | 4262306a36Sopenharmony_ci | |-------|-------+-----------------------| | 4362306a36Sopenharmony_ci +---------------+ | | +---------------+ 4462306a36Sopenharmony_ci | | 4562306a36Sopenharmony_ci | | 4662306a36Sopenharmony_ci | | 4762306a36Sopenharmony_ci +--+-------+--+ 4862306a36Sopenharmony_ci | | 4962306a36Sopenharmony_ci | Slave | 5062306a36Sopenharmony_ci | Interface 2 | 5162306a36Sopenharmony_ci | | 5262306a36Sopenharmony_ci +-------------+ 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ciTerminology 5662306a36Sopenharmony_ci=========== 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ciThe MIPI SoundWire specification uses the term 'device' to refer to a Master 5962306a36Sopenharmony_cior Slave interface, which of course can be confusing. In this summary and 6062306a36Sopenharmony_cicode we use the term interface only to refer to the hardware. We follow the 6162306a36Sopenharmony_ciLinux device model by mapping each Slave interface connected on the bus as a 6262306a36Sopenharmony_cidevice managed by a specific driver. The Linux SoundWire subsystem provides 6362306a36Sopenharmony_cia framework to implement a SoundWire Slave driver with an API allowing 6462306a36Sopenharmony_ci3rd-party vendors to enable implementation-defined functionality while 6562306a36Sopenharmony_cicommon setup/configuration tasks are handled by the bus. 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ciBus: 6862306a36Sopenharmony_ciImplements SoundWire Linux Bus which handles the SoundWire protocol. 6962306a36Sopenharmony_ciPrograms all the MIPI-defined Slave registers. Represents a SoundWire 7062306a36Sopenharmony_ciMaster. Multiple instances of Bus may be present in a system. 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ciSlave: 7362306a36Sopenharmony_ciRegisters as SoundWire Slave device (Linux Device). Multiple Slave devices 7462306a36Sopenharmony_cican register to a Bus instance. 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ciSlave driver: 7762306a36Sopenharmony_ciDriver controlling the Slave device. MIPI-specified registers are controlled 7862306a36Sopenharmony_cidirectly by the Bus (and transmitted through the Master driver/interface). 7962306a36Sopenharmony_ciAny implementation-defined Slave register is controlled by Slave driver. In 8062306a36Sopenharmony_cipractice, it is expected that the Slave driver relies on regmap and does not 8162306a36Sopenharmony_cirequest direct register access. 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ciProgramming interfaces (SoundWire Master interface Driver) 8462306a36Sopenharmony_ci========================================================== 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ciSoundWire Bus supports programming interfaces for the SoundWire Master 8762306a36Sopenharmony_ciimplementation and SoundWire Slave devices. All the code uses the "sdw" 8862306a36Sopenharmony_ciprefix commonly used by SoC designers and 3rd party vendors. 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ciEach of the SoundWire Master interfaces needs to be registered to the Bus. 9162306a36Sopenharmony_ciBus implements API to read standard Master MIPI properties and also provides 9262306a36Sopenharmony_cicallback in Master ops for Master driver to implement its own functions that 9362306a36Sopenharmony_ciprovides capabilities information. DT support is not implemented at this 9462306a36Sopenharmony_citime but should be trivial to add since capabilities are enabled with the 9562306a36Sopenharmony_ci``device_property_`` API. 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ciThe Master interface along with the Master interface capabilities are 9862306a36Sopenharmony_ciregistered based on board file, DT or ACPI. 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ciFollowing is the Bus API to register the SoundWire Bus: 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci.. code-block:: c 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci int sdw_bus_master_add(struct sdw_bus *bus, 10562306a36Sopenharmony_ci struct device *parent, 10662306a36Sopenharmony_ci struct fwnode_handle) 10762306a36Sopenharmony_ci { 10862306a36Sopenharmony_ci sdw_master_device_add(bus, parent, fwnode); 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci mutex_init(&bus->lock); 11162306a36Sopenharmony_ci INIT_LIST_HEAD(&bus->slaves); 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci /* Check ACPI for Slave devices */ 11462306a36Sopenharmony_ci sdw_acpi_find_slaves(bus); 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci /* Check DT for Slave devices */ 11762306a36Sopenharmony_ci sdw_of_find_slaves(bus); 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci return 0; 12062306a36Sopenharmony_ci } 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ciThis will initialize sdw_bus object for Master device. "sdw_master_ops" and 12362306a36Sopenharmony_ci"sdw_master_port_ops" callback functions are provided to the Bus. 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci"sdw_master_ops" is used by Bus to control the Bus in the hardware specific 12662306a36Sopenharmony_ciway. It includes Bus control functions such as sending the SoundWire 12762306a36Sopenharmony_ciread/write messages on Bus, setting up clock frequency & Stream 12862306a36Sopenharmony_ciSynchronization Point (SSP). The "sdw_master_ops" structure abstracts the 12962306a36Sopenharmony_cihardware details of the Master from the Bus. 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci"sdw_master_port_ops" is used by Bus to setup the Port parameters of the 13262306a36Sopenharmony_ciMaster interface Port. Master interface Port register map is not defined by 13362306a36Sopenharmony_ciMIPI specification, so Bus calls the "sdw_master_port_ops" callback 13462306a36Sopenharmony_cifunction to do Port operations like "Port Prepare", "Port Transport params 13562306a36Sopenharmony_ciset", "Port enable and disable". The implementation of the Master driver can 13662306a36Sopenharmony_cithen perform hardware-specific configurations. 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ciProgramming interfaces (SoundWire Slave Driver) 13962306a36Sopenharmony_ci=============================================== 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ciThe MIPI specification requires each Slave interface to expose a unique 14262306a36Sopenharmony_ci48-bit identifier, stored in 6 read-only dev_id registers. This dev_id 14362306a36Sopenharmony_ciidentifier contains vendor and part information, as well as a field enabling 14462306a36Sopenharmony_cito differentiate between identical components. An additional class field is 14562306a36Sopenharmony_cicurrently unused. Slave driver is written for a specific vendor and part 14662306a36Sopenharmony_ciidentifier, Bus enumerates the Slave device based on these two ids. 14762306a36Sopenharmony_ciSlave device and driver match is done based on these two ids . Probe 14862306a36Sopenharmony_ciof the Slave driver is called by Bus on successful match between device and 14962306a36Sopenharmony_cidriver id. A parent/child relationship is enforced between Master and Slave 15062306a36Sopenharmony_cidevices (the logical representation is aligned with the physical 15162306a36Sopenharmony_ciconnectivity). 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ciThe information on Master/Slave dependencies is stored in platform data, 15462306a36Sopenharmony_ciboard-file, ACPI or DT. The MIPI Software specification defines additional 15562306a36Sopenharmony_cilink_id parameters for controllers that have multiple Master interfaces. The 15662306a36Sopenharmony_cidev_id registers are only unique in the scope of a link, and the link_id 15762306a36Sopenharmony_ciunique in the scope of a controller. Both dev_id and link_id are not 15862306a36Sopenharmony_cinecessarily unique at the system level but the parent/child information is 15962306a36Sopenharmony_ciused to avoid ambiguity. 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci.. code-block:: c 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci static const struct sdw_device_id slave_id[] = { 16462306a36Sopenharmony_ci SDW_SLAVE_ENTRY(0x025d, 0x700, 0), 16562306a36Sopenharmony_ci {}, 16662306a36Sopenharmony_ci }; 16762306a36Sopenharmony_ci MODULE_DEVICE_TABLE(sdw, slave_id); 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci static struct sdw_driver slave_sdw_driver = { 17062306a36Sopenharmony_ci .driver = { 17162306a36Sopenharmony_ci .name = "slave_xxx", 17262306a36Sopenharmony_ci .pm = &slave_runtime_pm, 17362306a36Sopenharmony_ci }, 17462306a36Sopenharmony_ci .probe = slave_sdw_probe, 17562306a36Sopenharmony_ci .remove = slave_sdw_remove, 17662306a36Sopenharmony_ci .ops = &slave_slave_ops, 17762306a36Sopenharmony_ci .id_table = slave_id, 17862306a36Sopenharmony_ci }; 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ciFor capabilities, Bus implements API to read standard Slave MIPI properties 18262306a36Sopenharmony_ciand also provides callback in Slave ops for Slave driver to implement own 18362306a36Sopenharmony_cifunction that provides capabilities information. Bus needs to know a set of 18462306a36Sopenharmony_ciSlave capabilities to program Slave registers and to control the Bus 18562306a36Sopenharmony_cireconfigurations. 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ciFuture enhancements to be done 18862306a36Sopenharmony_ci============================== 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci (1) Bulk Register Access (BRA) transfers. 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci (2) Multiple data lane support. 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ciLinks 19662306a36Sopenharmony_ci===== 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ciSoundWire MIPI specification 1.1 is available at: 19962306a36Sopenharmony_cihttps://members.mipi.org/wg/All-Members/document/70290 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ciSoundWire MIPI DisCo (Discovery and Configuration) specification is 20262306a36Sopenharmony_ciavailable at: 20362306a36Sopenharmony_cihttps://www.mipi.org/specifications/mipi-disco-soundwire 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci(publicly accessible with registration or directly accessible to MIPI 20662306a36Sopenharmony_cimembers) 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ciMIPI Alliance Manufacturer ID Page: mid.mipi.org 209