Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754173AbbFKLOF (ORCPT ); Thu, 11 Jun 2015 07:14:05 -0400 Received: from mail-bl2on0138.outbound.protection.outlook.com ([65.55.169.138]:44715 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751754AbbFKLN6 (ORCPT ); Thu, 11 Jun 2015 07:13:58 -0400 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; From: Zidan Wang To: CC: , , , , , , , , Zidan Wang Subject: [alsa-devel][PATCH 2/4] ASoC: wm8960: support configure headphone jack detect pin and polarity from device tree 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 Content-Type: text/plain 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?kzRXwmEnIZUq5UjvNIoyBAwfWXAs1WrgeP10HZx29YfOvvBaJ49qkrbqoOn3?= =?us-ascii?Q?gy7tcpvr8GpWWHEDRJVsA7Zm2lVKCOzCtbLYFGaSVKrFlhefi6Hht7equ+dD?= =?us-ascii?Q?qyh0kRCBCtvMMmVD7kbWWYHzR2MigORGgwnV7wZ/+W6ELzsiuoMdmBXroara?= =?us-ascii?Q?MiUBwj3bt4OMOdDa3sm4s/RZ4Ky3/GIP9Np3PUmAmLV6yW89+boxigZRO966?= =?us-ascii?Q?7eVq9AY8z7XogJ+cbQx8CFZRhfgZVhK/doVuujXfbhAUqk8ESspOlBBR/yMm?= =?us-ascii?Q?oucHq2r4GroeYrFL/PCAUZij17l3Odx8J+5kJOOQokWQeGlC1ryKpG5TW6Yv?= =?us-ascii?Q?AxlHmp0w87Qf/zbBIxiWYa2Os+VnWQgGfWFOxGF/bpXC10fxaHUHArIXNW3u?= =?us-ascii?Q?SfEzcgj0d3+24+veBI9zQCZ6lslqhzvabLd70tvI6No8hoYa9rh6cNZdO/M3?= =?us-ascii?Q?Yr/7jYgguKZNG3ImfTGdN421G1jwfo2/yPI+v9d9wd/Jhl1biUtrAuWS28LS?= =?us-ascii?Q?8ZvwG+OFWTTsOHObQWLUciRHOHMD4DX1ErGMUmI/uJWKUqNzvBkG+qHyfwNS?= =?us-ascii?Q?31aGRUOLEBegfG2hSANiaASxgofRxvpAnpsSDb5gdG0uuaSYFOkPSKm+vObM?= =?us-ascii?Q?yosOgO9twpqx37ZDK0KS8blvevqVkQRLJ5yafPfIaQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1254;3:7tlmUOVydjP8xynyiy4jsv+qjffzlT7ouZB4P9NXgiqAEv2STQNAmGuw4WylzhmhO7RzorjLCrnyfXV6MiKEMMs2jXH1txkdzEP7CgzQolInUGGMusLlhdruyir/T9Ep7RHJ2NaVfmYON+0ruBTpVQ==;10:P4DFjfFDjRWFgRzr9brGB5Pm/LgFWN+HMivOYkouvDaNU7crfAB7Vfo3uq0jPdjNQ6noNLuL6Ty5dzv/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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3509 Lines: 98 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); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/