From patchwork Wed Apr 22 11:23:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inha Song X-Patchwork-Id: 6255681 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 3F2DD9F1C4 for ; Wed, 22 Apr 2015 11:24:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 529A4202F2 for ; Wed, 22 Apr 2015 11:24:22 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id F208020253 for ; Wed, 22 Apr 2015 11:24:20 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1EDB02664E2; Wed, 22 Apr 2015 13:24:20 +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, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 9A666265817; Wed, 22 Apr 2015 13:23:36 +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 B676026578E; Wed, 22 Apr 2015 13:23:34 +0200 (CEST) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by alsa0.perex.cz (Postfix) with ESMTP id E08FE26057F for ; Wed, 22 Apr 2015 13:23:26 +0200 (CEST) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NN700KN8GZ0N4B0@mailout4.samsung.com> for alsa-devel@alsa-project.org; Wed, 22 Apr 2015 20:23:24 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.113]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id B7.24.28411.CA487355; Wed, 22 Apr 2015 20:23:24 +0900 (KST) X-AuditID: cbfee68e-f79c56d000006efb-d8-553784acb3da Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id AE.F6.03871.CA487355; Wed, 22 Apr 2015 20:23:24 +0900 (KST) Received: from songinha-Samsung-DeskTop-System.10.32.193.11 ([10.252.81.136]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NN700EAQGYYO350@mmp1.samsung.com>; Wed, 22 Apr 2015 20:23:24 +0900 (KST) From: Inha Song To: lee.jones@linaro.org Date: Wed, 22 Apr 2015 20:23:20 +0900 Message-id: <1429701801-25287-2-git-send-email-ideal.song@samsung.com> X-Mailer: git-send-email 2.0.0.390.gcb682f8 In-reply-to: <1429701801-25287-1-git-send-email-ideal.song@samsung.com> References: <1429701801-25287-1-git-send-email-ideal.song@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42JZI2JSqLumxTzU4Od/LYsrFw8xWUx9+ITN 4t+UG+wW1788Z7WYf+Qcq8Wuv/cZLc69Wslocf/rUUaLy7vmsFksvX6RyWL52/9sFhOmr2Wx mDXxD4tF694j7A58Hhs+N7F5rJm3htFj5fIvbB6bVnWyedy5tofN4+XE32wefVtWMXp83iQX wBHFZZOSmpNZllqkb5fAldFzfBN7wWylir/LpzI3MN6S6WLk5JAQMJHYtPchE4QtJnHh3no2 EFtIYCmjRMdiP5ia880PWbsYuYDiixglDl6/wAxRNJFJ4uW5PBCbTUBD4vvnzWBxEQEJiY0/ +lhAGpgFfjJJfL37BSwhLFArsfrTNEYQm0V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pecn7u JkZwrD6T3sG4qsHiEKMAB6MSDy8Dl3moEGtiWXFl7iFGCQ5mJRHehnqgEG9KYmVValF+fFFp TmrxIUZToKsmMkuJJucD00heSbyhsYmZkaWRuaGFkbG5kjjvHF25UCGB9MSS1OzU1ILUIpg+ Jg5OqQbGjeeMtT149acvWDNHhUvx/4q5u11X667yWr6cK8DQNZrXY7/80hI+m7jYOf/NjBdl PjsZf0v63oPe1wd5iqtTX92/0//z3rvYry9cE7fFsPqlHpP9pf+qRNV8zYt3n5dpsy3WmP/h YPXG5YobrTPqXt441ta6cre/Z9x8xf51f7wfiMw16I/LV2Ipzkg01GIuKk4EAKPRfXbrAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, cw00.choi@samsung.com, broonie@kernel.org, ckeepax@opensource.wolfsonmicro.com, rf@opensource.wolfsonmicro.com, Inha Song Subject: [alsa-devel] [PATCH v3 1/2] extcon: arizona: Add support for select accessory detect mode when headphone detection 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add support for select accessory detect mode to HPDETL or HPDETR. Arizona provides a headphone detection circuit on the HPDETL and HPDETR pins to measure the impedance of an external load connected to the headphone. Depending on board design, headphone detect pins can change to HPDETR or HPDETL. Signed-off-by: Inha Song --- drivers/extcon/extcon-arizona.c | 38 ++++++++++++++++++++++++++++++-------- include/dt-bindings/mfd/arizona.h | 8 ++++++++ include/linux/mfd/arizona/pdata.h | 3 +++ 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 include/dt-bindings/mfd/arizona.h diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 63f01c4..d9284af 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -32,13 +32,10 @@ #include #include #include +#include #define ARIZONA_MAX_MICD_RANGE 8 -#define ARIZONA_ACCDET_MODE_MIC 0 -#define ARIZONA_ACCDET_MODE_HPL 1 -#define ARIZONA_ACCDET_MODE_HPR 2 - #define ARIZONA_MICD_CLAMP_MODE_JDL 0x4 #define ARIZONA_MICD_CLAMP_MODE_JDH 0x5 #define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9 @@ -653,9 +650,9 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info) ret = regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1, ARIZONA_ACCDET_MODE_MASK, - ARIZONA_ACCDET_MODE_HPL); + arizona->pdata.hpdet_channel); if (ret != 0) { - dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret); + dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret); goto err; } @@ -705,9 +702,9 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info) ARIZONA_ACCESSORY_DETECT_MODE_1, ARIZONA_ACCDET_SRC | ARIZONA_ACCDET_MODE_MASK, info->micd_modes[0].src | - ARIZONA_ACCDET_MODE_HPL); + arizona->pdata.hpdet_channel); if (ret != 0) { - dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret); + dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret); goto err; } @@ -1103,6 +1100,26 @@ static void arizona_micd_set_level(struct arizona *arizona, int index, regmap_update_bits(arizona->regmap, reg, mask, level); } +static int arizona_extcon_of_get_pdata(struct arizona *arizona) +{ + struct arizona_pdata *pdata = &arizona->pdata; + unsigned int val; + + of_property_read_u32(arizona->dev->of_node, "wlf,hpdet-channel", &val); + switch (val) { + case ARIZONA_ACCDET_MODE_HPL: + case ARIZONA_ACCDET_MODE_HPR: + pdata->hpdet_channel = val; + break; + default: + dev_err(arizona->dev, + "Wrong wlf,hpdet-channel DT value %d\n", val); + pdata->hpdet_channel = ARIZONA_ACCDET_MODE_HPL; + } + + return 0; +} + static int arizona_extcon_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -1120,6 +1137,11 @@ static int arizona_extcon_probe(struct platform_device *pdev) if (!info) return -ENOMEM; + if (IS_ENABLED(CONFIG_OF)) { + if (!dev_get_platdata(arizona->dev)) + arizona_extcon_of_get_pdata(arizona); + } + info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD"); if (IS_ERR(info->micvdd)) { ret = PTR_ERR(info->micvdd); diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h new file mode 100644 index 0000000..9ecff78 --- /dev/null +++ b/include/dt-bindings/mfd/arizona.h @@ -0,0 +1,8 @@ +#ifndef __DT_BINDINGS_ARIZONA_H__ +#define __DT_BINDINGS_ARIZONA_H__ + +#define ARIZONA_ACCDET_MODE_MIC 0 +#define ARIZONA_ACCDET_MODE_HPL 1 +#define ARIZONA_ACCDET_MODE_HPR 2 + +#endif /* __DT_BINDINGS_ARIZONA_H__ */ diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h index 4578c72..2473a67 100644 --- a/include/linux/mfd/arizona/pdata.h +++ b/include/linux/mfd/arizona/pdata.h @@ -139,6 +139,9 @@ struct arizona_pdata { /** GPIO used for mic isolation with HPDET */ int hpdet_id_gpio; + /** Channel to use for headphone detection */ + unsigned int hpdet_channel; + /** Extra debounce timeout used during initial mic detection (ms) */ int micd_detect_debounce;