summaryrefslogtreecommitdiff
path: root/sound/soc/ti/omap3pandora.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/ti/omap3pandora.c')
-rw-r--r--sound/soc/ti/omap3pandora.c109
1 files changed, 47 insertions, 62 deletions
diff --git a/sound/soc/ti/omap3pandora.c b/sound/soc/ti/omap3pandora.c
index a287e9747c2a..f11b1d8a1306 100644
--- a/sound/soc/ti/omap3pandora.c
+++ b/sound/soc/ti/omap3pandora.c
@@ -7,7 +7,7 @@
#include <linux/clk.h>
#include <linux/platform_device.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/delay.h>
#include <linux/regulator/consumer.h>
#include <linux/module.h>
@@ -21,19 +21,18 @@
#include "omap-mcbsp.h"
-#define OMAP3_PANDORA_DAC_POWER_GPIO 118
-#define OMAP3_PANDORA_AMP_POWER_GPIO 14
-
#define PREFIX "ASoC omap3pandora: "
static struct regulator *omap3pandora_dac_reg;
+static struct gpio_desc *dac_power_gpio;
+static struct gpio_desc *amp_power_gpio;
static int omap3pandora_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
- struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
- struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
+ struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
+ struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
int ret;
/* Set the codec system clock for DAC and ADC */
@@ -72,15 +71,17 @@ static int omap3pandora_dac_event(struct snd_soc_dapm_widget *w,
* VCC power on/off and /PD pin high/low
*/
if (SND_SOC_DAPM_EVENT_ON(event)) {
+ struct device *dev = snd_soc_dapm_to_dev(w->dapm);
+
ret = regulator_enable(omap3pandora_dac_reg);
if (ret) {
- dev_err(w->dapm->dev, "Failed to power DAC: %d\n", ret);
+ dev_err(dev, "Failed to power DAC: %d\n", ret);
return ret;
}
mdelay(1);
- gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 1);
+ gpiod_set_value(dac_power_gpio, 1);
} else {
- gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 0);
+ gpiod_set_value(dac_power_gpio, 0);
mdelay(1);
regulator_disable(omap3pandora_dac_reg);
}
@@ -92,9 +93,9 @@ static int omap3pandora_hp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{
if (SND_SOC_DAPM_EVENT_ON(event))
- gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 1);
+ gpiod_set_value(amp_power_gpio, 1);
else
- gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 0);
+ gpiod_set_value(amp_power_gpio, 0);
return 0;
}
@@ -140,32 +141,32 @@ static const struct snd_soc_dapm_route omap3pandora_map[] = {
static int omap3pandora_out_init(struct snd_soc_pcm_runtime *rtd)
{
- struct snd_soc_dapm_context *dapm = &rtd->card->dapm;
+ struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(rtd->card);
/* All TWL4030 output pins are floating */
- snd_soc_dapm_nc_pin(dapm, "EARPIECE");
- snd_soc_dapm_nc_pin(dapm, "PREDRIVEL");
- snd_soc_dapm_nc_pin(dapm, "PREDRIVER");
- snd_soc_dapm_nc_pin(dapm, "HSOL");
- snd_soc_dapm_nc_pin(dapm, "HSOR");
- snd_soc_dapm_nc_pin(dapm, "CARKITL");
- snd_soc_dapm_nc_pin(dapm, "CARKITR");
- snd_soc_dapm_nc_pin(dapm, "HFL");
- snd_soc_dapm_nc_pin(dapm, "HFR");
- snd_soc_dapm_nc_pin(dapm, "VIBRA");
+ snd_soc_dapm_disable_pin(dapm, "EARPIECE");
+ snd_soc_dapm_disable_pin(dapm, "PREDRIVEL");
+ snd_soc_dapm_disable_pin(dapm, "PREDRIVER");
+ snd_soc_dapm_disable_pin(dapm, "HSOL");
+ snd_soc_dapm_disable_pin(dapm, "HSOR");
+ snd_soc_dapm_disable_pin(dapm, "CARKITL");
+ snd_soc_dapm_disable_pin(dapm, "CARKITR");
+ snd_soc_dapm_disable_pin(dapm, "HFL");
+ snd_soc_dapm_disable_pin(dapm, "HFR");
+ snd_soc_dapm_disable_pin(dapm, "VIBRA");
return 0;
}
static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd)
{
- struct snd_soc_dapm_context *dapm = &rtd->card->dapm;
+ struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(rtd->card);
/* Not comnnected */
- snd_soc_dapm_nc_pin(dapm, "HSMIC");
- snd_soc_dapm_nc_pin(dapm, "CARKITMIC");
- snd_soc_dapm_nc_pin(dapm, "DIGIMIC0");
- snd_soc_dapm_nc_pin(dapm, "DIGIMIC1");
+ snd_soc_dapm_disable_pin(dapm, "HSMIC");
+ snd_soc_dapm_disable_pin(dapm, "CARKITMIC");
+ snd_soc_dapm_disable_pin(dapm, "DIGIMIC0");
+ snd_soc_dapm_disable_pin(dapm, "DIGIMIC1");
return 0;
}
@@ -190,7 +191,7 @@ static struct snd_soc_dai_link omap3pandora_dai[] = {
.name = "PCM1773",
.stream_name = "HiFi Out",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
+ SND_SOC_DAIFMT_CBC_CFC,
.ops = &omap3pandora_ops,
.init = omap3pandora_out_init,
SND_SOC_DAILINK_REG(out),
@@ -198,7 +199,7 @@ static struct snd_soc_dai_link omap3pandora_dai[] = {
.name = "TWL4030",
.stream_name = "Line/Mic In",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
+ SND_SOC_DAIFMT_CBC_CFC,
.ops = &omap3pandora_ops,
.init = omap3pandora_in_init,
SND_SOC_DAILINK_REG(in),
@@ -229,35 +230,10 @@ static int __init omap3pandora_soc_init(void)
pr_info("OMAP3 Pandora SoC init\n");
- ret = gpio_request(OMAP3_PANDORA_DAC_POWER_GPIO, "dac_power");
- if (ret) {
- pr_err(PREFIX "Failed to get DAC power GPIO\n");
- return ret;
- }
-
- ret = gpio_direction_output(OMAP3_PANDORA_DAC_POWER_GPIO, 0);
- if (ret) {
- pr_err(PREFIX "Failed to set DAC power GPIO direction\n");
- goto fail0;
- }
-
- ret = gpio_request(OMAP3_PANDORA_AMP_POWER_GPIO, "amp_power");
- if (ret) {
- pr_err(PREFIX "Failed to get amp power GPIO\n");
- goto fail0;
- }
-
- ret = gpio_direction_output(OMAP3_PANDORA_AMP_POWER_GPIO, 0);
- if (ret) {
- pr_err(PREFIX "Failed to set amp power GPIO direction\n");
- goto fail1;
- }
-
omap3pandora_snd_device = platform_device_alloc("soc-audio", -1);
if (omap3pandora_snd_device == NULL) {
pr_err(PREFIX "Platform device allocation failed\n");
- ret = -ENOMEM;
- goto fail1;
+ return -ENOMEM;
}
platform_set_drvdata(omap3pandora_snd_device, &snd_soc_card_omap3pandora);
@@ -268,6 +244,20 @@ static int __init omap3pandora_soc_init(void)
goto fail2;
}
+ dac_power_gpio = devm_gpiod_get(&omap3pandora_snd_device->dev,
+ "dac", GPIOD_OUT_LOW);
+ if (IS_ERR(dac_power_gpio)) {
+ ret = PTR_ERR(dac_power_gpio);
+ goto fail3;
+ }
+
+ amp_power_gpio = devm_gpiod_get(&omap3pandora_snd_device->dev,
+ "amp", GPIOD_OUT_LOW);
+ if (IS_ERR(amp_power_gpio)) {
+ ret = PTR_ERR(amp_power_gpio);
+ goto fail3;
+ }
+
omap3pandora_dac_reg = regulator_get(&omap3pandora_snd_device->dev, "vcc");
if (IS_ERR(omap3pandora_dac_reg)) {
pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n",
@@ -283,10 +273,7 @@ fail3:
platform_device_del(omap3pandora_snd_device);
fail2:
platform_device_put(omap3pandora_snd_device);
-fail1:
- gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO);
-fail0:
- gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO);
+
return ret;
}
module_init(omap3pandora_soc_init);
@@ -295,8 +282,6 @@ static void __exit omap3pandora_soc_exit(void)
{
regulator_put(omap3pandora_dac_reg);
platform_device_unregister(omap3pandora_snd_device);
- gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO);
- gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO);
}
module_exit(omap3pandora_soc_exit);