1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 // Copyright(c) 2015-22 Intel Corporation.
5 * Soundwire Intel Manager Driver
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>
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"
24 #include "intel_auxdevice.h"
26 #define INTEL_MASTER_SUSPEND_DELAY_MS 3000
29 * debug/config flags for the Intel SoundWire Master.
31 * Since we may have multiple masters active, we can have up to 8
32 * flags reused in each byte, with master0 using the ls-byte, etc.
35 #define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME BIT(0)
36 #define SDW_INTEL_MASTER_DISABLE_CLOCK_STOP BIT(1)
37 #define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE BIT(2)
38 #define SDW_INTEL_MASTER_DISABLE_MULTI_LINK BIT(3)
41 module_param_named(sdw_md_flags
, md_flags
, int, 0444);
42 MODULE_PARM_DESC(sdw_md_flags
, "SoundWire Intel Master device flags (0x0 all off)");
44 static int mclk_divider
;
45 module_param_named(sdw_mclk_divider
, mclk_divider
, int, 0444);
46 MODULE_PARM_DESC(sdw_mclk_divider
, "SoundWire Intel mclk divider");
48 struct wake_capable_part
{
53 static struct wake_capable_part wake_capable_list
[] = {
71 static bool is_wake_capable(struct sdw_slave
*slave
)
75 for (i
= 0; i
< ARRAY_SIZE(wake_capable_list
); i
++)
76 if (slave
->id
.part_id
== wake_capable_list
[i
].part_id
&&
77 slave
->id
.mfg_id
== wake_capable_list
[i
].mfg_id
)
82 static int generic_pre_bank_switch(struct sdw_bus
*bus
)
84 struct sdw_cdns
*cdns
= bus_to_cdns(bus
);
85 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
87 return sdw
->link_res
->hw_ops
->pre_bank_switch(sdw
);
90 static int generic_post_bank_switch(struct sdw_bus
*bus
)
92 struct sdw_cdns
*cdns
= bus_to_cdns(bus
);
93 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
95 return sdw
->link_res
->hw_ops
->post_bank_switch(sdw
);
98 static void generic_new_peripheral_assigned(struct sdw_bus
*bus
,
99 struct sdw_slave
*slave
,
102 struct sdw_cdns
*cdns
= bus_to_cdns(bus
);
103 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
106 bool wake_capable
= slave
->prop
.wake_capable
|| is_wake_capable(slave
);
109 dev_num_min
= SDW_INTEL_DEV_NUM_IDA_MIN
;
110 dev_num_max
= SDW_MAX_DEVICES
;
113 dev_num_max
= SDW_INTEL_DEV_NUM_IDA_MIN
- 1;
116 /* paranoia check, this should never happen */
117 if (dev_num
< dev_num_min
|| dev_num
> dev_num_max
) {
118 dev_err(bus
->dev
, "%s: invalid dev_num %d, wake supported %d\n",
119 __func__
, dev_num
, slave
->prop
.wake_capable
);
123 if (sdw
->link_res
->hw_ops
->program_sdi
&& wake_capable
)
124 sdw
->link_res
->hw_ops
->program_sdi(sdw
, dev_num
);
127 static int sdw_master_read_intel_prop(struct sdw_bus
*bus
)
129 struct sdw_master_prop
*prop
= &bus
->prop
;
130 struct sdw_intel_prop
*intel_prop
;
131 struct fwnode_handle
*link
;
135 /* Find master handle */
136 snprintf(name
, sizeof(name
),
137 "mipi-sdw-link-%d-subproperties", bus
->link_id
);
139 link
= device_get_named_child_node(bus
->dev
, name
);
141 dev_err(bus
->dev
, "Master node %s not found\n", name
);
145 fwnode_property_read_u32(link
,
146 "intel-sdw-ip-clock",
150 /* use kernel parameter for BIOS or board work-arounds */
151 prop
->mclk_freq
/= mclk_divider
;
153 /* the values reported by BIOS are the 2x clock, not the bus clock */
154 prop
->mclk_freq
/= 2;
156 fwnode_property_read_u32(link
,
160 if (quirk_mask
& SDW_INTEL_QUIRK_MASK_BUS_DISABLE
)
161 prop
->hw_disabled
= true;
163 prop
->quirks
= SDW_MASTER_QUIRKS_CLEAR_INITIAL_CLASH
|
164 SDW_MASTER_QUIRKS_CLEAR_INITIAL_PARITY
;
166 intel_prop
= devm_kzalloc(bus
->dev
, sizeof(*intel_prop
), GFP_KERNEL
);
168 fwnode_handle_put(link
);
172 /* initialize with hardware defaults, in case the properties are not found */
173 intel_prop
->clde
= 0x0;
174 intel_prop
->doaise2
= 0x0;
175 intel_prop
->dodse2
= 0x0;
176 intel_prop
->clds
= 0x0;
177 intel_prop
->clss
= 0x0;
178 intel_prop
->doaise
= 0x1;
179 intel_prop
->doais
= 0x3;
180 intel_prop
->dodse
= 0x0;
181 intel_prop
->dods
= 0x1;
183 fwnode_property_read_u16(link
,
186 fwnode_property_read_u16(link
,
188 &intel_prop
->doaise2
);
189 fwnode_property_read_u16(link
,
191 &intel_prop
->dodse2
);
192 fwnode_property_read_u16(link
,
195 fwnode_property_read_u16(link
,
198 fwnode_property_read_u16(link
,
200 &intel_prop
->doaise
);
201 fwnode_property_read_u16(link
,
204 fwnode_property_read_u16(link
,
207 fwnode_property_read_u16(link
,
210 bus
->vendor_specific_prop
= intel_prop
;
212 dev_dbg(bus
->dev
, "doaise %#x doais %#x dodse %#x dods %#x\n",
218 fwnode_handle_put(link
);
223 static int intel_prop_read(struct sdw_bus
*bus
)
225 struct sdw_master_prop
*prop
;
227 /* Initialize with default handler to read all DisCo properties */
228 sdw_master_read_prop(bus
);
231 * Only one bus frequency is supported so far, filter
232 * frequencies reported in the DSDT
235 if (prop
->clk_freq
&& prop
->num_clk_freq
> 1) {
236 unsigned int default_bus_frequency
;
238 default_bus_frequency
=
239 prop
->default_frame_rate
*
242 SDW_DOUBLE_RATE_FACTOR
;
244 prop
->num_clk_freq
= 1;
245 prop
->clk_freq
[0] = default_bus_frequency
;
246 prop
->max_clk_freq
= default_bus_frequency
;
249 /* read Intel-specific properties */
250 sdw_master_read_intel_prop(bus
);
255 static DEFINE_IDA(intel_peripheral_ida
);
257 static int intel_get_device_num_ida(struct sdw_bus
*bus
, struct sdw_slave
*slave
)
261 if (slave
->prop
.wake_capable
|| is_wake_capable(slave
))
262 return ida_alloc_range(&intel_peripheral_ida
,
263 SDW_INTEL_DEV_NUM_IDA_MIN
, SDW_MAX_DEVICES
,
266 bit
= find_first_zero_bit(slave
->bus
->assigned
, SDW_MAX_DEVICES
);
267 if (bit
== SDW_MAX_DEVICES
)
273 static void intel_put_device_num_ida(struct sdw_bus
*bus
, struct sdw_slave
*slave
)
275 if (slave
->prop
.wake_capable
|| is_wake_capable(slave
))
276 ida_free(&intel_peripheral_ida
, slave
->dev_num
);
279 static struct sdw_master_ops sdw_intel_ops
= {
280 .read_prop
= intel_prop_read
,
281 .override_adr
= sdw_dmi_override_adr
,
282 .xfer_msg
= cdns_xfer_msg
,
283 .xfer_msg_defer
= cdns_xfer_msg_defer
,
284 .set_bus_conf
= cdns_bus_conf
,
285 .pre_bank_switch
= generic_pre_bank_switch
,
286 .post_bank_switch
= generic_post_bank_switch
,
287 .read_ping_status
= cdns_read_ping_status
,
288 .get_device_num
= intel_get_device_num_ida
,
289 .put_device_num
= intel_put_device_num_ida
,
290 .new_peripheral_assigned
= generic_new_peripheral_assigned
,
294 * probe and init (aux_dev_id argument is required by function prototype but not used)
296 static int intel_link_probe(struct auxiliary_device
*auxdev
,
297 const struct auxiliary_device_id
*aux_dev_id
)
300 struct device
*dev
= &auxdev
->dev
;
301 struct sdw_intel_link_dev
*ldev
= auxiliary_dev_to_sdw_intel_link_dev(auxdev
);
302 struct sdw_intel
*sdw
;
303 struct sdw_cdns
*cdns
;
307 sdw
= devm_kzalloc(dev
, sizeof(*sdw
), GFP_KERNEL
);
314 sdw
->instance
= auxdev
->id
;
315 sdw
->link_res
= &ldev
->link_res
;
317 cdns
->registers
= sdw
->link_res
->registers
;
318 cdns
->ip_offset
= sdw
->link_res
->ip_offset
;
319 cdns
->instance
= sdw
->instance
;
322 /* single controller for all SoundWire links */
323 bus
->controller_id
= 0;
325 bus
->link_id
= auxdev
->id
;
326 bus
->clk_stop_timeout
= 1;
329 * paranoia check: make sure ACPI-reported number of links is aligned with
330 * hardware capabilities.
332 ret
= sdw_intel_get_link_count(sdw
);
334 dev_err(dev
, "%s: sdw_intel_get_link_count failed: %d\n", __func__
, ret
);
337 if (ret
<= sdw
->instance
) {
338 dev_err(dev
, "%s: invalid link id %d, link count %d\n", __func__
, auxdev
->id
, ret
);
342 sdw_cdns_probe(cdns
);
345 bus
->ops
= &sdw_intel_ops
;
347 /* set driver data, accessed by snd_soc_dai_get_drvdata() */
348 auxiliary_set_drvdata(auxdev
, cdns
);
350 /* use generic bandwidth allocation algorithm */
351 sdw
->cdns
.bus
.compute_params
= sdw_compute_params
;
353 /* avoid resuming from pm_runtime suspend if it's not required */
354 dev_pm_set_driver_flags(dev
, DPM_FLAG_SMART_SUSPEND
);
356 ret
= sdw_bus_master_add(bus
, dev
, dev
->fwnode
);
358 dev_err(dev
, "sdw_bus_master_add fail: %d\n", ret
);
362 if (bus
->prop
.hw_disabled
)
364 "SoundWire master %d is disabled, will be ignored\n",
367 * Ignore BIOS err_threshold, it's a really bad idea when dealing
368 * with multiple hardware synchronized links
370 bus
->prop
.err_threshold
= 0;
375 int intel_link_startup(struct auxiliary_device
*auxdev
)
377 struct device
*dev
= &auxdev
->dev
;
378 struct sdw_cdns
*cdns
= auxiliary_get_drvdata(auxdev
);
379 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
380 struct sdw_bus
*bus
= &cdns
->bus
;
383 u32 clock_stop_quirks
;
386 if (bus
->prop
.hw_disabled
) {
388 "SoundWire master %d is disabled, ignoring\n",
393 link_flags
= md_flags
>> (bus
->link_id
* 8);
394 multi_link
= !(link_flags
& SDW_INTEL_MASTER_DISABLE_MULTI_LINK
);
396 dev_dbg(dev
, "Multi-link is disabled\n");
399 * hardware-based synchronization is required regardless
400 * of the number of segments used by a stream: SSP-based
401 * synchronization is gated by gsync when the multi-master
404 bus
->hw_sync_min_links
= 1;
406 bus
->multi_link
= multi_link
;
408 /* Initialize shim, controller */
409 ret
= sdw_intel_link_power_up(sdw
);
414 ret
= sdw_intel_register_dai(sdw
);
416 dev_err(dev
, "DAI registration failed: %d\n", ret
);
420 sdw_intel_debugfs_init(sdw
);
422 /* Enable runtime PM */
423 if (!(link_flags
& SDW_INTEL_MASTER_DISABLE_PM_RUNTIME
)) {
424 pm_runtime_set_autosuspend_delay(dev
,
425 INTEL_MASTER_SUSPEND_DELAY_MS
);
426 pm_runtime_use_autosuspend(dev
);
427 pm_runtime_mark_last_busy(dev
);
429 pm_runtime_set_active(dev
);
430 pm_runtime_enable(dev
);
432 pm_runtime_resume(bus
->dev
);
436 ret
= sdw_intel_start_bus(sdw
);
438 dev_err(dev
, "bus start failed: %d\n", ret
);
442 clock_stop_quirks
= sdw
->link_res
->clock_stop_quirks
;
443 if (clock_stop_quirks
& SDW_INTEL_CLK_STOP_NOT_ALLOWED
) {
445 * To keep the clock running we need to prevent
446 * pm_runtime suspend from happening by increasing the
448 * This quirk is specified by the parent PCI device in
449 * case of specific latency requirements. It will have
450 * no effect if pm_runtime is disabled by the user via
451 * a module parameter for testing purposes.
453 pm_runtime_get_noresume(dev
);
457 * The runtime PM status of Slave devices is "Unsupported"
458 * until they report as ATTACHED. If they don't, e.g. because
459 * there are no Slave devices populated or if the power-on is
460 * delayed or dependent on a power switch, the Master will
461 * remain active and prevent its parent from suspending.
463 * Conditionally force the pm_runtime core to re-evaluate the
464 * Master status in the absence of any Slave activity. A quirk
465 * is provided to e.g. deal with Slaves that may be powered on
466 * with a delay. A more complete solution would require the
467 * definition of Master properties.
469 if (!(link_flags
& SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE
)) {
470 pm_runtime_mark_last_busy(bus
->dev
);
471 pm_runtime_mark_last_busy(dev
);
472 pm_runtime_idle(dev
);
475 sdw
->startup_done
= true;
479 if (!(link_flags
& SDW_INTEL_MASTER_DISABLE_PM_RUNTIME
))
480 pm_runtime_disable(dev
);
482 sdw_intel_link_power_down(sdw
);
487 static void intel_link_remove(struct auxiliary_device
*auxdev
)
489 struct sdw_cdns
*cdns
= auxiliary_get_drvdata(auxdev
);
490 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
491 struct sdw_bus
*bus
= &cdns
->bus
;
494 * Since pm_runtime is already disabled, we don't decrease
495 * the refcount when the clock_stop_quirk is
496 * SDW_INTEL_CLK_STOP_NOT_ALLOWED
498 if (!bus
->prop
.hw_disabled
) {
499 sdw_intel_debugfs_exit(sdw
);
500 cancel_delayed_work_sync(&cdns
->attach_dwork
);
501 sdw_cdns_enable_interrupt(cdns
, false);
503 sdw_bus_master_delete(bus
);
506 int intel_link_process_wakeen_event(struct auxiliary_device
*auxdev
)
508 struct device
*dev
= &auxdev
->dev
;
509 struct sdw_intel
*sdw
;
512 sdw
= auxiliary_get_drvdata(auxdev
);
513 bus
= &sdw
->cdns
.bus
;
515 if (bus
->prop
.hw_disabled
|| !sdw
->startup_done
) {
516 dev_dbg(dev
, "SoundWire master %d is disabled or not-started, ignoring\n",
521 if (!sdw_intel_shim_check_wake(sdw
))
524 /* disable WAKEEN interrupt ASAP to prevent interrupt flood */
525 sdw_intel_shim_wake(sdw
, false);
528 * resume the Master, which will generate a bus reset and result in
529 * Slaves re-attaching and be re-enumerated. The SoundWire physical
530 * device which generated the wake will trigger an interrupt, which
531 * will in turn cause the corresponding Linux Slave device to be
532 * resumed and the Slave codec driver to check the status.
534 pm_request_resume(dev
);
543 int intel_resume_child_device(struct device
*dev
, void *data
)
546 struct sdw_slave
*slave
= dev_to_sdw_dev(dev
);
548 if (!slave
->probed
) {
549 dev_dbg(dev
, "skipping device, no probed driver\n");
552 if (!slave
->dev_num_sticky
) {
553 dev_dbg(dev
, "skipping device, never detected on bus\n");
557 ret
= pm_runtime_resume(dev
);
559 dev_err(dev
, "%s: pm_runtime_resume failed: %d\n", __func__
, ret
);
566 static int __maybe_unused
intel_pm_prepare(struct device
*dev
)
568 struct sdw_cdns
*cdns
= dev_get_drvdata(dev
);
569 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
570 struct sdw_bus
*bus
= &cdns
->bus
;
571 u32 clock_stop_quirks
;
574 if (bus
->prop
.hw_disabled
|| !sdw
->startup_done
) {
575 dev_dbg(dev
, "SoundWire master %d is disabled or not-started, ignoring\n",
580 clock_stop_quirks
= sdw
->link_res
->clock_stop_quirks
;
582 if (pm_runtime_suspended(dev
) &&
583 pm_runtime_suspended(dev
->parent
) &&
584 ((clock_stop_quirks
& SDW_INTEL_CLK_STOP_BUS_RESET
) ||
585 !clock_stop_quirks
)) {
587 * if we've enabled clock stop, and the parent is suspended, the SHIM registers
588 * are not accessible and the shim wake cannot be disabled.
589 * The only solution is to resume the entire bus to full power
593 * If any operation in this block fails, we keep going since we don't want
594 * to prevent system suspend from happening and errors should be recoverable
599 * first resume the device for this link. This will also by construction
600 * resume the PCI parent device.
602 ret
= pm_runtime_resume(dev
);
604 dev_err(dev
, "%s: pm_runtime_resume failed: %d\n", __func__
, ret
);
609 * Continue resuming the entire bus (parent + child devices) to exit
610 * the clock stop mode. If there are no devices connected on this link
612 * The resume to full power could have been implemented with a .prepare
613 * step in SoundWire codec drivers. This would however require a lot
614 * of code to handle an Intel-specific corner case. It is simpler in
615 * practice to add a loop at the link level.
617 ret
= device_for_each_child(bus
->dev
, NULL
, intel_resume_child_device
);
620 dev_err(dev
, "%s: intel_resume_child_device failed: %d\n", __func__
, ret
);
626 static int __maybe_unused
intel_suspend(struct device
*dev
)
628 struct sdw_cdns
*cdns
= dev_get_drvdata(dev
);
629 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
630 struct sdw_bus
*bus
= &cdns
->bus
;
631 u32 clock_stop_quirks
;
634 if (bus
->prop
.hw_disabled
|| !sdw
->startup_done
) {
635 dev_dbg(dev
, "SoundWire master %d is disabled or not-started, ignoring\n",
640 if (pm_runtime_suspended(dev
)) {
641 dev_dbg(dev
, "pm_runtime status: suspended\n");
643 clock_stop_quirks
= sdw
->link_res
->clock_stop_quirks
;
645 if ((clock_stop_quirks
& SDW_INTEL_CLK_STOP_BUS_RESET
) ||
646 !clock_stop_quirks
) {
648 if (pm_runtime_suspended(dev
->parent
)) {
650 * paranoia check: this should not happen with the .prepare
651 * resume to full power
653 dev_err(dev
, "%s: invalid config: parent is suspended\n", __func__
);
655 sdw_intel_shim_wake(sdw
, false);
662 ret
= sdw_intel_stop_bus(sdw
, false);
664 dev_err(dev
, "%s: cannot stop bus: %d\n", __func__
, ret
);
671 static int __maybe_unused
intel_suspend_runtime(struct device
*dev
)
673 struct sdw_cdns
*cdns
= dev_get_drvdata(dev
);
674 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
675 struct sdw_bus
*bus
= &cdns
->bus
;
676 u32 clock_stop_quirks
;
679 if (bus
->prop
.hw_disabled
|| !sdw
->startup_done
) {
680 dev_dbg(dev
, "SoundWire master %d is disabled or not-started, ignoring\n",
685 clock_stop_quirks
= sdw
->link_res
->clock_stop_quirks
;
687 if (clock_stop_quirks
& SDW_INTEL_CLK_STOP_TEARDOWN
) {
688 ret
= sdw_intel_stop_bus(sdw
, false);
690 dev_err(dev
, "%s: cannot stop bus during teardown: %d\n",
694 } else if (clock_stop_quirks
& SDW_INTEL_CLK_STOP_BUS_RESET
|| !clock_stop_quirks
) {
695 ret
= sdw_intel_stop_bus(sdw
, true);
697 dev_err(dev
, "%s: cannot stop bus during clock_stop: %d\n",
702 dev_err(dev
, "%s clock_stop_quirks %x unsupported\n",
703 __func__
, clock_stop_quirks
);
710 static int __maybe_unused
intel_resume(struct device
*dev
)
712 struct sdw_cdns
*cdns
= dev_get_drvdata(dev
);
713 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
714 struct sdw_bus
*bus
= &cdns
->bus
;
718 if (bus
->prop
.hw_disabled
|| !sdw
->startup_done
) {
719 dev_dbg(dev
, "SoundWire master %d is disabled or not-started, ignoring\n",
724 if (pm_runtime_suspended(dev
)) {
725 dev_dbg(dev
, "pm_runtime status was suspended, forcing active\n");
727 /* follow required sequence from runtime_pm.rst */
728 pm_runtime_disable(dev
);
729 pm_runtime_set_active(dev
);
730 pm_runtime_mark_last_busy(dev
);
731 pm_runtime_enable(dev
);
733 pm_runtime_resume(bus
->dev
);
735 link_flags
= md_flags
>> (bus
->link_id
* 8);
737 if (!(link_flags
& SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE
))
738 pm_runtime_idle(dev
);
741 ret
= sdw_intel_link_power_up(sdw
);
743 dev_err(dev
, "%s failed: %d\n", __func__
, ret
);
748 * make sure all Slaves are tagged as UNATTACHED and provide
749 * reason for reinitialization
751 sdw_clear_slave_status(bus
, SDW_UNATTACH_REQUEST_MASTER_RESET
);
753 ret
= sdw_intel_start_bus(sdw
);
755 dev_err(dev
, "cannot start bus during resume\n");
756 sdw_intel_link_power_down(sdw
);
761 * after system resume, the pm_runtime suspend() may kick in
762 * during the enumeration, before any children device force the
763 * master device to remain active. Using pm_runtime_get()
764 * routines is not really possible, since it'd prevent the
765 * master from suspending.
766 * A reasonable compromise is to update the pm_runtime
767 * counters and delay the pm_runtime suspend by several
768 * seconds, by when all enumeration should be complete.
770 pm_runtime_mark_last_busy(bus
->dev
);
771 pm_runtime_mark_last_busy(dev
);
776 static int __maybe_unused
intel_resume_runtime(struct device
*dev
)
778 struct sdw_cdns
*cdns
= dev_get_drvdata(dev
);
779 struct sdw_intel
*sdw
= cdns_to_intel(cdns
);
780 struct sdw_bus
*bus
= &cdns
->bus
;
781 u32 clock_stop_quirks
;
784 if (bus
->prop
.hw_disabled
|| !sdw
->startup_done
) {
785 dev_dbg(dev
, "SoundWire master %d is disabled or not-started, ignoring\n",
790 /* unconditionally disable WAKEEN interrupt */
791 sdw_intel_shim_wake(sdw
, false);
793 clock_stop_quirks
= sdw
->link_res
->clock_stop_quirks
;
795 if (clock_stop_quirks
& SDW_INTEL_CLK_STOP_TEARDOWN
) {
796 ret
= sdw_intel_link_power_up(sdw
);
798 dev_err(dev
, "%s: power_up failed after teardown: %d\n", __func__
, ret
);
803 * make sure all Slaves are tagged as UNATTACHED and provide
804 * reason for reinitialization
806 sdw_clear_slave_status(bus
, SDW_UNATTACH_REQUEST_MASTER_RESET
);
808 ret
= sdw_intel_start_bus(sdw
);
810 dev_err(dev
, "%s: cannot start bus after teardown: %d\n", __func__
, ret
);
811 sdw_intel_link_power_down(sdw
);
815 } else if (clock_stop_quirks
& SDW_INTEL_CLK_STOP_BUS_RESET
) {
816 ret
= sdw_intel_link_power_up(sdw
);
818 dev_err(dev
, "%s: power_up failed after bus reset: %d\n", __func__
, ret
);
822 ret
= sdw_intel_start_bus_after_reset(sdw
);
824 dev_err(dev
, "%s: cannot start bus after reset: %d\n", __func__
, ret
);
825 sdw_intel_link_power_down(sdw
);
828 } else if (!clock_stop_quirks
) {
830 sdw_intel_check_clock_stop(sdw
);
832 ret
= sdw_intel_link_power_up(sdw
);
834 dev_err(dev
, "%s: power_up failed: %d\n", __func__
, ret
);
838 ret
= sdw_intel_start_bus_after_clock_stop(sdw
);
840 dev_err(dev
, "%s: cannot start bus after clock stop: %d\n", __func__
, ret
);
841 sdw_intel_link_power_down(sdw
);
845 dev_err(dev
, "%s: clock_stop_quirks %x unsupported\n",
846 __func__
, clock_stop_quirks
);
853 static const struct dev_pm_ops intel_pm
= {
854 .prepare
= intel_pm_prepare
,
855 SET_SYSTEM_SLEEP_PM_OPS(intel_suspend
, intel_resume
)
856 SET_RUNTIME_PM_OPS(intel_suspend_runtime
, intel_resume_runtime
, NULL
)
859 static const struct auxiliary_device_id intel_link_id_table
[] = {
860 { .name
= "soundwire_intel.link" },
863 MODULE_DEVICE_TABLE(auxiliary
, intel_link_id_table
);
865 static struct auxiliary_driver sdw_intel_drv
= {
866 .probe
= intel_link_probe
,
867 .remove
= intel_link_remove
,
869 /* auxiliary_driver_register() sets .name to be the modname */
872 .id_table
= intel_link_id_table
874 module_auxiliary_driver(sdw_intel_drv
);
876 MODULE_LICENSE("Dual BSD/GPL");
877 MODULE_DESCRIPTION("Intel Soundwire Link Driver");