sound: starfive: pwmdac: Fixed playback failed after hibernation
authorXingyu Wu <xingyu.wu@starfivetech.com>
Wed, 11 Jan 2023 03:08:28 +0000 (11:08 +0800)
committerXingyu Wu <xingyu.wu@starfivetech.com>
Wed, 11 Jan 2023 05:54:56 +0000 (13:54 +0800)
Fixed playback failed after hibernation by saving and restoring
register data.
Fixed error when open PWMDAC_PCM.

Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
sound/soc/starfive/pwmdac.h [changed mode: 0755->0644]
sound/soc/starfive/starfive_pwmdac.c

old mode 100755 (executable)
new mode 100644 (file)
index 8b93d7d..d4742f9
@@ -34,9 +34,6 @@
 #define PWMDAC_DUTY_CYCLE_LOW  2
 #define PWMDAC_DUTY_CYCLE_HIGH 3
 
-
-
-
 #define PWMDAC_MCLK    4096000
 
 enum pwmdac_lr_change{
@@ -86,7 +83,6 @@ enum pwmdac_sample_count{
        PWMDAC_SAMPLE_CNT_511 = 511,
 };
 
-
 enum data_shift{
        PWMDAC_DATA_LEFT_SHIFT_BIT_0 = 0,
        PWMDAC_DATA_LEFT_SHIFT_BIT_1,
@@ -144,11 +140,10 @@ struct sf_pwmdac_dev {
        struct clk *audio_src;
        struct clk *pwmdac_apb;
        struct clk *pwmdac_mclk;
+       unsigned int pwmdac_ctrl_data;
 };
 
-
-
-#if IS_ENABLED(CONFIG_SND_STARFIVE_PWMDAC_PCM)
+#if IS_ENABLED(CONFIG_SND_SOC_STARFIVE_PWMDAC_PCM)
 void sf_pwmdac_pcm_push_tx(struct sf_pwmdac_dev *dev);
 void sf_pwmdac_pcm_pop_rx(struct sf_pwmdac_dev *dev);
 int sf_pwmdac_pcm_register(struct platform_device *pdev);
index 1e7a4384e6cbb5bc7dbaa8c3a6e225a2663ba14d..fba58e22d7ef736dd166c12991fa041f2fa94ebb 100644 (file)
@@ -761,12 +761,25 @@ static int sf_pwmdac_dai_probe(struct snd_soc_dai *dai)
 #ifdef CONFIG_PM_SLEEP
 static int starfive_pwmdac_system_suspend(struct device *dev)
 {
+       struct sf_pwmdac_dev *pwmdac = dev_get_drvdata(dev);
+
+       /* save the register value */
+       pwmdac->pwmdac_ctrl_data = pwmdc_read_reg(pwmdac->pwmdac_base, PWMDAC_CTRL);
        return pm_runtime_force_suspend(dev);
 }
 
 static int starfive_pwmdac_system_resume(struct device *dev)
 {
-       return pm_runtime_force_resume(dev);
+       struct sf_pwmdac_dev *pwmdac = dev_get_drvdata(dev);
+       int ret;
+
+       ret = pm_runtime_force_resume(dev);
+       if (ret)
+               return ret;
+
+       /* restore the register value */
+       pwmdc_write_reg(pwmdac->pwmdac_base, PWMDAC_CTRL, pwmdac->pwmdac_ctrl_data);
+       return 0;
 }
 #endif