From patchwork Tue Feb 3 07:54:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Lauss X-Patchwork-Id: 5766791 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 67F499F302 for ; Tue, 3 Feb 2015 07:55:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C02420AA2 for ; Tue, 3 Feb 2015 07:55:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1B7DE20A9D for ; Tue, 3 Feb 2015 07:55:54 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8C9F0261292; Tue, 3 Feb 2015 08:55:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 6EB98260A56; Tue, 3 Feb 2015 08:55:44 +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 1550B260A5B; Tue, 3 Feb 2015 08:55:42 +0100 (CET) Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by alsa0.perex.cz (Postfix) with ESMTP id D99B32608D4 for ; Tue, 3 Feb 2015 08:55:37 +0100 (CET) Received: by mail-wg0-f42.google.com with SMTP id x13so43144578wgg.1 for ; Mon, 02 Feb 2015 23:55:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=XmhY48Sh1gsBQJj7ES65tU5cyKJ8y3oyV1egCDpu8F8=; b=zDWgiPBdbC925XpcTkOLAeQhv1kju9gsZG02A0BQZaS+t3sA3C43nlbzk0BSr2F3/y 48jFev+MNTWeMvI3b0zcr7ZDBVL/2j4DROGTiVClN94Ppm9oSYfCwETD0VoLPXZb/6Ik /t03EWQ0xz6d90iz2f9gfNGT7joR2IDyelNBEJaswwaW33L96OoNCpXs3lRkWOQFhMdy mbTgWQaoG6htc/v9vZHVw6oFMosK6dO2wwacbJD6U5T3dCxQ8yFNTA6ZgIIe0u6F9rGl MgBceKJjfyP6EzPQmcSxwnB+FFM4tzzZlW0RZ09iVK2NwnNMCt0WawIsPznPpaWE8jDE d2Mg== X-Received: by 10.180.108.202 with SMTP id hm10mr31662561wib.68.1422950137621; Mon, 02 Feb 2015 23:55:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.154.6 with HTTP; Mon, 2 Feb 2015 23:54:57 -0800 (PST) In-Reply-To: <1422934415-24957-1-git-send-email-voice.shen@atmel.com> References: <1422934415-24957-1-git-send-email-voice.shen@atmel.com> From: Manuel Lauss Date: Tue, 3 Feb 2015 08:54:57 +0100 Message-ID: To: Bo Shen Cc: alsa-devel , Richard Purdie , patches@opensource.wolfsonmicro.com, LKML , linux-sound@vger.kernel.org, Manuel Lauss , Mark Brown , linux-arm-kernel@lists.infradead.org, Liam Girdwood Subject: Re: [alsa-devel] [RFC PATCH] ASoC: wm8731: let codec to manage clock by itself 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 On Tue, Feb 3, 2015 at 4:33 AM, Bo Shen wrote: > Let the wm8731 codec to manage clock by itself. > > As all at91 related boards have been switch to CCF framework. So, on > the at91 related boards which use wm8731 will let it manage the clock, > or else the board use wm8731 is broken. > > However, at the same time the wm8731 codec is used on other boards, > I am sure this change will broken some boards. > > For example: poodle and corgi based on PXA SoC (in default configuration > file, no one use it). DB1200 board which is a mips based board. So I have > no idea how to fix them. > > So, my suggestion is to add CCF check based on the following patch? Any > idea or suggestions? What about the patch below? It makes absence of mclk object non-fatal and checks if wm8731->mclk is non-NULL before enabling/disabling it. Works on my DB1200/DB1300 boards: unsigned int sysclk; @@ -389,6 +391,8 @@ static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai, switch (clk_id) { case WM8731_SYSCLK_XTAL: case WM8731_SYSCLK_MCLK: + if (wm8731->mclk && clk_set_rate(wm8731->mclk, freq)) + return -EINVAL; wm8731->sysclk_type = clk_id; break; default: @@ -490,6 +494,8 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: + if (wm8731->mclk) + clk_prepare_enable(wm8731->mclk); break; case SND_SOC_BIAS_PREPARE: break; @@ -508,6 +514,8 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, snd_soc_write(codec, WM8731_PWR, reg | 0x0040); break; case SND_SOC_BIAS_OFF: + if (wm8731->mclk) + clk_disable_unprepare(wm8731->mclk); snd_soc_write(codec, WM8731_PWR, 0xffff); regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); @@ -666,6 +674,12 @@ static int wm8731_spi_probe(struct spi_device *spi) if (wm8731 == NULL) return -ENOMEM; + wm8731->mclk = devm_clk_get(&spi->dev, "mclk"); + if (IS_ERR(wm8731->mclk)) { + wm8731->mclk = NULL; + dev_warn(&spi->dev, "assuming static MCLK\n"); + } + mutex_init(&wm8731->lock); wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap); @@ -719,6 +733,12 @@ static int wm8731_i2c_probe(struct i2c_client *i2c, mutex_init(&wm8731->lock); + wm8731->mclk = devm_clk_get(&i2c->dev, "mclk"); + if (IS_ERR(wm8731->mclk)) { + wm8731->mclk = NULL; + dev_warn(&i2c->dev, "assuming static MCLK\n"); + } + wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap); if (IS_ERR(wm8731->regmap)) { ret = PTR_ERR(wm8731->regmap); diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index b115ed8..648b8cd 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -13,6 +13,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -45,6 +46,7 @@ static const char *wm8731_supply_names[WM8731_NUM_SUPPLIES] = { /* codec private data */ struct wm8731_priv { struct regmap *regmap; + struct clk *mclk; struct regulator_bulk_data supplies[WM8731_NUM_SUPPLIES]; const struct snd_pcm_hw_constraint_list *constraints;