Skip to content

Commit

Permalink
soundwire: bus: introduce controller_id
Browse files Browse the repository at this point in the history
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.
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.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
  • Loading branch information
plbossart committed Oct 4, 2023
1 parent 5c85a87 commit 64bb8bf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions drivers/soundwire/amd_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
amd_manager->bus.compute_params = &amd_sdw_compute_params;
amd_manager->bus.clk_stop_timeout = 200;
amd_manager->bus.link_id = amd_manager->instance;
amd_manager->bus.controller_id = amd_manager->instance;

switch (amd_manager->instance) {
case ACP_SDW0:
Expand Down
4 changes: 4 additions & 0 deletions drivers/soundwire/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ static int sdw_get_id(struct sdw_bus *bus)
return rc;

bus->id = rc;

if (bus->controller_id == -1)
bus->controller_id = rc;

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/soundwire/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void sdw_bus_debugfs_init(struct sdw_bus *bus)
return;

/* create the debugfs master-N */
snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id);
snprintf(name, sizeof(name), "master-%d-%d", bus->controller_id, bus->link_id);
bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root);
}

Expand Down
3 changes: 3 additions & 0 deletions drivers/soundwire/intel_auxdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
cdns->instance = sdw->instance;
cdns->msg_count = 0;

/* single controller for all SoundWire links */
bus->controller_id = 0;

bus->link_id = auxdev->id;
bus->clk_stop_timeout = 1;

Expand Down
2 changes: 1 addition & 1 deletion drivers/soundwire/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
md->dev.fwnode = fwnode;
md->dev.dma_mask = parent->dma_mask;

dev_set_name(&md->dev, "sdw-master-%d", bus->id);
dev_set_name(&md->dev, "sdw-master-%d-%d", bus->controller_id, bus->link_id);

ret = device_register(&md->dev);
if (ret) {
Expand Down
3 changes: 3 additions & 0 deletions drivers/soundwire/qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,9 @@ static int qcom_swrm_probe(struct platform_device *pdev)
}
}

/* FIXME: is there a DT-defined value to use ? */
ctrl->bus.controller_id = -1;

ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode);
if (ret) {
dev_err(dev, "Failed to register Soundwire controller (%d)\n",
Expand Down
4 changes: 3 additions & 1 deletion include/linux/soundwire/sdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,8 @@ struct sdw_master_ops {
* struct sdw_bus - SoundWire bus
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
* @md: Master device
* @link_id: Link id number, can be 0 to N, unique for each Master
* @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
* @link_id: Link id number, can be 0 to N, unique for each Controller
* @id: bus system-wide unique id
* @slaves: list of Slaves on this bus
* @assigned: Bitmap for Slave device numbers.
Expand Down Expand Up @@ -918,6 +919,7 @@ struct sdw_master_ops {
struct sdw_bus {
struct device *dev;
struct sdw_master_device *md;
int controller_id;
unsigned int link_id;
int id;
struct list_head slaves;
Expand Down

0 comments on commit 64bb8bf

Please sign in to comment.