| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 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>
|
| 18 | #include "../intel/common/soc-intel-quirks.h"
|
| 19 | #include "ops.h"
|
| 20 | #include "sof-acpi-dev.h"
|
| 21 |
|
| 22 |
|
| 23 | #include "intel/shim.h"
|
| 24 |
|
| 25 | static char *fw_path;
|
| 26 | module_param(fw_path, charp, 0444);
|
| 27 | MODULE_PARM_DESC(fw_path, "deprecated - moved to snd-sof module.");
|
| 28 |
|
| 29 | static char *tplg_path;
|
| 30 | module_param(tplg_path, charp, 0444);
|
| 31 | MODULE_PARM_DESC(tplg_path, "deprecated - moved to snd-sof module.");
|
| 32 |
|
| 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 |
|
| 39 | EXPORT_NS_DEV_PM_OPS(sof_acpi_pm, SND_SOC_SOF_ACPI_DEV) = {
|
| 40 | SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume)
|
| 41 | RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume,
|
| 42 | snd_sof_runtime_idle)
|
| 43 | };
|
| 44 |
|
| 45 | static void sof_acpi_probe_complete(struct device *dev)
|
| 46 | {
|
| 47 | dev_dbg(dev, "Completing SOF ACPI probe");
|
| 48 |
|
| 49 | if (sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME)
|
| 50 | return;
|
| 51 |
|
| 52 |
|
| 53 | pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS);
|
| 54 | pm_runtime_use_autosuspend(dev);
|
| 55 | pm_runtime_enable(dev);
|
| 56 | }
|
| 57 |
|
| 58 | int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc)
|
| 59 | {
|
| 60 | struct device *dev = &pdev->dev;
|
| 61 | struct snd_sof_pdata *sof_pdata;
|
| 62 |
|
| 63 | dev_dbg(dev, "ACPI DSP detected");
|
| 64 |
|
| 65 | sof_pdata = devm_kzalloc(dev, sizeof(*sof_pdata), GFP_KERNEL);
|
| 66 | if (!sof_pdata)
|
| 67 | return -ENOMEM;
|
| 68 |
|
| 69 | if (!desc->ops) {
|
| 70 | dev_err(dev, "error: no matching ACPI descriptor ops\n");
|
| 71 | return -ENODEV;
|
| 72 | }
|
| 73 |
|
| 74 | sof_pdata->desc = desc;
|
| 75 | sof_pdata->dev = &pdev->dev;
|
| 76 |
|
| 77 | sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default;
|
| 78 | sof_pdata->ipc_file_profile_base.fw_path = fw_path;
|
| 79 | sof_pdata->ipc_file_profile_base.tplg_path = tplg_path;
|
| 80 |
|
| 81 |
|
| 82 | sof_pdata->sof_probe_complete = sof_acpi_probe_complete;
|
| 83 |
|
| 84 |
|
| 85 | return snd_sof_device_probe(dev, sof_pdata);
|
| 86 | }
|
| 87 | EXPORT_SYMBOL_NS(sof_acpi_probe, "SND_SOC_SOF_ACPI_DEV");
|
| 88 |
|
| 89 | void sof_acpi_remove(struct platform_device *pdev)
|
| 90 | {
|
| 91 | struct device *dev = &pdev->dev;
|
| 92 |
|
| 93 | if (!(sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME))
|
| 94 | pm_runtime_disable(dev);
|
| 95 |
|
| 96 |
|
| 97 | snd_sof_device_remove(dev);
|
| 98 | }
|
| 99 | EXPORT_SYMBOL_NS(sof_acpi_remove, "SND_SOC_SOF_ACPI_DEV");
|
| 100 |
|
| 101 | MODULE_LICENSE("Dual BSD/GPL");
|
| 102 | MODULE_DESCRIPTION("SOF support for ACPI platforms");
|