Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions drivers/soundwire/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ static void sdw_modify_slave_status(struct sdw_slave *slave,

if (status == SDW_SLAVE_UNATTACHED) {
dev_dbg(&slave->dev,
"%s: initializing completion for Slave %d\n",
"%s: initializing enumeration and init completion for Slave %d\n",
__func__, slave->dev_num);

init_completion(&slave->enumeration_complete);
Expand All @@ -810,7 +810,7 @@ static void sdw_modify_slave_status(struct sdw_slave *slave,
} else if ((status == SDW_SLAVE_ATTACHED) &&
(slave->status == SDW_SLAVE_UNATTACHED)) {
dev_dbg(&slave->dev,
"%s: signaling completion for Slave %d\n",
"%s: signaling enumeration completion for Slave %d\n",
__func__, slave->dev_num);

complete(&slave->enumeration_complete);
Expand Down Expand Up @@ -1463,6 +1463,8 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
bool parity_check;
bool parity_quirk;

dev_dbg(&slave->dev, "%s: start\n", __func__);

sdw_modify_slave_status(slave, SDW_SLAVE_ALERT);

ret = pm_runtime_get_sync(&slave->dev);
Expand Down Expand Up @@ -1499,6 +1501,8 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
}

do {
dev_dbg(&slave->dev, "Interrupt loop count: %d\n", count);

slave_notify = false;

/*
Expand All @@ -1510,12 +1514,20 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
parity_quirk = !slave->first_interrupt_done &&
(slave->prop.quirks & SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY);

dev_dbg(&slave->dev,
"Parity: SDW_SCP_INT1 0x%02x INT1_MASK 0x%02x first_interrupt_done %d\n",
buf, slave->prop.scp_int1_mask, slave->first_interrupt_done);

if (parity_check && !parity_quirk)
dev_err(&slave->dev, "Parity error detected\n");
clear |= SDW_SCP_INT1_PARITY;
}

if (buf & SDW_SCP_INT1_BUS_CLASH) {
dev_dbg(&slave->dev,
"Bus Clash: SDW_SCP_INT1 0x%02x INT1_MASK 0x%02x first_interrupt_done %d\n",
buf, slave->prop.scp_int1_mask, slave->first_interrupt_done);

if (slave->prop.scp_int1_mask & SDW_SCP_INT1_BUS_CLASH)
dev_err(&slave->dev, "Bus clash detected\n");
clear |= SDW_SCP_INT1_BUS_CLASH;
Expand All @@ -1529,6 +1541,10 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
*/

if (buf & SDW_SCP_INT1_IMPL_DEF) {
dev_dbg(&slave->dev,
"Imp-def interrupt: SDW_SCP_INT1 0x%02x INT1_MASK 0x%02x first_interrupt_done %d\n",
buf, slave->prop.scp_int1_mask, slave->first_interrupt_done);

if (slave->prop.scp_int1_mask & SDW_SCP_INT1_IMPL_DEF) {
dev_dbg(&slave->dev, "Slave impl defined interrupt\n");
slave_notify = true;
Expand Down Expand Up @@ -1594,7 +1610,10 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
}

/* at this point all initial interrupt sources were handled */
slave->first_interrupt_done = true;
if (!slave->first_interrupt_done) {
slave->first_interrupt_done = true;
dev_dbg(&slave->dev, "first_interrupt_done set to true\n");
}

/*
* Read status again to ensure no new interrupts arrived
Expand Down Expand Up @@ -1650,13 +1669,16 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
pm_runtime_mark_last_busy(&slave->dev);
pm_runtime_put_autosuspend(&slave->dev);

dev_dbg(&slave->dev, "%s: done\n", __func__);

return ret;
}

static int sdw_update_slave_status(struct sdw_slave *slave,
enum sdw_slave_status status)
{
unsigned long time;
int ret;

if (!slave->probed) {
/*
Expand All @@ -1678,7 +1700,11 @@ static int sdw_update_slave_status(struct sdw_slave *slave,
if (!slave->ops || !slave->ops->update_status)
return 0;

return slave->ops->update_status(slave, status);
dev_dbg(&slave->dev, "update_status starting\n");
ret = slave->ops->update_status(slave, status);
dev_dbg(&slave->dev, "update_status done\n");

return ret;
}

/**
Expand Down Expand Up @@ -1748,6 +1774,12 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
break;

case SDW_SLAVE_ALERT:
if (slave->status != SDW_SLAVE_ATTACHED) {
dev_err(&slave->dev,
"Slave %d reports alert but was not attached before\n", i);
break;
}

ret = sdw_handle_slave_alerts(slave);
if (ret)
dev_err(&slave->dev,
Expand Down Expand Up @@ -1785,8 +1817,13 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
if (ret)
dev_err(&slave->dev,
"Update Slave status failed:%d\n", ret);
if (attached_initializing)
if (attached_initializing) {
dev_dbg(&slave->dev,
"%s: signaling initialization completion for Slave %d\n",
__func__, slave->dev_num);

complete(&slave->initialization_complete);
}
}

return ret;
Expand Down Expand Up @@ -1814,6 +1851,7 @@ void sdw_clear_slave_status(struct sdw_bus *bus, u32 request)
if (slave->status != SDW_SLAVE_UNATTACHED) {
sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
slave->first_interrupt_done = false;
dev_dbg(&slave->dev, "first_interrupt_done set to false\n");
}

/* keep track of request, used in pm_runtime resume */
Expand Down
9 changes: 9 additions & 0 deletions drivers/soundwire/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,8 @@ static int __maybe_unused intel_resume(struct device *dev)
return 0;
}

dev_dbg(dev, "%s: start\n", __func__);

link_flags = md_flags >> (bus->link_id * 8);
multi_link = !(link_flags & SDW_INTEL_MASTER_DISABLE_MULTI_LINK);

Expand Down Expand Up @@ -1795,6 +1797,9 @@ static int __maybe_unused intel_resume(struct device *dev)
*/
pm_runtime_mark_last_busy(dev);

dev_dbg(dev, "%s: done\n", __func__);


return ret;
}

Expand All @@ -1816,6 +1821,8 @@ static int intel_resume_runtime(struct device *dev)
return 0;
}

dev_dbg(dev, "%s: start\n", __func__);

link_flags = md_flags >> (bus->link_id * 8);
multi_link = !(link_flags & SDW_INTEL_MASTER_DISABLE_MULTI_LINK);

Expand Down Expand Up @@ -1968,6 +1975,8 @@ static int intel_resume_runtime(struct device *dev)
ret = -EINVAL;
}

