All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: alsa-devel@alsa-project.org
Cc: patches.audio@intel.com,
	Pardha Saradhi K <pardha.saradhi.kesapragada@intel.com>,
	Jayachandran B <jayachandran.b@intel.com>,
	liam.r.girdwood@linux.intel.com,
	Vinod Koul <vinod.koul@intel.com>,
	broonie@kernel.org
Subject: [PATCH 04/10] ASoC: Intel: Skylake: Add support for programming D0i3C
Date: Mon, 26 Sep 2016 11:05:31 +0530	[thread overview]
Message-ID: <1474868137-29712-5-git-send-email-vinod.koul@intel.com> (raw)
In-Reply-To: <1474868137-29712-1-git-send-email-vinod.koul@intel.com>

From: Pardha Saradhi K <pardha.saradhi.kesapragada@intel.com>

To set the controller in D0i3 mode, the driver needs to set D0i3C
register after DSP is quiesced. Since the D0iX entry/exit is done by IPC,
add this as callback so that it can be invoked from IPC module.

Signed-off-by: Pardha Saradhi K <pardha.saradhi.kesapragada@intel.com>
Signed-off-by: Jayachandran B <jayachandran.b@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 sound/soc/intel/skylake/skl-pcm.c     |  1 +
 sound/soc/intel/skylake/skl-sst-ipc.h |  3 +++
 sound/soc/intel/skylake/skl.c         | 47 +++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl.h         |  5 ++++
 4 files changed, 56 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index c7cdcba04c5d..792b989733bf 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1197,6 +1197,7 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform)
 			return ret;
 		}
 		skl_populate_modules(skl);
+		skl->skl_sst->update_d0i3c = skl_update_d0i3c;
 	}
 	pm_runtime_mark_last_busy(platform->dev);
 	pm_runtime_put_autosuspend(platform->dev);
diff --git a/sound/soc/intel/skylake/skl-sst-ipc.h b/sound/soc/intel/skylake/skl-sst-ipc.h
index 1ae265d8ee08..ef2182d21934 100644
--- a/sound/soc/intel/skylake/skl-sst-ipc.h
+++ b/sound/soc/intel/skylake/skl-sst-ipc.h
@@ -83,6 +83,9 @@ struct skl_sst {
 
 	/* tplg manifest */
 	struct skl_dfw_manifest manifest;
+
+	/* Callback to update D0i3C register */
+	void (*update_d0i3c)(struct device *dev, bool enable);
 };
 
 struct skl_ipc_init_instance_msg {
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 2989c164dafe..b9209af89915 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -26,6 +26,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/platform_device.h>
 #include <linux/firmware.h>
+#include <linux/delay.h>
 #include <sound/pcm.h>
 #include "../common/sst-acpi.h"
 #include <sound/hda_register.h>
@@ -109,6 +110,52 @@ static int skl_init_chip(struct hdac_bus *bus, bool full_reset)
 	return ret;
 }
 
