aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasily Khoruzhick <anarsoul@gmail.com>2018-10-21 11:39:11 -0400
committerMark Brown <broonie@kernel.org>2018-10-21 11:46:32 -0400
commit7f91e2af1a4a2c34fc2e8fb046c722e1a9c85399 (patch)
tree3ea68f9d5e370786dd9067ab3556256ebd6712aa
parentc5d09485def41cab9e75ba23abbf87080183183c (diff)
ASoC: sun4i-i2s: move code from startup/shutdown hooks into pm_runtime hooks
startup() and shutdown() hooks are called for both substreams, so stopping either substream when another is running breaks the latter. E.g. playback breaks if capture is stopped when playback is running. Move code from startup() and shutdown() to resume() and suspend() hooks respectively to fix this issue Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sunxi/sun4i-i2s.c61
1 files changed, 25 insertions, 36 deletions
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index c63d226e2436..d5ec1a20499d 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -644,40 +644,6 @@ static int sun4i_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
644 return 0; 644 return 0;
645} 645}
646 646
647static int sun4i_i2s_startup(struct snd_pcm_substream *substream,
648 struct snd_soc_dai *dai)
649{
650 struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
651
652 /* Enable the whole hardware block */
653 regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
654 SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN);
655
656 /* Enable the first output line */
657 regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
658 SUN4I_I2S_CTRL_SDO_EN_MASK,
659 SUN4I_I2S_CTRL_SDO_EN(0));
660
661
662 return clk_prepare_enable(i2s->mod_clk);
663}
664
665static void sun4i_i2s_shutdown(struct snd_pcm_substream *substream,
666 struct snd_soc_dai *dai)
667{
668 struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
669
670 clk_disable_unprepare(i2s->mod_clk);
671
672 /* Disable our output lines */
673 regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
674 SUN4I_I2S_CTRL_SDO_EN_MASK, 0);
675
676 /* Disable the whole hardware block */
677 regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
678 SUN4I_I2S_CTRL_GL_EN, 0);
679}
680
681static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, 647static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id,
682 unsigned int freq, int dir) 648 unsigned int freq, int dir)
683{ 649{
@@ -695,8 +661,6 @@ static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = {
695 .hw_params = sun4i_i2s_hw_params, 661 .hw_params = sun4i_i2s_hw_params,
696 .set_fmt = sun4i_i2s_set_fmt, 662 .set_fmt = sun4i_i2s_set_fmt,
697 .set_sysclk = sun4i_i2s_set_sysclk, 663 .set_sysclk = sun4i_i2s_set_sysclk,
698 .shutdown = sun4i_i2s_shutdown,
699 .startup = sun4i_i2s_startup,
700 .trigger = sun4i_i2s_trigger, 664 .trigger = sun4i_i2s_trigger,
701}; 665};
702 666
@@ -869,6 +833,21 @@ static int sun4i_i2s_runtime_resume(struct device *dev)
869 goto err_disable_clk; 833 goto err_disable_clk;
870 } 834 }
871 835
836 /* Enable the whole hardware block */
837 regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
838 SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN);
839
840 /* Enable the first output line */
841 regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
842 SUN4I_I2S_CTRL_SDO_EN_MASK,
843 SUN4I_I2S_CTRL_SDO_EN(0));
844
845 ret = clk_prepare_enable(i2s->mod_clk);
846 if (ret) {
847 dev_err(dev, "Failed to enable module clock\n");
848 goto err_disable_clk;
849 }
850
872 return 0; 851 return 0;
873 852
874err_disable_clk: 853err_disable_clk:
@@ -880,6 +859,16 @@ static int sun4i_i2s_runtime_suspend(struct device *dev)
880{ 859{
881 struct sun4i_i2s *i2s = dev_get_drvdata(dev); 860 struct sun4i_i2s *i2s = dev_get_drvdata(dev);
882 861
862 clk_disable_unprepare(i2s->mod_clk);
863
864 /* Disable our output lines */
865 regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
866 SUN4I_I2S_CTRL_SDO_EN_MASK, 0);
867
868 /* Disable the whole hardware block */
869 regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
870 SUN4I_I2S_CTRL_GL_EN, 0);
871
883 regcache_cache_only(i2s->regmap, true); 872 regcache_cache_only(i2s->regmap, true);
884 873
885 clk_disable_unprepare(i2s->bus_clk); 874 clk_disable_unprepare(i2s->bus_clk);