diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-01-21 16:50:00 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-02-01 05:17:24 -0500 |
commit | 4a086e4cc423c5f89ea7b2e25c29800057477b58 (patch) | |
tree | 2dfa977defc19d85f50c95701ce358ff44b2ec57 /sound/soc/codecs/wm8996.c | |
parent | 177f72fd101d512d938558b53cd4faa6a5434090 (diff) |
ASoC: wm8996: Switch to using common code for managing CPVDD supply
Nice code saving.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8996.c')
-rw-r--r-- | sound/soc/codecs/wm8996.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 3fc30c29f5f1..42af0a396839 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c | |||
@@ -73,7 +73,6 @@ struct wm8996_priv { | |||
73 | 73 | ||
74 | struct regulator_bulk_data supplies[WM8996_NUM_SUPPLIES]; | 74 | struct regulator_bulk_data supplies[WM8996_NUM_SUPPLIES]; |
75 | struct notifier_block disable_nb[WM8996_NUM_SUPPLIES]; | 75 | struct notifier_block disable_nb[WM8996_NUM_SUPPLIES]; |
76 | struct regulator *cpvdd; | ||
77 | int bg_ena; | 76 | int bg_ena; |
78 | 77 | ||
79 | struct wm8996_pdata pdata; | 78 | struct wm8996_pdata pdata; |
@@ -793,29 +792,18 @@ static int bg_event(struct snd_soc_dapm_widget *w, | |||
793 | static int cp_event(struct snd_soc_dapm_widget *w, | 792 | static int cp_event(struct snd_soc_dapm_widget *w, |
794 | struct snd_kcontrol *kcontrol, int event) | 793 | struct snd_kcontrol *kcontrol, int event) |
795 | { | 794 | { |
796 | struct snd_soc_codec *codec = w->codec; | ||
797 | struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); | ||
798 | int ret = 0; | 795 | int ret = 0; |
799 | 796 | ||
800 | switch (event) { | 797 | switch (event) { |
801 | case SND_SOC_DAPM_PRE_PMU: | ||
802 | ret = regulator_enable(wm8996->cpvdd); | ||
803 | if (ret != 0) | ||
804 | dev_err(codec->dev, "Failed to enable CPVDD: %d\n", | ||
805 | ret); | ||
806 | break; | ||
807 | case SND_SOC_DAPM_POST_PMU: | 798 | case SND_SOC_DAPM_POST_PMU: |
808 | msleep(5); | 799 | msleep(5); |
809 | break; | 800 | break; |
810 | case SND_SOC_DAPM_POST_PMD: | ||
811 | regulator_disable_deferred(wm8996->cpvdd, 20); | ||
812 | break; | ||
813 | default: | 801 | default: |
814 | BUG(); | 802 | BUG(); |
815 | ret = -EINVAL; | 803 | ret = -EINVAL; |
816 | } | 804 | } |
817 | 805 | ||
818 | return ret; | 806 | return 0; |
819 | } | 807 | } |
820 | 808 | ||
821 | static int rmv_short_event(struct snd_soc_dapm_widget *w, | 809 | static int rmv_short_event(struct snd_soc_dapm_widget *w, |
@@ -1117,12 +1105,12 @@ SND_SOC_DAPM_INPUT("IN2RP"), | |||
1117 | SND_SOC_DAPM_INPUT("DMIC1DAT"), | 1105 | SND_SOC_DAPM_INPUT("DMIC1DAT"), |
1118 | SND_SOC_DAPM_INPUT("DMIC2DAT"), | 1106 | SND_SOC_DAPM_INPUT("DMIC2DAT"), |
1119 | 1107 | ||
1108 | SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20), | ||
1120 | SND_SOC_DAPM_SUPPLY_S("SYSCLK", 1, WM8996_AIF_CLOCKING_1, 0, 0, NULL, 0), | 1109 | SND_SOC_DAPM_SUPPLY_S("SYSCLK", 1, WM8996_AIF_CLOCKING_1, 0, 0, NULL, 0), |
1121 | SND_SOC_DAPM_SUPPLY_S("SYSDSPCLK", 2, WM8996_CLOCKING_1, 1, 0, NULL, 0), | 1110 | SND_SOC_DAPM_SUPPLY_S("SYSDSPCLK", 2, WM8996_CLOCKING_1, 1, 0, NULL, 0), |
1122 | SND_SOC_DAPM_SUPPLY_S("AIFCLK", 2, WM8996_CLOCKING_1, 2, 0, NULL, 0), | 1111 | SND_SOC_DAPM_SUPPLY_S("AIFCLK", 2, WM8996_CLOCKING_1, 2, 0, NULL, 0), |
1123 | SND_SOC_DAPM_SUPPLY_S("Charge Pump", 2, WM8996_CHARGE_PUMP_1, 15, 0, cp_event, | 1112 | SND_SOC_DAPM_SUPPLY_S("Charge Pump", 2, WM8996_CHARGE_PUMP_1, 15, 0, cp_event, |
1124 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 1113 | SND_SOC_DAPM_POST_PMU), |
1125 | SND_SOC_DAPM_POST_PMD), | ||
1126 | SND_SOC_DAPM_SUPPLY("Bandgap", SND_SOC_NOPM, 0, 0, bg_event, | 1114 | SND_SOC_DAPM_SUPPLY("Bandgap", SND_SOC_NOPM, 0, 0, bg_event, |
1127 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | 1115 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
1128 | SND_SOC_DAPM_SUPPLY("LDO2", WM8996_POWER_MANAGEMENT_2, 1, 0, NULL, 0), | 1116 | SND_SOC_DAPM_SUPPLY("LDO2", WM8996_POWER_MANAGEMENT_2, 1, 0, NULL, 0), |
@@ -1281,6 +1269,7 @@ static const struct snd_soc_dapm_route wm8996_dapm_routes[] = { | |||
1281 | { "AIFCLK", NULL, "SYSCLK" }, | 1269 | { "AIFCLK", NULL, "SYSCLK" }, |
1282 | { "SYSDSPCLK", NULL, "SYSCLK" }, | 1270 | { "SYSDSPCLK", NULL, "SYSCLK" }, |
1283 | { "Charge Pump", NULL, "SYSCLK" }, | 1271 | { "Charge Pump", NULL, "SYSCLK" }, |
1272 | { "Charge Pump", NULL, "CPVDD" }, | ||
1284 | 1273 | ||
1285 | { "MICB1", NULL, "LDO2" }, | 1274 | { "MICB1", NULL, "LDO2" }, |
1286 | { "MICB1", NULL, "MICB1 Audio" }, | 1275 | { "MICB1", NULL, "MICB1 Audio" }, |
@@ -3049,7 +3038,6 @@ static int wm8996_remove(struct snd_soc_codec *codec) | |||
3049 | for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) | 3038 | for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) |
3050 | regulator_unregister_notifier(wm8996->supplies[i].consumer, | 3039 | regulator_unregister_notifier(wm8996->supplies[i].consumer, |
3051 | &wm8996->disable_nb[i]); | 3040 | &wm8996->disable_nb[i]); |
3052 | regulator_put(wm8996->cpvdd); | ||
3053 | regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); | 3041 | regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); |
3054 | 3042 | ||
3055 | return 0; | 3043 | return 0; |
@@ -3172,18 +3160,11 @@ static __devinit int wm8996_i2c_probe(struct i2c_client *i2c, | |||
3172 | goto err_gpio; | 3160 | goto err_gpio; |
3173 | } | 3161 | } |
3174 | 3162 | ||
3175 | wm8996->cpvdd = regulator_get(&i2c->dev, "CPVDD"); | ||
3176 | if (IS_ERR(wm8996->cpvdd)) { | ||
3177 | ret = PTR_ERR(wm8996->cpvdd); | ||
3178 | dev_err(&i2c->dev, "Failed to get CPVDD: %d\n", ret); | ||
3179 | goto err_get; | ||
3180 | } | ||
3181 | |||
3182 | ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies), | 3163 | ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies), |
3183 | wm8996->supplies); | 3164 | wm8996->supplies); |
3184 | if (ret != 0) { | 3165 | if (ret != 0) { |
3185 | dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); | 3166 | dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); |
3186 | goto err_cpvdd; | 3167 | goto err_get; |
3187 | } | 3168 | } |
3188 | 3169 | ||
3189 | if (wm8996->pdata.ldo_ena > 0) { | 3170 | if (wm8996->pdata.ldo_ena > 0) { |
@@ -3245,8 +3226,6 @@ err_enable: | |||
3245 | if (wm8996->pdata.ldo_ena > 0) | 3226 | if (wm8996->pdata.ldo_ena > 0) |
3246 | gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); | 3227 | gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); |
3247 | regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); | 3228 | regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); |
3248 | err_cpvdd: | ||
3249 | regulator_put(wm8996->cpvdd); | ||
3250 | err_get: | 3229 | err_get: |
3251 | regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); | 3230 | regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); |
3252 | err_gpio: | 3231 | err_gpio: |
@@ -3263,7 +3242,6 @@ static __devexit int wm8996_i2c_remove(struct i2c_client *client) | |||
3263 | 3242 | ||
3264 | snd_soc_unregister_codec(&client->dev); | 3243 | snd_soc_unregister_codec(&client->dev); |
3265 | wm8996_free_gpio(wm8996); | 3244 | wm8996_free_gpio(wm8996); |
3266 | regulator_put(wm8996->cpvdd); | ||
3267 | regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); | 3245 | regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); |
3268 | regmap_exit(wm8996->regmap); | 3246 | regmap_exit(wm8996->regmap); |
3269 | if (wm8996->pdata.ldo_ena > 0) { | 3247 | if (wm8996->pdata.ldo_ena > 0) { |