devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	mcoquelin.stm32-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	alexandre.torgue-qxv4g6HH51o@public.gmane.org,
	lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org,
	knaack.h-Mmb7MZpHnFY@public.gmane.org,
	pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org,
	benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	benjamin.gaignard-qxv4g6HH51o@public.gmane.org,
	linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 3/4] iio: dac: stm32: add support for stm32f4
Date: Mon, 10 Jul 2017 21:54:53 +0100	[thread overview]
Message-ID: <20170710215453.057afa22@kernel.org> (raw)
In-Reply-To: <1499693040-12994-4-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>

On Mon, 10 Jul 2017 15:23:59 +0200
Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org> wrote:

> This adds support for STM32F4 Digital-To-Analog converter.
> Add compatible configuration data to handle hfsel (not present
> in stm32f4).
> 
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
Hmm. I thought for a bit on whether I wanted to see data for the other
part as well to act as documentation.
Whilst that would have been fine, I came to the conclusion this is fine
as well.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to time out on (not sure what is going on there
at the moment but 0day has been struggling for a few days!)

Jonathan
> ---
>  drivers/iio/dac/stm32-dac-core.c | 38 +++++++++++++++++++++++++++++++-------
>  1 file changed, 31 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/dac/stm32-dac-core.c b/drivers/iio/dac/stm32-dac-core.c
> index 75e4878..32701be 100644
> --- a/drivers/iio/dac/stm32-dac-core.c
> +++ b/drivers/iio/dac/stm32-dac-core.c
> @@ -42,6 +42,14 @@ struct stm32_dac_priv {
>  	struct stm32_dac_common common;
>  };
>  
> +/**
> + * struct stm32_dac_cfg - DAC configuration
> + * @has_hfsel: DAC has high frequency control
> + */
> +struct stm32_dac_cfg {
> +	bool has_hfsel;
> +};
> +
>  static struct stm32_dac_priv *to_stm32_dac_priv(struct stm32_dac_common *com)
>  {
>  	return container_of(com, struct stm32_dac_priv, common);
> @@ -57,6 +65,7 @@ static struct stm32_dac_priv *to_stm32_dac_priv(struct stm32_dac_common *com)
>  static int stm32_dac_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> +	const struct stm32_dac_cfg *cfg;
>  	struct stm32_dac_priv *priv;
>  	struct regmap *regmap;
>  	struct resource *res;
> @@ -69,6 +78,8 @@ static int stm32_dac_probe(struct platform_device *pdev)
>  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
>  		return -ENOMEM;
> +	cfg = (const struct stm32_dac_cfg *)
> +		of_match_device(dev->driver->of_match_table, dev)->data;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	mmio = devm_ioremap_resource(dev, res);
> @@ -121,12 +132,16 @@ static int stm32_dac_probe(struct platform_device *pdev)
>  		reset_control_deassert(priv->rst);
>  	}
>  
> -	/* When clock speed is higher than 80MHz, set HFSEL */
> -	priv->common.hfsel = (clk_get_rate(priv->pclk) > 80000000UL);
> -	ret = regmap_update_bits(regmap, STM32_DAC_CR, STM32H7_DAC_CR_HFSEL,
> -				 priv->common.hfsel ? STM32H7_DAC_CR_HFSEL : 0);
> -	if (ret)
> -		goto err_pclk;
> +	if (cfg && cfg->has_hfsel) {
> +		/* When clock speed is higher than 80MHz, set HFSEL */
> +		priv->common.hfsel = (clk_get_rate(priv->pclk) > 80000000UL);
> +		ret = regmap_update_bits(regmap, STM32_DAC_CR,
> +					 STM32H7_DAC_CR_HFSEL,
> +					 priv->common.hfsel ?
> +					 STM32H7_DAC_CR_HFSEL : 0);
> +		if (ret)
> +			goto err_pclk;
> +	}
>  
>  	platform_set_drvdata(pdev, &priv->common);
>  
> @@ -158,8 +173,17 @@ static int stm32_dac_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static const struct stm32_dac_cfg stm32h7_dac_cfg = {
> +	.has_hfsel = true,
> +};
> +
>  static const struct of_device_id stm32_dac_of_match[] = {
> -	{ .compatible = "st,stm32h7-dac-core", },
> +	{
> +		.compatible = "st,stm32f4-dac-core",
> +	}, {
> +		.compatible = "st,stm32h7-dac-core",
> +		.data = (void *)&stm32h7_dac_cfg,
> +	},
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, stm32_dac_of_match);

  parent reply	other threads:[~2017-07-10 20:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10 13:23 [PATCH 0/4] Add support for STM32F4 DAC Fabrice Gasnier
2017-07-10 13:23 ` [PATCH 1/4] dt-bindings: iio: stm32-dac: add support for STM32F4 Fabrice Gasnier
     [not found]   ` <1499693040-12994-2-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-07-10 20:51     ` Jonathan Cameron
2017-07-14 14:41     ` Rob Herring
2017-07-10 13:23 ` [PATCH 2/4] iio: dac: stm32: fix error message Fabrice Gasnier
     [not found]   ` <1499693040-12994-3-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-07-10 20:51     ` Jonathan Cameron
     [not found] ` <1499693040-12994-1-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-07-10 13:23   ` [PATCH 3/4] iio: dac: stm32: add support for stm32f4 Fabrice Gasnier
     [not found]     ` <1499693040-12994-4-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-07-10 20:54       ` Jonathan Cameron [this message]
2017-07-10 13:24 ` [PATCH 4/4] ARM: dts: stm32: Add DAC support on stm32f429 Fabrice Gasnier
     [not found]   ` <1499693040-12994-5-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2017-07-10 20:56     ` Jonathan Cameron
2017-07-27  7:29   ` Alexandre Torgue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170710215453.057afa22@kernel.org \
    --to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=alexandre.torgue-qxv4g6HH51o@public.gmane.org \
    --cc=benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=benjamin.gaignard-qxv4g6HH51o@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=fabrice.gasnier-qxv4g6HH51o@public.gmane.org \
    --cc=knaack.h-Mmb7MZpHnFY@public.gmane.org \
    --cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
    --cc=linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=mcoquelin.stm32-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).