From patchwork Tue Jun 21 01:54:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 9189171 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 D0D306075F for ; Tue, 21 Jun 2016 01:55:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB19A20748 for ; Tue, 21 Jun 2016 01:55:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD25127E78; Tue, 21 Jun 2016 01:55:25 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, 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 D974320748 for ; Tue, 21 Jun 2016 01:55:24 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 95A972667B1; Tue, 21 Jun 2016 03:55:23 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7516D2667C7; Tue, 21 Jun 2016 03:55:13 +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 E38942666AE; Tue, 21 Jun 2016 03:55:11 +0200 (CEST) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by alsa0.perex.cz (Postfix) with ESMTP id 5B81726666D for ; Tue, 21 Jun 2016 03:54:58 +0200 (CEST) Received: by mail-pf0-f196.google.com with SMTP id c74so175929pfb.0 for ; Mon, 20 Jun 2016 18:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ZFtYS1Ai4x0qBg6vT2Mie5DFqJoQHkJX0EKWu1Xp3Ig=; b=BZBaRCrZt67oM1b9qL3g/F96SzIV+EPtjxv3H7p+W249EfmgH8biEwn6EuWwQbZ3W4 QHBifWZrenPBHcv7V/2prAY8pODhatAnCgymqS1pLinDuLzUb0BCzzLdaTMiUCrkxKsX oq7VX1WoEt1qlgEQPHLe59Hqke2vh+j9GTQxIotttfx4AQFORvGRRstR34K2DnkPHRS8 C30aVBymP+87Hvx4nZmILC570DKqOxD9r/aATHJxHqOpwgnh0GrxwLo6sJYVxqH3A3QN uKxI9gq6BN1CnsyadNRCB/qtSr5UiQz3/Yu91llOEGxKoLXTK697eWcVyIMpv/Ix2W54 Y1QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZFtYS1Ai4x0qBg6vT2Mie5DFqJoQHkJX0EKWu1Xp3Ig=; b=DHnaq6Mdf0UCp8Y3EL1QOeyerpoxHqtsSmNR/qqBRaqSV+MruQhGHnI34cEFv3MzvO YCtH49tX5orCAwueaaT1xRC2ak5V5ygBBrnkFB11Aj/zMEPLncsppdSKGjXJlS9Ty8K0 8sCBVmZQ6mqv0oxwk7wPjt8Mqemn9xiz/wlbBwhAMS2Y5awMCIO+JZxirf2DIJM+zceU jjA08ZXjj33hn9PqOxYB8OuxbbbeQQ3vXAvHiJrxIvApz20sqViuGnwc3BMRqKkES5we phdt9qGTUCDeRQRBJXyyZ7+AKu074UX95fckYRD7PcBaHay+t412QVHD/4bScTSTZnmT sOMg== X-Gm-Message-State: ALyK8tL6amQexFb4C3vcrGvff5x/+UrLf7j5glt2abgOgWkzKFYgY68Q53EHntD7fnFisQ== X-Received: by 10.98.149.149 with SMTP id c21mr25229175pfk.73.1466474097269; Mon, 20 Jun 2016 18:54:57 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id pk18sm60059143pab.27.2016.06.20.18.54.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jun 2016 18:54:56 -0700 (PDT) From: Nicolin Chen To: broonie@kernel.org Date: Mon, 20 Jun 2016 18:54:44 -0700 Message-Id: <1466474084-6775-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, brian.austin@cirrus.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Paul.Handrigan@cirrus.com, lgirdwood@gmail.com, robh+dt@kernel.org Subject: [alsa-devel] [PATCH] ASoC: cs53l30: Add MUTE pin control support via GPIO 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 The codec chip has a physical MUTE pin to let users control it via GPIO. So this patch add a mute control support to the driver. Signed-off-by: Nicolin Chen --- .../devicetree/bindings/sound/cs53l30.txt | 2 ++ sound/soc/codecs/cs53l30.c | 30 ++++++++++++++++++++++ sound/soc/codecs/cs53l30.h | 1 + 3 files changed, 33 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/cs53l30.txt b/Documentation/devicetree/bindings/sound/cs53l30.txt index 18d6b99..6f7d3c8 100644 --- a/Documentation/devicetree/bindings/sound/cs53l30.txt +++ b/Documentation/devicetree/bindings/sound/cs53l30.txt @@ -13,6 +13,8 @@ Optional properties: - reset-gpios : a GPIO spec for the reset pin. + - mute-gpios : a GPIO spec for the MUTE pin. + - cirrus,micbias-lvl : Set the output voltage level on the MICBIAS Pin. 0 = Hi-Z 1 = 1.80 V diff --git a/sound/soc/codecs/cs53l30.c b/sound/soc/codecs/cs53l30.c index b0a64a1..5988b5c 100644 --- a/sound/soc/codecs/cs53l30.c +++ b/sound/soc/codecs/cs53l30.c @@ -35,6 +35,7 @@ struct cs53l30_private { struct regulator_bulk_data supplies[CS53L30_NUM_SUPPLIES]; struct regmap *regmap; struct gpio_desc *reset_gpio; + struct gpio_desc *mute_gpio; struct clk *mclk; bool use_sdout2; u32 mclk_rate; @@ -833,6 +834,16 @@ static int cs53l30_set_dai_tdm_slot(struct snd_soc_dai *dai, return 0; } +static int cs53l30_mute_stream(struct snd_soc_dai *dai, int mute, int stream) +{ + struct cs53l30_private *priv = snd_soc_codec_get_drvdata(dai->codec); + + if (priv->mute_gpio) + gpiod_set_value_cansleep(priv->mute_gpio, mute); + + return 0; +} + /* SNDRV_PCM_RATE_KNOT -> 12000, 24000 Hz, limit with constraint list */ #define CS53L30_RATES (SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT) @@ -846,6 +857,7 @@ static const struct snd_soc_dai_ops cs53l30_ops = { .set_sysclk = cs53l30_set_sysclk, .set_tristate = cs53l30_set_tristate, .set_tdm_slot = cs53l30_set_dai_tdm_slot, + .mute_stream = cs53l30_mute_stream, }; static struct snd_soc_dai_driver cs53l30_dai = { @@ -991,6 +1003,24 @@ static int cs53l30_i2c_probe(struct i2c_client *client, cs53l30->mclk = NULL; } + /* Fetch the MUTE control */ + cs53l30->mute_gpio = devm_gpiod_get_optional(dev, "mute", + GPIOD_OUT_HIGH); + if (IS_ERR(cs53l30->mute_gpio)) { + ret = PTR_ERR(cs53l30->mute_gpio); + goto error; + } + + if (cs53l30->mute_gpio) { + /* Enable MUTE controls via MUTE pin */ + regmap_write(cs53l30->regmap, CS53L30_MUTEP_CTL1, + CS53L30_MUTEP_CTL1_MUTEALL); + /* Flip the polarity of MUTE pin */ + if (gpiod_is_active_low(cs53l30->mute_gpio)) + regmap_update_bits(cs53l30->regmap, CS53L30_MUTEP_CTL2, + CS53L30_MUTE_PIN_POLARITY, 0); + } + if (!of_property_read_u8(np, "cirrus,micbias-lvl", &val)) regmap_update_bits(cs53l30->regmap, CS53L30_MICBIAS_CTL, CS53L30_MIC_BIAS_CTRL_MASK, val); diff --git a/sound/soc/codecs/cs53l30.h b/sound/soc/codecs/cs53l30.h index 0dd4afb..5e39da5 100644 --- a/sound/soc/codecs/cs53l30.h +++ b/sound/soc/codecs/cs53l30.h @@ -253,6 +253,7 @@ #define CS53L30_MUTE_MB_ALL_PDN_MASK (1 << CS53L30_MUTE_MB_ALL_PDN_SHIFT) #define CS53L30_MUTE_MB_ALL_PDN (1 << CS53L30_MUTE_MB_ALL_PDN_SHIFT) +#define CS53L30_MUTEP_CTL1_MUTEALL (0xdf) #define CS53L30_MUTEP_CTL1_DEFAULT (0) /* R32 (0x20) CS53L30_MUTEP_CTL2 - MUTE Pin Control 2 */