Skip to content

Commit c458b92

Browse files
committed
ASoc: tas2783A: fw name based on system details
The firmware file for tas2783A contains the device and algorithm settings. So the firmware files are unique for a system and driver should have the ability to distinctly identify and pick the right firmware. This commit adds the method to uniquely identify the firmware for a system based on the below format. <Subsystem>-<Link>-<Unique>.bin * Subsystem is the PCI device subsystem-id * Link is the SoundWire link id on which the device recides. * Unique is the SoundWire slave unique id in the system. Signed-off-by: Niranjan H Y <niranjan.hy@ti.com> --- v2: - rename get_hwid to get_pci_dev - update commit message
1 parent e6fe84e commit c458b92

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

sound/soc/codecs/tas2783-sdw.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/soundwire/sdw.h>
2828
#include <linux/soundwire/sdw_registers.h>
2929
#include <linux/soundwire/sdw_type.h>
30+
#include <linux/pci.h>
3031
#include <sound/sdca_function.h>
3132
#include <sound/sdw.h>
3233
#include <sound/soc.h>
@@ -1171,15 +1172,35 @@ static const struct dev_pm_ops tas2783_sdca_pm = {
11711172
RUNTIME_PM_OPS(tas2783_sdca_dev_suspend, tas2783_sdca_dev_resume, NULL)
11721173
};
11731174

1175+
static struct pci_dev *tas_get_pci_dev(struct sdw_slave *peripheral)
1176+
{
1177+
struct device *dev = &peripheral->dev;
1178+
1179+
for (; dev; dev = dev->parent)
1180+
if (dev->bus == &pci_bus_type)
1181+
return to_pci_dev(dev);
1182+
1183+
return NULL;
1184+
}
1185+
11741186
static s32 tas_io_init(struct device *dev, struct sdw_slave *slave)
11751187
{
1188+
struct pci_dev *pci;
1189+
struct sdw_bus *bus;
11761190
struct tas2783_prv *tas_dev = dev_get_drvdata(dev);
11771191
s32 ret;
11781192
u8 unique_id = tas_dev->sdw_peripheral->id.unique_id;
11791193

11801194
if (tas_dev->hw_init)
11811195
return 0;
11821196

1197+
pci = tas_get_pci_dev(slave);
1198+
if (!pci) {
1199+
dev_err(dev, "pci device id can't be read");
1200+
return -EINVAL;
1201+
}
1202+
1203+
bus = slave->bus;
11831204
tas_dev->fw_dl_task_done = false;
11841205
tas_dev->fw_dl_success = false;
11851206

@@ -1190,8 +1211,10 @@ static s32 tas_io_init(struct device *dev, struct sdw_slave *slave)
11901211
}
11911212
usleep_range(2000, 2200);
11921213

1214+
/* subsystem_id-link_id-unique_id */
11931215
scnprintf(tas_dev->rca_binaryname, sizeof(tas_dev->rca_binaryname),
1194-
"tas2783-%01x.bin", unique_id);
1216+
"%04X-%1X-%1X.bin", pci->subsystem_device, bus->link_id,
1217+
unique_id);
11951218

11961219
ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
11971220
tas_dev->rca_binaryname, tas_dev->dev,

0 commit comments

Comments
 (0)