1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 // Copyright(c) 2015-22 Intel Corporation.
3 
4 /*
5  * Soundwire Intel Manager Driver
6  */
7 
8 #include <linux/acpi.h>
9 #include <linux/debugfs.h>
10 #include <linux/delay.h>
11 #include <linux/module.h>
12 #include <linux/interrupt.h>
13 #include <linux/io.h>
14 #include <linux/auxiliary_bus.h>
15 #include <sound/pcm_params.h>
16 #include <linux/pm_runtime.h>
17 #include <sound/soc.h>
18 #include <linux/soundwire/sdw_registers.h>
19 #include <linux/soundwire/sdw.h>
20 #include <linux/soundwire/sdw_intel.h>
21 #include "cadence_master.h"
22 #include "bus.h"
23 #include "intel.h"
24 #include "intel_auxdevice.h"
25 
26 /* IDA min selected to avoid conflicts with HDaudio/iDISP SDI values */
27 #define INTEL_DEV_NUM_IDA_MIN           4
28 
29 #define INTEL_MASTER_SUSPEND_DELAY_MS	3000
30 
31 /*
32  * debug/config flags for the Intel SoundWire Master.
33  *
34  * Since we may have multiple masters active, we can have up to 8
35  * flags reused in each byte, with master0 using the ls-byte, etc.
36  */
37 
38 #define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME		BIT(0)
39 #define SDW_INTEL_MASTER_DISABLE_CLOCK_STOP		BIT(1)
40 #define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE	BIT(2)
41 #define SDW_INTEL_MASTER_DISABLE_MULTI_LINK		BIT(3)
42 
43 static int md_flags;
44 module_param_named(sdw_md_flags, md_flags, int, 0444);
45 MODULE_PARM_DESC(sdw_md_flags, "SoundWire Intel Master device flags (0x0 all off)");
46 
47 static int generic_pre_bank_switch(struct sdw_bus *bus)
48 {
49 	struct sdw_cdns *cdns = bus_to_cdns(bus);
50 	struct sdw_intel *sdw = cdns_to_intel(cdns);
51 
52 	return sdw->link_res->hw_ops->pre_bank_switch(sdw);
53 }
54 
55 static int generic_post_bank_switch(struct sdw_bus *bus)
56 {
57 	struct sdw_cdns *cdns = bus_to_cdns(bus);
58 	struct sdw_intel *sdw = cdns_to_intel(cdns);
59 
60 	return sdw->link_res->hw_ops->post_bank_switch(sdw);
61 }
62 
63 static int sdw_master_read_intel_prop(struct sdw_bus *bus)
64 {
65 	struct sdw_master_prop *prop = &bus->prop;
66 	struct fwnode_handle *link;
67 	char name[32];
68 	u32 quirk_mask;
69 
70 	/* Find master handle */
71 	snprintf(name, sizeof(name),
72 		 "mipi-sdw-link-%d-subproperties", bus->link_id);
73 
74 	link = device_get_named_child_node(bus->dev, name);
75 	if (!link) {
76 		dev_err(bus->dev, "Master node %s not found\n", name);
77 		return -EIO;
78 	}
79 
80 	fwnode_property_read_u32(link,
81 				 "intel-sdw-ip-clock",
82 				 &prop->mclk_freq);
83 
84 	/* the values reported by BIOS are the 2x clock, not the bus clock */
85 	prop->mclk_freq /= 2;
86 
87 	fwnode_property_read_u32(link,
88 				 "intel-quirk-mask",
89 				 &quirk_mask);
90 
91 	if (quirk_mask & SDW_INTEL_QUIRK_MASK_BUS_DISABLE)
92 		prop->hw_disabled = true;
93 
94 	prop->quirks = SDW_MASTER_QUIRKS_CLEAR_INITIAL_CLASH |
95 		SDW_MASTER_QUIRKS_CLEAR_INITIAL_PARITY;
96 
97 	return 0;
98 }
99 
100 static int intel_prop_read(struct sdw_bus *bus)
101 {
102 	/* Initialize with default handler to read all DisCo properties */
103 	sdw_master_read_prop(bus);
104 
105 	/* read Intel-specific properties */
106 	sdw_master_read_intel_prop(bus);
107 
108 	return 0;
109 }
110 
111 static struct sdw_master_ops sdw_intel_ops = {
112 	.read_prop = intel_prop_read,
113 	.override_adr = sdw_dmi_override_adr,
114 	.xfer_msg = cdns_xfer_msg,
115 	.xfer_msg_defer = cdns_xfer_msg_defer,
116 	.set_bus_conf = cdns_bus_conf,
117 	.pre_bank_switch = generic_pre_bank_switch,
118 	.post_bank_switch = generic_post_bank_switch,
119 	.read_ping_status = cdns_read_ping_status,
120 };
121 
122 /*
123  * probe and init (aux_dev_id argument is required by function prototype but not used)
124  */
125 static int intel_link_probe(struct auxiliary_device *auxdev,
126 			    const struct auxiliary_device_id *aux_dev_id)
127 
128 {
129 	struct device *dev = &auxdev->dev;
130 	struct sdw_intel_link_dev *ldev = auxiliary_dev_to_sdw_intel_link_dev(auxdev);
131 	struct sdw_intel *sdw;
132 	struct sdw_cdns *cdns;
133 	struct sdw_bus *bus;
134 	int ret;
135 
136 	sdw = devm_kzalloc(dev, sizeof(*sdw), GFP_KERNEL);
137 	if (!sdw)
138 		return -ENOMEM;
139 
140 	cdns = &sdw->cdns;
141 	bus = &cdns->bus;
142 
143 	sdw->instance = auxdev->id;
144 	sdw->link_res = &ldev->link_res;
145 	cdns->dev = dev;
146 	cdns->registers = sdw->link_res->registers;
147 	cdns->instance = sdw->instance;
148 	cdns->msg_count = 0;
149 
150 	bus->link_id = auxdev->id;
151 	bus->dev_num_ida_min = INTEL_DEV_NUM_IDA_MIN;
152 	bus->clk_stop_timeout = 1;
153 
154 	sdw_cdns_probe(cdns);
155 
156 	/* Set ops */
157 	bus->ops = &sdw_intel_ops;
158 
159 	/* set driver data, accessed by snd_soc_dai_get_drvdata() */
160 	auxiliary_set_drvdata(auxdev, cdns);
161 
162 	/* use generic bandwidth allocation algorithm */
163 	sdw->cdns.bus.compute_params = sdw_compute_params;
164 
165 	/* avoid resuming from pm_runtime suspend if it's not required */
166 	dev_pm_set_driver_flags(dev, DPM_FLAG_SMART_SUSPEND);
167 
168 	ret = sdw_bus_master_add(bus, dev, dev->fwnode);
169 	if (ret) {
170 		dev_err(dev, "sdw_bus_master_add fail: %d\n", ret);
171 		return ret;
172 	}
173 
174 	if (bus->prop.hw_disabled)
175 		dev_info(dev,
176 			 "SoundWire master %d is disabled, will be ignored\n",
177 			 bus->link_id);
178 	/*
179 	 * Ignore BIOS err_threshold, it's a really bad idea when dealing
180 	 * with multiple hardware synchronized links
181 	 */
182 	bus->prop.err_threshold = 0;
183 
184 	return 0;
185 }
186 
187 int intel_link_startup(struct auxiliary_device *auxdev)
188 {
189 	struct device *dev = &auxdev->dev;
190 	struct sdw_cdns *cdns = auxiliary_get_drvdata(auxdev);
191 	struct sdw_intel *sdw = cdns_to_intel(cdns);
192 	struct sdw_bus *bus = &cdns->bus;
193 	int link_flags;
194 	bool multi_link;
195 	u32 clock_stop_quirks;
196 	int ret;
197 
198 	if (bus->prop.hw_disabled) {
199 		dev_info(dev,
200 			 "SoundWire master %d is disabled, ignoring\n",
201 			 sdw->instance);
202 		return 0;
203 	}
204 
205 	link_flags = md_flags >> (bus->link_id * 8);
206 	multi_link = !(link_flags & SDW_INTEL_MASTER_DISABLE_MULTI_LINK);
207 	if (!multi_link) {
208 		dev_dbg(dev, "Multi-link is disabled\n");
209 	} else {
210 		/*
211 		 * hardware-based synchronization is required regardless
212 		 * of the number of segments used by a stream: SSP-based
213 		 * synchronization is gated by gsync when the multi-master
214 		 * mode is set.
215 		 */
216 		bus->hw_sync_min_links = 1;
217 	}
218 	bus->multi_link = multi_link;
219 
220 	/* Initialize shim, controller */
221 	ret = sdw_intel_link_power_up(sdw);
222 	if (ret)
223 		goto err_init;
224 
225 	/* Register DAIs */
226 	ret = sdw_intel_register_dai(sdw);
227 	if (ret) {
228 		dev_err(dev, "DAI registration failed: %d\n", ret);
229 		goto err_power_up;
230 	}
231 
232 	sdw_intel_debugfs_init(sdw);
233 
234 	/* start bus */
235 	ret = sdw_intel_start_bus(sdw);
236 	if (ret) {
237 		dev_err(dev, "bus start failed: %d\n", ret);
238 		goto err_power_up;
239 	}
240 
241 	/* Enable runtime PM */
242 	if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME)) {
243 		pm_runtime_set_autosuspend_delay(dev,
244 						 INTEL_MASTER_SUSPEND_DELAY_MS);
245 		pm_runtime_use_autosuspend(dev);
246 		pm_runtime_mark_last_busy(dev);
247 
248 		pm_runtime_set_active(dev);
249 		pm_runtime_enable(dev);
250 	}
251 
252 	clock_stop_quirks = sdw->link_res->clock_stop_quirks;
253 	if (clock_stop_quirks & SDW_INTEL_CLK_STOP_NOT_ALLOWED) {
254 		/*
255 		 * To keep the clock running we need to prevent
256 		 * pm_runtime suspend from happening by increasing the
257 		 * reference count.
258 		 * This quirk is specified by the parent PCI device in
259 		 * case of specific latency requirements. It will have
260 		 * no effect if pm_runtime is disabled by the user via
261 		 * a module parameter for testing purposes.
262 		 */
263 		pm_runtime_get_noresume(dev);
264 	}
265 
266 	/*
267 	 * The runtime PM status of Slave devices is "Unsupported"
268 	 * until they report as ATTACHED. If they don't, e.g. because
269 	 * there are no Slave devices populated or if the power-on is
270 	 * delayed or dependent on a power switch, the Master will
271 	 * remain active and prevent its parent from suspending.
272 	 *
273 	 * Conditionally force the pm_runtime core to re-evaluate the
274 	 * Master status in the absence of any Slave activity. A quirk
275 	 * is provided to e.g. deal with Slaves that may be powered on
276 	 * with a delay. A more complete solution would require the
277 	 * definition of Master properties.
278 	 */
279 	if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE))
280 		pm_runtime_idle(dev);
281 
282 	sdw->startup_done = true;
283 	return 0;
284 
285 err_power_up:
286 	sdw_intel_link_power_down(sdw);
287 err_init:
288 	return ret;
289 }
290 
291 static void intel_link_remove(struct auxiliary_device *auxdev)
292 {
293 	struct sdw_cdns *cdns = auxiliary_get_drvdata(auxdev);
294 	struct sdw_intel *sdw = cdns_to_intel(cdns);
295 	struct sdw_bus *bus = &cdns->bus;
296 
297 	/*
298 	 * Since pm_runtime is already disabled, we don't decrease
299 	 * the refcount when the clock_stop_quirk is
300 	 * SDW_INTEL_CLK_STOP_NOT_ALLOWED
301 	 */
302 	if (!bus->prop.hw_disabled) {
303 		sdw_intel_debugfs_exit(sdw);
304 		sdw_cdns_enable_interrupt(cdns, false);
305 	}
306 	sdw_bus_master_delete(bus);
307 }
308 
309 int intel_link_process_wakeen_event(struct auxiliary_device *auxdev)
310 {
311 	struct device *dev = &auxdev->dev;
312 	struct sdw_intel *sdw;
313 	struct sdw_bus *bus;
314 
315 	sdw = auxiliary_get_drvdata(auxdev);
316 	bus = &sdw->cdns.bus;
317 
318 	if (bus->prop.hw_disabled || !sdw->startup_done) {
319 		dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
320 			bus->link_id);
321 		return 0;
322 	}
323 
324 	if (!sdw_intel_shim_check_wake(sdw))
325 		return 0;
326 
327 	/* disable WAKEEN interrupt ASAP to prevent interrupt flood */
328 	sdw_intel_shim_wake(sdw, false);
329 
330 	/*
331 	 * resume the Master, which will generate a bus reset and result in
332 	 * Slaves re-attaching and be re-enumerated. The SoundWire physical
333 	 * device which generated the wake will trigger an interrupt, which
334 	 * will in turn cause the corresponding Linux Slave device to be
335 	 * resumed and the Slave codec driver to check the status.
336 	 */
337 	pm_request_resume(dev);
338 
339 	return 0;
340 }
341 
342 /*
343  * PM calls
344  */
345 
346 static int intel_resume_child_device(struct device *dev, void *data)
347 {
348 	int ret;
349 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
350 
351 	if (!slave->probed) {
352 		dev_dbg(dev, "skipping device, no probed driver\n");
353 		return 0;
354 	}
355 	if (!slave->dev_num_sticky) {
356 		dev_dbg(dev, "skipping device, never detected on bus\n");
357 		return 0;
358 	}
359 
360 	ret = pm_request_resume(dev);
361 	if (ret < 0) {
362 		dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret);
363 		return ret;
364 	}
365 
366 	return 0;
367 }
368 
369 static int __maybe_unused intel_pm_prepare(struct device *dev)
370 {
371 	struct sdw_cdns *cdns = dev_get_drvdata(dev);
372 	struct sdw_intel *sdw = cdns_to_intel(cdns);
373 	struct sdw_bus *bus = &cdns->bus;
374 	u32 clock_stop_quirks;
375 	int ret;
376 
377 	if (bus->prop.hw_disabled || !sdw->startup_done) {
378 		dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
379 			bus->link_id);
380 		return 0;
381 	}
382 
383 	clock_stop_quirks = sdw->link_res->clock_stop_quirks;
384 
385 	if (pm_runtime_suspended(dev) &&
386 	    pm_runtime_suspended(dev->parent) &&
387 	    ((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) ||
388 	     !clock_stop_quirks)) {
389 		/*
390 		 * if we've enabled clock stop, and the parent is suspended, the SHIM registers
391 		 * are not accessible and the shim wake cannot be disabled.
392 		 * The only solution is to resume the entire bus to full power
393 		 */
394 
395 		/*
396 		 * If any operation in this block fails, we keep going since we don't want
397 		 * to prevent system suspend from happening and errors should be recoverable
398 		 * on resume.
399 		 */
400 
401 		/*
402 		 * first resume the device for this link. This will also by construction
403 		 * resume the PCI parent device.
404 		 */
405 		ret = pm_request_resume(dev);
406 		if (ret < 0) {
407 			dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret);
408 			return 0;
409 		}
410 
411 		/*
412 		 * Continue resuming the entire bus (parent + child devices) to exit
413 		 * the clock stop mode. If there are no devices connected on this link
414 		 * this is a no-op.
415 		 * The resume to full power could have been implemented with a .prepare
416 		 * step in SoundWire codec drivers. This would however require a lot
417 		 * of code to handle an Intel-specific corner case. It is simpler in
418 		 * practice to add a loop at the link level.
419 		 */
420 		ret = device_for_each_child(bus->dev, NULL, intel_resume_child_device);
421 
422 		if (ret < 0)
423 			dev_err(dev, "%s: intel_resume_child_device failed: %d\n", __func__, ret);
424 	}
425 
426 	return 0;
427 }
428 
429 static int __maybe_unused intel_suspend(struct device *dev)
430 {
431 	struct sdw_cdns *cdns = dev_get_drvdata(dev);
432 	struct sdw_intel *sdw = cdns_to_intel(cdns);
433 	struct sdw_bus *bus = &cdns->bus;
434 	u32 clock_stop_quirks;
435 	int ret;
436 
437 	if (bus->prop.hw_disabled || !sdw->startup_done) {
438 		dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
439 			bus->link_id);
440 		return 0;
441 	}
442 
443 	if (pm_runtime_suspended(dev)) {
444 		dev_dbg(dev, "pm_runtime status: suspended\n");
445 
446 		clock_stop_quirks = sdw->link_res->clock_stop_quirks;
447 
448 		if ((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) ||
449 		    !clock_stop_quirks) {
450 
451 			if (pm_runtime_suspended(dev->parent)) {
452 				/*
453 				 * paranoia check: this should not happen with the .prepare
454 				 * resume to full power
455 				 */
456 				dev_err(dev, "%s: invalid config: parent is suspended\n", __func__);
457 			} else {
458 				sdw_intel_shim_wake(sdw, false);
459 			}
460 		}
461 
462 		return 0;
463 	}
464 
465 	ret = sdw_intel_stop_bus(sdw, false);
466 	if (ret < 0) {
467 		dev_err(dev, "%s: cannot stop bus: %d\n", __func__, ret);
468 		return ret;
469 	}
470 
471 	return 0;
472 }
473 
474 static int __maybe_unused intel_suspend_runtime(struct device *dev)
475 {
476 	struct sdw_cdns *cdns = dev_get_drvdata(dev);
477 	struct sdw_intel *sdw = cdns_to_intel(cdns);
478 	struct sdw_bus *bus = &cdns->bus;
479 	u32 clock_stop_quirks;
480 	int ret;
481 
482 	if (bus->prop.hw_disabled || !sdw->startup_done) {
483 		dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
484 			bus->link_id);
485 		return 0;
486 	}
487 
488 	clock_stop_quirks = sdw->link_res->clock_stop_quirks;
489 
490 	if (clock_stop_quirks & SDW_INTEL_CLK_STOP_TEARDOWN) {
491 		ret = sdw_intel_stop_bus(sdw, false);
492 		if (ret < 0) {
493 			dev_err(dev, "%s: cannot stop bus during teardown: %d\n",
494 				__func__, ret);
495 			return ret;
496 		}
497 	} else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET || !clock_stop_quirks) {
498 		ret = sdw_intel_stop_bus(sdw, true);
499 		if (ret < 0) {
500 			dev_err(dev, "%s: cannot stop bus during clock_stop: %d\n",
501 				__func__, ret);
502 			return ret;
503 		}
504 	} else {
505 		dev_err(dev, "%s clock_stop_quirks %x unsupported\n",
506 			__func__, clock_stop_quirks);
507 		ret = -EINVAL;
508 	}
509 
510 	return ret;
511 }
512 
513 static int __maybe_unused intel_resume(struct device *dev)
514 {
515 	struct sdw_cdns *cdns = dev_get_drvdata(dev);
516 	struct sdw_intel *sdw = cdns_to_intel(cdns);
517 	struct sdw_bus *bus = &cdns->bus;
518 	int link_flags;
519 	int ret;
520 
521 	if (bus->prop.hw_disabled || !sdw->startup_done) {
522 		dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
523 			bus->link_id);
524 		return 0;
525 	}
526 
527 	link_flags = md_flags >> (bus->link_id * 8);
528 
529 	if (pm_runtime_suspended(dev)) {
530 		dev_dbg(dev, "pm_runtime status was suspended, forcing active\n");
531 
532 		/* follow required sequence from runtime_pm.rst */
533 		pm_runtime_disable(dev);
534 		pm_runtime_set_active(dev);
535 		pm_runtime_mark_last_busy(dev);
536 		pm_runtime_enable(dev);
537 
538 		link_flags = md_flags >> (bus->link_id * 8);
539 
540 		if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE))
541 			pm_runtime_idle(dev);
542 	}
543 
544 	ret = sdw_intel_link_power_up(sdw);
545 	if (ret) {
546 		dev_err(dev, "%s failed: %d\n", __func__, ret);
547 		return ret;
548 	}
549 
550 	/*
551 	 * make sure all Slaves are tagged as UNATTACHED and provide
552 	 * reason for reinitialization
553 	 */
554 	sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET);
555 
556 	ret = sdw_intel_start_bus(sdw);
557 	if (ret < 0) {
558 		dev_err(dev, "cannot start bus during resume\n");
559 		sdw_intel_link_power_down(sdw);
560 		return ret;
561 	}
562 
563 	/*
564 	 * after system resume, the pm_runtime suspend() may kick in
565 	 * during the enumeration, before any children device force the
566 	 * master device to remain active.  Using pm_runtime_get()
567 	 * routines is not really possible, since it'd prevent the
568 	 * master from suspending.
569 	 * A reasonable compromise is to update the pm_runtime
570 	 * counters and delay the pm_runtime suspend by several
571 	 * seconds, by when all enumeration should be complete.
572 	 */
573 	pm_runtime_mark_last_busy(dev);
574 
575 	return 0;
576 }
577 
578 static int __maybe_unused intel_resume_runtime(struct device *dev)
579 {
580 	struct sdw_cdns *cdns = dev_get_drvdata(dev);
581 	struct sdw_intel *sdw = cdns_to_intel(cdns);
582 	struct sdw_bus *bus = &cdns->bus;
583 	u32 clock_stop_quirks;
584 	int ret;
585 
586 	if (bus->prop.hw_disabled || !sdw->startup_done) {
587 		dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
588 			bus->link_id);
589 		return 0;
590 	}
591 
592 	/* unconditionally disable WAKEEN interrupt */
593 	sdw_intel_shim_wake(sdw, false);
594 
595 	clock_stop_quirks = sdw->link_res->clock_stop_quirks;
596 
597 	if (clock_stop_quirks & SDW_INTEL_CLK_STOP_TEARDOWN) {
598 		ret = sdw_intel_link_power_up(sdw);
599 		if (ret) {
600 			dev_err(dev, "%s: power_up failed after teardown: %d\n", __func__, ret);
601 			return ret;
602 		}
603 
604 		/*
605 		 * make sure all Slaves are tagged as UNATTACHED and provide
606 		 * reason for reinitialization
607 		 */
608 		sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET);
609 
610 		ret = sdw_intel_start_bus(sdw);
611 		if (ret < 0) {
612 			dev_err(dev, "%s: cannot start bus after teardown: %d\n", __func__, ret);
613 			sdw_intel_link_power_down(sdw);
614 			return ret;
615 		}
616 
617 	} else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) {
618 		ret = sdw_intel_link_power_up(sdw);
619 		if (ret) {
620 			dev_err(dev, "%s: power_up failed after bus reset: %d\n", __func__, ret);
621 			return ret;
622 		}
623 
624 		ret = sdw_intel_start_bus_after_reset(sdw);
625 		if (ret < 0) {
626 			dev_err(dev, "%s: cannot start bus after reset: %d\n", __func__, ret);
627 			sdw_intel_link_power_down(sdw);
628 			return ret;
629 		}
630 	} else if (!clock_stop_quirks) {
631 
632 		sdw_intel_check_clock_stop(sdw);
633 
634 		ret = sdw_intel_link_power_up(sdw);
635 		if (ret) {
636 			dev_err(dev, "%s: power_up failed: %d\n", __func__, ret);
637 			return ret;
638 		}
639 
640 		ret = sdw_intel_start_bus_after_clock_stop(sdw);
641 		if (ret < 0) {
642 			dev_err(dev, "%s: cannot start bus after clock stop: %d\n", __func__, ret);
643 			sdw_intel_link_power_down(sdw);
644 			return ret;
645 		}
646 	} else {
647 		dev_err(dev, "%s: clock_stop_quirks %x unsupported\n",
648 			__func__, clock_stop_quirks);
649 		ret = -EINVAL;
650 	}
651 
652 	return ret;
653 }
654 
655 static const struct dev_pm_ops intel_pm = {
656 	.prepare = intel_pm_prepare,
657 	SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
658 	SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
659 };
660 
661 static const struct auxiliary_device_id intel_link_id_table[] = {
662 	{ .name = "soundwire_intel.link" },
663 	{},
664 };
665 MODULE_DEVICE_TABLE(auxiliary, intel_link_id_table);
666 
667 static struct auxiliary_driver sdw_intel_drv = {
668 	.probe = intel_link_probe,
669 	.remove = intel_link_remove,
670 	.driver = {
671 		/* auxiliary_driver_register() sets .name to be the modname */
672 		.pm = &intel_pm,
673 	},
674 	.id_table = intel_link_id_table
675 };
676 module_auxiliary_driver(sdw_intel_drv);
677 
678 MODULE_LICENSE("Dual BSD/GPL");
679 MODULE_DESCRIPTION("Intel Soundwire Link Driver");
680