soundWire: intel_auxdevice: resume 'sdw-master' on startup and system resume
[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                 pm_runtime_resume(bus->dev);
262         }
263
264         /* start bus */
265         ret = sdw_intel_start_bus(sdw);
266         if (ret) {
267                 dev_err(dev, "bus start failed: %d\n", ret);
268                 goto err_pm_runtime;
269         }
270
271         clock_stop_quirks = sdw->link_res->clock_stop_quirks;
272         if (clock_stop_quirks & SDW_INTEL_CLK_STOP_NOT_ALLOWED) {
273                 /*
274                  * To keep the clock running we need to prevent
275                  * pm_runtime suspend from happening by increasing the
276                  * reference count.
277                  * This quirk is specified by the parent PCI device in
278                  * case of specific latency requirements. It will have
279                  * no effect if pm_runtime is disabled by the user via
280                  * a module parameter for testing purposes.
281                  */
282                 pm_runtime_get_noresume(dev);
283         }
284
285         /*
286          * The runtime PM status of Slave devices is "Unsupported"
287          * until they report as ATTACHED. If they don't, e.g. because
288          * there are no Slave devices populated or if the power-on is
289          * delayed or dependent on a power switch, the Master will
290          * remain active and prevent its parent from suspending.
291          *
292          * Conditionally force the pm_runtime core to re-evaluate the
293          * Master status in the absence of any Slave activity. A quirk
294          * is provided to e.g. deal with Slaves that may be powered on
295          * with a delay. A more complete solution would require the
296          * definition of Master properties.
297          */
298         if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE)) {
299                 pm_runtime_mark_last_busy(bus->dev);
300                 pm_runtime_mark_last_busy(dev);
301                 pm_runtime_idle(dev);
302         }
303
304         sdw->startup_done = true;
305         return 0;
306
307 err_pm_runtime:
308         if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME))
309                 pm_runtime_disable(dev);
310 err_power_up:
311         sdw_intel_link_power_down(sdw);
312 err_init:
313         return ret;
314 }
315
316 static void intel_link_remove(struct auxiliary_device *auxdev)
317 {
318         struct sdw_cdns *cdns = auxiliary_get_drvdata(auxdev);
319         struct sdw_intel *sdw = cdns_to_intel(cdns);
320         struct sdw_bus *bus = &cdns->bus;
321
322         /*
323          * Since pm_runtime is already disabled, we don't decrease
324          * the refcount when the clock_stop_quirk is
325          * SDW_INTEL_CLK_STOP_NOT_ALLOWED
326          */
327         if (!bus->prop.hw_disabled) {
328                 sdw_intel_debugfs_exit(sdw);
329                 sdw_cdns_enable_interrupt(cdns, false);
330         }
331         sdw_bus_master_delete(bus);
332 }
333
334 int intel_link_process_wakeen_event(struct auxiliary_device *auxdev)
335 {
336         struct device *dev = &auxdev->dev;
337         struct sdw_intel *sdw;
338         struct sdw_bus *bus;
339
340         sdw = auxiliary_get_drvdata(auxdev);
341         bus = &sdw->cdns.bus;
342
343         if (bus->prop.hw_disabled || !sdw->startup_done) {
344                 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
345                         bus->link_id);
346                 return 0;
347         }
348
349         if (!sdw_intel_shim_check_wake(sdw))
350                 return 0;
351
352         /* disable WAKEEN interrupt ASAP to prevent interrupt flood */
353         sdw_intel_shim_wake(sdw, false);
354
355         /*
356          * resume the Master, which will generate a bus reset and result in
357          * Slaves re-attaching and be re-enumerated. The SoundWire physical
358          * device which generated the wake will trigger an interrupt, which
359          * will in turn cause the corresponding Linux Slave device to be
360          * resumed and the Slave codec driver to check the status.
361          */
362         pm_request_resume(dev);
363
364         return 0;
365 }
366
367 /*
368  * PM calls
369  */
370
371 static int intel_resume_child_device(struct device *dev, void *data)
372 {
373         int ret;
374         struct sdw_slave *slave = dev_to_sdw_dev(dev);
375
376         if (!slave->probed) {
377                 dev_dbg(dev, "skipping device, no probed driver\n");
378                 return 0;
379         }
380         if (!slave->dev_num_sticky) {
381                 dev_dbg(dev, "skipping device, never detected on bus\n");
382                 return 0;
383         }
384
385         ret = pm_request_resume(dev);
386         if (ret < 0) {
387                 dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret);
388                 return ret;
389         }
390
391         return 0;
392 }
393
394 static int __maybe_unused intel_pm_prepare(struct device *dev)
395 {
396         struct sdw_cdns *cdns = dev_get_drvdata(dev);
397         struct sdw_intel *sdw = cdns_to_intel(cdns);
398         struct sdw_bus *bus = &cdns->bus;
399         u32 clock_stop_quirks;
400         int ret;
401
402         if (bus->prop.hw_disabled || !sdw->startup_done) {
403                 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
404                         bus->link_id);
405                 return 0;
406         }
407
408         clock_stop_quirks = sdw->link_res->clock_stop_quirks;
409
410         if (pm_runtime_suspended(dev) &&
411             pm_runtime_suspended(dev->parent) &&
412             ((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) ||
413              !clock_stop_quirks)) {
414                 /*
415                  * if we've enabled clock stop, and the parent is suspended, the SHIM registers
416                  * are not accessible and the shim wake cannot be disabled.
417                  * The only solution is to resume the entire bus to full power
418                  */
419
420                 /*
421                  * If any operation in this block fails, we keep going since we don't want
422                  * to prevent system suspend from happening and errors should be recoverable
423                  * on resume.
424                  */
425
426                 /*
427                  * first resume the device for this link. This will also by construction
428                  * resume the PCI parent device.
429                  */
430                 ret = pm_request_resume(dev);
431                 if (ret < 0) {
432                         dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret);
433                         return 0;
434                 }
435
436                 /*
437                  * Continue resuming the entire bus (parent + child devices) to exit
438                  * the clock stop mode. If there are no devices connected on this link
439                  * this is a no-op.
440                  * The resume to full power could have been implemented with a .prepare
441                  * step in SoundWire codec drivers. This would however require a lot
442                  * of code to handle an Intel-specific corner case. It is simpler in
443                  * practice to add a loop at the link level.
444                  */
445                 ret = device_for_each_child(bus->dev, NULL, intel_resume_child_device);
446
447                 if (ret < 0)
448                         dev_err(dev, "%s: intel_resume_child_device failed: %d\n", __func__, ret);
449         }
450
451         return 0;
452 }
453
454 static int __maybe_unused intel_suspend(struct device *dev)
455 {
456         struct sdw_cdns *cdns = dev_get_drvdata(dev);
457         struct sdw_intel *sdw = cdns_to_intel(cdns);
458         struct sdw_bus *bus = &cdns->bus;
459         u32 clock_stop_quirks;
460         int ret;
461
462         if (bus->prop.hw_disabled || !sdw->startup_done) {
463                 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
464                         bus->link_id);
465                 return 0;
466         }
467
468         if (pm_runtime_suspended(dev)) {
469                 dev_dbg(dev, "pm_runtime status: suspended\n");
470
471                 clock_stop_quirks = sdw->link_res->clock_stop_quirks;
472
473                 if ((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) ||
474                     !clock_stop_quirks) {
475
476                         if (pm_runtime_suspended(dev->parent)) {
477                                 /*
478                                  * paranoia check: this should not happen with the .prepare
479                                  * resume to full power
480                                  */
481                                 dev_err(dev, "%s: invalid config: parent is suspended\n", __func__);
482                         } else {
483                                 sdw_intel_shim_wake(sdw, false);
484                         }
485                 }
486
487                 return 0;
488         }
489
490         ret = sdw_intel_stop_bus(sdw, false);
491         if (ret < 0) {
492                 dev_err(dev, "%s: cannot stop bus: %d\n", __func__, ret);
493                 return ret;
494         }
495
496         return 0;
497 }
498
499 static int __maybe_unused intel_suspend_runtime(struct device *dev)
500 {
501         struct sdw_cdns *cdns = dev_get_drvdata(dev);
502         struct sdw_intel *sdw = cdns_to_intel(cdns);
503         struct sdw_bus *bus = &cdns->bus;
504         u32 clock_stop_quirks;
505         int ret;
506
507         if (bus->prop.hw_disabled || !sdw->startup_done) {
508                 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
509                         bus->link_id);
510                 return 0;
511         }
512
513         clock_stop_quirks = sdw->link_res->clock_stop_quirks;
514
515         if (clock_stop_quirks & SDW_INTEL_CLK_STOP_TEARDOWN) {
516                 ret = sdw_intel_stop_bus(sdw, false);
517                 if (ret < 0) {
518                         dev_err(dev, "%s: cannot stop bus during teardown: %d\n",
519                                 __func__, ret);
520                         return ret;
521                 }
522         } else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET || !clock_stop_quirks) {
523                 ret = sdw_intel_stop_bus(sdw, true);
524                 if (ret < 0) {
525                         dev_err(dev, "%s: cannot stop bus during clock_stop: %d\n",
526                                 __func__, ret);
527                         return ret;
528                 }
529         } else {
530                 dev_err(dev, "%s clock_stop_quirks %x unsupported\n",
531                         __func__, clock_stop_quirks);
532                 ret = -EINVAL;
533         }
534
535         return ret;
536 }
537
538 static int __maybe_unused intel_resume(struct device *dev)
539 {
540         struct sdw_cdns *cdns = dev_get_drvdata(dev);
541         struct sdw_intel *sdw = cdns_to_intel(cdns);
542         struct sdw_bus *bus = &cdns->bus;
543         int link_flags;
544         int ret;
545
546         if (bus->prop.hw_disabled || !sdw->startup_done) {
547                 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
548                         bus->link_id);
549                 return 0;
550         }
551
552         link_flags = md_flags >> (bus->link_id * 8);
553
554         if (pm_runtime_suspended(dev)) {
555                 dev_dbg(dev, "pm_runtime status was suspended, forcing active\n");
556
557                 /* follow required sequence from runtime_pm.rst */
558                 pm_runtime_disable(dev);
559                 pm_runtime_set_active(dev);
560                 pm_runtime_mark_last_busy(dev);
561                 pm_runtime_enable(dev);
562
563                 pm_runtime_resume(bus->dev);
564
565                 link_flags = md_flags >> (bus->link_id * 8);
566
567                 if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE))
568                         pm_runtime_idle(dev);
569         }
570
571         ret = sdw_intel_link_power_up(sdw);
572         if (ret) {
573                 dev_err(dev, "%s failed: %d\n", __func__, ret);
574                 return ret;
575         }
576
577         /*
578          * make sure all Slaves are tagged as UNATTACHED and provide
579          * reason for reinitialization
580          */
581         sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET);
582
583         ret = sdw_intel_start_bus(sdw);
584         if (ret < 0) {
585                 dev_err(dev, "cannot start bus during resume\n");
586                 sdw_intel_link_power_down(sdw);
587                 return ret;
588         }
589
590         /*
591          * after system resume, the pm_runtime suspend() may kick in
592          * during the enumeration, before any children device force the
593          * master device to remain active.  Using pm_runtime_get()
594          * routines is not really possible, since it'd prevent the
595          * master from suspending.
596          * A reasonable compromise is to update the pm_runtime
597          * counters and delay the pm_runtime suspend by several
598          * seconds, by when all enumeration should be complete.
599          */
600         pm_runtime_mark_last_busy(bus->dev);
601         pm_runtime_mark_last_busy(dev);
602
603         return 0;
604 }
605
606 static int __maybe_unused intel_resume_runtime(struct device *dev)
607 {
608         struct sdw_cdns *cdns = dev_get_drvdata(dev);
609         struct sdw_intel *sdw = cdns_to_intel(cdns);
610         struct sdw_bus *bus = &cdns->bus;
611         u32 clock_stop_quirks;
612         int ret;
613
614         if (bus->prop.hw_disabled || !sdw->startup_done) {
615                 dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
616                         bus->link_id);
617                 return 0;
618         }
619
620         /* unconditionally disable WAKEEN interrupt */
621         sdw_intel_shim_wake(sdw, false);
622
623         clock_stop_quirks = sdw->link_res->clock_stop_quirks;
624
625         if (clock_stop_quirks & SDW_INTEL_CLK_STOP_TEARDOWN) {
626                 ret = sdw_intel_link_power_up(sdw);
627                 if (ret) {
628                         dev_err(dev, "%s: power_up failed after teardown: %d\n", __func__, ret);
629                         return ret;
630                 }
631
632                 /*
633                  * make sure all Slaves are tagged as UNATTACHED and provide
634                  * reason for reinitialization
635                  */
636                 sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET);
637
638                 ret = sdw_intel_start_bus(sdw);
639                 if (ret < 0) {
640                         dev_err(dev, "%s: cannot start bus after teardown: %d\n", __func__, ret);
641                         sdw_intel_link_power_down(sdw);
642                         return ret;
643                 }
644
645         } else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) {
646                 ret = sdw_intel_link_power_up(sdw);
647                 if (ret) {
648                         dev_err(dev, "%s: power_up failed after bus reset: %d\n", __func__, ret);
649                         return ret;
650                 }
651
652                 ret = sdw_intel_start_bus_after_reset(sdw);
653                 if (ret < 0) {
654                         dev_err(dev, "%s: cannot start bus after reset: %d\n", __func__, ret);
655                         sdw_intel_link_power_down(sdw);
656                         return ret;
657                 }
658         } else if (!clock_stop_quirks) {
659
660                 sdw_intel_check_clock_stop(sdw);
661
662                 ret = sdw_intel_link_power_up(sdw);
663                 if (ret) {
664                         dev_err(dev, "%s: power_up failed: %d\n", __func__, ret);
665                         return ret;
666                 }
667
668                 ret = sdw_intel_start_bus_after_clock_stop(sdw);
669                 if (ret < 0) {
670                         dev_err(dev, "%s: cannot start bus after clock stop: %d\n", __func__, ret);
671                         sdw_intel_link_power_down(sdw);
672                         return ret;
673                 }
674         } else {
675                 dev_err(dev, "%s: clock_stop_quirks %x unsupported\n",
676                         __func__, clock_stop_quirks);
677                 ret = -EINVAL;
678         }
679
680         return ret;
681 }
682
683 static const struct dev_pm_ops intel_pm = {
684         .prepare = intel_pm_prepare,
685         SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
686         SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
687 };
688
689 static const struct auxiliary_device_id intel_link_id_table[] = {
690         { .name = "soundwire_intel.link" },
691         {},
692 };
693 MODULE_DEVICE_TABLE(auxiliary, intel_link_id_table);
694
695 static struct auxiliary_driver sdw_intel_drv = {
696         .probe = intel_link_probe,
697         .remove = intel_link_remove,
698         .driver = {
699                 /* auxiliary_driver_register() sets .name to be the modname */
700                 .pm = &intel_pm,
701         },
702         .id_table = intel_link_id_table
703 };
704 module_auxiliary_driver(sdw_intel_drv);
705
706 MODULE_LICENSE("Dual BSD/GPL");
707 MODULE_DESCRIPTION("Intel Soundwire Link Driver");