aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/tegra/harmony.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/sound/soc/tegra/harmony.c b/sound/soc/tegra/harmony.c
index cd5d90ae33e3..66512426317d 100644
--- a/sound/soc/tegra/harmony.c
+++ b/sound/soc/tegra/harmony.c
@@ -52,10 +52,14 @@
52 52
53#define DRV_NAME "tegra-snd-harmony" 53#define DRV_NAME "tegra-snd-harmony"
54 54
55#define GPIO_SPKR_EN BIT(0)
56#define GPIO_INT_MIC_EN BIT(1)
57#define GPIO_EXT_MIC_EN BIT(2)
58
55struct tegra_harmony { 59struct tegra_harmony {
56 struct tegra_asoc_utils_data util_data; 60 struct tegra_asoc_utils_data util_data;
57 struct harmony_audio_platform_data *pdata; 61 struct harmony_audio_platform_data *pdata;
58 int gpio_spkr_en_requested; 62 int gpio_requested;
59}; 63};
60 64
61static int harmony_asoc_hw_params(struct snd_pcm_substream *substream, 65static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
@@ -202,10 +206,30 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
202 dev_err(card->dev, "cannot get spkr_en gpio\n"); 206 dev_err(card->dev, "cannot get spkr_en gpio\n");
203 return ret; 207 return ret;
204 } 208 }
205 harmony->gpio_spkr_en_requested = 1; 209 harmony->gpio_requested |= GPIO_SPKR_EN;
206 210
207 gpio_direction_output(pdata->gpio_spkr_en, 0); 211 gpio_direction_output(pdata->gpio_spkr_en, 0);
208 212
213 ret = gpio_request(pdata->gpio_int_mic_en, "int_mic_en");
214 if (ret) {
215 dev_err(card->dev, "cannot get int_mic_en gpio\n");
216 return ret;
217 }
218 harmony->gpio_requested |= GPIO_INT_MIC_EN;
219
220 /* Disable int mic; enable signal is active-high */
221 gpio_direction_output(pdata->gpio_int_mic_en, 0);
222
223 ret = gpio_request(pdata->gpio_ext_mic_en, "ext_mic_en");
224 if (ret) {
225 dev_err(card->dev, "cannot get ext_mic_en gpio\n");
226 return ret;
227 }
228 harmony->gpio_requested |= GPIO_EXT_MIC_EN;
229
230 /* Enable ext mic; enable signal is active-low */
231 gpio_direction_output(pdata->gpio_ext_mic_en, 0);
232
209 ret = snd_soc_add_controls(codec, harmony_controls, 233 ret = snd_soc_add_controls(codec, harmony_controls,
210 ARRAY_SIZE(harmony_controls)); 234 ARRAY_SIZE(harmony_controls));
211 if (ret < 0) 235 if (ret < 0)
@@ -330,7 +354,11 @@ static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev)
330 354
331 tegra_asoc_utils_fini(&harmony->util_data); 355 tegra_asoc_utils_fini(&harmony->util_data);
332 356
333 if (harmony->gpio_spkr_en_requested) 357 if (harmony->gpio_requested & GPIO_EXT_MIC_EN)
358 gpio_free(pdata->gpio_ext_mic_en);
359 if (harmony->gpio_requested & GPIO_INT_MIC_EN)
360 gpio_free(pdata->gpio_int_mic_en);
361 if (harmony->gpio_requested & GPIO_SPKR_EN)
334 gpio_free(pdata->gpio_spkr_en); 362 gpio_free(pdata->gpio_spkr_en);
335 363
336 kfree(harmony); 364 kfree(harmony);