2023-08-07 16:09:45 -05:00
|
|
|
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
|
|
|
|
//
|
2024-05-03 09:03:51 -05:00
|
|
|
// Copyright(c) 2023 Intel Corporation
|
2023-08-07 16:09:45 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Hardware interface for audio DSP on LunarLake.
|
|
|
|
*/
|
|
|
|
|
2024-04-03 13:52:04 +03:00
|
|
|
#include <linux/debugfs.h>
|
2023-08-07 16:09:45 -05:00
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <sound/hda_register.h>
|
|
|
|
#include <sound/sof/ipc4/header.h>
|
|
|
|
#include <trace/events/sof_intel.h>
|
|
|
|
#include "../ipc4-priv.h"
|
|
|
|
#include "../ops.h"
|
|
|
|
#include "hda.h"
|
|
|
|
#include "hda-ipc.h"
|
|
|
|
#include "../sof-audio.h"
|
|
|
|
#include "mtl.h"
|
2024-04-03 13:52:06 +03:00
|
|
|
#include "lnl.h"
|
2023-08-07 16:09:45 -05:00
|
|
|
#include <sound/hda-mlink.h>
|
|
|
|
|
2023-08-07 16:09:47 -05:00
|
|
|
/* this helps allows the DSP to setup DMIC/SSP */
|
2024-04-03 14:18:39 +03:00
|
|
|
static int hdac_bus_offload_dmic_ssp(struct hdac_bus *bus, bool enable)
|
2023-08-07 16:09:47 -05:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2024-04-03 14:18:39 +03:00
|
|
|
ret = hdac_bus_eml_enable_offload(bus, true,
|
|
|
|
AZX_REG_ML_LEPTR_ID_INTEL_SSP, enable);
|
2023-08-07 16:09:47 -05:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2024-04-03 14:18:39 +03:00
|
|
|
ret = hdac_bus_eml_enable_offload(bus, true,
|
|
|
|
AZX_REG_ML_LEPTR_ID_INTEL_DMIC, enable);
|
2023-08-07 16:09:47 -05:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lnl_hda_dsp_probe(struct snd_sof_dev *sdev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = hda_dsp_probe(sdev);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2024-04-03 14:18:39 +03:00
|
|
|
return hdac_bus_offload_dmic_ssp(sof_to_bus(sdev), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lnl_hda_dsp_remove(struct snd_sof_dev *sdev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = hdac_bus_offload_dmic_ssp(sof_to_bus(sdev), false);
|
|
|
|
if (ret < 0)
|
|
|
|
dev_warn(sdev->dev,
|
|
|
|
"Failed to disable offload for DMIC/SSP: %d\n", ret);
|
|
|
|
|
|
|
|
hda_dsp_remove(sdev);
|
2023-08-07 16:09:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static int lnl_hda_dsp_resume(struct snd_sof_dev *sdev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = hda_dsp_resume(sdev);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2024-04-03 14:18:39 +03:00
|
|
|
return hdac_bus_offload_dmic_ssp(sof_to_bus(sdev), true);
|
2023-08-07 16:09:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static int lnl_hda_dsp_runtime_resume(struct snd_sof_dev *sdev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = hda_dsp_runtime_resume(sdev);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2024-04-03 14:18:39 +03:00
|
|
|
return hdac_bus_offload_dmic_ssp(sof_to_bus(sdev), true);
|
2023-08-07 16:09:47 -05:00
|
|
|
}
|
|
|
|
|
2024-02-13 12:12:42 +02:00
|
|
|
static int lnl_dsp_post_fw_run(struct snd_sof_dev *sdev)
|
|
|
|
{
|
|
|
|
if (sdev->first_boot) {
|
|
|
|
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
|
|
|
|
|
|
|
|
/* Check if IMR boot is usable */
|
2024-04-03 13:52:04 +03:00
|
|
|
if (!sof_debug_check_flag(SOF_DBG_IGNORE_D3_PERSISTENT)) {
|
2024-02-13 12:12:42 +02:00
|
|
|
hda->imrboot_supported = true;
|
2024-04-03 13:52:04 +03:00
|
|
|
debugfs_create_bool("skip_imr_boot",
|
|
|
|
0644, sdev->debugfs_root,
|
|
|
|
&hda->skip_imr_boot);
|
|
|
|
}
|
2024-02-13 12:12:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2025-03-07 13:28:10 +02:00
|
|
|
int sof_lnl_set_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *dsp_ops)
|
2023-08-07 16:09:46 -05:00
|
|
|
{
|
2025-03-07 13:28:10 +02:00
|
|
|
int ret;
|
2023-08-07 16:09:46 -05:00
|
|
|
|
2025-03-07 13:28:10 +02:00
|
|
|
ret = sof_mtl_set_ops(sdev, dsp_ops);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2023-08-07 16:09:46 -05:00
|
|
|
|
2024-04-03 14:18:39 +03:00
|
|
|
/* probe/remove */
|
|
|
|
if (!sdev->dspless_mode_selected) {
|
2025-03-07 13:28:10 +02:00
|
|
|
dsp_ops->probe = lnl_hda_dsp_probe;
|
|
|
|
dsp_ops->remove = lnl_hda_dsp_remove;
|
2024-04-03 14:18:39 +03:00
|
|
|
}
|
2023-08-07 16:09:47 -05:00
|
|
|
|
2025-03-07 13:28:10 +02:00
|
|
|
/* post fw run */
|
|
|
|
dsp_ops->post_fw_run = lnl_dsp_post_fw_run;
|
2023-08-07 16:09:46 -05:00
|
|
|
|
2023-08-07 16:09:47 -05:00
|
|
|
/* PM */
|
2024-02-13 12:12:46 +02:00
|
|
|
if (!sdev->dspless_mode_selected) {
|
2025-03-07 13:28:10 +02:00
|
|
|
dsp_ops->resume = lnl_hda_dsp_resume;
|
|
|
|
dsp_ops->runtime_resume = lnl_hda_dsp_runtime_resume;
|
2024-02-13 12:12:46 +02:00
|
|
|
}
|
2023-08-07 16:09:47 -05:00
|
|
|
|
2023-08-07 16:09:46 -05:00
|
|
|
return 0;
|
2025-03-07 13:28:10 +02:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_NS(sof_lnl_set_ops, "SND_SOC_SOF_INTEL_LNL");
|
2023-08-07 16:09:46 -05:00
|
|
|
|
2023-08-07 16:09:45 -05:00
|
|
|
/* Check if an SDW IRQ occurred */
|
2025-03-07 13:28:12 +02:00
|
|
|
bool lnl_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
|
2023-08-07 16:09:45 -05:00
|
|
|
{
|
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
|
|
|
|
return hdac_bus_eml_check_interrupt(bus, true, AZX_REG_ML_LEPTR_ID_SDW);
|
|
|
|
}
|
2025-03-07 13:28:12 +02:00
|
|
|
EXPORT_SYMBOL_NS(lnl_dsp_check_sdw_irq, "SND_SOC_SOF_INTEL_LNL");
|
2023-08-07 16:09:45 -05:00
|
|
|
|
2025-03-07 13:28:12 +02:00
|
|
|
int lnl_dsp_disable_interrupts(struct snd_sof_dev *sdev)
|
2023-08-07 16:09:45 -05:00
|
|
|
{
|
|
|
|
mtl_disable_ipc_interrupts(sdev);
|
|
|
|
return mtl_enable_interrupts(sdev, false);
|
|
|
|
}
|
2025-03-07 13:28:12 +02:00
|
|
|
EXPORT_SYMBOL_NS(lnl_dsp_disable_interrupts, "SND_SOC_SOF_INTEL_LNL");
|
2023-08-07 16:09:45 -05:00
|
|
|
|
2025-03-07 13:28:12 +02:00
|
|
|
bool lnl_sdw_check_wakeen_irq(struct snd_sof_dev *sdev)
|
2024-04-04 14:03:55 -05:00
|
|
|
{
|
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
u16 wake_sts;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we need to use the global HDaudio WAKEEN/STS to be able to
|
|
|
|
* detect wakes in low-power modes. The link-specific information
|
|
|
|
* is handled in the process_wakeen() helper, this helper only
|
|
|
|
* detects a SoundWire wake without identifying the link.
|
|
|
|
*/
|
|
|
|
wake_sts = snd_hdac_chip_readw(bus, STATESTS);
|
|
|
|
|
|
|
|
/* filter out the range of SDIs that can be set for SoundWire */
|
|
|
|
return wake_sts & GENMASK(SDW_MAX_DEVICES, SDW_INTEL_DEV_NUM_IDA_MIN);
|
|
|
|
}
|
2025-03-07 13:28:12 +02:00
|
|
|
EXPORT_SYMBOL_NS(lnl_sdw_check_wakeen_irq, "SND_SOC_SOF_INTEL_LNL");
|
2024-04-04 14:03:55 -05:00
|
|
|
|
2023-08-07 16:09:45 -05:00
|
|
|
const struct sof_intel_dsp_desc lnl_chip_info = {
|
|
|
|
.cores_num = 5,
|
|
|
|
.init_core_mask = BIT(0),
|
|
|
|
.host_managed_cores_mask = BIT(0),
|
|
|
|
.ipc_req = MTL_DSP_REG_HFIPCXIDR,
|
|
|
|
.ipc_req_mask = MTL_DSP_REG_HFIPCXIDR_BUSY,
|
|
|
|
.ipc_ack = MTL_DSP_REG_HFIPCXIDA,
|
|
|
|
.ipc_ack_mask = MTL_DSP_REG_HFIPCXIDA_DONE,
|
|
|
|
.ipc_ctl = MTL_DSP_REG_HFIPCXCTL,
|
2024-04-03 13:52:06 +03:00
|
|
|
.rom_status_reg = LNL_DSP_REG_HFDSC,
|
2023-08-07 16:09:45 -05:00
|
|
|
.rom_init_timeout = 300,
|
|
|
|
.ssp_count = MTL_SSP_COUNT,
|
|
|
|
.d0i3_offset = MTL_HDA_VS_D0I3C,
|
|
|
|
.read_sdw_lcount = hda_sdw_check_lcount_ext,
|
|
|
|
.check_sdw_irq = lnl_dsp_check_sdw_irq,
|
2024-04-04 14:03:55 -05:00
|
|
|
.check_sdw_wakeen_irq = lnl_sdw_check_wakeen_irq,
|
2024-05-03 08:52:20 -05:00
|
|
|
.sdw_process_wakeen = hda_sdw_process_wakeen_common,
|
2023-08-07 16:09:45 -05:00
|
|
|
.check_ipc_irq = mtl_dsp_check_ipc_irq,
|
|
|
|
.cl_init = mtl_dsp_cl_init,
|
|
|
|
.power_down_dsp = mtl_power_down_dsp,
|
|
|
|
.disable_interrupts = lnl_dsp_disable_interrupts,
|
|
|
|
.hw_ip_version = SOF_INTEL_ACE_2_0,
|
|
|
|
};
|
2024-08-02 14:40:09 +02:00
|
|
|
|
2025-03-07 13:28:10 +02:00
|
|
|
MODULE_IMPORT_NS("SND_SOC_SOF_INTEL_MTL");
|
|
|
|
MODULE_IMPORT_NS("SND_SOC_SOF_HDA_MLINK");
|