ASoC: SOF: Intel: split MTL and LNL operations
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 7 Aug 2023 21:09:46 +0000 (16:09 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 7 Aug 2023 22:09:36 +0000 (23:09 +0100)
It was just a matter of time before we found a case where we needed
separate ops for MTL and LNL. For LNL we need to set the DMIC/SSP
OFLEN bit in the probe and resume steps, and this can only be done
cleanly with separate ops.

The function prototypes in mtl.h were added in the same order as their
implementation in mtl.c.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230807210959.506849-8-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda.h
sound/soc/sof/intel/lnl.c
sound/soc/sof/intel/mtl.c
sound/soc/sof/intel/mtl.h
sound/soc/sof/intel/pci-lnl.c

index fae3be291861a344397f9360d8b685a7e6c380c3..17164fc42501c9e549e5f4b8eb3e79d7b623580c 100644 (file)
@@ -845,6 +845,8 @@ extern struct snd_sof_dsp_ops sof_icl_ops;
 int sof_icl_ops_init(struct snd_sof_dev *sdev);
 extern struct snd_sof_dsp_ops sof_mtl_ops;
 int sof_mtl_ops_init(struct snd_sof_dev *sdev);
+extern struct snd_sof_dsp_ops sof_lnl_ops;
+int sof_lnl_ops_init(struct snd_sof_dev *sdev);
 
 extern const struct sof_intel_dsp_desc skl_chip_info;
 extern const struct sof_intel_dsp_desc apl_chip_info;
index 535a0fd36f38be648a39f4ca7bb6e4d5ee2cd85f..65a78d9511e999fd6436d9c4a545c03ef775b5a5 100644 (file)
 #include "hda.h"
 #include <sound/hda-mlink.h>
 
+/* LunarLake ops */
+struct snd_sof_dsp_ops sof_lnl_ops;
+EXPORT_SYMBOL_NS(sof_lnl_ops, SND_SOC_SOF_INTEL_HDA_COMMON);
+
+static const struct snd_sof_debugfs_map lnl_dsp_debugfs[] = {
+       {"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS},
+       {"pp", HDA_DSP_PP_BAR,  0, 0x1000, SOF_DEBUGFS_ACCESS_ALWAYS},
+       {"dsp", HDA_DSP_BAR,  0, 0x10000, SOF_DEBUGFS_ACCESS_ALWAYS},
+};
+
+int sof_lnl_ops_init(struct snd_sof_dev *sdev)
+{
+       struct sof_ipc4_fw_data *ipc4_data;
+
+       /* common defaults */
+       memcpy(&sof_lnl_ops, &sof_hda_common_ops, sizeof(struct snd_sof_dsp_ops));
+
+       /* shutdown */
+       sof_lnl_ops.shutdown = hda_dsp_shutdown;
+
+       /* doorbell */
+       sof_lnl_ops.irq_thread = mtl_ipc_irq_thread;
+
+       /* ipc */
+       sof_lnl_ops.send_msg = mtl_ipc_send_msg;
+       sof_lnl_ops.get_mailbox_offset = mtl_dsp_ipc_get_mailbox_offset;
+       sof_lnl_ops.get_window_offset = mtl_dsp_ipc_get_window_offset;
+
+       /* debug */
+       sof_lnl_ops.debug_map = lnl_dsp_debugfs;
+       sof_lnl_ops.debug_map_count = ARRAY_SIZE(lnl_dsp_debugfs);
+       sof_lnl_ops.dbg_dump = mtl_dsp_dump;
+       sof_lnl_ops.ipc_dump = mtl_ipc_dump;
+
+       /* pre/post fw run */
+       sof_lnl_ops.pre_fw_run = mtl_dsp_pre_fw_run;
+       sof_lnl_ops.post_fw_run = mtl_dsp_post_fw_run;
+
+       /* parse platform specific extended manifest */
+       sof_lnl_ops.parse_platform_ext_manifest = NULL;
+
+       /* dsp core get/put */
+       /* TODO: add core_get and core_put */
+
+       sof_lnl_ops.get_stream_position = mtl_dsp_get_stream_hda_link_position;
+
+       sdev->private = devm_kzalloc(sdev->dev, sizeof(struct sof_ipc4_fw_data), GFP_KERNEL);
+       if (!sdev->private)
+               return -ENOMEM;
+
+       ipc4_data = sdev->private;
+       ipc4_data->manifest_fw_hdr_offset = SOF_MAN4_FW_HDR_OFFSET;
+
+       ipc4_data->mtrace_type = SOF_IPC4_MTRACE_INTEL_CAVS_2;
+
+       /* External library loading support */
+       ipc4_data->load_library = hda_dsp_ipc4_load_library;
+
+       /* set DAI ops */
+       hda_set_dai_drv_ops(sdev, &sof_lnl_ops);
+
+       sof_lnl_ops.set_power_state = hda_dsp_set_power_state_ipc4;
+
+       return 0;
+};
+EXPORT_SYMBOL_NS(sof_lnl_ops_init, SND_SOC_SOF_INTEL_HDA_COMMON);
+
 /* Check if an SDW IRQ occurred */
 static bool lnl_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
 {
index 30fe77fd87bf8dddbaa8cc5c7012f6045f8748ad..be3155f9894469dac1f04977623d24512cbb3500 100644 (file)
@@ -91,7 +91,7 @@ static bool mtl_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
        return false;
 }
 
-static int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
+int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
 {
        struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
        struct sof_ipc4_msg *msg_data = msg->msg_data;
@@ -230,7 +230,7 @@ int mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable)
 }
 
 /* pre fw run operations */
-static int mtl_dsp_pre_fw_run(struct snd_sof_dev *sdev)
+int mtl_dsp_pre_fw_run(struct snd_sof_dev *sdev)
 {
        struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
        u32 dsphfpwrsts;
@@ -279,7 +279,7 @@ static int mtl_dsp_pre_fw_run(struct snd_sof_dev *sdev)
        return ret;
 }
 
-static int mtl_dsp_post_fw_run(struct snd_sof_dev *sdev)
+int mtl_dsp_post_fw_run(struct snd_sof_dev *sdev)
 {
        int ret;
 
@@ -301,7 +301,7 @@ static int mtl_dsp_post_fw_run(struct snd_sof_dev *sdev)
        return 0;
 }
 
-static void mtl_dsp_dump(struct snd_sof_dev *sdev, u32 flags)
+void mtl_dsp_dump(struct snd_sof_dev *sdev, u32 flags)
 {
        char *level = (flags & SOF_DBG_DUMP_OPTIONAL) ? KERN_DEBUG : KERN_ERR;
        u32 romdbgsts;
@@ -495,7 +495,7 @@ err:
        return ret;
 }
 
-static irqreturn_t mtl_ipc_irq_thread(int irq, void *context)
+irqreturn_t mtl_ipc_irq_thread(int irq, void *context)
 {
        struct sof_ipc4_msg notification_data = {{ 0 }};
        struct snd_sof_dev *sdev = context;
@@ -578,17 +578,17 @@ static irqreturn_t mtl_ipc_irq_thread(int irq, void *context)
        return IRQ_HANDLED;
 }
 
-static int mtl_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev)
+int mtl_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev)
 {
        return MTL_DSP_MBOX_UPLINK_OFFSET;
 }
 
