diff options
author | Grazvydas Ignotas <notasas@gmail.com> | 2010-02-05 09:29:53 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-02-05 12:08:16 -0500 |
commit | c50749de02f272be6e09b9016e13a17307d29066 (patch) | |
tree | b8e8ca903fd615863bba3826e33918d6f4dfdb80 /sound | |
parent | 4f2c120d1860ce33a71c617f59cf80c700b30d2a (diff) |
ASoC: pandora: Add DAC regulator support
Pandora's external DAC is connected to VSIM TWL4030 supply, so let's
start switching it too to save more power.
Also DAC got it's own DAPM handler.
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/omap/omap3pandora.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index 68980c19a3bc..de10f76baded 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/regulator/consumer.h> | ||
26 | 27 | ||
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
28 | #include <sound/pcm.h> | 29 | #include <sound/pcm.h> |
@@ -40,6 +41,8 @@ | |||
40 | 41 | ||
41 | #define PREFIX "ASoC omap3pandora: " | 42 | #define PREFIX "ASoC omap3pandora: " |
42 | 43 | ||
44 | static struct regulator *omap3pandora_dac_reg; | ||
45 | |||
43 | static int omap3pandora_cmn_hw_params(struct snd_pcm_substream *substream, | 46 | static int omap3pandora_cmn_hw_params(struct snd_pcm_substream *substream, |
44 | struct snd_pcm_hw_params *params, unsigned int fmt) | 47 | struct snd_pcm_hw_params *params, unsigned int fmt) |
45 | { | 48 | { |
@@ -106,21 +109,37 @@ static int omap3pandora_in_hw_params(struct snd_pcm_substream *substream, | |||
106 | SND_SOC_DAIFMT_CBS_CFS); | 109 | SND_SOC_DAIFMT_CBS_CFS); |
107 | } | 110 | } |
108 | 111 | ||
109 | static int omap3pandora_hp_event(struct snd_soc_dapm_widget *w, | 112 | static int omap3pandora_dac_event(struct snd_soc_dapm_widget *w, |
110 | struct snd_kcontrol *k, int event) | 113 | struct snd_kcontrol *k, int event) |
111 | { | 114 | { |
115 | /* | ||
116 | * The PCM1773 DAC datasheet requires 1ms delay between switching | ||
117 | * VCC power on/off and /PD pin high/low | ||
118 | */ | ||
112 | if (SND_SOC_DAPM_EVENT_ON(event)) { | 119 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
120 | regulator_enable(omap3pandora_dac_reg); | ||
121 | mdelay(1); | ||
113 | gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 1); | 122 | gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 1); |
114 | gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 1); | ||
115 | } else { | 123 | } else { |
116 | gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 0); | ||
117 | mdelay(1); | ||
118 | gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 0); | 124 | gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 0); |
125 | mdelay(1); | ||
126 | regulator_disable(omap3pandora_dac_reg); | ||
119 | } | 127 | } |
120 | 128 | ||
121 | return 0; | 129 | return 0; |
122 | } | 130 | } |
123 | 131 | ||
132 | static int omap3pandora_hp_event(struct snd_soc_dapm_widget *w, | ||
133 | struct snd_kcontrol *k, int event) | ||
134 | { | ||
135 | if (SND_SOC_DAPM_EVENT_ON(event)) | ||
136 | gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 1); | ||
137 | else | ||
138 | gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 0); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
124 | /* | 143 | /* |
125 | * Audio paths on Pandora board: | 144 | * Audio paths on Pandora board: |
126 | * | 145 | * |
@@ -130,7 +149,9 @@ static int omap3pandora_hp_event(struct snd_soc_dapm_widget *w, | |||
130 | * |P| <--- TWL4030 <--------- Line In and MICs | 149 | * |P| <--- TWL4030 <--------- Line In and MICs |
131 | */ | 150 | */ |
132 | static const struct snd_soc_dapm_widget omap3pandora_out_dapm_widgets[] = { | 151 | static const struct snd_soc_dapm_widget omap3pandora_out_dapm_widgets[] = { |
133 | SND_SOC_DAPM_DAC("PCM DAC", "HiFi Playback", SND_SOC_NOPM, 0, 0), | 152 | SND_SOC_DAPM_DAC_E("PCM DAC", "HiFi Playback", SND_SOC_NOPM, |
153 | 0, 0, omap3pandora_dac_event, | ||
154 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), | ||
134 | SND_SOC_DAPM_PGA_E("Headphone Amplifier", SND_SOC_NOPM, | 155 | SND_SOC_DAPM_PGA_E("Headphone Amplifier", SND_SOC_NOPM, |
135 | 0, 0, NULL, 0, omap3pandora_hp_event, | 156 | 0, 0, NULL, 0, omap3pandora_hp_event, |
136 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), | 157 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
@@ -306,8 +327,18 @@ static int __init omap3pandora_soc_init(void) | |||
306 | goto fail2; | 327 | goto fail2; |
307 | } | 328 | } |
308 | 329 | ||
330 | omap3pandora_dac_reg = regulator_get(&omap3pandora_snd_device->dev, "vcc"); | ||
331 | if (IS_ERR(omap3pandora_dac_reg)) { | ||
332 | pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n", | ||
333 | dev_name(&omap3pandora_snd_device->dev), | ||
334 | PTR_ERR(omap3pandora_dac_reg)); | ||
335 | goto fail3; | ||
336 | } | ||
337 | |||
309 | return 0; | 338 | return 0; |
310 | 339 | ||
340 | fail3: | ||
341 | platform_device_del(omap3pandora_snd_device); | ||
311 | fail2: | 342 | fail2: |
312 | platform_device_put(omap3pandora_snd_device); | 343 | platform_device_put(omap3pandora_snd_device); |
313 | fail1: | 344 | fail1: |
@@ -320,6 +351,7 @@ module_init(omap3pandora_soc_init); | |||
320 | 351 | ||
321 | static void __exit omap3pandora_soc_exit(void) | 352 | static void __exit omap3pandora_soc_exit(void) |
322 | { | 353 | { |
354 | regulator_put(omap3pandora_dac_reg); | ||
323 | platform_device_unregister(omap3pandora_snd_device); | 355 | platform_device_unregister(omap3pandora_snd_device); |
324 | gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO); | 356 | gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO); |
325 | gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO); | 357 | gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO); |