From patchwork Wed Jul 26 00:35:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 108723 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp198518qge; Tue, 25 Jul 2017 17:35:38 -0700 (PDT) X-Received: by 10.99.111.132 with SMTP id k126mr20743818pgc.76.1501029337654; Tue, 25 Jul 2017 17:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501029337; cv=none; d=google.com; s=arc-20160816; b=nxvgAPMKQldC84s9cTFPlKGxmys7qTCLe0QgDQL5tLYA/akCXbKObjFoMyXS/NeSdQ dQqCBkr9FYiUSbfJKiaB9dRCo9aVhLHEdTGuj1WyPpbx4gtOR2WW7je4Bbr/iLY1HPMo JLb5cHAiwQKCnSbYiaJQbo+mOOwH1uZSQxwlGTu07CGt6dxQrxCF4HJzebJamZ99S4qu FYTAjTpBPKUhoS78aF2Q+NDeZngriYUUOHKgvU88o+pdNWjyWxtjG+llL9xCmQQL5/Qa yEa6uowX/8stdWLWqvTDrA8yKVg5qes72vvbsedBW6o/SQh0yUAarBC/WazbS641YHkn UBpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rt9fWE+6UYKfu5AiB9lM/68lhanDVbAogcqEd8ZgIN8=; b=waJHV/nlW3lMgJ1EDCz4UMy1CnyRl+eSsuiix+kgwkCpu6/15sVmKwMPpfxGMkuSQ7 /7RmcDz6KE1tDZ0JaJJtjU9hXmvYVBFe/SQ0XCxrPegaDqeZWn6dB9p0XiOi2hWf+kg2 hO10atGCgfE/97v1JSZnytwpKTJ+SLWt1EyfbH7F0GmMT5CmiwMJeYkeKRIp1LTWAAKz UV0z8sSnQEQPnzy4MZqQXtZaV3bUTO0ax+DTM7e+kFIVQkwaecJHgD9SoxrPEb8HdyGW b9VEM4f2F/vZ3SHzvqJYU88/2SwYnhiiGtrTN4Hd7NYo/VaS4D7Nhw0oHi7dlItZ1AcG NfwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=ReiKoQhy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9si8888327pge.35.2017.07.25.17.35.37; Tue, 25 Jul 2017 17:35:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=ReiKoQhy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbdGZAfe (ORCPT + 26 others); Tue, 25 Jul 2017 20:35:34 -0400 Received: from mail-io0-f178.google.com ([209.85.223.178]:35505 "EHLO mail-io0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbdGZAfc (ORCPT ); Tue, 25 Jul 2017 20:35:32 -0400 Received: by mail-io0-f178.google.com with SMTP id m88so53437213iod.2 for ; Tue, 25 Jul 2017 17:35:31 -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=rt9fWE+6UYKfu5AiB9lM/68lhanDVbAogcqEd8ZgIN8=; b=ReiKoQhy+DUCwIjbhXHQ0xEPCiw7fnfa3M6fJhZsydv4rHM6jQa+PxkpZBg3vqnb/f IAETYdebnW3DRMmNaLion9G/hrvaOicmrxhejEJZhJEhqtOfQ65WneCYqVMFr5w8fHaK MPVKUm4NIXzpexV1+avVTDJLDqAZph4kojRwQ= 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=rt9fWE+6UYKfu5AiB9lM/68lhanDVbAogcqEd8ZgIN8=; b=Krb4FpB61iGJ3DfLqTvvg6/RIL7IJSLJmNHh7x3q6Ii1BF5x/2QX3UxdAxkvS47xtv JejESvJMq+kYraC8uRIs6QuFRkXhU/0al1NCXbD8png1L342zF54XtSK+YYKh18TQYG6 Vxp5S9TOqsLFfUMewMNbtnH0646vF6LvlHiMUbIVwm8udr6R6XJUp+yEDHAGzuPKjdqf 7JRVoCJugUKlJPBRdcusJKXHYnVQmEBdVvz6KFQk9+1pnbAzLtceYuL/YD8+APUIPKzH q+T9bpiDqSjG2+8XfTFB7fRi3SEUYzrTybq7icirJF9ae7/gmGw0gMyetPxGKsS185S+ NmCQ== X-Gm-Message-State: AIVw111nTc5YmzZz1RFjSMOLCvTykGEdivNJk1X5eNJ06QoIqzXXv1u4 KC5yn9M7CmPP6hf+ X-Received: by 10.107.23.4 with SMTP id 4mr20502834iox.110.1501029331416; Tue, 25 Jul 2017 17:35:31 -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 l69sm5097373ioi.49.2017.07.25.17.35.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:35:31 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v1 4/6] ASoC: codecs: msm8916-wcd-analog: set default micbias voltage to 1.8 Date: Wed, 26 Jul 2017 02:35:10 +0200 Message-Id: <20170726003512.18965-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> References: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla This patch sets the default internal micbias voltage to 1.8v. This default value is required for mbhc buttons to work. Also adds dt bindings to allow the board level file to specify the required default micbias value. Signed-off-by: Srinivas Kandagatla --- .../bindings/sound/qcom,msm8916-wcd-analog.txt | 1 + sound/soc/codecs/msm8916-wcd-analog.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) -- 2.9.3 diff --git a/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt b/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt index ccb401c..05b67a1 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 6606954..69df0ee 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -93,8 +93,13 @@ #define MICB_1_EN_TX3_GND_SEL_TX_GND 0 #define CDC_A_MICB_1_VAL (0xf141) +#define MICB_DEFAULT_VAL 1800 +#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 +230,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 +271,16 @@ 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); + snd_soc_write(codec, CDC_A_MICB_1_VAL, + MICB_VOLTAGE_REGVAL(wcd->micbias_mv)); 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 +799,10 @@ static int pm8916_wcd_analog_parse_dt(struct device *dev, else priv->micbias2_cap_mode = MICB_1_EN_NO_EXT_BYP_CAP; + if (of_property_read_u32(dev->of_node, "qcom,micbias-lvl", + &priv->micbias_mv)) + priv->micbias_mv = MICB_DEFAULT_VAL; + return 0; }