Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: codecs: wcd93xx: Few simplifications of code and

Merge series from Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>:

Make the WCD93xx codec drivers simpler using
devm_regulator_bulk_get_enable() and obtain missing VDD_PX supply on
wcd939x.

Context depends on fixes:
https://lore.kernel.org/r/20250526-b4-b4-asoc-wcd9395-vdd-px-fixes-v1-0-0b8a2993b7d3@linaro.org

+34 -81
+3
Documentation/devicetree/bindings/sound/qcom,wcd939x.yaml
··· 45 45 purpose of handling altmode muxing and orientation switching to detect and 46 46 enable Audio Accessory Mode. 47 47 48 + vdd-px-supply: 49 + description: A reference to the 1.2V PX supply 50 + 48 51 required: 49 52 - compatible 50 53
+9 -22
sound/soc/codecs/wcd937x.c
··· 90 90 struct irq_domain *virq; 91 91 struct regmap_irq_chip *wcd_regmap_irq_chip; 92 92 struct regmap_irq_chip_data *irq_chip; 93 - struct regulator_bulk_data supplies[WCD937X_MAX_BULK_SUPPLY]; 94 93 struct snd_soc_jack *jack; 95 94 unsigned long status_mask; 96 95 s32 micb_ref[WCD937X_MAX_MICBIAS]; ··· 110 111 111 112 atomic_t rx_clk_cnt; 112 113 atomic_t ana_clk_count; 114 + }; 115 + 116 + static const char * const wcd937x_supplies[] = { 117 + "vdd-rxtx", "vdd-px", "vdd-mic-bias", "vdd-buck", 113 118 }; 114 119 115 120 static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800); ··· 2937 2934 cfg = &wcd937x->mbhc_cfg; 2938 2935 cfg->swap_gnd_mic = wcd937x_swap_gnd_mic; 2939 2936 2940 - wcd937x->supplies[0].supply = "vdd-rxtx"; 2941 - wcd937x->supplies[1].supply = "vdd-px"; 2942 - wcd937x->supplies[2].supply = "vdd-mic-bias"; 2943 - wcd937x->supplies[3].supply = "vdd-buck"; 2944 - 2945 - ret = devm_regulator_bulk_get(dev, WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies); 2937 + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd937x_supplies), 2938 + wcd937x_supplies); 2946 2939 if (ret) 2947 - return dev_err_probe(dev, ret, "Failed to get supplies\n"); 2948 - 2949 - ret = regulator_bulk_enable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies); 2950 - if (ret) 2951 - return dev_err_probe(dev, ret, "Failed to enable supplies\n"); 2940 + return dev_err_probe(dev, ret, "Failed to get and enable supplies\n"); 2952 2941 2953 2942 wcd937x_dt_parse_micbias_info(dev, wcd937x); 2954 2943 ··· 2957 2962 2958 2963 ret = wcd937x_add_slave_components(wcd937x, dev, &match); 2959 2964 if (ret) 2960 - goto err_disable_regulators; 2965 + return ret; 2961 2966 2962 2967 wcd937x_reset(wcd937x); 2963 2968 2964 2969 ret = component_master_add_with_match(dev, &wcd937x_comp_ops, match); 2965 2970 if (ret) 2966 - goto err_disable_regulators; 2971 + return ret; 2967 2972 2968 2973 pm_runtime_set_autosuspend_delay(dev, 1000); 2969 2974 pm_runtime_use_autosuspend(dev); ··· 2973 2978 pm_runtime_idle(dev); 2974 2979 2975 2980 return 0; 2976 - 2977 - err_disable_regulators: 2978 - regulator_bulk_disable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies); 2979 - 2980 - return ret; 2981 2981 } 2982 2982 2983 2983 static void wcd937x_remove(struct platform_device *pdev) 2984 2984 { 2985 2985 struct device *dev = &pdev->dev; 2986 - struct wcd937x_priv *wcd937x = dev_get_drvdata(dev); 2987 2986 2988 2987 component_master_del(&pdev->dev, &wcd937x_comp_ops); 2989 2988 2990 2989 pm_runtime_disable(dev); 2991 2990 pm_runtime_set_suspended(dev); 2992 2991 pm_runtime_dont_use_autosuspend(dev); 2993 - 2994 - regulator_bulk_disable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies); 2995 2992 } 2996 2993 2997 2994 #if defined(CONFIG_OF)
-1
sound/soc/codecs/wcd937x.h
··· 487 487 #define WCD937X_MAX_REGISTER (WCD937X_DIGITAL_EFUSE_REG_31) 488 488 489 489 #define WCD937X_MAX_MICBIAS 3 490 - #define WCD937X_MAX_BULK_SUPPLY 4 491 490 #define WCD937X_MAX_SWR_CH_IDS 15 492 491 #define WCD937X_SWRM_CH_MASK(ch_idx) BIT(ch_idx - 1) 493 492
+9 -26
sound/soc/codecs/wcd938x.c
··· 26 26 #include "wcd938x.h" 27 27 28 28 #define WCD938X_MAX_MICBIAS (4) 29 - #define WCD938X_MAX_SUPPLY (4) 30 29 #define WCD938X_MBHC_MAX_BUTTONS (8) 31 30 #define TX_ADC_MAX (4) 32 31 ··· 160 161 struct irq_domain *virq; 161 162 struct regmap_irq_chip *wcd_regmap_irq_chip; 162 163 struct regmap_irq_chip_data *irq_chip; 163 - struct regulator_bulk_data supplies[WCD938X_MAX_SUPPLY]; 164 164 struct snd_soc_jack *jack; 165 165 unsigned long status_mask; 166 166 s32 micb_ref[WCD938X_MAX_MICBIAS]; ··· 184 186 bool comp2_enable; 185 187 bool ldoh; 186 188 bool mux_setup_done; 189 + }; 190 + 191 + static const char * const wcd938x_supplies[] = { 192 + "vdd-rxtx", "vdd-io", "vdd-buck", "vdd-mic-bias", 187 193 }; 188 194 189 195 static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800); ··· 3294 3292 3295 3293 cfg->swap_gnd_mic = wcd938x_swap_gnd_mic; 3296 3294 3297 - wcd938x->supplies[0].supply = "vdd-rxtx"; 3298 - wcd938x->supplies[1].supply = "vdd-io"; 3299 - wcd938x->supplies[2].supply = "vdd-buck"; 3300 - wcd938x->supplies[3].supply = "vdd-mic-bias"; 3301 - 3302 - ret = regulator_bulk_get(dev, WCD938X_MAX_SUPPLY, wcd938x->supplies); 3295 + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd938x_supplies), 3296 + wcd938x_supplies); 3303 3297 if (ret) 3304 - return dev_err_probe(dev, ret, "Failed to get supplies\n"); 3305 - 3306 - ret = regulator_bulk_enable(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3307 - if (ret) { 3308 - regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3309 - return dev_err_probe(dev, ret, "Failed to enable supplies\n"); 3310 - } 3298 + return dev_err_probe(dev, ret, "Failed to get and enable supplies\n"); 3311 3299 3312 3300 wcd938x_dt_parse_micbias_info(dev, wcd938x); 3313 3301 ··· 3561 3569 3562 3570 ret = wcd938x_add_slave_components(wcd938x, dev, &match); 3563 3571 if (ret) 3564 - goto err_disable_regulators; 3572 + return ret; 3565 3573 3566 3574 wcd938x_reset(wcd938x); 3567 3575 3568 3576 ret = component_master_add_with_match(dev, &wcd938x_comp_ops, match); 3569 3577 if (ret) 3570 - goto err_disable_regulators; 3578 + return ret; 3571 3579 3572 3580 pm_runtime_set_autosuspend_delay(dev, 1000); 3573 3581 pm_runtime_use_autosuspend(dev); ··· 3577 3585 pm_runtime_idle(dev); 3578 3586 3579 3587 return 0; 3580 - 3581 - err_disable_regulators: 3582 - regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3583 - regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3584 - 3585 - return ret; 3586 3588 } 3587 3589 3588 3590 static void wcd938x_remove(struct platform_device *pdev) ··· 3592 3606 3593 3607 if (wcd938x->us_euro_mux && wcd938x->mux_setup_done) 3594 3608 mux_control_deselect(wcd938x->us_euro_mux); 3595 - 3596 - regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3597 - regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3598 3609 } 3599 3610 3600 3611 #if defined(CONFIG_OF)
+13 -32
sound/soc/codecs/wcd939x.c
··· 32 32 #include "wcd939x.h" 33 33 34 34 #define WCD939X_MAX_MICBIAS (4) 35 - #define WCD939X_MAX_SUPPLY (4) 36 35 #define WCD939X_MBHC_MAX_BUTTONS (8) 37 36 #define TX_ADC_MAX (4) 38 37 #define WCD_MBHC_HS_V_MAX 1600 ··· 191 192 struct irq_domain *virq; 192 193 struct regmap_irq_chip *wcd_regmap_irq_chip; 193 194 struct regmap_irq_chip_data *irq_chip; 194 - struct regulator_bulk_data supplies[WCD939X_MAX_SUPPLY]; 195 195 struct snd_soc_jack *jack; 196 196 unsigned long status_mask; 197 197 s32 micb_ref[WCD939X_MAX_MICBIAS]; ··· 209 211 bool comp1_enable; 210 212 bool comp2_enable; 211 213 bool ldoh; 214 + }; 215 + 216 + static const char * const wcd939x_supplies[] = { 217 + "vdd-rxtx", "vdd-io", "vdd-buck", "vdd-mic-bias", "vdd-px", 212 218 }; 213 219 214 220 static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800); ··· 3241 3239 int ret; 3242 3240 3243 3241 wcd939x->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); 3244 - if (IS_ERR(wcd939x->reset_gpio)) { 3245 - ret = PTR_ERR(wcd939x->reset_gpio); 3246 - return dev_err_probe(dev, ret, "Failed to get reset gpio\n"); 3247 - } 3242 + if (IS_ERR(wcd939x->reset_gpio)) 3243 + return dev_err_probe(dev, PTR_ERR(wcd939x->reset_gpio), 3244 + "Failed to get reset gpio\n"); 3248 3245 3249 - wcd939x->supplies[0].supply = "vdd-rxtx"; 3250 - wcd939x->supplies[1].supply = "vdd-io"; 3251 - wcd939x->supplies[2].supply = "vdd-buck"; 3252 - wcd939x->supplies[3].supply = "vdd-mic-bias"; 3253 - 3254 - ret = regulator_bulk_get(dev, WCD939X_MAX_SUPPLY, wcd939x->supplies); 3246 + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd939x_supplies), 3247 + wcd939x_supplies); 3255 3248 if (ret) 3256 - return dev_err_probe(dev, ret, "Failed to get supplies\n"); 3257 - 3258 - ret = regulator_bulk_enable(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3259 - if (ret) { 3260 - regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3261 - return dev_err_probe(dev, ret, "Failed to enable supplies\n"); 3262 - } 3249 + return dev_err_probe(dev, ret, "Failed to get and enable supplies\n"); 3263 3250 3264 3251 wcd939x_dt_parse_micbias_info(dev, wcd939x); 3265 3252 ··· 3620 3629 3621 3630 ret = wcd939x_add_typec(wcd939x, dev); 3622 3631 if (ret) 3623 - goto err_disable_regulators; 3632 + return ret; 3624 3633 3625 3634 ret = wcd939x_add_slave_components(wcd939x, dev, &match); 3626 3635 if (ret) 3627 - goto err_disable_regulators; 3636 + return ret; 3628 3637 3629 3638 wcd939x_reset(wcd939x); 3630 3639 3631 3640 ret = component_master_add_with_match(dev, &wcd939x_comp_ops, match); 3632 3641 if (ret) 3633 - goto err_disable_regulators; 3642 + return ret; 3634 3643 3635 3644 pm_runtime_set_autosuspend_delay(dev, 1000); 3636 3645 pm_runtime_use_autosuspend(dev); ··· 3640 3649 pm_runtime_idle(dev); 3641 3650 3642 3651 return 0; 3643 - 3644 - err_disable_regulators: 3645 - regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3646 - regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3647 - 3648 - return ret; 3649 3652 } 3650 3653 3651 3654 static void wcd939x_remove(struct platform_device *pdev) 3652 3655 { 3653 3656 struct device *dev = &pdev->dev; 3654 - struct wcd939x_priv *wcd939x = dev_get_drvdata(dev); 3655 3657 3656 3658 component_master_del(dev, &wcd939x_comp_ops); 3657 3659 3658 3660 pm_runtime_disable(dev); 3659 3661 pm_runtime_set_suspended(dev); 3660 3662 pm_runtime_dont_use_autosuspend(dev); 3661 - 3662 - regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3663 - regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3664 3663 } 3665 3664 3666 3665 #if defined(CONFIG_OF)