From patchwork Wed Mar 26 10:22:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 3892541 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 BCE66BF540 for ; Wed, 26 Mar 2014 10:23:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE2AC2022A for ; Wed, 26 Mar 2014 10:23:28 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C7EF920221 for ; Wed, 26 Mar 2014 10:23:27 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id F18382651B2; Wed, 26 Mar 2014 11:23:25 +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 C240E265130; Wed, 26 Mar 2014 11:23:14 +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 E3B24265150; Wed, 26 Mar 2014 11:23:12 +0100 (CET) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by alsa0.perex.cz (Postfix) with ESMTP id ED36C265130 for ; Wed, 26 Mar 2014 11:23:05 +0100 (CET) Received: by mail-bk0-f54.google.com with SMTP id 6so453035bkj.13 for ; Wed, 26 Mar 2014 03:23:05 -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=4+RLLZLMNijLJU6xrpGg8UiJG1YMcZcReV67VIar/+A=; b=pAfq8ocKVz7NWzGqb/pZmpAq53MZbJL2AefUrd6JXEA60UYoKHuL0kaoOGeazTVQPQ 56zthJvfyei4W32p2kXzI/RIHwkl2HnoOsByVcXt8L5ILSA5X2BsFPwgqjyD/m/BfoTb 30pbaMLWRMPjBh8Ual1epAQ+e10Vn00WVYotfO5EIYzKVt9Q0tbYBk4OsTtvccJ3lQbC hHh8cTejQy1RZEGAjmSap9bDWGI65e3HefB5abN1gLDkTGVen0xUck1KKLkyucaeWH0p 8KbRw7D9xOO3E7Ffvg+bq0TSMt87AHk2H46BfXfm4lrvhuIJBPnrqT1bO2TwyeBen+5G sIlg== X-Received: by 10.204.77.77 with SMTP id f13mr964317bkk.46.1395829385507; Wed, 26 Mar 2014 03:23:05 -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.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Mar 2014 03:23:04 -0700 (PDT) From: Daniel Mack To: broonie@kernel.org Date: Wed, 26 Mar 2014 11:22:56 +0100 Message-Id: <1395829378-13055-1-git-send-email-zonque@gmail.com> X-Mailer: git-send-email 1.8.5.3 Cc: alsa-devel@alsa-project.org, Daniel Mack Subject: [alsa-devel] [PATCH 1/3] ASoC: ak5386: 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 chip has two power supplies, VA and VDD. Register and enable them both. Signed-off-by: Daniel Mack --- sound/soc/codecs/ak5386.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/ak5386.c b/sound/soc/codecs/ak5386.c index 72e953b..99fb5db 100644 --- a/sound/soc/codecs/ak5386.c +++ b/sound/soc/codecs/ak5386.c @@ -14,12 +14,18 @@ #include #include #include +#include #include #include #include +static const char *supply_names[] = { + "va", "vd" +}; + struct ak5386_priv { int reset_gpio; + struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; }; static const struct snd_soc_dapm_widget ak5386_dapm_widgets[] = { @@ -122,6 +128,7 @@ static int ak5386_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct ak5386_priv *priv; + int ret, i; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -130,6 +137,19 @@ static int ak5386_probe(struct platform_device *pdev) priv->reset_gpio = -EINVAL; dev_set_drvdata(dev, priv); + 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) + return ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), + priv->supplies); + if (ret < 0) + return ret; + if (of_match_device(of_match_ptr(ak5386_dt_ids), dev)) priv->reset_gpio = of_get_named_gpio(dev->of_node, "reset-gpio", 0); @@ -140,13 +160,22 @@ static int ak5386_probe(struct platform_device *pdev) "AK5386 Reset")) priv->reset_gpio = -EINVAL; - return snd_soc_register_codec(dev, &soc_codec_ak5386, - &ak5386_dai, 1); + ret = snd_soc_register_codec(dev, &soc_codec_ak5386, + &ak5386_dai, 1); + if (ret < 0) + regulator_bulk_disable(ARRAY_SIZE(priv->supplies), + priv->supplies); + return ret; } static int ak5386_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); + struct device *dev = &pdev->dev; + struct ak5386_priv *priv = dev_get_drvdata(dev); + + snd_soc_unregister_codec(dev); + regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); + return 0; }