From patchwork Wed Jul 27 23:02:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 9250511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37C07607D8 for ; Thu, 28 Jul 2016 00:36:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DF5624B48 for ; Thu, 28 Jul 2016 00:36:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11CA9254F7; Thu, 28 Jul 2016 00:36:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481B024B48 for ; Thu, 28 Jul 2016 00:36:00 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 535502656F5; Thu, 28 Jul 2016 02:35:57 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 41CD226617B; Thu, 28 Jul 2016 02:27:01 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C0AD226617B; Thu, 28 Jul 2016 02:26:59 +0200 (CEST) Received: from mail-pa0-f68.google.com (mail-pa0-f68.google.com [209.85.220.68]) by alsa0.perex.cz (Postfix) with ESMTP id CC334266C1B for ; Thu, 28 Jul 2016 01:03:01 +0200 (CEST) Received: by mail-pa0-f68.google.com with SMTP id q2so2436440pap.0 for ; Wed, 27 Jul 2016 16:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=PubpFukXsJ5hT5lRSs5E72j6EORyM/QBBOjL7qZxCXs=; b=TlnKSHRRatWTrEyZr+e890oc1ol7Ub9gG/VUdUZ6i5EeIs7GiMJPfG+AJbfDx330PQ 76NgW3qcmSEsZU1tgcJIUVydvs947Pe/MnIpnGFMf8xABqZ4buSqO04+XC18nNxg5Qe/ Os0JMlYY0rSiVsrbM0pq2ZrhcOdCR4g2Hr2uS6DNld69g8hEEWzOSiAmNcrJPY2KXfX+ TVJoLWNc2+phTcT/OAOBlsdkzdYieZ38OlSI2beVEEPzTLeC/kAX26ekpYYHAl/3gMr1 Lro101TLHB1q9MdH0LSnbmh1ITipls8D41FAPeda7Dfy9Lvl+5ZBeYP/InD4WjUE0225 JqbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PubpFukXsJ5hT5lRSs5E72j6EORyM/QBBOjL7qZxCXs=; b=aMA8Z3qwjD6uRbPDPmdzG0dGSLgtM8hs7qkRsR7JwFvzYDWPhlMwkLcEoVkFRx/9Wq 1IA3lNbQN6UQ7ZTOcbNX4slzu1XSgnf3Sj0BXmHehPHLSITeyr7dJaKDfj3vWxZRaUvO 2upR8bPFBjm36M57a6DF6nFL2o4Z6o94f3oTMRfTmGh/NEvCURRwpx7GJoaQO5pc+xTP SjDQ27+ED26+hnp/XtAJDYXJBegg7goLJApQC2hTtrTE3Arn5+osZWNr8zgovFZ9uRhF 6/OIXK3MqMYMhnII5kxz06Hb38r1LzVkYMarT0S2aTEbCaMTItddGry8PIs5QBY0Wt6Q Hlhw== X-Gm-Message-State: AEkooutIXmdQA+oopnX0cdKO1pUS62oqZJNwggnEhfRsM0nY98xGDqxe8pxi3OnfXSGCTQ== X-Received: by 10.66.226.201 with SMTP id ru9mr53429535pac.55.1469660580526; Wed, 27 Jul 2016 16:03:00 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id e2sm11652753pfd.45.2016.07.27.16.02.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jul 2016 16:02:59 -0700 (PDT) From: Nicolin Chen To: broonie@kernel.org Date: Wed, 27 Jul 2016 16:02:48 -0700 Message-Id: <1469660568-3511-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 Cc: mark.rutland@arm.com, oder_chiou@realtek.com, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, bardliao@realtek.com Subject: [alsa-devel] [PATCH] ASoC: rt5659: Add mclk controls X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The codec driver should control the mclk. So this patch adds this support. Signed-off-by: Nicolin Chen --- Documentation/devicetree/bindings/sound/rt5659.txt | 3 +++ sound/soc/codecs/rt5659.c | 24 ++++++++++++++++++++++ sound/soc/codecs/rt5659.h | 1 + 3 files changed, 28 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rt5659.txt b/Documentation/devicetree/bindings/sound/rt5659.txt index 5f79e7f..1766e05 100644 --- a/Documentation/devicetree/bindings/sound/rt5659.txt +++ b/Documentation/devicetree/bindings/sound/rt5659.txt @@ -12,6 +12,9 @@ Required properties: Optional properties: +- clocks: The phandle of the master clock to the CODEC +- clock-names: Should be "mclk" + - realtek,in1-differential - realtek,in3-differential - realtek,in4-differential diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index 1b30914..d9ead96 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -9,6 +9,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -3565,7 +3566,9 @@ static int rt5659_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) static int rt5659_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + int ret; switch (level) { case SND_SOC_BIAS_PREPARE: @@ -3582,6 +3585,17 @@ static int rt5659_set_bias_level(struct snd_soc_codec *codec, RT5659_PWR_FV1 | RT5659_PWR_FV2); break; + case SND_SOC_BIAS_STANDBY: + if (dapm->bias_level == SND_SOC_BIAS_OFF) { + ret = clk_prepare_enable(rt5659->mclk); + if (ret) { + dev_err(codec->dev, + "failed to enable MCLK: %d\n", ret); + return ret; + } + } + break; + case SND_SOC_BIAS_OFF: regmap_update_bits(rt5659->regmap, RT5659_PWR_DIG_1, RT5659_PWR_LDO, 0); @@ -3591,6 +3605,7 @@ static int rt5659_set_bias_level(struct snd_soc_codec *codec, RT5659_PWR_MB | RT5659_PWR_VREF2); regmap_update_bits(rt5659->regmap, RT5659_DIG_MISC, RT5659_DIG_GATE_CTRL, 0); + clk_disable_unprepare(rt5659->mclk); break; default: @@ -4020,6 +4035,15 @@ static int rt5659_i2c_probe(struct i2c_client *i2c, regmap_write(rt5659->regmap, RT5659_RESET, 0); + /* Check if MCLK provided */ + rt5659->mclk = devm_clk_get(&i2c->dev, "mclk"); + if (IS_ERR(rt5659->mclk)) { + if (PTR_ERR(rt5659->mclk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + /* Otherwise mark the mclk pointer to NULL */ + rt5659->mclk = NULL; + } + rt5659_calibrate(rt5659); /* line in diff mode*/ diff --git a/sound/soc/codecs/rt5659.h b/sound/soc/codecs/rt5659.h index d31c9e5..d69b0eb 100644 --- a/sound/soc/codecs/rt5659.h +++ b/sound/soc/codecs/rt5659.h @@ -1796,6 +1796,7 @@ struct rt5659_priv { struct gpio_desc *gpiod_reset; struct snd_soc_jack *hs_jack; struct delayed_work jack_detect_work; + struct clk *mclk; int sysclk; int sysclk_src;