@@ -869,37 +869,6 @@ static int wcd937x_enable_rx3(struct snd_soc_dapm_widget *w,
869869 return 0 ;
870870}
871871
872- static int wcd937x_codec_enable_vdd_buck (struct snd_soc_dapm_widget * w ,
873- struct snd_kcontrol * kcontrol ,
874- int event )
875- {
876- struct snd_soc_component * component = snd_soc_dapm_to_component (w -> dapm );
877- struct wcd937x_priv * wcd937x = snd_soc_component_get_drvdata (component );
878- int ret = 0 ;
879-
880- switch (event ) {
881- case SND_SOC_DAPM_PRE_PMU :
882- if (test_bit (ALLOW_BUCK_DISABLE , & wcd937x -> status_mask )) {
883- dev_err (component -> dev , "buck already in enabled state\n" );
884- clear_bit (ALLOW_BUCK_DISABLE , & wcd937x -> status_mask );
885- return 0 ;
886- }
887- ret = regulator_enable (wcd937x -> buck_supply );
888- if (ret ) {
889- dev_err (component -> dev , "VDD_BUCK is not enabled\n" );
890- return ret ;
891- }
892- clear_bit (ALLOW_BUCK_DISABLE , & wcd937x -> status_mask );
893- usleep_range (200 , 250 );
894- break ;
895- case SND_SOC_DAPM_POST_PMD :
896- set_bit (ALLOW_BUCK_DISABLE , & wcd937x -> status_mask );
897- break ;
898- }
899-
900- return 0 ;
901- }
902-
903872static int wcd937x_get_micb_vout_ctl_val (u32 micb_mv )
904873{
905874 if (micb_mv < 1000 || micb_mv > 2850 ) {
@@ -1164,16 +1133,7 @@ static int __wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w,
11641133 int event )
11651134{
11661135 struct snd_soc_component * component = snd_soc_dapm_to_component (w -> dapm );
1167- int micb_num ;
1168-
1169- if (strnstr (w -> name , "MIC BIAS1" , sizeof ("MIC BIAS1" )))
1170- micb_num = MIC_BIAS_1 ;
1171- else if (strnstr (w -> name , "MIC BIAS2" , sizeof ("MIC BIAS2" )))
1172- micb_num = MIC_BIAS_2 ;
1173- else if (strnstr (w -> name , "MIC BIAS3" , sizeof ("MIC BIAS3" )))
1174- micb_num = MIC_BIAS_3 ;
1175- else
1176- return - EINVAL ;
1136+ int micb_num = w -> shift ;
11771137
11781138 switch (event ) {
11791139 case SND_SOC_DAPM_PRE_PMU :
@@ -1203,16 +1163,7 @@ static int __wcd937x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w,
12031163 int event )
12041164{
12051165 struct snd_soc_component * component = snd_soc_dapm_to_component (w -> dapm );
1206- int micb_num ;
1207-
1208- if (strnstr (w -> name , "VA MIC BIAS1" , sizeof ("VA MIC BIAS1" )))
1209- micb_num = MIC_BIAS_1 ;
1210- else if (strnstr (w -> name , "VA MIC BIAS2" , sizeof ("VA MIC BIAS2" )))
1211- micb_num = MIC_BIAS_2 ;
1212- else if (strnstr (w -> name , "VA MIC BIAS3" , sizeof ("VA MIC BIAS3" )))
1213- micb_num = MIC_BIAS_3 ;
1214- else
1215- return - EINVAL ;
1166+ int micb_num = w -> shift ;
12161167
12171168 switch (event ) {
12181169 case SND_SOC_DAPM_PRE_PMU :
@@ -2231,23 +2182,20 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
22312182 SND_SOC_DAPM_POST_PMD ),
22322183
22332184 /* MIC_BIAS widgets */
2234- SND_SOC_DAPM_SUPPLY ("MIC BIAS1" , SND_SOC_NOPM , 0 , 0 ,
2185+ SND_SOC_DAPM_SUPPLY ("MIC BIAS1" , SND_SOC_NOPM , MIC_BIAS_1 , 0 ,
22352186 wcd937x_codec_enable_micbias ,
22362187 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
22372188 SND_SOC_DAPM_POST_PMD ),
2238- SND_SOC_DAPM_SUPPLY ("MIC BIAS2" , SND_SOC_NOPM , 0 , 0 ,
2189+ SND_SOC_DAPM_SUPPLY ("MIC BIAS2" , SND_SOC_NOPM , MIC_BIAS_2 , 0 ,
22392190 wcd937x_codec_enable_micbias ,
22402191 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
22412192 SND_SOC_DAPM_POST_PMD ),
2242- SND_SOC_DAPM_SUPPLY ("MIC BIAS3" , SND_SOC_NOPM , 0 , 0 ,
2193+ SND_SOC_DAPM_SUPPLY ("MIC BIAS3" , SND_SOC_NOPM , MIC_BIAS_3 , 0 ,
22432194 wcd937x_codec_enable_micbias ,
22442195 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
22452196 SND_SOC_DAPM_POST_PMD ),
22462197
2247- SND_SOC_DAPM_SUPPLY ("VDD_BUCK" , SND_SOC_NOPM , 0 , 0 ,
2248- wcd937x_codec_enable_vdd_buck ,
2249- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD ),
2250-
2198+ SND_SOC_DAPM_SUPPLY ("VDD_BUCK" , SND_SOC_NOPM , 0 , 0 , NULL , 0 ),
22512199 SND_SOC_DAPM_SUPPLY_S ("CLS_H_PORT" , 1 , SND_SOC_NOPM , 0 , 0 , NULL , 0 ),
22522200
22532201 /* RX widgets */
@@ -2320,15 +2268,15 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
23202268 SND_SOC_DAPM_OUTPUT ("HPHR" ),
23212269
23222270 /* MIC_BIAS pull up widgets */
2323- SND_SOC_DAPM_SUPPLY ("VA MIC BIAS1" , SND_SOC_NOPM , 0 , 0 ,
2271+ SND_SOC_DAPM_SUPPLY ("VA MIC BIAS1" , SND_SOC_NOPM , MIC_BIAS_1 , 0 ,
23242272 wcd937x_codec_enable_micbias_pullup ,
23252273 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
23262274 SND_SOC_DAPM_POST_PMD ),
2327- SND_SOC_DAPM_SUPPLY ("VA MIC BIAS2" , SND_SOC_NOPM , 0 , 0 ,
2275+ SND_SOC_DAPM_SUPPLY ("VA MIC BIAS2" , SND_SOC_NOPM , MIC_BIAS_2 , 0 ,
23282276 wcd937x_codec_enable_micbias_pullup ,
23292277 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
23302278 SND_SOC_DAPM_POST_PMD ),
2331- SND_SOC_DAPM_SUPPLY ("VA MIC BIAS3" , SND_SOC_NOPM , 0 , 0 ,
2279+ SND_SOC_DAPM_SUPPLY ("VA MIC BIAS3" , SND_SOC_NOPM , MIC_BIAS_3 , 0 ,
23322280 wcd937x_codec_enable_micbias_pullup ,
23332281 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
23342282 SND_SOC_DAPM_POST_PMD ),
@@ -2933,24 +2881,17 @@ static int wcd937x_probe(struct platform_device *pdev)
29332881 wcd937x -> supplies [0 ].supply = "vdd-rxtx" ;
29342882 wcd937x -> supplies [1 ].supply = "vdd-px" ;
29352883 wcd937x -> supplies [2 ].supply = "vdd-mic-bias" ;
2884+ wcd937x -> supplies [3 ].supply = "vdd-buck" ;
29362885
29372886 ret = devm_regulator_bulk_get (dev , WCD937X_MAX_BULK_SUPPLY , wcd937x -> supplies );
29382887 if (ret )
29392888 return dev_err_probe (dev , ret , "Failed to get supplies\n" );
29402889
29412890 ret = regulator_bulk_enable (WCD937X_MAX_BULK_SUPPLY , wcd937x -> supplies );
2942- if (ret )
2891+ if (ret ) {
2892+ regulator_bulk_free (WCD937X_MAX_BULK_SUPPLY , wcd937x -> supplies );
29432893 return dev_err_probe (dev , ret , "Failed to enable supplies\n" );
2944-
2945- /* Get the buck separately, as it needs special handling */
2946- wcd937x -> buck_supply = devm_regulator_get (dev , "vdd-buck" );
2947- if (IS_ERR (wcd937x -> buck_supply ))
2948- return dev_err_probe (dev , PTR_ERR (wcd937x -> buck_supply ),
2949- "Failed to get buck supply\n" );
2950-
2951- ret = regulator_enable (wcd937x -> buck_supply );
2952- if (ret )
2953- return dev_err_probe (dev , ret , "Failed to enable buck supply\n" );
2894+ }
29542895
29552896 wcd937x_dt_parse_micbias_info (dev , wcd937x );
29562897
@@ -2967,13 +2908,13 @@ static int wcd937x_probe(struct platform_device *pdev)
29672908
29682909 ret = wcd937x_add_slave_components (wcd937x , dev , & match );
29692910 if (ret )
2970- return ret ;
2911+ goto err_disable_regulators ;
29712912
29722913 wcd937x_reset (wcd937x );
29732914
29742915 ret = component_master_add_with_match (dev , & wcd937x_comp_ops , match );
29752916 if (ret )
2976- return ret ;
2917+ goto err_disable_regulators ;
29772918
29782919 pm_runtime_set_autosuspend_delay (dev , 1000 );
29792920 pm_runtime_use_autosuspend (dev );
@@ -2982,6 +2923,12 @@ static int wcd937x_probe(struct platform_device *pdev)
29822923 pm_runtime_enable (dev );
29832924 pm_runtime_idle (dev );
29842925
2926+ return 0 ;
2927+
2928+ err_disable_regulators :
2929+ regulator_bulk_disable (WCD937X_MAX_BULK_SUPPLY , wcd937x -> supplies );
2930+ regulator_bulk_free (WCD937X_MAX_BULK_SUPPLY , wcd937x -> supplies );
2931+
29852932 return ret ;
29862933}
29872934
0 commit comments