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