diff options
author | Misael Lopez Cruz <misael.lopez@ti.com> | 2011-04-19 20:41:54 -0500 |
---|---|---|
committer | Dan Murphy <dmurphy@ti.com> | 2011-04-20 09:06:03 -0500 |
commit | 2b3c5945463fe470b240eee8643cad4db48dae66 (patch) | |
tree | dadf25f0d1c9e7424b026f0d464c68bfa1f798e6 /sound | |
parent | 10fefb0dcabb81d95a5f61cbd2dc3df63cdb9d9d (diff) |
ASoC: sdp4430: Add vaux2 regulator for AV Switch
An AV switch is used in Blaze/SDP4430 to switch headset jack pin 3
between headset microphone and video output. AV switch is then a
consumer of VAUX2 supply. The corresponding consumer-supply is added
to have VAUX2 supply when headset microphone is in use.
Change-Id: Ibb0264926ca599e8eae99ef0b747e8e08a4e316b
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/omap/sdp4430.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c index ff3f4af69ad7..074df54cad1b 100644 --- a/sound/soc/omap/sdp4430.c +++ b/sound/soc/omap/sdp4430.c @@ -25,6 +25,7 @@ #include <linux/i2c.h> #include <linux/mfd/twl6040-codec.h> #include <linux/i2c/twl.h> +#include <linux/regulator/consumer.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -50,6 +51,7 @@ #define TPS6130X_I2C_ADAPTER 1 +static struct regulator *av_switch_reg; static int twl6040_power_mode; static int mcbsp_cfg; @@ -333,6 +335,19 @@ static struct snd_soc_jack_pin hs_jack_pins[] = { }, }; +static int sdp4430_av_switch_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + int ret; + + if (SND_SOC_DAPM_EVENT_ON(event)) + ret = regulator_enable(av_switch_reg); + else + ret = regulator_disable(av_switch_reg); + + return ret; +} + static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -370,6 +385,9 @@ static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { SND_SOC_DAPM_HP("Headset Stereophone", NULL), SND_SOC_DAPM_SPK("Earphone Spk", NULL), SND_SOC_DAPM_INPUT("Aux/FM Stereo In"), + SND_SOC_DAPM_SUPPLY("AV Switch Supply", + SND_SOC_NOPM, 0, 0, sdp4430_av_switch_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), }; static const struct snd_soc_dapm_route audio_map[] = { @@ -385,6 +403,7 @@ static const struct snd_soc_dapm_route audio_map[] = { /* Headset Mic: HSMIC with bias */ {"HSMIC", NULL, "Headset Mic Bias"}, {"Headset Mic Bias", NULL, "Headset Mic"}, + {"Headset Mic", NULL, "AV Switch Supply"}, /* Headset Stereophone (Headphone): HSOL, HSOR */ {"Headset Stereophone", NULL, "HSOL"}, @@ -947,18 +966,26 @@ static int __init sdp4430_soc_init(void) ret = platform_device_add(sdp4430_snd_device); if (ret) - goto err; + goto plat_err; + + av_switch_reg = regulator_get(&sdp4430_snd_device->dev, "av-switch"); + if (IS_ERR(av_switch_reg)) { + ret = PTR_ERR(av_switch_reg); + printk(KERN_ERR "couldn't get AV Switch regulator %d\n", + ret); + goto reg_err; + } /* enable tps6130x */ ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &gpoctl, TWL6040_REG_GPOCTL); if (ret) - goto err; + goto gpo_err; ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, gpoctl | TWL6040_GPO2, TWL6040_REG_GPOCTL); if (ret) - goto err; + goto gpo_err; adapter = i2c_get_adapter(TPS6130X_I2C_ADAPTER); if (!adapter) { @@ -994,7 +1021,11 @@ tps_err: i2c_put_adapter(adapter); adp_err: twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, gpoctl, TWL6040_REG_GPOCTL); -err: +gpo_err: + regulator_put(av_switch_reg); +reg_err: + platform_device_del(sdp4430_snd_device); +plat_err: printk(KERN_ERR "Unable to add platform device\n"); platform_device_put(sdp4430_snd_device); return ret; @@ -1003,6 +1034,7 @@ module_init(sdp4430_soc_init); static void __exit sdp4430_soc_exit(void) { + regulator_put(av_switch_reg); platform_device_unregister(sdp4430_snd_device); i2c_unregister_device(tps6130x_client); } |