Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: bus: introduce controller_id

The existing SoundWire support misses a clear Controller/Manager
hiearchical definition to deal with all variants across SOC vendors.

a) Intel platforms have one controller with 4 or more Managers.
b) AMD platforms have two controllers with one Manager each, but due
to BIOS issues use two different link_id values within the scope of a
single controller.
c) QCOM platforms have one or more controller with one Manager each.

This patch adds a 'controller_id' which can be set by higher
levels. If assigned to -1, the controller_id will be set to the
system-unique IDA-assigned bus->id.

The main change is that the bus->id is no longer used for any device
name, which makes the definition completely predictable and not
dependent on any enumeration order. The bus->id is only used to insert
the Managers in the stream rt context.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/stable/20231017160933.12624-2-pierre-louis.bossart%40linux.intel.com
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231017160933.12624-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Pierre-Louis Bossart and committed by
Vinod Koul
6543ac13 21f4c443

+23 -3
+8
drivers/soundwire/amd_manager.c
··· 927 927 amd_manager->bus.clk_stop_timeout = 200; 928 928 amd_manager->bus.link_id = amd_manager->instance; 929 929 930 + /* 931 + * Due to BIOS compatibility, the two links are exposed within 932 + * the scope of a single controller. If this changes, the 933 + * controller_id will have to be updated with drv_data 934 + * information. 935 + */ 936 + amd_manager->bus.controller_id = 0; 937 + 930 938 switch (amd_manager->instance) { 931 939 case ACP_SDW0: 932 940 amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS;
+4
drivers/soundwire/bus.c
··· 22 22 return rc; 23 23 24 24 bus->id = rc; 25 + 26 + if (bus->controller_id == -1) 27 + bus->controller_id = rc; 28 + 25 29 return 0; 26 30 } 27 31
+1 -1
drivers/soundwire/debugfs.c
··· 20 20 return; 21 21 22 22 /* create the debugfs master-N */ 23 - snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id); 23 + snprintf(name, sizeof(name), "master-%d-%d", bus->controller_id, bus->link_id); 24 24 bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root); 25 25 } 26 26
+3
drivers/soundwire/intel_auxdevice.c
··· 234 234 cdns->instance = sdw->instance; 235 235 cdns->msg_count = 0; 236 236 237 + /* single controller for all SoundWire links */ 238 + bus->controller_id = 0; 239 + 237 240 bus->link_id = auxdev->id; 238 241 bus->clk_stop_timeout = 1; 239 242
+1 -1
drivers/soundwire/master.c
··· 145 145 md->dev.fwnode = fwnode; 146 146 md->dev.dma_mask = parent->dma_mask; 147 147 148 - dev_set_name(&md->dev, "sdw-master-%d", bus->id); 148 + dev_set_name(&md->dev, "sdw-master-%d-%d", bus->controller_id, bus->link_id); 149 149 150 150 ret = device_register(&md->dev); 151 151 if (ret) {
+3
drivers/soundwire/qcom.c
··· 1620 1620 } 1621 1621 } 1622 1622 1623 + /* FIXME: is there a DT-defined value to use ? */ 1624 + ctrl->bus.controller_id = -1; 1625 + 1623 1626 ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode); 1624 1627 if (ret) { 1625 1628 dev_err(dev, "Failed to register Soundwire controller (%d)\n",
+3 -1
include/linux/soundwire/sdw.h
··· 886 886 * struct sdw_bus - SoundWire bus 887 887 * @dev: Shortcut to &bus->md->dev to avoid changing the entire code. 888 888 * @md: Master device 889 - * @link_id: Link id number, can be 0 to N, unique for each Master 889 + * @controller_id: system-unique controller ID. If set to -1, the bus @id will be used. 890 + * @link_id: Link id number, can be 0 to N, unique for each Controller 890 891 * @id: bus system-wide unique id 891 892 * @slaves: list of Slaves on this bus 892 893 * @assigned: Bitmap for Slave device numbers. ··· 919 918 struct sdw_bus { 920 919 struct device *dev; 921 920 struct sdw_master_device *md; 921 + int controller_id; 922 922 unsigned int link_id; 923 923 int id; 924 924 struct list_head slaves;