Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) |
| 2 | // Copyright(c) 2015-17 Intel Corporation. |
| 3 | |
| 4 | /* |
| 5 | * Soundwire Intel Master Driver |
| 6 | */ |
| 7 | |
| 8 | #include <linux/acpi.h> |
Pierre-Louis Bossart | 79ee663 | 2019-08-21 13:58:20 -0500 | [diff] [blame] | 9 | #include <linux/debugfs.h> |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 10 | #include <linux/delay.h> |
Paul Gortmaker | 4abbd78 | 2019-04-13 11:12:52 -0400 | [diff] [blame] | 11 | #include <linux/module.h> |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 12 | #include <linux/interrupt.h> |
Pierre-Louis Bossart | df72b71 | 2019-09-16 13:57:38 -0500 | [diff] [blame] | 13 | #include <linux/io.h> |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 15 | #include <sound/pcm_params.h> |
Rander Wang | ab2c913 | 2020-07-16 23:09:46 +0800 | [diff] [blame] | 16 | #include <linux/pm_runtime.h> |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 17 | #include <sound/soc.h> |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 18 | #include <linux/soundwire/sdw_registers.h> |
| 19 | #include <linux/soundwire/sdw.h> |
| 20 | #include <linux/soundwire/sdw_intel.h> |
| 21 | #include "cadence_master.h" |
Pierre-Louis Bossart | 79ee663 | 2019-08-21 13:58:20 -0500 | [diff] [blame] | 22 | #include "bus.h" |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 23 | #include "intel.h" |
| 24 | |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 25 | #define INTEL_MASTER_SUSPEND_DELAY_MS 3000 |
| 26 | |
| 27 | /* |
| 28 | * debug/config flags for the Intel SoundWire Master. |
| 29 | * |
| 30 | * Since we may have multiple masters active, we can have up to 8 |
| 31 | * flags reused in each byte, with master0 using the ls-byte, etc. |
| 32 | */ |
| 33 | |
Pierre-Louis Bossart | a2d9c16 | 2020-08-17 23:29:17 +0800 | [diff] [blame] | 34 | #define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME BIT(0) |
| 35 | #define SDW_INTEL_MASTER_DISABLE_CLOCK_STOP BIT(1) |
| 36 | #define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE BIT(2) |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 37 | #define SDW_INTEL_MASTER_DISABLE_MULTI_LINK BIT(3) |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 38 | |
| 39 | static int md_flags; |
| 40 | module_param_named(sdw_md_flags, md_flags, int, 0444); |
| 41 | MODULE_PARM_DESC(sdw_md_flags, "SoundWire Intel Master device flags (0x0 all off)"); |
| 42 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 43 | /* Intel SHIM Registers Definition */ |
| 44 | #define SDW_SHIM_LCAP 0x0 |
| 45 | #define SDW_SHIM_LCTL 0x4 |
| 46 | #define SDW_SHIM_IPPTR 0x8 |
| 47 | #define SDW_SHIM_SYNC 0xC |
| 48 | |
Pierre-Louis Bossart | 7cc6e31 | 2019-05-01 10:57:39 -0500 | [diff] [blame] | 49 | #define SDW_SHIM_CTLSCAP(x) (0x010 + 0x60 * (x)) |
| 50 | #define SDW_SHIM_CTLS0CM(x) (0x012 + 0x60 * (x)) |
| 51 | #define SDW_SHIM_CTLS1CM(x) (0x014 + 0x60 * (x)) |
| 52 | #define SDW_SHIM_CTLS2CM(x) (0x016 + 0x60 * (x)) |
| 53 | #define SDW_SHIM_CTLS3CM(x) (0x018 + 0x60 * (x)) |
| 54 | #define SDW_SHIM_PCMSCAP(x) (0x020 + 0x60 * (x)) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 55 | |
Pierre-Louis Bossart | 7cc6e31 | 2019-05-01 10:57:39 -0500 | [diff] [blame] | 56 | #define SDW_SHIM_PCMSYCHM(x, y) (0x022 + (0x60 * (x)) + (0x2 * (y))) |
| 57 | #define SDW_SHIM_PCMSYCHC(x, y) (0x042 + (0x60 * (x)) + (0x2 * (y))) |
| 58 | #define SDW_SHIM_PDMSCAP(x) (0x062 + 0x60 * (x)) |
| 59 | #define SDW_SHIM_IOCTL(x) (0x06C + 0x60 * (x)) |
| 60 | #define SDW_SHIM_CTMCTL(x) (0x06E + 0x60 * (x)) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 61 | |
| 62 | #define SDW_SHIM_WAKEEN 0x190 |
| 63 | #define SDW_SHIM_WAKESTS 0x192 |
| 64 | |
| 65 | #define SDW_SHIM_LCTL_SPA BIT(0) |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 66 | #define SDW_SHIM_LCTL_SPA_MASK GENMASK(3, 0) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 67 | #define SDW_SHIM_LCTL_CPA BIT(8) |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 68 | #define SDW_SHIM_LCTL_CPA_MASK GENMASK(11, 8) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 69 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 70 | #define SDW_SHIM_SYNC_SYNCPRD_VAL_24 (24000 / SDW_CADENCE_GSYNC_KHZ - 1) |
| 71 | #define SDW_SHIM_SYNC_SYNCPRD_VAL_38_4 (38400 / SDW_CADENCE_GSYNC_KHZ - 1) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 72 | #define SDW_SHIM_SYNC_SYNCPRD GENMASK(14, 0) |
| 73 | #define SDW_SHIM_SYNC_SYNCCPU BIT(15) |
| 74 | #define SDW_SHIM_SYNC_CMDSYNC_MASK GENMASK(19, 16) |
| 75 | #define SDW_SHIM_SYNC_CMDSYNC BIT(16) |
| 76 | #define SDW_SHIM_SYNC_SYNCGO BIT(24) |
| 77 | |
| 78 | #define SDW_SHIM_PCMSCAP_ISS GENMASK(3, 0) |
| 79 | #define SDW_SHIM_PCMSCAP_OSS GENMASK(7, 4) |
| 80 | #define SDW_SHIM_PCMSCAP_BSS GENMASK(12, 8) |
| 81 | |
| 82 | #define SDW_SHIM_PCMSYCM_LCHN GENMASK(3, 0) |
| 83 | #define SDW_SHIM_PCMSYCM_HCHN GENMASK(7, 4) |
| 84 | #define SDW_SHIM_PCMSYCM_STREAM GENMASK(13, 8) |
| 85 | #define SDW_SHIM_PCMSYCM_DIR BIT(15) |
| 86 | |
| 87 | #define SDW_SHIM_PDMSCAP_ISS GENMASK(3, 0) |
| 88 | #define SDW_SHIM_PDMSCAP_OSS GENMASK(7, 4) |
| 89 | #define SDW_SHIM_PDMSCAP_BSS GENMASK(12, 8) |
| 90 | #define SDW_SHIM_PDMSCAP_CPSS GENMASK(15, 13) |
| 91 | |
| 92 | #define SDW_SHIM_IOCTL_MIF BIT(0) |
| 93 | #define SDW_SHIM_IOCTL_CO BIT(1) |
| 94 | #define SDW_SHIM_IOCTL_COE BIT(2) |
| 95 | #define SDW_SHIM_IOCTL_DO BIT(3) |
| 96 | #define SDW_SHIM_IOCTL_DOE BIT(4) |
| 97 | #define SDW_SHIM_IOCTL_BKE BIT(5) |
| 98 | #define SDW_SHIM_IOCTL_WPDD BIT(6) |
| 99 | #define SDW_SHIM_IOCTL_CIBD BIT(8) |
| 100 | #define SDW_SHIM_IOCTL_DIBD BIT(9) |
| 101 | |
| 102 | #define SDW_SHIM_CTMCTL_DACTQE BIT(0) |
| 103 | #define SDW_SHIM_CTMCTL_DODS BIT(1) |
| 104 | #define SDW_SHIM_CTMCTL_DOAIS GENMASK(4, 3) |
| 105 | |
| 106 | #define SDW_SHIM_WAKEEN_ENABLE BIT(0) |
| 107 | #define SDW_SHIM_WAKESTS_STATUS BIT(0) |
| 108 | |
| 109 | /* Intel ALH Register definitions */ |
Pierre-Louis Bossart | 7cc6e31 | 2019-05-01 10:57:39 -0500 | [diff] [blame] | 110 | #define SDW_ALH_STRMZCFG(x) (0x000 + (0x4 * (x))) |
Pierre-Louis Bossart | 79ee663 | 2019-08-21 13:58:20 -0500 | [diff] [blame] | 111 | #define SDW_ALH_NUM_STREAMS 64 |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 112 | |
| 113 | #define SDW_ALH_STRMZCFG_DMAT_VAL 0x3 |
| 114 | #define SDW_ALH_STRMZCFG_DMAT GENMASK(7, 0) |
| 115 | #define SDW_ALH_STRMZCFG_CHN GENMASK(19, 16) |
| 116 | |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 117 | enum intel_pdi_type { |
| 118 | INTEL_PDI_IN = 0, |
| 119 | INTEL_PDI_OUT = 1, |
| 120 | INTEL_PDI_BD = 2, |
| 121 | }; |
| 122 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 123 | #define cdns_to_intel(_cdns) container_of(_cdns, struct sdw_intel, cdns) |
| 124 | |
| 125 | /* |
| 126 | * Read, write helpers for HW registers |
| 127 | */ |
| 128 | static inline int intel_readl(void __iomem *base, int offset) |
| 129 | { |
| 130 | return readl(base + offset); |
| 131 | } |
| 132 | |
| 133 | static inline void intel_writel(void __iomem *base, int offset, int value) |
| 134 | { |
| 135 | writel(value, base + offset); |
| 136 | } |
| 137 | |
| 138 | static inline u16 intel_readw(void __iomem *base, int offset) |
| 139 | { |
| 140 | return readw(base + offset); |
| 141 | } |
| 142 | |
| 143 | static inline void intel_writew(void __iomem *base, int offset, u16 value) |
| 144 | { |
| 145 | writew(value, base + offset); |
| 146 | } |
| 147 | |
Pierre-Louis Bossart | 7d2845d | 2020-07-16 23:09:39 +0800 | [diff] [blame] | 148 | static int intel_wait_bit(void __iomem *base, int offset, u32 mask, u32 target) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 149 | { |
| 150 | int timeout = 10; |
| 151 | u32 reg_read; |
| 152 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 153 | do { |
| 154 | reg_read = readl(base + offset); |
Pierre-Louis Bossart | 7d2845d | 2020-07-16 23:09:39 +0800 | [diff] [blame] | 155 | if ((reg_read & mask) == target) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 156 | return 0; |
| 157 | |
| 158 | timeout--; |
Pierre-Louis Bossart | 7d2845d | 2020-07-16 23:09:39 +0800 | [diff] [blame] | 159 | usleep_range(50, 100); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 160 | } while (timeout != 0); |
| 161 | |
| 162 | return -EAGAIN; |
| 163 | } |
| 164 | |
Pierre-Louis Bossart | 7d2845d | 2020-07-16 23:09:39 +0800 | [diff] [blame] | 165 | static int intel_clear_bit(void __iomem *base, int offset, u32 value, u32 mask) |
| 166 | { |
| 167 | writel(value, base + offset); |
| 168 | return intel_wait_bit(base, offset, mask, 0); |
| 169 | } |
| 170 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 171 | static int intel_set_bit(void __iomem *base, int offset, u32 value, u32 mask) |
| 172 | { |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 173 | writel(value, base + offset); |
Pierre-Louis Bossart | 7d2845d | 2020-07-16 23:09:39 +0800 | [diff] [blame] | 174 | return intel_wait_bit(base, offset, mask, mask); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | /* |
Pierre-Louis Bossart | 79ee663 | 2019-08-21 13:58:20 -0500 | [diff] [blame] | 178 | * debugfs |
| 179 | */ |
| 180 | #ifdef CONFIG_DEBUG_FS |
| 181 | |
| 182 | #define RD_BUF (2 * PAGE_SIZE) |
| 183 | |
| 184 | static ssize_t intel_sprintf(void __iomem *mem, bool l, |
| 185 | char *buf, size_t pos, unsigned int reg) |
| 186 | { |
| 187 | int value; |
| 188 | |
| 189 | if (l) |
| 190 | value = intel_readl(mem, reg); |
| 191 | else |
| 192 | value = intel_readw(mem, reg); |
| 193 | |
| 194 | return scnprintf(buf + pos, RD_BUF - pos, "%4x\t%4x\n", reg, value); |
| 195 | } |
| 196 | |
| 197 | static int intel_reg_show(struct seq_file *s_file, void *data) |
| 198 | { |
| 199 | struct sdw_intel *sdw = s_file->private; |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 200 | void __iomem *s = sdw->link_res->shim; |
| 201 | void __iomem *a = sdw->link_res->alh; |
Pierre-Louis Bossart | 79ee663 | 2019-08-21 13:58:20 -0500 | [diff] [blame] | 202 | char *buf; |
| 203 | ssize_t ret; |
| 204 | int i, j; |
| 205 | unsigned int links, reg; |
| 206 | |
| 207 | buf = kzalloc(RD_BUF, GFP_KERNEL); |
| 208 | if (!buf) |
| 209 | return -ENOMEM; |
| 210 | |
| 211 | links = intel_readl(s, SDW_SHIM_LCAP) & GENMASK(2, 0); |
| 212 | |
| 213 | ret = scnprintf(buf, RD_BUF, "Register Value\n"); |
| 214 | ret += scnprintf(buf + ret, RD_BUF - ret, "\nShim\n"); |
| 215 | |
| 216 | for (i = 0; i < links; i++) { |
| 217 | reg = SDW_SHIM_LCAP + i * 4; |
| 218 | ret += intel_sprintf(s, true, buf, ret, reg); |
| 219 | } |
| 220 | |
| 221 | for (i = 0; i < links; i++) { |
| 222 | ret += scnprintf(buf + ret, RD_BUF - ret, "\nLink%d\n", i); |
| 223 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLSCAP(i)); |
| 224 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS0CM(i)); |
| 225 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS1CM(i)); |
| 226 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS2CM(i)); |
| 227 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS3CM(i)); |
| 228 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_PCMSCAP(i)); |
| 229 | |
| 230 | ret += scnprintf(buf + ret, RD_BUF - ret, "\n PCMSyCH registers\n"); |
| 231 | |
| 232 | /* |
| 233 | * the value 10 is the number of PDIs. We will need a |
| 234 | * cleanup to remove hard-coded Intel configurations |
| 235 | * from cadence_master.c |
| 236 | */ |
| 237 | for (j = 0; j < 10; j++) { |
| 238 | ret += intel_sprintf(s, false, buf, ret, |
| 239 | SDW_SHIM_PCMSYCHM(i, j)); |
| 240 | ret += intel_sprintf(s, false, buf, ret, |
| 241 | SDW_SHIM_PCMSYCHC(i, j)); |
| 242 | } |
| 243 | ret += scnprintf(buf + ret, RD_BUF - ret, "\n PDMSCAP, IOCTL, CTMCTL\n"); |
| 244 | |
| 245 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_PDMSCAP(i)); |
| 246 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_IOCTL(i)); |
| 247 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTMCTL(i)); |
| 248 | } |
| 249 | |
| 250 | ret += scnprintf(buf + ret, RD_BUF - ret, "\nWake registers\n"); |
| 251 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_WAKEEN); |
| 252 | ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_WAKESTS); |
| 253 | |
| 254 | ret += scnprintf(buf + ret, RD_BUF - ret, "\nALH STRMzCFG\n"); |
| 255 | for (i = 0; i < SDW_ALH_NUM_STREAMS; i++) |
| 256 | ret += intel_sprintf(a, true, buf, ret, SDW_ALH_STRMZCFG(i)); |
| 257 | |
| 258 | seq_printf(s_file, "%s", buf); |
| 259 | kfree(buf); |
| 260 | |
| 261 | return 0; |
| 262 | } |
| 263 | DEFINE_SHOW_ATTRIBUTE(intel_reg); |
| 264 | |
| 265 | static void intel_debugfs_init(struct sdw_intel *sdw) |
| 266 | { |
| 267 | struct dentry *root = sdw->cdns.bus.debugfs; |
| 268 | |
| 269 | if (!root) |
| 270 | return; |
| 271 | |
| 272 | sdw->debugfs = debugfs_create_dir("intel-sdw", root); |
| 273 | |
| 274 | debugfs_create_file("intel-registers", 0400, sdw->debugfs, sdw, |
| 275 | &intel_reg_fops); |
| 276 | |
| 277 | sdw_cdns_debugfs_init(&sdw->cdns, sdw->debugfs); |
| 278 | } |
| 279 | |
| 280 | static void intel_debugfs_exit(struct sdw_intel *sdw) |
| 281 | { |
| 282 | debugfs_remove_recursive(sdw->debugfs); |
| 283 | } |
| 284 | #else |
| 285 | static void intel_debugfs_init(struct sdw_intel *sdw) {} |
| 286 | static void intel_debugfs_exit(struct sdw_intel *sdw) {} |
| 287 | #endif /* CONFIG_DEBUG_FS */ |
| 288 | |
| 289 | /* |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 290 | * shim ops |
| 291 | */ |
| 292 | |
| 293 | static int intel_link_power_up(struct sdw_intel *sdw) |
| 294 | { |
| 295 | unsigned int link_id = sdw->instance; |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 296 | void __iomem *shim = sdw->link_res->shim; |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 297 | u32 *shim_mask = sdw->link_res->shim_mask; |
| 298 | struct sdw_bus *bus = &sdw->cdns.bus; |
| 299 | struct sdw_master_prop *prop = &bus->prop; |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 300 | u32 spa_mask, cpa_mask; |
| 301 | u32 link_control; |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 302 | int ret = 0; |
| 303 | u32 syncprd; |
| 304 | u32 sync_reg; |
| 305 | |
| 306 | mutex_lock(sdw->link_res->shim_lock); |
| 307 | |
| 308 | /* |
| 309 | * The hardware relies on an internal counter, typically 4kHz, |
| 310 | * to generate the SoundWire SSP - which defines a 'safe' |
| 311 | * synchronization point between commands and audio transport |
| 312 | * and allows for multi link synchronization. The SYNCPRD value |
| 313 | * is only dependent on the oscillator clock provided to |
| 314 | * the IP, so adjust based on _DSD properties reported in DSDT |
| 315 | * tables. The values reported are based on either 24MHz |
| 316 | * (CNL/CML) or 38.4 MHz (ICL/TGL+). |
| 317 | */ |
| 318 | if (prop->mclk_freq % 6000000) |
| 319 | syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_38_4; |
| 320 | else |
| 321 | syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_24; |
| 322 | |
| 323 | if (!*shim_mask) { |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 324 | dev_dbg(sdw->cdns.dev, "%s: powering up all links\n", __func__); |
| 325 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 326 | /* we first need to program the SyncPRD/CPU registers */ |
| 327 | dev_dbg(sdw->cdns.dev, |
| 328 | "%s: first link up, programming SYNCPRD\n", __func__); |
| 329 | |
| 330 | /* set SyncPRD period */ |
| 331 | sync_reg = intel_readl(shim, SDW_SHIM_SYNC); |
| 332 | sync_reg |= (syncprd << |
| 333 | SDW_REG_SHIFT(SDW_SHIM_SYNC_SYNCPRD)); |
| 334 | |
| 335 | /* Set SyncCPU bit */ |
| 336 | sync_reg |= SDW_SHIM_SYNC_SYNCCPU; |
| 337 | intel_writel(shim, SDW_SHIM_SYNC, sync_reg); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 338 | |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 339 | /* Link power up sequence */ |
| 340 | link_control = intel_readl(shim, SDW_SHIM_LCTL); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 341 | |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 342 | /* only power-up enabled links */ |
| 343 | spa_mask = sdw->link_res->link_mask << |
| 344 | SDW_REG_SHIFT(SDW_SHIM_LCTL_SPA_MASK); |
| 345 | cpa_mask = sdw->link_res->link_mask << |
| 346 | SDW_REG_SHIFT(SDW_SHIM_LCTL_CPA_MASK); |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 347 | |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 348 | link_control |= spa_mask; |
| 349 | |
| 350 | ret = intel_set_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask); |
| 351 | if (ret < 0) { |
| 352 | dev_err(sdw->cdns.dev, "Failed to power up link: %d\n", ret); |
| 353 | goto out; |
| 354 | } |
| 355 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 356 | /* SyncCPU will change once link is active */ |
| 357 | ret = intel_wait_bit(shim, SDW_SHIM_SYNC, |
| 358 | SDW_SHIM_SYNC_SYNCCPU, 0); |
| 359 | if (ret < 0) { |
| 360 | dev_err(sdw->cdns.dev, |
| 361 | "Failed to set SHIM_SYNC: %d\n", ret); |
| 362 | goto out; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | *shim_mask |= BIT(link_id); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 367 | |
| 368 | sdw->cdns.link_up = true; |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 369 | out: |
| 370 | mutex_unlock(sdw->link_res->shim_lock); |
| 371 | |
| 372 | return ret; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 373 | } |
| 374 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 375 | /* this needs to be called with shim_lock */ |
| 376 | static void intel_shim_glue_to_master_ip(struct sdw_intel *sdw) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 377 | { |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 378 | void __iomem *shim = sdw->link_res->shim; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 379 | unsigned int link_id = sdw->instance; |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 380 | u16 ioctl; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 381 | |
| 382 | /* Switch to MIP from Glue logic */ |
| 383 | ioctl = intel_readw(shim, SDW_SHIM_IOCTL(link_id)); |
| 384 | |
| 385 | ioctl &= ~(SDW_SHIM_IOCTL_DOE); |
| 386 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 387 | usleep_range(10, 15); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 388 | |
| 389 | ioctl &= ~(SDW_SHIM_IOCTL_DO); |
| 390 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 391 | usleep_range(10, 15); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 392 | |
| 393 | ioctl |= (SDW_SHIM_IOCTL_MIF); |
| 394 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 395 | usleep_range(10, 15); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 396 | |
| 397 | ioctl &= ~(SDW_SHIM_IOCTL_BKE); |
| 398 | ioctl &= ~(SDW_SHIM_IOCTL_COE); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 399 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 400 | usleep_range(10, 15); |
| 401 | |
| 402 | /* at this point Master IP has full control of the I/Os */ |
| 403 | } |
| 404 | |
| 405 | /* this needs to be called with shim_lock */ |
| 406 | static void intel_shim_master_ip_to_glue(struct sdw_intel *sdw) |
| 407 | { |
| 408 | unsigned int link_id = sdw->instance; |
| 409 | void __iomem *shim = sdw->link_res->shim; |
| 410 | u16 ioctl; |
| 411 | |
| 412 | /* Glue logic */ |
| 413 | ioctl = intel_readw(shim, SDW_SHIM_IOCTL(link_id)); |
| 414 | ioctl |= SDW_SHIM_IOCTL_BKE; |
| 415 | ioctl |= SDW_SHIM_IOCTL_COE; |
| 416 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
| 417 | usleep_range(10, 15); |
| 418 | |
| 419 | ioctl &= ~(SDW_SHIM_IOCTL_MIF); |
| 420 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
| 421 | usleep_range(10, 15); |
| 422 | |
| 423 | /* at this point Integration Glue has full control of the I/Os */ |
| 424 | } |
| 425 | |
| 426 | static int intel_shim_init(struct sdw_intel *sdw, bool clock_stop) |
| 427 | { |
| 428 | void __iomem *shim = sdw->link_res->shim; |
| 429 | unsigned int link_id = sdw->instance; |
| 430 | int ret = 0; |
| 431 | u16 ioctl = 0, act = 0; |
| 432 | |
| 433 | mutex_lock(sdw->link_res->shim_lock); |
| 434 | |
| 435 | /* Initialize Shim */ |
| 436 | ioctl |= SDW_SHIM_IOCTL_BKE; |
| 437 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
| 438 | usleep_range(10, 15); |
| 439 | |
| 440 | ioctl |= SDW_SHIM_IOCTL_WPDD; |
| 441 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
| 442 | usleep_range(10, 15); |
| 443 | |
| 444 | ioctl |= SDW_SHIM_IOCTL_DO; |
| 445 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
| 446 | usleep_range(10, 15); |
| 447 | |
| 448 | ioctl |= SDW_SHIM_IOCTL_DOE; |
| 449 | intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl); |
| 450 | usleep_range(10, 15); |
| 451 | |
| 452 | intel_shim_glue_to_master_ip(sdw); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 453 | |
| 454 | act |= 0x1 << SDW_REG_SHIFT(SDW_SHIM_CTMCTL_DOAIS); |
| 455 | act |= SDW_SHIM_CTMCTL_DACTQE; |
| 456 | act |= SDW_SHIM_CTMCTL_DODS; |
| 457 | intel_writew(shim, SDW_SHIM_CTMCTL(link_id), act); |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 458 | usleep_range(10, 15); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 459 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 460 | mutex_unlock(sdw->link_res->shim_lock); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 461 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 462 | return ret; |
| 463 | } |
| 464 | |
Rander Wang | ab2c913 | 2020-07-16 23:09:46 +0800 | [diff] [blame] | 465 | static void intel_shim_wake(struct sdw_intel *sdw, bool wake_enable) |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 466 | { |
| 467 | void __iomem *shim = sdw->link_res->shim; |
| 468 | unsigned int link_id = sdw->instance; |
| 469 | u16 wake_en, wake_sts; |
| 470 | |
| 471 | mutex_lock(sdw->link_res->shim_lock); |
| 472 | wake_en = intel_readw(shim, SDW_SHIM_WAKEEN); |
| 473 | |
| 474 | if (wake_enable) { |
| 475 | /* Enable the wakeup */ |
| 476 | wake_en |= (SDW_SHIM_WAKEEN_ENABLE << link_id); |
| 477 | intel_writew(shim, SDW_SHIM_WAKEEN, wake_en); |
| 478 | } else { |
| 479 | /* Disable the wake up interrupt */ |
| 480 | wake_en &= ~(SDW_SHIM_WAKEEN_ENABLE << link_id); |
| 481 | intel_writew(shim, SDW_SHIM_WAKEEN, wake_en); |
| 482 | |
| 483 | /* Clear wake status */ |
| 484 | wake_sts = intel_readw(shim, SDW_SHIM_WAKESTS); |
| 485 | wake_sts |= (SDW_SHIM_WAKEEN_ENABLE << link_id); |
| 486 | intel_writew(shim, SDW_SHIM_WAKESTS_STATUS, wake_sts); |
| 487 | } |
| 488 | mutex_unlock(sdw->link_res->shim_lock); |
| 489 | } |
| 490 | |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 491 | static int intel_link_power_down(struct sdw_intel *sdw) |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 492 | { |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 493 | u32 link_control, spa_mask, cpa_mask; |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 494 | unsigned int link_id = sdw->instance; |
| 495 | void __iomem *shim = sdw->link_res->shim; |
| 496 | u32 *shim_mask = sdw->link_res->shim_mask; |
| 497 | int ret = 0; |
| 498 | |
| 499 | mutex_lock(sdw->link_res->shim_lock); |
| 500 | |
| 501 | intel_shim_master_ip_to_glue(sdw); |
| 502 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 503 | if (!(*shim_mask & BIT(link_id))) |
| 504 | dev_err(sdw->cdns.dev, |
| 505 | "%s: Unbalanced power-up/down calls\n", __func__); |
| 506 | |
| 507 | *shim_mask &= ~BIT(link_id); |
| 508 | |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 509 | if (!*shim_mask) { |
| 510 | |
| 511 | dev_dbg(sdw->cdns.dev, "%s: powering down all links\n", __func__); |
| 512 | |
| 513 | /* Link power down sequence */ |
| 514 | link_control = intel_readl(shim, SDW_SHIM_LCTL); |
| 515 | |
| 516 | /* only power-down enabled links */ |
| 517 | spa_mask = (~sdw->link_res->link_mask) << |
| 518 | SDW_REG_SHIFT(SDW_SHIM_LCTL_SPA_MASK); |
| 519 | cpa_mask = sdw->link_res->link_mask << |
| 520 | SDW_REG_SHIFT(SDW_SHIM_LCTL_CPA_MASK); |
| 521 | |
| 522 | link_control &= spa_mask; |
| 523 | |
| 524 | ret = intel_clear_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask); |
| 525 | } |
| 526 | |
| 527 | link_control = intel_readl(shim, SDW_SHIM_LCTL); |
| 528 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 529 | mutex_unlock(sdw->link_res->shim_lock); |
| 530 | |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 531 | if (ret < 0) { |
| 532 | dev_err(sdw->cdns.dev, "%s: could not power down link\n", __func__); |
| 533 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 534 | return ret; |
Pierre-Louis Bossart | 5ee74eb | 2020-09-01 23:05:56 +0800 | [diff] [blame] | 535 | } |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 536 | |
| 537 | sdw->cdns.link_up = false; |
| 538 | return 0; |
| 539 | } |
| 540 | |
Pierre-Louis Bossart | 02629e4 | 2020-07-16 23:09:41 +0800 | [diff] [blame] | 541 | static void intel_shim_sync_arm(struct sdw_intel *sdw) |
| 542 | { |
| 543 | void __iomem *shim = sdw->link_res->shim; |
| 544 | u32 sync_reg; |
| 545 | |
| 546 | mutex_lock(sdw->link_res->shim_lock); |
| 547 | |
| 548 | /* update SYNC register */ |
| 549 | sync_reg = intel_readl(shim, SDW_SHIM_SYNC); |
| 550 | sync_reg |= (SDW_SHIM_SYNC_CMDSYNC << sdw->instance); |
| 551 | intel_writel(shim, SDW_SHIM_SYNC, sync_reg); |
| 552 | |
| 553 | mutex_unlock(sdw->link_res->shim_lock); |
| 554 | } |
| 555 | |
Pierre-Louis Bossart | 437e328 | 2020-07-16 23:09:42 +0800 | [diff] [blame] | 556 | static int intel_shim_sync_go_unlocked(struct sdw_intel *sdw) |
| 557 | { |
| 558 | void __iomem *shim = sdw->link_res->shim; |
| 559 | u32 sync_reg; |
| 560 | int ret; |
| 561 | |
| 562 | /* Read SYNC register */ |
| 563 | sync_reg = intel_readl(shim, SDW_SHIM_SYNC); |
| 564 | |
| 565 | /* |
| 566 | * Set SyncGO bit to synchronously trigger a bank switch for |
| 567 | * all the masters. A write to SYNCGO bit clears CMDSYNC bit for all |
| 568 | * the Masters. |
| 569 | */ |
| 570 | sync_reg |= SDW_SHIM_SYNC_SYNCGO; |
| 571 | |
| 572 | ret = intel_clear_bit(shim, SDW_SHIM_SYNC, sync_reg, |
| 573 | SDW_SHIM_SYNC_SYNCGO); |
| 574 | |
| 575 | if (ret < 0) |
| 576 | dev_err(sdw->cdns.dev, "SyncGO clear failed: %d\n", ret); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 577 | |
| 578 | return ret; |
| 579 | } |
| 580 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 581 | static int intel_shim_sync_go(struct sdw_intel *sdw) |
| 582 | { |
| 583 | int ret; |
| 584 | |
| 585 | mutex_lock(sdw->link_res->shim_lock); |
| 586 | |
| 587 | ret = intel_shim_sync_go_unlocked(sdw); |
| 588 | |
| 589 | mutex_unlock(sdw->link_res->shim_lock); |
| 590 | |
| 591 | return ret; |
| 592 | } |
| 593 | |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 594 | /* |
| 595 | * PDI routines |
| 596 | */ |
| 597 | static void intel_pdi_init(struct sdw_intel *sdw, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 598 | struct sdw_cdns_stream_config *config) |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 599 | { |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 600 | void __iomem *shim = sdw->link_res->shim; |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 601 | unsigned int link_id = sdw->instance; |
| 602 | int pcm_cap, pdm_cap; |
| 603 | |
| 604 | /* PCM Stream Capability */ |
| 605 | pcm_cap = intel_readw(shim, SDW_SHIM_PCMSCAP(link_id)); |
| 606 | |
| 607 | config->pcm_bd = (pcm_cap & SDW_SHIM_PCMSCAP_BSS) >> |
| 608 | SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_BSS); |
| 609 | config->pcm_in = (pcm_cap & SDW_SHIM_PCMSCAP_ISS) >> |
| 610 | SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_ISS); |
| 611 | config->pcm_out = (pcm_cap & SDW_SHIM_PCMSCAP_OSS) >> |
| 612 | SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_OSS); |
| 613 | |
Pierre-Louis Bossart | 121f436 | 2019-05-22 14:47:29 -0500 | [diff] [blame] | 614 | dev_dbg(sdw->cdns.dev, "PCM cap bd:%d in:%d out:%d\n", |
| 615 | config->pcm_bd, config->pcm_in, config->pcm_out); |
| 616 | |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 617 | /* PDM Stream Capability */ |
| 618 | pdm_cap = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id)); |
| 619 | |
| 620 | config->pdm_bd = (pdm_cap & SDW_SHIM_PDMSCAP_BSS) >> |
| 621 | SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_BSS); |
| 622 | config->pdm_in = (pdm_cap & SDW_SHIM_PDMSCAP_ISS) >> |
| 623 | SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_ISS); |
| 624 | config->pdm_out = (pdm_cap & SDW_SHIM_PDMSCAP_OSS) >> |
| 625 | SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_OSS); |
Pierre-Louis Bossart | 121f436 | 2019-05-22 14:47:29 -0500 | [diff] [blame] | 626 | |
| 627 | dev_dbg(sdw->cdns.dev, "PDM cap bd:%d in:%d out:%d\n", |
| 628 | config->pdm_bd, config->pdm_in, config->pdm_out); |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | static int |
| 632 | intel_pdi_get_ch_cap(struct sdw_intel *sdw, unsigned int pdi_num, bool pcm) |
| 633 | { |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 634 | void __iomem *shim = sdw->link_res->shim; |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 635 | unsigned int link_id = sdw->instance; |
| 636 | int count; |
| 637 | |
| 638 | if (pcm) { |
| 639 | count = intel_readw(shim, SDW_SHIM_PCMSYCHC(link_id, pdi_num)); |
Pierre-Louis Bossart | 1804633 | 2019-08-05 19:55:07 -0500 | [diff] [blame] | 640 | |
| 641 | /* |
| 642 | * WORKAROUND: on all existing Intel controllers, pdi |
| 643 | * number 2 reports channel count as 1 even though it |
| 644 | * supports 8 channels. Performing hardcoding for pdi |
| 645 | * number 2. |
| 646 | */ |
| 647 | if (pdi_num == 2) |
| 648 | count = 7; |
| 649 | |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 650 | } else { |
| 651 | count = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id)); |
| 652 | count = ((count & SDW_SHIM_PDMSCAP_CPSS) >> |
| 653 | SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_CPSS)); |
| 654 | } |
| 655 | |
| 656 | /* zero based values for channel count in register */ |
| 657 | count++; |
| 658 | |
| 659 | return count; |
| 660 | } |
| 661 | |
| 662 | static int intel_pdi_get_ch_update(struct sdw_intel *sdw, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 663 | struct sdw_cdns_pdi *pdi, |
| 664 | unsigned int num_pdi, |
| 665 | unsigned int *num_ch, bool pcm) |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 666 | { |
| 667 | int i, ch_count = 0; |
| 668 | |
| 669 | for (i = 0; i < num_pdi; i++) { |
| 670 | pdi->ch_count = intel_pdi_get_ch_cap(sdw, pdi->num, pcm); |
| 671 | ch_count += pdi->ch_count; |
| 672 | pdi++; |
| 673 | } |
| 674 | |
| 675 | *num_ch = ch_count; |
| 676 | return 0; |
| 677 | } |
| 678 | |
| 679 | static int intel_pdi_stream_ch_update(struct sdw_intel *sdw, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 680 | struct sdw_cdns_streams *stream, bool pcm) |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 681 | { |
| 682 | intel_pdi_get_ch_update(sdw, stream->bd, stream->num_bd, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 683 | &stream->num_ch_bd, pcm); |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 684 | |
| 685 | intel_pdi_get_ch_update(sdw, stream->in, stream->num_in, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 686 | &stream->num_ch_in, pcm); |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 687 | |
| 688 | intel_pdi_get_ch_update(sdw, stream->out, stream->num_out, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 689 | &stream->num_ch_out, pcm); |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 690 | |
| 691 | return 0; |
| 692 | } |
| 693 | |
| 694 | static int intel_pdi_ch_update(struct sdw_intel *sdw) |
| 695 | { |
| 696 | /* First update PCM streams followed by PDM streams */ |
| 697 | intel_pdi_stream_ch_update(sdw, &sdw->cdns.pcm, true); |
| 698 | intel_pdi_stream_ch_update(sdw, &sdw->cdns.pdm, false); |
| 699 | |
| 700 | return 0; |
| 701 | } |
| 702 | |
| 703 | static void |
| 704 | intel_pdi_shim_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi) |
| 705 | { |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 706 | void __iomem *shim = sdw->link_res->shim; |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 707 | unsigned int link_id = sdw->instance; |
| 708 | int pdi_conf = 0; |
| 709 | |
Pierre-Louis Bossart | c134f91 | 2019-10-22 18:29:48 -0500 | [diff] [blame] | 710 | /* the Bulk and PCM streams are not contiguous */ |
| 711 | pdi->intel_alh_id = (link_id * 16) + pdi->num + 3; |
| 712 | if (pdi->num >= 2) |
| 713 | pdi->intel_alh_id += 2; |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 714 | |
| 715 | /* |
| 716 | * Program stream parameters to stream SHIM register |
| 717 | * This is applicable for PCM stream only. |
| 718 | */ |
| 719 | if (pdi->type != SDW_STREAM_PCM) |
| 720 | return; |
| 721 | |
| 722 | if (pdi->dir == SDW_DATA_DIR_RX) |
| 723 | pdi_conf |= SDW_SHIM_PCMSYCM_DIR; |
| 724 | else |
| 725 | pdi_conf &= ~(SDW_SHIM_PCMSYCM_DIR); |
| 726 | |
| 727 | pdi_conf |= (pdi->intel_alh_id << |
| 728 | SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_STREAM)); |
| 729 | pdi_conf |= (pdi->l_ch_num << SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_LCHN)); |
| 730 | pdi_conf |= (pdi->h_ch_num << SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_HCHN)); |
| 731 | |
| 732 | intel_writew(shim, SDW_SHIM_PCMSYCHM(link_id, pdi->num), pdi_conf); |
| 733 | } |
| 734 | |
| 735 | static void |
| 736 | intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi) |
| 737 | { |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 738 | void __iomem *alh = sdw->link_res->alh; |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 739 | unsigned int link_id = sdw->instance; |
| 740 | unsigned int conf; |
| 741 | |
Pierre-Louis Bossart | c134f91 | 2019-10-22 18:29:48 -0500 | [diff] [blame] | 742 | /* the Bulk and PCM streams are not contiguous */ |
| 743 | pdi->intel_alh_id = (link_id * 16) + pdi->num + 3; |
| 744 | if (pdi->num >= 2) |
| 745 | pdi->intel_alh_id += 2; |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 746 | |
| 747 | /* Program Stream config ALH register */ |
| 748 | conf = intel_readl(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id)); |
| 749 | |
| 750 | conf |= (SDW_ALH_STRMZCFG_DMAT_VAL << |
| 751 | SDW_REG_SHIFT(SDW_ALH_STRMZCFG_DMAT)); |
| 752 | |
| 753 | conf |= ((pdi->ch_count - 1) << |
| 754 | SDW_REG_SHIFT(SDW_ALH_STRMZCFG_CHN)); |
| 755 | |
| 756 | intel_writel(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id), conf); |
| 757 | } |
| 758 | |
Rander Wang | 4b206d3 | 2019-12-11 19:45:02 -0600 | [diff] [blame] | 759 | static int intel_params_stream(struct sdw_intel *sdw, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 760 | struct snd_pcm_substream *substream, |
| 761 | struct snd_soc_dai *dai, |
Rander Wang | 4b206d3 | 2019-12-11 19:45:02 -0600 | [diff] [blame] | 762 | struct snd_pcm_hw_params *hw_params, |
| 763 | int link_id, int alh_stream_id) |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 764 | { |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 765 | struct sdw_intel_link_res *res = sdw->link_res; |
Rander Wang | 4b206d3 | 2019-12-11 19:45:02 -0600 | [diff] [blame] | 766 | struct sdw_intel_stream_params_data params_data; |
Pierre-Louis Bossart | 05c8afe4 | 2019-08-05 19:55:06 -0500 | [diff] [blame] | 767 | |
Rander Wang | 4b206d3 | 2019-12-11 19:45:02 -0600 | [diff] [blame] | 768 | params_data.substream = substream; |
| 769 | params_data.dai = dai; |
| 770 | params_data.hw_params = hw_params; |
| 771 | params_data.link_id = link_id; |
| 772 | params_data.alh_stream_id = alh_stream_id; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 773 | |
Rander Wang | 4b206d3 | 2019-12-11 19:45:02 -0600 | [diff] [blame] | 774 | if (res->ops && res->ops->params_stream && res->dev) |
| 775 | return res->ops->params_stream(res->dev, |
| 776 | ¶ms_data); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 777 | return -EIO; |
| 778 | } |
| 779 | |
Pierre-Louis Bossart | eff346f | 2020-02-14 19:47:40 -0600 | [diff] [blame] | 780 | static int intel_free_stream(struct sdw_intel *sdw, |
| 781 | struct snd_pcm_substream *substream, |
| 782 | struct snd_soc_dai *dai, |
| 783 | int link_id) |
| 784 | { |
| 785 | struct sdw_intel_link_res *res = sdw->link_res; |
| 786 | struct sdw_intel_stream_free_data free_data; |
| 787 | |
| 788 | free_data.substream = substream; |
| 789 | free_data.dai = dai; |
| 790 | free_data.link_id = link_id; |
| 791 | |
| 792 | if (res->ops && res->ops->free_stream && res->dev) |
| 793 | return res->ops->free_stream(res->dev, |
| 794 | &free_data); |
| 795 | |
| 796 | return 0; |
| 797 | } |
| 798 | |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 799 | /* |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 800 | * bank switch routines |
| 801 | */ |
| 802 | |
| 803 | static int intel_pre_bank_switch(struct sdw_bus *bus) |
| 804 | { |
| 805 | struct sdw_cdns *cdns = bus_to_cdns(bus); |
| 806 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 807 | |
| 808 | /* Write to register only for multi-link */ |
| 809 | if (!bus->multi_link) |
| 810 | return 0; |
| 811 | |
Pierre-Louis Bossart | 02629e4 | 2020-07-16 23:09:41 +0800 | [diff] [blame] | 812 | intel_shim_sync_arm(sdw); |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 813 | |
| 814 | return 0; |
| 815 | } |
| 816 | |
| 817 | static int intel_post_bank_switch(struct sdw_bus *bus) |
| 818 | { |
| 819 | struct sdw_cdns *cdns = bus_to_cdns(bus); |
| 820 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
Pierre-Louis Bossart | 2523486 | 2020-02-14 19:47:36 -0600 | [diff] [blame] | 821 | void __iomem *shim = sdw->link_res->shim; |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 822 | int sync_reg, ret; |
| 823 | |
| 824 | /* Write to register only for multi-link */ |
| 825 | if (!bus->multi_link) |
| 826 | return 0; |
| 827 | |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 828 | mutex_lock(sdw->link_res->shim_lock); |
| 829 | |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 830 | /* Read SYNC register */ |
| 831 | sync_reg = intel_readl(shim, SDW_SHIM_SYNC); |
| 832 | |
| 833 | /* |
| 834 | * post_bank_switch() ops is called from the bus in loop for |
| 835 | * all the Masters in the steam with the expectation that |
| 836 | * we trigger the bankswitch for the only first Master in the list |
| 837 | * and do nothing for the other Masters |
| 838 | * |
| 839 | * So, set the SYNCGO bit only if CMDSYNC bit is set for any Master. |
| 840 | */ |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 841 | if (!(sync_reg & SDW_SHIM_SYNC_CMDSYNC_MASK)) { |
| 842 | ret = 0; |
| 843 | goto unlock; |
| 844 | } |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 845 | |
Pierre-Louis Bossart | 437e328 | 2020-07-16 23:09:42 +0800 | [diff] [blame] | 846 | ret = intel_shim_sync_go_unlocked(sdw); |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 847 | unlock: |
| 848 | mutex_unlock(sdw->link_res->shim_lock); |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 849 | |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 850 | if (ret < 0) |
Pierre-Louis Bossart | 17ed5be | 2019-05-01 10:57:45 -0500 | [diff] [blame] | 851 | dev_err(sdw->cdns.dev, "Post bank switch failed: %d\n", ret); |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 852 | |
| 853 | return ret; |
| 854 | } |
| 855 | |
| 856 | /* |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 857 | * DAI routines |
| 858 | */ |
| 859 | |
Rander Wang | 5e7484d | 2020-02-14 19:47:39 -0600 | [diff] [blame] | 860 | static int intel_startup(struct snd_pcm_substream *substream, |
| 861 | struct snd_soc_dai *dai) |
| 862 | { |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 863 | struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); |
| 864 | int ret; |
| 865 | |
| 866 | ret = pm_runtime_get_sync(cdns->dev); |
| 867 | if (ret < 0 && ret != -EACCES) { |
| 868 | dev_err_ratelimited(cdns->dev, |
| 869 | "pm_runtime_get_sync failed in %s, ret %d\n", |
| 870 | __func__, ret); |
| 871 | pm_runtime_put_noidle(cdns->dev); |
| 872 | return ret; |
| 873 | } |
Pierre-Louis Bossart | ff16d1e | 2020-07-01 02:43:54 +0800 | [diff] [blame] | 874 | return 0; |
Rander Wang | 5e7484d | 2020-02-14 19:47:39 -0600 | [diff] [blame] | 875 | } |
| 876 | |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 877 | static int intel_hw_params(struct snd_pcm_substream *substream, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 878 | struct snd_pcm_hw_params *params, |
| 879 | struct snd_soc_dai *dai) |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 880 | { |
| 881 | struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); |
| 882 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
| 883 | struct sdw_cdns_dma_data *dma; |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 884 | struct sdw_cdns_pdi *pdi; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 885 | struct sdw_stream_config sconfig; |
| 886 | struct sdw_port_config *pconfig; |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 887 | int ch, dir; |
| 888 | int ret; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 889 | bool pcm = true; |
| 890 | |
| 891 | dma = snd_soc_dai_get_dma_data(dai, substream); |
| 892 | if (!dma) |
| 893 | return -EIO; |
| 894 | |
| 895 | ch = params_channels(params); |
| 896 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) |
| 897 | dir = SDW_DATA_DIR_RX; |
| 898 | else |
| 899 | dir = SDW_DATA_DIR_TX; |
| 900 | |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 901 | if (dma->stream_type == SDW_STREAM_PDM) |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 902 | pcm = false; |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 903 | |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 904 | if (pcm) |
Bard Liao | 1b53385 | 2019-09-16 14:23:48 -0500 | [diff] [blame] | 905 | pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id); |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 906 | else |
Bard Liao | 1b53385 | 2019-09-16 14:23:48 -0500 | [diff] [blame] | 907 | pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir, dai->id); |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 908 | |
| 909 | if (!pdi) { |
| 910 | ret = -EINVAL; |
| 911 | goto error; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 912 | } |
| 913 | |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 914 | /* do run-time configurations for SHIM, ALH and PDI/PORT */ |
| 915 | intel_pdi_shim_configure(sdw, pdi); |
| 916 | intel_pdi_alh_configure(sdw, pdi); |
| 917 | sdw_cdns_config_stream(cdns, ch, dir, pdi); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 918 | |
Bard Liao | a5a0239 | 2020-08-17 23:29:16 +0800 | [diff] [blame] | 919 | /* store pdi and hw_params, may be needed in prepare step */ |
| 920 | dma->suspended = false; |
| 921 | dma->pdi = pdi; |
| 922 | dma->hw_params = params; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 923 | |
| 924 | /* Inform DSP about PDI stream number */ |
Rander Wang | 4b206d3 | 2019-12-11 19:45:02 -0600 | [diff] [blame] | 925 | ret = intel_params_stream(sdw, substream, dai, params, |
| 926 | sdw->instance, |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 927 | pdi->intel_alh_id); |
| 928 | if (ret) |
| 929 | goto error; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 930 | |
| 931 | sconfig.direction = dir; |
| 932 | sconfig.ch_count = ch; |
| 933 | sconfig.frame_rate = params_rate(params); |
| 934 | sconfig.type = dma->stream_type; |
| 935 | |
| 936 | if (dma->stream_type == SDW_STREAM_PDM) { |
| 937 | sconfig.frame_rate *= 50; |
| 938 | sconfig.bps = 1; |
| 939 | } else { |
| 940 | sconfig.bps = snd_pcm_format_width(params_format(params)); |
| 941 | } |
| 942 | |
| 943 | /* Port configuration */ |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 944 | pconfig = kcalloc(1, sizeof(*pconfig), GFP_KERNEL); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 945 | if (!pconfig) { |
| 946 | ret = -ENOMEM; |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 947 | goto error; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 948 | } |
| 949 | |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 950 | pconfig->num = pdi->num; |
| 951 | pconfig->ch_mask = (1 << ch) - 1; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 952 | |
| 953 | ret = sdw_stream_add_master(&cdns->bus, &sconfig, |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 954 | pconfig, 1, dma->stream); |
| 955 | if (ret) |
Pierre-Louis Bossart | 17ed5be | 2019-05-01 10:57:45 -0500 | [diff] [blame] | 956 | dev_err(cdns->dev, "add master to stream failed:%d\n", ret); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 957 | |
| 958 | kfree(pconfig); |
Pierre-Louis Bossart | 57a3479 | 2019-09-16 14:23:46 -0500 | [diff] [blame] | 959 | error: |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 960 | return ret; |
| 961 | } |
| 962 | |
Rander Wang | 27b198f | 2020-02-14 19:47:37 -0600 | [diff] [blame] | 963 | static int intel_prepare(struct snd_pcm_substream *substream, |
| 964 | struct snd_soc_dai *dai) |
| 965 | { |
Bard Liao | a5a0239 | 2020-08-17 23:29:16 +0800 | [diff] [blame] | 966 | struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); |
| 967 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
Rander Wang | 27b198f | 2020-02-14 19:47:37 -0600 | [diff] [blame] | 968 | struct sdw_cdns_dma_data *dma; |
Bard Liao | a5a0239 | 2020-08-17 23:29:16 +0800 | [diff] [blame] | 969 | int ch, dir; |
| 970 | int ret; |
Rander Wang | 27b198f | 2020-02-14 19:47:37 -0600 | [diff] [blame] | 971 | |
| 972 | dma = snd_soc_dai_get_dma_data(dai, substream); |
| 973 | if (!dma) { |
| 974 | dev_err(dai->dev, "failed to get dma data in %s", |
| 975 | __func__); |
| 976 | return -EIO; |
| 977 | } |
| 978 | |
Bard Liao | a5a0239 | 2020-08-17 23:29:16 +0800 | [diff] [blame] | 979 | if (dma->suspended) { |
| 980 | dma->suspended = false; |
| 981 | |
| 982 | /* |
| 983 | * .prepare() is called after system resume, where we |
| 984 | * need to reinitialize the SHIM/ALH/Cadence IP. |
| 985 | * .prepare() is also called to deal with underflows, |
| 986 | * but in those cases we cannot touch ALH/SHIM |
| 987 | * registers |
| 988 | */ |
| 989 | |
| 990 | /* configure stream */ |
| 991 | ch = params_channels(dma->hw_params); |
| 992 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) |
| 993 | dir = SDW_DATA_DIR_RX; |
| 994 | else |
| 995 | dir = SDW_DATA_DIR_TX; |
| 996 | |
| 997 | intel_pdi_shim_configure(sdw, dma->pdi); |
| 998 | intel_pdi_alh_configure(sdw, dma->pdi); |
| 999 | sdw_cdns_config_stream(cdns, ch, dir, dma->pdi); |
| 1000 | |
| 1001 | /* Inform DSP about PDI stream number */ |
| 1002 | ret = intel_params_stream(sdw, substream, dai, |
| 1003 | dma->hw_params, |
| 1004 | sdw->instance, |
| 1005 | dma->pdi->intel_alh_id); |
| 1006 | if (ret) |
| 1007 | goto err; |
| 1008 | } |
| 1009 | |
| 1010 | ret = sdw_prepare_stream(dma->stream); |
| 1011 | |
| 1012 | err: |
| 1013 | return ret; |
Rander Wang | 27b198f | 2020-02-14 19:47:37 -0600 | [diff] [blame] | 1014 | } |
| 1015 | |
Rander Wang | 973a842 | 2020-02-14 19:47:38 -0600 | [diff] [blame] | 1016 | static int intel_trigger(struct snd_pcm_substream *substream, int cmd, |
| 1017 | struct snd_soc_dai *dai) |
| 1018 | { |
| 1019 | struct sdw_cdns_dma_data *dma; |
| 1020 | int ret; |
| 1021 | |
| 1022 | dma = snd_soc_dai_get_dma_data(dai, substream); |
| 1023 | if (!dma) { |
| 1024 | dev_err(dai->dev, "failed to get dma data in %s", __func__); |
| 1025 | return -EIO; |
| 1026 | } |
| 1027 | |
| 1028 | switch (cmd) { |
| 1029 | case SNDRV_PCM_TRIGGER_START: |
| 1030 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 1031 | case SNDRV_PCM_TRIGGER_RESUME: |
| 1032 | ret = sdw_enable_stream(dma->stream); |
| 1033 | break; |
| 1034 | |
| 1035 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
| 1036 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 1037 | case SNDRV_PCM_TRIGGER_STOP: |
| 1038 | ret = sdw_disable_stream(dma->stream); |
| 1039 | break; |
| 1040 | |
| 1041 | default: |
| 1042 | ret = -EINVAL; |
| 1043 | break; |
| 1044 | } |
| 1045 | |
| 1046 | if (ret) |
| 1047 | dev_err(dai->dev, |
| 1048 | "%s trigger %d failed: %d", |
| 1049 | __func__, cmd, ret); |
| 1050 | return ret; |
| 1051 | } |
| 1052 | |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1053 | static int |
| 1054 | intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) |
| 1055 | { |
| 1056 | struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); |
Pierre-Louis Bossart | eff346f | 2020-02-14 19:47:40 -0600 | [diff] [blame] | 1057 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1058 | struct sdw_cdns_dma_data *dma; |
| 1059 | int ret; |
| 1060 | |
| 1061 | dma = snd_soc_dai_get_dma_data(dai, substream); |
| 1062 | if (!dma) |
| 1063 | return -EIO; |
| 1064 | |
Pierre-Louis Bossart | eff346f | 2020-02-14 19:47:40 -0600 | [diff] [blame] | 1065 | ret = sdw_deprepare_stream(dma->stream); |
| 1066 | if (ret) { |
| 1067 | dev_err(dai->dev, "sdw_deprepare_stream: failed %d", ret); |
| 1068 | return ret; |
| 1069 | } |
| 1070 | |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1071 | ret = sdw_stream_remove_master(&cdns->bus, dma->stream); |
Pierre-Louis Bossart | eff346f | 2020-02-14 19:47:40 -0600 | [diff] [blame] | 1072 | if (ret < 0) { |
Pierre-Louis Bossart | 17ed5be | 2019-05-01 10:57:45 -0500 | [diff] [blame] | 1073 | dev_err(dai->dev, "remove master from stream %s failed: %d\n", |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 1074 | dma->stream->name, ret); |
Pierre-Louis Bossart | eff346f | 2020-02-14 19:47:40 -0600 | [diff] [blame] | 1075 | return ret; |
| 1076 | } |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1077 | |
Pierre-Louis Bossart | eff346f | 2020-02-14 19:47:40 -0600 | [diff] [blame] | 1078 | ret = intel_free_stream(sdw, substream, dai, sdw->instance); |
| 1079 | if (ret < 0) { |
| 1080 | dev_err(dai->dev, "intel_free_stream: failed %d", ret); |
| 1081 | return ret; |
| 1082 | } |
| 1083 | |
Bard Liao | a5a0239 | 2020-08-17 23:29:16 +0800 | [diff] [blame] | 1084 | dma->hw_params = NULL; |
| 1085 | dma->pdi = NULL; |
| 1086 | |
Pierre-Louis Bossart | eff346f | 2020-02-14 19:47:40 -0600 | [diff] [blame] | 1087 | return 0; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1088 | } |
| 1089 | |
Pierre-Louis Bossart | 183c768 | 2019-08-05 19:55:22 -0500 | [diff] [blame] | 1090 | static void intel_shutdown(struct snd_pcm_substream *substream, |
| 1091 | struct snd_soc_dai *dai) |
| 1092 | { |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1093 | struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); |
Pierre-Louis Bossart | 183c768 | 2019-08-05 19:55:22 -0500 | [diff] [blame] | 1094 | |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1095 | pm_runtime_mark_last_busy(cdns->dev); |
| 1096 | pm_runtime_put_autosuspend(cdns->dev); |
Pierre-Louis Bossart | 183c768 | 2019-08-05 19:55:22 -0500 | [diff] [blame] | 1097 | } |
| 1098 | |
Bard Liao | a5a0239 | 2020-08-17 23:29:16 +0800 | [diff] [blame] | 1099 | static int intel_component_dais_suspend(struct snd_soc_component *component) |
| 1100 | { |
| 1101 | struct sdw_cdns_dma_data *dma; |
| 1102 | struct snd_soc_dai *dai; |
| 1103 | |
| 1104 | for_each_component_dais(component, dai) { |
| 1105 | /* |
| 1106 | * we don't have a .suspend dai_ops, and we don't have access |
| 1107 | * to the substream, so let's mark both capture and playback |
| 1108 | * DMA contexts as suspended |
| 1109 | */ |
| 1110 | dma = dai->playback_dma_data; |
| 1111 | if (dma) |
| 1112 | dma->suspended = true; |
| 1113 | |
| 1114 | dma = dai->capture_dma_data; |
| 1115 | if (dma) |
| 1116 | dma->suspended = true; |
| 1117 | } |
| 1118 | |
| 1119 | return 0; |
| 1120 | } |
| 1121 | |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1122 | static int intel_pcm_set_sdw_stream(struct snd_soc_dai *dai, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 1123 | void *stream, int direction) |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1124 | { |
| 1125 | return cdns_set_sdw_stream(dai, stream, true, direction); |
| 1126 | } |
| 1127 | |
| 1128 | static int intel_pdm_set_sdw_stream(struct snd_soc_dai *dai, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 1129 | void *stream, int direction) |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1130 | { |
| 1131 | return cdns_set_sdw_stream(dai, stream, false, direction); |
| 1132 | } |
| 1133 | |
Pierre-Louis Bossart | 0955314 | 2020-07-01 02:43:52 +0800 | [diff] [blame] | 1134 | static void *intel_get_sdw_stream(struct snd_soc_dai *dai, |
| 1135 | int direction) |
| 1136 | { |
| 1137 | struct sdw_cdns_dma_data *dma; |
| 1138 | |
| 1139 | if (direction == SNDRV_PCM_STREAM_PLAYBACK) |
| 1140 | dma = dai->playback_dma_data; |
| 1141 | else |
| 1142 | dma = dai->capture_dma_data; |
| 1143 | |
| 1144 | if (!dma) |
| 1145 | return NULL; |
| 1146 | |
| 1147 | return dma->stream; |
| 1148 | } |
| 1149 | |
Julia Lawall | b163559 | 2018-10-27 15:34:42 +0200 | [diff] [blame] | 1150 | static const struct snd_soc_dai_ops intel_pcm_dai_ops = { |
Rander Wang | 5e7484d | 2020-02-14 19:47:39 -0600 | [diff] [blame] | 1151 | .startup = intel_startup, |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1152 | .hw_params = intel_hw_params, |
Rander Wang | 27b198f | 2020-02-14 19:47:37 -0600 | [diff] [blame] | 1153 | .prepare = intel_prepare, |
Rander Wang | 973a842 | 2020-02-14 19:47:38 -0600 | [diff] [blame] | 1154 | .trigger = intel_trigger, |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1155 | .hw_free = intel_hw_free, |
Pierre-Louis Bossart | 183c768 | 2019-08-05 19:55:22 -0500 | [diff] [blame] | 1156 | .shutdown = intel_shutdown, |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1157 | .set_sdw_stream = intel_pcm_set_sdw_stream, |
Pierre-Louis Bossart | 0955314 | 2020-07-01 02:43:52 +0800 | [diff] [blame] | 1158 | .get_sdw_stream = intel_get_sdw_stream, |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1159 | }; |
| 1160 | |
Julia Lawall | b163559 | 2018-10-27 15:34:42 +0200 | [diff] [blame] | 1161 | static const struct snd_soc_dai_ops intel_pdm_dai_ops = { |
Rander Wang | 5e7484d | 2020-02-14 19:47:39 -0600 | [diff] [blame] | 1162 | .startup = intel_startup, |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1163 | .hw_params = intel_hw_params, |
Rander Wang | 27b198f | 2020-02-14 19:47:37 -0600 | [diff] [blame] | 1164 | .prepare = intel_prepare, |
Rander Wang | 973a842 | 2020-02-14 19:47:38 -0600 | [diff] [blame] | 1165 | .trigger = intel_trigger, |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1166 | .hw_free = intel_hw_free, |
Pierre-Louis Bossart | 183c768 | 2019-08-05 19:55:22 -0500 | [diff] [blame] | 1167 | .shutdown = intel_shutdown, |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1168 | .set_sdw_stream = intel_pdm_set_sdw_stream, |
Pierre-Louis Bossart | 0955314 | 2020-07-01 02:43:52 +0800 | [diff] [blame] | 1169 | .get_sdw_stream = intel_get_sdw_stream, |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1170 | }; |
| 1171 | |
| 1172 | static const struct snd_soc_component_driver dai_component = { |
| 1173 | .name = "soundwire", |
Bard Liao | a5a0239 | 2020-08-17 23:29:16 +0800 | [diff] [blame] | 1174 | .suspend = intel_component_dais_suspend |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1175 | }; |
| 1176 | |
| 1177 | static int intel_create_dai(struct sdw_cdns *cdns, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 1178 | struct snd_soc_dai_driver *dais, |
| 1179 | enum intel_pdi_type type, |
| 1180 | u32 num, u32 off, u32 max_ch, bool pcm) |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1181 | { |
| 1182 | int i; |
| 1183 | |
| 1184 | if (num == 0) |
| 1185 | return 0; |
| 1186 | |
| 1187 | /* TODO: Read supported rates/formats from hardware */ |
| 1188 | for (i = off; i < (off + num); i++) { |
Pierre-Louis Bossart | bf6d6e6 | 2020-06-17 11:35:36 -0500 | [diff] [blame] | 1189 | dais[i].name = devm_kasprintf(cdns->dev, GFP_KERNEL, |
| 1190 | "SDW%d Pin%d", |
| 1191 | cdns->instance, i); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1192 | if (!dais[i].name) |
| 1193 | return -ENOMEM; |
| 1194 | |
| 1195 | if (type == INTEL_PDI_BD || type == INTEL_PDI_OUT) { |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1196 | dais[i].playback.channels_min = 1; |
| 1197 | dais[i].playback.channels_max = max_ch; |
| 1198 | dais[i].playback.rates = SNDRV_PCM_RATE_48000; |
| 1199 | dais[i].playback.formats = SNDRV_PCM_FMTBIT_S16_LE; |
| 1200 | } |
| 1201 | |
| 1202 | if (type == INTEL_PDI_BD || type == INTEL_PDI_IN) { |
Srinivas Kandagatla | 3919412 | 2019-06-06 12:23:04 +0100 | [diff] [blame] | 1203 | dais[i].capture.channels_min = 1; |
| 1204 | dais[i].capture.channels_max = max_ch; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1205 | dais[i].capture.rates = SNDRV_PCM_RATE_48000; |
| 1206 | dais[i].capture.formats = SNDRV_PCM_FMTBIT_S16_LE; |
| 1207 | } |
| 1208 | |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1209 | if (pcm) |
| 1210 | dais[i].ops = &intel_pcm_dai_ops; |
| 1211 | else |
| 1212 | dais[i].ops = &intel_pdm_dai_ops; |
| 1213 | } |
| 1214 | |
| 1215 | return 0; |
| 1216 | } |
| 1217 | |
| 1218 | static int intel_register_dai(struct sdw_intel *sdw) |
| 1219 | { |
| 1220 | struct sdw_cdns *cdns = &sdw->cdns; |
| 1221 | struct sdw_cdns_streams *stream; |
| 1222 | struct snd_soc_dai_driver *dais; |
| 1223 | int num_dai, ret, off = 0; |
| 1224 | |
| 1225 | /* DAIs are created based on total number of PDIs supported */ |
| 1226 | num_dai = cdns->pcm.num_pdi + cdns->pdm.num_pdi; |
| 1227 | |
| 1228 | dais = devm_kcalloc(cdns->dev, num_dai, sizeof(*dais), GFP_KERNEL); |
| 1229 | if (!dais) |
| 1230 | return -ENOMEM; |
| 1231 | |
| 1232 | /* Create PCM DAIs */ |
| 1233 | stream = &cdns->pcm; |
| 1234 | |
Bard Liao | cf92496 | 2019-09-16 14:23:43 -0500 | [diff] [blame] | 1235 | ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pcm.num_in, |
Vinod Koul | 1215dae | 2019-05-02 16:29:25 +0530 | [diff] [blame] | 1236 | off, stream->num_ch_in, true); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1237 | if (ret) |
| 1238 | return ret; |
| 1239 | |
| 1240 | off += cdns->pcm.num_in; |
Vinod Koul | 1215dae | 2019-05-02 16:29:25 +0530 | [diff] [blame] | 1241 | ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pcm.num_out, |
| 1242 | off, stream->num_ch_out, true); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1243 | if (ret) |
| 1244 | return ret; |
| 1245 | |
| 1246 | off += cdns->pcm.num_out; |
Vinod Koul | 1215dae | 2019-05-02 16:29:25 +0530 | [diff] [blame] | 1247 | ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pcm.num_bd, |
| 1248 | off, stream->num_ch_bd, true); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1249 | if (ret) |
| 1250 | return ret; |
| 1251 | |
| 1252 | /* Create PDM DAIs */ |
| 1253 | stream = &cdns->pdm; |
| 1254 | off += cdns->pcm.num_bd; |
Vinod Koul | 1215dae | 2019-05-02 16:29:25 +0530 | [diff] [blame] | 1255 | ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pdm.num_in, |
| 1256 | off, stream->num_ch_in, false); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1257 | if (ret) |
| 1258 | return ret; |
| 1259 | |
| 1260 | off += cdns->pdm.num_in; |
Vinod Koul | 1215dae | 2019-05-02 16:29:25 +0530 | [diff] [blame] | 1261 | ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pdm.num_out, |
| 1262 | off, stream->num_ch_out, false); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1263 | if (ret) |
| 1264 | return ret; |
| 1265 | |
Bard Liao | cf92496 | 2019-09-16 14:23:43 -0500 | [diff] [blame] | 1266 | off += cdns->pdm.num_out; |
Vinod Koul | 1215dae | 2019-05-02 16:29:25 +0530 | [diff] [blame] | 1267 | ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pdm.num_bd, |
| 1268 | off, stream->num_ch_bd, false); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1269 | if (ret) |
| 1270 | return ret; |
| 1271 | |
| 1272 | return snd_soc_register_component(cdns->dev, &dai_component, |
Pierre-Louis Bossart | d542bc9 | 2019-05-01 10:57:38 -0500 | [diff] [blame] | 1273 | dais, num_dai); |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1274 | } |
| 1275 | |
Pierre-Louis Bossart | 085f4ac | 2019-08-05 19:55:16 -0500 | [diff] [blame] | 1276 | static int sdw_master_read_intel_prop(struct sdw_bus *bus) |
| 1277 | { |
| 1278 | struct sdw_master_prop *prop = &bus->prop; |
| 1279 | struct fwnode_handle *link; |
| 1280 | char name[32]; |
Pierre-Louis Bossart | 395713d | 2019-08-21 13:58:21 -0500 | [diff] [blame] | 1281 | u32 quirk_mask; |
Pierre-Louis Bossart | 085f4ac | 2019-08-05 19:55:16 -0500 | [diff] [blame] | 1282 | |
| 1283 | /* Find master handle */ |
| 1284 | snprintf(name, sizeof(name), |
| 1285 | "mipi-sdw-link-%d-subproperties", bus->link_id); |
| 1286 | |
| 1287 | link = device_get_named_child_node(bus->dev, name); |
| 1288 | if (!link) { |
| 1289 | dev_err(bus->dev, "Master node %s not found\n", name); |
| 1290 | return -EIO; |
| 1291 | } |
| 1292 | |
| 1293 | fwnode_property_read_u32(link, |
| 1294 | "intel-sdw-ip-clock", |
| 1295 | &prop->mclk_freq); |
Pierre-Louis Bossart | 395713d | 2019-08-21 13:58:21 -0500 | [diff] [blame] | 1296 | |
Bard Liao | a19efb5 | 2020-01-13 17:11:29 -0600 | [diff] [blame] | 1297 | /* the values reported by BIOS are the 2x clock, not the bus clock */ |
| 1298 | prop->mclk_freq /= 2; |
| 1299 | |
Pierre-Louis Bossart | 395713d | 2019-08-21 13:58:21 -0500 | [diff] [blame] | 1300 | fwnode_property_read_u32(link, |
| 1301 | "intel-quirk-mask", |
| 1302 | &quirk_mask); |
| 1303 | |
| 1304 | if (quirk_mask & SDW_INTEL_QUIRK_MASK_BUS_DISABLE) |
| 1305 | prop->hw_disabled = true; |
| 1306 | |
Pierre-Louis Bossart | 085f4ac | 2019-08-05 19:55:16 -0500 | [diff] [blame] | 1307 | return 0; |
| 1308 | } |
| 1309 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1310 | static int intel_prop_read(struct sdw_bus *bus) |
| 1311 | { |
| 1312 | /* Initialize with default handler to read all DisCo properties */ |
| 1313 | sdw_master_read_prop(bus); |
| 1314 | |
Pierre-Louis Bossart | 085f4ac | 2019-08-05 19:55:16 -0500 | [diff] [blame] | 1315 | /* read Intel-specific properties */ |
| 1316 | sdw_master_read_intel_prop(bus); |
| 1317 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1318 | return 0; |
| 1319 | } |
| 1320 | |
Shreyas NC | c91605f | 2018-04-26 18:38:43 +0530 | [diff] [blame] | 1321 | static struct sdw_master_ops sdw_intel_ops = { |
| 1322 | .read_prop = sdw_master_read_prop, |
| 1323 | .xfer_msg = cdns_xfer_msg, |
| 1324 | .xfer_msg_defer = cdns_xfer_msg_defer, |
| 1325 | .reset_page_addr = cdns_reset_page_addr, |
Vinod Koul | 07abeff | 2018-04-26 18:38:48 +0530 | [diff] [blame] | 1326 | .set_bus_conf = cdns_bus_conf, |
Shreyas NC | 30246e2 | 2018-07-27 14:44:17 +0530 | [diff] [blame] | 1327 | .pre_bank_switch = intel_pre_bank_switch, |
| 1328 | .post_bank_switch = intel_post_bank_switch, |
Shreyas NC | c91605f | 2018-04-26 18:38:43 +0530 | [diff] [blame] | 1329 | }; |
| 1330 | |
Pierre-Louis Bossart | dfbe642 | 2019-10-22 18:54:46 -0500 | [diff] [blame] | 1331 | static int intel_init(struct sdw_intel *sdw) |
| 1332 | { |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 1333 | bool clock_stop; |
| 1334 | |
Pierre-Louis Bossart | dfbe642 | 2019-10-22 18:54:46 -0500 | [diff] [blame] | 1335 | /* Initialize shim and controller */ |
| 1336 | intel_link_power_up(sdw); |
Pierre-Louis Bossart | 4a17c44 | 2020-07-16 23:09:40 +0800 | [diff] [blame] | 1337 | |
| 1338 | clock_stop = sdw_cdns_is_clock_stop(&sdw->cdns); |
| 1339 | |
| 1340 | intel_shim_init(sdw, clock_stop); |
| 1341 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1342 | return 0; |
Pierre-Louis Bossart | dfbe642 | 2019-10-22 18:54:46 -0500 | [diff] [blame] | 1343 | } |
| 1344 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1345 | /* |
| 1346 | * probe and init |
| 1347 | */ |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1348 | static int intel_master_probe(struct platform_device *pdev) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1349 | { |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1350 | struct device *dev = &pdev->dev; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1351 | struct sdw_intel *sdw; |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1352 | struct sdw_cdns *cdns; |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1353 | struct sdw_bus *bus; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1354 | int ret; |
| 1355 | |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1356 | sdw = devm_kzalloc(dev, sizeof(*sdw), GFP_KERNEL); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1357 | if (!sdw) |
| 1358 | return -ENOMEM; |
| 1359 | |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1360 | cdns = &sdw->cdns; |
| 1361 | bus = &cdns->bus; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1362 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1363 | sdw->instance = pdev->id; |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1364 | sdw->link_res = dev_get_platdata(dev); |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1365 | cdns->dev = dev; |
| 1366 | cdns->registers = sdw->link_res->registers; |
| 1367 | cdns->instance = sdw->instance; |
| 1368 | cdns->msg_count = 0; |
| 1369 | |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1370 | bus->link_id = pdev->id; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1371 | |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1372 | sdw_cdns_probe(cdns); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1373 | |
| 1374 | /* Set property read ops */ |
Shreyas NC | c91605f | 2018-04-26 18:38:43 +0530 | [diff] [blame] | 1375 | sdw_intel_ops.read_prop = intel_prop_read; |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1376 | bus->ops = &sdw_intel_ops; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1377 | |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1378 | /* set driver data, accessed by snd_soc_dai_get_drvdata() */ |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1379 | dev_set_drvdata(dev, cdns); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1380 | |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1381 | ret = sdw_bus_master_add(bus, dev, dev->fwnode); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1382 | if (ret) { |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1383 | dev_err(dev, "sdw_bus_master_add fail: %d\n", ret); |
Pierre-Louis Bossart | 9e3d47f | 2019-10-22 18:54:47 -0500 | [diff] [blame] | 1384 | return ret; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1385 | } |
| 1386 | |
Pierre-Louis Bossart | 6d2c666 | 2020-06-01 02:21:02 +0800 | [diff] [blame] | 1387 | if (bus->prop.hw_disabled) |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1388 | dev_info(dev, |
| 1389 | "SoundWire master %d is disabled, will be ignored\n", |
| 1390 | bus->link_id); |
Pierre-Louis Bossart | 0ef2986 | 2020-09-01 23:05:48 +0800 | [diff] [blame] | 1391 | /* |
| 1392 | * Ignore BIOS err_threshold, it's a really bad idea when dealing |
| 1393 | * with multiple hardware synchronized links |
| 1394 | */ |
| 1395 | bus->prop.err_threshold = 0; |
Pierre-Louis Bossart | 6d2c666 | 2020-06-01 02:21:02 +0800 | [diff] [blame] | 1396 | |
Pierre-Louis Bossart | 6d2c666 | 2020-06-01 02:21:02 +0800 | [diff] [blame] | 1397 | return 0; |
Pierre-Louis Bossart | 6d2c666 | 2020-06-01 02:21:02 +0800 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | int intel_master_startup(struct platform_device *pdev) |
| 1401 | { |
| 1402 | struct sdw_cdns_stream_config config; |
| 1403 | struct device *dev = &pdev->dev; |
| 1404 | struct sdw_cdns *cdns = dev_get_drvdata(dev); |
| 1405 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
| 1406 | struct sdw_bus *bus = &cdns->bus; |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1407 | int link_flags; |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1408 | bool multi_link; |
Pierre-Louis Bossart | caf6881 | 2020-08-17 23:29:20 +0800 | [diff] [blame] | 1409 | u32 clock_stop_quirks; |
Pierre-Louis Bossart | 6d2c666 | 2020-06-01 02:21:02 +0800 | [diff] [blame] | 1410 | int ret; |
| 1411 | |
| 1412 | if (bus->prop.hw_disabled) { |
| 1413 | dev_info(dev, |
| 1414 | "SoundWire master %d is disabled, ignoring\n", |
| 1415 | sdw->instance); |
Pierre-Louis Bossart | 395713d | 2019-08-21 13:58:21 -0500 | [diff] [blame] | 1416 | return 0; |
| 1417 | } |
| 1418 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1419 | link_flags = md_flags >> (bus->link_id * 8); |
| 1420 | multi_link = !(link_flags & SDW_INTEL_MASTER_DISABLE_MULTI_LINK); |
| 1421 | if (!multi_link) { |
| 1422 | dev_dbg(dev, "Multi-link is disabled\n"); |
| 1423 | bus->multi_link = false; |
| 1424 | } else { |
Pierre-Louis Bossart | 94eed66 | 2020-09-01 23:05:52 +0800 | [diff] [blame] | 1425 | /* |
| 1426 | * hardware-based synchronization is required regardless |
| 1427 | * of the number of segments used by a stream: SSP-based |
| 1428 | * synchronization is gated by gsync when the multi-master |
| 1429 | * mode is set. |
| 1430 | */ |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1431 | bus->multi_link = true; |
Pierre-Louis Bossart | 94eed66 | 2020-09-01 23:05:52 +0800 | [diff] [blame] | 1432 | bus->hw_sync_min_links = 1; |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | /* Initialize shim, controller */ |
Pierre-Louis Bossart | dfbe642 | 2019-10-22 18:54:46 -0500 | [diff] [blame] | 1436 | ret = intel_init(sdw); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1437 | if (ret) |
| 1438 | goto err_init; |
| 1439 | |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 1440 | /* Read the PDI config and initialize cadence PDI */ |
| 1441 | intel_pdi_init(sdw, &config); |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1442 | ret = sdw_cdns_pdi_init(cdns, config); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1443 | if (ret) |
| 1444 | goto err_init; |
| 1445 | |
Vinod Koul | 37a2d22 | 2018-04-26 18:38:58 +0530 | [diff] [blame] | 1446 | intel_pdi_ch_update(sdw); |
| 1447 | |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1448 | ret = sdw_cdns_enable_interrupt(cdns, true); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1449 | if (ret < 0) { |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1450 | dev_err(dev, "cannot enable interrupts\n"); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1451 | goto err_init; |
| 1452 | } |
| 1453 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1454 | /* |
| 1455 | * follow recommended programming flows to avoid timeouts when |
| 1456 | * gsync is enabled |
| 1457 | */ |
| 1458 | if (multi_link) |
| 1459 | intel_shim_sync_arm(sdw); |
| 1460 | |
| 1461 | ret = sdw_cdns_init(cdns); |
| 1462 | if (ret < 0) { |
| 1463 | dev_err(dev, "unable to initialize Cadence IP\n"); |
| 1464 | goto err_interrupt; |
| 1465 | } |
| 1466 | |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1467 | ret = sdw_cdns_exit_reset(cdns); |
Pierre-Louis Bossart | 49ea07d | 2019-10-22 18:54:44 -0500 | [diff] [blame] | 1468 | if (ret < 0) { |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1469 | dev_err(dev, "unable to exit bus reset sequence\n"); |
Pierre-Louis Bossart | 9e3d47f | 2019-10-22 18:54:47 -0500 | [diff] [blame] | 1470 | goto err_interrupt; |
Pierre-Louis Bossart | 49ea07d | 2019-10-22 18:54:44 -0500 | [diff] [blame] | 1471 | } |
| 1472 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1473 | if (multi_link) { |
| 1474 | ret = intel_shim_sync_go(sdw); |
| 1475 | if (ret < 0) { |
| 1476 | dev_err(dev, "sync go failed: %d\n", ret); |
| 1477 | goto err_interrupt; |
| 1478 | } |
| 1479 | } |
| 1480 | |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1481 | /* Register DAIs */ |
| 1482 | ret = intel_register_dai(sdw); |
| 1483 | if (ret) { |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1484 | dev_err(dev, "DAI registration failed: %d\n", ret); |
| 1485 | snd_soc_unregister_component(dev); |
Pierre-Louis Bossart | 9e3d47f | 2019-10-22 18:54:47 -0500 | [diff] [blame] | 1486 | goto err_interrupt; |
Vinod Koul | c46302e | 2018-04-26 18:39:05 +0530 | [diff] [blame] | 1487 | } |
| 1488 | |
Pierre-Louis Bossart | 79ee663 | 2019-08-21 13:58:20 -0500 | [diff] [blame] | 1489 | intel_debugfs_init(sdw); |
| 1490 | |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1491 | /* Enable runtime PM */ |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1492 | if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME)) { |
| 1493 | pm_runtime_set_autosuspend_delay(dev, |
| 1494 | INTEL_MASTER_SUSPEND_DELAY_MS); |
| 1495 | pm_runtime_use_autosuspend(dev); |
| 1496 | pm_runtime_mark_last_busy(dev); |
| 1497 | |
| 1498 | pm_runtime_set_active(dev); |
| 1499 | pm_runtime_enable(dev); |
| 1500 | } |
| 1501 | |
Pierre-Louis Bossart | caf6881 | 2020-08-17 23:29:20 +0800 | [diff] [blame] | 1502 | clock_stop_quirks = sdw->link_res->clock_stop_quirks; |
| 1503 | if (clock_stop_quirks & SDW_INTEL_CLK_STOP_NOT_ALLOWED) { |
| 1504 | /* |
| 1505 | * To keep the clock running we need to prevent |
| 1506 | * pm_runtime suspend from happening by increasing the |
| 1507 | * reference count. |
| 1508 | * This quirk is specified by the parent PCI device in |
| 1509 | * case of specific latency requirements. It will have |
| 1510 | * no effect if pm_runtime is disabled by the user via |
| 1511 | * a module parameter for testing purposes. |
| 1512 | */ |
| 1513 | pm_runtime_get_noresume(dev); |
| 1514 | } |
| 1515 | |
Pierre-Louis Bossart | a2d9c16 | 2020-08-17 23:29:17 +0800 | [diff] [blame] | 1516 | /* |
| 1517 | * The runtime PM status of Slave devices is "Unsupported" |
| 1518 | * until they report as ATTACHED. If they don't, e.g. because |
| 1519 | * there are no Slave devices populated or if the power-on is |
| 1520 | * delayed or dependent on a power switch, the Master will |
| 1521 | * remain active and prevent its parent from suspending. |
| 1522 | * |
| 1523 | * Conditionally force the pm_runtime core to re-evaluate the |
| 1524 | * Master status in the absence of any Slave activity. A quirk |
| 1525 | * is provided to e.g. deal with Slaves that may be powered on |
| 1526 | * with a delay. A more complete solution would require the |
| 1527 | * definition of Master properties. |
| 1528 | */ |
| 1529 | if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE)) |
| 1530 | pm_runtime_idle(dev); |
| 1531 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1532 | return 0; |
| 1533 | |
Pierre-Louis Bossart | 9e3d47f | 2019-10-22 18:54:47 -0500 | [diff] [blame] | 1534 | err_interrupt: |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1535 | sdw_cdns_enable_interrupt(cdns, false); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1536 | err_init: |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1537 | return ret; |
| 1538 | } |
| 1539 | |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1540 | static int intel_master_remove(struct platform_device *pdev) |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1541 | { |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1542 | struct device *dev = &pdev->dev; |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1543 | struct sdw_cdns *cdns = dev_get_drvdata(dev); |
| 1544 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
| 1545 | struct sdw_bus *bus = &cdns->bus; |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1546 | |
Pierre-Louis Bossart | caf6881 | 2020-08-17 23:29:20 +0800 | [diff] [blame] | 1547 | /* |
| 1548 | * Since pm_runtime is already disabled, we don't decrease |
| 1549 | * the refcount when the clock_stop_quirk is |
| 1550 | * SDW_INTEL_CLK_STOP_NOT_ALLOWED |
| 1551 | */ |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1552 | if (!bus->prop.hw_disabled) { |
Pierre-Louis Bossart | 395713d | 2019-08-21 13:58:21 -0500 | [diff] [blame] | 1553 | intel_debugfs_exit(sdw); |
Pierre-Louis Bossart | 83e129a | 2020-06-01 02:20:58 +0800 | [diff] [blame] | 1554 | sdw_cdns_enable_interrupt(cdns, false); |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1555 | snd_soc_unregister_component(dev); |
Pierre-Louis Bossart | 395713d | 2019-08-21 13:58:21 -0500 | [diff] [blame] | 1556 | } |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1557 | sdw_bus_master_delete(bus); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1558 | |
| 1559 | return 0; |
| 1560 | } |
| 1561 | |
Rander Wang | ab2c913 | 2020-07-16 23:09:46 +0800 | [diff] [blame] | 1562 | int intel_master_process_wakeen_event(struct platform_device *pdev) |
| 1563 | { |
| 1564 | struct device *dev = &pdev->dev; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1565 | struct sdw_intel *sdw; |
Rander Wang | ab2c913 | 2020-07-16 23:09:46 +0800 | [diff] [blame] | 1566 | struct sdw_bus *bus; |
| 1567 | void __iomem *shim; |
| 1568 | u16 wake_sts; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1569 | |
| 1570 | sdw = platform_get_drvdata(pdev); |
Rander Wang | ab2c913 | 2020-07-16 23:09:46 +0800 | [diff] [blame] | 1571 | bus = &sdw->cdns.bus; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1572 | |
Rander Wang | ab2c913 | 2020-07-16 23:09:46 +0800 | [diff] [blame] | 1573 | if (bus->prop.hw_disabled) { |
| 1574 | dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", bus->link_id); |
| 1575 | return 0; |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1576 | } |
Rander Wang | ab2c913 | 2020-07-16 23:09:46 +0800 | [diff] [blame] | 1577 | |
| 1578 | shim = sdw->link_res->shim; |
| 1579 | wake_sts = intel_readw(shim, SDW_SHIM_WAKESTS); |
| 1580 | |
| 1581 | if (!(wake_sts & BIT(sdw->instance))) |
| 1582 | return 0; |
| 1583 | |
| 1584 | /* disable WAKEEN interrupt ASAP to prevent interrupt flood */ |
| 1585 | intel_shim_wake(sdw, false); |
| 1586 | |
| 1587 | /* |
| 1588 | * resume the Master, which will generate a bus reset and result in |
| 1589 | * Slaves re-attaching and be re-enumerated. The SoundWire physical |
| 1590 | * device which generated the wake will trigger an interrupt, which |
| 1591 | * will in turn cause the corresponding Linux Slave device to be |
| 1592 | * resumed and the Slave codec driver to check the status. |
| 1593 | */ |
| 1594 | pm_request_resume(dev); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1595 | |
| 1596 | return 0; |
| 1597 | } |
| 1598 | |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1599 | /* |
| 1600 | * PM calls |
| 1601 | */ |
| 1602 | |
| 1603 | #ifdef CONFIG_PM |
| 1604 | |
Bard Liao | f046b23 | 2020-08-24 21:32:34 +0800 | [diff] [blame] | 1605 | static int __maybe_unused intel_suspend(struct device *dev) |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1606 | { |
| 1607 | struct sdw_cdns *cdns = dev_get_drvdata(dev); |
| 1608 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
| 1609 | struct sdw_bus *bus = &cdns->bus; |
Pierre-Louis Bossart | e4be9fa | 2020-09-01 23:05:47 +0800 | [diff] [blame] | 1610 | u32 clock_stop_quirks; |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1611 | int ret; |
| 1612 | |
| 1613 | if (bus->prop.hw_disabled) { |
| 1614 | dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", |
| 1615 | bus->link_id); |
| 1616 | return 0; |
| 1617 | } |
| 1618 | |
Pierre-Louis Bossart | b61b8b3 | 2020-08-17 23:29:13 +0800 | [diff] [blame] | 1619 | if (pm_runtime_suspended(dev)) { |
| 1620 | dev_dbg(dev, "%s: pm_runtime status: suspended\n", __func__); |
| 1621 | |
Pierre-Louis Bossart | e4be9fa | 2020-09-01 23:05:47 +0800 | [diff] [blame] | 1622 | clock_stop_quirks = sdw->link_res->clock_stop_quirks; |
| 1623 | |
| 1624 | if ((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET || |
| 1625 | !clock_stop_quirks) && |
| 1626 | !pm_runtime_suspended(dev->parent)) { |
| 1627 | |
| 1628 | /* |
| 1629 | * if we've enabled clock stop, and the parent |
| 1630 | * is still active, disable shim wake. The |
| 1631 | * SHIM registers are not accessible if the |
| 1632 | * parent is already pm_runtime suspended so |
| 1633 | * it's too late to change that configuration |
| 1634 | */ |
| 1635 | |
| 1636 | intel_shim_wake(sdw, false); |
| 1637 | } |
| 1638 | |
Pierre-Louis Bossart | b61b8b3 | 2020-08-17 23:29:13 +0800 | [diff] [blame] | 1639 | return 0; |
| 1640 | } |
| 1641 | |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1642 | ret = sdw_cdns_enable_interrupt(cdns, false); |
| 1643 | if (ret < 0) { |
| 1644 | dev_err(dev, "cannot disable interrupts on suspend\n"); |
| 1645 | return ret; |
| 1646 | } |
| 1647 | |
| 1648 | ret = intel_link_power_down(sdw); |
| 1649 | if (ret) { |
| 1650 | dev_err(dev, "Link power down failed: %d", ret); |
| 1651 | return ret; |
| 1652 | } |
| 1653 | |
| 1654 | intel_shim_wake(sdw, false); |
| 1655 | |
| 1656 | return 0; |
| 1657 | } |
| 1658 | |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1659 | static int intel_suspend_runtime(struct device *dev) |
| 1660 | { |
| 1661 | struct sdw_cdns *cdns = dev_get_drvdata(dev); |
| 1662 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
| 1663 | struct sdw_bus *bus = &cdns->bus; |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1664 | u32 clock_stop_quirks; |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1665 | int ret; |
| 1666 | |
| 1667 | if (bus->prop.hw_disabled) { |
| 1668 | dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", |
| 1669 | bus->link_id); |
| 1670 | return 0; |
| 1671 | } |
| 1672 | |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1673 | clock_stop_quirks = sdw->link_res->clock_stop_quirks; |
| 1674 | |
| 1675 | if (clock_stop_quirks & SDW_INTEL_CLK_STOP_TEARDOWN) { |
| 1676 | |
| 1677 | ret = sdw_cdns_enable_interrupt(cdns, false); |
| 1678 | if (ret < 0) { |
| 1679 | dev_err(dev, "cannot disable interrupts on suspend\n"); |
| 1680 | return ret; |
| 1681 | } |
| 1682 | |
| 1683 | ret = intel_link_power_down(sdw); |
| 1684 | if (ret) { |
| 1685 | dev_err(dev, "Link power down failed: %d", ret); |
| 1686 | return ret; |
| 1687 | } |
| 1688 | |
| 1689 | intel_shim_wake(sdw, false); |
| 1690 | |
Pierre-Louis Bossart | 61fb830 | 2020-08-17 23:29:22 +0800 | [diff] [blame] | 1691 | } else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET || |
| 1692 | !clock_stop_quirks) { |
Rander Wang | 6626a61 | 2020-08-17 23:29:19 +0800 | [diff] [blame] | 1693 | ret = sdw_cdns_clock_stop(cdns, true); |
| 1694 | if (ret < 0) { |
| 1695 | dev_err(dev, "cannot enable clock stop on suspend\n"); |
| 1696 | return ret; |
| 1697 | } |
| 1698 | |
| 1699 | ret = sdw_cdns_enable_interrupt(cdns, false); |
| 1700 | if (ret < 0) { |
| 1701 | dev_err(dev, "cannot disable interrupts on suspend\n"); |
| 1702 | return ret; |
| 1703 | } |
| 1704 | |
| 1705 | ret = intel_link_power_down(sdw); |
| 1706 | if (ret) { |
| 1707 | dev_err(dev, "Link power down failed: %d", ret); |
| 1708 | return ret; |
| 1709 | } |
| 1710 | |
| 1711 | intel_shim_wake(sdw, true); |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1712 | } else { |
| 1713 | dev_err(dev, "%s clock_stop_quirks %x unsupported\n", |
| 1714 | __func__, clock_stop_quirks); |
| 1715 | ret = -EINVAL; |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1716 | } |
| 1717 | |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1718 | return ret; |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1719 | } |
| 1720 | |
Bard Liao | f046b23 | 2020-08-24 21:32:34 +0800 | [diff] [blame] | 1721 | static int __maybe_unused intel_resume(struct device *dev) |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1722 | { |
| 1723 | struct sdw_cdns *cdns = dev_get_drvdata(dev); |
| 1724 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
| 1725 | struct sdw_bus *bus = &cdns->bus; |
Pierre-Louis Bossart | a2d9c16 | 2020-08-17 23:29:17 +0800 | [diff] [blame] | 1726 | int link_flags; |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1727 | bool multi_link; |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1728 | int ret; |
| 1729 | |
| 1730 | if (bus->prop.hw_disabled) { |
| 1731 | dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", |
| 1732 | bus->link_id); |
| 1733 | return 0; |
| 1734 | } |
| 1735 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1736 | link_flags = md_flags >> (bus->link_id * 8); |
| 1737 | multi_link = !(link_flags & SDW_INTEL_MASTER_DISABLE_MULTI_LINK); |
| 1738 | |
Pierre-Louis Bossart | b61b8b3 | 2020-08-17 23:29:13 +0800 | [diff] [blame] | 1739 | if (pm_runtime_suspended(dev)) { |
| 1740 | dev_dbg(dev, "%s: pm_runtime status was suspended, forcing active\n", __func__); |
| 1741 | |
| 1742 | /* follow required sequence from runtime_pm.rst */ |
| 1743 | pm_runtime_disable(dev); |
| 1744 | pm_runtime_set_active(dev); |
| 1745 | pm_runtime_mark_last_busy(dev); |
| 1746 | pm_runtime_enable(dev); |
Pierre-Louis Bossart | a2d9c16 | 2020-08-17 23:29:17 +0800 | [diff] [blame] | 1747 | |
| 1748 | link_flags = md_flags >> (bus->link_id * 8); |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1749 | |
Pierre-Louis Bossart | a2d9c16 | 2020-08-17 23:29:17 +0800 | [diff] [blame] | 1750 | if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE)) |
| 1751 | pm_runtime_idle(dev); |
Pierre-Louis Bossart | b61b8b3 | 2020-08-17 23:29:13 +0800 | [diff] [blame] | 1752 | } |
| 1753 | |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1754 | ret = intel_init(sdw); |
| 1755 | if (ret) { |
| 1756 | dev_err(dev, "%s failed: %d", __func__, ret); |
| 1757 | return ret; |
| 1758 | } |
| 1759 | |
Pierre-Louis Bossart | 99b6a30 | 2020-08-17 23:29:15 +0800 | [diff] [blame] | 1760 | /* |
| 1761 | * make sure all Slaves are tagged as UNATTACHED and provide |
| 1762 | * reason for reinitialization |
| 1763 | */ |
| 1764 | sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET); |
| 1765 | |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1766 | ret = sdw_cdns_enable_interrupt(cdns, true); |
| 1767 | if (ret < 0) { |
| 1768 | dev_err(dev, "cannot enable interrupts during resume\n"); |
| 1769 | return ret; |
| 1770 | } |
| 1771 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1772 | /* |
| 1773 | * follow recommended programming flows to avoid timeouts when |
| 1774 | * gsync is enabled |
| 1775 | */ |
| 1776 | if (multi_link) |
| 1777 | intel_shim_sync_arm(sdw); |
| 1778 | |
| 1779 | ret = sdw_cdns_init(&sdw->cdns); |
| 1780 | if (ret < 0) { |
| 1781 | dev_err(dev, "unable to initialize Cadence IP during resume\n"); |
| 1782 | return ret; |
| 1783 | } |
| 1784 | |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1785 | ret = sdw_cdns_exit_reset(cdns); |
| 1786 | if (ret < 0) { |
| 1787 | dev_err(dev, "unable to exit bus reset sequence during resume\n"); |
| 1788 | return ret; |
| 1789 | } |
| 1790 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1791 | if (multi_link) { |
| 1792 | ret = intel_shim_sync_go(sdw); |
| 1793 | if (ret < 0) { |
| 1794 | dev_err(dev, "sync go failed during resume\n"); |
| 1795 | return ret; |
| 1796 | } |
| 1797 | } |
| 1798 | |
Pierre-Louis Bossart | cb1e6d5 | 2020-08-17 23:29:14 +0800 | [diff] [blame] | 1799 | /* |
| 1800 | * after system resume, the pm_runtime suspend() may kick in |
| 1801 | * during the enumeration, before any children device force the |
| 1802 | * master device to remain active. Using pm_runtime_get() |
| 1803 | * routines is not really possible, since it'd prevent the |
| 1804 | * master from suspending. |
| 1805 | * A reasonable compromise is to update the pm_runtime |
| 1806 | * counters and delay the pm_runtime suspend by several |
| 1807 | * seconds, by when all enumeration should be complete. |
| 1808 | */ |
| 1809 | pm_runtime_mark_last_busy(dev); |
| 1810 | |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1811 | return ret; |
| 1812 | } |
| 1813 | |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1814 | static int intel_resume_runtime(struct device *dev) |
| 1815 | { |
| 1816 | struct sdw_cdns *cdns = dev_get_drvdata(dev); |
| 1817 | struct sdw_intel *sdw = cdns_to_intel(cdns); |
| 1818 | struct sdw_bus *bus = &cdns->bus; |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1819 | u32 clock_stop_quirks; |
Rander Wang | 08abad9 | 2020-08-17 23:29:23 +0800 | [diff] [blame] | 1820 | bool clock_stop0; |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1821 | int link_flags; |
| 1822 | bool multi_link; |
Rander Wang | 08abad9 | 2020-08-17 23:29:23 +0800 | [diff] [blame] | 1823 | int status; |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1824 | int ret; |
| 1825 | |
| 1826 | if (bus->prop.hw_disabled) { |
| 1827 | dev_dbg(dev, "SoundWire master %d is disabled, ignoring\n", |
| 1828 | bus->link_id); |
| 1829 | return 0; |
| 1830 | } |
| 1831 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1832 | link_flags = md_flags >> (bus->link_id * 8); |
| 1833 | multi_link = !(link_flags & SDW_INTEL_MASTER_DISABLE_MULTI_LINK); |
| 1834 | |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1835 | clock_stop_quirks = sdw->link_res->clock_stop_quirks; |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1836 | |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1837 | if (clock_stop_quirks & SDW_INTEL_CLK_STOP_TEARDOWN) { |
| 1838 | ret = intel_init(sdw); |
| 1839 | if (ret) { |
| 1840 | dev_err(dev, "%s failed: %d", __func__, ret); |
| 1841 | return ret; |
| 1842 | } |
Pierre-Louis Bossart | 99b6a30 | 2020-08-17 23:29:15 +0800 | [diff] [blame] | 1843 | |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1844 | /* |
| 1845 | * make sure all Slaves are tagged as UNATTACHED and provide |
| 1846 | * reason for reinitialization |
| 1847 | */ |
| 1848 | sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET); |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1849 | |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1850 | ret = sdw_cdns_enable_interrupt(cdns, true); |
| 1851 | if (ret < 0) { |
| 1852 | dev_err(dev, "cannot enable interrupts during resume\n"); |
| 1853 | return ret; |
| 1854 | } |
| 1855 | |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1856 | /* |
| 1857 | * follow recommended programming flows to avoid |
| 1858 | * timeouts when gsync is enabled |
| 1859 | */ |
| 1860 | if (multi_link) |
| 1861 | intel_shim_sync_arm(sdw); |
| 1862 | |
| 1863 | ret = sdw_cdns_init(&sdw->cdns); |
| 1864 | if (ret < 0) { |
| 1865 | dev_err(dev, "unable to initialize Cadence IP during resume\n"); |
| 1866 | return ret; |
| 1867 | } |
| 1868 | |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1869 | ret = sdw_cdns_exit_reset(cdns); |
| 1870 | if (ret < 0) { |
| 1871 | dev_err(dev, "unable to exit bus reset sequence during resume\n"); |
| 1872 | return ret; |
| 1873 | } |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1874 | |
| 1875 | if (multi_link) { |
| 1876 | ret = intel_shim_sync_go(sdw); |
| 1877 | if (ret < 0) { |
| 1878 | dev_err(dev, "sync go failed during resume\n"); |
| 1879 | return ret; |
| 1880 | } |
| 1881 | } |
Rander Wang | 6626a61 | 2020-08-17 23:29:19 +0800 | [diff] [blame] | 1882 | } else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) { |
| 1883 | ret = intel_init(sdw); |
| 1884 | if (ret) { |
| 1885 | dev_err(dev, "%s failed: %d", __func__, ret); |
| 1886 | return ret; |
| 1887 | } |
| 1888 | |
| 1889 | /* |
Rander Wang | 08abad9 | 2020-08-17 23:29:23 +0800 | [diff] [blame] | 1890 | * An exception condition occurs for the CLK_STOP_BUS_RESET |
| 1891 | * case if one or more masters remain active. In this condition, |
| 1892 | * all the masters are powered on for they are in the same power |
| 1893 | * domain. Master can preserve its context for clock stop0, so |
| 1894 | * there is no need to clear slave status and reset bus. |
| 1895 | */ |
| 1896 | clock_stop0 = sdw_cdns_is_clock_stop(&sdw->cdns); |
| 1897 | |
Rander Wang | 08abad9 | 2020-08-17 23:29:23 +0800 | [diff] [blame] | 1898 | if (!clock_stop0) { |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1899 | |
| 1900 | /* |
Pierre-Louis Bossart | 857a7c4 | 2020-09-01 23:05:49 +0800 | [diff] [blame] | 1901 | * make sure all Slaves are tagged as UNATTACHED and |
| 1902 | * provide reason for reinitialization |
| 1903 | */ |
| 1904 | |
Rander Wang | 08abad9 | 2020-08-17 23:29:23 +0800 | [diff] [blame] | 1905 | status = SDW_UNATTACH_REQUEST_MASTER_RESET; |
| 1906 | sdw_clear_slave_status(bus, status); |
Rander Wang | 08abad9 | 2020-08-17 23:29:23 +0800 | [diff] [blame] | 1907 | |
Pierre-Louis Bossart | d78071b | 2020-09-01 23:05:50 +0800 | [diff] [blame] | 1908 | ret = sdw_cdns_enable_interrupt(cdns, true); |
| 1909 | if (ret < 0) { |
| 1910 | dev_err(dev, "cannot enable interrupts during resume\n"); |
| 1911 | return ret; |
| 1912 | } |
Rander Wang | 6626a61 | 2020-08-17 23:29:19 +0800 | [diff] [blame] | 1913 | |
Pierre-Louis Bossart | d78071b | 2020-09-01 23:05:50 +0800 | [diff] [blame] | 1914 | /* |
| 1915 | * follow recommended programming flows to avoid |
| 1916 | * timeouts when gsync is enabled |
| 1917 | */ |
| 1918 | if (multi_link) |
| 1919 | intel_shim_sync_arm(sdw); |
| 1920 | |
| 1921 | /* |
| 1922 | * Re-initialize the IP since it was powered-off |
| 1923 | */ |
| 1924 | sdw_cdns_init(&sdw->cdns); |
| 1925 | |
| 1926 | } else { |
| 1927 | ret = sdw_cdns_enable_interrupt(cdns, true); |
| 1928 | if (ret < 0) { |
| 1929 | dev_err(dev, "cannot enable interrupts during resume\n"); |
| 1930 | return ret; |
| 1931 | } |
Rander Wang | 6626a61 | 2020-08-17 23:29:19 +0800 | [diff] [blame] | 1932 | } |
| 1933 | |
Rander Wang | 08abad9 | 2020-08-17 23:29:23 +0800 | [diff] [blame] | 1934 | ret = sdw_cdns_clock_restart(cdns, !clock_stop0); |
Rander Wang | 6626a61 | 2020-08-17 23:29:19 +0800 | [diff] [blame] | 1935 | if (ret < 0) { |
| 1936 | dev_err(dev, "unable to restart clock during resume\n"); |
| 1937 | return ret; |
| 1938 | } |
Pierre-Louis Bossart | d78071b | 2020-09-01 23:05:50 +0800 | [diff] [blame] | 1939 | |
| 1940 | if (!clock_stop0) { |
| 1941 | ret = sdw_cdns_exit_reset(cdns); |
| 1942 | if (ret < 0) { |
| 1943 | dev_err(dev, "unable to exit bus reset sequence during resume\n"); |
| 1944 | return ret; |
| 1945 | } |
| 1946 | |
| 1947 | if (multi_link) { |
| 1948 | ret = intel_shim_sync_go(sdw); |
| 1949 | if (ret < 0) { |
| 1950 | dev_err(sdw->cdns.dev, "sync go failed during resume\n"); |
| 1951 | return ret; |
| 1952 | } |
| 1953 | } |
| 1954 | } |
Pierre-Louis Bossart | 61fb830 | 2020-08-17 23:29:22 +0800 | [diff] [blame] | 1955 | } else if (!clock_stop_quirks) { |
Pierre-Louis Bossart | f748f34e | 2020-09-01 23:05:54 +0800 | [diff] [blame] | 1956 | |
| 1957 | clock_stop0 = sdw_cdns_is_clock_stop(&sdw->cdns); |
| 1958 | if (!clock_stop0) |
| 1959 | dev_err(dev, "%s invalid configuration, clock was not stopped", __func__); |
| 1960 | |
Pierre-Louis Bossart | 61fb830 | 2020-08-17 23:29:22 +0800 | [diff] [blame] | 1961 | ret = intel_init(sdw); |
| 1962 | if (ret) { |
| 1963 | dev_err(dev, "%s failed: %d", __func__, ret); |
| 1964 | return ret; |
| 1965 | } |
| 1966 | |
| 1967 | ret = sdw_cdns_enable_interrupt(cdns, true); |
| 1968 | if (ret < 0) { |
| 1969 | dev_err(dev, "cannot enable interrupts during resume\n"); |
| 1970 | return ret; |
| 1971 | } |
| 1972 | |
| 1973 | ret = sdw_cdns_clock_restart(cdns, false); |
| 1974 | if (ret < 0) { |
| 1975 | dev_err(dev, "unable to resume master during resume\n"); |
| 1976 | return ret; |
| 1977 | } |
Pierre-Louis Bossart | a320f41 | 2020-08-17 23:29:18 +0800 | [diff] [blame] | 1978 | } else { |
| 1979 | dev_err(dev, "%s clock_stop_quirks %x unsupported\n", |
| 1980 | __func__, clock_stop_quirks); |
| 1981 | ret = -EINVAL; |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1982 | } |
| 1983 | |
| 1984 | return ret; |
| 1985 | } |
| 1986 | |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1987 | #endif |
| 1988 | |
| 1989 | static const struct dev_pm_ops intel_pm = { |
| 1990 | SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume) |
Pierre-Louis Bossart | ebf878e | 2020-08-17 23:29:12 +0800 | [diff] [blame] | 1991 | SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL) |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1992 | }; |
| 1993 | |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1994 | static struct platform_driver sdw_intel_drv = { |
Pierre-Louis Bossart | b6109dd | 2020-06-01 02:20:57 +0800 | [diff] [blame] | 1995 | .probe = intel_master_probe, |
| 1996 | .remove = intel_master_remove, |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 1997 | .driver = { |
Pierre-Louis Bossart | 6d2c666 | 2020-06-01 02:21:02 +0800 | [diff] [blame] | 1998 | .name = "intel-sdw", |
Pierre-Louis Bossart | 9b3b4b3 | 2020-07-22 04:37:11 +0800 | [diff] [blame] | 1999 | .pm = &intel_pm, |
| 2000 | } |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 2001 | }; |
| 2002 | |
| 2003 | module_platform_driver(sdw_intel_drv); |
| 2004 | |
| 2005 | MODULE_LICENSE("Dual BSD/GPL"); |
Pierre-Louis Bossart | 6d2c666 | 2020-06-01 02:21:02 +0800 | [diff] [blame] | 2006 | MODULE_ALIAS("platform:intel-sdw"); |
Vinod Koul | 71bb8a1 | 2017-12-14 11:19:43 +0530 | [diff] [blame] | 2007 | MODULE_DESCRIPTION("Intel Soundwire Master Driver"); |