blob: 6a745602c9ccc154c0a0a43c904b641048cae32b [file] [log] [blame]
Vinod Koul71bb8a12017-12-14 11:19:43 +05301// 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 Bossart79ee6632019-08-21 13:58:20 -05009#include <linux/debugfs.h>
Vinod Koul71bb8a12017-12-14 11:19:43 +053010#include <linux/delay.h>
Paul Gortmaker4abbd782019-04-13 11:12:52 -040011#include <linux/module.h>
Vinod Koul71bb8a12017-12-14 11:19:43 +053012#include <linux/interrupt.h>
Pierre-Louis Bossartdf72b712019-09-16 13:57:38 -050013#include <linux/io.h>
Vinod Koul71bb8a12017-12-14 11:19:43 +053014#include <linux/platform_device.h>
Vinod Koul37a2d222018-04-26 18:38:58 +053015#include <sound/pcm_params.h>
16#include <sound/soc.h>
Vinod Koul71bb8a12017-12-14 11:19:43 +053017#include <linux/soundwire/sdw_registers.h>
18#include <linux/soundwire/sdw.h>
19#include <linux/soundwire/sdw_intel.h>
20#include "cadence_master.h"
Pierre-Louis Bossart79ee6632019-08-21 13:58:20 -050021#include "bus.h"
Vinod Koul71bb8a12017-12-14 11:19:43 +053022#include "intel.h"
23
24/* Intel SHIM Registers Definition */
25#define SDW_SHIM_LCAP 0x0
26#define SDW_SHIM_LCTL 0x4
27#define SDW_SHIM_IPPTR 0x8
28#define SDW_SHIM_SYNC 0xC
29
Pierre-Louis Bossart7cc6e312019-05-01 10:57:39 -050030#define SDW_SHIM_CTLSCAP(x) (0x010 + 0x60 * (x))
31#define SDW_SHIM_CTLS0CM(x) (0x012 + 0x60 * (x))
32#define SDW_SHIM_CTLS1CM(x) (0x014 + 0x60 * (x))
33#define SDW_SHIM_CTLS2CM(x) (0x016 + 0x60 * (x))
34#define SDW_SHIM_CTLS3CM(x) (0x018 + 0x60 * (x))
35#define SDW_SHIM_PCMSCAP(x) (0x020 + 0x60 * (x))
Vinod Koul71bb8a12017-12-14 11:19:43 +053036
Pierre-Louis Bossart7cc6e312019-05-01 10:57:39 -050037#define SDW_SHIM_PCMSYCHM(x, y) (0x022 + (0x60 * (x)) + (0x2 * (y)))
38#define SDW_SHIM_PCMSYCHC(x, y) (0x042 + (0x60 * (x)) + (0x2 * (y)))
39#define SDW_SHIM_PDMSCAP(x) (0x062 + 0x60 * (x))
40#define SDW_SHIM_IOCTL(x) (0x06C + 0x60 * (x))
41#define SDW_SHIM_CTMCTL(x) (0x06E + 0x60 * (x))
Vinod Koul71bb8a12017-12-14 11:19:43 +053042
43#define SDW_SHIM_WAKEEN 0x190
44#define SDW_SHIM_WAKESTS 0x192
45
46#define SDW_SHIM_LCTL_SPA BIT(0)
47#define SDW_SHIM_LCTL_CPA BIT(8)
48
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +080049#define SDW_SHIM_SYNC_SYNCPRD_VAL_24 (24000 / SDW_CADENCE_GSYNC_KHZ - 1)
50#define SDW_SHIM_SYNC_SYNCPRD_VAL_38_4 (38400 / SDW_CADENCE_GSYNC_KHZ - 1)
Vinod Koul71bb8a12017-12-14 11:19:43 +053051#define SDW_SHIM_SYNC_SYNCPRD GENMASK(14, 0)
52#define SDW_SHIM_SYNC_SYNCCPU BIT(15)
53#define SDW_SHIM_SYNC_CMDSYNC_MASK GENMASK(19, 16)
54#define SDW_SHIM_SYNC_CMDSYNC BIT(16)
55#define SDW_SHIM_SYNC_SYNCGO BIT(24)
56
57#define SDW_SHIM_PCMSCAP_ISS GENMASK(3, 0)
58#define SDW_SHIM_PCMSCAP_OSS GENMASK(7, 4)
59#define SDW_SHIM_PCMSCAP_BSS GENMASK(12, 8)
60
61#define SDW_SHIM_PCMSYCM_LCHN GENMASK(3, 0)
62#define SDW_SHIM_PCMSYCM_HCHN GENMASK(7, 4)
63#define SDW_SHIM_PCMSYCM_STREAM GENMASK(13, 8)
64#define SDW_SHIM_PCMSYCM_DIR BIT(15)
65
66#define SDW_SHIM_PDMSCAP_ISS GENMASK(3, 0)
67#define SDW_SHIM_PDMSCAP_OSS GENMASK(7, 4)
68#define SDW_SHIM_PDMSCAP_BSS GENMASK(12, 8)
69#define SDW_SHIM_PDMSCAP_CPSS GENMASK(15, 13)
70
71#define SDW_SHIM_IOCTL_MIF BIT(0)
72#define SDW_SHIM_IOCTL_CO BIT(1)
73#define SDW_SHIM_IOCTL_COE BIT(2)
74#define SDW_SHIM_IOCTL_DO BIT(3)
75#define SDW_SHIM_IOCTL_DOE BIT(4)
76#define SDW_SHIM_IOCTL_BKE BIT(5)
77#define SDW_SHIM_IOCTL_WPDD BIT(6)
78#define SDW_SHIM_IOCTL_CIBD BIT(8)
79#define SDW_SHIM_IOCTL_DIBD BIT(9)
80
81#define SDW_SHIM_CTMCTL_DACTQE BIT(0)
82#define SDW_SHIM_CTMCTL_DODS BIT(1)
83#define SDW_SHIM_CTMCTL_DOAIS GENMASK(4, 3)
84
85#define SDW_SHIM_WAKEEN_ENABLE BIT(0)
86#define SDW_SHIM_WAKESTS_STATUS BIT(0)
87
88/* Intel ALH Register definitions */
Pierre-Louis Bossart7cc6e312019-05-01 10:57:39 -050089#define SDW_ALH_STRMZCFG(x) (0x000 + (0x4 * (x)))
Pierre-Louis Bossart79ee6632019-08-21 13:58:20 -050090#define SDW_ALH_NUM_STREAMS 64
Vinod Koul71bb8a12017-12-14 11:19:43 +053091
92#define SDW_ALH_STRMZCFG_DMAT_VAL 0x3
93#define SDW_ALH_STRMZCFG_DMAT GENMASK(7, 0)
94#define SDW_ALH_STRMZCFG_CHN GENMASK(19, 16)
95
Vinod Koulc46302e2018-04-26 18:39:05 +053096enum intel_pdi_type {
97 INTEL_PDI_IN = 0,
98 INTEL_PDI_OUT = 1,
99 INTEL_PDI_BD = 2,
100};
101
Vinod Koul71bb8a12017-12-14 11:19:43 +0530102#define cdns_to_intel(_cdns) container_of(_cdns, struct sdw_intel, cdns)
103
104/*
105 * Read, write helpers for HW registers
106 */
107static inline int intel_readl(void __iomem *base, int offset)
108{
109 return readl(base + offset);
110}
111
112static inline void intel_writel(void __iomem *base, int offset, int value)
113{
114 writel(value, base + offset);
115}
116
117static inline u16 intel_readw(void __iomem *base, int offset)
118{
119 return readw(base + offset);
120}
121
122static inline void intel_writew(void __iomem *base, int offset, u16 value)
123{
124 writew(value, base + offset);
125}
126
Pierre-Louis Bossart7d2845d2020-07-16 23:09:39 +0800127static int intel_wait_bit(void __iomem *base, int offset, u32 mask, u32 target)
Vinod Koul71bb8a12017-12-14 11:19:43 +0530128{
129 int timeout = 10;
130 u32 reg_read;
131
Vinod Koul71bb8a12017-12-14 11:19:43 +0530132 do {
133 reg_read = readl(base + offset);
Pierre-Louis Bossart7d2845d2020-07-16 23:09:39 +0800134 if ((reg_read & mask) == target)
Vinod Koul71bb8a12017-12-14 11:19:43 +0530135 return 0;
136
137 timeout--;
Pierre-Louis Bossart7d2845d2020-07-16 23:09:39 +0800138 usleep_range(50, 100);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530139 } while (timeout != 0);
140
141 return -EAGAIN;
142}
143
Pierre-Louis Bossart7d2845d2020-07-16 23:09:39 +0800144static int intel_clear_bit(void __iomem *base, int offset, u32 value, u32 mask)
145{
146 writel(value, base + offset);
147 return intel_wait_bit(base, offset, mask, 0);
148}
149
Vinod Koul71bb8a12017-12-14 11:19:43 +0530150static int intel_set_bit(void __iomem *base, int offset, u32 value, u32 mask)
151{
Vinod Koul71bb8a12017-12-14 11:19:43 +0530152 writel(value, base + offset);
Pierre-Louis Bossart7d2845d2020-07-16 23:09:39 +0800153 return intel_wait_bit(base, offset, mask, mask);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530154}
155
156/*
Pierre-Louis Bossart79ee6632019-08-21 13:58:20 -0500157 * debugfs
158 */
159#ifdef CONFIG_DEBUG_FS
160
161#define RD_BUF (2 * PAGE_SIZE)
162
163static ssize_t intel_sprintf(void __iomem *mem, bool l,
164 char *buf, size_t pos, unsigned int reg)
165{
166 int value;
167
168 if (l)
169 value = intel_readl(mem, reg);
170 else
171 value = intel_readw(mem, reg);
172
173 return scnprintf(buf + pos, RD_BUF - pos, "%4x\t%4x\n", reg, value);
174}
175
176static int intel_reg_show(struct seq_file *s_file, void *data)
177{
178 struct sdw_intel *sdw = s_file->private;
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600179 void __iomem *s = sdw->link_res->shim;
180 void __iomem *a = sdw->link_res->alh;
Pierre-Louis Bossart79ee6632019-08-21 13:58:20 -0500181 char *buf;
182 ssize_t ret;
183 int i, j;
184 unsigned int links, reg;
185
186 buf = kzalloc(RD_BUF, GFP_KERNEL);
187 if (!buf)
188 return -ENOMEM;
189
190 links = intel_readl(s, SDW_SHIM_LCAP) & GENMASK(2, 0);
191
192 ret = scnprintf(buf, RD_BUF, "Register Value\n");
193 ret += scnprintf(buf + ret, RD_BUF - ret, "\nShim\n");
194
195 for (i = 0; i < links; i++) {
196 reg = SDW_SHIM_LCAP + i * 4;
197 ret += intel_sprintf(s, true, buf, ret, reg);
198 }
199
200 for (i = 0; i < links; i++) {
201 ret += scnprintf(buf + ret, RD_BUF - ret, "\nLink%d\n", i);
202 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLSCAP(i));
203 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS0CM(i));
204 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS1CM(i));
205 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS2CM(i));
206 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTLS3CM(i));
207 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_PCMSCAP(i));
208
209 ret += scnprintf(buf + ret, RD_BUF - ret, "\n PCMSyCH registers\n");
210
211 /*
212 * the value 10 is the number of PDIs. We will need a
213 * cleanup to remove hard-coded Intel configurations
214 * from cadence_master.c
215 */
216 for (j = 0; j < 10; j++) {
217 ret += intel_sprintf(s, false, buf, ret,
218 SDW_SHIM_PCMSYCHM(i, j));
219 ret += intel_sprintf(s, false, buf, ret,
220 SDW_SHIM_PCMSYCHC(i, j));
221 }
222 ret += scnprintf(buf + ret, RD_BUF - ret, "\n PDMSCAP, IOCTL, CTMCTL\n");
223
224 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_PDMSCAP(i));
225 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_IOCTL(i));
226 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_CTMCTL(i));
227 }
228
229 ret += scnprintf(buf + ret, RD_BUF - ret, "\nWake registers\n");
230 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_WAKEEN);
231 ret += intel_sprintf(s, false, buf, ret, SDW_SHIM_WAKESTS);
232
233 ret += scnprintf(buf + ret, RD_BUF - ret, "\nALH STRMzCFG\n");
234 for (i = 0; i < SDW_ALH_NUM_STREAMS; i++)
235 ret += intel_sprintf(a, true, buf, ret, SDW_ALH_STRMZCFG(i));
236
237 seq_printf(s_file, "%s", buf);
238 kfree(buf);
239
240 return 0;
241}
242DEFINE_SHOW_ATTRIBUTE(intel_reg);
243
244static void intel_debugfs_init(struct sdw_intel *sdw)
245{
246 struct dentry *root = sdw->cdns.bus.debugfs;
247
248 if (!root)
249 return;
250
251 sdw->debugfs = debugfs_create_dir("intel-sdw", root);
252
253 debugfs_create_file("intel-registers", 0400, sdw->debugfs, sdw,
254 &intel_reg_fops);
255
256 sdw_cdns_debugfs_init(&sdw->cdns, sdw->debugfs);
257}
258
259static void intel_debugfs_exit(struct sdw_intel *sdw)
260{
261 debugfs_remove_recursive(sdw->debugfs);
262}
263#else
264static void intel_debugfs_init(struct sdw_intel *sdw) {}
265static void intel_debugfs_exit(struct sdw_intel *sdw) {}
266#endif /* CONFIG_DEBUG_FS */
267
268/*
Vinod Koul71bb8a12017-12-14 11:19:43 +0530269 * shim ops
270 */
271
272static int intel_link_power_up(struct sdw_intel *sdw)
273{
274 unsigned int link_id = sdw->instance;
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600275 void __iomem *shim = sdw->link_res->shim;
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800276 u32 *shim_mask = sdw->link_res->shim_mask;
277 struct sdw_bus *bus = &sdw->cdns.bus;
278 struct sdw_master_prop *prop = &bus->prop;
Vinod Koul71bb8a12017-12-14 11:19:43 +0530279 int spa_mask, cpa_mask;
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800280 int link_control;
281 int ret = 0;
282 u32 syncprd;
283 u32 sync_reg;
284
285 mutex_lock(sdw->link_res->shim_lock);
286
287 /*
288 * The hardware relies on an internal counter, typically 4kHz,
289 * to generate the SoundWire SSP - which defines a 'safe'
290 * synchronization point between commands and audio transport
291 * and allows for multi link synchronization. The SYNCPRD value
292 * is only dependent on the oscillator clock provided to
293 * the IP, so adjust based on _DSD properties reported in DSDT
294 * tables. The values reported are based on either 24MHz
295 * (CNL/CML) or 38.4 MHz (ICL/TGL+).
296 */
297 if (prop->mclk_freq % 6000000)
298 syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_38_4;
299 else
300 syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_24;
301
302 if (!*shim_mask) {
303 /* we first need to program the SyncPRD/CPU registers */
304 dev_dbg(sdw->cdns.dev,
305 "%s: first link up, programming SYNCPRD\n", __func__);
306
307 /* set SyncPRD period */
308 sync_reg = intel_readl(shim, SDW_SHIM_SYNC);
309 sync_reg |= (syncprd <<
310 SDW_REG_SHIFT(SDW_SHIM_SYNC_SYNCPRD));
311
312 /* Set SyncCPU bit */
313 sync_reg |= SDW_SHIM_SYNC_SYNCCPU;
314 intel_writel(shim, SDW_SHIM_SYNC, sync_reg);
315 }
Vinod Koul71bb8a12017-12-14 11:19:43 +0530316
317 /* Link power up sequence */
318 link_control = intel_readl(shim, SDW_SHIM_LCTL);
319 spa_mask = (SDW_SHIM_LCTL_SPA << link_id);
320 cpa_mask = (SDW_SHIM_LCTL_CPA << link_id);
321 link_control |= spa_mask;
322
323 ret = intel_set_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800324 if (ret < 0) {
325 dev_err(sdw->cdns.dev, "Failed to power up link: %d\n", ret);
326 goto out;
327 }
328
329 if (!*shim_mask) {
330 /* SyncCPU will change once link is active */
331 ret = intel_wait_bit(shim, SDW_SHIM_SYNC,
332 SDW_SHIM_SYNC_SYNCCPU, 0);
333 if (ret < 0) {
334 dev_err(sdw->cdns.dev,
335 "Failed to set SHIM_SYNC: %d\n", ret);
336 goto out;
337 }
338 }
339
340 *shim_mask |= BIT(link_id);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530341
342 sdw->cdns.link_up = true;
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800343out:
344 mutex_unlock(sdw->link_res->shim_lock);
345
346 return ret;
Vinod Koul71bb8a12017-12-14 11:19:43 +0530347}
348
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800349/* this needs to be called with shim_lock */
350static void intel_shim_glue_to_master_ip(struct sdw_intel *sdw)
Vinod Koul71bb8a12017-12-14 11:19:43 +0530351{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600352 void __iomem *shim = sdw->link_res->shim;
Vinod Koul71bb8a12017-12-14 11:19:43 +0530353 unsigned int link_id = sdw->instance;
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800354 u16 ioctl;
Vinod Koul71bb8a12017-12-14 11:19:43 +0530355
356 /* Switch to MIP from Glue logic */
357 ioctl = intel_readw(shim, SDW_SHIM_IOCTL(link_id));
358
359 ioctl &= ~(SDW_SHIM_IOCTL_DOE);
360 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800361 usleep_range(10, 15);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530362
363 ioctl &= ~(SDW_SHIM_IOCTL_DO);
364 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800365 usleep_range(10, 15);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530366
367 ioctl |= (SDW_SHIM_IOCTL_MIF);
368 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800369 usleep_range(10, 15);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530370
371 ioctl &= ~(SDW_SHIM_IOCTL_BKE);
372 ioctl &= ~(SDW_SHIM_IOCTL_COE);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530373 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800374 usleep_range(10, 15);
375
376 /* at this point Master IP has full control of the I/Os */
377}
378
379/* this needs to be called with shim_lock */
380static void intel_shim_master_ip_to_glue(struct sdw_intel *sdw)
381{
382 unsigned int link_id = sdw->instance;
383 void __iomem *shim = sdw->link_res->shim;
384 u16 ioctl;
385
386 /* Glue logic */
387 ioctl = intel_readw(shim, SDW_SHIM_IOCTL(link_id));
388 ioctl |= SDW_SHIM_IOCTL_BKE;
389 ioctl |= SDW_SHIM_IOCTL_COE;
390 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
391 usleep_range(10, 15);
392
393 ioctl &= ~(SDW_SHIM_IOCTL_MIF);
394 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
395 usleep_range(10, 15);
396
397 /* at this point Integration Glue has full control of the I/Os */
398}
399
400static int intel_shim_init(struct sdw_intel *sdw, bool clock_stop)
401{
402 void __iomem *shim = sdw->link_res->shim;
403 unsigned int link_id = sdw->instance;
404 int ret = 0;
405 u16 ioctl = 0, act = 0;
406
407 mutex_lock(sdw->link_res->shim_lock);
408
409 /* Initialize Shim */
410 ioctl |= SDW_SHIM_IOCTL_BKE;
411 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
412 usleep_range(10, 15);
413
414 ioctl |= SDW_SHIM_IOCTL_WPDD;
415 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
416 usleep_range(10, 15);
417
418 ioctl |= SDW_SHIM_IOCTL_DO;
419 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
420 usleep_range(10, 15);
421
422 ioctl |= SDW_SHIM_IOCTL_DOE;
423 intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
424 usleep_range(10, 15);
425
426 intel_shim_glue_to_master_ip(sdw);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530427
428 act |= 0x1 << SDW_REG_SHIFT(SDW_SHIM_CTMCTL_DOAIS);
429 act |= SDW_SHIM_CTMCTL_DACTQE;
430 act |= SDW_SHIM_CTMCTL_DODS;
431 intel_writew(shim, SDW_SHIM_CTMCTL(link_id), act);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800432 usleep_range(10, 15);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530433
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800434 mutex_unlock(sdw->link_res->shim_lock);
Vinod Koul71bb8a12017-12-14 11:19:43 +0530435
436 return ret;
437}
438
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800439static void __maybe_unused intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
440{
441 void __iomem *shim = sdw->link_res->shim;
442 unsigned int link_id = sdw->instance;
443 u16 wake_en, wake_sts;
444
445 mutex_lock(sdw->link_res->shim_lock);
446 wake_en = intel_readw(shim, SDW_SHIM_WAKEEN);
447
448 if (wake_enable) {
449 /* Enable the wakeup */
450 wake_en |= (SDW_SHIM_WAKEEN_ENABLE << link_id);
451 intel_writew(shim, SDW_SHIM_WAKEEN, wake_en);
452 } else {
453 /* Disable the wake up interrupt */
454 wake_en &= ~(SDW_SHIM_WAKEEN_ENABLE << link_id);
455 intel_writew(shim, SDW_SHIM_WAKEEN, wake_en);
456
457 /* Clear wake status */
458 wake_sts = intel_readw(shim, SDW_SHIM_WAKESTS);
459 wake_sts |= (SDW_SHIM_WAKEEN_ENABLE << link_id);
460 intel_writew(shim, SDW_SHIM_WAKESTS_STATUS, wake_sts);
461 }
462 mutex_unlock(sdw->link_res->shim_lock);
463}
464
465static int __maybe_unused intel_link_power_down(struct sdw_intel *sdw)
466{
467 int link_control, spa_mask, cpa_mask;
468 unsigned int link_id = sdw->instance;
469 void __iomem *shim = sdw->link_res->shim;
470 u32 *shim_mask = sdw->link_res->shim_mask;
471 int ret = 0;
472
473 mutex_lock(sdw->link_res->shim_lock);
474
475 intel_shim_master_ip_to_glue(sdw);
476
477 /* Link power down sequence */
478 link_control = intel_readl(shim, SDW_SHIM_LCTL);
479 spa_mask = ~(SDW_SHIM_LCTL_SPA << link_id);
480 cpa_mask = (SDW_SHIM_LCTL_CPA << link_id);
481 link_control &= spa_mask;
482
483 ret = intel_clear_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask);
484
485 if (!(*shim_mask & BIT(link_id)))
486 dev_err(sdw->cdns.dev,
487 "%s: Unbalanced power-up/down calls\n", __func__);
488
489 *shim_mask &= ~BIT(link_id);
490
491 mutex_unlock(sdw->link_res->shim_lock);
492
493 if (ret < 0)
494 return ret;
495
496 sdw->cdns.link_up = false;
497 return 0;
498}
499
Pierre-Louis Bossart02629e452020-07-16 23:09:41 +0800500static void intel_shim_sync_arm(struct sdw_intel *sdw)
501{
502 void __iomem *shim = sdw->link_res->shim;
503 u32 sync_reg;
504
505 mutex_lock(sdw->link_res->shim_lock);
506
507 /* update SYNC register */
508 sync_reg = intel_readl(shim, SDW_SHIM_SYNC);
509 sync_reg |= (SDW_SHIM_SYNC_CMDSYNC << sdw->instance);
510 intel_writel(shim, SDW_SHIM_SYNC, sync_reg);
511
512 mutex_unlock(sdw->link_res->shim_lock);
513}
514
Vinod Koul37a2d222018-04-26 18:38:58 +0530515/*
516 * PDI routines
517 */
518static void intel_pdi_init(struct sdw_intel *sdw,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500519 struct sdw_cdns_stream_config *config)
Vinod Koul37a2d222018-04-26 18:38:58 +0530520{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600521 void __iomem *shim = sdw->link_res->shim;
Vinod Koul37a2d222018-04-26 18:38:58 +0530522 unsigned int link_id = sdw->instance;
523 int pcm_cap, pdm_cap;
524
525 /* PCM Stream Capability */
526 pcm_cap = intel_readw(shim, SDW_SHIM_PCMSCAP(link_id));
527
528 config->pcm_bd = (pcm_cap & SDW_SHIM_PCMSCAP_BSS) >>
529 SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_BSS);
530 config->pcm_in = (pcm_cap & SDW_SHIM_PCMSCAP_ISS) >>
531 SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_ISS);
532 config->pcm_out = (pcm_cap & SDW_SHIM_PCMSCAP_OSS) >>
533 SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_OSS);
534
Pierre-Louis Bossart121f4362019-05-22 14:47:29 -0500535 dev_dbg(sdw->cdns.dev, "PCM cap bd:%d in:%d out:%d\n",
536 config->pcm_bd, config->pcm_in, config->pcm_out);
537
Vinod Koul37a2d222018-04-26 18:38:58 +0530538 /* PDM Stream Capability */
539 pdm_cap = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id));
540
541 config->pdm_bd = (pdm_cap & SDW_SHIM_PDMSCAP_BSS) >>
542 SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_BSS);
543 config->pdm_in = (pdm_cap & SDW_SHIM_PDMSCAP_ISS) >>
544 SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_ISS);
545 config->pdm_out = (pdm_cap & SDW_SHIM_PDMSCAP_OSS) >>
546 SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_OSS);
Pierre-Louis Bossart121f4362019-05-22 14:47:29 -0500547
548 dev_dbg(sdw->cdns.dev, "PDM cap bd:%d in:%d out:%d\n",
549 config->pdm_bd, config->pdm_in, config->pdm_out);
Vinod Koul37a2d222018-04-26 18:38:58 +0530550}
551
552static int
553intel_pdi_get_ch_cap(struct sdw_intel *sdw, unsigned int pdi_num, bool pcm)
554{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600555 void __iomem *shim = sdw->link_res->shim;
Vinod Koul37a2d222018-04-26 18:38:58 +0530556 unsigned int link_id = sdw->instance;
557 int count;
558
559 if (pcm) {
560 count = intel_readw(shim, SDW_SHIM_PCMSYCHC(link_id, pdi_num));
Pierre-Louis Bossart18046332019-08-05 19:55:07 -0500561
562 /*
563 * WORKAROUND: on all existing Intel controllers, pdi
564 * number 2 reports channel count as 1 even though it
565 * supports 8 channels. Performing hardcoding for pdi
566 * number 2.
567 */
568 if (pdi_num == 2)
569 count = 7;
570
Vinod Koul37a2d222018-04-26 18:38:58 +0530571 } else {
572 count = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id));
573 count = ((count & SDW_SHIM_PDMSCAP_CPSS) >>
574 SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_CPSS));
575 }
576
577 /* zero based values for channel count in register */
578 count++;
579
580 return count;
581}
582
583static int intel_pdi_get_ch_update(struct sdw_intel *sdw,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500584 struct sdw_cdns_pdi *pdi,
585 unsigned int num_pdi,
586 unsigned int *num_ch, bool pcm)
Vinod Koul37a2d222018-04-26 18:38:58 +0530587{
588 int i, ch_count = 0;
589
590 for (i = 0; i < num_pdi; i++) {
591 pdi->ch_count = intel_pdi_get_ch_cap(sdw, pdi->num, pcm);
592 ch_count += pdi->ch_count;
593 pdi++;
594 }
595
596 *num_ch = ch_count;
597 return 0;
598}
599
600static int intel_pdi_stream_ch_update(struct sdw_intel *sdw,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500601 struct sdw_cdns_streams *stream, bool pcm)
Vinod Koul37a2d222018-04-26 18:38:58 +0530602{
603 intel_pdi_get_ch_update(sdw, stream->bd, stream->num_bd,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500604 &stream->num_ch_bd, pcm);
Vinod Koul37a2d222018-04-26 18:38:58 +0530605
606 intel_pdi_get_ch_update(sdw, stream->in, stream->num_in,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500607 &stream->num_ch_in, pcm);
Vinod Koul37a2d222018-04-26 18:38:58 +0530608
609 intel_pdi_get_ch_update(sdw, stream->out, stream->num_out,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500610 &stream->num_ch_out, pcm);
Vinod Koul37a2d222018-04-26 18:38:58 +0530611
612 return 0;
613}
614
615static int intel_pdi_ch_update(struct sdw_intel *sdw)
616{
617 /* First update PCM streams followed by PDM streams */
618 intel_pdi_stream_ch_update(sdw, &sdw->cdns.pcm, true);
619 intel_pdi_stream_ch_update(sdw, &sdw->cdns.pdm, false);
620
621 return 0;
622}
623
624static void
625intel_pdi_shim_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)
626{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600627 void __iomem *shim = sdw->link_res->shim;
Vinod Koul37a2d222018-04-26 18:38:58 +0530628 unsigned int link_id = sdw->instance;
629 int pdi_conf = 0;
630
Pierre-Louis Bossartc134f912019-10-22 18:29:48 -0500631 /* the Bulk and PCM streams are not contiguous */
632 pdi->intel_alh_id = (link_id * 16) + pdi->num + 3;
633 if (pdi->num >= 2)
634 pdi->intel_alh_id += 2;
Vinod Koul37a2d222018-04-26 18:38:58 +0530635
636 /*
637 * Program stream parameters to stream SHIM register
638 * This is applicable for PCM stream only.
639 */
640 if (pdi->type != SDW_STREAM_PCM)
641 return;
642
643 if (pdi->dir == SDW_DATA_DIR_RX)
644 pdi_conf |= SDW_SHIM_PCMSYCM_DIR;
645 else
646 pdi_conf &= ~(SDW_SHIM_PCMSYCM_DIR);
647
648 pdi_conf |= (pdi->intel_alh_id <<
649 SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_STREAM));
650 pdi_conf |= (pdi->l_ch_num << SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_LCHN));
651 pdi_conf |= (pdi->h_ch_num << SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_HCHN));
652
653 intel_writew(shim, SDW_SHIM_PCMSYCHM(link_id, pdi->num), pdi_conf);
654}
655
656static void
657intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)
658{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600659 void __iomem *alh = sdw->link_res->alh;
Vinod Koul37a2d222018-04-26 18:38:58 +0530660 unsigned int link_id = sdw->instance;
661 unsigned int conf;
662
Pierre-Louis Bossartc134f912019-10-22 18:29:48 -0500663 /* the Bulk and PCM streams are not contiguous */
664 pdi->intel_alh_id = (link_id * 16) + pdi->num + 3;
665 if (pdi->num >= 2)
666 pdi->intel_alh_id += 2;
Vinod Koul37a2d222018-04-26 18:38:58 +0530667
668 /* Program Stream config ALH register */
669 conf = intel_readl(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id));
670
671 conf |= (SDW_ALH_STRMZCFG_DMAT_VAL <<
672 SDW_REG_SHIFT(SDW_ALH_STRMZCFG_DMAT));
673
674 conf |= ((pdi->ch_count - 1) <<
675 SDW_REG_SHIFT(SDW_ALH_STRMZCFG_CHN));
676
677 intel_writel(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id), conf);
678}
679
Rander Wang4b206d32019-12-11 19:45:02 -0600680static int intel_params_stream(struct sdw_intel *sdw,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500681 struct snd_pcm_substream *substream,
682 struct snd_soc_dai *dai,
Rander Wang4b206d32019-12-11 19:45:02 -0600683 struct snd_pcm_hw_params *hw_params,
684 int link_id, int alh_stream_id)
Vinod Koulc46302e2018-04-26 18:39:05 +0530685{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600686 struct sdw_intel_link_res *res = sdw->link_res;
Rander Wang4b206d32019-12-11 19:45:02 -0600687 struct sdw_intel_stream_params_data params_data;
Pierre-Louis Bossart05c8afe42019-08-05 19:55:06 -0500688
Rander Wang4b206d32019-12-11 19:45:02 -0600689 params_data.substream = substream;
690 params_data.dai = dai;
691 params_data.hw_params = hw_params;
692 params_data.link_id = link_id;
693 params_data.alh_stream_id = alh_stream_id;
Vinod Koulc46302e2018-04-26 18:39:05 +0530694
Rander Wang4b206d32019-12-11 19:45:02 -0600695 if (res->ops && res->ops->params_stream && res->dev)
696 return res->ops->params_stream(res->dev,
697 &params_data);
Vinod Koulc46302e2018-04-26 18:39:05 +0530698 return -EIO;
699}
700
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600701static int intel_free_stream(struct sdw_intel *sdw,
702 struct snd_pcm_substream *substream,
703 struct snd_soc_dai *dai,
704 int link_id)
705{
706 struct sdw_intel_link_res *res = sdw->link_res;
707 struct sdw_intel_stream_free_data free_data;
708
709 free_data.substream = substream;
710 free_data.dai = dai;
711 free_data.link_id = link_id;
712
713 if (res->ops && res->ops->free_stream && res->dev)
714 return res->ops->free_stream(res->dev,
715 &free_data);
716
717 return 0;
718}
719
Vinod Koulc46302e2018-04-26 18:39:05 +0530720/*
Shreyas NC30246e22018-07-27 14:44:17 +0530721 * bank switch routines
722 */
723
724static int intel_pre_bank_switch(struct sdw_bus *bus)
725{
726 struct sdw_cdns *cdns = bus_to_cdns(bus);
727 struct sdw_intel *sdw = cdns_to_intel(cdns);
Shreyas NC30246e22018-07-27 14:44:17 +0530728
729 /* Write to register only for multi-link */
730 if (!bus->multi_link)
731 return 0;
732
Pierre-Louis Bossart02629e452020-07-16 23:09:41 +0800733 intel_shim_sync_arm(sdw);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800734
Shreyas NC30246e22018-07-27 14:44:17 +0530735 return 0;
736}
737
738static int intel_post_bank_switch(struct sdw_bus *bus)
739{
740 struct sdw_cdns *cdns = bus_to_cdns(bus);
741 struct sdw_intel *sdw = cdns_to_intel(cdns);
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600742 void __iomem *shim = sdw->link_res->shim;
Shreyas NC30246e22018-07-27 14:44:17 +0530743 int sync_reg, ret;
744
745 /* Write to register only for multi-link */
746 if (!bus->multi_link)
747 return 0;
748
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800749 mutex_lock(sdw->link_res->shim_lock);
750
Shreyas NC30246e22018-07-27 14:44:17 +0530751 /* Read SYNC register */
752 sync_reg = intel_readl(shim, SDW_SHIM_SYNC);
753
754 /*
755 * post_bank_switch() ops is called from the bus in loop for
756 * all the Masters in the steam with the expectation that
757 * we trigger the bankswitch for the only first Master in the list
758 * and do nothing for the other Masters
759 *
760 * So, set the SYNCGO bit only if CMDSYNC bit is set for any Master.
761 */
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800762 if (!(sync_reg & SDW_SHIM_SYNC_CMDSYNC_MASK)) {
763 ret = 0;
764 goto unlock;
765 }
Shreyas NC30246e22018-07-27 14:44:17 +0530766 /*
767 * Set SyncGO bit to synchronously trigger a bank switch for
768 * all the masters. A write to SYNCGO bit clears CMDSYNC bit for all
769 * the Masters.
770 */
771 sync_reg |= SDW_SHIM_SYNC_SYNCGO;
772
773 ret = intel_clear_bit(shim, SDW_SHIM_SYNC, sync_reg,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500774 SDW_SHIM_SYNC_SYNCGO);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800775unlock:
776 mutex_unlock(sdw->link_res->shim_lock);
777
Shreyas NC30246e22018-07-27 14:44:17 +0530778 if (ret < 0)
Pierre-Louis Bossart17ed5be2019-05-01 10:57:45 -0500779 dev_err(sdw->cdns.dev, "Post bank switch failed: %d\n", ret);
Shreyas NC30246e22018-07-27 14:44:17 +0530780
781 return ret;
782}
783
784/*
Vinod Koulc46302e2018-04-26 18:39:05 +0530785 * DAI routines
786 */
787
Rander Wang5e7484d2020-02-14 19:47:39 -0600788static int intel_startup(struct snd_pcm_substream *substream,
789 struct snd_soc_dai *dai)
790{
791 /*
792 * TODO: add pm_runtime support here, the startup callback
793 * will make sure the IP is 'active'
794 */
Pierre-Louis Bossartff16d1e2020-07-01 02:43:54 +0800795 return 0;
Rander Wang5e7484d2020-02-14 19:47:39 -0600796}
797
Vinod Koulc46302e2018-04-26 18:39:05 +0530798static int intel_hw_params(struct snd_pcm_substream *substream,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500799 struct snd_pcm_hw_params *params,
800 struct snd_soc_dai *dai)
Vinod Koulc46302e2018-04-26 18:39:05 +0530801{
802 struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
803 struct sdw_intel *sdw = cdns_to_intel(cdns);
804 struct sdw_cdns_dma_data *dma;
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500805 struct sdw_cdns_pdi *pdi;
Vinod Koulc46302e2018-04-26 18:39:05 +0530806 struct sdw_stream_config sconfig;
807 struct sdw_port_config *pconfig;
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500808 int ch, dir;
809 int ret;
Vinod Koulc46302e2018-04-26 18:39:05 +0530810 bool pcm = true;
811
812 dma = snd_soc_dai_get_dma_data(dai, substream);
813 if (!dma)
814 return -EIO;
815
816 ch = params_channels(params);
817 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
818 dir = SDW_DATA_DIR_RX;
819 else
820 dir = SDW_DATA_DIR_TX;
821
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500822 if (dma->stream_type == SDW_STREAM_PDM)
Vinod Koulc46302e2018-04-26 18:39:05 +0530823 pcm = false;
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500824
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500825 if (pcm)
Bard Liao1b53385e2019-09-16 14:23:48 -0500826 pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id);
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500827 else
Bard Liao1b53385e2019-09-16 14:23:48 -0500828 pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir, dai->id);
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500829
830 if (!pdi) {
831 ret = -EINVAL;
832 goto error;
Vinod Koulc46302e2018-04-26 18:39:05 +0530833 }
834
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500835 /* do run-time configurations for SHIM, ALH and PDI/PORT */
836 intel_pdi_shim_configure(sdw, pdi);
837 intel_pdi_alh_configure(sdw, pdi);
838 sdw_cdns_config_stream(cdns, ch, dir, pdi);
Vinod Koulc46302e2018-04-26 18:39:05 +0530839
Vinod Koulc46302e2018-04-26 18:39:05 +0530840
841 /* Inform DSP about PDI stream number */
Rander Wang4b206d32019-12-11 19:45:02 -0600842 ret = intel_params_stream(sdw, substream, dai, params,
843 sdw->instance,
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500844 pdi->intel_alh_id);
845 if (ret)
846 goto error;
Vinod Koulc46302e2018-04-26 18:39:05 +0530847
848 sconfig.direction = dir;
849 sconfig.ch_count = ch;
850 sconfig.frame_rate = params_rate(params);
851 sconfig.type = dma->stream_type;
852
853 if (dma->stream_type == SDW_STREAM_PDM) {
854 sconfig.frame_rate *= 50;
855 sconfig.bps = 1;
856 } else {
857 sconfig.bps = snd_pcm_format_width(params_format(params));
858 }
859
860 /* Port configuration */
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500861 pconfig = kcalloc(1, sizeof(*pconfig), GFP_KERNEL);
Vinod Koulc46302e2018-04-26 18:39:05 +0530862 if (!pconfig) {
863 ret = -ENOMEM;
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500864 goto error;
Vinod Koulc46302e2018-04-26 18:39:05 +0530865 }
866
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500867 pconfig->num = pdi->num;
868 pconfig->ch_mask = (1 << ch) - 1;
Vinod Koulc46302e2018-04-26 18:39:05 +0530869
870 ret = sdw_stream_add_master(&cdns->bus, &sconfig,
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500871 pconfig, 1, dma->stream);
872 if (ret)
Pierre-Louis Bossart17ed5be2019-05-01 10:57:45 -0500873 dev_err(cdns->dev, "add master to stream failed:%d\n", ret);
Vinod Koulc46302e2018-04-26 18:39:05 +0530874
875 kfree(pconfig);
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500876error:
Vinod Koulc46302e2018-04-26 18:39:05 +0530877 return ret;
878}
879
Rander Wang27b198f2020-02-14 19:47:37 -0600880static int intel_prepare(struct snd_pcm_substream *substream,
881 struct snd_soc_dai *dai)
882{
883 struct sdw_cdns_dma_data *dma;
884
885 dma = snd_soc_dai_get_dma_data(dai, substream);
886 if (!dma) {
887 dev_err(dai->dev, "failed to get dma data in %s",
888 __func__);
889 return -EIO;
890 }
891
892 return sdw_prepare_stream(dma->stream);
893}
894
Rander Wang973a8422020-02-14 19:47:38 -0600895static int intel_trigger(struct snd_pcm_substream *substream, int cmd,
896 struct snd_soc_dai *dai)
897{
898 struct sdw_cdns_dma_data *dma;
899 int ret;
900
901 dma = snd_soc_dai_get_dma_data(dai, substream);
902 if (!dma) {
903 dev_err(dai->dev, "failed to get dma data in %s", __func__);
904 return -EIO;
905 }
906
907 switch (cmd) {
908 case SNDRV_PCM_TRIGGER_START:
909 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
910 case SNDRV_PCM_TRIGGER_RESUME:
911 ret = sdw_enable_stream(dma->stream);
912 break;
913
914 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
915 case SNDRV_PCM_TRIGGER_SUSPEND:
916 case SNDRV_PCM_TRIGGER_STOP:
917 ret = sdw_disable_stream(dma->stream);
918 break;
919
920 default:
921 ret = -EINVAL;
922 break;
923 }
924
925 if (ret)
926 dev_err(dai->dev,
927 "%s trigger %d failed: %d",
928 __func__, cmd, ret);
929 return ret;
930}
931
Vinod Koulc46302e2018-04-26 18:39:05 +0530932static int
933intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
934{
935 struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600936 struct sdw_intel *sdw = cdns_to_intel(cdns);
Vinod Koulc46302e2018-04-26 18:39:05 +0530937 struct sdw_cdns_dma_data *dma;
938 int ret;
939
940 dma = snd_soc_dai_get_dma_data(dai, substream);
941 if (!dma)
942 return -EIO;
943
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600944 ret = sdw_deprepare_stream(dma->stream);
945 if (ret) {
946 dev_err(dai->dev, "sdw_deprepare_stream: failed %d", ret);
947 return ret;
948 }
949
Vinod Koulc46302e2018-04-26 18:39:05 +0530950 ret = sdw_stream_remove_master(&cdns->bus, dma->stream);
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600951 if (ret < 0) {
Pierre-Louis Bossart17ed5be2019-05-01 10:57:45 -0500952 dev_err(dai->dev, "remove master from stream %s failed: %d\n",
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500953 dma->stream->name, ret);
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600954 return ret;
955 }
Vinod Koulc46302e2018-04-26 18:39:05 +0530956
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600957 ret = intel_free_stream(sdw, substream, dai, sdw->instance);
958 if (ret < 0) {
959 dev_err(dai->dev, "intel_free_stream: failed %d", ret);
960 return ret;
961 }
962
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600963 return 0;
Vinod Koulc46302e2018-04-26 18:39:05 +0530964}
965
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -0500966static void intel_shutdown(struct snd_pcm_substream *substream,
967 struct snd_soc_dai *dai)
968{
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -0500969
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -0500970}
971
Vinod Koulc46302e2018-04-26 18:39:05 +0530972static int intel_pcm_set_sdw_stream(struct snd_soc_dai *dai,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500973 void *stream, int direction)
Vinod Koulc46302e2018-04-26 18:39:05 +0530974{
975 return cdns_set_sdw_stream(dai, stream, true, direction);
976}
977
978static int intel_pdm_set_sdw_stream(struct snd_soc_dai *dai,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500979 void *stream, int direction)
Vinod Koulc46302e2018-04-26 18:39:05 +0530980{
981 return cdns_set_sdw_stream(dai, stream, false, direction);
982}
983
Pierre-Louis Bossart09553142020-07-01 02:43:52 +0800984static void *intel_get_sdw_stream(struct snd_soc_dai *dai,
985 int direction)
986{
987 struct sdw_cdns_dma_data *dma;
988
989 if (direction == SNDRV_PCM_STREAM_PLAYBACK)
990 dma = dai->playback_dma_data;
991 else
992 dma = dai->capture_dma_data;
993
994 if (!dma)
995 return NULL;
996
997 return dma->stream;
998}
999
Julia Lawallb1635592018-10-27 15:34:42 +02001000static const struct snd_soc_dai_ops intel_pcm_dai_ops = {
Rander Wang5e7484d2020-02-14 19:47:39 -06001001 .startup = intel_startup,
Vinod Koulc46302e2018-04-26 18:39:05 +05301002 .hw_params = intel_hw_params,
Rander Wang27b198f2020-02-14 19:47:37 -06001003 .prepare = intel_prepare,
Rander Wang973a8422020-02-14 19:47:38 -06001004 .trigger = intel_trigger,
Vinod Koulc46302e2018-04-26 18:39:05 +05301005 .hw_free = intel_hw_free,
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -05001006 .shutdown = intel_shutdown,
Vinod Koulc46302e2018-04-26 18:39:05 +05301007 .set_sdw_stream = intel_pcm_set_sdw_stream,
Pierre-Louis Bossart09553142020-07-01 02:43:52 +08001008 .get_sdw_stream = intel_get_sdw_stream,
Vinod Koulc46302e2018-04-26 18:39:05 +05301009};
1010
Julia Lawallb1635592018-10-27 15:34:42 +02001011static const struct snd_soc_dai_ops intel_pdm_dai_ops = {
Rander Wang5e7484d2020-02-14 19:47:39 -06001012 .startup = intel_startup,
Vinod Koulc46302e2018-04-26 18:39:05 +05301013 .hw_params = intel_hw_params,
Rander Wang27b198f2020-02-14 19:47:37 -06001014 .prepare = intel_prepare,
Rander Wang973a8422020-02-14 19:47:38 -06001015 .trigger = intel_trigger,
Vinod Koulc46302e2018-04-26 18:39:05 +05301016 .hw_free = intel_hw_free,
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -05001017 .shutdown = intel_shutdown,
Vinod Koulc46302e2018-04-26 18:39:05 +05301018 .set_sdw_stream = intel_pdm_set_sdw_stream,
Pierre-Louis Bossart09553142020-07-01 02:43:52 +08001019 .get_sdw_stream = intel_get_sdw_stream,
Vinod Koulc46302e2018-04-26 18:39:05 +05301020};
1021
1022static const struct snd_soc_component_driver dai_component = {
1023 .name = "soundwire",
1024};
1025
1026static int intel_create_dai(struct sdw_cdns *cdns,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -05001027 struct snd_soc_dai_driver *dais,
1028 enum intel_pdi_type type,
1029 u32 num, u32 off, u32 max_ch, bool pcm)
Vinod Koulc46302e2018-04-26 18:39:05 +05301030{
1031 int i;
1032
1033 if (num == 0)
1034 return 0;
1035
1036 /* TODO: Read supported rates/formats from hardware */
1037 for (i = off; i < (off + num); i++) {
1038 dais[i].name = kasprintf(GFP_KERNEL, "SDW%d Pin%d",
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -05001039 cdns->instance, i);
Vinod Koulc46302e2018-04-26 18:39:05 +05301040 if (!dais[i].name)
1041 return -ENOMEM;
1042
1043 if (type == INTEL_PDI_BD || type == INTEL_PDI_OUT) {
Vinod Koulc46302e2018-04-26 18:39:05 +05301044 dais[i].playback.channels_min = 1;
1045 dais[i].playback.channels_max = max_ch;
1046 dais[i].playback.rates = SNDRV_PCM_RATE_48000;
1047 dais[i].playback.formats = SNDRV_PCM_FMTBIT_S16_LE;
1048 }
1049
1050 if (type == INTEL_PDI_BD || type == INTEL_PDI_IN) {
Srinivas Kandagatla39194122019-06-06 12:23:04 +01001051 dais[i].capture.channels_min = 1;
1052 dais[i].capture.channels_max = max_ch;
Vinod Koulc46302e2018-04-26 18:39:05 +05301053 dais[i].capture.rates = SNDRV_PCM_RATE_48000;
1054 dais[i].capture.formats = SNDRV_PCM_FMTBIT_S16_LE;
1055 }
1056
Vinod Koulc46302e2018-04-26 18:39:05 +05301057 if (pcm)
1058 dais[i].ops = &intel_pcm_dai_ops;
1059 else
1060 dais[i].ops = &intel_pdm_dai_ops;
1061 }
1062
1063 return 0;
1064}
1065
1066static int intel_register_dai(struct sdw_intel *sdw)
1067{
1068 struct sdw_cdns *cdns = &sdw->cdns;
1069 struct sdw_cdns_streams *stream;
1070 struct snd_soc_dai_driver *dais;
1071 int num_dai, ret, off = 0;
1072
1073 /* DAIs are created based on total number of PDIs supported */
1074 num_dai = cdns->pcm.num_pdi + cdns->pdm.num_pdi;
1075
1076 dais = devm_kcalloc(cdns->dev, num_dai, sizeof(*dais), GFP_KERNEL);
1077 if (!dais)
1078 return -ENOMEM;
1079
1080 /* Create PCM DAIs */
1081 stream = &cdns->pcm;
1082
Bard Liaocf924962019-09-16 14:23:43 -05001083 ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pcm.num_in,
Vinod Koul1215dae2019-05-02 16:29:25 +05301084 off, stream->num_ch_in, true);
Vinod Koulc46302e2018-04-26 18:39:05 +05301085 if (ret)
1086 return ret;
1087
1088 off += cdns->pcm.num_in;
Vinod Koul1215dae2019-05-02 16:29:25 +05301089 ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pcm.num_out,
1090 off, stream->num_ch_out, true);
Vinod Koulc46302e2018-04-26 18:39:05 +05301091 if (ret)
1092 return ret;
1093
1094 off += cdns->pcm.num_out;
Vinod Koul1215dae2019-05-02 16:29:25 +05301095 ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pcm.num_bd,
1096 off, stream->num_ch_bd, true);
Vinod Koulc46302e2018-04-26 18:39:05 +05301097 if (ret)
1098 return ret;
1099
1100 /* Create PDM DAIs */
1101 stream = &cdns->pdm;
1102 off += cdns->pcm.num_bd;
Vinod Koul1215dae2019-05-02 16:29:25 +05301103 ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pdm.num_in,
1104 off, stream->num_ch_in, false);
Vinod Koulc46302e2018-04-26 18:39:05 +05301105 if (ret)
1106 return ret;
1107
1108 off += cdns->pdm.num_in;
Vinod Koul1215dae2019-05-02 16:29:25 +05301109 ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pdm.num_out,
1110 off, stream->num_ch_out, false);
Vinod Koulc46302e2018-04-26 18:39:05 +05301111 if (ret)
1112 return ret;
1113
Bard Liaocf924962019-09-16 14:23:43 -05001114 off += cdns->pdm.num_out;
Vinod Koul1215dae2019-05-02 16:29:25 +05301115 ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pdm.num_bd,
1116 off, stream->num_ch_bd, false);
Vinod Koulc46302e2018-04-26 18:39:05 +05301117 if (ret)
1118 return ret;
1119
1120 return snd_soc_register_component(cdns->dev, &dai_component,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -05001121 dais, num_dai);
Vinod Koulc46302e2018-04-26 18:39:05 +05301122}
1123
Pierre-Louis Bossart085f4ac2019-08-05 19:55:16 -05001124static int sdw_master_read_intel_prop(struct sdw_bus *bus)
1125{
1126 struct sdw_master_prop *prop = &bus->prop;
1127 struct fwnode_handle *link;
1128 char name[32];
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001129 u32 quirk_mask;
Pierre-Louis Bossart085f4ac2019-08-05 19:55:16 -05001130
1131 /* Find master handle */
1132 snprintf(name, sizeof(name),
1133 "mipi-sdw-link-%d-subproperties", bus->link_id);
1134
1135 link = device_get_named_child_node(bus->dev, name);
1136 if (!link) {
1137 dev_err(bus->dev, "Master node %s not found\n", name);
1138 return -EIO;
1139 }
1140
1141 fwnode_property_read_u32(link,
1142 "intel-sdw-ip-clock",
1143 &prop->mclk_freq);
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001144
Bard Liaoa19efb52020-01-13 17:11:29 -06001145 /* the values reported by BIOS are the 2x clock, not the bus clock */
1146 prop->mclk_freq /= 2;
1147
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001148 fwnode_property_read_u32(link,
1149 "intel-quirk-mask",
1150 &quirk_mask);
1151
1152 if (quirk_mask & SDW_INTEL_QUIRK_MASK_BUS_DISABLE)
1153 prop->hw_disabled = true;
1154
Pierre-Louis Bossart085f4ac2019-08-05 19:55:16 -05001155 return 0;
1156}
1157
Vinod Koul71bb8a12017-12-14 11:19:43 +05301158static int intel_prop_read(struct sdw_bus *bus)
1159{
1160 /* Initialize with default handler to read all DisCo properties */
1161 sdw_master_read_prop(bus);
1162
Pierre-Louis Bossart085f4ac2019-08-05 19:55:16 -05001163 /* read Intel-specific properties */
1164 sdw_master_read_intel_prop(bus);
1165
Vinod Koul71bb8a12017-12-14 11:19:43 +05301166 return 0;
1167}
1168
Shreyas NCc91605f2018-04-26 18:38:43 +05301169static struct sdw_master_ops sdw_intel_ops = {
1170 .read_prop = sdw_master_read_prop,
1171 .xfer_msg = cdns_xfer_msg,
1172 .xfer_msg_defer = cdns_xfer_msg_defer,
1173 .reset_page_addr = cdns_reset_page_addr,
Vinod Koul07abeff2018-04-26 18:38:48 +05301174 .set_bus_conf = cdns_bus_conf,
Shreyas NC30246e22018-07-27 14:44:17 +05301175 .pre_bank_switch = intel_pre_bank_switch,
1176 .post_bank_switch = intel_post_bank_switch,
Shreyas NCc91605f2018-04-26 18:38:43 +05301177};
1178
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001179static int intel_init(struct sdw_intel *sdw)
1180{
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +08001181 bool clock_stop;
1182
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001183 /* Initialize shim and controller */
1184 intel_link_power_up(sdw);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +08001185
1186 clock_stop = sdw_cdns_is_clock_stop(&sdw->cdns);
1187
1188 intel_shim_init(sdw, clock_stop);
1189
1190 if (clock_stop)
1191 return 0;
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001192
Rander Wang7b174f22020-03-17 11:33:14 -05001193 return sdw_cdns_init(&sdw->cdns);
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001194}
1195
Vinod Koul71bb8a12017-12-14 11:19:43 +05301196/*
1197 * probe and init
1198 */
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001199static int intel_master_probe(struct platform_device *pdev)
Vinod Koul71bb8a12017-12-14 11:19:43 +05301200{
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001201 struct device *dev = &pdev->dev;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301202 struct sdw_intel *sdw;
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001203 struct sdw_cdns *cdns;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001204 struct sdw_bus *bus;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301205 int ret;
1206
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001207 sdw = devm_kzalloc(dev, sizeof(*sdw), GFP_KERNEL);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301208 if (!sdw)
1209 return -ENOMEM;
1210
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001211 cdns = &sdw->cdns;
1212 bus = &cdns->bus;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001213
Vinod Koul71bb8a12017-12-14 11:19:43 +05301214 sdw->instance = pdev->id;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001215 sdw->link_res = dev_get_platdata(dev);
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001216 cdns->dev = dev;
1217 cdns->registers = sdw->link_res->registers;
1218 cdns->instance = sdw->instance;
1219 cdns->msg_count = 0;
1220
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001221 bus->link_id = pdev->id;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301222
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001223 sdw_cdns_probe(cdns);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301224
1225 /* Set property read ops */
Shreyas NCc91605f2018-04-26 18:38:43 +05301226 sdw_intel_ops.read_prop = intel_prop_read;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001227 bus->ops = &sdw_intel_ops;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301228
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001229 /* set driver data, accessed by snd_soc_dai_get_drvdata() */
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001230 dev_set_drvdata(dev, cdns);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301231
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001232 ret = sdw_bus_master_add(bus, dev, dev->fwnode);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301233 if (ret) {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001234 dev_err(dev, "sdw_bus_master_add fail: %d\n", ret);
Pierre-Louis Bossart9e3d47f2019-10-22 18:54:47 -05001235 return ret;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301236 }
1237
Pierre-Louis Bossart6d2c6662020-06-01 02:21:02 +08001238 if (bus->prop.hw_disabled)
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001239 dev_info(dev,
1240 "SoundWire master %d is disabled, will be ignored\n",
1241 bus->link_id);
Pierre-Louis Bossart6d2c6662020-06-01 02:21:02 +08001242
1243 /* Acquire IRQ */
1244 ret = request_threaded_irq(sdw->link_res->irq,
1245 sdw_cdns_irq, sdw_cdns_thread,
1246 IRQF_SHARED, KBUILD_MODNAME, cdns);
1247 if (ret < 0) {
1248 dev_err(dev, "unable to grab IRQ %d, disabling device\n",
1249 sdw->link_res->irq);
1250 goto err_init;
1251 }
1252
1253 return 0;
1254
1255err_init:
1256 sdw_bus_master_delete(bus);
1257 return ret;
1258}
1259
1260int intel_master_startup(struct platform_device *pdev)
1261{
1262 struct sdw_cdns_stream_config config;
1263 struct device *dev = &pdev->dev;
1264 struct sdw_cdns *cdns = dev_get_drvdata(dev);
1265 struct sdw_intel *sdw = cdns_to_intel(cdns);
1266 struct sdw_bus *bus = &cdns->bus;
1267 int ret;
1268
1269 if (bus->prop.hw_disabled) {
1270 dev_info(dev,
1271 "SoundWire master %d is disabled, ignoring\n",
1272 sdw->instance);
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001273 return 0;
1274 }
1275
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001276 /* Initialize shim, controller and Cadence IP */
1277 ret = intel_init(sdw);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301278 if (ret)
1279 goto err_init;
1280
Vinod Koul37a2d222018-04-26 18:38:58 +05301281 /* Read the PDI config and initialize cadence PDI */
1282 intel_pdi_init(sdw, &config);
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001283 ret = sdw_cdns_pdi_init(cdns, config);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301284 if (ret)
1285 goto err_init;
1286
Vinod Koul37a2d222018-04-26 18:38:58 +05301287 intel_pdi_ch_update(sdw);
1288
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001289 ret = sdw_cdns_enable_interrupt(cdns, true);
Pierre-Louis Bossart49ea07d2019-10-22 18:54:44 -05001290 if (ret < 0) {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001291 dev_err(dev, "cannot enable interrupts\n");
Pierre-Louis Bossart49ea07d2019-10-22 18:54:44 -05001292 goto err_init;
1293 }
1294
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001295 ret = sdw_cdns_exit_reset(cdns);
Pierre-Louis Bossart49ea07d2019-10-22 18:54:44 -05001296 if (ret < 0) {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001297 dev_err(dev, "unable to exit bus reset sequence\n");
Pierre-Louis Bossart9e3d47f2019-10-22 18:54:47 -05001298 goto err_interrupt;
Pierre-Louis Bossart49ea07d2019-10-22 18:54:44 -05001299 }
1300
Vinod Koulc46302e2018-04-26 18:39:05 +05301301 /* Register DAIs */
1302 ret = intel_register_dai(sdw);
1303 if (ret) {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001304 dev_err(dev, "DAI registration failed: %d\n", ret);
1305 snd_soc_unregister_component(dev);
Pierre-Louis Bossart9e3d47f2019-10-22 18:54:47 -05001306 goto err_interrupt;
Vinod Koulc46302e2018-04-26 18:39:05 +05301307 }
1308
Pierre-Louis Bossart79ee6632019-08-21 13:58:20 -05001309 intel_debugfs_init(sdw);
1310
Vinod Koul71bb8a12017-12-14 11:19:43 +05301311 return 0;
1312
Pierre-Louis Bossart9e3d47f2019-10-22 18:54:47 -05001313err_interrupt:
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001314 sdw_cdns_enable_interrupt(cdns, false);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301315err_init:
Vinod Koul71bb8a12017-12-14 11:19:43 +05301316 return ret;
1317}
1318
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001319static int intel_master_remove(struct platform_device *pdev)
Vinod Koul71bb8a12017-12-14 11:19:43 +05301320{
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001321 struct device *dev = &pdev->dev;
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001322 struct sdw_cdns *cdns = dev_get_drvdata(dev);
1323 struct sdw_intel *sdw = cdns_to_intel(cdns);
1324 struct sdw_bus *bus = &cdns->bus;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001325
1326 if (!bus->prop.hw_disabled) {
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001327 intel_debugfs_exit(sdw);
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001328 sdw_cdns_enable_interrupt(cdns, false);
Pierre-Louis Bossart25234862020-02-14 19:47:36 -06001329 free_irq(sdw->link_res->irq, sdw);
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001330 snd_soc_unregister_component(dev);
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001331 }
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001332 sdw_bus_master_delete(bus);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301333
1334 return 0;
1335}
1336
1337static struct platform_driver sdw_intel_drv = {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001338 .probe = intel_master_probe,
1339 .remove = intel_master_remove,
Vinod Koul71bb8a12017-12-14 11:19:43 +05301340 .driver = {
Pierre-Louis Bossart6d2c6662020-06-01 02:21:02 +08001341 .name = "intel-sdw",
Vinod Koul71bb8a12017-12-14 11:19:43 +05301342 },
1343};
1344
1345module_platform_driver(sdw_intel_drv);
1346
1347MODULE_LICENSE("Dual BSD/GPL");
Pierre-Louis Bossart6d2c6662020-06-01 02:21:02 +08001348MODULE_ALIAS("platform:intel-sdw");
Vinod Koul71bb8a12017-12-14 11:19:43 +05301349MODULE_DESCRIPTION("Intel Soundwire Master Driver");