Commit | Line | Data |
---|---|---|
e149ca29 | 1 | // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) |
cd679898 LG |
2 | // |
3 | // This file is provided under a dual BSD/GPLv2 license. When using or | |
4 | // redistributing this file, you may do so under either license. | |
5 | // | |
6 | // Copyright(c) 2018 Intel Corporation. All rights reserved. | |
7 | // | |
8 | // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> | |
9 | // | |
10 | ||
11 | #include <linux/acpi.h> | |
12 | #include <linux/firmware.h> | |
13 | #include <linux/module.h> | |
14 | #include <linux/pm_runtime.h> | |
15 | #include <sound/soc-acpi.h> | |
16 | #include <sound/soc-acpi-intel-match.h> | |
17 | #include <sound/sof.h> | |
536cfd2f | 18 | #include "../intel/common/soc-intel-quirks.h" |
cd679898 | 19 | #include "ops.h" |
8a49cd11 | 20 | #include "sof-acpi-dev.h" |
cd679898 LG |
21 | |
22 | /* platform specific devices */ | |
23 | #include "intel/shim.h" | |
24 | ||
25 | static char *fw_path; | |
26 | module_param(fw_path, charp, 0444); | |
27 | MODULE_PARM_DESC(fw_path, "alternate path for SOF firmware."); | |
28 | ||
29 | static char *tplg_path; | |
30 | module_param(tplg_path, charp, 0444); | |
31 | MODULE_PARM_DESC(tplg_path, "alternate path for SOF topology."); | |
32 | ||
70b0c75a PLB |
33 | static int sof_acpi_debug; |
34 | module_param_named(sof_acpi_debug, sof_acpi_debug, int, 0444); | |
35 | MODULE_PARM_DESC(sof_acpi_debug, "SOF ACPI debug options (0x0 all off)"); | |
36 | ||
37 | #define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0) | |
38 | ||
8a49cd11 | 39 | const struct dev_pm_ops sof_acpi_pm = { |
cd679898 LG |
40 | SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume) |
41 | SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume, | |
62fde977 | 42 | snd_sof_runtime_idle) |
cd679898 | 43 | }; |
8a49cd11 | 44 | EXPORT_SYMBOL_NS(sof_acpi_pm, SND_SOC_SOF_ACPI_DEV); |
cd679898 LG |
45 | |
46 | static void sof_acpi_probe_complete(struct device *dev) | |
47 | { | |
71d551f5 PLB |
48 | dev_dbg(dev, "Completing SOF ACPI probe"); |
49 | ||
70b0c75a PLB |
50 | if (sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME) |
51 | return; | |
52 | ||
cd679898 LG |
53 | /* allow runtime_pm */ |
54 | pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS); | |
55 | pm_runtime_use_autosuspend(dev); | |
56 | pm_runtime_enable(dev); | |
57 | } | |
58 | ||
8a49cd11 | 59 | int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc) |
cd679898 LG |
60 | { |
61 | struct device *dev = &pdev->dev; | |
cd679898 | 62 | struct snd_sof_pdata *sof_pdata; |
cd679898 | 63 | |
f7313f9f | 64 | dev_dbg(dev, "ACPI DSP detected"); |
cd679898 LG |
65 | |
66 | sof_pdata = devm_kzalloc(dev, sizeof(*sof_pdata), GFP_KERNEL); | |
67 | if (!sof_pdata) | |
68 | return -ENOMEM; | |
69 | ||
fd979ec1 | 70 | if (!desc->ops) { |
cd679898 LG |
71 | dev_err(dev, "error: no matching ACPI descriptor ops\n"); |
72 | return -ENODEV; | |
73 | } | |
74 | ||
cd679898 LG |
75 | sof_pdata->desc = desc; |
76 | sof_pdata->dev = &pdev->dev; | |
cd679898 | 77 | |
a07625dc PU |
78 | sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; |
79 | sof_pdata->ipc_file_profile_base.fw_path = fw_path; | |
80 | sof_pdata->ipc_file_profile_base.tplg_path = tplg_path; | |
81 | ||
4d1284cd | 82 | /* set callback to be called on successful device probe to enable runtime_pm */ |
cd679898 | 83 | sof_pdata->sof_probe_complete = sof_acpi_probe_complete; |
cd679898 | 84 | |
4d1284cd PU |
85 | /* call sof helper for DSP hardware probe */ |
86 | return snd_sof_device_probe(dev, sof_pdata); | |
cd679898 | 87 | } |
8a49cd11 | 88 | EXPORT_SYMBOL_NS(sof_acpi_probe, SND_SOC_SOF_ACPI_DEV); |
cd679898 | 89 | |
52fee5c9 | 90 | void sof_acpi_remove(struct platform_device *pdev) |
cd679898 | 91 | { |
8a49cd11 AB |
92 | struct device *dev = &pdev->dev; |
93 | ||
70b0c75a | 94 | if (!(sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME)) |
8a49cd11 | 95 | pm_runtime_disable(dev); |
cd679898 LG |
96 | |
97 | /* call sof helper for DSP hardware remove */ | |
8a49cd11 | 98 | snd_sof_device_remove(dev); |
cd679898 | 99 | } |
8a49cd11 | 100 | EXPORT_SYMBOL_NS(sof_acpi_remove, SND_SOC_SOF_ACPI_DEV); |
cd679898 LG |
101 | |
102 | MODULE_LICENSE("Dual BSD/GPL"); |