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 Intel Corporation. All rights reserved.
7 //
8 // Authors: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9 //	    Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
10 //	    Rander Wang <rander.wang@intel.com>
11 //          Keyon Jie <yang.jie@linux.intel.com>
12 //
13 
14 /*
15  * Hardware interface for audio DSP on Apollolake and GeminiLake
16  */
17 
18 #include <sound/sof/ext_manifest4.h>
19 #include "../ipc4-priv.h"
20 #include "../sof-priv.h"
21 #include "hda.h"
22 #include "../sof-audio.h"
23 
24 static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = {
25 	{"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS},
26 	{"pp", HDA_DSP_PP_BAR,  0, 0x1000, SOF_DEBUGFS_ACCESS_ALWAYS},
27 	{"dsp", HDA_DSP_BAR,  0, 0x10000, SOF_DEBUGFS_ACCESS_ALWAYS},
28 };
29 
30 /* apollolake ops */
31 struct snd_sof_dsp_ops sof_apl_ops;
32 EXPORT_SYMBOL_NS(sof_apl_ops, SND_SOC_SOF_INTEL_HDA_COMMON);
33 
sof_apl_ops_init(struct snd_sof_dev * sdev)34 int sof_apl_ops_init(struct snd_sof_dev *sdev)
35 {
36 	/* common defaults */
37 	memcpy(&sof_apl_ops, &sof_hda_common_ops, sizeof(struct snd_sof_dsp_ops));
38 
39 	/* probe/remove/shutdown */
40 	sof_apl_ops.shutdown	= hda_dsp_shutdown;
41 
42 	if (sdev->pdata->ipc_type == SOF_IPC) {
43 		/* doorbell */
44 		sof_apl_ops.irq_thread	= hda_dsp_ipc_irq_thread;
45 
46 		/* ipc */
47 		sof_apl_ops.send_msg	= hda_dsp_ipc_send_msg;
48 
49 		/* debug */
50 		sof_apl_ops.ipc_dump	= hda_ipc_dump;
51 	}
52 
53 	if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
54 		struct sof_ipc4_fw_data *ipc4_data;
55 
56 		sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL);
57 		if (!sdev->private)
58 			return -ENOMEM;
59 
60 		ipc4_data = sdev->private;
61 		ipc4_data->manifest_fw_hdr_offset = SOF_MAN4_FW_HDR_OFFSET;
62 
63 		ipc4_data->mtrace_type = SOF_IPC4_MTRACE_INTEL_CAVS_1_5;
64 
65 		/* doorbell */
66 		sof_apl_ops.irq_thread	= hda_dsp_ipc4_irq_thread;
67 
68 		/* ipc */
69 		sof_apl_ops.send_msg	= hda_dsp_ipc4_send_msg;
70 
71 		/* debug */
72 		sof_apl_ops.ipc_dump	= hda_ipc4_dump;
73 	}
74 
75 	/* set DAI driver ops */
76 	hda_set_dai_drv_ops(sdev, &sof_apl_ops);
77 
78 	/* debug */
79 	sof_apl_ops.debug_map	= apl_dsp_debugfs;
80 	sof_apl_ops.debug_map_count	= ARRAY_SIZE(apl_dsp_debugfs);
81 
82 	/* firmware run */
83 	sof_apl_ops.run = hda_dsp_cl_boot_firmware;
84 
85 	/* pre/post fw run */
86 	sof_apl_ops.post_fw_run = hda_dsp_post_fw_run;
87 
88 	/* dsp core get/put */
89 	sof_apl_ops.core_get = hda_dsp_core_get;
90 
91 	return 0;
92 };
93 EXPORT_SYMBOL_NS(sof_apl_ops_init, SND_SOC_SOF_INTEL_HDA_COMMON);
94 
95 const struct sof_intel_dsp_desc apl_chip_info = {
96 	/* Apollolake */
97 	.cores_num = 2,
98 	.init_core_mask = 1,
99 	.host_managed_cores_mask = GENMASK(1, 0),
100 	.ipc_req = HDA_DSP_REG_HIPCI,
101 	.ipc_req_mask = HDA_DSP_REG_HIPCI_BUSY,
102 	.ipc_ack = HDA_DSP_REG_HIPCIE,
103 	.ipc_ack_mask = HDA_DSP_REG_HIPCIE_DONE,
104 	.ipc_ctl = HDA_DSP_REG_HIPCCTL,
105 	.rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS,
106 	.rom_init_timeout	= 150,
107 	.ssp_count = APL_SSP_COUNT,
108 	.ssp_base_offset = APL_SSP_BASE_OFFSET,
109 	.quirks = SOF_INTEL_PROCEN_FMT_QUIRK,
110 	.check_ipc_irq	= hda_dsp_check_ipc_irq,
111 	.cl_init = cl_dsp_init,
112 	.power_down_dsp = hda_power_down_dsp,
113 	.disable_interrupts = hda_dsp_disable_interrupts,
114 	.hw_ip_version = SOF_INTEL_CAVS_1_5_PLUS,
115 };
116 EXPORT_SYMBOL_NS(apl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON);
117