Skip to content

Commit 79e7123

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: intel_ace2x: fix wakeup handling
The initial programming sequence only worked in the case where the OFLEN bit is set, i.e. the DSP handles the SoundWire interface. In the Linux integration, the interface is owned by the host. This disconnect leads to wake-ups being routed to the DSP and not to the host. The suggested update is to rely on the global HDAudio WAKEEN/STATESTS registers, with the SDI bits used to program the wakeups and check the status. Note that there is no way to know which peripheral generated a wake-up. When the hardware detects a change, it sets all the bits corresponding to LSDIIDx. The LSDIIDx information can be used to figure out on which link the wakeup happened, but for further details the software will have to check the status of each peripheral. Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Rander Wang <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 4cd5ea6 commit 79e7123

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

drivers/soundwire/intel_ace2x.c

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
#include <linux/soundwire/sdw_registers.h>
1111
#include <linux/soundwire/sdw.h>
1212
#include <linux/soundwire/sdw_intel.h>
13-
#include <sound/pcm_params.h>
13+
#include <sound/hdaudio.h>
1414
#include <sound/hda-mlink.h>
15+
#include <sound/hda_register.h>
16+
#include <sound/pcm_params.h>
1517
#include "cadence_master.h"
1618
#include "bus.h"
1719
#include "intel.h"
@@ -49,37 +51,56 @@ static void intel_shim_vs_set_clock_source(struct sdw_intel *sdw, u32 source)
4951

5052
static int intel_shim_check_wake(struct sdw_intel *sdw)
5153
{
52-
void __iomem *shim_vs;
54+
u16 lsdiid = 0;
5355
u16 wake_sts;
56+
int ret;
57+
58+
/* find out which bits are set in LSDIID for this sublink */
59+
ret = hdac_bus_eml_sdw_get_lsdiid_unlocked(sdw->link_res->hbus, sdw->instance, &lsdiid);
60+
if (ret < 0)
61+
return ret;
5462

55-
shim_vs = sdw->link_res->shim_vs;
56-
wake_sts = intel_readw(shim_vs, SDW_SHIM2_INTEL_VS_WAKESTS);
63+
/*
64+
* we need to use the global HDaudio WAKEEN/STS to be able to detect
65+
* wakes in low-power modes
66+
*/
67+
wake_sts = snd_hdac_chip_readw(sdw->link_res->hbus, STATESTS);
5768

58-
return wake_sts & SDW_SHIM2_INTEL_VS_WAKEEN_PWS;
69+
return wake_sts & lsdiid;
5970
}
6071

6172
static void intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
6273
{
63-
void __iomem *shim_vs = sdw->link_res->shim_vs;
74+
u16 lsdiid = 0;
6475
u16 wake_en;
6576
u16 wake_sts;
77+
int ret;
78+
79+
mutex_lock(sdw->link_res->shim_lock);
6680

67-
wake_en = intel_readw(shim_vs, SDW_SHIM2_INTEL_VS_WAKEEN);
81+
ret = hdac_bus_eml_sdw_get_lsdiid_unlocked(sdw->link_res->hbus, sdw->instance, &lsdiid);
82+
if (ret < 0)
83+
goto unlock;
84+
85+
wake_en = snd_hdac_chip_readw(sdw->link_res->hbus, WAKEEN);
6886

6987
if (wake_enable) {
7088
/* Enable the wakeup */
71-
wake_en |= SDW_SHIM2_INTEL_VS_WAKEEN_PWE;
72-
intel_writew(shim_vs, SDW_SHIM2_INTEL_VS_WAKEEN, wake_en);
89+
wake_en |= lsdiid;
90+
91+
snd_hdac_chip_writew(sdw->link_res->hbus, WAKEEN, wake_en);
7392
} else {
7493
/* Disable the wake up interrupt */
75-
wake_en &= ~SDW_SHIM2_INTEL_VS_WAKEEN_PWE;
76-
intel_writew(shim_vs, SDW_SHIM2_INTEL_VS_WAKEEN, wake_en);
94+
wake_en &= ~lsdiid;
95+
snd_hdac_chip_writew(sdw->link_res->hbus, WAKEEN, wake_en);
7796

7897
/* Clear wake status (W1C) */
79-
wake_sts = intel_readw(shim_vs, SDW_SHIM2_INTEL_VS_WAKESTS);
80-
wake_sts |= SDW_SHIM2_INTEL_VS_WAKEEN_PWS;
81-
intel_writew(shim_vs, SDW_SHIM2_INTEL_VS_WAKESTS, wake_sts);
98+
wake_sts = snd_hdac_chip_readw(sdw->link_res->hbus, STATESTS);
99+
wake_sts |= lsdiid;
100+
snd_hdac_chip_writew(sdw->link_res->hbus, STATESTS, wake_sts);
82101
}
102+
unlock:
103+
mutex_unlock(sdw->link_res->shim_lock);
83104
}
84105

85106
static int intel_link_power_up(struct sdw_intel *sdw)

0 commit comments

Comments
 (0)