From patchwork Thu Oct 8 11:58:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 52503 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 n98C82v5007869 for ; Thu, 8 Oct 2009 12:08:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757854AbZJHMB1 (ORCPT ); Thu, 8 Oct 2009 08:01:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757940AbZJHMB1 (ORCPT ); Thu, 8 Oct 2009 08:01:27 -0400 Received: from smtp.nokia.com ([192.100.122.230]:55113 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757854AbZJHMBU (ORCPT ); Thu, 8 Oct 2009 08:01:20 -0400 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n98BxkxV031545; Thu, 8 Oct 2009 14:59:48 +0300 Received: from vaebh102.NOE.Nokia.com ([10.160.244.23]) by vaebh105.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 vaebh102.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 8/8] ASoC: tpa6130a2: Control vdd using regulator framework Date: Thu, 8 Oct 2009 14:58:57 +0300 Message-Id: <1255003137-1034-9-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.0964 (UTC) FILETIME=[C96DD1C0: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/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index d246aad..35720ce 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ struct tpa6130a2_data { unsigned char regs[TPA6130A2_CACHEREGNUM]; unsigned char power_state; int (*set_power)(int state); + struct regulator *regulator; }; static int tpa6130a2_i2c_read(int reg) @@ -121,6 +123,8 @@ void tpa6130a2_power(int power) mutex_lock(&data->mutex); if (power) { + if (data->regulator) + regulator_enable(data->regulator); /* Power on */ if (data->set_power) { data->set_power(1); @@ -141,6 +145,8 @@ void tpa6130a2_power(int power) data->set_power(0); data->power_state = 0; } + if (data->regulator) + regulator_disable(data->regulator); } mutex_unlock(&data->mutex); } @@ -292,6 +298,12 @@ static int tpa6130a2_probe(struct i2c_client *client, } pdata = (struct tpa6130a2_platform_data *)client->dev.platform_data; + data->regulator = regulator_get(dev, "vdd"); + if (IS_ERR(data->regulator)) { + dev_info(dev, "Could not get regulator for vdd. " + "Executing without regulator.\n"); + data->regulator = NULL; + } /* Set default register values */ data->regs[TPA6130A2_REG_CONTROL] = TPA6130A2_SWS | TPA6130A2_HP_EN_R | @@ -326,6 +338,8 @@ static int tpa6130a2_probe(struct i2c_client *client, return 0; fail3: tpa6130a2_power(0); + if (data->regulator) + regulator_put(data->regulator); fail2: kfree(data); i2c_set_clientdata(tpa6130a2_client, NULL); @@ -340,6 +354,8 @@ static int tpa6130a2_remove(struct i2c_client *client) struct tpa6130a2_data *data = i2c_get_clientdata(client); tpa6130a2_power(0); + if (data->regulator) + regulator_put(data->regulator); kfree(data); tpa6130a2_client = 0;