diff mbox

[3/7] iio: adc: stm32-dfsdm: fix clock source selection

Message ID 1519390261-25453-4-git-send-email-fabrice.gasnier@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fabrice Gasnier Feb. 23, 2018, 12:50 p.m. UTC
Add missing clock source selection. In case "audio" clock is provided,
it's unused currently: "dfsdm" clock is wrongly used by default.

Fixes: bed73904e76f ("IIO: ADC: add stm32 DFSDM core support")

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
 drivers/iio/adc/stm32-dfsdm-core.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron Feb. 24, 2018, 12:59 p.m. UTC | #1
On Fri, 23 Feb 2018 13:50:57 +0100
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:

> Add missing clock source selection. In case "audio" clock is provided,
> it's unused currently: "dfsdm" clock is wrongly used by default.
> 
> Fixes: bed73904e76f ("IIO: ADC: add stm32 DFSDM core support")
> 
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/stm32-dfsdm-core.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c
> index 0635f93..e50efdc 100644
> --- a/drivers/iio/adc/stm32-dfsdm-core.c
> +++ b/drivers/iio/adc/stm32-dfsdm-core.c
> @@ -83,7 +83,7 @@ int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm)
>  {
>  	struct dfsdm_priv *priv = container_of(dfsdm, struct dfsdm_priv, dfsdm);
>  	struct device *dev = &priv->pdev->dev;
> -	unsigned int clk_div = priv->spi_clk_out_div;
> +	unsigned int clk_div = priv->spi_clk_out_div, clk_src;
>  	int ret;
>  
>  	if (atomic_inc_return(&priv->n_active_ch) == 1) {
> @@ -100,6 +100,14 @@ int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm)
>  			}
>  		}
>  
> +		/* select clock source, e.g. 0 for "dfsdm" or 1 for "audio" */
> +		clk_src = priv->aclk ? 1 : 0;
> +		ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0),
> +					 DFSDM_CHCFGR1_CKOUTSRC_MASK,
> +					 DFSDM_CHCFGR1_CKOUTSRC(clk_src));
> +		if (ret < 0)
> +			goto disable_aclk;
> +
>  		/* Output the SPI CLKOUT (if clk_div == 0 clock if OFF) */
>  		ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0),
>  					 DFSDM_CHCFGR1_CKOUTDIV_MASK,

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c
index 0635f93..e50efdc 100644
--- a/drivers/iio/adc/stm32-dfsdm-core.c
+++ b/drivers/iio/adc/stm32-dfsdm-core.c
@@ -83,7 +83,7 @@  int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm)
 {
 	struct dfsdm_priv *priv = container_of(dfsdm, struct dfsdm_priv, dfsdm);
 	struct device *dev = &priv->pdev->dev;
-	unsigned int clk_div = priv->spi_clk_out_div;
+	unsigned int clk_div = priv->spi_clk_out_div, clk_src;
 	int ret;
 
 	if (atomic_inc_return(&priv->n_active_ch) == 1) {
@@ -100,6 +100,14 @@  int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm)
 			}
 		}
 
+		/* select clock source, e.g. 0 for "dfsdm" or 1 for "audio" */
+		clk_src = priv->aclk ? 1 : 0;
+		ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0),
+					 DFSDM_CHCFGR1_CKOUTSRC_MASK,
+					 DFSDM_CHCFGR1_CKOUTSRC(clk_src));
+		if (ret < 0)
+			goto disable_aclk;
+
 		/* Output the SPI CLKOUT (if clk_div == 0 clock if OFF) */
 		ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0),
 					 DFSDM_CHCFGR1_CKOUTDIV_MASK,