dev_dbg(dev, "%s: done\n", __func__);

return ret;
}

Expand Down
29 changes: 29 additions & 0 deletions drivers/soundwire/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,36 @@ static void sdw_master_device_release(struct device *dev)
kfree(md);
}

static int __maybe_unused sdw_master_device_suspend(struct device *dev)
{
dev_dbg(dev, "%s: start\n", __func__);

dev_dbg(dev, "%s: done\n", __func__);

return 0;
}

static int __maybe_unused sdw_master_device_resume(struct device *dev)
{
dev_dbg(dev, "%s: start\n", __func__);

if (pm_runtime_suspended(dev)) {
dev_dbg(dev, "%s: pm_runtime status was suspended, forcing active\n", __func__);

/* follow required sequence from runtime_pm.rst */
pm_runtime_disable(dev);
pm_runtime_set_active(dev);
pm_runtime_mark_last_busy(dev);
pm_runtime_enable(dev);
}

dev_dbg(dev, "%s: done\n", __func__);

return 0;
}

static const struct dev_pm_ops master_dev_pm = {
SET_SYSTEM_SLEEP_PM_OPS(sdw_master_device_suspend, sdw_master_device_resume)
SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend,
pm_generic_runtime_resume, NULL)
};
Expand Down
47 changes: 44 additions & 3 deletions sound/soc/codecs/max98373-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,29 +259,69 @@ static __maybe_unused int max98373_resume(struct device *dev)
struct max98373_priv *max98373 = dev_get_drvdata(dev);
unsigned long time;

if (!max98373->hw_init)
dev_dbg(dev, "%s: start\n", __func__);

if (!max98373->hw_init) {
dev_dbg(dev, "%s: done - hw_init not necessary\n",
__func__);
return 0;
}

if (!slave->unattach_request)
goto regmap_sync;


slave->unattach_request = 0;

dev_dbg(dev, "%s: wait_for_completion start\n", __func__);

time = wait_for_completion_timeout(&slave->initialization_complete,
msecs_to_jiffies(MAX98373_PROBE_TIMEOUT));
if (!time) {
dev_err(dev, "Initialization not complete, timed out\n");
return -ETIMEDOUT;
}

