Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: ACPI: avoid reverse module dependency

The SOF-ACPI driver is backwards from the normal Linux model, it has a
generic driver that knows about all the specific drivers, as opposed to
having hardware specific drivers that link against a common framework.

This requires ugly Kconfig magic and leads to missed dependencies as
seen in this link error:

arm-linux-gnueabi-ld: sound/soc/sof/sof-pci-dev.o: in function `sof_acpi_probe':
sof-pci-dev.c:(.text+0x1c): undefined reference to `snd_intel_dsp_driver_probe'

Change it to use the normal probe order of starting with a specific
device in a driver, turning the sof-acpi-dev.c driver into a
library (exported symbols are name-spaced to avoid symbol pollution).

For backwards-compatibility with previous Kconfigs, the default values
for platform drivers uses the top-level ACPI configurations. The
modules were also renamed to allow for gradual transitions in test
scripts.

Co-developed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20210302003125.1178419-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Arnd Bergmann and committed by
Takashi Iwai
8a49cd11 c7929b15

+215 -176
+5 -3
sound/soc/sof/Kconfig
··· 23 23 config SND_SOC_SOF_ACPI 24 24 tristate "SOF ACPI enumeration support" 25 25 depends on ACPI || COMPILE_TEST 26 - select SND_SOC_SOF 27 - select SND_SOC_ACPI if ACPI 28 - select IOSF_MBI if X86 && PCI 29 26 help 30 27 This adds support for ACPI enumeration. This option is required 31 28 to enable Intel Broadwell/Baytrail/Cherrytrail devices. 29 + For backwards-compatibility with previous configurations the selection will 30 + be used as default for platform-specific drivers. 32 31 Say Y if you need this option. 33 32 If unsure select "N". 33 + 34 + config SND_SOC_SOF_ACPI_DEV 35 + tristate 34 36 35 37 config SND_SOC_SOF_OF 36 38 tristate "SOF OF enumeration support"
+1 -1
sound/soc/sof/Makefile
··· 14 14 obj-$(CONFIG_SND_SOC_SOF_NOCODEC) += snd-sof-nocodec.o 15 15 16 16 17 - obj-$(CONFIG_SND_SOC_SOF_ACPI) += snd-sof-acpi.o 17 + obj-$(CONFIG_SND_SOC_SOF_ACPI_DEV) += snd-sof-acpi.o 18 18 obj-$(CONFIG_SND_SOC_SOF_OF) += snd-sof-of.o 19 19 obj-$(CONFIG_SND_SOC_SOF_PCI) += snd-sof-pci.o 20 20
+17 -31
sound/soc/sof/intel/Kconfig
··· 9 9 10 10 if SND_SOC_SOF_INTEL_TOPLEVEL 11 11 12 - config SND_SOC_SOF_INTEL_ACPI 13 - def_tristate SND_SOC_SOF_ACPI 14 - select SND_SOC_SOF_BAYTRAIL if SND_SOC_SOF_BAYTRAIL_SUPPORT 15 - select SND_SOC_SOF_BROADWELL if SND_SOC_SOF_BROADWELL_SUPPORT 16 - help 17 - This option is not user-selectable but automagically handled by 18 - 'select' statements at a higher level. 19 - 20 12 config SND_SOC_SOF_INTEL_PCI 21 13 def_tristate SND_SOC_SOF_PCI 22 14 select SND_SOC_SOF_MERRIFIELD if SND_SOC_SOF_MERRIFIELD_SUPPORT ··· 42 50 43 51 config SND_SOC_SOF_INTEL_COMMON 44 52 tristate 53 + select SND_SOC_SOF 45 54 select SND_SOC_ACPI_INTEL_MATCH 46 55 select SND_SOC_SOF_XTENSA 47 56 select SND_SOC_INTEL_MACH 48 57 select SND_SOC_ACPI if ACPI 58 + select SND_INTEL_DSP_CONFIG 49 59 help 50 60 This option is not user-selectable but automagically handled by 51 61 'select' statements at a higher level. 52 62 53 - if SND_SOC_SOF_INTEL_ACPI 63 + if SND_SOC_SOF_ACPI 54 64 55 - config SND_SOC_SOF_BAYTRAIL_SUPPORT 56 - bool "SOF support for Baytrail, Braswell and Cherrytrail" 65 + config SND_SOC_SOF_BAYTRAIL 66 + tristate "SOF support for Baytrail, Braswell and Cherrytrail" 67 + default SND_SOC_SOF_ACPI 68 + select SND_SOC_SOF_INTEL_COMMON 69 + select SND_SOC_SOF_INTEL_ATOM_HIFI_EP 70 + select SND_SOC_SOF_ACPI_DEV 71 + select IOSF_MBI if X86 && PCI 57 72 help 58 73 This adds support for Sound Open Firmware for Intel(R) platforms 59 74 using the Baytrail, Braswell or Cherrytrail processors. ··· 74 75 Say Y if you want to enable SOF on Baytrail/Cherrytrail. 75 76 If unsure select "N". 76 77 77 - config SND_SOC_SOF_BAYTRAIL 78 - tristate 79 - select SND_SOC_SOF_INTEL_ATOM_HIFI_EP 80 - select SND_INTEL_DSP_CONFIG 81 - help 82 - This option is not user-selectable but automagically handled by 83 - 'select' statements at a higher level. 84 - 85 - config SND_SOC_SOF_BROADWELL_SUPPORT 86 - bool "SOF support for Broadwell" 87 - select SND_INTEL_DSP_CONFIG 78 + config SND_SOC_SOF_BROADWELL 79 + tristate "SOF support for Broadwell" 80 + default SND_SOC_SOF_ACPI 81 + select SND_SOC_SOF_INTEL_COMMON 82 + select SND_SOC_SOF_INTEL_HIFI_EP_IPC 83 + select SND_SOC_SOF_ACPI_DEV 88 84 help 89 85 This adds support for Sound Open Firmware for Intel(R) platforms 90 86 using the Broadwell processors. ··· 94 100 Say Y if you want to enable SOF on Broadwell. 95 101 If unsure select "N". 96 102 97 - config SND_SOC_SOF_BROADWELL 98 - tristate 99 - select SND_SOC_SOF_INTEL_COMMON 100 - select SND_SOC_SOF_INTEL_HIFI_EP_IPC 101 - help 102 - This option is not user-selectable but automagically handled by 103 - 'select' statements at a higher level. 104 - 105 - endif ## SND_SOC_SOF_INTEL_ACPI 103 + endif ## SND_SOC_SOF_ACPI 106 104 107 105 if SND_SOC_SOF_INTEL_PCI 108 106
+4 -4
sound/soc/sof/intel/Makefile
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 2 2 3 - snd-sof-intel-byt-objs := byt.o 4 - snd-sof-intel-bdw-objs := bdw.o 3 + snd-sof-acpi-intel-byt-objs := byt.o 4 + snd-sof-acpi-intel-bdw-objs := bdw.o 5 5 6 6 snd-sof-intel-ipc-objs := intel-ipc.o 7 7 ··· 13 13 14 14 snd-sof-intel-hda-objs := hda-codec.o 15 15 16 - obj-$(CONFIG_SND_SOC_SOF_INTEL_ATOM_HIFI_EP) += snd-sof-intel-byt.o 17 - obj-$(CONFIG_SND_SOC_SOF_BROADWELL) += snd-sof-intel-bdw.o 16 + obj-$(CONFIG_SND_SOC_SOF_INTEL_ATOM_HIFI_EP) += snd-sof-acpi-intel-byt.o 17 + obj-$(CONFIG_SND_SOC_SOF_BROADWELL) += snd-sof-acpi-intel-bdw.o 18 18 obj-$(CONFIG_SND_SOC_SOF_INTEL_HIFI_EP_IPC) += snd-sof-intel-ipc.o 19 19 obj-$(CONFIG_SND_SOC_SOF_HDA_COMMON) += snd-sof-intel-hda-common.o 20 20 obj-$(CONFIG_SND_SOC_SOF_HDA) += snd-sof-intel-hda.o
+63 -4
sound/soc/sof/intel/bdw.c
··· 15 15 #include <linux/module.h> 16 16 #include <sound/sof.h> 17 17 #include <sound/sof/xtensa.h> 18 + #include <sound/soc-acpi.h> 19 + #include <sound/soc-acpi-intel-match.h> 20 + #include <sound/intel-dsp-config.h> 18 21 #include "../ops.h" 19 22 #include "shim.h" 23 + #include "../sof-acpi-dev.h" 20 24 #include "../sof-audio.h" 21 25 22 26 /* BARs */ ··· 594 590 }; 595 591 596 592 /* broadwell ops */ 597 - const struct snd_sof_dsp_ops sof_bdw_ops = { 593 + static const struct snd_sof_dsp_ops sof_bdw_ops = { 598 594 /*Device init */ 599 595 .probe = bdw_probe, 600 596 ··· 655 651 656 652 .arch_ops = &sof_xtensa_arch_ops, 657 653 }; 658 - EXPORT_SYMBOL_NS(sof_bdw_ops, SND_SOC_SOF_BROADWELL); 659 654 660 - const struct sof_intel_dsp_desc bdw_chip_info = { 655 + static const struct sof_intel_dsp_desc bdw_chip_info = { 661 656 .cores_num = 1, 662 657 .host_managed_cores_mask = 1, 663 658 }; 664 - EXPORT_SYMBOL_NS(bdw_chip_info, SND_SOC_SOF_BROADWELL); 659 + 660 + static const struct sof_dev_desc sof_acpi_broadwell_desc = { 661 + .machines = snd_soc_acpi_intel_broadwell_machines, 662 + .resindex_lpe_base = 0, 663 + .resindex_pcicfg_base = 1, 664 + .resindex_imr_base = -1, 665 + .irqindex_host_ipc = 0, 666 + .chip_info = &bdw_chip_info, 667 + .default_fw_path = "intel/sof", 668 + .default_tplg_path = "intel/sof-tplg", 669 + .default_fw_filename = "sof-bdw.ri", 670 + .nocodec_tplg_filename = "sof-bdw-nocodec.tplg", 671 + .ops = &sof_bdw_ops, 672 + }; 673 + 674 + static const struct acpi_device_id sof_broadwell_match[] = { 675 + { "INT3438", (unsigned long)&sof_acpi_broadwell_desc }, 676 + { } 677 + }; 678 + MODULE_DEVICE_TABLE(acpi, sof_broadwell_match); 679 + 680 + static int sof_broadwell_probe(struct platform_device *pdev) 681 + { 682 + struct device *dev = &pdev->dev; 683 + const struct acpi_device_id *id; 684 + const struct sof_dev_desc *desc; 685 + int ret; 686 + 687 + id = acpi_match_device(dev->driver->acpi_match_table, dev); 688 + if (!id) 689 + return -ENODEV; 690 + 691 + ret = snd_intel_acpi_dsp_driver_probe(dev, id->id); 692 + if (ret != SND_INTEL_DSP_DRIVER_ANY && ret != SND_INTEL_DSP_DRIVER_SOF) { 693 + dev_dbg(dev, "SOF ACPI driver not selected, aborting probe\n"); 694 + return -ENODEV; 695 + } 696 + 697 + desc = device_get_match_data(dev); 698 + if (!desc) 699 + return -ENODEV; 700 + 701 + return sof_acpi_probe(pdev, device_get_match_data(dev)); 702 + } 703 + 704 + /* acpi_driver definition */ 705 + static struct platform_driver snd_sof_acpi_intel_bdw_driver = { 706 + .probe = sof_broadwell_probe, 707 + .remove = sof_acpi_remove, 708 + .driver = { 709 + .name = "sof-audio-acpi-intel-bdw", 710 + .pm = &sof_acpi_pm, 711 + .acpi_match_table = sof_broadwell_match, 712 + }, 713 + }; 714 + module_platform_driver(snd_sof_acpi_intel_bdw_driver); 665 715 666 716 MODULE_LICENSE("Dual BSD/GPL"); 667 717 MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); 668 718 MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); 719 + MODULE_IMPORT_NS(SND_SOC_SOF_ACPI_DEV);
+98 -8
sound/soc/sof/intel/byt.c
··· 15 15 #include <linux/module.h> 16 16 #include <sound/sof.h> 17 17 #include <sound/sof/xtensa.h> 18 + #include <sound/soc-acpi.h> 19 + #include <sound/soc-acpi-intel-match.h> 20 + #include <sound/intel-dsp-config.h> 18 21 #include "../ops.h" 19 22 #include "shim.h" 23 + #include "../sof-acpi-dev.h" 20 24 #include "../sof-audio.h" 21 25 #include "../../intel/common/soc-intel-quirks.h" 22 26 ··· 826 822 } 827 823 828 824 /* baytrail ops */ 829 - const struct snd_sof_dsp_ops sof_byt_ops = { 825 + static const struct snd_sof_dsp_ops sof_byt_ops = { 830 826 /* device init */ 831 827 .probe = byt_acpi_probe, 832 828 .remove = byt_remove, ··· 896 892 897 893 .arch_ops = &sof_xtensa_arch_ops, 898 894 }; 899 - EXPORT_SYMBOL_NS(sof_byt_ops, SND_SOC_SOF_BAYTRAIL); 900 895 901 - const struct sof_intel_dsp_desc byt_chip_info = { 896 + static const struct sof_intel_dsp_desc byt_chip_info = { 902 897 .cores_num = 1, 903 898 .host_managed_cores_mask = 1, 904 899 }; 905 - EXPORT_SYMBOL_NS(byt_chip_info, SND_SOC_SOF_BAYTRAIL); 906 900 907 901 /* cherrytrail and braswell ops */ 908 - const struct snd_sof_dsp_ops sof_cht_ops = { 902 + static const struct snd_sof_dsp_ops sof_cht_ops = { 909 903 /* device init */ 910 904 .probe = byt_acpi_probe, 911 905 .remove = byt_remove, ··· 974 972 975 973 .arch_ops = &sof_xtensa_arch_ops, 976 974 }; 977 - EXPORT_SYMBOL_NS(sof_cht_ops, SND_SOC_SOF_BAYTRAIL); 978 975 979 - const struct sof_intel_dsp_desc cht_chip_info = { 976 + static const struct sof_intel_dsp_desc cht_chip_info = { 980 977 .cores_num = 1, 981 978 .host_managed_cores_mask = 1, 982 979 }; 983 - EXPORT_SYMBOL_NS(cht_chip_info, SND_SOC_SOF_BAYTRAIL); 980 + 981 + /* BYTCR uses different IRQ index */ 982 + static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { 983 + .machines = snd_soc_acpi_intel_baytrail_machines, 984 + .resindex_lpe_base = 0, 985 + .resindex_pcicfg_base = 1, 986 + .resindex_imr_base = 2, 987 + .irqindex_host_ipc = 0, 988 + .chip_info = &byt_chip_info, 989 + .default_fw_path = "intel/sof", 990 + .default_tplg_path = "intel/sof-tplg", 991 + .default_fw_filename = "sof-byt.ri", 992 + .nocodec_tplg_filename = "sof-byt-nocodec.tplg", 993 + .ops = &sof_byt_ops, 994 + }; 995 + 996 + static const struct sof_dev_desc sof_acpi_baytrail_desc = { 997 + .machines = snd_soc_acpi_intel_baytrail_machines, 998 + .resindex_lpe_base = 0, 999 + .resindex_pcicfg_base = 1, 1000 + .resindex_imr_base = 2, 1001 + .irqindex_host_ipc = 5, 1002 + .chip_info = &byt_chip_info, 1003 + .default_fw_path = "intel/sof", 1004 + .default_tplg_path = "intel/sof-tplg", 1005 + .default_fw_filename = "sof-byt.ri", 1006 + .nocodec_tplg_filename = "sof-byt-nocodec.tplg", 1007 + .ops = &sof_byt_ops, 1008 + }; 1009 + 1010 + static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { 1011 + .machines = snd_soc_acpi_intel_cherrytrail_machines, 1012 + .resindex_lpe_base = 0, 1013 + .resindex_pcicfg_base = 1, 1014 + .resindex_imr_base = 2, 1015 + .irqindex_host_ipc = 5, 1016 + .chip_info = &cht_chip_info, 1017 + .default_fw_path = "intel/sof", 1018 + .default_tplg_path = "intel/sof-tplg", 1019 + .default_fw_filename = "sof-cht.ri", 1020 + .nocodec_tplg_filename = "sof-cht-nocodec.tplg", 1021 + .ops = &sof_cht_ops, 1022 + }; 1023 + 1024 + static const struct acpi_device_id sof_baytrail_match[] = { 1025 + { "80860F28", (unsigned long)&sof_acpi_baytrail_desc }, 1026 + { "808622A8", (unsigned long)&sof_acpi_cherrytrail_desc }, 1027 + { } 1028 + }; 1029 + MODULE_DEVICE_TABLE(acpi, sof_baytrail_match); 1030 + 1031 + static int sof_baytrail_probe(struct platform_device *pdev) 1032 + { 1033 + struct device *dev = &pdev->dev; 1034 + const struct sof_dev_desc *desc; 1035 + const struct acpi_device_id *id; 1036 + int ret; 1037 + 1038 + id = acpi_match_device(dev->driver->acpi_match_table, dev); 1039 + if (!id) 1040 + return -ENODEV; 1041 + 1042 + ret = snd_intel_acpi_dsp_driver_probe(dev, id->id); 1043 + if (ret != SND_INTEL_DSP_DRIVER_ANY && ret != SND_INTEL_DSP_DRIVER_SOF) { 1044 + dev_dbg(dev, "SOF ACPI driver not selected, aborting probe\n"); 1045 + return -ENODEV; 1046 + } 1047 + 1048 + desc = device_get_match_data(&pdev->dev); 1049 + if (!desc) 1050 + return -ENODEV; 1051 + 1052 + if (desc == &sof_acpi_baytrail_desc && soc_intel_is_byt_cr(pdev)) 1053 + desc = &sof_acpi_baytrailcr_desc; 1054 + 1055 + return sof_acpi_probe(pdev, desc); 1056 + } 1057 + 1058 + /* acpi_driver definition */ 1059 + static struct platform_driver snd_sof_acpi_intel_byt_driver = { 1060 + .probe = sof_baytrail_probe, 1061 + .remove = sof_acpi_remove, 1062 + .driver = { 1063 + .name = "sof-audio-acpi-intel-byt", 1064 + .pm = &sof_acpi_pm, 1065 + .acpi_match_table = sof_baytrail_match, 1066 + }, 1067 + }; 1068 + module_platform_driver(snd_sof_acpi_intel_byt_driver); 984 1069 985 1070 #endif /* CONFIG_SND_SOC_SOF_BAYTRAIL */ 986 1071 987 1072 MODULE_LICENSE("Dual BSD/GPL"); 988 1073 MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); 989 1074 MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); 1075 + MODULE_IMPORT_NS(SND_SOC_SOF_ACPI_DEV);
-6
sound/soc/sof/intel/shim.h
··· 167 167 }; 168 168 169 169 extern const struct snd_sof_dsp_ops sof_tng_ops; 170 - extern const struct snd_sof_dsp_ops sof_byt_ops; 171 - extern const struct snd_sof_dsp_ops sof_cht_ops; 172 - extern const struct snd_sof_dsp_ops sof_bdw_ops; 173 170 174 - extern const struct sof_intel_dsp_desc byt_chip_info; 175 - extern const struct sof_intel_dsp_desc cht_chip_info; 176 - extern const struct sof_intel_dsp_desc bdw_chip_info; 177 171 extern const struct sof_intel_dsp_desc tng_chip_info; 178 172 179 173 struct sof_intel_stream {
+11 -119
sound/soc/sof/sof-acpi-dev.c
··· 12 12 #include <linux/firmware.h> 13 13 #include <linux/module.h> 14 14 #include <linux/pm_runtime.h> 15 - #include <sound/intel-dsp-config.h> 16 15 #include <sound/soc-acpi.h> 17 16 #include <sound/soc-acpi-intel-match.h> 18 17 #include <sound/sof.h> 19 18 #include "../intel/common/soc-intel-quirks.h" 20 19 #include "ops.h" 20 + #include "sof-acpi-dev.h" 21 21 22 22 /* platform specific devices */ 23 23 #include "intel/shim.h" ··· 36 36 37 37 #define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0) 38 38 39 - #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) 40 - static const struct sof_dev_desc sof_acpi_broadwell_desc = { 41 - .machines = snd_soc_acpi_intel_broadwell_machines, 42 - .resindex_lpe_base = 0, 43 - .resindex_pcicfg_base = 1, 44 - .resindex_imr_base = -1, 45 - .irqindex_host_ipc = 0, 46 - .chip_info = &bdw_chip_info, 47 - .default_fw_path = "intel/sof", 48 - .default_tplg_path = "intel/sof-tplg", 49 - .default_fw_filename = "sof-bdw.ri", 50 - .nocodec_tplg_filename = "sof-bdw-nocodec.tplg", 51 - .ops = &sof_bdw_ops, 52 - }; 53 - #endif 54 - 55 - #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL) 56 - 57 - /* BYTCR uses different IRQ index */ 58 - static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { 59 - .machines = snd_soc_acpi_intel_baytrail_machines, 60 - .resindex_lpe_base = 0, 61 - .resindex_pcicfg_base = 1, 62 - .resindex_imr_base = 2, 63 - .irqindex_host_ipc = 0, 64 - .chip_info = &byt_chip_info, 65 - .default_fw_path = "intel/sof", 66 - .default_tplg_path = "intel/sof-tplg", 67 - .default_fw_filename = "sof-byt.ri", 68 - .nocodec_tplg_filename = "sof-byt-nocodec.tplg", 69 - .ops = &sof_byt_ops, 70 - }; 71 - 72 - static const struct sof_dev_desc sof_acpi_baytrail_desc = { 73 - .machines = snd_soc_acpi_intel_baytrail_machines, 74 - .resindex_lpe_base = 0, 75 - .resindex_pcicfg_base = 1, 76 - .resindex_imr_base = 2, 77 - .irqindex_host_ipc = 5, 78 - .chip_info = &byt_chip_info, 79 - .default_fw_path = "intel/sof", 80 - .default_tplg_path = "intel/sof-tplg", 81 - .default_fw_filename = "sof-byt.ri", 82 - .nocodec_tplg_filename = "sof-byt-nocodec.tplg", 83 - .ops = &sof_byt_ops, 84 - }; 85 - 86 - static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { 87 - .machines = snd_soc_acpi_intel_cherrytrail_machines, 88 - .resindex_lpe_base = 0, 89 - .resindex_pcicfg_base = 1, 90 - .resindex_imr_base = 2, 91 - .irqindex_host_ipc = 5, 92 - .chip_info = &cht_chip_info, 93 - .default_fw_path = "intel/sof", 94 - .default_tplg_path = "intel/sof-tplg", 95 - .default_fw_filename = "sof-cht.ri", 96 - .nocodec_tplg_filename = "sof-cht-nocodec.tplg", 97 - .ops = &sof_cht_ops, 98 - }; 99 - 100 - #endif 101 - 102 - static const struct dev_pm_ops sof_acpi_pm = { 39 + const struct dev_pm_ops sof_acpi_pm = { 103 40 SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume) 104 41 SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume, 105 42 snd_sof_runtime_idle) 106 43 }; 44 + EXPORT_SYMBOL_NS(sof_acpi_pm, SND_SOC_SOF_ACPI_DEV); 107 45 108 46 static void sof_acpi_probe_complete(struct device *dev) 109 47 { ··· 56 118 pm_runtime_enable(dev); 57 119 } 58 120 59 - static int sof_acpi_probe(struct platform_device *pdev) 121 + int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc) 60 122 { 61 123 struct device *dev = &pdev->dev; 62 - const struct acpi_device_id *id; 63 - const struct sof_dev_desc *desc; 64 124 struct snd_sof_pdata *sof_pdata; 65 125 const struct snd_sof_dsp_ops *ops; 66 126 int ret; 67 127 68 - id = acpi_match_device(dev->driver->acpi_match_table, dev); 69 - if (!id) 70 - return -ENODEV; 71 - 72 - if (IS_REACHABLE(CONFIG_SND_INTEL_DSP_CONFIG)) { 73 - ret = snd_intel_acpi_dsp_driver_probe(dev, id->id); 74 - if (ret != SND_INTEL_DSP_DRIVER_ANY && ret != SND_INTEL_DSP_DRIVER_SOF) { 75 - dev_dbg(dev, "SOF ACPI driver not selected, aborting probe\n"); 76 - return -ENODEV; 77 - } 78 - } 79 128 dev_dbg(dev, "ACPI DSP detected"); 80 129 81 130 sof_pdata = devm_kzalloc(dev, sizeof(*sof_pdata), GFP_KERNEL); 82 131 if (!sof_pdata) 83 132 return -ENOMEM; 84 - 85 - desc = device_get_match_data(dev); 86 - if (!desc) 87 - return -ENODEV; 88 - 89 - #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL) 90 - if (desc == &sof_acpi_baytrail_desc && soc_intel_is_byt_cr(pdev)) 91 - desc = &sof_acpi_baytrailcr_desc; 92 - #endif 93 133 94 134 /* get ops for platform */ 95 135 ops = desc->ops; ··· 110 194 111 195 return ret; 112 196 } 197 + EXPORT_SYMBOL_NS(sof_acpi_probe, SND_SOC_SOF_ACPI_DEV); 113 198 114 - static int sof_acpi_remove(struct platform_device *pdev) 199 + int sof_acpi_remove(struct platform_device *pdev) 115 200 { 201 + struct device *dev = &pdev->dev; 202 + 116 203 if (!(sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME)) 117 - pm_runtime_disable(&pdev->dev); 204 + pm_runtime_disable(dev); 118 205 119 206 /* call sof helper for DSP hardware remove */ 120 - snd_sof_device_remove(&pdev->dev); 207 + snd_sof_device_remove(dev); 121 208 122 209 return 0; 123 210 } 124 - 125 - #ifdef CONFIG_ACPI 126 - static const struct acpi_device_id sof_acpi_match[] = { 127 - #if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) 128 - { "INT3438", (unsigned long)&sof_acpi_broadwell_desc }, 129 - #endif 130 - #if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL) 131 - { "80860F28", (unsigned long)&sof_acpi_baytrail_desc }, 132 - { "808622A8", (unsigned long)&sof_acpi_cherrytrail_desc }, 133 - #endif 134 - { } 135 - }; 136 - MODULE_DEVICE_TABLE(acpi, sof_acpi_match); 137 - #endif 138 - 139 - /* acpi_driver definition */ 140 - static struct platform_driver snd_sof_acpi_driver = { 141 - .probe = sof_acpi_probe, 142 - .remove = sof_acpi_remove, 143 - .driver = { 144 - .name = "sof-audio-acpi", 145 - .pm = &sof_acpi_pm, 146 - .acpi_match_table = ACPI_PTR(sof_acpi_match), 147 - }, 148 - }; 149 - module_platform_driver(snd_sof_acpi_driver); 211 + EXPORT_SYMBOL_NS(sof_acpi_remove, SND_SOC_SOF_ACPI_DEV); 150 212 151 213 MODULE_LICENSE("Dual BSD/GPL"); 152 - MODULE_IMPORT_NS(SND_SOC_SOF_BAYTRAIL); 153 - MODULE_IMPORT_NS(SND_SOC_SOF_BROADWELL);
+16
sound/soc/sof/sof-acpi-dev.h
··· 1 + /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 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) 2021 Intel Corporation. All rights reserved. 7 + */ 8 + 9 + #ifndef __SOUND_SOC_SOF_ACPI_H 10 + #define __SOUND_SOC_SOF_ACPI_H 11 + 12 + extern const struct dev_pm_ops sof_acpi_pm; 13 + int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc); 14 + int sof_acpi_remove(struct platform_device *pdev); 15 + 16 + #endif