From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Sugar Zhang <sugar.zhang@rock-chips.com>,
broonie@kernel.org, heiko@sntech.de
Cc: Mark Rutland <mark.rutland@arm.com>,
Oder Chiou <oder_chiou@realtek.com>,
alsa-devel@alsa-project.org, Pawel Moll <pawel.moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
linux-kernel@vger.kernel.org, Takashi Iwai <tiwai@suse.com>,
Liam Girdwood <lgirdwood@gmail.com>,
devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Kumar Gala <galak@codeaurora.org>,
Bard Liao <bardliao@realtek.com>
Subject: Re: [alsa-devel] [PATCH] ASoC: rt5640: add master clock handling for rt5640
Date: Tue, 23 Feb 2016 08:50:04 -0600 [thread overview]
Message-ID: <56CC719C.1090901@linux.intel.com> (raw)
In-Reply-To: <1456190782-18865-1-git-send-email-sugar.zhang@rock-chips.com>
On 2/22/16 7:26 PM, Sugar Zhang wrote:
> enable/disable master clock when codec is active or not.
>
> Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
> ---
>
> Documentation/devicetree/bindings/sound/rt5640.txt | 3 +++
> sound/soc/codecs/rt5640.c | 31 ++++++++++++++++++++++
> sound/soc/codecs/rt5640.h | 2 ++
> 3 files changed, 36 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/rt5640.txt b/Documentation/devicetree/bindings/sound/rt5640.txt
> index 9e62f6e..57fe646 100644
> --- a/Documentation/devicetree/bindings/sound/rt5640.txt
> +++ b/Documentation/devicetree/bindings/sound/rt5640.txt
> @@ -12,6 +12,9 @@ Required properties:
>
> Optional properties:
>
> +- clocks: The phandle of the master clock to the CODEC
> +- clock-names: Should be "mclk"
This patch assumes that the information on mclk comes from DeviceTree.
The mclk may also be enabled/disabled in the machine driver with an
explicit transition to use an internal clock when the codec is not used.
I hope this patch doesn't preclude such usages or there will be a
conflict with the patches we are about to upstream for Baytrail/cht devices.
> +
> - realtek,in1-differential
> - realtek,in2-differential
> - realtek,in3-differential
> diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
> index 11d032c..6cd84fb 100644
> --- a/sound/soc/codecs/rt5640.c
> +++ b/sound/soc/codecs/rt5640.c
> @@ -1949,7 +1949,33 @@ static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
> static int rt5640_set_bias_level(struct snd_soc_codec *codec,
> enum snd_soc_bias_level level)
> {
> + struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
> + int ret;
> +
> switch (level) {
> + case SND_SOC_BIAS_ON:
> + break;
> +
> + case SND_SOC_BIAS_PREPARE:
> + /*
> + * SND_SOC_BIAS_PREPARE is called while preparing for a
> + * transition to ON or away from ON. If current bias_level
> + * is SND_SOC_BIAS_ON, then it is preparing for a transition
> + * away from ON. Disable the clock in that case, otherwise
> + * enable it.
> + */
> + if (IS_ERR(rt5640->mclk))
> + break;
> +
> + if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) {
> + clk_disable_unprepare(rt5640->mclk);
> + } else {
> + ret = clk_prepare_enable(rt5640->mclk);
> + if (ret)
> + return ret;
> + }
> + break;
> +
> case SND_SOC_BIAS_STANDBY:
> if (SND_SOC_BIAS_OFF == snd_soc_codec_get_bias_level(codec)) {
> snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
> @@ -2088,6 +2114,11 @@ static int rt5640_probe(struct snd_soc_codec *codec)
> struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
> struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
>
> + /* Check if MCLK provided */
> + rt5640->mclk = devm_clk_get(codec->dev, "mclk");
> + if (PTR_ERR(rt5640->mclk) == -EPROBE_DEFER)
> + return -EPROBE_DEFER;
> +
> rt5640->codec = codec;
>
> snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF);
> diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h
> index 83a7150..1761c3a9 100644
> --- a/sound/soc/codecs/rt5640.h
> +++ b/sound/soc/codecs/rt5640.h
> @@ -12,6 +12,7 @@
> #ifndef _RT5640_H
> #define _RT5640_H
>
> +#include <linux/clk.h>
> #include <sound/rt5640.h>
>
> /* Info */
> @@ -2097,6 +2098,7 @@ struct rt5640_priv {
> struct snd_soc_codec *codec;
> struct rt5640_platform_data pdata;
> struct regmap *regmap;
> + struct clk *mclk;
>
> int sysclk;
> int sysclk_src;
>
next prev parent reply other threads:[~2016-02-23 14:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-23 1:26 [PATCH] ASoC: rt5640: add master clock handling for rt5640 Sugar Zhang
2016-02-23 14:50 ` Pierre-Louis Bossart [this message]
2016-02-23 23:08 ` [alsa-devel] " Heiko Stuebner
2016-02-24 3:32 ` Mark Brown
[not found] ` <20160224033259.GL18327-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-02-24 16:10 ` [alsa-devel] " Pierre-Louis Bossart
2016-02-26 1:08 ` Mark Brown
2016-02-26 15:43 ` Pierre-Louis Bossart
2016-02-27 1:51 ` [alsa-devel] " Mark Brown
2016-02-23 22:00 ` Rob Herring
[not found] ` <1456190782-18865-1-git-send-email-sugar.zhang-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-02-24 3:37 ` 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=56CC719C.1090901@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=bardliao@realtek.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=heiko@sntech.de \
--cc=ijc+devicetree@hellion.org.uk \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=oder_chiou@realtek.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=sugar.zhang@rock-chips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).