Commit c1f5ded2 authored by Fabrice Gasnier's avatar Fabrice Gasnier Committed by Greg Kroah-Hartman

iio: adc: stm32-adc: add missing vdda-supply

commit 7685010f upstream.

Add missing vdda-supply, analog power supply, to STM32 ADC. When vdda is
an independent supply, it needs to be properly turned on or off to supply
the ADC.
Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@st.com>
Fixes: 1add6988 ("iio: adc: Add support for STM32 ADC core").
Cc: <Stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9edfd065
...@@ -87,6 +87,7 @@ struct stm32_adc_priv_cfg { ...@@ -87,6 +87,7 @@ struct stm32_adc_priv_cfg {
* @domain: irq domain reference * @domain: irq domain reference
* @aclk: clock reference for the analog circuitry * @aclk: clock reference for the analog circuitry
* @bclk: bus clock common for all ADCs, depends on part used * @bclk: bus clock common for all ADCs, depends on part used
* @vdda: vdda analog supply reference
* @vref: regulator reference * @vref: regulator reference
* @cfg: compatible configuration data * @cfg: compatible configuration data
* @common: common data for all ADC instances * @common: common data for all ADC instances
...@@ -97,6 +98,7 @@ struct stm32_adc_priv { ...@@ -97,6 +98,7 @@ struct stm32_adc_priv {
struct irq_domain *domain; struct irq_domain *domain;
struct clk *aclk; struct clk *aclk;
struct clk *bclk; struct clk *bclk;
struct regulator *vdda;
struct regulator *vref; struct regulator *vref;
const struct stm32_adc_priv_cfg *cfg; const struct stm32_adc_priv_cfg *cfg;
struct stm32_adc_common common; struct stm32_adc_common common;
...@@ -394,10 +396,16 @@ static int stm32_adc_core_hw_start(struct device *dev) ...@@ -394,10 +396,16 @@ static int stm32_adc_core_hw_start(struct device *dev)
struct stm32_adc_priv *priv = to_stm32_adc_priv(common); struct stm32_adc_priv *priv = to_stm32_adc_priv(common);
int ret; int ret;
ret = regulator_enable(priv->vdda);
if (ret < 0) {
dev_err(dev, "vdda enable failed %d\n", ret);
return ret;
}
ret = regulator_enable(priv->vref); ret = regulator_enable(priv->vref);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "vref enable failed\n"); dev_err(dev, "vref enable failed\n");
return ret; goto err_vdda_disable;
} }
if (priv->bclk) { if (priv->bclk) {
...@@ -425,6 +433,8 @@ static int stm32_adc_core_hw_start(struct device *dev) ...@@ -425,6 +433,8 @@ static int stm32_adc_core_hw_start(struct device *dev)
clk_disable_unprepare(priv->bclk); clk_disable_unprepare(priv->bclk);
err_regulator_disable: err_regulator_disable:
regulator_disable(priv->vref); regulator_disable(priv->vref);
err_vdda_disable:
regulator_disable(priv->vdda);
return ret; return ret;
} }
...@@ -441,6 +451,7 @@ static void stm32_adc_core_hw_stop(struct device *dev) ...@@ -441,6 +451,7 @@ static void stm32_adc_core_hw_stop(struct device *dev)
if (priv->bclk) if (priv->bclk)
clk_disable_unprepare(priv->bclk); clk_disable_unprepare(priv->bclk);
regulator_disable(priv->vref); regulator_disable(priv->vref);
regulator_disable(priv->vdda);
} }
static int stm32_adc_probe(struct platform_device *pdev) static int stm32_adc_probe(struct platform_device *pdev)
...@@ -468,6 +479,14 @@ static int stm32_adc_probe(struct platform_device *pdev) ...@@ -468,6 +479,14 @@ static int stm32_adc_probe(struct platform_device *pdev)
return PTR_ERR(priv->common.base); return PTR_ERR(priv->common.base);
priv->common.phys_base = res->start; priv->common.phys_base = res->start;
priv->vdda = devm_regulator_get(&pdev->dev, "vdda");
if (IS_ERR(priv->vdda)) {
ret = PTR_ERR(priv->vdda);
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "vdda get failed, %d\n", ret);
return ret;
}
priv->vref = devm_regulator_get(&pdev->dev, "vref"); priv->vref = devm_regulator_get(&pdev->dev, "vref");
if (IS_ERR(priv->vref)) { if (IS_ERR(priv->vref)) {
ret = PTR_ERR(priv->vref); ret = PTR_ERR(priv->vref);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment