asoc: tegra: aic326x: Use avdd_audio regulator
Vijay Mali [Thu, 21 Mar 2013 15:09:05 +0000 (20:09 +0530)]
- Enable avdd_audio regulator during playback on Headphone and Speaker.
- This prevent leakage current in codec.
- Improve codec power numbers.

Bug 1238662

Change-Id: Ie9fa31b6291c06ad4f83138c4e595fb4da29a7f9
Signed-off-by: Vijay Mali <vmali@nvidia.com>
Reviewed-on: http://git-master/r/211670
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Niranjan Wartikar <nwartikar@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

sound/soc/tegra/tegra_aic326x.c

index 9f3119f..dbcab64 100644 (file)
@@ -1108,6 +1108,8 @@ static int tegra_aic326x_event_int_spk(struct snd_soc_dapm_widget *w,
                        /*  set speaker amplifier voulme to 18 dB, E-1 state */
                        snd_soc_write(codec, AIC3262_SPK_AMP_CNTL_R4, 0x33);
                }
+               if (machine->audio_reg)
+                       regulator_enable(machine->audio_reg);
        } else {
                ret = edp_update_client_request(
                                        machine->spk_edp_client,
@@ -1116,6 +1118,8 @@ static int tegra_aic326x_event_int_spk(struct snd_soc_dapm_widget *w,
                        dev_err(card->dev,
                                "E+1 state transition failed\n");
                }
+               if (machine->audio_reg)
+                       regulator_disable(machine->audio_reg);
        }
 err_null_spk_edp_client:
        if (!(machine->gpio_requested & GPIO_SPKR_EN))
@@ -1135,6 +1139,13 @@ static int tegra_aic326x_event_hp(struct snd_soc_dapm_widget *w,
        struct tegra_aic326x *machine = snd_soc_card_get_drvdata(card);
        struct tegra_asoc_platform_data *pdata = machine->pdata;
 
+       if (machine->audio_reg) {
+               if (SND_SOC_DAPM_EVENT_ON(event))
+                       regulator_enable(machine->audio_reg);
+               else
+                       regulator_disable(machine->audio_reg);
+       }
+
        if (!(machine->gpio_requested & GPIO_HP_MUTE))
                return 0;
 
@@ -1547,6 +1558,12 @@ static __devinit int tegra_aic326x_driver_probe(struct platform_device *pdev)
                machine->hmic_reg = 0;
        }
 
+       machine->audio_reg = regulator_get(NULL, "avdd_audio");
+       if (IS_ERR(machine->audio_reg)) {
+               dev_info(&pdev->dev, "No avdd_audio regulator found\n");
+               machine->audio_reg = 0;
+       }
+
        card->dev = &pdev->dev;
        platform_set_drvdata(pdev, card);
        snd_soc_card_set_drvdata(card, machine);