From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: alsa-devel@alsa-project.org, vkoul@kernel.org
Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org,
tiwai@suse.de, broonie@kernel.org,
pierre-louis.bossart@linux.intel.com, bard.liao@intel.com
Subject: [PATCH 3/8] ASoC: SOF: Intel: mtl: factor interrupt enable/disable interrupt functions
Date: Fri, 11 Nov 2022 12:26:48 +0800 [thread overview]
Message-ID: <20221111042653.45520-4-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20221111042653.45520-1-yung-chuan.liao@linux.intel.com>
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The offsets and sequences are identical for interrupt enabling and
disabling, we can refactor the code with a single routine and a
boolean.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
sound/soc/sof/intel/mtl.c | 120 +++++++++++++-------------------------
1 file changed, 40 insertions(+), 80 deletions(-)
diff --git a/sound/soc/sof/intel/mtl.c b/sound/soc/sof/intel/mtl.c
index 7452a7dbb0e4..43ffcccec0be 100644
--- a/sound/soc/sof/intel/mtl.c
+++ b/sound/soc/sof/intel/mtl.c
@@ -134,112 +134,72 @@ static void mtl_disable_ipc_interrupts(struct snd_sof_dev *sdev)
MTL_DSP_REG_HFIPCXCTL_BUSY | MTL_DSP_REG_HFIPCXCTL_DONE, 0);
}
-static int mtl_enable_interrupts(struct snd_sof_dev *sdev)
+static int mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable)
{
u32 hfintipptr;
u32 irqinten;
- u32 host_ipc;
u32 hipcie;
+ u32 mask;
+ u32 val;
int ret;
/* read Interrupt IP Pointer */
hfintipptr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFINTIPPTR) & MTL_HFINTIPPTR_PTR_MASK;
- /* Enable Host IPC and SOUNDWIRE */
- snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, hfintipptr,
- MTL_IRQ_INTEN_L_HOST_IPC_MASK | MTL_IRQ_INTEN_L_SOUNDWIRE_MASK,
- MTL_IRQ_INTEN_L_HOST_IPC_MASK | MTL_IRQ_INTEN_L_SOUNDWIRE_MASK);
+ /* Enable/Disable Host IPC and SOUNDWIRE */
+ mask = MTL_IRQ_INTEN_L_HOST_IPC_MASK | MTL_IRQ_INTEN_L_SOUNDWIRE_MASK;
+ if (enable)
+ val = mask;
+ else
+ val = 0;
+
+ snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, hfintipptr, mask, val);
/* check if operation was successful */
- host_ipc = MTL_IRQ_INTEN_L_HOST_IPC_MASK | MTL_IRQ_INTEN_L_SOUNDWIRE_MASK;
ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, hfintipptr, irqinten,
- (irqinten & host_ipc) == host_ipc,
+ (irqinten & mask) == val,
HDA_DSP_REG_POLL_INTERVAL_US, HDA_DSP_RESET_TIMEOUT_US);
if (ret < 0) {
- dev_err(sdev->dev, "failed to enable Host IPC and/or SOUNDWIRE\n");
+ dev_err(sdev->dev, "failed to %s Host IPC and/or SOUNDWIRE\n",
+ enable ? "enable" : "disable");
return ret;
}
- /* Set Host IPC interrupt enable */
- snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfHIPCIE,
- MTL_DSP_REG_HfHIPCIE_IE_MASK, MTL_DSP_REG_HfHIPCIE_IE_MASK);
+ /* Enable/Disable Host IPC interrupt*/
+ mask = MTL_DSP_REG_HfHIPCIE_IE_MASK;
+ if (enable)
+ val = mask;
+ else
+ val = 0;
+
+ snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfHIPCIE, mask, val);
/* check if operation was successful */
- host_ipc = MTL_DSP_REG_HfHIPCIE_IE_MASK;
ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfHIPCIE, hipcie,
- (hipcie & host_ipc) == host_ipc,
+ (hipcie & mask) == val,
HDA_DSP_REG_POLL_INTERVAL_US, HDA_DSP_RESET_TIMEOUT_US);
if (ret < 0) {
- dev_err(sdev->dev, "failed to set Host IPC interrupt enable\n");
+ dev_err(sdev->dev, "failed to set Host IPC interrupt %s\n",
+ enable ? "enable" : "disable");
return ret;
}
- snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfSNDWIE,
- MTL_DSP_REG_HfSNDWIE_IE_MASK, MTL_DSP_REG_HfSNDWIE_IE_MASK);
- host_ipc = MTL_DSP_REG_HfSNDWIE_IE_MASK;
+ /* Enable/Disable SoundWire interrupt */
+ mask = MTL_DSP_REG_HfSNDWIE_IE_MASK;
+ if (enable)
+ val = mask;
+ else
+ val = 0;
+
+ snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfSNDWIE, mask, val);
+
+ /* check if operation was successful */
ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfSNDWIE, hipcie,
- (hipcie & host_ipc) == host_ipc,
+ (hipcie & mask) == val,
HDA_DSP_REG_POLL_INTERVAL_US, HDA_DSP_RESET_TIMEOUT_US);
if (ret < 0)
- dev_err(sdev->dev, "failed to set SoundWire IPC interrupt enable\n");
-
- return ret;
-}
-
-static int mtl_disable_interrupts(struct snd_sof_dev *sdev)
-{
- u32 hfintipptr;
- u32 irqinten;
- u32 host_ipc;
- u32 hipcie;
- int ret1;
- int ret;
-
- /* read Interrupt IP Pointer */
- hfintipptr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFINTIPPTR) & MTL_HFINTIPPTR_PTR_MASK;
-
- /* Disable Host IPC and SOUNDWIRE */
- snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, hfintipptr,
- MTL_IRQ_INTEN_L_HOST_IPC_MASK | MTL_IRQ_INTEN_L_SOUNDWIRE_MASK, 0);
-
- /* check if operation was successful */
- host_ipc = MTL_IRQ_INTEN_L_HOST_IPC_MASK | MTL_IRQ_INTEN_L_SOUNDWIRE_MASK;
- ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, hfintipptr, irqinten,
- (irqinten & host_ipc) == 0,
- HDA_DSP_REG_POLL_INTERVAL_US, HDA_DSP_RESET_TIMEOUT_US);
- /* Continue to disable other interrupts when error happens */
- if (ret < 0)
- dev_err(sdev->dev, "failed to disable Host IPC and SoundWire\n");
-
- /* Set Host IPC interrupt disable */
- snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfHIPCIE,
- MTL_DSP_REG_HfHIPCIE_IE_MASK, 0);
-
- /* check if operation was successful */
- host_ipc = MTL_DSP_REG_HfHIPCIE_IE_MASK;
- ret1 = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfHIPCIE, hipcie,
- (hipcie & host_ipc) == 0,
- HDA_DSP_REG_POLL_INTERVAL_US,
- HDA_DSP_RESET_TIMEOUT_US);
- if (ret1 < 0) {
- dev_err(sdev->dev, "failed to set Host IPC interrupt disable\n");
- if (!ret)
- ret = ret1;
- }
-
- /* Set SoundWire IPC interrupt disable */
- snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfSNDWIE,
- MTL_DSP_REG_HfSNDWIE_IE_MASK, 0);
- host_ipc = MTL_DSP_REG_HfSNDWIE_IE_MASK;
- ret1 = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfSNDWIE, hipcie,
- (hipcie & host_ipc) == 0,
- HDA_DSP_REG_POLL_INTERVAL_US,
- HDA_DSP_RESET_TIMEOUT_US);
- if (ret1 < 0) {
- dev_err(sdev->dev, "failed to set SoundWire IPC interrupt disable\n");
- if (!ret)
- ret = ret1;
- }
+ dev_err(sdev->dev, "failed to set SoundWire IPC interrupt %s\n",
+ enable ? "enable" : "disable");
return ret;
}
@@ -473,7 +433,7 @@ static int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_bo
chip->ipc_ack_mask);
/* step 4: enable interrupts */
- ret = mtl_enable_interrupts(sdev);
+ ret = mtl_enable_interrupts(sdev, true);
if (ret < 0) {
if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS)
dev_err(sdev->dev, "%s: failed to enable interrupts\n", __func__);
@@ -609,7 +569,7 @@ static void mtl_ipc_dump(struct snd_sof_dev *sdev)
static int mtl_dsp_disable_interrupts(struct snd_sof_dev *sdev)
{
mtl_disable_ipc_interrupts(sdev);
- return mtl_disable_interrupts(sdev);
+ return mtl_enable_interrupts(sdev, false);
}
/* Meteorlake ops */
--
2.25.1
next prev parent reply other threads:[~2022-11-11 4:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 4:26 [PATCH 0/8] ASoC/soundwire: revisit interrupt and lcount handling Bard Liao
2022-11-11 4:26 ` [PATCH 1/8] soundwire: intel_init: remove useless interrupt enablement in interrupt thread Bard Liao
2022-11-23 14:45 ` Vinod Koul
2022-11-11 4:26 ` [PATCH 2/8] ASoC: SOF: Intel: hda: add per-chip enable_sdw_irq() callback Bard Liao
2022-11-11 4:26 ` Bard Liao [this message]
2022-11-11 4:26 ` [PATCH 4/8] ASoC: SOF: Intel: mtl: move SoundWire interrupt enabling to callback Bard Liao
2022-11-11 4:26 ` [PATCH 5/8] ASoC: SOF: Intel: hda: add callback to check SoundWire lcount information Bard Liao
2022-11-11 4:26 ` [PATCH 6/8] soundwire: intel_init: remove sdw_intel_enable_irq() Bard Liao
2022-11-23 14:46 ` Vinod Koul
2022-11-11 4:26 ` [PATCH 7/8] soundwire: intel_init: remove check on number of links Bard Liao
2022-11-23 14:45 ` Vinod Koul
2022-11-11 4:26 ` [PATCH 8/8] ASoC: SOF: Intel: hda: read multi-link capabilities earlier Bard Liao
2022-11-25 14:26 ` [PATCH 0/8] ASoC/soundwire: revisit interrupt and lcount handling Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221111042653.45520-4-yung-chuan.liao@linux.intel.com \
--to=yung-chuan.liao@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=bard.liao@intel.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=tiwai@suse.de \
--cc=vinod.koul@linaro.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®