From: Sebastian Reichel <sebastian.reichel@collabora.com> To: Support Opensource <support.opensource@diasemi.com>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org> Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Sebastian Reichel <sebastian.reichel@collabora.com> Subject: [PATCHv1 5/5] ASoC: da7213: add default clock handling Date: Fri, 8 Nov 2019 18:48:43 +0100 [thread overview] Message-ID: <20191108174843.11227-6-sebastian.reichel@collabora.com> (raw) In-Reply-To: <20191108174843.11227-1-sebastian.reichel@collabora.com> This adds default clock/PLL configuration to the driver for usage with generic drivers like simple-card for usage with a fixed rate clock. Upstreaming this requires a good way to disable the automatic clock handling for systems doing it manually to avoid breaking existing setups. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> --- sound/soc/codecs/da7213.c | 34 +++++++++++++++++++++++++++++++++- sound/soc/codecs/da7213.h | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 197609691525..a4ed382ddfc7 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -1163,6 +1163,8 @@ static int da7213_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); + int freq = 0; u8 dai_ctrl = 0; u8 fs; @@ -1188,38 +1190,54 @@ static int da7213_hw_params(struct snd_pcm_substream *substream, switch (params_rate(params)) { case 8000: fs = DA7213_SR_8000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 11025: fs = DA7213_SR_11025; + freq = DA7213_PLL_FREQ_OUT_90316800; break; case 12000: fs = DA7213_SR_12000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 16000: fs = DA7213_SR_16000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 22050: fs = DA7213_SR_22050; + freq = DA7213_PLL_FREQ_OUT_90316800; break; case 32000: fs = DA7213_SR_32000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 44100: fs = DA7213_SR_44100; + freq = DA7213_PLL_FREQ_OUT_90316800; break; case 48000: fs = DA7213_SR_48000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 88200: fs = DA7213_SR_88200; + freq = DA7213_PLL_FREQ_OUT_90316800; break; case 96000: fs = DA7213_SR_96000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; default: return -EINVAL; } + /* setup PLL */ + if (da7213->fixed_clk_auto) { + snd_soc_component_set_pll(component, 0, DA7213_SYSCLK_PLL, + da7213->mclk_rate, freq); + } + snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_WORD_LENGTH_MASK, dai_ctrl); snd_soc_component_write(component, DA7213_SR, fs); @@ -1700,10 +1718,10 @@ static struct da7213_platform_data return pdata; } - static int da7213_probe(struct snd_soc_component *component) { struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); + int ret; pm_runtime_get_sync(component->dev); @@ -1836,6 +1854,20 @@ static int da7213_probe(struct snd_soc_component *component) return PTR_ERR(da7213->mclk); else da7213->mclk = NULL; + } else { + /* Store clock rate for fixed clocks for automatic PLL setup */ + ret = clk_prepare_enable(da7213->mclk); + if (ret) { + dev_err(component->dev, "Failed to enable mclk\n"); + return ret; + } + + da7213->mclk_rate = clk_get_rate(da7213->mclk); + + clk_disable_unprepare(da7213->mclk); + + /* assume fixed clock until set_sysclk() is being called */ + da7213->fixed_clk_auto = true; } return 0; diff --git a/sound/soc/codecs/da7213.h b/sound/soc/codecs/da7213.h index 97a250ea39e6..00aca0126cdb 100644 --- a/sound/soc/codecs/da7213.h +++ b/sound/soc/codecs/da7213.h @@ -532,6 +532,7 @@ struct da7213_priv { bool master; bool alc_calib_auto; bool alc_en; + bool fixed_clk_auto; struct da7213_platform_data *pdata; }; -- 2.24.0.rc1
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Reichel <sebastian.reichel@collabora.com> To: Support Opensource <support.opensource@diasemi.com>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org> Cc: alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.com>, linux-kernel@vger.kernel.org, Sebastian Reichel <sebastian.reichel@collabora.com>, kernel@collabora.com Subject: [alsa-devel] [PATCHv1 5/5] ASoC: da7213: add default clock handling Date: Fri, 8 Nov 2019 18:48:43 +0100 [thread overview] Message-ID: <20191108174843.11227-6-sebastian.reichel@collabora.com> (raw) In-Reply-To: <20191108174843.11227-1-sebastian.reichel@collabora.com> This adds default clock/PLL configuration to the driver for usage with generic drivers like simple-card for usage with a fixed rate clock. Upstreaming this requires a good way to disable the automatic clock handling for systems doing it manually to avoid breaking existing setups. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> --- sound/soc/codecs/da7213.c | 34 +++++++++++++++++++++++++++++++++- sound/soc/codecs/da7213.h | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 197609691525..a4ed382ddfc7 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -1163,6 +1163,8 @@ static int da7213_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); + int freq = 0; u8 dai_ctrl = 0; u8 fs; @@ -1188,38 +1190,54 @@ static int da7213_hw_params(struct snd_pcm_substream *substream, switch (params_rate(params)) { case 8000: fs = DA7213_SR_8000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 11025: fs = DA7213_SR_11025; + freq = DA7213_PLL_FREQ_OUT_90316800; break; case 12000: fs = DA7213_SR_12000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 16000: fs = DA7213_SR_16000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 22050: fs = DA7213_SR_22050; + freq = DA7213_PLL_FREQ_OUT_90316800; break; case 32000: fs = DA7213_SR_32000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 44100: fs = DA7213_SR_44100; + freq = DA7213_PLL_FREQ_OUT_90316800; break; case 48000: fs = DA7213_SR_48000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; case 88200: fs = DA7213_SR_88200; + freq = DA7213_PLL_FREQ_OUT_90316800; break; case 96000: fs = DA7213_SR_96000; + freq = DA7213_PLL_FREQ_OUT_98304000; break; default: return -EINVAL; } + /* setup PLL */ + if (da7213->fixed_clk_auto) { + snd_soc_component_set_pll(component, 0, DA7213_SYSCLK_PLL, + da7213->mclk_rate, freq); + } + snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_WORD_LENGTH_MASK, dai_ctrl); snd_soc_component_write(component, DA7213_SR, fs); @@ -1700,10 +1718,10 @@ static struct da7213_platform_data return pdata; } - static int da7213_probe(struct snd_soc_component *component) { struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); + int ret; pm_runtime_get_sync(component->dev); @@ -1836,6 +1854,20 @@ static int da7213_probe(struct snd_soc_component *component) return PTR_ERR(da7213->mclk); else da7213->mclk = NULL; + } else { + /* Store clock rate for fixed clocks for automatic PLL setup */ + ret = clk_prepare_enable(da7213->mclk); + if (ret) { + dev_err(component->dev, "Failed to enable mclk\n"); + return ret; + } + + da7213->mclk_rate = clk_get_rate(da7213->mclk); + + clk_disable_unprepare(da7213->mclk); + + /* assume fixed clock until set_sysclk() is being called */ + da7213->fixed_clk_auto = true; } return 0; diff --git a/sound/soc/codecs/da7213.h b/sound/soc/codecs/da7213.h index 97a250ea39e6..00aca0126cdb 100644 --- a/sound/soc/codecs/da7213.h +++ b/sound/soc/codecs/da7213.h @@ -532,6 +532,7 @@ struct da7213_priv { bool master; bool alc_calib_auto; bool alc_en; + bool fixed_clk_auto; struct da7213_platform_data *pdata; }; -- 2.24.0.rc1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2019-11-08 17:49 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-08 17:48 [PATCHv1 0/5] ASoC: da7213: support for usage with simple-card Sebastian Reichel 2019-11-08 17:48 ` [alsa-devel] " Sebastian Reichel 2019-11-08 17:48 ` [PATCHv1 1/5] ASoC: da7213: Add regulator support Sebastian Reichel 2019-11-08 17:48 ` [alsa-devel] " Sebastian Reichel 2019-11-11 14:07 ` Adam Thomson 2019-11-11 14:07 ` [alsa-devel] " Adam Thomson 2019-11-12 15:24 ` Sebastian Reichel 2019-11-12 15:24 ` [alsa-devel] " Sebastian Reichel 2019-11-12 16:58 ` Mark Brown 2019-11-12 16:58 ` [alsa-devel] " Mark Brown 2019-11-13 10:51 ` Adam Thomson 2019-11-13 10:51 ` [alsa-devel] " Adam Thomson 2019-11-08 17:48 ` [PATCHv1 2/5] ASoC: Add DA7213 audio codec as selectable option Sebastian Reichel 2019-11-08 17:48 ` [alsa-devel] " Sebastian Reichel 2019-11-08 17:48 ` [PATCHv1 3/5] ASoC: da7213: move set_sysclk to codec level Sebastian Reichel 2019-11-08 17:48 ` [alsa-devel] " Sebastian Reichel 2019-11-08 17:48 ` [PATCHv1 4/5] ASoC: da7213: move set_pll " Sebastian Reichel 2019-11-08 17:48 ` [alsa-devel] " Sebastian Reichel 2019-11-08 17:48 ` Sebastian Reichel [this message] 2019-11-08 17:48 ` [alsa-devel] [PATCHv1 5/5] ASoC: da7213: add default clock handling Sebastian Reichel 2019-11-11 14:20 ` Adam Thomson 2019-11-11 14:20 ` [alsa-devel] " Adam Thomson 2019-11-12 16:29 ` Sebastian Reichel 2019-11-12 16:29 ` [alsa-devel] " Sebastian Reichel 2019-11-13 11:25 ` Adam Thomson 2019-11-13 11:25 ` [alsa-devel] " Adam Thomson
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=20191108174843.11227-6-sebastian.reichel@collabora.com \ --to=sebastian.reichel@collabora.com \ --cc=alsa-devel@alsa-project.org \ --cc=broonie@kernel.org \ --cc=kernel@collabora.com \ --cc=lgirdwood@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=perex@perex.cz \ --cc=support.opensource@diasemi.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: linkBe 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.