All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@kernel.org,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Rander Wang <rander.wang@intel.com>
Subject: [PATCH v2 09/11] ASoC: SOF: Intel: hda: add WAKEEN interrupt support for SoundWire
Date: Wed, 25 Mar 2020 16:50:25 -0500	[thread overview]
Message-ID: <20200325215027.28716-10-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20200325215027.28716-1-pierre-louis.bossart@linux.intel.com>

From: Rander Wang <rander.wang@intel.com>

When a SoundWire link is in clock stop state, a Slave device may wake
up the Master for some events such as jack detection. The WAKEEN
interrupt will be triggered and processed by the audio pci device.

If audio device is in D3, the interrupt will be routed to PME, or
aggregated at cAVS level as interrupt when audio device is in D0. This
patch only supports D3 case, where the audio pci device will be
resumed by a PME event and the WAKEEN interrupt will be processed
after audio pci device is powered up and ROM is initialized
successfully.

The WAKEEN handling is only enabled after the first boot due to
dependencies on a shim_lock mutex being initialized.

Signed-off-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/intel/hda-loader.c | 18 ++++++++++++++++++
 sound/soc/sof/intel/hda.c        | 11 +++++++++++
 sound/soc/sof/intel/hda.h        |  5 +++++
 3 files changed, 34 insertions(+)

diff --git a/sound/soc/sof/intel/hda-loader.c b/sound/soc/sof/intel/hda-loader.c
index 2ae94ea53122..e1550ccd0a49 100644
--- a/sound/soc/sof/intel/hda-loader.c
+++ b/sound/soc/sof/intel/hda-loader.c
@@ -346,6 +346,24 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev)
 		goto cleanup;
 	}
 
+	/*
+	 * When a SoundWire link is in clock stop state, a Slave
+	 * device may trigger in-band wakes for events such as jack
+	 * insertion or acoustic event detection. This event will lead
+	 * to a WAKEEN interrupt, handled by the PCI device and routed
+	 * to PME if the PCI device is in D3. The resume function in
+	 * audio PCI driver will be invoked by ACPI for PME event and
+	 * initialize the device and process WAKEEN interrupt.
+	 *
+	 * The WAKEEN interrupt should be processed ASAP to prevent an
+	 * interrupt flood, otherwise other interrupts, such IPC,
+	 * cannot work normally.  The WAKEEN is handled after the ROM
+	 * is initialized successfully, which ensures power rails are
+	 * enabled before accessing the SoundWire SHIM registers
+	 */
+	if (!sdev->first_boot)
+		hda_sdw_process_wakeen(sdev);
+
 	/*
 	 * at this point DSP ROM has been initialized and
 	 * should be ready for code loading and firmware boot
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 1e69cfcee8e0..7d1aa4c7d82c 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -241,6 +241,17 @@ static irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
 	return sdw_intel_thread(irq, context);
 }
 
+void hda_sdw_process_wakeen(struct snd_sof_dev *sdev)
+{
+	struct sof_intel_hda_dev *hdev;
+
+	hdev = sdev->pdata->hw_pdata;
+	if (!hdev->sdw)
+		return;
+
+	sdw_intel_process_wakeen_event(hdev->sdw);
+}
+
 #endif
 
 /*
diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h
index fc104c5ba006..6f1765b1ed1d 100644
--- a/sound/soc/sof/intel/hda.h
+++ b/sound/soc/sof/intel/hda.h
@@ -671,6 +671,7 @@ int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
 
 int hda_sdw_startup(struct snd_sof_dev *sdev);
 void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable);
+void hda_sdw_process_wakeen(struct snd_sof_dev *sdev);
 
 #else
 
@@ -707,6 +708,10 @@ static inline irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
 {
 	return IRQ_HANDLED;
 }
+
+static inline void hda_sdw_process_wakeen(struct snd_sof_dev *sdev)
+{
+}
 #endif
 
 /* common dai driver */
-- 
2.20.1


  parent reply	other threads:[~2020-03-25 21:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 21:50 [PATCH v2 00/11] ASoC: SOF: Intel: add SoundWire support Pierre-Louis Bossart
2020-03-25 21:50 ` [PATCH v2 01/11] ASoC: soc-acpi: expand description of _ADR-based devices Pierre-Louis Bossart
2020-03-27 15:34   ` Applied "ASoC: soc-acpi: expand description of _ADR-based devices" to the asoc tree Mark Brown
2020-03-25 21:50 ` [PATCH v2 02/11] ASoC: SOF: Intel: add SoundWire configuration interface Pierre-Louis Bossart
2020-03-25 21:50 ` [PATCH v2 03/11] ASoC: SOF: IPC: dai-intel: move ALH declarations in header file Pierre-Louis Bossart
2020-03-25 21:50 ` [PATCH v2 04/11] ASoC: SOF: Intel: hda: add SoundWire stream config/free callbacks Pierre-Louis Bossart
2020-03-25 21:50 ` [PATCH v2 05/11] ASoC: SOF: Intel: hda: initial SoundWire machine driver autodetect Pierre-Louis Bossart
2020-03-27 15:34   ` Applied "ASoC: SOF: Intel: hda: initial SoundWire machine driver autodetect" to the asoc tree Mark Brown
2020-03-25 21:50 ` [PATCH v2 06/11] ASoC: SOF: Intel: hda: disable SoundWire interrupts on suspend Pierre-Louis Bossart
2020-03-25 21:50 ` [PATCH v2 07/11] ASoC: SOF: Intel: hda: merge IPC, stream and SoundWire interrupt handlers Pierre-Louis Bossart
2020-03-25 21:50 ` [PATCH v2 08/11] ASoC: SOF: Intel: hda: add parameter to control SoundWire clock stop quirks Pierre-Louis Bossart
2020-03-25 21:50 ` Pierre-Louis Bossart [this message]
2020-03-25 21:50 ` [PATCH v2 10/11] Asoc: SOF: Intel: hda: check SoundWire wakeen interrupt in irq thread Pierre-Louis Bossart
2020-03-25 21:50 ` [PATCH v2 11/11] ASoC: SOF: Intel: hda-ctrl: add reset cycle before parsing capabilities Pierre-Louis Bossart
2020-03-27 15:33   ` Applied "ASoC: SOF: Intel: hda-ctrl: add reset cycle before parsing capabilities" to the asoc tree 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=20200325215027.28716-10-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=rander.wang@intel.com \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.