diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-01-21 17:10:24 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-01-26 11:07:55 -0500 |
commit | 1cf733569e6f484a09cb7e4b8602a48c32864594 (patch) | |
tree | fc1114872650bacc2e81520e78cc463b21f3eac7 /sound/soc/codecs/wm5100.c | |
parent | 62ea874abc11f02dbeb05314eb82f7d38e82e894 (diff) |
ASoC: wm5100: Move regulator supplies over to DAPM infrastructure
Saves a nice block of code.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm5100.c')
-rw-r--r-- | sound/soc/codecs/wm5100.c | 131 |
1 files changed, 10 insertions, 121 deletions
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index 714256e609c1..c1c8bdb7bb01 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c | |||
@@ -55,9 +55,6 @@ struct wm5100_priv { | |||
55 | struct snd_soc_codec *codec; | 55 | struct snd_soc_codec *codec; |
56 | 56 | ||
57 | struct regulator_bulk_data core_supplies[WM5100_NUM_CORE_SUPPLIES]; | 57 | struct regulator_bulk_data core_supplies[WM5100_NUM_CORE_SUPPLIES]; |
58 | struct regulator *cpvdd; | ||
59 | struct regulator *dbvdd2; | ||
60 | struct regulator *dbvdd3; | ||
61 | 58 | ||
62 | int rev; | 59 | int rev; |
63 | 60 | ||
@@ -777,85 +774,6 @@ static int wm5100_out_ev(struct snd_soc_dapm_widget *w, | |||
777 | return 0; | 774 | return 0; |
778 | } | 775 | } |
779 | 776 | ||
780 | static int wm5100_cp_ev(struct snd_soc_dapm_widget *w, | ||
781 | struct snd_kcontrol *kcontrol, | ||
782 | int event) | ||
783 | { | ||
784 | struct snd_soc_codec *codec = w->codec; | ||
785 | struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); | ||
786 | int ret; | ||
787 | |||
788 | switch (event) { | ||
789 | case SND_SOC_DAPM_PRE_PMU: | ||
790 | ret = regulator_enable(wm5100->cpvdd); | ||
791 | if (ret != 0) { | ||
792 | dev_err(codec->dev, "Failed to enable CPVDD: %d\n", | ||
793 | ret); | ||
794 | return ret; | ||
795 | } | ||
796 | return ret; | ||
797 | |||
798 | case SND_SOC_DAPM_POST_PMD: | ||
799 | ret = regulator_disable_deferred(wm5100->cpvdd, 20); | ||
800 | if (ret != 0) { | ||
801 | dev_err(codec->dev, "Failed to disable CPVDD: %d\n", | ||
802 | ret); | ||
803 | return ret; | ||
804 | } | ||
805 | return ret; | ||
806 | |||
807 | default: | ||
808 | BUG(); | ||
809 | return 0; | ||
810 | } | ||
811 | } | ||
812 | |||
813 | static int wm5100_dbvdd_ev(struct snd_soc_dapm_widget *w, | ||
814 | struct snd_kcontrol *kcontrol, | ||
815 | int event) | ||
816 | { | ||
817 | struct snd_soc_codec *codec = w->codec; | ||
818 | struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); | ||
819 | struct regulator *regulator; | ||
820 | int ret; | ||
821 | |||
822 | switch (w->shift) { | ||
823 | case 2: | ||
824 | regulator = wm5100->dbvdd2; | ||
825 | break; | ||
826 | case 3: | ||
827 | regulator = wm5100->dbvdd3; | ||
828 | break; | ||
829 | default: | ||
830 | BUG(); | ||
831 | return 0; | ||
832 | } | ||
833 | |||
834 | switch (event) { | ||
835 | case SND_SOC_DAPM_PRE_PMU: | ||
836 | ret = regulator_enable(regulator); | ||
837 | if (ret != 0) { | ||
838 | dev_err(codec->dev, "Failed to enable DBVDD%d: %d\n", | ||
839 | w->shift, ret); | ||
840 | return ret; | ||
841 | } | ||
842 | return ret; | ||
843 | |||
844 | case SND_SOC_DAPM_POST_PMD: | ||
845 | ret = regulator_disable(regulator); | ||
846 | if (ret != 0) { | ||
847 | dev_err(codec->dev, "Failed to enable DBVDD%d: %d\n", | ||
848 | w->shift, ret); | ||
849 | return ret; | ||
850 | } | ||
851 | return ret; | ||
852 | |||
853 | default: | ||
854 | BUG(); | ||
855 | return 0; | ||
856 | } | ||
857 | } | ||
858 | |||
859 | static void wm5100_log_status3(struct wm5100_priv *wm5100, int val) | 777 | static void wm5100_log_status3(struct wm5100_priv *wm5100, int val) |
860 | { | 778 | { |
861 | if (val & WM5100_SPK_SHUTDOWN_WARN_EINT) | 779 | if (val & WM5100_SPK_SHUTDOWN_WARN_EINT) |
@@ -926,18 +844,16 @@ SND_SOC_DAPM_SUPPLY("SYSCLK", WM5100_CLOCKING_3, WM5100_SYSCLK_ENA_SHIFT, 0, | |||
926 | SND_SOC_DAPM_SUPPLY("ASYNCCLK", WM5100_CLOCKING_6, WM5100_ASYNC_CLK_ENA_SHIFT, | 844 | SND_SOC_DAPM_SUPPLY("ASYNCCLK", WM5100_CLOCKING_6, WM5100_ASYNC_CLK_ENA_SHIFT, |
927 | 0, NULL, 0), | 845 | 0, NULL, 0), |
928 | 846 | ||
847 | SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20), | ||
848 | SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0), | ||
849 | SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0), | ||
850 | |||
929 | SND_SOC_DAPM_SUPPLY("CP1", WM5100_HP_CHARGE_PUMP_1, WM5100_CP1_ENA_SHIFT, 0, | 851 | SND_SOC_DAPM_SUPPLY("CP1", WM5100_HP_CHARGE_PUMP_1, WM5100_CP1_ENA_SHIFT, 0, |
930 | wm5100_cp_ev, | 852 | NULL, 0), |
931 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
932 | SND_SOC_DAPM_SUPPLY("CP2", WM5100_MIC_CHARGE_PUMP_1, WM5100_CP2_ENA_SHIFT, 0, | 853 | SND_SOC_DAPM_SUPPLY("CP2", WM5100_MIC_CHARGE_PUMP_1, WM5100_CP2_ENA_SHIFT, 0, |
933 | NULL, 0), | 854 | NULL, 0), |
934 | SND_SOC_DAPM_SUPPLY("CP2 Active", WM5100_MIC_CHARGE_PUMP_1, | 855 | SND_SOC_DAPM_SUPPLY("CP2 Active", WM5100_MIC_CHARGE_PUMP_1, |
935 | WM5100_CP2_BYPASS_SHIFT, 1, wm5100_cp_ev, | 856 | WM5100_CP2_BYPASS_SHIFT, 1, NULL, 0), |
936 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
937 | SND_SOC_DAPM_SUPPLY("DBVDD2", SND_SOC_NOPM, 2, 0, wm5100_dbvdd_ev, | ||
938 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
939 | SND_SOC_DAPM_SUPPLY("DBVDD3", SND_SOC_NOPM, 3, 0, wm5100_dbvdd_ev, | ||
940 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
941 | 857 | ||
942 | SND_SOC_DAPM_SUPPLY("MICBIAS1", WM5100_MIC_BIAS_CTRL_1, WM5100_MICB1_ENA_SHIFT, | 858 | SND_SOC_DAPM_SUPPLY("MICBIAS1", WM5100_MIC_BIAS_CTRL_1, WM5100_MICB1_ENA_SHIFT, |
943 | 0, NULL, 0), | 859 | 0, NULL, 0), |
@@ -1148,6 +1064,9 @@ SND_SOC_DAPM_POST("Post", wm5100_post_ev), | |||
1148 | }; | 1064 | }; |
1149 | 1065 | ||
1150 | static const struct snd_soc_dapm_route wm5100_dapm_routes[] = { | 1066 | static const struct snd_soc_dapm_route wm5100_dapm_routes[] = { |
1067 | { "CP1", NULL, "CPVDD" }, | ||
1068 | { "CP2 Active", NULL, "CPVDD" }, | ||
1069 | |||
1151 | { "IN1L", NULL, "SYSCLK" }, | 1070 | { "IN1L", NULL, "SYSCLK" }, |
1152 | { "IN1R", NULL, "SYSCLK" }, | 1071 | { "IN1R", NULL, "SYSCLK" }, |
1153 | { "IN2L", NULL, "SYSCLK" }, | 1072 | { "IN2L", NULL, "SYSCLK" }, |
@@ -2593,33 +2512,12 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c, | |||
2593 | goto err_regmap; | 2512 | goto err_regmap; |
2594 | } | 2513 | } |
2595 | 2514 | ||
2596 | wm5100->cpvdd = regulator_get(&i2c->dev, "CPVDD"); | ||
2597 | if (IS_ERR(wm5100->cpvdd)) { | ||
2598 | ret = PTR_ERR(wm5100->cpvdd); | ||
2599 | dev_err(&i2c->dev, "Failed to get CPVDD: %d\n", ret); | ||
2600 | goto err_core; | ||
2601 | } | ||
2602 | |||
2603 | wm5100->dbvdd2 = regulator_get(&i2c->dev, "DBVDD2"); | ||
2604 | if (IS_ERR(wm5100->dbvdd2)) { | ||
2605 | ret = PTR_ERR(wm5100->dbvdd2); | ||
2606 | dev_err(&i2c->dev, "Failed to get DBVDD2: %d\n", ret); | ||
2607 | goto err_cpvdd; | ||
2608 | } | ||
2609 | |||
2610 | wm5100->dbvdd3 = regulator_get(&i2c->dev, "DBVDD3"); | ||
2611 | if (IS_ERR(wm5100->dbvdd3)) { | ||
2612 | ret = PTR_ERR(wm5100->dbvdd3); | ||
2613 | dev_err(&i2c->dev, "Failed to get DBVDD2: %d\n", ret); | ||
2614 | goto err_dbvdd2; | ||
2615 | } | ||
2616 | |||
2617 | ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), | 2515 | ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), |
2618 | wm5100->core_supplies); | 2516 | wm5100->core_supplies); |
2619 | if (ret != 0) { | 2517 | if (ret != 0) { |
2620 | dev_err(&i2c->dev, "Failed to enable core supplies: %d\n", | 2518 | dev_err(&i2c->dev, "Failed to enable core supplies: %d\n", |
2621 | ret); | 2519 | ret); |
2622 | goto err_dbvdd3; | 2520 | goto err_core; |
2623 | } | 2521 | } |
2624 | 2522 | ||
2625 | if (wm5100->pdata.ldo_ena) { | 2523 | if (wm5100->pdata.ldo_ena) { |
@@ -2788,12 +2686,6 @@ err_ldo: | |||
2788 | err_enable: | 2686 | err_enable: |
2789 | regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), | 2687 | regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), |
2790 | wm5100->core_supplies); | 2688 | wm5100->core_supplies); |
2791 | err_dbvdd3: | ||
2792 | regulator_put(wm5100->dbvdd3); | ||
2793 | err_dbvdd2: | ||
2794 | regulator_put(wm5100->dbvdd2); | ||
2795 | err_cpvdd: | ||
2796 | regulator_put(wm5100->cpvdd); | ||
2797 | err_core: | 2689 | err_core: |
2798 | regulator_bulk_free(ARRAY_SIZE(wm5100->core_supplies), | 2690 | regulator_bulk_free(ARRAY_SIZE(wm5100->core_supplies), |
2799 | wm5100->core_supplies); | 2691 | wm5100->core_supplies); |
@@ -2819,9 +2711,6 @@ static __devexit int wm5100_i2c_remove(struct i2c_client *i2c) | |||
2819 | gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); | 2711 | gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); |
2820 | gpio_free(wm5100->pdata.ldo_ena); | 2712 | gpio_free(wm5100->pdata.ldo_ena); |
2821 | } | 2713 | } |
2822 | regulator_put(wm5100->dbvdd3); | ||
2823 | regulator_put(wm5100->dbvdd2); | ||
2824 | regulator_put(wm5100->cpvdd); | ||
2825 | regulator_bulk_free(ARRAY_SIZE(wm5100->core_supplies), | 2714 | regulator_bulk_free(ARRAY_SIZE(wm5100->core_supplies), |
2826 | wm5100->core_supplies); | 2715 | wm5100->core_supplies); |
2827 | regmap_exit(wm5100->regmap); | 2716 | regmap_exit(wm5100->regmap); |