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: 9864069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D353D6038F for ; Wed, 26 Jul 2017 00:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C22F0286FE for ; Wed, 26 Jul 2017 00:36:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B719D28726; Wed, 26 Jul 2017 00:36:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E93DC286FE for ; Wed, 26 Jul 2017 00:36:46 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A0A6F26739C; Wed, 26 Jul 2017 02:35:41 +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 DD59F267398; Wed, 26 Jul 2017 02:35:37 +0200 (CEST) Received: from mail-io0-f174.google.com (mail-io0-f174.google.com [209.85.223.174]) by alsa0.perex.cz (Postfix) with ESMTP id C059F267354 for ; Wed, 26 Jul 2017 02:35:32 +0200 (CEST) Received: by mail-io0-f174.google.com with SMTP id g35so29488322ioi.3 for ; Tue, 25 Jul 2017 17:35:32 -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=NQuNezb47p4cKWlytRHmLzU3l8X40v0lP555QcMVwSmhxHKqQXVYfH1hLRUoYZi3Gw oqn/QFtghgiDi+Xc8WKrlc3o7qRQDH48QHe+5tKmlPIOLvP87vErizq4Mf72qJxfsvfx zkHY0MNy6vvmK3yIC89t6KNB43pi7mHlKlDUk+qs+c99qRYBN0aM/F41GSePiTVZG+p/ yvJ7MorwJ1fjgcw3yuul9HY6GoiNNED611xX9VGK0sGu1U6VA25D6TQUr9DuyP9v9YSP JtxwFKlonhxbOHenOUIaoGmYOcd5YISDS14rx6euSeXtXn5R6ACPVxCBY5m1c7l+bEDa NK4Q== X-Gm-Message-State: AIVw112NCLzi314RKkSwqvHGIMTOVpUdHN4G87bsQe93+nNrqQBOeqr6 cfGsmS3x5vs6iiEx 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 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> Cc: linux-kernel@vger.kernel.org, Patrick Lai , Srinivas Kandagatla , Takashi Iwai Subject: [alsa-devel] [PATCH v1 4/6] ASoC: codecs: msm8916-wcd-analog: set default micbias voltage to 1.8 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 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(-) 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; }