From patchwork Thu Aug 17 08:02:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 110302 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1858668qge; Thu, 17 Aug 2017 01:02:43 -0700 (PDT) X-Received: by 10.223.160.26 with SMTP id k26mr2574031wrk.121.1502956963823; Thu, 17 Aug 2017 01:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502956963; cv=none; d=google.com; s=arc-20160816; b=u7bTPJhaQq7kPTmV9rFBJQ1JO8Ma5cERkA0MUZ/nYgHb0M/ZKWGi9/q3ou6VSAH2im zS9FTpZTl+OX+Ycl4zQzwql1quEcgibOx5Bmc01ACGeCM44U2SBzEcGCxDyK5LGmKLSs gHe8f8zBYKZjM26+C/1jT2idWYRfeLWSxyd4zAuaQwCkKggOt0KbQ1POPrnqJ3aymJYJ cxm8qgmmH+RVdfktppI5oUyscyqqOmTE+dl0Kc3+9W/ZPA/wWCXPaBhV+w4YfGm4pw5s lOsc9AH0AGfMeYjJMbj4d29CNEzL6kabSGvIM6+kuaEX49pPP4HZoTHA0WtK1n7MGMZf jYNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=/Qd/Q4NjMnXJW6d7hdg5/tpqUw9nMw/zCDkl3d6HUCw=; b=XBqa7OOC/HXbPzJ1XHyEZagjMNTyqnbFF2BaNQhsKSgqB2bGk+pTkAGhB5RIlFqDWN FdCeyLy4EH+smRAv/PMCKGQeOcplqepdYtFItGSu8/bLwymwsvwqFFFVvlghmiRapBcB kz2p0KXdDG5ZraEc2s0M8zRqkz7VOO7iMTr/5k9nRZqtGKUOaoBEyJMOBrDWX6Ww1lZq mkc9VksHMjCkT0N6MngKa3Gl9fH07eeLcEsZfrylIkB8eNOTYjr36anXM7d+097+tUC0 SS0NSvs24G+2jPu4PcuNckL1//1Z0RfdwSJqoulJrO+PRA7QgUWzCxs64+PJ3tDNTpuX hYMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Kyhs2SAI; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id g132si2217218wmf.106.2017.08.17.01.02.43; Thu, 17 Aug 2017 01:02:43 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Kyhs2SAI; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id C8D03266DBC; Thu, 17 Aug 2017 10:02:25 +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 2C039266D8D; Thu, 17 Aug 2017 10:02:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-it0-f41.google.com (mail-it0-f41.google.com [209.85.214.41]) by alsa0.perex.cz (Postfix) with ESMTP id E165D266D8D for ; Thu, 17 Aug 2017 10:02:20 +0200 (CEST) Received: by mail-it0-f41.google.com with SMTP id 76so27824065ith.0 for ; Thu, 17 Aug 2017 01:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NxnaR5C/SCwfAaJiRa2SfF4nS18Xz5XdwvTPH0jtJ6w=; b=Kyhs2SAIKQVxKG4lI4OFCxfuGWKQ1U6LJtOKj2XifdEhNt2GiGokGFFmB/SAEtD1lv nt+8WLtprkYgECbUDI2qGWuJz5hbNIS1elYG21HZ2sshB+9v//05kXM94DjzuBB1IJtz cG0ZWUK/LT/Pzxns+EQjng22Zd6hiiuO7Y5oQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NxnaR5C/SCwfAaJiRa2SfF4nS18Xz5XdwvTPH0jtJ6w=; b=aiygPt+Imu08Vqx2BCFdD8gUxlBA6Oi4Jpx2/pHKg69jdWz2hl3DVAPxKNY1x0DWqd M6eSIXnMCgQNEnYuzerSDEGsghvwR4tqytjkN5MWF7lWblpTvLoIDpIZakQqfPlQrKEH 3F19x0j2apk5ZX3e5/NVcL/pBMnrscG7AjJFbQ8aqQqwC/yn4kMSEDQF0ZE3Ltjj+et7 WFrS8tgbc7zpbc+6fbS/RHyRjdVpYcZcEc/dqPYcnycoELLLDllI26/8oP8mFRhfqOqn XNIfodlMwY9GYCsc16LgSJVvhaH2pK+sqwczXyCzOascDrcB/NGWt2HNQmVD64t1k4Bf C1IA== X-Gm-Message-State: AHYfb5jK47eWOxSqt3u1DJTJXNCIKKGFP19uIpf5wq8VvZI4Ac57NZrR 61Tpa2BKuGqC2PXI X-Received: by 10.36.142.131 with SMTP id h125mr1091684ite.7.1502956939610; Thu, 17 Aug 2017 01:02:19 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id o10sm1235777ioe.27.2017.08.17.01.02.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Aug 2017 01:02:19 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Date: Thu, 17 Aug 2017 10:02:09 +0200 Message-Id: <20170817080211.11453-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170817080211.11453-1-srinivas.kandagatla@linaro.org> References: <20170817080211.11453-1-srinivas.kandagatla@linaro.org> Cc: damien.riegel@savoirfairelinux.com, Patrick Lai , linux-kernel@vger.kernel.org, Takashi Iwai , Srinivas Kandagatla Subject: [alsa-devel] [PATCH v4 1/3] ASoC: codecs: msm8916-wcd-analog: get micbias voltage from dt 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 From: Srinivas Kandagatla This patch adds bindings in DT to provide required micbias voltage which could be specific to board. With this new binding, now the mic bias voltage is left at hardware default value if the device tree does not specify any mic bias voltage value. Correct micbias value is required for mbhc buttons to work. Signed-off-by: Srinivas Kandagatla --- .../bindings/sound/qcom,msm8916-wcd-analog.txt | 1 + sound/soc/codecs/msm8916-wcd-analog.c | 27 +++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) -- 2.11.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt b/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt index ccb401cfef9d..05b67a1d4851 100644 --- a/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt +++ b/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt @@ -33,6 +33,7 @@ Required properties - vdd-micbias-supply: phandle of VDD_MICBIAS supply's regulator DT node. Optional Properties: +- qcom,micbias-lvl: Voltage (mV) for Mic Bias - qcom,micbias1-ext-cap: boolean, present if micbias1 has external capacitor connected. - qcom,micbias2-ext-cap: boolean, present if micbias2 has external capacitor diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index a0de3e7204d5..8633524b1961 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -93,8 +93,12 @@ #define MICB_1_EN_TX3_GND_SEL_TX_GND 0 #define CDC_A_MICB_1_VAL (0xf141) +#define MICB_MIN_VAL 1600 +#define MICB_STEP_SIZE 50 +#define MICB_VOLTAGE_REGVAL(v) ((v - MICB_MIN_VAL)/MICB_STEP_SIZE) #define MICB_1_VAL_MICB_OUT_VAL_MASK GENMASK(7, 3) #define MICB_1_VAL_MICB_OUT_VAL_V2P70V ((0x16) << 3) +#define MICB_1_VAL_MICB_OUT_VAL_V1P80V ((0x4) << 3) #define CDC_A_MICB_1_CTL (0xf142) #define MICB_1_CTL_CFILT_REF_SEL_MASK BIT(1) @@ -225,6 +229,7 @@ struct pm8916_wcd_analog_priv { struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; unsigned int micbias1_cap_mode; unsigned int micbias2_cap_mode; + unsigned int micbias_mv; }; static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" }; @@ -265,18 +270,25 @@ static const struct snd_kcontrol_new pm8916_wcd_analog_snd_controls[] = { static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec) { + struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, MICB_1_CTL_INT_PRECHARG_BYP_EXT_PRECHRG_SEL | MICB_1_CTL_EXT_PRECHARG_EN_ENABLE); - snd_soc_write(codec, CDC_A_MICB_1_VAL, MICB_1_VAL_MICB_OUT_VAL_V2P70V); - /* - * Special headset needs MICBIAS as 2.7V so wait for - * 50 msec for the MICBIAS to reach 2.7 volts. - */ - msleep(50); + if (wcd->micbias_mv) { + snd_soc_write(codec, CDC_A_MICB_1_VAL, + MICB_VOLTAGE_REGVAL(wcd->micbias_mv)); + /* + * Special headset needs MICBIAS as 2.7V so wait for + * 50 msec for the MICBIAS to reach 2.7 volts. + */ + if (wcd->micbias_mv >= 2700) + msleep(50); + } + snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, 0); @@ -795,6 +807,9 @@ static int pm8916_wcd_analog_parse_dt(struct device *dev, else priv->micbias2_cap_mode = MICB_1_EN_NO_EXT_BYP_CAP; + of_property_read_u32(dev->of_node, "qcom,micbias-lvl", + &priv->micbias_mv); + return 0; }