dev_dbg(dev, "%s: wait_for_completion start\n", __func__);

regmap_sync:
slave->unattach_request = 0;
dev_dbg(dev, "%s: regmap_sync\n", __func__);

regcache_cache_only(max98373->regmap, false);
regcache_sync(max98373->regmap);

pm_runtime_mark_last_busy(dev);

dev_dbg(dev, "%s: done\n", __func__);

return 0;
}

static __maybe_unused int max98373_system_resume(struct device *dev)
{
int ret;

dev_dbg(dev, "%s: start\n", __func__);

if (pm_runtime_suspended(dev)) {
dev_dbg(dev, "%s: pm_runtime status was suspended, forcing active\n", __func__);

/* follow required sequence from runtime_pm.rst */
pm_runtime_disable(dev);
pm_runtime_set_active(dev);
pm_runtime_mark_last_busy(dev);
pm_runtime_enable(dev);
}

ret = max98373_resume(dev);

dev_dbg(dev, "%s: done\n", __func__);

return ret;
}

static const struct dev_pm_ops max98373_pm = {
SET_SYSTEM_SLEEP_PM_OPS(max98373_suspend, max98373_resume)
SET_SYSTEM_SLEEP_PM_OPS(max98373_suspend, max98373_system_resume)
SET_RUNTIME_PM_OPS(max98373_suspend, max98373_resume, NULL)
};

Expand All @@ -294,6 +334,7 @@ static int max98373_read_prop(struct sdw_slave *slave)
struct sdw_dpn_prop *dpn;

prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY;
prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY;

/* BITMAP: 00001000 Dataport 3 is active */
prop->source_ports = BIT(3);
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt1308-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,8 @@ static int __maybe_unused rt1308_dev_resume(struct device *dev)
if (!slave->unattach_request)
goto regmap_sync;

slave->unattach_request = 0;

time = wait_for_completion_timeout(&slave->initialization_complete,
msecs_to_jiffies(RT1308_PROBE_TIMEOUT));
if (!time) {
Expand All @@ -723,7 +725,6 @@ static int __maybe_unused rt1308_dev_resume(struct device *dev)
}

regmap_sync:
slave->unattach_request = 0;
regcache_cache_only(rt1308->regmap, false);
regcache_sync_region(rt1308->regmap, 0xc000, 0xcfff);

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt1316-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ static int __maybe_unused rt1316_dev_resume(struct device *dev)
if (!slave->unattach_request)
goto regmap_sync;

slave->unattach_request = 0;

time = wait_for_completion_timeout(&slave->initialization_complete,
msecs_to_jiffies(RT1316_PROBE_TIMEOUT));
if (!time) {
Expand All @@ -727,7 +729,6 @@ static int __maybe_unused rt1316_dev_resume(struct device *dev)
}

regmap_sync:
slave->unattach_request = 0;
regcache_cache_only(rt1316->regmap, false);
regcache_sync(rt1316->regmap);

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt5682-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,8 @@ static int __maybe_unused rt5682_dev_resume(struct device *dev)
if (!slave->unattach_request)
goto regmap_sync;

slave->unattach_request = 0;

time = wait_for_completion_timeout(&slave->initialization_complete,
msecs_to_jiffies(RT5682_PROBE_TIMEOUT));
if (!time) {
Expand All @@ -749,7 +751,6 @@ static int __maybe_unused rt5682_dev_resume(struct device *dev)
}

regmap_sync:
slave->unattach_request = 0;
regcache_cache_only(rt5682->regmap, false);
regcache_sync(rt5682->regmap);

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt700-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ static int __maybe_unused rt700_dev_resume(struct device *dev)
if (!slave->unattach_request)
goto regmap_sync;

slave->unattach_request = 0;

time = wait_for_completion_timeout(&slave->initialization_complete,
msecs_to_jiffies(RT700_PROBE_TIMEOUT));
if (!time) {
Expand All @@ -512,7 +514,6 @@ static int __maybe_unused rt700_dev_resume(struct device *dev)
}

regmap_sync:
slave->unattach_request = 0;
regcache_cache_only(rt700->regmap, false);
regcache_sync_region(rt700->regmap, 0x3000, 0x8fff);
regcache_sync_region(rt700->regmap, 0x752010, 0x75206b);
Expand Down
Loading