From patchwork Wed Nov 19 12:36:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zidan Wang X-Patchwork-Id: 5336961 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 C4926C11AC for ; Wed, 19 Nov 2014 12:36:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E131A201F2 for ; Wed, 19 Nov 2014 12:36:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B9945201E4 for ; Wed, 19 Nov 2014 12:36:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 35A9C260505; Wed, 19 Nov 2014 13:36:00 +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, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 8DAE82604F0; Wed, 19 Nov 2014 13:35:52 +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 A0C0E2604FA; Wed, 19 Nov 2014 13:35:50 +0100 (CET) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0142.outbound.protection.outlook.com [157.56.111.142]) by alsa0.perex.cz (Postfix) with ESMTP id B21A42604E7 for ; Wed, 19 Nov 2014 13:35:40 +0100 (CET) Received: from DM2PR0301MB1262.namprd03.prod.outlook.com (25.160.219.27) by DM2PR0301MB0608.namprd03.prod.outlook.com (25.160.95.24) with Microsoft SMTP Server (TLS) id 15.1.16.15; Wed, 19 Nov 2014 12:35:38 +0000 Received: from BN3PR0301CA0061.namprd03.prod.outlook.com (25.160.152.157) by DM2PR0301MB1262.namprd03.prod.outlook.com (25.160.219.27) with Microsoft SMTP Server (TLS) id 15.1.16.15; Wed, 19 Nov 2014 12:35:37 +0000 Received: from BL2FFO11FD054.protection.gbl (2a01:111:f400:7c09::154) by BN3PR0301CA0061.outlook.office365.com (2a01:111:e400:401e::29) with Microsoft SMTP Server (TLS) id 15.1.16.15 via Frontend Transport; Wed, 19 Nov 2014 12:35:37 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD054.mail.protection.outlook.com (10.173.161.182) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Wed, 19 Nov 2014 12:35:36 +0000 Received: from b50113.ap.freescale.net (b50113.ap.freescale.net [10.192.241.89]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id sAJCZTgh011400; Wed, 19 Nov 2014 05:35:30 -0700 From: Zidan Wang To: Date: Wed, 19 Nov 2014 20:36:08 +0800 Message-ID: <1416400568-7512-1-git-send-email-b50113@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=B50113@freescale.com; X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(107046002)(64706001)(229853001)(20776003)(2351001)(104016003)(110136001)(33646002)(36756003)(99396003)(47776003)(120916001)(88136002)(87936001)(102836001)(87286001)(48376002)(97736003)(104166001)(85426001)(46102003)(68736004)(62966003)(50226001)(4396001)(50986999)(106466001)(89996001)(77156002)(84676001)(31966008)(86362001)(50466002)(92726001)(93916002)(105606002)(19580405001)(19580395003)(44976005)(95666004)(21056001)(92566001)(6806004)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR0301MB1262; H:tx30smr01.am.freescale.net; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1262; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:DM2PR0301MB1262; X-Forefront-PRVS: 04004D94E2 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:DM2PR0301MB1262; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0608; X-OriginatorOrg: freescale.com Cc: alsa-devel@alsa-project.org, lars@metafoo.de, tiwai@suse.de, linux-kernel@vger.kernel.org, patches@opensource.wolfsonmicro.com, lgirdwood@gmail.com, Li.Xiubo@freescale.com, Zidan Wang , ckeepax@opensource.wolfsonmicro.com Subject: [alsa-devel] [PATCH] ASoC: wm8960: Add shared_lrclk and capless to device tree 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 wm8960 codec has a wm8960_data struct which has two fields shared_lrclk and capless. The wm8960_data is get from platform_data and it is reasonable to set it from device tree when platform_data is null. And when shared_lrclk is set, LRCM will be enabled. But the following software reset in wm8960_probe will reset it to the default state. So LRCM operation should after software reset. Signed-off-by: Zidan Wang --- sound/soc/codecs/wm8960.c | 49 ++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 4dc4e85..1d56c90 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -125,6 +125,7 @@ struct wm8960_priv { struct snd_soc_dapm_widget *out3; bool deemph; int playback_fs; + struct wm8960_data pdata; }; #define wm8960_reset(c) snd_soc_write(c, WM8960_RESET, 0) @@ -961,17 +962,13 @@ static int wm8960_resume(struct snd_soc_codec *codec) static int wm8960_probe(struct snd_soc_codec *codec) { struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); - struct wm8960_data *pdata = dev_get_platdata(codec->dev); + struct wm8960_data *pdata = &wm8960->pdata; int ret; - wm8960->set_bias_level = wm8960_set_bias_level_out3; - - if (!pdata) { - dev_warn(codec->dev, "No platform data supplied\n"); - } else { - if (pdata->capless) - wm8960->set_bias_level = wm8960_set_bias_level_capless; - } + if (pdata->capless) + wm8960->set_bias_level = wm8960_set_bias_level_capless; + else + wm8960->set_bias_level = wm8960_set_bias_level_out3; ret = wm8960_reset(codec); if (ret < 0) { @@ -979,6 +976,14 @@ static int wm8960_probe(struct snd_soc_codec *codec) return ret; } + if (pdata->shared_lrclk) { + ret = snd_soc_update_bits(codec, WM8960_ADDCTL2, 0x4, 0x4); + if (ret < 0) { + dev_err(codec->dev, "Failed to enable LRCM: %d\n", ret); + return ret; + } + } + wm8960->set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* Latch the update bits */ @@ -1029,6 +1034,18 @@ static const struct regmap_config wm8960_regmap = { .volatile_reg = wm8960_volatile, }; +static void wm8960_set_pdata_from_of(struct i2c_client *i2c, + struct wm8960_data *pdata) +{ + const struct device_node *np = i2c->dev.of_node; + + if (of_property_read_bool(np, "capless")) + pdata->capless = true; + + if (of_property_read_bool(np, "shared_lrclk")) + pdata->shared_lrclk = true; +} + static int wm8960_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -1038,6 +1055,7 @@ static int wm8960_i2c_probe(struct i2c_client *i2c, wm8960 = devm_kzalloc(&i2c->dev, sizeof(struct wm8960_priv), GFP_KERNEL); + if (wm8960 == NULL) return -ENOMEM; @@ -1045,15 +1063,10 @@ static int wm8960_i2c_probe(struct i2c_client *i2c, if (IS_ERR(wm8960->regmap)) return PTR_ERR(wm8960->regmap); - if (pdata && pdata->shared_lrclk) { - ret = regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, - 0x4, 0x4); - if (ret != 0) { - dev_err(&i2c->dev, "Failed to enable LRCM: %d\n", - ret); - return ret; - } - } + if (pdata) + memcpy(&wm8960->pdata, pdata, sizeof(struct wm8960_data)); + else if (i2c->dev.of_node) + wm8960_set_pdata_from_of(i2c, &wm8960->pdata); i2c_set_clientdata(i2c, wm8960);