From patchwork Thu Jun 11 11:14:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zidan Wang X-Patchwork-Id: 6587611 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 920B4C0020 for ; Thu, 11 Jun 2015 11:14:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF987204A9 for ; Thu, 11 Jun 2015 11:14:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 56D63204AD for ; Thu, 11 Jun 2015 11:14:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4D9392664D9; Thu, 11 Jun 2015 13:14:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, 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 DE507261AB7; Thu, 11 Jun 2015 13:14:07 +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 4D42B26644B; Thu, 11 Jun 2015 13:14:06 +0200 (CEST) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0133.outbound.protection.outlook.com [207.46.100.133]) by alsa0.perex.cz (Postfix) with ESMTP id 79BA4261A5F for ; Thu, 11 Jun 2015 13:13:58 +0200 (CEST) Received: from CO2PR03CA0029.namprd03.prod.outlook.com (10.141.194.156) by BY1PR0301MB1254.namprd03.prod.outlook.com (10.161.203.26) with Microsoft SMTP Server (TLS) id 15.1.184.17; Thu, 11 Jun 2015 11:13:55 +0000 Received: from BN1AFFO11FD021.protection.gbl (2a01:111:f400:7c10::170) by CO2PR03CA0029.outlook.office365.com (2a01:111:e400:1414::28) with Microsoft SMTP Server (TLS) id 15.1.190.14 via Frontend Transport; Thu, 11 Jun 2015 11:13:55 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD021.mail.protection.outlook.com (10.58.52.81) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Thu, 11 Jun 2015 11:13:54 +0000 Received: from b50113.ap.freescale.net (b50113.ap.freescale.net [10.192.241.89]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t5BBDjKi015356; Thu, 11 Jun 2015 04:13:51 -0700 From: Zidan Wang To: Date: Thu, 11 Jun 2015 19:14:34 +0800 Message-ID: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD021; 1:oPibQvFuC478qo8ROmlznMLUyAW2V27T4xpEG1BvnhyqD7d7MBotXBBYeHiBA7mMLvTpUBWG+wwJusIpIU91s7iw6ZhEnoKpFuj0NRscsfqvce4fx/JC0Mtn2uqK9+DIxZyEuxSjfju0s9Qh8psv80by8RGiMmFbQY72I4HAQ5W31YH0Ym8ymNsjucj1nAY37cyF4EoUHq4cwjNRf1itaCrFcA1V85rIMU7wW1E9+5PBt7zjdalf+9X9g/wLO0/R30bM/sP7cBJlVtrlAGDHSvfFdU0DYwCIx8pWgjsFUjIP3gRWjOJdj3WXPbeiSxNUvxiXIuK7ON1I5H7nxyceFiUfKJOyFlYxhl0O0gZNjjE= X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(199003)(189002)(19580405001)(106466001)(19580395003)(76176999)(50986999)(47776003)(77156002)(62966003)(6806004)(36756003)(87936001)(85426001)(86362001)(48376002)(50466002)(92566002)(77096005)(2950100001)(50226001)(46102003)(118296001)(5001920100001)(5001960100002)(189998001)(107886002)(110136002)(33646002)(105606002)(2351001)(229853001)(104016003)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR0301MB1254; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB1254; 2:sTLtXb6HdnefsHrO+ZDYclhKeSs8OBw0zyIFshsLgQU1IwBchGa6EASOxuaec9oE; 2:wBgaWWRBVtwH9tuip+lCZo1fFkWUD4ZFxwbWO1BB8IhYEH2ZAN+DYa0wvims9nrF0X5JnPUABQgt3uuIKGWEvriWZmEfc4jNBC06ex4thC/NAOoScGVB441WMQfrmuHs5Np278NcalFan/4R80z2oVqNeYywIvR81iAyvczjquur66X1hbiVwYXlxmnml7YF5U6KtFDupjgq5CJLdk7EGNwrGs8Tf1CT7VlQWd2IgCU=; 6:oM4BG6Gqd7IKrOIG9e0vlFZxgiSVNj51VF5u3rPaowW6ZJlhd+GlwlxzYzY0hyZId2I4/t4DDc7cfo2lsd2ECzMiGes8oAl4bCmSKMqxKwtpcmypA+4Q9mt/YMq6Ea9d1M/tbto/l8axeldlMfZuZe2rj6yhfHg6KQbhChou8d/wgc0Ii8c5fFfGTYZTmSqpxYeFnOuJebfwHjKczAyiqvvJqzS/9N0ZH2drMEnSodYLwt53PqAnVj0/lw/VUpNugLumR4yw+zX9nFrSSl5kRW+I1S0aa11uCGM2SxqPNw5UtFmJ+9T21w7vQT9x3uV3tGCo7XNfVDs0xy8+4s2/SQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1254; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(520003)(5005006)(3002001); SRVR:BY1PR0301MB1254; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0301MB1254; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB1254; 3:eTL0G3rky0oOh/6NovPW2aP1jsdBwTWqFC4hebR/SeCuM1IxzaXl8ECtytnaLnymM5ehisvf7rl/BBjVO+zlPh5UBLl64OzHF6pNbfwKtX7NxJsJHlpfdHGEQSSJ9p8npwzFzZmr4VyuGxlQ3sD9vSd5LJrFEpaXfRQGhASwCqC7ZyzzoRkCUkzkAu8XGKgH6/L+ePXLGP7NKYrcWyFMjLaRGL3Dm2B1dRICSWGiYrn7Q1uGqt1BEZmDKWLFaduw3+KyT6/7Y+MSTAHmOPLABZqWcge7hsvfxi+v6YCf8+wsfL1UpSg6jOOiMFOgTVwQ X-Forefront-PRVS: 0604AFA86B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0301MB1254; 9:5SFFzRieJKmwGaqQToPar/jPxrdtwOKKlTYEzpZL?= =?us-ascii?Q?ivoHMxYISQUlvw7qV3I8mMIxAeWzuRVkX+VoS4yacEnFXW1AFsG2rZEOIER4?= =?us-ascii?Q?kRbF68UFYfzSoVh6sYKs0ucjOO8cL2qMT3RUigDodaJaAz9PGId5mJy9gD1Y?= =?us-ascii?Q?jH4avdvNl+CrPGkDJKa1msArxZ8weK1wN9wJ4ujiJMVkCJDnqLMQq0Yn67jU?= =?us-ascii?Q?NkjKwpME+P/j65pZmG7nS36MyJJ6iQ06aHlhibYjLCWkwmPSccJS5hY56FWZ?= =?us-ascii?Q?kzRXwmEnIZUq5UjvNIoyBAwfWXAs1WrgeP10HZx29YfO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LuL6Ty5dzv/E3lJois/DCZ/urE3k5hE6aRNawI=; 6:+62ilwjykWChheLIPAf4lY6LZnt7s6le+hYuXCTobPyUsibcw7Zerdb46rnOiKB7 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2015 11:13:54.5763 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB1254 Cc: alsa-devel@alsa-project.org, lars@metafoo.de, Zidan Wang , tiwai@suse.de, linux-kernel@vger.kernel.org, patches@opensource.wolfsonmicro.com, lgirdwood@gmail.com, ckeepax@opensource.wolfsonmicro.com Subject: [alsa-devel] [PATCH 2/4] ASoC: wm8960: support configure headphone jack detect pin and polarity from 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 The ADCLRC/GPIO1, LINPUT3/JD2 and RINPUT3/JD3 pins can be selected as headphone jack detect inputs to automatically disable the speaker output and enable the headphone. Signed-off-by: Zidan Wang --- Documentation/devicetree/bindings/sound/wm8960.txt | 11 +++++++++++ include/sound/wm8960.h | 1 + sound/soc/codecs/wm8960.c | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/wm8960.txt b/Documentation/devicetree/bindings/sound/wm8960.txt index 2deb8a3..4f1aa8b 100644 --- a/Documentation/devicetree/bindings/sound/wm8960.txt +++ b/Documentation/devicetree/bindings/sound/wm8960.txt @@ -21,6 +21,16 @@ Optional properties: enabled and disabled together with HP_L and HP_R pins in response to jack detect events. + - wlf,hp-det: ADCLRC/GPIO1, LINPUT3/JD2 and RINPUT3/JD3 pins can be selected as + headphone jack detect inputs to automatically disable the speaker output + and enable the headphone output. + hp-det = ; + hp-det-pin = 1: ADCLRC/GPIO1 used as detect pin + hp-det-pin = 2: LINPUT3/JD2 used as detect pin + hp-det-pin = 3: RINPUT3/JD3 used as detect pin + hp-det-polarity = 0: hp detect high for headphone + hp-det-polarity = 1: hp detect high for speaker + Example: codec: wm8960@1a { @@ -28,4 +38,5 @@ codec: wm8960@1a { reg = <0x1a>; wlf,shared-lrclk; + wlf,hp-det = <2 0> }; diff --git a/include/sound/wm8960.h b/include/sound/wm8960.h index e8ce8ee..a787376 100644 --- a/include/sound/wm8960.h +++ b/include/sound/wm8960.h @@ -19,6 +19,7 @@ struct wm8960_data { bool capless; /* Headphone outputs configured in capless mode */ bool shared_lrclk; /* DAC and ADC LRCLKs are wired together */ + u32 hp_det[2]; /* headphone detect pin and polarity */ }; #endif diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 729205f..c1be15c 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -1123,6 +1123,11 @@ static void wm8960_set_pdata_from_of(struct i2c_client *i2c, if (of_property_read_bool(np, "wlf,shared-lrclk")) pdata->shared_lrclk = true; + + of_property_read_u32_array(np, "wlf,hp-det", pdata->hp_det, 2); + + if (pdata->hp_det[0] > 3) + pdata->hp_det[0] = 0; } static int wm8960_i2c_probe(struct i2c_client *i2c, @@ -1168,6 +1173,23 @@ static int wm8960_i2c_probe(struct i2c_client *i2c, } } + /* + * ADCLRC/GPIO1 pin configured as GPIO1 to select jack + * detect input function + */ + if (wm8960->pdata.hp_det[0] == 1) + regmap_update_bits(wm8960->regmap, WM8960_IFACE2, 1<<6, 1<<6); + + /* Enable headphone jack detect */ + if (wm8960->pdata.hp_det[0] != 0) { + regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, 1<<6, 1<<6); + regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, 1<<5, + wm8960->pdata.hp_det[1]<<5); + regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 3<<2, + wm8960->pdata.hp_det[0]<<2); + regmap_update_bits(wm8960->regmap, WM8960_ADDCTL1, 3, 3); + } + /* Latch the update bits */ regmap_update_bits(wm8960->regmap, WM8960_LINVOL, 0x100, 0x100); regmap_update_bits(wm8960->regmap, WM8960_RINVOL, 0x100, 0x100);