From patchwork Wed Mar 26 10:22:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 3892561 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A06FFBF540 for ; Wed, 26 Mar 2014 10:24:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C510A2017B for ; Wed, 26 Mar 2014 10:24:23 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9881120170 for ; Wed, 26 Mar 2014 10:24:22 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B7846265251; Wed, 26 Mar 2014 11:24:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 786AB26517E; Wed, 26 Mar 2014 11:23:19 +0100 (CET) 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 1AB3D26516D; Wed, 26 Mar 2014 11:23:16 +0100 (CET) Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) by alsa0.perex.cz (Postfix) with ESMTP id 7DE2426513E for ; Wed, 26 Mar 2014 11:23:08 +0100 (CET) Received: by mail-bk0-f53.google.com with SMTP id r7so443751bkg.26 for ; Wed, 26 Mar 2014 03:23: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:in-reply-to:references; bh=sT0deZdrCK9yss+TJb/kngzBwpcsvwpGIak9AWIuo7Y=; b=Co0fwiTP1WO0eFhKmTo83D0QENUipE5Ved+4y6j8zPa28kSTljla7tZF/JxBFUtSuf oiqDQJttxY9pQx12ml2UJ8XXl2thTUb2qqfwOMMucZkF4xfmIwv/a9K6Ut4GW2E0AaMR PpVPd4D3q4z89Y4IqrhrzcmCIMbmsbBtgf9IEP2srFfoGBac2Q/gQ+ms3Du3K2SMAz/S 0n5jGILvJwOJ9PmsnXnaNXnf/gjwF2Ryp4mEweJZxmupDo71MFTNvB5J8GC67sJwuTun zvi2JfFOzLQB0ZY5ihbYrQzdRsb0xe/EEB4Cp6y9Fe9Rr2dVvQvF3Ar7u6R0KmW7Jewp oltQ== X-Received: by 10.204.197.202 with SMTP id el10mr43667638bkb.24.1395829388171; Wed, 26 Mar 2014 03:23:08 -0700 (PDT) Received: from tamtam.Speedport_W_723V_1_32_000 (pd907dbf4.dip0.t-ipconnect.de. [217.7.219.244]) by mx.google.com with ESMTPSA id bh9sm22273657bkb.16.2014.03.26.03.23.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Mar 2014 03:23:07 -0700 (PDT) From: Daniel Mack To: broonie@kernel.org Date: Wed, 26 Mar 2014 11:22:58 +0100 Message-Id: <1395829378-13055-3-git-send-email-zonque@gmail.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1395829378-13055-1-git-send-email-zonque@gmail.com> References: <1395829378-13055-1-git-send-email-zonque@gmail.com> Cc: alsa-devel@alsa-project.org, Daniel Mack Subject: [alsa-devel] [PATCH 3/3] ASoC: tas5086: add regulator consumer support 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 TAS5086 has two power domains, DVDD and AVDD. Add support for regulators to the TAS5086 codec driver. Signed-off-by: Daniel Mack --- sound/soc/codecs/tas5086.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index a895a5e..e87a577 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -240,6 +241,10 @@ static int tas5086_reg_read(void *context, unsigned int reg, return 0; } +static const char *supply_names[] = { + "dvdd", "avdd" +}; + struct tas5086_private { struct regmap *regmap; unsigned int mclk, sclk; @@ -251,6 +256,7 @@ struct tas5086_private { int rate; /* GPIO driving Reset pin, if any */ int gpio_nreset; + struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; }; static int tas5086_deemph[] = { 0, 32000, 44100, 48000 }; @@ -773,6 +779,8 @@ static int tas5086_soc_suspend(struct snd_soc_codec *codec) if (ret < 0) return ret; + regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); + return 0; } @@ -781,6 +789,10 @@ static int tas5086_soc_resume(struct snd_soc_codec *codec) struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); + if (ret < 0) + return ret; + tas5086_reset(priv); regcache_mark_dirty(priv->regmap); @@ -812,6 +824,12 @@ static int tas5086_probe(struct snd_soc_codec *codec) struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); int i, ret; + ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); + if (ret < 0) { + dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); + return ret; + } + priv->pwm_start_mid_z = 0; priv->charge_period = 1300000; /* hardware default is 1300 ms */ @@ -834,14 +852,19 @@ static int tas5086_probe(struct snd_soc_codec *codec) ret = tas5086_init(codec->dev, priv); if (ret < 0) - return ret; + goto exit_disable_regulators; /* set master volume to 0 dB */ ret = regmap_write(priv->regmap, TAS5086_MASTER_VOL, 0x30); if (ret < 0) - return ret; + goto exit_disable_regulators; return 0; + +exit_disable_regulators: + regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); + + return ret; } static int tas5086_remove(struct snd_soc_codec *codec) @@ -852,6 +875,8 @@ static int tas5086_remove(struct snd_soc_codec *codec) /* Set codec to the reset state */ gpio_set_value(priv->gpio_nreset, 0); + regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); + return 0; }; @@ -900,6 +925,16 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, if (!priv) return -ENOMEM; + for (i = 0; i < ARRAY_SIZE(supply_names); i++) + priv->supplies[i].supply = supply_names[i]; + + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(priv->supplies), + priv->supplies); + if (ret < 0) { + dev_err(dev, "Failed to get regulators: %d\n", ret); + return ret; + } + priv->regmap = devm_regmap_init(dev, NULL, i2c, &tas5086_regmap); if (IS_ERR(priv->regmap)) { ret = PTR_ERR(priv->regmap);