From patchwork Tue Jun 21 23:50:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 638918 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rZ4GX0TKrz9t0X for ; Wed, 22 Jun 2016 09:50:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=V0iM+eSS; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751664AbcFUXuK (ORCPT ); Tue, 21 Jun 2016 19:50:10 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:35141 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750890AbcFUXuJ (ORCPT ); Tue, 21 Jun 2016 19:50:09 -0400 Received: by mail-pa0-f68.google.com with SMTP id hf6so2256910pac.2; Tue, 21 Jun 2016 16:50:08 -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=eJGkZ5BIy88zeVAvHtwLxivBWoCpYScs8EqVYmh02Dc=; b=V0iM+eSSVWf7HxDfYNmoZB9uz+u4r0Rz3Gk1yqRqhbsNbXZTiW4LgdE0VUeOgGR5aG RSu4Qb14VDCJAHGseRj8s3CvwsQa20RDoycJRvzAzNg3DaDsapw2+GWcFAVcd+tyRz62 pUwIln7iQvvzb7h+2M8ebLTqNCvFqESh28/tTD22J5uCxEmtjBj7L7XQ/F+RbQTk4a+x aQ5y7OXJdowJtf/5b2GLr+LBZJ89NZfwmwgVCkwnhvVkOTh2Wq0rtq0+AtoihTz7Gv4O NY1lx2Gdaah46DDXcsAJy/t2P0VOeMLSQLBiqCXrf9ATTXNb0hG/75WtRyzxbEI4MQXJ JiRA== 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=eJGkZ5BIy88zeVAvHtwLxivBWoCpYScs8EqVYmh02Dc=; b=kv/s7og1uPFtrwn+eB767aNhCJ8AqAWoJH+PElFICPBN/tRO+wbHB+EgMG5y2w6zHn omvWSu7kvKNH6TnG3LhxCZjALsVEG+RN26Rf98gwg6pLHctWSBIkIha4lwQIFQzcW/O4 IZnJ1nWtf2/NdkTPzPAhsOFuCtfol1ZR+Xp/lrgQzkLyl9g6xMLCr+WO/O6snRC8Lhrj MSRUtpBHxJZOhxr3RD5DwI8JM2GfO/nFeuFCTeubG2Ns3LLmXjqt5M/OG7lPq8HYuMet /LbIODMSUuzwFo/50NvURTBSY4sQ2bGE1LeCOfMh/+6j5qKyAi/S/xE6HliMT+cBT10g 26WA== X-Gm-Message-State: ALyK8tJG6bmtvfERZG5N39vSOKA4+RmPeyCyZkRZMliSB/8vgGBvxSqei3Em5ZAewMq60g== X-Received: by 10.66.149.99 with SMTP id tz3mr31548742pab.128.1466553007888; Tue, 21 Jun 2016 16:50:07 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id b67sm47169027pfg.85.2016.06.21.16.50.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Jun 2016 16:50:07 -0700 (PDT) From: Nicolin Chen To: broonie@kernel.org Cc: lgirdwood@gmail.com, brian.austin@cirrus.com, Paul.Handrigan@cirrus.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Subject: [PATCH v2] ASoC: cs53l30: Add MUTE pin control support via GPIO Date: Tue, 21 Jun 2016 16:50:13 -0700 Message-Id: <1466553013-15154-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 Acked-by: Paul Handrigan --- Changelog: v1->v2 * Revise the DT binding part regarding the active state of the mute pin .../devicetree/bindings/sound/cs53l30.txt | 4 +++ sound/soc/codecs/cs53l30.c | 30 ++++++++++++++++++++++ sound/soc/codecs/cs53l30.h | 1 + 3 files changed, 35 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/cs53l30.txt b/Documentation/devicetree/bindings/sound/cs53l30.txt index 18d6b99..4dbfb82 100644 --- a/Documentation/devicetree/bindings/sound/cs53l30.txt +++ b/Documentation/devicetree/bindings/sound/cs53l30.txt @@ -13,6 +13,10 @@ Optional properties: - reset-gpios : a GPIO spec for the reset pin. + - mute-gpios : a GPIO spec for the MUTE pin. The active state can be either + GPIO_ACTIVE_HIGH or GPIO_ACTIVE_LOW, which would be handled + by the driver automatically. + - 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 384a3f7..e46b7de 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 = { @@ -990,6 +1002,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 */