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" << 21 20 22 /* platform specific devices */ 21 /* platform specific devices */ 23 #include "intel/shim.h" 22 #include "intel/shim.h" 24 23 25 static char *fw_path; 24 static char *fw_path; 26 module_param(fw_path, charp, 0444); 25 module_param(fw_path, charp, 0444); 27 MODULE_PARM_DESC(fw_path, "alternate path for 26 MODULE_PARM_DESC(fw_path, "alternate path for SOF firmware."); 28 27 29 static char *tplg_path; 28 static char *tplg_path; 30 module_param(tplg_path, charp, 0444); 29 module_param(tplg_path, charp, 0444); 31 MODULE_PARM_DESC(tplg_path, "alternate path fo 30 MODULE_PARM_DESC(tplg_path, "alternate path for SOF topology."); 32 31 33 static int sof_acpi_debug; 32 static int sof_acpi_debug; 34 module_param_named(sof_acpi_debug, sof_acpi_de 33 module_param_named(sof_acpi_debug, sof_acpi_debug, int, 0444); 35 MODULE_PARM_DESC(sof_acpi_debug, "SOF ACPI deb 34 MODULE_PARM_DESC(sof_acpi_debug, "SOF ACPI debug options (0x0 all off)"); 36 35 37 #define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0) 36 #define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0) 38 37 39 const struct dev_pm_ops sof_acpi_pm = { !! 38 #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) >> 39 static const struct sof_dev_desc sof_acpi_broadwell_desc = { >> 40 .machines = snd_soc_acpi_intel_broadwell_machines, >> 41 .resindex_lpe_base = 0, >> 42 .resindex_pcicfg_base = 1, >> 43 .resindex_imr_base = -1, >> 44 .irqindex_host_ipc = 0, >> 45 .chip_info = &bdw_chip_info, >> 46 .default_fw_path = "intel/sof", >> 47 .default_tplg_path = "intel/sof-tplg", >> 48 .default_fw_filename = "sof-bdw.ri", >> 49 .nocodec_tplg_filename = "sof-bdw-nocodec.tplg", >> 50 .ops = &sof_bdw_ops, >> 51 }; >> 52 #endif >> 53 >> 54 #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL) >> 55 >> 56 /* BYTCR uses different IRQ index */ >> 57 static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { >> 58 .machines = snd_soc_acpi_intel_baytrail_machines, >> 59 .resindex_lpe_base = 0, >> 60 .resindex_pcicfg_base = 1, >> 61 .resindex_imr_base = 2, >> 62 .irqindex_host_ipc = 0, >> 63 .chip_info = &byt_chip_info, >> 64 .default_fw_path = "intel/sof", >> 65 .default_tplg_path = "intel/sof-tplg", >> 66 .default_fw_filename = "sof-byt.ri", >> 67 .nocodec_tplg_filename = "sof-byt-nocodec.tplg", >> 68 .ops = &sof_byt_ops, >> 69 }; >> 70 >> 71 static const struct sof_dev_desc sof_acpi_baytrail_desc = { >> 72 .machines = snd_soc_acpi_intel_baytrail_machines, >> 73 .resindex_lpe_base = 0, >> 74 .resindex_pcicfg_base = 1, >> 75 .resindex_imr_base = 2, >> 76 .irqindex_host_ipc = 5, >> 77 .chip_info = &byt_chip_info, >> 78 .default_fw_path = "intel/sof", >> 79 .default_tplg_path = "intel/sof-tplg", >> 80 .default_fw_filename = "sof-byt.ri", >> 81 .nocodec_tplg_filename = "sof-byt-nocodec.tplg", >> 82 .ops = &sof_byt_ops, >> 83 }; >> 84 >> 85 static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { >> 86 .machines = snd_soc_acpi_intel_cherrytrail_machines, >> 87 .resindex_lpe_base = 0, >> 88 .resindex_pcicfg_base = 1, >> 89 .resindex_imr_base = 2, >> 90 .irqindex_host_ipc = 5, >> 91 .chip_info = &cht_chip_info, >> 92 .default_fw_path = "intel/sof", >> 93 .default_tplg_path = "intel/sof-tplg", >> 94 .default_fw_filename = "sof-cht.ri", >> 95 .nocodec_tplg_filename = "sof-cht-nocodec.tplg", >> 96 .ops = &sof_cht_ops, >> 97 }; >> 98 >> 99 #endif >> 100 >> 101 static const struct dev_pm_ops sof_acpi_pm = { 40 SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspen 102 SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume) 41 SET_RUNTIME_PM_OPS(snd_sof_runtime_sus 103 SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume, 42 snd_sof_runtime_idl 104 snd_sof_runtime_idle) 43 }; 105 }; 44 EXPORT_SYMBOL_NS(sof_acpi_pm, SND_SOC_SOF_ACPI << 45 106 46 static void sof_acpi_probe_complete(struct dev 107 static void sof_acpi_probe_complete(struct device *dev) 47 { 108 { 48 dev_dbg(dev, "Completing SOF ACPI prob << 49 << 50 if (sof_acpi_debug & SOF_ACPI_DISABLE_ 109 if (sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME) 51 return; 110 return; 52 111 53 /* allow runtime_pm */ 112 /* allow runtime_pm */ 54 pm_runtime_set_autosuspend_delay(dev, 113 pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS); 55 pm_runtime_use_autosuspend(dev); 114 pm_runtime_use_autosuspend(dev); 56 pm_runtime_enable(dev); 115 pm_runtime_enable(dev); 57 } 116 } 58 117 59 int sof_acpi_probe(struct platform_device *pde !! 118 static int sof_acpi_probe(struct platform_device *pdev) 60 { 119 { 61 struct device *dev = &pdev->dev; 120 struct device *dev = &pdev->dev; >> 121 const struct sof_dev_desc *desc; 62 struct snd_sof_pdata *sof_pdata; 122 struct snd_sof_pdata *sof_pdata; >> 123 const struct snd_sof_dsp_ops *ops; >> 124 int ret; 63 125 64 dev_dbg(dev, "ACPI DSP detected"); !! 126 dev_dbg(&pdev->dev, "ACPI DSP detected"); 65 127 66 sof_pdata = devm_kzalloc(dev, sizeof(* 128 sof_pdata = devm_kzalloc(dev, sizeof(*sof_pdata), GFP_KERNEL); 67 if (!sof_pdata) 129 if (!sof_pdata) 68 return -ENOMEM; 130 return -ENOMEM; 69 131 70 if (!desc->ops) { !! 132 desc = device_get_match_data(dev); >> 133 if (!desc) >> 134 return -ENODEV; >> 135 >> 136 #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL) >> 137 if (desc == &sof_acpi_baytrail_desc && soc_intel_is_byt_cr(pdev)) >> 138 desc = &sof_acpi_baytrailcr_desc; >> 139 #endif >> 140 >> 141 /* get ops for platform */ >> 142 ops = desc->ops; >> 143 if (!ops) { 71 dev_err(dev, "error: no matchi 144 dev_err(dev, "error: no matching ACPI descriptor ops\n"); 72 return -ENODEV; 145 return -ENODEV; 73 } 146 } 74 147 75 sof_pdata->desc = desc; 148 sof_pdata->desc = desc; 76 sof_pdata->dev = &pdev->dev; 149 sof_pdata->dev = &pdev->dev; >> 150 sof_pdata->fw_filename = desc->default_fw_filename; 77 151 78 sof_pdata->ipc_file_profile_base.ipc_t !! 152 /* alternate fw and tplg filenames ? */ 79 sof_pdata->ipc_file_profile_base.fw_pa !! 153 if (fw_path) 80 sof_pdata->ipc_file_profile_base.tplg_ !! 154 sof_pdata->fw_filename_prefix = fw_path; >> 155 else >> 156 sof_pdata->fw_filename_prefix = >> 157 sof_pdata->desc->default_fw_path; >> 158 >> 159 if (tplg_path) >> 160 sof_pdata->tplg_filename_prefix = tplg_path; >> 161 else >> 162 sof_pdata->tplg_filename_prefix = >> 163 sof_pdata->desc->default_tplg_path; 81 164 82 /* set callback to be called on succes !! 165 #if IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) >> 166 /* set callback to enable runtime_pm */ 83 sof_pdata->sof_probe_complete = sof_ac 167 sof_pdata->sof_probe_complete = sof_acpi_probe_complete; 84 !! 168 #endif 85 /* call sof helper for DSP hardware pr 169 /* call sof helper for DSP hardware probe */ 86 return snd_sof_device_probe(dev, sof_p !! 170 ret = snd_sof_device_probe(dev, sof_pdata); >> 171 if (ret) { >> 172 dev_err(dev, "error: failed to probe DSP hardware!\n"); >> 173 return ret; >> 174 } >> 175 >> 176 #if !IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) >> 177 sof_acpi_probe_complete(dev); >> 178 #endif >> 179 >> 180 return ret; 87 } 181 } 88 EXPORT_SYMBOL_NS(sof_acpi_probe, SND_SOC_SOF_A << 89 182 90 void sof_acpi_remove(struct platform_device *p !! 183 static int sof_acpi_remove(struct platform_device *pdev) 91 { 184 { 92 struct device *dev = &pdev->dev; << 93 << 94 if (!(sof_acpi_debug & SOF_ACPI_DISABL 185 if (!(sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME)) 95 pm_runtime_disable(dev); !! 186 pm_runtime_disable(&pdev->dev); 96 187 97 /* call sof helper for DSP hardware re 188 /* call sof helper for DSP hardware remove */ 98 snd_sof_device_remove(dev); !! 189 snd_sof_device_remove(&pdev->dev); >> 190 >> 191 return 0; 99 } 192 } 100 EXPORT_SYMBOL_NS(sof_acpi_remove, SND_SOC_SOF_ !! 193 >> 194 #ifdef CONFIG_ACPI >> 195 static const struct acpi_device_id sof_acpi_match[] = { >> 196 #if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) >> 197 { "INT3438", (unsigned long)&sof_acpi_broadwell_desc }, >> 198 #endif >> 199 #if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL) >> 200 { "80860F28", (unsigned long)&sof_acpi_baytrail_desc }, >> 201 { "808622A8", (unsigned long)&sof_acpi_cherrytrail_desc }, >> 202 #endif >> 203 { } >> 204 }; >> 205 MODULE_DEVICE_TABLE(acpi, sof_acpi_match); >> 206 #endif >> 207 >> 208 /* acpi_driver definition */ >> 209 static struct platform_driver snd_sof_acpi_driver = { >> 210 .probe = sof_acpi_probe, >> 211 .remove = sof_acpi_remove, >> 212 .driver = { >> 213 .name = "sof-audio-acpi", >> 214 .pm = &sof_acpi_pm, >> 215 .acpi_match_table = ACPI_PTR(sof_acpi_match), >> 216 }, >> 217 }; >> 218 module_platform_driver(snd_sof_acpi_driver); 101 219 102 MODULE_LICENSE("Dual BSD/GPL"); 220 MODULE_LICENSE("Dual BSD/GPL"); 103 MODULE_DESCRIPTION("SOF support for ACPI platf !! 221 MODULE_IMPORT_NS(SND_SOC_SOF_BAYTRAIL); >> 222 MODULE_IMPORT_NS(SND_SOC_SOF_BROADWELL); 104 223
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.