From patchwork Tue Mar 25 09:56:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bo Shen X-Patchwork-Id: 3886511 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 267649F334 for ; Tue, 25 Mar 2014 09:57:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BD9B202B4 for ; Tue, 25 Mar 2014 09:57:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0C056202E5 for ; Tue, 25 Mar 2014 09:57:42 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 81EB5262634; Tue, 25 Mar 2014 10:57:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 4ACEF2625FE; Tue, 25 Mar 2014 10:57:29 +0100 (CET) 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 6C2E1262600; Tue, 25 Mar 2014 10:57:28 +0100 (CET) Received: from DVREDG01.corp.atmel.com (nasmtp01.atmel.com [192.199.1.245]) by alsa0.perex.cz (Postfix) with ESMTP id 2CC852625EE for ; Tue, 25 Mar 2014 10:57:21 +0100 (CET) Received: from sjogate2.atmel.com (10.42.103.223) by DVREDG01.corp.atmel.com (10.42.103.30) with Microsoft SMTP Server id 14.2.347.0; Tue, 25 Mar 2014 03:57:01 -0600 Received: from Dev4Android.corp.atmel.com ([10.217.2.124]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id s2P9ns9U025426; Tue, 25 Mar 2014 02:49:56 -0700 (PDT) From: Bo Shen To: Mark Brown Date: Tue, 25 Mar 2014 17:56:56 +0800 Message-ID: <1395741416-23981-1-git-send-email-voice.shen@atmel.com> X-Mailer: git-send-email 1.8.5.2 MIME-Version: 1.0 Cc: mark.rutland@arm.com, alsa-devel@alsa-project.org, b.brezillon.dev@gmail.com, nicolas.ferre@atmel.com, linux-sound@vger.kernel.org, Bo Shen , linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [RFC v2 PATCH] ASoC: wm8904: add CCF support 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Enable WM8904 to support common clock framework. - Now it supports use SoC provided clock or external oscillator as MCLK. Signed-off-by: Bo Shen --- Documentation/devicetree/bindings/sound/wm8904.txt | 48 ++++++++++++++++++++++ sound/soc/codecs/wm8904.c | 17 ++++++++ 2 files changed, 65 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/wm8904.txt diff --git a/Documentation/devicetree/bindings/sound/wm8904.txt b/Documentation/devicetree/bindings/sound/wm8904.txt new file mode 100644 index 0000000..bcf4aa0 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/wm8904.txt @@ -0,0 +1,48 @@ +WM8904 audio CODEC + +This device supports I2C only. + +Required properties: + - compatible: "wlf,wm8904" + - reg: the I2C address of the device. + - clocks and clock-names: reference to + + +Pins on the device (for linking into audio routes): + + * IN1L + * IN1R + * IN2L + * IN2R + * IN3L + * IN3R + * HPOUTL + * HPOUTR + * LINEOUTL + * LINEOUTR + * MICBIAS + +Examples: + +1. Using SoC provided clock as mclk: +codec: wm8904@1a { + compatible = "wlf,wm8904"; + reg = <0x1a>; + clocks = <&pck0>; + clock-names = "mclk"; +}; + +2. Using external oscillator as mclk: +codec: wm8904@1a { + compatible = "wlf,wm8904"; + reg = <0x1a>; + + wm8904_osc { + compatible = "fixed-clock"; + #clock-cells = <0>; + #clock-frequency = <12000000>; + } + + clocks = <&wm8904_osc>; + clock-names = "mclk"; +}; diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 49c35c3..4db6a26 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -11,6 +11,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -49,6 +50,7 @@ static const char *wm8904_supply_names[WM8904_NUM_SUPPLIES] = { /* codec private data */ struct wm8904_priv { struct regmap *regmap; + struct clk *mclk; enum wm8904_type devtype; @@ -1828,6 +1830,9 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: + if (IS_ENABLED(CONFIG_COMMON_CLK)) + if (wm8904->mclk) + clk_prepare_enable(wm8904->mclk); break; case SND_SOC_BIAS_PREPARE: @@ -1894,6 +1899,9 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); + if (IS_ENABLED(CONFIG_COMMON_CLK)) + if (wm8904->mclk) + clk_disable_unprepare(wm8904->mclk); break; } codec->dapm.bias_level = level; @@ -2139,6 +2147,15 @@ static int wm8904_i2c_probe(struct i2c_client *i2c, return ret; } + if (IS_ENABLED(CONFIG_COMMON_CLK)) { + wm8904->mclk = devm_clk_get(&i2c->dev, "mclk"); + if (IS_ERR(wm8904->mclk)) { + dev_err(&i2c->dev, "Failed to get MCLK\n"); + ret = PTR_ERR(wm8904->mclk); + goto err_enable; + } + } + ret = regmap_read(wm8904->regmap, WM8904_SW_RESET_AND_ID, &val); if (ret < 0) { dev_err(&i2c->dev, "Failed to read ID register: %d\n", ret);