-static int mtl_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id)
+int mtl_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id)
 {
        return MTL_SRAM_WINDOW_OFFSET(id);
 }
 
-static void mtl_ipc_dump(struct snd_sof_dev *sdev)
+void mtl_ipc_dump(struct snd_sof_dev *sdev)
 {
        u32 hipcidr, hipcidd, hipcida, hipctdr, hipctdd, hipctda, hipcctl;
 
@@ -612,9 +612,9 @@ static int mtl_dsp_disable_interrupts(struct snd_sof_dev *sdev)
        return mtl_enable_interrupts(sdev, false);
 }
 
-static u64 mtl_dsp_get_stream_hda_link_position(struct snd_sof_dev *sdev,
-                                               struct snd_soc_component *component,
-                                               struct snd_pcm_substream *substream)
+u64 mtl_dsp_get_stream_hda_link_position(struct snd_sof_dev *sdev,
+                                        struct snd_soc_component *component,
+                                        struct snd_pcm_substream *substream)
 {
        struct hdac_stream *hstream = substream->runtime->private_data;
        u32 llp_l, llp_u;
index 2794fe6e81396dd84f6e0db069b8218a65401741..02181490f12a6f1b550e0463dcae039161a0993b 100644 (file)
 #define MTL_DSP_REG_HfIMRIS1           0x162088
 #define MTL_DSP_REG_HfIMRIS1_IU_MASK   BIT(0)
 
+bool mtl_dsp_check_ipc_irq(struct snd_sof_dev *sdev);
+int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
+
 void mtl_enable_ipc_interrupts(struct snd_sof_dev *sdev);
 void mtl_disable_ipc_interrupts(struct snd_sof_dev *sdev);
-bool mtl_dsp_check_ipc_irq(struct snd_sof_dev *sdev);
 
 int mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable);
-int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot);
+
+int mtl_dsp_pre_fw_run(struct snd_sof_dev *sdev);
+int mtl_dsp_post_fw_run(struct snd_sof_dev *sdev);
+void mtl_dsp_dump(struct snd_sof_dev *sdev, u32 flags);
+
 int mtl_power_down_dsp(struct snd_sof_dev *sdev);
+int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot);
+
+irqreturn_t mtl_ipc_irq_thread(int irq, void *context);
+
+int mtl_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev);
+int mtl_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id);
+
+void mtl_ipc_dump(struct snd_sof_dev *sdev);
+
+u64 mtl_dsp_get_stream_hda_link_position(struct snd_sof_dev *sdev,
+                                        struct snd_soc_component *component,
+                                        struct snd_pcm_substream *substream);
index 55c757737a950b89bc1b194ba162c6ae8693656b..1b12c280edb46c3146e03721593050ed9c2252d3 100644 (file)
@@ -42,9 +42,8 @@ static const struct sof_dev_desc lnl_desc = {
                [SOF_INTEL_IPC4] = "sof-lnl.ri",
        },
        .nocodec_tplg_filename = "sof-lnl-nocodec.tplg",
-       /* the MTL ops are still used for now */
-       .ops = &sof_mtl_ops,
-       .ops_init = sof_mtl_ops_init,
+       .ops = &sof_lnl_ops,
+       .ops_init = sof_lnl_ops_init,
 };
 
 /* PCI IDs */