|
10 | 10 | #include <linux/soundwire/sdw_registers.h>
|
11 | 11 | #include <linux/soundwire/sdw.h>
|
12 | 12 | #include <linux/soundwire/sdw_intel.h>
|
13 |
| -#include <sound/pcm_params.h> |
| 13 | +#include <sound/hdaudio.h> |
14 | 14 | #include <sound/hda-mlink.h>
|
| 15 | +#include <sound/hda_register.h> |
| 16 | +#include <sound/pcm_params.h> |
15 | 17 | #include "cadence_master.h"
|
16 | 18 | #include "bus.h"
|
17 | 19 | #include "intel.h"
|
@@ -49,37 +51,56 @@ static void intel_shim_vs_set_clock_source(struct sdw_intel *sdw, u32 source)
|
49 | 51 |
|
50 | 52 | static int intel_shim_check_wake(struct sdw_intel *sdw)
|
51 | 53 | {
|
52 |
| - void __iomem *shim_vs; |
| 54 | + u16 lsdiid = 0; |
53 | 55 | 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; |
54 | 62 |
|
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); |
57 | 68 |
|
58 |
| - return wake_sts & SDW_SHIM2_INTEL_VS_WAKEEN_PWS; |
| 69 | + return wake_sts & lsdiid; |
59 | 70 | }
|
60 | 71 |
|
61 | 72 | static void intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
|
62 | 73 | {
|
63 |
| - void __iomem *shim_vs = sdw->link_res->shim_vs; |
| 74 | + u16 lsdiid = 0; |
64 | 75 | u16 wake_en;
|
65 | 76 | u16 wake_sts;
|
| 77 | + int ret; |
| 78 | + |
| 79 | + mutex_lock(sdw->link_res->shim_lock); |
66 | 80 |
|
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); |
68 | 86 |
|
69 | 87 | if (wake_enable) {
|
70 | 88 | /* 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); |
73 | 92 | } else {
|
74 | 93 | /* 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); |
77 | 96 |
|
78 | 97 | /* 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); |
82 | 101 | }
|
| 102 | +unlock: |
| 103 | + mutex_unlock(sdw->link_res->shim_lock); |
83 | 104 | }
|
84 | 105 |
|
85 | 106 | static int intel_link_power_up(struct sdw_intel *sdw)
|
|
0 commit comments