summaryrefslogtreecommitdiff
path: root/sound/soc/samsung/speyside.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/samsung/speyside.c')
-rw-r--r--sound/soc/samsung/speyside.c91
1 files changed, 62 insertions, 29 deletions
diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c
index 22e2ad63d64d..26701a55fe0a 100644
--- a/sound/soc/samsung/speyside.c
+++ b/sound/soc/samsung/speyside.c
@@ -7,13 +7,13 @@
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/jack.h>
-#include <linux/gpio.h>
+#include <linux/gpio/machine.h>
+#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include "../codecs/wm8996.h"
#include "../codecs/wm9081.h"
-#define WM8996_HPSEL_GPIO 214
#define MCLK_AUDIO_RATE (512 * 48000)
static int speyside_set_bias_level(struct snd_soc_card *card,
@@ -25,9 +25,9 @@ static int speyside_set_bias_level(struct snd_soc_card *card,
int ret;
rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
- codec_dai = asoc_rtd_to_codec(rtd, 0);
+ codec_dai = snd_soc_rtd_to_codec(rtd, 0);
- if (dapm->dev != codec_dai->dev)
+ if (snd_soc_dapm_to_dev(dapm) != codec_dai->dev)
return 0;
switch (level) {
@@ -61,14 +61,14 @@ static int speyside_set_bias_level_post(struct snd_soc_card *card,
int ret;
rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
- codec_dai = asoc_rtd_to_codec(rtd, 0);
+ codec_dai = snd_soc_rtd_to_codec(rtd, 0);
- if (dapm->dev != codec_dai->dev)
+ if (snd_soc_dapm_to_dev(dapm) != codec_dai->dev)
return 0;
switch (level) {
case SND_SOC_BIAS_PREPARE:
- if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) {
+ if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) {
ret = snd_soc_dai_set_pll(codec_dai, 0,
WM8996_FLL_MCLK2,
32768, MCLK_AUDIO_RATE);
@@ -90,8 +90,6 @@ static int speyside_set_bias_level_post(struct snd_soc_card *card,
break;
}
- card->dapm.bias_level = level;
-
return 0;
}
@@ -105,15 +103,16 @@ static struct snd_soc_jack_pin speyside_headset_pins[] = {
},
};
+static struct gpio_desc *speyside_hpsel_gpio;
/* Default the headphone selection to active high */
static int speyside_jack_polarity;
static int speyside_get_micbias(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{
- if (speyside_jack_polarity && (strcmp(source->name, "MICB1") == 0))
+ if (speyside_jack_polarity && (snd_soc_dapm_widget_name_cmp(source, "MICB1") == 0))
return 1;
- if (!speyside_jack_polarity && (strcmp(source->name, "MICB2") == 0))
+ if (!speyside_jack_polarity && (snd_soc_dapm_widget_name_cmp(source, "MICB2") == 0))
return 1;
return 0;
@@ -123,15 +122,15 @@ static void speyside_set_polarity(struct snd_soc_component *component,
int polarity)
{
speyside_jack_polarity = !polarity;
- gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity);
+ gpiod_direction_output(speyside_hpsel_gpio, speyside_jack_polarity);
/* Re-run DAPM to make sure we're using the correct mic bias */
- snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
+ snd_soc_dapm_sync(snd_soc_component_to_dapm(component));
}
static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd)
{
- struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
+ struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
int ret;
ret = snd_soc_dai_set_sysclk(dai, 0, MCLK_AUDIO_RATE, 0);
@@ -143,18 +142,24 @@ static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd)
static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd)
{
- struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
+ struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
struct snd_soc_component *component = dai->component;
+ enum gpiod_flags flags;
int ret;
ret = snd_soc_dai_set_sysclk(dai, WM8996_SYSCLK_MCLK2, 32768, 0);
if (ret < 0)
return ret;
- ret = gpio_request(WM8996_HPSEL_GPIO, "HP_SEL");
- if (ret != 0)
- pr_err("Failed to request HP_SEL GPIO: %d\n", ret);
- gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity);
+ if (speyside_jack_polarity)
+ flags = GPIOD_OUT_HIGH;
+ else
+ flags = GPIOD_OUT_LOW;
+ speyside_hpsel_gpio = devm_gpiod_get(rtd->card->dev,
+ "hp-sel",
+ flags);
+ if (IS_ERR(speyside_hpsel_gpio))
+ return PTR_ERR(speyside_hpsel_gpio);
ret = snd_soc_card_jack_new_pins(rtd->card, "Headset",
SND_JACK_LINEOUT | SND_JACK_HEADSET |
@@ -172,13 +177,15 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd)
static int speyside_late_probe(struct snd_soc_card *card)
{
- snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone");
- snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Mic");
- snd_soc_dapm_ignore_suspend(&card->dapm, "Main AMIC");
- snd_soc_dapm_ignore_suspend(&card->dapm, "Main DMIC");
- snd_soc_dapm_ignore_suspend(&card->dapm, "Main Speaker");
- snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Output");
- snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Input");
+ struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
+
+ snd_soc_dapm_ignore_suspend(dapm, "Headphone");
+ snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
+ snd_soc_dapm_ignore_suspend(dapm, "Main AMIC");
+ snd_soc_dapm_ignore_suspend(dapm, "Main DMIC");
+ snd_soc_dapm_ignore_suspend(dapm, "Main Speaker");
+ snd_soc_dapm_ignore_suspend(dapm, "WM1250 Output");
+ snd_soc_dapm_ignore_suspend(dapm, "WM1250 Input");
return 0;
}
@@ -210,7 +217,7 @@ static struct snd_soc_dai_link speyside_dai[] = {
.stream_name = "CPU-DSP",
.init = speyside_wm0010_init,
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
- | SND_SOC_DAIFMT_CBM_CFM,
+ | SND_SOC_DAIFMT_CBP_CFP,
SND_SOC_DAILINK_REG(cpu_dsp),
},
{
@@ -218,7 +225,7 @@ static struct snd_soc_dai_link speyside_dai[] = {
.stream_name = "DSP-CODEC",
.init = speyside_wm8996_init,
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
- | SND_SOC_DAIFMT_CBM_CFM,
+ | SND_SOC_DAIFMT_CBP_CFP,
.c2c_params = &dsp_codec_params,
.num_c2c_params = 1,
.ignore_suspend = 1,
@@ -228,7 +235,7 @@ static struct snd_soc_dai_link speyside_dai[] = {
.name = "Baseband",
.stream_name = "Baseband",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
- | SND_SOC_DAIFMT_CBM_CFM,
+ | SND_SOC_DAIFMT_CBP_CFP,
.ignore_suspend = 1,
SND_SOC_DAILINK_REG(baseband),
},
@@ -325,6 +332,26 @@ static struct snd_soc_card speyside = {
.late_probe = speyside_late_probe,
};
+static struct gpiod_lookup_table wm8996_gpiod_table = {
+ /* Hardcoded device name in board file mach-crag6410.c */
+ .dev_id = "speyside",
+ .table = {
+ /*
+ * This line was hardcoded to 214 in the global GPIO
+ * number space, S3C GPIO macros seems top set the
+ * wm8996 codec GPIO start offset to 212, so this will
+ * be GPIO 214 - 212 = 2 on the wm8996.
+ */
+ GPIO_LOOKUP("wm8996", 2, "hp-sel", GPIO_ACTIVE_HIGH),
+ { },
+ },
+};
+
+static void speyside_gpiod_table_action(void *data)
+{
+ gpiod_remove_lookup_table(&wm8996_gpiod_table);
+}
+
static int speyside_probe(struct platform_device *pdev)
{
struct snd_soc_card *card = &speyside;
@@ -332,6 +359,12 @@ static int speyside_probe(struct platform_device *pdev)
card->dev = &pdev->dev;
+ gpiod_add_lookup_table(&wm8996_gpiod_table);
+ ret = devm_add_action_or_reset(&pdev->dev, speyside_gpiod_table_action,
+ NULL);
+ if (ret)
+ return ret;
+
ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret)
dev_err_probe(&pdev->dev, ret, "snd_soc_register_card() failed\n");