From patchwork Wed Mar 26 10:22:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 3892551 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 85ED5BF540 for ; Wed, 26 Mar 2014 10:23:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4F532022F for ; Wed, 26 Mar 2014 10:23:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 8876520222 for ; Wed, 26 Mar 2014 10:23:48 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9F6FE2651EA; Wed, 26 Mar 2014 11:23:47 +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 93F4826516A; Wed, 26 Mar 2014 11:23:18 +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 479C7265130; Wed, 26 Mar 2014 11:23:14 +0100 (CET) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by alsa0.perex.cz (Postfix) with ESMTP id 52F53265134 for ; Wed, 26 Mar 2014 11:23:07 +0100 (CET) Received: by mail-bk0-f52.google.com with SMTP id my13so446182bkb.25 for ; Wed, 26 Mar 2014 03:23:07 -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=vAKVJV5YkEU7Vw8/Pct3K8afffdngnkPTLxzENJd7Pg=; b=HUeiuXaTjMJr8AxpgPePulIBhmZ7g8Qe2Pcq4rq+Pd1Ezvt9AEyiWWJCP4bXfQb49p IEv62U/pcK8jl5HyQp9JEc9+GughDtp/I4gQf50XyuamziPo57ed/UqbQ701bBi34U1m Ewb34ACIRDKVJZTfEqCUYAfW9Bq2Pw8jzCQOA80Q25+s30eDP1VyXCuvKTvRM5g6wYu/ LZDKmSm+Hoq/bfbyOG1reR7tUAR77ZorqGm/khgohxYhpjTh1nCM/EbhCbOUfHlaHHAJ B38cYrq3qRPTkN+/qHqLe7M1woGRJUwjOIREEmev349oP2OsW3YwqrCcNpEa1ryc1Jzp 7AEw== X-Received: by 10.204.168.17 with SMTP id s17mr2298759bky.5.1395829386960; Wed, 26 Mar 2014 03:23:06 -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.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Mar 2014 03:23:06 -0700 (PDT) From: Daniel Mack To: broonie@kernel.org Date: Wed, 26 Mar 2014 11:22:57 +0100 Message-Id: <1395829378-13055-2-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 2/3] ASoC: ak4104: 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 AK4104 has only one power supply, called VDD. Make sure it is enabled during the life-time of the module. Signed-off-by: Daniel Mack --- sound/soc/codecs/ak4104.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c index b4819dc..c7a541d 100644 --- a/sound/soc/codecs/ak4104.c +++ b/sound/soc/codecs/ak4104.c @@ -11,13 +11,14 @@ #include #include -#include -#include -#include #include #include #include +#include #include +#include +#include +#include /* AK4104 registers addresses */ #define AK4104_REG_CONTROL1 0x00 @@ -47,6 +48,7 @@ struct ak4104_private { struct regmap *regmap; + struct regulator *regulator; }; static const struct snd_soc_dapm_widget ak4104_dapm_widgets[] = { @@ -176,20 +178,30 @@ static int ak4104_probe(struct snd_soc_codec *codec) codec->control_data = ak4104->regmap; + ret = regulator_enable(ak4104->regulator); + if (ret < 0) { + dev_err(codec->dev, "Unable to enable regulator: %d\n", ret); + return ret; + } + /* set power-up and non-reset bits */ ret = regmap_update_bits(ak4104->regmap, AK4104_REG_CONTROL1, AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN, AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN); if (ret < 0) - return ret; + goto exit_disable_regulator; /* enable transmitter */ ret = regmap_update_bits(ak4104->regmap, AK4104_REG_TX, AK4104_TX_TXE, AK4104_TX_TXE); if (ret < 0) - return ret; + goto exit_disable_regulator; return 0; + +exit_disable_regulator: + regulator_disable(ak4104->regulator); + return ret; } static int ak4104_remove(struct snd_soc_codec *codec) @@ -198,6 +210,7 @@ static int ak4104_remove(struct snd_soc_codec *codec) regmap_update_bits(ak4104->regmap, AK4104_REG_CONTROL1, AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN, 0); + regulator_disable(ak4104->regulator); return 0; } @@ -241,6 +254,13 @@ static int ak4104_spi_probe(struct spi_device *spi) if (ak4104 == NULL) return -ENOMEM; + ak4104->regulator = devm_regulator_get(&spi->dev, "vdd"); + if (IS_ERR(ak4104->regulator)) { + ret = PTR_ERR(ak4104->regulator); + dev_err(&spi->dev, "Unable to get Vdd regulator: %d\n", ret); + return ret; + } + ak4104->regmap = devm_regmap_init_spi(spi, &ak4104_regmap); if (IS_ERR(ak4104->regmap)) { ret = PTR_ERR(ak4104->regmap);