All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org
Cc: pierre-louis.bossart@linux.intel.com,
	Cezary Rojewski <cezary.rojewski@intel.com>,
	tiwai@suse.com, lgirdwood@gmail.com, hdegoede@redhat.com,
	broonie@kernel.org
Subject: [PATCH 4/5] ASoC: Intel: catpt: Streamline power routines across LPT and WPT
Date: Mon, 16 Nov 2020 14:33:31 +0100	[thread overview]
Message-ID: <20201116133332.8530-5-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20201116133332.8530-1-cezary.rojewski@intel.com>

There is no need for separate power on/off routines for LPT and WPT as
as the protocol is shared for both platforms. Make WPT routines generic
and reuse them in LPT case too.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/catpt/core.h   |  6 ++++--
 sound/soc/intel/catpt/device.c | 18 +++++++++---------
 sound/soc/intel/catpt/dsp.c    | 10 +++++-----
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/sound/soc/intel/catpt/core.h b/sound/soc/intel/catpt/core.h
index 88dc3fb6306f..693dc4a4b621 100644
--- a/sound/soc/intel/catpt/core.h
+++ b/sound/soc/intel/catpt/core.h
@@ -80,6 +80,8 @@ struct catpt_spec {
 	u32 host_ssp_offset[CATPT_SSP_COUNT];
 	u32 dram_mask;
 	u32 iram_mask;
+	u32 d3srampgd_bit;
+	u32 d3pgd_bit;
 	void (*pll_shutdown)(struct catpt_dev *cdev, bool enable);
 	int (*power_up)(struct catpt_dev *cdev);
 	int (*power_down)(struct catpt_dev *cdev);
@@ -128,8 +130,8 @@ void lpt_dsp_pll_shutdown(struct catpt_dev *cdev, bool enable);
 void wpt_dsp_pll_shutdown(struct catpt_dev *cdev, bool enable);
 int lpt_dsp_power_up(struct catpt_dev *cdev);
 int lpt_dsp_power_down(struct catpt_dev *cdev);
-int wpt_dsp_power_up(struct catpt_dev *cdev);
-int wpt_dsp_power_down(struct catpt_dev *cdev);
+int catpt_dsp_power_up(struct catpt_dev *cdev);
+int catpt_dsp_power_down(struct catpt_dev *cdev);
 int catpt_dsp_stall(struct catpt_dev *cdev, bool stall);
 void catpt_dsp_update_srampge(struct catpt_dev *cdev, struct resource *sram,
 			      unsigned long mask);
diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c
index a70179959795..b1d380868d8c 100644
--- a/sound/soc/intel/catpt/device.c
+++ b/sound/soc/intel/catpt/device.c
@@ -69,7 +69,7 @@ static int __maybe_unused catpt_suspend(struct device *dev)
 	dma_release_channel(chan);
 	if (ret)
 		return ret;
-	return cdev->spec->power_down(cdev);
+	return catpt_dsp_power_down(cdev);
 }
 
 static int __maybe_unused catpt_resume(struct device *dev)
@@ -77,7 +77,7 @@ static int __maybe_unused catpt_resume(struct device *dev)
 	struct catpt_dev *cdev = dev_get_drvdata(dev);
 	int ret, i;
 
-	ret = cdev->spec->power_up(cdev);
+	ret = catpt_dsp_power_up(cdev);
 	if (ret)
 		return ret;
 
@@ -162,7 +162,7 @@ static int catpt_probe_components(struct catpt_dev *cdev)
 {
 	int ret;
 
-	ret = cdev->spec->power_up(cdev);
+	ret = catpt_dsp_power_up(cdev);
 	if (ret)
 		return ret;
 
@@ -204,7 +204,7 @@ static int catpt_probe_components(struct catpt_dev *cdev)
 err_boot_fw:
 	catpt_dmac_remove(cdev);
 err_dmac_probe:
-	cdev->spec->power_down(cdev);
+	catpt_dsp_power_down(cdev);
 
 	return ret;
 }
@@ -293,7 +293,7 @@ static int catpt_acpi_remove(struct platform_device *pdev)
 
 	snd_soc_unregister_component(cdev->dev);
 	catpt_dmac_remove(cdev);
-	cdev->spec->power_down(cdev);
+	catpt_dsp_power_down(cdev);
 
 	catpt_sram_free(&cdev->iram);
 	catpt_sram_free(&cdev->dram);