+void skl_update_d0i3c(struct device *dev, bool enable)
+{
+	struct pci_dev *pci = to_pci_dev(dev);
+	struct hdac_ext_bus *ebus = pci_get_drvdata(pci);
+	struct hdac_bus *bus = ebus_to_hbus(ebus);
+	u8 reg;
+	int timeout = 50;
+
+	reg = snd_hdac_chip_readb(bus, VS_D0I3C);
+	/* Do not write to D0I3C until command in progress bit is cleared */
+	while ((reg & AZX_REG_VS_D0I3C_CIP) && --timeout) {
+		udelay(10);
+		reg = snd_hdac_chip_readb(bus, VS_D0I3C);
+	}
+
+	/* Highly unlikely. But if it happens, flag error explicitly */
+	if (!timeout) {
+		dev_err(bus->dev, "Before D0I3C update: D0I3C CIP timeout\n");
+		return;
+	}
+
+	if (enable)
+		reg = reg | AZX_REG_VS_D0I3C_I3;
+	else
+		reg = reg & (~AZX_REG_VS_D0I3C_I3);
+
+	snd_hdac_chip_writeb(bus, VS_D0I3C, reg);
+
+	timeout = 50;
+	/* Wait for cmd in progress to be cleared before exiting the function */
+	reg = snd_hdac_chip_readb(bus, VS_D0I3C);
+	while ((reg & AZX_REG_VS_D0I3C_CIP) && --timeout) {
+		udelay(10);
+		reg = snd_hdac_chip_readb(bus, VS_D0I3C);
+	}
+
+	/* Highly unlikely. But if it happens, flag error explicitly */
+	if (!timeout) {
+		dev_err(bus->dev, "After D0I3C update: D0I3C CIP timeout\n");
+		return;
+	}
+
+	dev_dbg(bus->dev, "D0I3C register = 0x%x\n",
+			snd_hdac_chip_readb(bus, VS_D0I3C));
+}
+
 /* called from IRQ */
 static void skl_stream_update(struct hdac_bus *bus, struct hdac_stream *hstr)
 {
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 5d4fbb094c48..88ba54ba5f72 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -52,6 +52,9 @@
 #define AZX_PGCTL_LSRMD_MASK		(1 << 4)
 #define AZX_PCIREG_CGCTL		0x48
 #define AZX_CGCTL_MISCBDCGE_MASK	(1 << 6)
+/* D0I3C Register fields */
+#define AZX_REG_VS_D0I3C_CIP      0x1 /* Command in progress */
+#define AZX_REG_VS_D0I3C_I3       0x4 /* D0i3 enable */
 
 struct skl_dsp_resource {
 	u32 max_mcps;
@@ -125,4 +128,6 @@ int skl_suspend_dsp(struct skl *skl);
 int skl_resume_dsp(struct skl *skl);
 void skl_cleanup_resources(struct skl *skl);
 const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id);
+void skl_update_d0i3c(struct device *dev, bool enable);
+
 #endif /* __SOUND_SOC_SKL_H */
-- 
1.9.1

  parent reply	other threads:[~2016-09-26  5:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26  5:35 [PATCH 00/10] ASoC: Intel: Skylake: Add support for D0i3 Vinod Koul
2016-09-26  5:35 ` [PATCH 01/10] ASoC: Intel: Add check_dsp_lp_on callback on IPC Vinod Koul
2016-09-26  5:35 ` [PATCH 02/10] ASoC: Intel: Add sst_ipc_tx_message_nopm Vinod Koul
2016-10-28 18:05   ` Mark Brown
2016-10-30 21:37     ` Vinod Koul
2016-11-03 17:27   ` Applied "ASoC: Intel: Add sst_ipc_tx_message_nopm" to the asoc tree Mark Brown
2016-09-26  5:35 ` [PATCH 03/10] ASoC: Intel: Skylake: Add D0iX IPCs Vinod Koul
2016-10-28 18:06   ` Mark Brown
2016-10-30 21:40     ` Vinod Koul
2016-11-03 17:27   ` Applied "ASoC: Intel: Skylake: Add D0iX IPCs" to the asoc tree Mark Brown
2016-09-26  5:35 ` Vinod Koul [this message]
2016-11-03 17:27   ` Applied "ASoC: Intel: Skylake: Add support for programming D0i3C" " Mark Brown
2016-09-26  5:35 ` [PATCH 05/10] ASoC: Intel: Skylake: Add D0iX callbacks Vinod Koul
2016-11-03 17:26   ` Applied "ASoC: Intel: Skylake: Add D0iX callbacks" to the asoc tree Mark Brown
2016-09-26  5:35 ` [PATCH 06/10] ASoC: Intel: Skylake: Add support for LPMode Vinod Koul
2016-11-03 17:26   ` Applied "ASoC: Intel: Skylake: Add support for LPMode" to the asoc tree Mark Brown
2016-09-26  5:35 ` [PATCH 07/10] ASoC: Intel: Skylake: Add support for specifying D0i3 configuration Vinod Koul
2016-11-03 17:26   ` Applied "ASoC: Intel: Skylake: Add support for specifying D0i3 configuration" to the asoc tree Mark Brown
2016-09-26  5:35 ` [PATCH 08/10] ASoC: Intel: Skylake: Add D0i3 mode ref counting Vinod Koul
2016-11-03 17:26   ` Applied "ASoC: Intel: Skylake: Add D0i3 mode ref counting" to the asoc tree Mark Brown
2016-09-26  5:35 ` [PATCH 09/10] ASoC: Intel: Skylake: Flush pending D0i3 request on suspend Vinod Koul
2016-11-09 15:25   ` Applied "ASoC: Intel: Skylake: Flush pending D0i3 request on suspend" to the asoc tree Mark Brown
2016-09-26  5:35 ` [PATCH 10/10] ASoC: Intel: Skylake: remove pci device enabling calls on suspend Vinod Koul
2016-11-09 15:25   ` Applied "ASoC: Intel: Skylake: remove pci device enabling calls on suspend" 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=1474868137-29712-5-git-send-email-vinod.koul@intel.com \
    --to=vinod.koul@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jayachandran.b@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=pardha.saradhi.kesapragada@intel.com \
    --cc=patches.audio@intel.com \
    /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.