blob: 4792613e8e5a4773d96c5b9f5f525ab47b2f5af4 [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
Vinod Koul37a2d222018-04-26 18:38:58 +0530500/*
501 * PDI routines
502 */
503static void intel_pdi_init(struct sdw_intel *sdw,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500504 struct sdw_cdns_stream_config *config)
Vinod Koul37a2d222018-04-26 18:38:58 +0530505{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600506 void __iomem *shim = sdw->link_res->shim;
Vinod Koul37a2d222018-04-26 18:38:58 +0530507 unsigned int link_id = sdw->instance;
508 int pcm_cap, pdm_cap;
509
510 /* PCM Stream Capability */
511 pcm_cap = intel_readw(shim, SDW_SHIM_PCMSCAP(link_id));
512
513 config->pcm_bd = (pcm_cap & SDW_SHIM_PCMSCAP_BSS) >>
514 SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_BSS);
515 config->pcm_in = (pcm_cap & SDW_SHIM_PCMSCAP_ISS) >>
516 SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_ISS);
517 config->pcm_out = (pcm_cap & SDW_SHIM_PCMSCAP_OSS) >>
518 SDW_REG_SHIFT(SDW_SHIM_PCMSCAP_OSS);
519
Pierre-Louis Bossart121f4362019-05-22 14:47:29 -0500520 dev_dbg(sdw->cdns.dev, "PCM cap bd:%d in:%d out:%d\n",
521 config->pcm_bd, config->pcm_in, config->pcm_out);
522
Vinod Koul37a2d222018-04-26 18:38:58 +0530523 /* PDM Stream Capability */
524 pdm_cap = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id));
525
526 config->pdm_bd = (pdm_cap & SDW_SHIM_PDMSCAP_BSS) >>
527 SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_BSS);
528 config->pdm_in = (pdm_cap & SDW_SHIM_PDMSCAP_ISS) >>
529 SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_ISS);
530 config->pdm_out = (pdm_cap & SDW_SHIM_PDMSCAP_OSS) >>
531 SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_OSS);
Pierre-Louis Bossart121f4362019-05-22 14:47:29 -0500532
533 dev_dbg(sdw->cdns.dev, "PDM cap bd:%d in:%d out:%d\n",
534 config->pdm_bd, config->pdm_in, config->pdm_out);
Vinod Koul37a2d222018-04-26 18:38:58 +0530535}
536
537static int
538intel_pdi_get_ch_cap(struct sdw_intel *sdw, unsigned int pdi_num, bool pcm)
539{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600540 void __iomem *shim = sdw->link_res->shim;
Vinod Koul37a2d222018-04-26 18:38:58 +0530541 unsigned int link_id = sdw->instance;
542 int count;
543
544 if (pcm) {
545 count = intel_readw(shim, SDW_SHIM_PCMSYCHC(link_id, pdi_num));
Pierre-Louis Bossart18046332019-08-05 19:55:07 -0500546
547 /*
548 * WORKAROUND: on all existing Intel controllers, pdi
549 * number 2 reports channel count as 1 even though it
550 * supports 8 channels. Performing hardcoding for pdi
551 * number 2.
552 */
553 if (pdi_num == 2)
554 count = 7;
555
Vinod Koul37a2d222018-04-26 18:38:58 +0530556 } else {
557 count = intel_readw(shim, SDW_SHIM_PDMSCAP(link_id));
558 count = ((count & SDW_SHIM_PDMSCAP_CPSS) >>
559 SDW_REG_SHIFT(SDW_SHIM_PDMSCAP_CPSS));
560 }
561
562 /* zero based values for channel count in register */
563 count++;
564
565 return count;
566}
567
568static int intel_pdi_get_ch_update(struct sdw_intel *sdw,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500569 struct sdw_cdns_pdi *pdi,
570 unsigned int num_pdi,
571 unsigned int *num_ch, bool pcm)
Vinod Koul37a2d222018-04-26 18:38:58 +0530572{
573 int i, ch_count = 0;
574
575 for (i = 0; i < num_pdi; i++) {
576 pdi->ch_count = intel_pdi_get_ch_cap(sdw, pdi->num, pcm);
577 ch_count += pdi->ch_count;
578 pdi++;
579 }
580
581 *num_ch = ch_count;
582 return 0;
583}
584
585static int intel_pdi_stream_ch_update(struct sdw_intel *sdw,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500586 struct sdw_cdns_streams *stream, bool pcm)
Vinod Koul37a2d222018-04-26 18:38:58 +0530587{
588 intel_pdi_get_ch_update(sdw, stream->bd, stream->num_bd,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500589 &stream->num_ch_bd, pcm);
Vinod Koul37a2d222018-04-26 18:38:58 +0530590
591 intel_pdi_get_ch_update(sdw, stream->in, stream->num_in,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500592 &stream->num_ch_in, pcm);
Vinod Koul37a2d222018-04-26 18:38:58 +0530593
594 intel_pdi_get_ch_update(sdw, stream->out, stream->num_out,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500595 &stream->num_ch_out, pcm);
Vinod Koul37a2d222018-04-26 18:38:58 +0530596
597 return 0;
598}
599
600static int intel_pdi_ch_update(struct sdw_intel *sdw)
601{
602 /* First update PCM streams followed by PDM streams */
603 intel_pdi_stream_ch_update(sdw, &sdw->cdns.pcm, true);
604 intel_pdi_stream_ch_update(sdw, &sdw->cdns.pdm, false);
605
606 return 0;
607}
608
609static void
610intel_pdi_shim_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)
611{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600612 void __iomem *shim = sdw->link_res->shim;
Vinod Koul37a2d222018-04-26 18:38:58 +0530613 unsigned int link_id = sdw->instance;
614 int pdi_conf = 0;
615
Pierre-Louis Bossartc134f912019-10-22 18:29:48 -0500616 /* the Bulk and PCM streams are not contiguous */
617 pdi->intel_alh_id = (link_id * 16) + pdi->num + 3;
618 if (pdi->num >= 2)
619 pdi->intel_alh_id += 2;
Vinod Koul37a2d222018-04-26 18:38:58 +0530620
621 /*
622 * Program stream parameters to stream SHIM register
623 * This is applicable for PCM stream only.
624 */
625 if (pdi->type != SDW_STREAM_PCM)
626 return;
627
628 if (pdi->dir == SDW_DATA_DIR_RX)
629 pdi_conf |= SDW_SHIM_PCMSYCM_DIR;
630 else
631 pdi_conf &= ~(SDW_SHIM_PCMSYCM_DIR);
632
633 pdi_conf |= (pdi->intel_alh_id <<
634 SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_STREAM));
635 pdi_conf |= (pdi->l_ch_num << SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_LCHN));
636 pdi_conf |= (pdi->h_ch_num << SDW_REG_SHIFT(SDW_SHIM_PCMSYCM_HCHN));
637
638 intel_writew(shim, SDW_SHIM_PCMSYCHM(link_id, pdi->num), pdi_conf);
639}
640
641static void
642intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)
643{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600644 void __iomem *alh = sdw->link_res->alh;
Vinod Koul37a2d222018-04-26 18:38:58 +0530645 unsigned int link_id = sdw->instance;
646 unsigned int conf;
647
Pierre-Louis Bossartc134f912019-10-22 18:29:48 -0500648 /* the Bulk and PCM streams are not contiguous */
649 pdi->intel_alh_id = (link_id * 16) + pdi->num + 3;
650 if (pdi->num >= 2)
651 pdi->intel_alh_id += 2;
Vinod Koul37a2d222018-04-26 18:38:58 +0530652
653 /* Program Stream config ALH register */
654 conf = intel_readl(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id));
655
656 conf |= (SDW_ALH_STRMZCFG_DMAT_VAL <<
657 SDW_REG_SHIFT(SDW_ALH_STRMZCFG_DMAT));
658
659 conf |= ((pdi->ch_count - 1) <<
660 SDW_REG_SHIFT(SDW_ALH_STRMZCFG_CHN));
661
662 intel_writel(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id), conf);
663}
664
Rander Wang4b206d32019-12-11 19:45:02 -0600665static int intel_params_stream(struct sdw_intel *sdw,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500666 struct snd_pcm_substream *substream,
667 struct snd_soc_dai *dai,
Rander Wang4b206d32019-12-11 19:45:02 -0600668 struct snd_pcm_hw_params *hw_params,
669 int link_id, int alh_stream_id)
Vinod Koulc46302e2018-04-26 18:39:05 +0530670{
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600671 struct sdw_intel_link_res *res = sdw->link_res;
Rander Wang4b206d32019-12-11 19:45:02 -0600672 struct sdw_intel_stream_params_data params_data;
Pierre-Louis Bossart05c8afe42019-08-05 19:55:06 -0500673
Rander Wang4b206d32019-12-11 19:45:02 -0600674 params_data.substream = substream;
675 params_data.dai = dai;
676 params_data.hw_params = hw_params;
677 params_data.link_id = link_id;
678 params_data.alh_stream_id = alh_stream_id;
Vinod Koulc46302e2018-04-26 18:39:05 +0530679
Rander Wang4b206d32019-12-11 19:45:02 -0600680 if (res->ops && res->ops->params_stream && res->dev)
681 return res->ops->params_stream(res->dev,
682 &params_data);
Vinod Koulc46302e2018-04-26 18:39:05 +0530683 return -EIO;
684}
685
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600686static int intel_free_stream(struct sdw_intel *sdw,
687 struct snd_pcm_substream *substream,
688 struct snd_soc_dai *dai,
689 int link_id)
690{
691 struct sdw_intel_link_res *res = sdw->link_res;
692 struct sdw_intel_stream_free_data free_data;
693
694 free_data.substream = substream;
695 free_data.dai = dai;
696 free_data.link_id = link_id;
697
698 if (res->ops && res->ops->free_stream && res->dev)
699 return res->ops->free_stream(res->dev,
700 &free_data);
701
702 return 0;
703}
704
Vinod Koulc46302e2018-04-26 18:39:05 +0530705/*
Shreyas NC30246e22018-07-27 14:44:17 +0530706 * bank switch routines
707 */
708
709static int intel_pre_bank_switch(struct sdw_bus *bus)
710{
711 struct sdw_cdns *cdns = bus_to_cdns(bus);
712 struct sdw_intel *sdw = cdns_to_intel(cdns);
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600713 void __iomem *shim = sdw->link_res->shim;
Shreyas NC30246e22018-07-27 14:44:17 +0530714 int sync_reg;
715
716 /* Write to register only for multi-link */
717 if (!bus->multi_link)
718 return 0;
719
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800720 mutex_lock(sdw->link_res->shim_lock);
721
Shreyas NC30246e22018-07-27 14:44:17 +0530722 /* Read SYNC register */
723 sync_reg = intel_readl(shim, SDW_SHIM_SYNC);
724 sync_reg |= SDW_SHIM_SYNC_CMDSYNC << sdw->instance;
725 intel_writel(shim, SDW_SHIM_SYNC, sync_reg);
726
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800727 mutex_unlock(sdw->link_res->shim_lock);
728
Shreyas NC30246e22018-07-27 14:44:17 +0530729 return 0;
730}
731
732static int intel_post_bank_switch(struct sdw_bus *bus)
733{
734 struct sdw_cdns *cdns = bus_to_cdns(bus);
735 struct sdw_intel *sdw = cdns_to_intel(cdns);
Pierre-Louis Bossart25234862020-02-14 19:47:36 -0600736 void __iomem *shim = sdw->link_res->shim;
Shreyas NC30246e22018-07-27 14:44:17 +0530737 int sync_reg, ret;
738
739 /* Write to register only for multi-link */
740 if (!bus->multi_link)
741 return 0;
742
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800743 mutex_lock(sdw->link_res->shim_lock);
744
Shreyas NC30246e22018-07-27 14:44:17 +0530745 /* Read SYNC register */
746 sync_reg = intel_readl(shim, SDW_SHIM_SYNC);
747
748 /*
749 * post_bank_switch() ops is called from the bus in loop for
750 * all the Masters in the steam with the expectation that
751 * we trigger the bankswitch for the only first Master in the list
752 * and do nothing for the other Masters
753 *
754 * So, set the SYNCGO bit only if CMDSYNC bit is set for any Master.
755 */
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800756 if (!(sync_reg & SDW_SHIM_SYNC_CMDSYNC_MASK)) {
757 ret = 0;
758 goto unlock;
759 }
Shreyas NC30246e22018-07-27 14:44:17 +0530760 /*
761 * Set SyncGO bit to synchronously trigger a bank switch for
762 * all the masters. A write to SYNCGO bit clears CMDSYNC bit for all
763 * the Masters.
764 */
765 sync_reg |= SDW_SHIM_SYNC_SYNCGO;
766
767 ret = intel_clear_bit(shim, SDW_SHIM_SYNC, sync_reg,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500768 SDW_SHIM_SYNC_SYNCGO);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +0800769unlock:
770 mutex_unlock(sdw->link_res->shim_lock);
771
Shreyas NC30246e22018-07-27 14:44:17 +0530772 if (ret < 0)
Pierre-Louis Bossart17ed5be2019-05-01 10:57:45 -0500773 dev_err(sdw->cdns.dev, "Post bank switch failed: %d\n", ret);
Shreyas NC30246e22018-07-27 14:44:17 +0530774
775 return ret;
776}
777
778/*
Vinod Koulc46302e2018-04-26 18:39:05 +0530779 * DAI routines
780 */
781
Rander Wang5e7484d2020-02-14 19:47:39 -0600782static int intel_startup(struct snd_pcm_substream *substream,
783 struct snd_soc_dai *dai)
784{
785 /*
786 * TODO: add pm_runtime support here, the startup callback
787 * will make sure the IP is 'active'
788 */
Pierre-Louis Bossartff16d1e2020-07-01 02:43:54 +0800789 return 0;
Rander Wang5e7484d2020-02-14 19:47:39 -0600790}
791
Vinod Koulc46302e2018-04-26 18:39:05 +0530792static int intel_hw_params(struct snd_pcm_substream *substream,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500793 struct snd_pcm_hw_params *params,
794 struct snd_soc_dai *dai)
Vinod Koulc46302e2018-04-26 18:39:05 +0530795{
796 struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
797 struct sdw_intel *sdw = cdns_to_intel(cdns);
798 struct sdw_cdns_dma_data *dma;
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500799 struct sdw_cdns_pdi *pdi;
Vinod Koulc46302e2018-04-26 18:39:05 +0530800 struct sdw_stream_config sconfig;
801 struct sdw_port_config *pconfig;
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500802 int ch, dir;
803 int ret;
Vinod Koulc46302e2018-04-26 18:39:05 +0530804 bool pcm = true;
805
806 dma = snd_soc_dai_get_dma_data(dai, substream);
807 if (!dma)
808 return -EIO;
809
810 ch = params_channels(params);
811 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
812 dir = SDW_DATA_DIR_RX;
813 else
814 dir = SDW_DATA_DIR_TX;
815
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500816 if (dma->stream_type == SDW_STREAM_PDM)
Vinod Koulc46302e2018-04-26 18:39:05 +0530817 pcm = false;
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500818
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500819 if (pcm)
Bard Liao1b53385e2019-09-16 14:23:48 -0500820 pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id);
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500821 else
Bard Liao1b53385e2019-09-16 14:23:48 -0500822 pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir, dai->id);
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500823
824 if (!pdi) {
825 ret = -EINVAL;
826 goto error;
Vinod Koulc46302e2018-04-26 18:39:05 +0530827 }
828
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500829 /* do run-time configurations for SHIM, ALH and PDI/PORT */
830 intel_pdi_shim_configure(sdw, pdi);
831 intel_pdi_alh_configure(sdw, pdi);
832 sdw_cdns_config_stream(cdns, ch, dir, pdi);
Vinod Koulc46302e2018-04-26 18:39:05 +0530833
Vinod Koulc46302e2018-04-26 18:39:05 +0530834
835 /* Inform DSP about PDI stream number */
Rander Wang4b206d32019-12-11 19:45:02 -0600836 ret = intel_params_stream(sdw, substream, dai, params,
837 sdw->instance,
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500838 pdi->intel_alh_id);
839 if (ret)
840 goto error;
Vinod Koulc46302e2018-04-26 18:39:05 +0530841
842 sconfig.direction = dir;
843 sconfig.ch_count = ch;
844 sconfig.frame_rate = params_rate(params);
845 sconfig.type = dma->stream_type;
846
847 if (dma->stream_type == SDW_STREAM_PDM) {
848 sconfig.frame_rate *= 50;
849 sconfig.bps = 1;
850 } else {
851 sconfig.bps = snd_pcm_format_width(params_format(params));
852 }
853
854 /* Port configuration */
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500855 pconfig = kcalloc(1, sizeof(*pconfig), GFP_KERNEL);
Vinod Koulc46302e2018-04-26 18:39:05 +0530856 if (!pconfig) {
857 ret = -ENOMEM;
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500858 goto error;
Vinod Koulc46302e2018-04-26 18:39:05 +0530859 }
860
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500861 pconfig->num = pdi->num;
862 pconfig->ch_mask = (1 << ch) - 1;
Vinod Koulc46302e2018-04-26 18:39:05 +0530863
864 ret = sdw_stream_add_master(&cdns->bus, &sconfig,
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500865 pconfig, 1, dma->stream);
866 if (ret)
Pierre-Louis Bossart17ed5be2019-05-01 10:57:45 -0500867 dev_err(cdns->dev, "add master to stream failed:%d\n", ret);
Vinod Koulc46302e2018-04-26 18:39:05 +0530868
869 kfree(pconfig);
Pierre-Louis Bossart57a34792019-09-16 14:23:46 -0500870error:
Vinod Koulc46302e2018-04-26 18:39:05 +0530871 return ret;
872}
873
Rander Wang27b198f2020-02-14 19:47:37 -0600874static int intel_prepare(struct snd_pcm_substream *substream,
875 struct snd_soc_dai *dai)
876{
877 struct sdw_cdns_dma_data *dma;
878
879 dma = snd_soc_dai_get_dma_data(dai, substream);
880 if (!dma) {
881 dev_err(dai->dev, "failed to get dma data in %s",
882 __func__);
883 return -EIO;
884 }
885
886 return sdw_prepare_stream(dma->stream);
887}
888
Rander Wang973a8422020-02-14 19:47:38 -0600889static int intel_trigger(struct snd_pcm_substream *substream, int cmd,
890 struct snd_soc_dai *dai)
891{
892 struct sdw_cdns_dma_data *dma;
893 int ret;
894
895 dma = snd_soc_dai_get_dma_data(dai, substream);
896 if (!dma) {
897 dev_err(dai->dev, "failed to get dma data in %s", __func__);
898 return -EIO;
899 }
900
901 switch (cmd) {
902 case SNDRV_PCM_TRIGGER_START:
903 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
904 case SNDRV_PCM_TRIGGER_RESUME:
905 ret = sdw_enable_stream(dma->stream);
906 break;
907
908 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
909 case SNDRV_PCM_TRIGGER_SUSPEND:
910 case SNDRV_PCM_TRIGGER_STOP:
911 ret = sdw_disable_stream(dma->stream);
912 break;
913
914 default:
915 ret = -EINVAL;
916 break;
917 }
918
919 if (ret)
920 dev_err(dai->dev,
921 "%s trigger %d failed: %d",
922 __func__, cmd, ret);
923 return ret;
924}
925
Vinod Koulc46302e2018-04-26 18:39:05 +0530926static int
927intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
928{
929 struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600930 struct sdw_intel *sdw = cdns_to_intel(cdns);
Vinod Koulc46302e2018-04-26 18:39:05 +0530931 struct sdw_cdns_dma_data *dma;
932 int ret;
933
934 dma = snd_soc_dai_get_dma_data(dai, substream);
935 if (!dma)
936 return -EIO;
937
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600938 ret = sdw_deprepare_stream(dma->stream);
939 if (ret) {
940 dev_err(dai->dev, "sdw_deprepare_stream: failed %d", ret);
941 return ret;
942 }
943
Vinod Koulc46302e2018-04-26 18:39:05 +0530944 ret = sdw_stream_remove_master(&cdns->bus, dma->stream);
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600945 if (ret < 0) {
Pierre-Louis Bossart17ed5be2019-05-01 10:57:45 -0500946 dev_err(dai->dev, "remove master from stream %s failed: %d\n",
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500947 dma->stream->name, ret);
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600948 return ret;
949 }
Vinod Koulc46302e2018-04-26 18:39:05 +0530950
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600951 ret = intel_free_stream(sdw, substream, dai, sdw->instance);
952 if (ret < 0) {
953 dev_err(dai->dev, "intel_free_stream: failed %d", ret);
954 return ret;
955 }
956
Pierre-Louis Bossarteff346f2020-02-14 19:47:40 -0600957 return 0;
Vinod Koulc46302e2018-04-26 18:39:05 +0530958}
959
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -0500960static void intel_shutdown(struct snd_pcm_substream *substream,
961 struct snd_soc_dai *dai)
962{
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -0500963
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -0500964}
965
Vinod Koulc46302e2018-04-26 18:39:05 +0530966static int intel_pcm_set_sdw_stream(struct snd_soc_dai *dai,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -0500967 void *stream, int direction)
Vinod Koulc46302e2018-04-26 18:39:05 +0530968{
969 return cdns_set_sdw_stream(dai, stream, true, direction);
970}
971
972static int intel_pdm_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, false, direction);
976}
977
Pierre-Louis Bossart09553142020-07-01 02:43:52 +0800978static void *intel_get_sdw_stream(struct snd_soc_dai *dai,
979 int direction)
980{
981 struct sdw_cdns_dma_data *dma;
982
983 if (direction == SNDRV_PCM_STREAM_PLAYBACK)
984 dma = dai->playback_dma_data;
985 else
986 dma = dai->capture_dma_data;
987
988 if (!dma)
989 return NULL;
990
991 return dma->stream;
992}
993
Julia Lawallb1635592018-10-27 15:34:42 +0200994static const struct snd_soc_dai_ops intel_pcm_dai_ops = {
Rander Wang5e7484d2020-02-14 19:47:39 -0600995 .startup = intel_startup,
Vinod Koulc46302e2018-04-26 18:39:05 +0530996 .hw_params = intel_hw_params,
Rander Wang27b198f2020-02-14 19:47:37 -0600997 .prepare = intel_prepare,
Rander Wang973a8422020-02-14 19:47:38 -0600998 .trigger = intel_trigger,
Vinod Koulc46302e2018-04-26 18:39:05 +0530999 .hw_free = intel_hw_free,
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -05001000 .shutdown = intel_shutdown,
Vinod Koulc46302e2018-04-26 18:39:05 +05301001 .set_sdw_stream = intel_pcm_set_sdw_stream,
Pierre-Louis Bossart09553142020-07-01 02:43:52 +08001002 .get_sdw_stream = intel_get_sdw_stream,
Vinod Koulc46302e2018-04-26 18:39:05 +05301003};
1004
Julia Lawallb1635592018-10-27 15:34:42 +02001005static const struct snd_soc_dai_ops intel_pdm_dai_ops = {
Rander Wang5e7484d2020-02-14 19:47:39 -06001006 .startup = intel_startup,
Vinod Koulc46302e2018-04-26 18:39:05 +05301007 .hw_params = intel_hw_params,
Rander Wang27b198f2020-02-14 19:47:37 -06001008 .prepare = intel_prepare,
Rander Wang973a8422020-02-14 19:47:38 -06001009 .trigger = intel_trigger,
Vinod Koulc46302e2018-04-26 18:39:05 +05301010 .hw_free = intel_hw_free,
Pierre-Louis Bossart183c7682019-08-05 19:55:22 -05001011 .shutdown = intel_shutdown,
Vinod Koulc46302e2018-04-26 18:39:05 +05301012 .set_sdw_stream = intel_pdm_set_sdw_stream,
Pierre-Louis Bossart09553142020-07-01 02:43:52 +08001013 .get_sdw_stream = intel_get_sdw_stream,
Vinod Koulc46302e2018-04-26 18:39:05 +05301014};
1015
1016static const struct snd_soc_component_driver dai_component = {
1017 .name = "soundwire",
1018};
1019
1020static int intel_create_dai(struct sdw_cdns *cdns,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -05001021 struct snd_soc_dai_driver *dais,
1022 enum intel_pdi_type type,
1023 u32 num, u32 off, u32 max_ch, bool pcm)
Vinod Koulc46302e2018-04-26 18:39:05 +05301024{
1025 int i;
1026
1027 if (num == 0)
1028 return 0;
1029
1030 /* TODO: Read supported rates/formats from hardware */
1031 for (i = off; i < (off + num); i++) {
1032 dais[i].name = kasprintf(GFP_KERNEL, "SDW%d Pin%d",
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -05001033 cdns->instance, i);
Vinod Koulc46302e2018-04-26 18:39:05 +05301034 if (!dais[i].name)
1035 return -ENOMEM;
1036
1037 if (type == INTEL_PDI_BD || type == INTEL_PDI_OUT) {
Vinod Koulc46302e2018-04-26 18:39:05 +05301038 dais[i].playback.channels_min = 1;
1039 dais[i].playback.channels_max = max_ch;
1040 dais[i].playback.rates = SNDRV_PCM_RATE_48000;
1041 dais[i].playback.formats = SNDRV_PCM_FMTBIT_S16_LE;
1042 }
1043
1044 if (type == INTEL_PDI_BD || type == INTEL_PDI_IN) {
Srinivas Kandagatla39194122019-06-06 12:23:04 +01001045 dais[i].capture.channels_min = 1;
1046 dais[i].capture.channels_max = max_ch;
Vinod Koulc46302e2018-04-26 18:39:05 +05301047 dais[i].capture.rates = SNDRV_PCM_RATE_48000;
1048 dais[i].capture.formats = SNDRV_PCM_FMTBIT_S16_LE;
1049 }
1050
Vinod Koulc46302e2018-04-26 18:39:05 +05301051 if (pcm)
1052 dais[i].ops = &intel_pcm_dai_ops;
1053 else
1054 dais[i].ops = &intel_pdm_dai_ops;
1055 }
1056
1057 return 0;
1058}
1059
1060static int intel_register_dai(struct sdw_intel *sdw)
1061{
1062 struct sdw_cdns *cdns = &sdw->cdns;
1063 struct sdw_cdns_streams *stream;
1064 struct snd_soc_dai_driver *dais;
1065 int num_dai, ret, off = 0;
1066
1067 /* DAIs are created based on total number of PDIs supported */
1068 num_dai = cdns->pcm.num_pdi + cdns->pdm.num_pdi;
1069
1070 dais = devm_kcalloc(cdns->dev, num_dai, sizeof(*dais), GFP_KERNEL);
1071 if (!dais)
1072 return -ENOMEM;
1073
1074 /* Create PCM DAIs */
1075 stream = &cdns->pcm;
1076
Bard Liaocf924962019-09-16 14:23:43 -05001077 ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pcm.num_in,
Vinod Koul1215dae2019-05-02 16:29:25 +05301078 off, stream->num_ch_in, true);
Vinod Koulc46302e2018-04-26 18:39:05 +05301079 if (ret)
1080 return ret;
1081
1082 off += cdns->pcm.num_in;
Vinod Koul1215dae2019-05-02 16:29:25 +05301083 ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pcm.num_out,
1084 off, stream->num_ch_out, true);
Vinod Koulc46302e2018-04-26 18:39:05 +05301085 if (ret)
1086 return ret;
1087
1088 off += cdns->pcm.num_out;
Vinod Koul1215dae2019-05-02 16:29:25 +05301089 ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pcm.num_bd,
1090 off, stream->num_ch_bd, true);
Vinod Koulc46302e2018-04-26 18:39:05 +05301091 if (ret)
1092 return ret;
1093
1094 /* Create PDM DAIs */
1095 stream = &cdns->pdm;
1096 off += cdns->pcm.num_bd;
Vinod Koul1215dae2019-05-02 16:29:25 +05301097 ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pdm.num_in,
1098 off, stream->num_ch_in, false);
Vinod Koulc46302e2018-04-26 18:39:05 +05301099 if (ret)
1100 return ret;
1101
1102 off += cdns->pdm.num_in;
Vinod Koul1215dae2019-05-02 16:29:25 +05301103 ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pdm.num_out,
1104 off, stream->num_ch_out, false);
Vinod Koulc46302e2018-04-26 18:39:05 +05301105 if (ret)
1106 return ret;
1107
Bard Liaocf924962019-09-16 14:23:43 -05001108 off += cdns->pdm.num_out;
Vinod Koul1215dae2019-05-02 16:29:25 +05301109 ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pdm.num_bd,
1110 off, stream->num_ch_bd, false);
Vinod Koulc46302e2018-04-26 18:39:05 +05301111 if (ret)
1112 return ret;
1113
1114 return snd_soc_register_component(cdns->dev, &dai_component,
Pierre-Louis Bossartd542bc92019-05-01 10:57:38 -05001115 dais, num_dai);
Vinod Koulc46302e2018-04-26 18:39:05 +05301116}
1117
Pierre-Louis Bossart085f4ac2019-08-05 19:55:16 -05001118static int sdw_master_read_intel_prop(struct sdw_bus *bus)
1119{
1120 struct sdw_master_prop *prop = &bus->prop;
1121 struct fwnode_handle *link;
1122 char name[32];
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001123 u32 quirk_mask;
Pierre-Louis Bossart085f4ac2019-08-05 19:55:16 -05001124
1125 /* Find master handle */
1126 snprintf(name, sizeof(name),
1127 "mipi-sdw-link-%d-subproperties", bus->link_id);
1128
1129 link = device_get_named_child_node(bus->dev, name);
1130 if (!link) {
1131 dev_err(bus->dev, "Master node %s not found\n", name);
1132 return -EIO;
1133 }
1134
1135 fwnode_property_read_u32(link,
1136 "intel-sdw-ip-clock",
1137 &prop->mclk_freq);
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001138
Bard Liaoa19efb52020-01-13 17:11:29 -06001139 /* the values reported by BIOS are the 2x clock, not the bus clock */
1140 prop->mclk_freq /= 2;
1141
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001142 fwnode_property_read_u32(link,
1143 "intel-quirk-mask",
1144 &quirk_mask);
1145
1146 if (quirk_mask & SDW_INTEL_QUIRK_MASK_BUS_DISABLE)
1147 prop->hw_disabled = true;
1148
Pierre-Louis Bossart085f4ac2019-08-05 19:55:16 -05001149 return 0;
1150}
1151
Vinod Koul71bb8a12017-12-14 11:19:43 +05301152static int intel_prop_read(struct sdw_bus *bus)
1153{
1154 /* Initialize with default handler to read all DisCo properties */
1155 sdw_master_read_prop(bus);
1156
Pierre-Louis Bossart085f4ac2019-08-05 19:55:16 -05001157 /* read Intel-specific properties */
1158 sdw_master_read_intel_prop(bus);
1159
Vinod Koul71bb8a12017-12-14 11:19:43 +05301160 return 0;
1161}
1162
Shreyas NCc91605f2018-04-26 18:38:43 +05301163static struct sdw_master_ops sdw_intel_ops = {
1164 .read_prop = sdw_master_read_prop,
1165 .xfer_msg = cdns_xfer_msg,
1166 .xfer_msg_defer = cdns_xfer_msg_defer,
1167 .reset_page_addr = cdns_reset_page_addr,
Vinod Koul07abeff2018-04-26 18:38:48 +05301168 .set_bus_conf = cdns_bus_conf,
Shreyas NC30246e22018-07-27 14:44:17 +05301169 .pre_bank_switch = intel_pre_bank_switch,
1170 .post_bank_switch = intel_post_bank_switch,
Shreyas NCc91605f2018-04-26 18:38:43 +05301171};
1172
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001173static int intel_init(struct sdw_intel *sdw)
1174{
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +08001175 bool clock_stop;
1176
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001177 /* Initialize shim and controller */
1178 intel_link_power_up(sdw);
Pierre-Louis Bossart4a17c442020-07-16 23:09:40 +08001179
1180 clock_stop = sdw_cdns_is_clock_stop(&sdw->cdns);
1181
1182 intel_shim_init(sdw, clock_stop);
1183
1184 if (clock_stop)
1185 return 0;
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001186
Rander Wang7b174f22020-03-17 11:33:14 -05001187 return sdw_cdns_init(&sdw->cdns);
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001188}
1189
Vinod Koul71bb8a12017-12-14 11:19:43 +05301190/*
1191 * probe and init
1192 */
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001193static int intel_master_probe(struct platform_device *pdev)
Vinod Koul71bb8a12017-12-14 11:19:43 +05301194{
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001195 struct device *dev = &pdev->dev;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301196 struct sdw_intel *sdw;
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001197 struct sdw_cdns *cdns;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001198 struct sdw_bus *bus;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301199 int ret;
1200
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001201 sdw = devm_kzalloc(dev, sizeof(*sdw), GFP_KERNEL);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301202 if (!sdw)
1203 return -ENOMEM;
1204
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001205 cdns = &sdw->cdns;
1206 bus = &cdns->bus;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001207
Vinod Koul71bb8a12017-12-14 11:19:43 +05301208 sdw->instance = pdev->id;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001209 sdw->link_res = dev_get_platdata(dev);
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001210 cdns->dev = dev;
1211 cdns->registers = sdw->link_res->registers;
1212 cdns->instance = sdw->instance;
1213 cdns->msg_count = 0;
1214
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001215 bus->link_id = pdev->id;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301216
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001217 sdw_cdns_probe(cdns);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301218
1219 /* Set property read ops */
Shreyas NCc91605f2018-04-26 18:38:43 +05301220 sdw_intel_ops.read_prop = intel_prop_read;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001221 bus->ops = &sdw_intel_ops;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301222
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001223 /* set driver data, accessed by snd_soc_dai_get_drvdata() */
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001224 dev_set_drvdata(dev, cdns);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301225
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001226 ret = sdw_bus_master_add(bus, dev, dev->fwnode);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301227 if (ret) {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001228 dev_err(dev, "sdw_bus_master_add fail: %d\n", ret);
Pierre-Louis Bossart9e3d47f2019-10-22 18:54:47 -05001229 return ret;
Vinod Koul71bb8a12017-12-14 11:19:43 +05301230 }
1231
Pierre-Louis Bossart6d2c6662020-06-01 02:21:02 +08001232 if (bus->prop.hw_disabled)
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001233 dev_info(dev,
1234 "SoundWire master %d is disabled, will be ignored\n",
1235 bus->link_id);
Pierre-Louis Bossart6d2c6662020-06-01 02:21:02 +08001236
1237 /* Acquire IRQ */
1238 ret = request_threaded_irq(sdw->link_res->irq,
1239 sdw_cdns_irq, sdw_cdns_thread,
1240 IRQF_SHARED, KBUILD_MODNAME, cdns);
1241 if (ret < 0) {
1242 dev_err(dev, "unable to grab IRQ %d, disabling device\n",
1243 sdw->link_res->irq);
1244 goto err_init;
1245 }
1246
1247 return 0;
1248
1249err_init:
1250 sdw_bus_master_delete(bus);
1251 return ret;
1252}
1253
1254int intel_master_startup(struct platform_device *pdev)
1255{
1256 struct sdw_cdns_stream_config config;
1257 struct device *dev = &pdev->dev;
1258 struct sdw_cdns *cdns = dev_get_drvdata(dev);
1259 struct sdw_intel *sdw = cdns_to_intel(cdns);
1260 struct sdw_bus *bus = &cdns->bus;
1261 int ret;
1262
1263 if (bus->prop.hw_disabled) {
1264 dev_info(dev,
1265 "SoundWire master %d is disabled, ignoring\n",
1266 sdw->instance);
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001267 return 0;
1268 }
1269
Pierre-Louis Bossartdfbe6422019-10-22 18:54:46 -05001270 /* Initialize shim, controller and Cadence IP */
1271 ret = intel_init(sdw);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301272 if (ret)
1273 goto err_init;
1274
Vinod Koul37a2d222018-04-26 18:38:58 +05301275 /* Read the PDI config and initialize cadence PDI */
1276 intel_pdi_init(sdw, &config);
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001277 ret = sdw_cdns_pdi_init(cdns, config);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301278 if (ret)
1279 goto err_init;
1280
Vinod Koul37a2d222018-04-26 18:38:58 +05301281 intel_pdi_ch_update(sdw);
1282
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001283 ret = sdw_cdns_enable_interrupt(cdns, true);
Pierre-Louis Bossart49ea07d2019-10-22 18:54:44 -05001284 if (ret < 0) {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001285 dev_err(dev, "cannot enable interrupts\n");
Pierre-Louis Bossart49ea07d2019-10-22 18:54:44 -05001286 goto err_init;
1287 }
1288
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001289 ret = sdw_cdns_exit_reset(cdns);
Pierre-Louis Bossart49ea07d2019-10-22 18:54:44 -05001290 if (ret < 0) {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001291 dev_err(dev, "unable to exit bus reset sequence\n");
Pierre-Louis Bossart9e3d47f2019-10-22 18:54:47 -05001292 goto err_interrupt;
Pierre-Louis Bossart49ea07d2019-10-22 18:54:44 -05001293 }
1294
Vinod Koulc46302e2018-04-26 18:39:05 +05301295 /* Register DAIs */
1296 ret = intel_register_dai(sdw);
1297 if (ret) {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001298 dev_err(dev, "DAI registration failed: %d\n", ret);
1299 snd_soc_unregister_component(dev);
Pierre-Louis Bossart9e3d47f2019-10-22 18:54:47 -05001300 goto err_interrupt;
Vinod Koulc46302e2018-04-26 18:39:05 +05301301 }
1302
Pierre-Louis Bossart79ee6632019-08-21 13:58:20 -05001303 intel_debugfs_init(sdw);
1304
Vinod Koul71bb8a12017-12-14 11:19:43 +05301305 return 0;
1306
Pierre-Louis Bossart9e3d47f2019-10-22 18:54:47 -05001307err_interrupt:
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001308 sdw_cdns_enable_interrupt(cdns, false);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301309err_init:
Vinod Koul71bb8a12017-12-14 11:19:43 +05301310 return ret;
1311}
1312
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001313static int intel_master_remove(struct platform_device *pdev)
Vinod Koul71bb8a12017-12-14 11:19:43 +05301314{
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001315 struct device *dev = &pdev->dev;
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001316 struct sdw_cdns *cdns = dev_get_drvdata(dev);
1317 struct sdw_intel *sdw = cdns_to_intel(cdns);
1318 struct sdw_bus *bus = &cdns->bus;
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001319
1320 if (!bus->prop.hw_disabled) {
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001321 intel_debugfs_exit(sdw);
Pierre-Louis Bossart83e129af2020-06-01 02:20:58 +08001322 sdw_cdns_enable_interrupt(cdns, false);
Pierre-Louis Bossart25234862020-02-14 19:47:36 -06001323 free_irq(sdw->link_res->irq, sdw);
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001324 snd_soc_unregister_component(dev);
Pierre-Louis Bossart395713d2019-08-21 13:58:21 -05001325 }
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001326 sdw_bus_master_delete(bus);
Vinod Koul71bb8a12017-12-14 11:19:43 +05301327
1328 return 0;
1329}
1330
1331static struct platform_driver sdw_intel_drv = {
Pierre-Louis Bossartb6109dd2020-06-01 02:20:57 +08001332 .probe = intel_master_probe,
1333 .remove = intel_master_remove,
Vinod Koul71bb8a12017-12-14 11:19:43 +05301334 .driver = {
Pierre-Louis Bossart6d2c6662020-06-01 02:21:02 +08001335 .name = "intel-sdw",
Vinod Koul71bb8a12017-12-14 11:19:43 +05301336 },
1337};
1338
1339module_platform_driver(sdw_intel_drv);
1340
1341MODULE_LICENSE("Dual BSD/GPL");
Pierre-Louis Bossart6d2c6662020-06-01 02:21:02 +08001342MODULE_ALIAS("platform:intel-sdw");
Vinod Koul71bb8a12017-12-14 11:19:43 +05301343MODULE_DESCRIPTION("Intel Soundwire Master Driver");