From patchwork Mon Jul 28 10:56:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 4633311 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D5BBBC0338 for ; Mon, 28 Jul 2014 10:54:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DB5C20158 for ; Mon, 28 Jul 2014 10:54:40 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C478B20154 for ; Mon, 28 Jul 2014 10:54:38 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id AC9B6265068; Mon, 28 Jul 2014 12:54:36 +0200 (CEST) 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, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 9FB8C26163C; Mon, 28 Jul 2014 12:54:25 +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 37B6D26164D; Mon, 28 Jul 2014 12:54:24 +0200 (CEST) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1lp0141.outbound.protection.outlook.com [207.46.163.141]) by alsa0.perex.cz (Postfix) with ESMTP id EE2A226163C for ; Mon, 28 Jul 2014 12:54:15 +0200 (CEST) Received: from BN3PR0301CA0021.namprd03.prod.outlook.com (25.160.180.159) by BLUPR03MB358.namprd03.prod.outlook.com (10.141.75.152) with Microsoft SMTP Server (TLS) id 15.0.995.14; Mon, 28 Jul 2014 10:54:14 +0000 Received: from BL2FFO11FD035.protection.gbl (2a01:111:f400:7c09::152) by BN3PR0301CA0021.outlook.office365.com (2a01:111:e400:4000::31) with Microsoft SMTP Server (TLS) id 15.0.995.14 via Frontend Transport; Mon, 28 Jul 2014 10:54:14 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD035.mail.protection.outlook.com (10.173.161.131) with Microsoft SMTP Server (TLS) id 15.0.990.10 via Frontend Transport; Mon, 28 Jul 2014 10:54:13 +0000 Received: from rio.ap.freescale.net (rio.ap.freescale.net [10.192.242.9]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s6SAs6SP024759; Mon, 28 Jul 2014 03:54:07 -0700 From: Nicolin Chen To: Date: Mon, 28 Jul 2014 18:56:01 +0800 Message-ID: <1406544961-19923-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 1.8.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130510184538278525; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(979002)(6009001)(199002)(189002)(102836001)(92726001)(74502001)(61266001)(47776003)(74662001)(20776003)(229853001)(64706001)(99396002)(107046002)(93916002)(19580395003)(6806004)(62966002)(19580405001)(44976005)(68736004)(50986999)(73392001)(73972005)(55446002)(104166001)(87572001)(80022001)(50226001)(92566001)(86362001)(84676001)(46102001)(87936001)(2351001)(33646002)(85306003)(81342001)(31966008)(81442001)(81542001)(26826002)(110136001)(97736001)(105596002)(79102001)(77156001)(48376002)(21056001)(4396001)(106466001)(77982001)(88136002)(85852003)(95666004)(89996001)(36756003)(104016003)(87286001)(82202001)(50466002)(83072002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:; SCL:1; SRVR:BLUPR03MB358; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 0286D7B531 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 192.88.168.50 as permitted sender) Authentication-Results: spf=softfail (sender IP is 192.88.168.50) smtp.mailfrom=nicoleotsuka@gmail.com; Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, b02247@freescale.com, linux-kernel@vger.kernel.org, b42378@freescale.com Subject: [alsa-devel] [PATCH] ASoC: wm8962: Let CODEC driver enable and disable its own MCLK 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 snd_soc_open() will trigger pm_runtime resume() which will then enable the regulator and initialization. So we should make sure the MCLK is enabled before this resume(). Previously we let the machine driver get the clock and enable it in its probe(). However, considering about power saving, it'll be better to enable it when it's going to be used and disable it after using. So this patch just simply adds clk_get() and clk_enable() to WM8962 driver. Meanwhile, it marks clock pointer to NULL if no clock assigned to it so it will not break any current function. Signed-off-by: Nicolin Chen --- include/sound/wm8962.h | 1 + sound/soc/codecs/wm8962.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/sound/wm8962.h b/include/sound/wm8962.h index 79e6d42..0af7c16 100644 --- a/include/sound/wm8962.h +++ b/include/sound/wm8962.h @@ -37,6 +37,7 @@ #define WM8962_GPIO_FN_MICSCD 22 struct wm8962_pdata { + struct clk *mclk; int gpio_base; u32 gpio_init[WM8962_MAX_GPIO]; diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index ca2fda9..256ae51 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -3541,6 +3542,8 @@ static int wm8962_set_pdata_from_of(struct i2c_client *i2c, pdata->gpio_init[i] = 0x0; } + pdata->mclk = devm_clk_get(&i2c->dev, NULL); + return 0; } @@ -3572,6 +3575,10 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, return ret; } + /* Mark the mclk pointer to NULL if no mclk assigned */ + if (IS_ERR(pdata->mclk)) + pdata->mclk = NULL; + for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) wm8962->supplies[i].supply = wm8962_supply_names[i]; @@ -3780,6 +3787,8 @@ static int wm8962_runtime_resume(struct device *dev) struct wm8962_priv *wm8962 = dev_get_drvdata(dev); int ret; + clk_prepare_enable(wm8962->pdata.mclk); + ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); if (ret != 0) { @@ -3839,6 +3848,8 @@ static int wm8962_runtime_suspend(struct device *dev) regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); + clk_disable_unprepare(wm8962->pdata.mclk); + return 0; } #endif