Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932222AbbDQIdr (ORCPT ); Fri, 17 Apr 2015 04:33:47 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:42227 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753910AbbDQIdN (ORCPT ); Fri, 17 Apr 2015 04:33:13 -0400 X-AuditID: cbfee68f-f793b6d000005f66-11-5530c53f0938 From: Inha Song To: lee.jones@linaro.org Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patches@opensource.wolfsonmicro.com, cw00.choi@samsung.com, broonie@kernel.org, ckeepax@opensource.wolfsonmicro.com, rf@opensource.wolfsonmicro.com, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, Inha Song Subject: [alsa-devel] [PATCH 1/2] extcon: arizona: Add support for select accessory detect mode when headphone detection" Date: Fri, 17 Apr 2015 17:32:58 +0900 Message-id: <1429259579-16563-2-git-send-email-ideal.song@samsung.com> X-Mailer: git-send-email 2.0.0.390.gcb682f8 In-reply-to: <1429259579-16563-1-git-send-email-ideal.song@samsung.com> References: <1429259579-16563-1-git-send-email-ideal.song@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42JZI2JSomt/1CDUYOJ+OYsrFw8xWUx9+ITN 4t+UG+wW1788Z7WYf+Qcq8Wuv/cZLc69Wslocf/rUUaLy7vmsFksvX6RyWL52/9sFhOmr2Wx mDXxD4tF694j7A58Hhs+N7F5rJm3htFj5fIvbB6bVnWyedy5tofN4+XE32wefVtWMXp83iQX wBHFZZOSmpNZllqkb5fAlTFzwgP2ghcyFTef3GJqYPwi3sXIySEhYCJxo3sFK4QtJnHh3nq2 LkYuDiGBpYwSSxtnsMIUPfqxFCqxiFFi7fQFLBDORCaJ3h0PwarYBDQkvn/ezAxiiwhISGz8 0QdWxCzwk0ni690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yQXFSem5hnrFibnFpXnpesn5uZsY wdH6TGoH48oGi0OMAhyMSjy8EkkGoUKsiWXFlbmHGCU4mJVEeDm2AYV4UxIrq1KL8uOLSnNS iw8xmgJdNZFZSjQ5H5hI8kriDY1NzIwsjcwNLYyMzZXEeefoyoUKCaQnlqRmp6YWpBbB9DFx cEo1MB5h0Bb0UZHv35NwR+rfRJ3kB9b3Vz3/39otdOVJjYya4r2l0TU+dp57H28znfanjC/r zioumbdzJPjn3C2c+kJv792MXxcyDCdE2Je96+mV2i7nsXTZ/PkzjT9N6lI6tJnhbID40VK3 91nSn2Vqew7MMD4t4/OvOnjuPHapmhvhtc96ZPuMPyixFGckGmoxFxUnAgAadpCW7AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3822 Lines: 116 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 | 34 ++++++++++++++++++++++++++++++---- include/linux/mfd/arizona/pdata.h | 3 +++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 63f01c4..7bc9159 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -95,6 +95,7 @@ struct arizona_extcon_info { int jack_flips; int hpdet_ip; + int hpdet_channel; struct extcon_dev *edev; }; @@ -653,9 +654,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); + info->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 +706,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); + info->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 +1104,23 @@ static void arizona_micd_set_level(struct arizona *arizona, int index, regmap_update_bits(arizona->regmap, reg, mask, level); } +#ifdef CONFIG_OF +static int arizona_of_get_extcon_pdata(struct arizona *arizona) +{ + struct arizona_pdata *pdata = &arizona->pdata; + + of_property_read_u32(arizona->dev->of_node, "wlf,hpdet-channel", + &pdata->hpdet_channel); + + return 0; +} +#else +static inline int arizona_of_get_extcon_pdata(struct arizona *arizona) +{ + return 0; +} +#endif + static int arizona_extcon_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -1120,6 +1138,9 @@ static int arizona_extcon_probe(struct platform_device *pdev) if (!info) return -ENOMEM; + if (!dev_get_platdata(arizona->dev)) + arizona_of_get_extcon_pdata(arizona); + info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD"); if (IS_ERR(info->micvdd)) { ret = PTR_ERR(info->micvdd); @@ -1338,6 +1359,11 @@ static int arizona_extcon_probe(struct platform_device *pdev) arizona_extcon_set_mode(info, 0); + if (arizona->pdata.hpdet_channel) + info->hpdet_channel = ARIZONA_ACCDET_MODE_HPR; + else + info->hpdet_channel = ARIZONA_ACCDET_MODE_HPL; + pm_runtime_enable(&pdev->dev); pm_runtime_idle(&pdev->dev); pm_runtime_get_sync(&pdev->dev); diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h index 4578c72..feb5903 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 */ + int hpdet_channel; + /** Extra debounce timeout used during initial mic detection (ms) */ int micd_detect_debounce; -- 2.0.0.390.gcb682f8 -- 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/