Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoundWire: introduce controller_id #4616

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions drivers/soundwire/amd_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,14 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
amd_manager->bus.clk_stop_timeout = 200;
amd_manager->bus.link_id = amd_manager->instance;

/*
* Due to BIOS compatibility, the two links are exposed within
* the scope of a single controller. If this changes, the
* controller_id will have to be updated with drv_data
* information.
*/
amd_manager->bus.controller_id = 0;

switch (amd_manager->instance) {
case ACP_SDW0:
amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS;
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
12 changes: 6 additions & 6 deletions drivers/soundwire/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ int sdw_slave_add(struct sdw_bus *bus,
slave->dev.fwnode = fwnode;

if (id->unique_id == SDW_IGNORED_UNIQUE_ID) {
/* name shall be sdw:link:mfg:part:class */
dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x",
bus->link_id, id->mfg_id, id->part_id,
/* name shall be sdw:ctrl:link:mfg:part:class */
dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x",
bus->controller_id, bus->link_id, id->mfg_id, id->part_id,
id->class_id);
} else {
/* name shall be sdw:link:mfg:part:class:unique */
dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x:%01x",
bus->link_id, id->mfg_id, id->part_id,
/* name shall be sdw:ctrl:link:mfg:part:class:unique */
dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x:%01x",
bus->controller_id, bus->link_id, id->mfg_id, id->part_id,
id->class_id, id->unique_id);
}

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
4 changes: 2 additions & 2 deletions sound/soc/intel/boards/sof_sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,11 +1242,11 @@ static int fill_sdw_codec_dlc(struct device *dev,
else if (is_unique_device(adr_link, sdw_version, mfg_id, part_id,
class_id, adr_index))
codec->name = devm_kasprintf(dev, GFP_KERNEL,
"sdw:%01x:%04x:%04x:%02x", link_id,
"sdw:0:%01x:%04x:%04x:%02x", link_id,
mfg_id, part_id, class_id);
else
codec->name = devm_kasprintf(dev, GFP_KERNEL,
"sdw:%01x:%04x:%04x:%02x:%01x", link_id,
"sdw:0:%01x:%04x:%04x:%02x:%01x", link_id,
mfg_id, part_id, class_id, unique_id);

if (!codec->name)
Expand Down