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) 2018-2022 Intel Corporation
7 //
8 // Author: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
9 //
10 
11 #include <linux/module.h>
12 #include <linux/pci.h>
13 #include <sound/soc-acpi.h>
14 #include <sound/soc-acpi-intel-match.h>
15 #include <sound/sof.h>
16 #include "../ops.h"
17 #include "../sof-pci-dev.h"
18 
19 /* platform specific devices */
20 #include "hda.h"
21 #include "mtl.h"
22 
23 /* Meteorlake ops */
24 static struct snd_sof_dsp_ops sof_mtl_ops;
25 
26 static int sof_mtl_ops_init(struct snd_sof_dev *sdev)
27 {
28 	return sof_mtl_set_ops(sdev, &sof_mtl_ops);
29 }
30 
31 static const struct sof_dev_desc mtl_desc = {
32 	.use_acpi_target_states	= true,
33 	.machines               = snd_soc_acpi_intel_mtl_machines,
34 	.alt_machines		= snd_soc_acpi_intel_mtl_sdw_machines,
35 	.resindex_lpe_base      = 0,
36 	.resindex_pcicfg_base   = -1,
37 	.resindex_imr_base      = -1,
38 	.irqindex_host_ipc      = -1,
39 	.chip_info = &mtl_chip_info,
40 	.ipc_supported_mask	= BIT(SOF_IPC_TYPE_4),
41 	.ipc_default		= SOF_IPC_TYPE_4,
42 	.dspless_mode_supported	= true,		/* Only supported for HDaudio */
43 	.default_fw_path = {
44 		[SOF_IPC_TYPE_4] = "intel/sof-ipc4/mtl",
45 	},
46 	.default_lib_path = {
47 		[SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/mtl",
48 	},
49 	.default_tplg_path = {
50 		[SOF_IPC_TYPE_4] = "intel/sof-ace-tplg",
51 	},
52 	.default_fw_filename = {
53 		[SOF_IPC_TYPE_4] = "sof-mtl.ri",
54 	},
55 	.nocodec_tplg_filename = "sof-mtl-nocodec.tplg",
56 	.ops = &sof_mtl_ops,
57 	.ops_init = sof_mtl_ops_init,
58 	.ops_free = hda_ops_free,
59 };
60 
61 static const struct sof_dev_desc arl_desc = {
62 	.use_acpi_target_states = true,
63 	.machines               = snd_soc_acpi_intel_arl_machines,
64 	.alt_machines           = snd_soc_acpi_intel_arl_sdw_machines,
65 	.resindex_lpe_base      = 0,
66 	.resindex_pcicfg_base   = -1,
67 	.resindex_imr_base      = -1,
68 	.irqindex_host_ipc      = -1,
69 	.chip_info = &mtl_chip_info,
70 	.ipc_supported_mask     = BIT(SOF_IPC_TYPE_4),
71 	.ipc_default            = SOF_IPC_TYPE_4,
72 	.dspless_mode_supported = true,         /* Only supported for HDaudio */
73 	.default_fw_path = {
74 		[SOF_IPC_TYPE_4] = "intel/sof-ipc4/arl",
75 	},
76 	.default_lib_path = {
77 		[SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/arl",
78 	},
79 	.default_tplg_path = {
80 		[SOF_IPC_TYPE_4] = "intel/sof-ace-tplg",
81 	},
82 	.default_fw_filename = {
83 		[SOF_IPC_TYPE_4] = "sof-arl.ri",
84 	},
85 	.nocodec_tplg_filename = "sof-arl-nocodec.tplg",
86 	.ops = &sof_mtl_ops,
87 	.ops_init = sof_mtl_ops_init,
88 	.ops_free = hda_ops_free,
89 };
90 
91 static const struct sof_dev_desc arl_s_desc = {
92 	.use_acpi_target_states = true,
93 	.machines               = snd_soc_acpi_intel_arl_machines,
94 	.alt_machines           = snd_soc_acpi_intel_arl_sdw_machines,
95 	.resindex_lpe_base      = 0,
96 	.resindex_pcicfg_base   = -1,
97 	.resindex_imr_base      = -1,
98 	.irqindex_host_ipc      = -1,
99 	.chip_info = &arl_s_chip_info,
100 	.ipc_supported_mask     = BIT(SOF_IPC_TYPE_4),
101 	.ipc_default            = SOF_IPC_TYPE_4,
102 	.dspless_mode_supported = true,         /* Only supported for HDaudio */
103 	.default_fw_path = {
104 		[SOF_IPC_TYPE_4] = "intel/sof-ipc4/arl-s",
105 	},
106 	.default_lib_path = {
107 		[SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/arl-s",
108 	},
109 	.default_tplg_path = {
110 		[SOF_IPC_TYPE_4] = "intel/sof-ace-tplg",
111 	},
112 	.default_fw_filename = {
113 		[SOF_IPC_TYPE_4] = "sof-arl-s.ri",
114 	},
115 	.nocodec_tplg_filename = "sof-arl-nocodec.tplg",
116 	.ops = &sof_mtl_ops,
117 	.ops_init = sof_mtl_ops_init,
118 	.ops_free = hda_ops_free,
119 };
120 
121 /* PCI IDs */
122 static const struct pci_device_id sof_pci_ids[] = {
123 	{ PCI_DEVICE_DATA(INTEL, HDA_MTL, &mtl_desc) },
124 	{ PCI_DEVICE_DATA(INTEL, HDA_ARL_S, &arl_s_desc) },
125 	{ PCI_DEVICE_DATA(INTEL, HDA_ARL, &arl_desc) },
126 	{ 0, }
127 };
128 MODULE_DEVICE_TABLE(pci, sof_pci_ids);
129 
130 /* pci_driver definition */
131 static struct pci_driver snd_sof_pci_intel_mtl_driver = {
132 	.name = "sof-audio-pci-intel-mtl",
133 	.id_table = sof_pci_ids,
134 	.probe = hda_pci_intel_probe,
135 	.remove = sof_pci_remove,
136 	.shutdown = sof_pci_shutdown,
137 	.driver = {
138 		.pm = pm_ptr(&sof_pci_pm),
139 	},
140 };
141 module_pci_driver(snd_sof_pci_intel_mtl_driver);
142 
143 MODULE_LICENSE("Dual BSD/GPL");
144 MODULE_DESCRIPTION("SOF support for MeteorLake platforms");
145 MODULE_IMPORT_NS("SND_SOC_SOF_INTEL_HDA_GENERIC");
146 MODULE_IMPORT_NS("SND_SOC_SOF_INTEL_HDA_COMMON");
147 MODULE_IMPORT_NS("SND_SOC_SOF_PCI_DEV");
148