@@ -311,9 +311,9 @@ static struct catpt_spec lpt_desc = {
 	.host_ssp_offset = { 0x0E8000, 0x0E9000 },
 	.dram_mask = LPT_VDRTCTL0_DSRAMPGE_MASK,
 	.iram_mask = LPT_VDRTCTL0_ISRAMPGE_MASK,
+	.d3srampgd_bit = LPT_VDRTCTL0_D3SRAMPGD,
+	.d3pgd_bit = LPT_VDRTCTL0_D3PGD,
 	.pll_shutdown = lpt_dsp_pll_shutdown,
-	.power_up = lpt_dsp_power_up,
-	.power_down = lpt_dsp_power_down,
 };
 
 static struct catpt_spec wpt_desc = {
@@ -326,9 +326,9 @@ static struct catpt_spec wpt_desc = {
 	.host_ssp_offset = { 0x0FC000, 0x0FD000 },
 	.dram_mask = WPT_VDRTCTL0_DSRAMPGE_MASK,
 	.iram_mask = WPT_VDRTCTL0_ISRAMPGE_MASK,
+	.d3srampgd_bit = WPT_VDRTCTL0_D3SRAMPGD,
+	.d3pgd_bit = WPT_VDRTCTL0_D3PGD,
 	.pll_shutdown = wpt_dsp_pll_shutdown,
-	.power_up = wpt_dsp_power_up,
-	.power_down = wpt_dsp_power_down,
 };
 
 static const struct acpi_device_id catpt_ids[] = {
diff --git a/sound/soc/intel/catpt/dsp.c b/sound/soc/intel/catpt/dsp.c
index 9e807b941732..dfa442a3c1f1 100644
--- a/sound/soc/intel/catpt/dsp.c
+++ b/sound/soc/intel/catpt/dsp.c
@@ -390,7 +390,7 @@ int lpt_dsp_power_up(struct catpt_dev *cdev)
 	return 0;
 }
 
-int wpt_dsp_power_down(struct catpt_dev *cdev)
+int catpt_dsp_power_down(struct catpt_dev *cdev)
 {
 	u32 mask, val;
 
@@ -420,8 +420,8 @@ int wpt_dsp_power_down(struct catpt_dev *cdev)
 			      cdev->spec->dram_mask);
 	catpt_dsp_set_srampge(cdev, &cdev->iram, cdev->spec->iram_mask,
 			      cdev->spec->iram_mask);
-	mask = WPT_VDRTCTL0_D3SRAMPGD | WPT_VDRTCTL0_D3PGD;
-	catpt_updatel_pci(cdev, VDRTCTL0, mask, WPT_VDRTCTL0_D3PGD);
+	mask = cdev->spec->d3srampgd_bit | cdev->spec->d3pgd_bit;
+	catpt_updatel_pci(cdev, VDRTCTL0, mask, cdev->spec->d3pgd_bit);
 
 	catpt_updatel_pci(cdev, PMCS, PCI_PM_CTRL_STATE_MASK, PCI_D3hot);
 	/* give hw time to drop off */
@@ -435,7 +435,7 @@ int wpt_dsp_power_down(struct catpt_dev *cdev)
 	return 0;
 }
 
-int wpt_dsp_power_up(struct catpt_dev *cdev)
+int catpt_dsp_power_up(struct catpt_dev *cdev)
 {
 	u32 mask, val;
 
@@ -450,7 +450,7 @@ int wpt_dsp_power_up(struct catpt_dev *cdev)
 	catpt_updatel_pci(cdev, PMCS, PCI_PM_CTRL_STATE_MASK, PCI_D0);
 
 	/* SRAM power gating none */
-	mask = WPT_VDRTCTL0_D3SRAMPGD | WPT_VDRTCTL0_D3PGD;
+	mask = cdev->spec->d3srampgd_bit | cdev->spec->d3pgd_bit;
 	catpt_updatel_pci(cdev, VDRTCTL0, mask, mask);
 	catpt_dsp_set_srampge(cdev, &cdev->dram, cdev->spec->dram_mask, 0);
 	catpt_dsp_set_srampge(cdev, &cdev->iram, cdev->spec->iram_mask, 0);
-- 
2.17.1


  parent reply	other threads:[~2020-11-16 13:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 13:33 [PATCH 0/5] ASoC: Intel: catpt: Offload fixes and code optimization Cezary Rojewski
2020-11-16 13:33 ` [PATCH 1/5] ASoC: Intel: catpt: Skip position update for unprepared streams Cezary Rojewski
2020-11-16 13:33 ` [PATCH 2/5] ASoC: Intel: catpt: Correct clock selection for dai trigger Cezary Rojewski
2020-11-16 13:33 ` [PATCH 3/5] ASoC: Intel: catpt: Optimize applying user settings Cezary Rojewski
2020-11-16 13:33 ` Cezary Rojewski [this message]
2020-11-16 13:33 ` [PATCH 5/5] ASoC: Intel: catpt: Cleanup after power routines streamlining Cezary Rojewski
2020-11-16 23:33 ` [PATCH 0/5] ASoC: Intel: catpt: Offload fixes and code optimization 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=20201116133332.8530-5-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=lgirdwood@gmail.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.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.