From patchwork Thu Oct 8 11:58:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 52500 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n98C1Qbp007026 for ; Thu, 8 Oct 2009 12:01:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757759AbZJHMBM (ORCPT ); Thu, 8 Oct 2009 08:01:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757665AbZJHMBK (ORCPT ); Thu, 8 Oct 2009 08:01:10 -0400 Received: from smtp.nokia.com ([192.100.122.233]:45208 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757712AbZJHMBG (ORCPT ); Thu, 8 Oct 2009 08:01:06 -0400 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n98BxY5s014365; Thu, 8 Oct 2009 14:59:34 +0300 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Oct 2009 14:59:29 +0300 Received: from vaebe101.NOE.Nokia.com ([10.160.244.11]) by vaebh104.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Oct 2009 14:59:28 +0300 Received: from localhost.localdomain ([172.21.40.103]) by vaebe101.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Oct 2009 14:59:27 +0300 From: Eduardo Valentin To: Mark Brown , ext Tony Lindgren Cc: "Ujfalusi Peter (Nokia-D/Tampere)" , "Nurkkala Eero.An (EXT-Offcode/Oulu)" , Jarkko Nikula , Linux-OMAP , ALSA-Devel , Eduardo Valentin Subject: [PATCH 7/8] ASoC: tlv320aic3x: add initial usage of regulator framework to control avdd_dac Date: Thu, 8 Oct 2009 14:58:56 +0300 Message-Id: <1255003137-1034-8-git-send-email-eduardo.valentin@nokia.com> X-Mailer: git-send-email 1.6.4.183.g04423 In-Reply-To: <1255003137-1034-1-git-send-email-eduardo.valentin@nokia.com> References: <1255003137-1034-1-git-send-email-eduardo.valentin@nokia.com> X-OriginalArrivalTime: 08 Oct 2009 11:59:27.0933 (UTC) FILETIME=[C96916D0:01CA480E] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 3395cf9..82e0a64 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,7 @@ struct aic3x_priv { struct snd_soc_codec codec; unsigned int sysclk; int master; + struct regulator *regulator; }; /* @@ -1286,6 +1288,11 @@ static int aic3x_unregister(struct aic3x_priv *aic3x) snd_soc_unregister_dai(&aic3x_dai); snd_soc_unregister_codec(&aic3x->codec); + if (aic3x->regulator) { + regulator_disable(aic3x->regulator); + regulator_put(aic3x->regulator); + } + kfree(aic3x); aic3x_codec = NULL; @@ -1320,6 +1327,25 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, codec->control_data = i2c; codec->hw_write = (hw_write_t) i2c_master_send; + aic3x->regulator = regulator_get(&i2c->dev, "avdd_dac"); + if (IS_ERR(aic3x->regulator)) { + dev_warn(&i2c->dev, "No regulator to supply avdd_dac." + " Assuming always on.\n"); + aic3x->regulator = NULL; + } + + /* + * REVISIT: Need to add proper code to put into sleep mode + * avdd_dac regulator. For now, just leave it on. + */ + if (aic3x->regulator) { + int err; + + err = regulator_enable(aic3x->regulator); + if (err < 0) + return err; + } + i2c_set_clientdata(i2c, aic3x); return aic3x_register(codec);