1 // SPDX-License-Identifier: (GPL-2.0-only OR B 1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 2 // 2 // 3 // This file is provided under a dual BSD/GPLv 3 // This file is provided under a dual BSD/GPLv2 license. When using or 4 // redistributing this file, you may do so und 4 // redistributing this file, you may do so under either license. 5 // 5 // 6 // Copyright(c) 2018 Intel Corporation !! 6 // Copyright(c) 2018 Intel Corporation. All rights reserved. 7 // 7 // 8 // Author: Liam Girdwood <liam.r.girdwood@linu 8 // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> 9 // 9 // 10 10 11 #include <linux/acpi.h> 11 #include <linux/acpi.h> 12 #include <linux/firmware.h> 12 #include <linux/firmware.h> 13 #include <linux/module.h> 13 #include <linux/module.h> 14 #include <linux/pm_runtime.h> 14 #include <linux/pm_runtime.h> 15 #include <sound/soc-acpi.h> 15 #include <sound/soc-acpi.h> 16 #include <sound/soc-acpi-intel-match.h> 16 #include <sound/soc-acpi-intel-match.h> 17 #include <sound/sof.h> 17 #include <sound/sof.h> 18 #include "../intel/common/soc-intel-quirks.h" 18 #include "../intel/common/soc-intel-quirks.h" 19 #include "ops.h" 19 #include "ops.h" 20 #include "sof-acpi-dev.h" 20 #include "sof-acpi-dev.h" 21 21 22 /* platform specific devices */ 22 /* platform specific devices */ 23 #include "intel/shim.h" 23 #include "intel/shim.h" 24 24 25 static char *fw_path; 25 static char *fw_path; 26 module_param(fw_path, charp, 0444); 26 module_param(fw_path, charp, 0444); 27 MODULE_PARM_DESC(fw_path, "alternate path for 27 MODULE_PARM_DESC(fw_path, "alternate path for SOF firmware."); 28 28 29 static char *tplg_path; 29 static char *tplg_path; 30 module_param(tplg_path, charp, 0444); 30 module_param(tplg_path, charp, 0444); 31 MODULE_PARM_DESC(tplg_path, "alternate path fo 31 MODULE_PARM_DESC(tplg_path, "alternate path for SOF topology."); 32 32 33 static int sof_acpi_debug; 33 static int sof_acpi_debug; 34 module_param_named(sof_acpi_debug, sof_acpi_de 34 module_param_named(sof_acpi_debug, sof_acpi_debug, int, 0444); 35 MODULE_PARM_DESC(sof_acpi_debug, "SOF ACPI deb 35 MODULE_PARM_DESC(sof_acpi_debug, "SOF ACPI debug options (0x0 all off)"); 36 36 37 #define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0) 37 #define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0) 38 38 39 const struct dev_pm_ops sof_acpi_pm = { 39 const struct dev_pm_ops sof_acpi_pm = { 40 SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspen 40 SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume) 41 SET_RUNTIME_PM_OPS(snd_sof_runtime_sus 41 SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume, 42 snd_sof_runtime_idl 42 snd_sof_runtime_idle) 43 }; 43 }; 44 EXPORT_SYMBOL_NS(sof_acpi_pm, SND_SOC_SOF_ACPI 44 EXPORT_SYMBOL_NS(sof_acpi_pm, SND_SOC_SOF_ACPI_DEV); 45 45 46 static void sof_acpi_probe_complete(struct dev 46 static void sof_acpi_probe_complete(struct device *dev) 47 { 47 { 48 dev_dbg(dev, "Completing SOF ACPI prob 48 dev_dbg(dev, "Completing SOF ACPI probe"); 49 49 50 if (sof_acpi_debug & SOF_ACPI_DISABLE_ 50 if (sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME) 51 return; 51 return; 52 52 53 /* allow runtime_pm */ 53 /* allow runtime_pm */ 54 pm_runtime_set_autosuspend_delay(dev, 54 pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS); 55 pm_runtime_use_autosuspend(dev); 55 pm_runtime_use_autosuspend(dev); 56 pm_runtime_enable(dev); 56 pm_runtime_enable(dev); 57 } 57 } 58 58 59 int sof_acpi_probe(struct platform_device *pde 59 int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc) 60 { 60 { 61 struct device *dev = &pdev->dev; 61 struct device *dev = &pdev->dev; 62 struct snd_sof_pdata *sof_pdata; 62 struct snd_sof_pdata *sof_pdata; >> 63 const struct snd_sof_dsp_ops *ops; 63 64 64 dev_dbg(dev, "ACPI DSP detected"); 65 dev_dbg(dev, "ACPI DSP detected"); 65 66 66 sof_pdata = devm_kzalloc(dev, sizeof(* 67 sof_pdata = devm_kzalloc(dev, sizeof(*sof_pdata), GFP_KERNEL); 67 if (!sof_pdata) 68 if (!sof_pdata) 68 return -ENOMEM; 69 return -ENOMEM; 69 70 70 if (!desc->ops) { !! 71 /* get ops for platform */ >> 72 ops = desc->ops; >> 73 if (!ops) { 71 dev_err(dev, "error: no matchi 74 dev_err(dev, "error: no matching ACPI descriptor ops\n"); 72 return -ENODEV; 75 return -ENODEV; 73 } 76 } 74 77 75 sof_pdata->desc = desc; 78 sof_pdata->desc = desc; 76 sof_pdata->dev = &pdev->dev; 79 sof_pdata->dev = &pdev->dev; >> 80 sof_pdata->fw_filename = desc->default_fw_filename; 77 81 78 sof_pdata->ipc_file_profile_base.ipc_t !! 82 /* alternate fw and tplg filenames ? */ 79 sof_pdata->ipc_file_profile_base.fw_pa !! 83 if (fw_path) 80 sof_pdata->ipc_file_profile_base.tplg_ !! 84 sof_pdata->fw_filename_prefix = fw_path; >> 85 else >> 86 sof_pdata->fw_filename_prefix = >> 87 sof_pdata->desc->default_fw_path; >> 88 >> 89 if (tplg_path) >> 90 sof_pdata->tplg_filename_prefix = tplg_path; >> 91 else >> 92 sof_pdata->tplg_filename_prefix = >> 93 sof_pdata->desc->default_tplg_path; 81 94 82 /* set callback to be called on succes 95 /* set callback to be called on successful device probe to enable runtime_pm */ 83 sof_pdata->sof_probe_complete = sof_ac 96 sof_pdata->sof_probe_complete = sof_acpi_probe_complete; 84 97 85 /* call sof helper for DSP hardware pr 98 /* call sof helper for DSP hardware probe */ 86 return snd_sof_device_probe(dev, sof_p 99 return snd_sof_device_probe(dev, sof_pdata); 87 } 100 } 88 EXPORT_SYMBOL_NS(sof_acpi_probe, SND_SOC_SOF_A 101 EXPORT_SYMBOL_NS(sof_acpi_probe, SND_SOC_SOF_ACPI_DEV); 89 102 90 void sof_acpi_remove(struct platform_device *p !! 103 int sof_acpi_remove(struct platform_device *pdev) 91 { 104 { 92 struct device *dev = &pdev->dev; 105 struct device *dev = &pdev->dev; 93 106 94 if (!(sof_acpi_debug & SOF_ACPI_DISABL 107 if (!(sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME)) 95 pm_runtime_disable(dev); 108 pm_runtime_disable(dev); 96 109 97 /* call sof helper for DSP hardware re 110 /* call sof helper for DSP hardware remove */ 98 snd_sof_device_remove(dev); 111 snd_sof_device_remove(dev); >> 112 >> 113 return 0; 99 } 114 } 100 EXPORT_SYMBOL_NS(sof_acpi_remove, SND_SOC_SOF_ 115 EXPORT_SYMBOL_NS(sof_acpi_remove, SND_SOC_SOF_ACPI_DEV); 101 116 102 MODULE_LICENSE("Dual BSD/GPL"); 117 MODULE_LICENSE("Dual BSD/GPL"); 103 MODULE_DESCRIPTION("SOF support for ACPI platf << 104 118
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.