Skip to content

Commit 6543ac1

Browse files
plbossartvinodkoul
authored andcommitted
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 <[email protected]> Reviewed-by: Vijendar Mukunda <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Tested-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/stable/20231017160933.12624-2-pierre-louis.bossart%40linux.intel.com Tested-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 21f4c44 commit 6543ac1

File tree

7 files changed

+23
-3
lines changed

7 files changed

+23
-3
lines changed

drivers/soundwire/amd_manager.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,14 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
927927
amd_manager->bus.clk_stop_timeout = 200;
928928
amd_manager->bus.link_id = amd_manager->instance;
929929

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+
930938
switch (amd_manager->instance) {
931939
case ACP_SDW0:
932940
amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS;

drivers/soundwire/bus.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ static int sdw_get_id(struct sdw_bus *bus)
2222
return rc;
2323

2424
bus->id = rc;
25+
26+
if (bus->controller_id == -1)
27+
bus->controller_id = rc;
28+
2529
return 0;
2630
}
2731

drivers/soundwire/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void sdw_bus_debugfs_init(struct sdw_bus *bus)
2020
return;
2121

2222
/* 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);
2424
bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root);
2525
}
2626

drivers/soundwire/intel_auxdevice.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
234234
cdns->instance = sdw->instance;
235235
cdns->msg_count = 0;
236236

237+
/* single controller for all SoundWire links */
238+
bus->controller_id = 0;
239+
237240
bus->link_id = auxdev->id;
238241
bus->clk_stop_timeout = 1;
239242

drivers/soundwire/master.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
145145
md->dev.fwnode = fwnode;
146146
md->dev.dma_mask = parent->dma_mask;
147147

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);
149149

150150
ret = device_register(&md->dev);
151151
if (ret) {

drivers/soundwire/qcom.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,9 @@ static int qcom_swrm_probe(struct platform_device *pdev)
16201620
}
16211621
}
16221622

1623+
/* FIXME: is there a DT-defined value to use ? */
1624+
ctrl->bus.controller_id = -1;
1625+
16231626
ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode);
16241627
if (ret) {
16251628
dev_err(dev, "Failed to register Soundwire controller (%d)\n",

include/linux/soundwire/sdw.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,8 @@ struct sdw_master_ops {
886886
* struct sdw_bus - SoundWire bus
887887
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
888888
* @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
890891
* @id: bus system-wide unique id
891892
* @slaves: list of Slaves on this bus
892893
* @assigned: Bitmap for Slave device numbers.
@@ -918,6 +919,7 @@ struct sdw_master_ops {
918919
struct sdw_bus {
919920
struct device *dev;
920921
struct sdw_master_device *md;
922+
int controller_id;
921923
unsigned int link_id;
922924
int id;
923925
struct list_head slaves;

0 commit comments

Comments
 (0)