summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorericz <ericz@nvidia.com>2014-01-15 18:42:31 +0800
committerGabby Lee <galee@nvidia.com>2014-02-13 21:36:19 -0800
commitcdf501907bfdb241d4010d5ba01eccf7ed3f65df (patch)
tree3fccbbb4a1c6f31e5f6385efae8ff09b99999cd8 /sound
parentcc61a14a09490692b7265b4adbbaaeeea2988f96 (diff)
tegra:fairfax: Enable TI AMP for headset
Bug: 1430485 Change-Id: Idc2fca3edcc7205ac9e80e9a8f419920b818b1a7 Signed-off-by: ericz <ericz@nvidia.com> Reviewed-on: http://git-master/r/360343 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Simon Je <sje@nvidia.com> Reviewed-by: Gabby Lee <galee@nvidia.com> Tested-by: Gabby Lee <galee@nvidia.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/tpa6130a2.c56
-rw-r--r--sound/soc/codecs/tpa6130a2.h2
-rw-r--r--sound/soc/tegra/Kconfig10
-rw-r--r--sound/soc/tegra/tegra_rt5640.c15
4 files changed, 32 insertions, 51 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 6fe4aa3ac544..e156507612c5 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -2,6 +2,7 @@
* ALSA SoC Texas Instruments TPA6130A2 headset stereo amplifier driver
*
* Copyright (C) Nokia Corporation
+ * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
*
* Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
*
@@ -44,8 +45,6 @@ static struct i2c_client *tpa6130a2_client;
struct tpa6130a2_data {
struct mutex mutex;
unsigned char regs[TPA6130A2_CACHEREGNUM];
- struct regulator *supply;
- int power_gpio;
u8 power_state:1;
enum tpa_model id;
};
@@ -121,13 +120,14 @@ static int tpa6130a2_initialize(void)
return ret;
}
-static int tpa6130a2_power(u8 power)
+int tpa6130a2_power(u8 power)
{
struct tpa6130a2_data *data;
u8 val;
int ret = 0;
- BUG_ON(tpa6130a2_client == NULL);
+ if (tpa6130a2_client == NULL)
+ return -1;
data = i2c_get_clientdata(tpa6130a2_client);
mutex_lock(&data->mutex);
@@ -135,24 +135,12 @@ static int tpa6130a2_power(u8 power)
goto exit;
if (power) {
- ret = regulator_enable(data->supply);
- if (ret != 0) {
- dev_err(&tpa6130a2_client->dev,
- "Failed to enable supply: %d\n", ret);
- goto exit;
- }
/* Power on */
- if (data->power_gpio >= 0)
- gpio_set_value(data->power_gpio, 1);
-
data->power_state = 1;
ret = tpa6130a2_initialize();
if (ret < 0) {
dev_err(&tpa6130a2_client->dev,
"Failed to initialize chip\n");
- if (data->power_gpio >= 0)
- gpio_set_value(data->power_gpio, 0);
- regulator_disable(data->supply);
data->power_state = 0;
goto exit;
}
@@ -162,11 +150,6 @@ static int tpa6130a2_power(u8 power)
val |= TPA6130A2_SWS;
tpa6130a2_i2c_write(TPA6130A2_REG_CONTROL, val);
- /* Power off */
- if (data->power_gpio >= 0)
- gpio_set_value(data->power_gpio, 0);
-
- ret = regulator_disable(data->supply);
if (ret != 0) {
dev_err(&tpa6130a2_client->dev,
"Failed to disable supply: %d\n", ret);
@@ -180,6 +163,7 @@ exit:
mutex_unlock(&data->mutex);
return ret;
}
+EXPORT_SYMBOL_GPL(tpa6130a2_power);
static int tpa6130a2_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
@@ -325,6 +309,8 @@ static void tpa6130a2_channel_enable(u8 channel, int enable)
int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable)
{
int ret = 0;
+ if (tpa6130a2_client == NULL)
+ return -1;
if (enable) {
ret = tpa6130a2_power(1);
if (ret < 0)
@@ -387,7 +373,6 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
i2c_set_clientdata(tpa6130a2_client, data);
pdata = client->dev.platform_data;
- data->power_gpio = pdata->power_gpio;
data->id = id->driver_data;
mutex_init(&data->mutex);
@@ -397,16 +382,6 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
data->regs[TPA6130A2_REG_VOL_MUTE] = TPA6130A2_MUTE_R |
TPA6130A2_MUTE_L;
- if (data->power_gpio >= 0) {
- ret = gpio_request(data->power_gpio, "tpa6130a2 enable");
- if (ret < 0) {
- dev_err(dev, "Failed to request power GPIO (%d)\n",
- data->power_gpio);
- goto err_gpio;
- }
- gpio_direction_output(data->power_gpio, 0);
- }
-
switch (data->id) {
default:
dev_warn(dev, "Unknown TPA model (%d). Assuming 6130A2\n",
@@ -419,13 +394,6 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
break;
}
- data->supply = regulator_get(dev, regulator);
- if (IS_ERR(data->supply)) {
- ret = PTR_ERR(data->supply);
- dev_err(dev, "Failed to request supply: %d\n", ret);
- goto err_regulator;
- }
-
ret = tpa6130a2_power(1);
if (ret != 0)
goto err_power;
@@ -439,16 +407,10 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
/* Disable the chip */
ret = tpa6130a2_power(0);
- if (ret != 0)
- goto err_power;
return 0;
err_power:
- regulator_put(data->supply);
-err_regulator:
- if (data->power_gpio >= 0)
- gpio_free(data->power_gpio);
err_gpio:
tpa6130a2_client = NULL;
@@ -461,10 +423,6 @@ static int __devexit tpa6130a2_remove(struct i2c_client *client)
tpa6130a2_power(0);
- if (data->power_gpio >= 0)
- gpio_free(data->power_gpio);
-
- regulator_put(data->supply);
tpa6130a2_client = NULL;
return 0;
diff --git a/sound/soc/codecs/tpa6130a2.h b/sound/soc/codecs/tpa6130a2.h
index 417444020ba6..927db3df9fe4 100644
--- a/sound/soc/codecs/tpa6130a2.h
+++ b/sound/soc/codecs/tpa6130a2.h
@@ -2,6 +2,7 @@
* ALSA SoC TPA6130A2 amplifier driver
*
* Copyright (C) Nokia Corporation
+ * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
*
* Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
*
@@ -58,5 +59,6 @@
extern int tpa6130a2_add_controls(struct snd_soc_codec *codec);
extern int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable);
+extern int tpa6130a2_power(u8 power);
#endif /* __TPA6130A2_H__ */
diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index 434856557c52..e272ebae2bff 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -216,6 +216,16 @@ config SND_SOC_TEGRA_RT5640
boards using the ALC5640 codec. Currently, the supported boards
are Kai,Cardhu,Dalmore and Macallan.
+config SND_SOC_TI_TPA6130A2
+ tristate "SoC Audio support for Tegra boards using a TPA6130A2 amp"
+ bool "Enable system DMA driver for NVIDIA Tegra SoCs"
+ select SND_SOC_TPA6130A2
+ help
+ Enable support for the
+ Tegra PWM controller(s).
+ This item is just
+ used for project with TPA6130A2.
+
config MACH_HAS_SND_SOC_TEGRA_MAX98095
bool
help
diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c
index 8c4eaaf1f55c..a91e3a86149f 100644
--- a/sound/soc/tegra/tegra_rt5640.c
+++ b/sound/soc/tegra/tegra_rt5640.c
@@ -50,6 +50,9 @@
#include <sound/soc.h>
#include "../codecs/rt5639.h"
#include "../codecs/rt5640.h"
+#ifdef CONFIG_SND_SOC_TI_TPA6130A2
+#include "../codecs/tpa6130a2.h"
+#endif
#include "tegra_pcm.h"
#include "tegra_asoc_utils.h"
@@ -1366,7 +1369,14 @@ static int tegra_rt5640_event_hp(struct snd_soc_dapm_widget *w,
struct snd_soc_card *card = dapm->card;
struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card);
struct tegra_asoc_platform_data *pdata = machine->pdata;
+#ifdef CONFIG_SND_SOC_TI_TPA6130A2
+ struct snd_soc_codec *codec = card->rtd[DAI_LINK_HIFI].codec;
+ if (SND_SOC_DAPM_EVENT_ON(event))
+ tpa6130a2_stereo_enable(codec, 1);
+ else
+ tpa6130a2_stereo_enable(codec, 0);
+#endif
if (!(machine->gpio_requested & GPIO_HP_MUTE))
return 0;
@@ -1909,7 +1919,6 @@ static __devinit int tegra_rt5640_driver_probe(struct platform_device *pdev)
}
#endif
-
if (!pdata->edp_support)
return 0;
@@ -1957,7 +1966,9 @@ static __devinit int tegra_rt5640_driver_probe(struct platform_device *pdev)
machine->spk_edp_client = NULL;
}
}
-
+#ifdef CONFIG_SND_SOC_TI_TPA6130A2
+ tpa6130a2_add_controls(card->rtd[DAI_LINK_HIFI].codec);
+#endif
return 0;
err_unregister_card: