OSDN Git Service

ASoC: Intel: catpt: Streamline power routines across LPT and WPT
authorCezary Rojewski <cezary.rojewski@intel.com>
Mon, 16 Nov 2020 13:33:31 +0000 (14:33 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 16 Nov 2020 20:03:30 +0000 (20:03 +0000)
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>
Link: https://lore.kernel.org/r/20201116133332.8530-5-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/catpt/core.h
sound/soc/intel/catpt/device.c
sound/soc/intel/catpt/dsp.c

index 88dc3fb..693dc4a 100644 (file)
@@ -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);
index a701799..b1d3808 100644 (file)
@@ -69,7 +69,7 @@ release_dma_chan:
        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 @@ err_reg_board:
 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[] = {
index 7d29685..aee72b9 100644 (file)
@@ -387,7 +387,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;
 
@@ -417,8 +417,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 */
@@ -432,7 +432,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;
 
@@ -447,7 +447,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);