mirror of
https://github.com/torvalds/linux.git
synced 2026-06-02 03:24:19 +02:00
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
This commit is contained in:
commit
65613ac1b4
|
|
@ -45,6 +45,9 @@ properties:
|
|||
purpose of handling altmode muxing and orientation switching to detect and
|
||||
enable Audio Accessory Mode.
|
||||
|
||||
vdd-px-supply:
|
||||
description: A reference to the 1.2V PX supply
|
||||
|
||||
required:
|
||||
- compatible
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ struct wcd937x_priv {
|
|||
struct irq_domain *virq;
|
||||
struct regmap_irq_chip *wcd_regmap_irq_chip;
|
||||
struct regmap_irq_chip_data *irq_chip;
|
||||
struct regulator_bulk_data supplies[WCD937X_MAX_BULK_SUPPLY];
|
||||
struct snd_soc_jack *jack;
|
||||
unsigned long status_mask;
|
||||
s32 micb_ref[WCD937X_MAX_MICBIAS];
|
||||
|
|
@ -113,6 +112,10 @@ struct wcd937x_priv {
|
|||
atomic_t ana_clk_count;
|
||||
};
|
||||
|
||||
static const char * const wcd937x_supplies[] = {
|
||||
"vdd-rxtx", "vdd-px", "vdd-mic-bias", "vdd-buck",
|
||||
};
|
||||
|
||||
static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800);
|
||||
static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
|
||||
static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
|
||||
|
|
@ -2934,18 +2937,10 @@ static int wcd937x_probe(struct platform_device *pdev)
|
|||
cfg = &wcd937x->mbhc_cfg;
|
||||
cfg->swap_gnd_mic = wcd937x_swap_gnd_mic;
|
||||
|
||||
wcd937x->supplies[0].supply = "vdd-rxtx";
|
||||
wcd937x->supplies[1].supply = "vdd-px";
|
||||
wcd937x->supplies[2].supply = "vdd-mic-bias";
|
||||
wcd937x->supplies[3].supply = "vdd-buck";
|
||||
|
||||
ret = devm_regulator_bulk_get(dev, WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
|
||||
ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd937x_supplies),
|
||||
wcd937x_supplies);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "Failed to get supplies\n");
|
||||
|
||||
ret = regulator_bulk_enable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "Failed to enable supplies\n");
|
||||
return dev_err_probe(dev, ret, "Failed to get and enable supplies\n");
|
||||
|
||||
wcd937x_dt_parse_micbias_info(dev, wcd937x);
|
||||
|
||||
|
|
@ -2962,13 +2957,13 @@ static int wcd937x_probe(struct platform_device *pdev)
|
|||
|
||||
ret = wcd937x_add_slave_components(wcd937x, dev, &match);
|
||||
if (ret)
|
||||
goto err_disable_regulators;
|
||||
return ret;
|
||||
|
||||
wcd937x_reset(wcd937x);
|
||||
|
||||
ret = component_master_add_with_match(dev, &wcd937x_comp_ops, match);
|
||||
if (ret)
|
||||
goto err_disable_regulators;
|
||||
return ret;
|
||||
|
||||
pm_runtime_set_autosuspend_delay(dev, 1000);
|
||||
pm_runtime_use_autosuspend(dev);
|
||||
|
|
@ -2978,25 +2973,17 @@ static int wcd937x_probe(struct platform_device *pdev)
|
|||
pm_runtime_idle(dev);
|
||||
|
||||
return 0;
|
||||
|
||||
err_disable_regulators:
|
||||
regulator_bulk_disable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void wcd937x_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(dev);
|
||||
|
||||
component_master_del(&pdev->dev, &wcd937x_comp_ops);
|
||||
|
||||
pm_runtime_disable(dev);
|
||||
pm_runtime_set_suspended(dev);
|
||||
pm_runtime_dont_use_autosuspend(dev);
|
||||
|
||||
regulator_bulk_disable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_OF)
|
||||
|
|
|
|||
|
|
@ -487,7 +487,6 @@
|
|||
#define WCD937X_MAX_REGISTER (WCD937X_DIGITAL_EFUSE_REG_31)
|
||||
|
||||
#define WCD937X_MAX_MICBIAS 3
|
||||
#define WCD937X_MAX_BULK_SUPPLY 4
|
||||
#define WCD937X_MAX_SWR_CH_IDS 15
|
||||
#define WCD937X_SWRM_CH_MASK(ch_idx) BIT(ch_idx - 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include "wcd938x.h"
|
||||
|
||||
#define WCD938X_MAX_MICBIAS (4)
|
||||
#define WCD938X_MAX_SUPPLY (4)
|
||||
#define WCD938X_MBHC_MAX_BUTTONS (8)
|
||||
#define TX_ADC_MAX (4)
|
||||
|
||||
|
|
@ -161,7 +160,6 @@ struct wcd938x_priv {
|
|||
struct irq_domain *virq;
|
||||
struct regmap_irq_chip *wcd_regmap_irq_chip;
|
||||
struct regmap_irq_chip_data *irq_chip;
|
||||
struct regulator_bulk_data supplies[WCD938X_MAX_SUPPLY];
|
||||
struct snd_soc_jack *jack;
|
||||
unsigned long status_mask;
|
||||
s32 micb_ref[WCD938X_MAX_MICBIAS];
|
||||
|
|
@ -188,6 +186,10 @@ struct wcd938x_priv {
|
|||
bool mux_setup_done;
|
||||
};
|
||||
|
||||
static const char * const wcd938x_supplies[] = {
|
||||
"vdd-rxtx", "vdd-io", "vdd-buck", "vdd-mic-bias",
|
||||
};
|
||||
|
||||
static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800);
|
||||
static const DECLARE_TLV_DB_SCALE(line_gain, -3000, 150, 0);
|
||||
static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(analog_gain, 0, 3000);
|
||||
|
|
@ -3292,20 +3294,10 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device
|
|||
|
||||
cfg->swap_gnd_mic = wcd938x_swap_gnd_mic;
|
||||
|
||||
wcd938x->supplies[0].supply = "vdd-rxtx";
|
||||
wcd938x->supplies[1].supply = "vdd-io";
|
||||
wcd938x->supplies[2].supply = "vdd-buck";
|
||||
wcd938x->supplies[3].supply = "vdd-mic-bias";
|
||||
|
||||
ret = regulator_bulk_get(dev, WCD938X_MAX_SUPPLY, wcd938x->supplies);
|
||||
ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd938x_supplies),
|
||||
wcd938x_supplies);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "Failed to get supplies\n");
|
||||
|
||||
ret = regulator_bulk_enable(WCD938X_MAX_SUPPLY, wcd938x->supplies);
|
||||
if (ret) {
|
||||
regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies);
|
||||
return dev_err_probe(dev, ret, "Failed to enable supplies\n");
|
||||
}
|
||||
return dev_err_probe(dev, ret, "Failed to get and enable supplies\n");
|
||||
|
||||
wcd938x_dt_parse_micbias_info(dev, wcd938x);
|
||||
|
||||
|
|
@ -3569,13 +3561,13 @@ static int wcd938x_probe(struct platform_device *pdev)
|
|||
|
||||
ret = wcd938x_add_slave_components(wcd938x, dev, &match);
|
||||
if (ret)
|
||||
goto err_disable_regulators;
|
||||
return ret;
|
||||
|
||||
wcd938x_reset(wcd938x);
|
||||
|
||||
ret = component_master_add_with_match(dev, &wcd938x_comp_ops, match);
|
||||
if (ret)
|
||||
goto err_disable_regulators;
|
||||
return ret;
|
||||
|
||||
pm_runtime_set_autosuspend_delay(dev, 1000);
|
||||
pm_runtime_use_autosuspend(dev);
|
||||
|
|
@ -3585,12 +3577,6 @@ static int wcd938x_probe(struct platform_device *pdev)
|
|||
pm_runtime_idle(dev);
|
||||
|
||||
return 0;
|
||||
|
||||
err_disable_regulators:
|
||||
regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies);
|
||||
regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void wcd938x_remove(struct platform_device *pdev)
|
||||
|
|
@ -3606,9 +3592,6 @@ static void wcd938x_remove(struct platform_device *pdev)
|
|||
|
||||
if (wcd938x->us_euro_mux && wcd938x->mux_setup_done)
|
||||
mux_control_deselect(wcd938x->us_euro_mux);
|
||||
|
||||
regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies);
|
||||
regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_OF)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include "wcd939x.h"
|
||||
|
||||
#define WCD939X_MAX_MICBIAS (4)
|
||||
#define WCD939X_MAX_SUPPLY (4)
|
||||
#define WCD939X_MBHC_MAX_BUTTONS (8)
|
||||
#define TX_ADC_MAX (4)
|
||||
#define WCD_MBHC_HS_V_MAX 1600
|
||||
|
|
@ -192,7 +191,6 @@ struct wcd939x_priv {
|
|||
struct irq_domain *virq;
|
||||
struct regmap_irq_chip *wcd_regmap_irq_chip;
|
||||
struct regmap_irq_chip_data *irq_chip;
|
||||
struct regulator_bulk_data supplies[WCD939X_MAX_SUPPLY];
|
||||
struct snd_soc_jack *jack;
|
||||
unsigned long status_mask;
|
||||
s32 micb_ref[WCD939X_MAX_MICBIAS];
|
||||
|
|
@ -213,6 +211,10 @@ struct wcd939x_priv {
|
|||
bool ldoh;
|
||||
};
|
||||
|
||||
static const char * const wcd939x_supplies[] = {
|
||||
"vdd-rxtx", "vdd-io", "vdd-buck", "vdd-mic-bias", "vdd-px",
|
||||
};
|
||||
|
||||
static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800);
|
||||
static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
|
||||
static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
|
||||
|
|
@ -3239,25 +3241,14 @@ static int wcd939x_populate_dt_data(struct wcd939x_priv *wcd939x, struct device
|
|||
int ret;
|
||||
|
||||
wcd939x->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(wcd939x->reset_gpio)) {
|
||||
ret = PTR_ERR(wcd939x->reset_gpio);
|
||||
return dev_err_probe(dev, ret, "Failed to get reset gpio\n");
|
||||
}
|
||||
if (IS_ERR(wcd939x->reset_gpio))
|
||||
return dev_err_probe(dev, PTR_ERR(wcd939x->reset_gpio),
|
||||
"Failed to get reset gpio\n");
|
||||
|
||||
wcd939x->supplies[0].supply = "vdd-rxtx";
|
||||
wcd939x->supplies[1].supply = "vdd-io";
|
||||
wcd939x->supplies[2].supply = "vdd-buck";
|
||||
wcd939x->supplies[3].supply = "vdd-mic-bias";
|
||||
|
||||
ret = regulator_bulk_get(dev, WCD939X_MAX_SUPPLY, wcd939x->supplies);
|
||||
ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd939x_supplies),
|
||||
wcd939x_supplies);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "Failed to get supplies\n");
|
||||
|
||||
ret = regulator_bulk_enable(WCD939X_MAX_SUPPLY, wcd939x->supplies);
|
||||
if (ret) {
|
||||
regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies);
|
||||
return dev_err_probe(dev, ret, "Failed to enable supplies\n");
|
||||
}
|
||||
return dev_err_probe(dev, ret, "Failed to get and enable supplies\n");
|
||||
|
||||
wcd939x_dt_parse_micbias_info(dev, wcd939x);
|
||||
|
||||
|
|
@ -3629,17 +3620,17 @@ static int wcd939x_probe(struct platform_device *pdev)
|
|||
|
||||
ret = wcd939x_add_typec(wcd939x, dev);
|
||||
if (ret)
|
||||
goto err_disable_regulators;
|
||||
return ret;
|
||||
|
||||
ret = wcd939x_add_slave_components(wcd939x, dev, &match);
|
||||
if (ret)
|
||||
goto err_disable_regulators;
|
||||
return ret;
|
||||
|
||||
wcd939x_reset(wcd939x);
|
||||
|
||||
ret = component_master_add_with_match(dev, &wcd939x_comp_ops, match);
|
||||
if (ret)
|
||||
goto err_disable_regulators;
|
||||
return ret;
|
||||
|
||||
pm_runtime_set_autosuspend_delay(dev, 1000);
|
||||
pm_runtime_use_autosuspend(dev);
|
||||
|
|
@ -3649,27 +3640,17 @@ static int wcd939x_probe(struct platform_device *pdev)
|
|||
pm_runtime_idle(dev);
|
||||
|
||||
return 0;
|
||||
|
||||
err_disable_regulators:
|
||||
regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies);
|
||||
regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void wcd939x_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct wcd939x_priv *wcd939x = dev_get_drvdata(dev);
|
||||
|
||||
component_master_del(dev, &wcd939x_comp_ops);
|
||||
|
||||
pm_runtime_disable(dev);
|
||||
pm_runtime_set_suspended(dev);
|
||||
pm_runtime_dont_use_autosuspend(dev);
|
||||
|
||||
regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies);
|
||||
regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_OF)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user