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