@@ -869,37 +869,6 @@ static int wcd937x_enable_rx3(struct snd_soc_dapm_widget *w,
869
869
return 0 ;
870
870
}
871
871
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
-
903
872
static int wcd937x_get_micb_vout_ctl_val (u32 micb_mv )
904
873
{
905
874
if (micb_mv < 1000 || micb_mv > 2850 ) {
@@ -1164,16 +1133,7 @@ static int __wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w,
1164
1133
int event )
1165
1134
{
1166
1135
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 ;
1177
1137
1178
1138
switch (event ) {
1179
1139
case SND_SOC_DAPM_PRE_PMU :
@@ -1203,16 +1163,7 @@ static int __wcd937x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w,
1203
1163
int event )
1204
1164
{
1205
1165
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 ;
1216
1167
1217
1168
switch (event ) {
1218
1169
case SND_SOC_DAPM_PRE_PMU :
@@ -2231,23 +2182,20 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
2231
2182
SND_SOC_DAPM_POST_PMD ),
2232
2183
2233
2184
/* 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 ,
2235
2186
wcd937x_codec_enable_micbias ,
2236
2187
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
2237
2188
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 ,
2239
2190
wcd937x_codec_enable_micbias ,
2240
2191
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
2241
2192
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 ,
2243
2194
wcd937x_codec_enable_micbias ,
2244
2195
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
2245
2196
SND_SOC_DAPM_POST_PMD ),
2246
2197
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 ),
2251
2199
SND_SOC_DAPM_SUPPLY_S ("CLS_H_PORT" , 1 , SND_SOC_NOPM , 0 , 0 , NULL , 0 ),
2252
2200
2253
2201
/* RX widgets */
@@ -2320,15 +2268,15 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
2320
2268
SND_SOC_DAPM_OUTPUT ("HPHR" ),
2321
2269
2322
2270
/* 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 ,
2324
2272
wcd937x_codec_enable_micbias_pullup ,
2325
2273
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
2326
2274
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 ,
2328
2276
wcd937x_codec_enable_micbias_pullup ,
2329
2277
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
2330
2278
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 ,
2332
2280
wcd937x_codec_enable_micbias_pullup ,
2333
2281
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
2334
2282
SND_SOC_DAPM_POST_PMD ),
@@ -2933,24 +2881,17 @@ static int wcd937x_probe(struct platform_device *pdev)
2933
2881
wcd937x -> supplies [0 ].supply = "vdd-rxtx" ;
2934
2882
wcd937x -> supplies [1 ].supply = "vdd-px" ;
2935
2883
wcd937x -> supplies [2 ].supply = "vdd-mic-bias" ;
2884
+ wcd937x -> supplies [3 ].supply = "vdd-buck" ;
2936
2885
2937
2886
ret = devm_regulator_bulk_get (dev , WCD937X_MAX_BULK_SUPPLY , wcd937x -> supplies );
2938
2887
if (ret )
2939
2888
return dev_err_probe (dev , ret , "Failed to get supplies\n" );
2940
2889
2941
2890
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 );
2943
2893
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
+ }
2954
2895
2955
2896
wcd937x_dt_parse_micbias_info (dev , wcd937x );
2956
2897
@@ -2967,13 +2908,13 @@ static int wcd937x_probe(struct platform_device *pdev)
2967
2908
2968
2909
ret = wcd937x_add_slave_components (wcd937x , dev , & match );
2969
2910
if (ret )
2970
- return ret ;
2911
+ goto err_disable_regulators ;
2971
2912
2972
2913
wcd937x_reset (wcd937x );
2973
2914
2974
2915
ret = component_master_add_with_match (dev , & wcd937x_comp_ops , match );
2975
2916
if (ret )
2976
- return ret ;
2917
+ goto err_disable_regulators ;
2977
2918
2978
2919
pm_runtime_set_autosuspend_delay (dev , 1000 );
2979
2920
pm_runtime_use_autosuspend (dev );
@@ -2982,6 +2923,12 @@ static int wcd937x_probe(struct platform_device *pdev)
2982
2923
pm_runtime_enable (dev );
2983
2924
pm_runtime_idle (dev );
2984
2925
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
+
2985
2932
return ret ;
2986
2933
}
2987
2934
0 commit comments