linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Ferre <nicolas.ferre-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
To: Romain Izard
	<romain.izard.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Boris Brezillon
	<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Michael Turquette
	<mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>,
	Stephen Boyd <sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Ludovic Desroches
	<ludovic.desroches-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>,
	Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Wenyou Yang <wenyou.yang-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>,
	Josh Wu <rainyfeeling-1ViLX0X+lBJBDgjK7y7TUQ@public.gmane.org>,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Brian Norris
	<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Marek Vasut <marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Cyrille Pitchen
	<cyrille.pitchen-yU5RGvR974pGWvitb5QawA@public.gmane.org>,
	Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Richard Genoud
	<richard.genoud-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	Alan Stern
	<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
	Eugen Hristev
	<Eugen.Hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
Cc: linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH v1 07/10] iio:adc:at91-sama5d2: Support backup mode
Date: Fri, 8 Sep 2017 18:03:23 +0200	[thread overview]
Message-ID: <760d7c25-afa4-2242-a278-e0989bca5478@microchip.com> (raw)
In-Reply-To: <20170908153604.28383-8-romain.izard.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On 08/09/2017 at 17:36, Romain Izard wrote:
> Support the backup mode for platform suspend, by restoring the hardware
> registers on resume.
> 
> Signed-off-by: Romain Izard <romain.izard.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Romain,

Thanks for your series: definitively some of your patches need to be
integrated (I've merged some of them in our current linux-4.9-at91 branch.
However, It seems that some of your additions have already been
submitted and/or accepted by maintainers.
For instance an equivalent of this one seems already in Linus' tree:
500a2eefd6b16ba141a8fb777ea6962d2eb65e3b ("iio: adc: at91-sama5d2_adc:
add support for suspend/resume functionality").

Please tell us if it fits what your observed on this driver (or others).

Regards,

> ---
>  drivers/iio/adc/at91-sama5d2_adc.c | 71 ++++++++++++++++++++++++++++++++------
>  1 file changed, 61 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
> index e10dca3ed74b..f9718c863363 100644
> --- a/drivers/iio/adc/at91-sama5d2_adc.c
> +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> @@ -200,6 +200,7 @@ struct at91_adc_state {
>  	u32				conversion_value;
>  	struct at91_adc_soc_info	soc_info;
>  	wait_queue_head_t		wq_data_available;
> +	unsigned int			current_rate;
>  	/*
>  	 * lock to prevent concurrent 'single conversion' requests through
>  	 * sysfs.
> @@ -269,6 +270,8 @@ static void at91_adc_setup_samp_freq(struct at91_adc_state *st, unsigned freq)
>  	mr |= AT91_SAMA5D2_MR_PRESCAL(prescal);
>  	at91_adc_writel(st, AT91_SAMA5D2_MR, mr);
>  
> +	st->current_rate = freq;
> +
>  	dev_dbg(&indio_dev->dev, "freq: %u, startup: %u, prescal: %u\n",
>  		freq, startup, prescal);
>  }
> @@ -375,7 +378,9 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev,
>  	    val > st->soc_info.max_sample_rate)
>  		return -EINVAL;
>  
> +	mutex_lock(&st->lock);
>  	at91_adc_setup_samp_freq(st, val);
> +	mutex_unlock(&st->lock);
>  
>  	return 0;
>  }
> @@ -386,6 +391,21 @@ static const struct iio_info at91_adc_info = {
>  	.driver_module = THIS_MODULE,
>  };
>  
> +static void at91_adc_init_hw(struct at91_adc_state *st, unsigned int freq)
> +{
> +	at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
> +	at91_adc_writel(st, AT91_SAMA5D2_IDR, 0xffffffff);
> +	/*
> +	 * Transfer field must be set to 2 according to the datasheet and
> +	 * allows different analog settings for each channel.
> +	 */
> +	at91_adc_writel(st, AT91_SAMA5D2_MR,
> +			AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
> +
> +	at91_adc_setup_samp_freq(st, freq);
> +
> +}
> +
>  static int at91_adc_probe(struct platform_device *pdev)
>  {
>  	struct iio_dev *indio_dev;
> @@ -482,16 +502,7 @@ static int at91_adc_probe(struct platform_device *pdev)
>  		goto vref_disable;
>  	}
>  
> -	at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
> -	at91_adc_writel(st, AT91_SAMA5D2_IDR, 0xffffffff);
> -	/*
> -	 * Transfer field must be set to 2 according to the datasheet and
> -	 * allows different analog settings for each channel.
> -	 */
> -	at91_adc_writel(st, AT91_SAMA5D2_MR,
> -			AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
> -
> -	at91_adc_setup_samp_freq(st, st->soc_info.min_sample_rate);
> +	at91_adc_init_hw(st, st->soc_info.min_sample_rate);
>  
>  	ret = clk_prepare_enable(st->per_clk);
>  	if (ret)
> @@ -541,12 +552,52 @@ static const struct of_device_id at91_adc_dt_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, at91_adc_dt_match);
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int at91_adc_suspend(struct device *dev)
> +{
> +	struct platform_device *pdev = to_platform_device(dev);
> +	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +	struct at91_adc_state *st = iio_priv(indio_dev);
> +
> +	clk_disable_unprepare(st->per_clk);
> +
> +	regulator_disable(st->vref);
> +	regulator_disable(st->reg);
> +
> +	return 0;
> +}
> +
> +static int at91_adc_resume(struct device *dev)
> +{
> +	struct platform_device *pdev = to_platform_device(dev);
> +	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +	struct at91_adc_state *st = iio_priv(indio_dev);
> +	int err;
> +
> +	err = regulator_enable(st->reg);
> +	if (err)
> +		return err;
> +
> +	err = regulator_enable(st->vref);
> +	if (err)
> +		return err;
> +
> +	at91_adc_init_hw(st, st->current_rate);
> +
> +	err = clk_prepare_enable(st->per_clk);
> +	return err;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
> +
>  static struct platform_driver at91_adc_driver = {
>  	.probe = at91_adc_probe,
>  	.remove = at91_adc_remove,
>  	.driver = {
>  		.name = "at91-sama5d2_adc",
>  		.of_match_table = at91_adc_dt_match,
> +		.pm = &at91_adc_pm_ops,
>  	},
>  };
>  module_platform_driver(at91_adc_driver)
> 


-- 
Nicolas Ferre

  parent reply	other threads:[~2017-09-08 16:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-08 15:35 [PATCH v1 00/10] Various patches for SAMA5D2 backup mode Romain Izard
2017-09-08 15:35 ` [PATCH v1 01/10] clk: at91: pmc: Wait for clocks when resuming Romain Izard
2017-09-13 12:15   ` Nicolas Ferre
2017-09-14 16:15     ` Romain Izard
2017-09-22 12:12       ` Nicolas Ferre
2017-09-08 15:35 ` [PATCH v1 02/10] clk: at91: pmc: Save SCSR during suspend Romain Izard
     [not found]   ` <20170908153604.28383-3-romain.izard.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-13 12:10     ` Nicolas Ferre
2017-09-08 15:35 ` [PATCH v1 03/10] clk: at91: pmc: Support backup for programmable clocks Romain Izard
2017-09-13 12:29   ` Nicolas Ferre
     [not found]     ` <b0c7e816-4a7c-609d-2bc7-281fc6ca751d-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-09-13 17:03       ` Alexandre Belloni
2017-09-14  7:41         ` romain izard
2017-09-14  9:38           ` Nicolas Ferre
2017-09-08 15:35 ` [PATCH v1 04/10] mtd: nand: atmel: Avoid ECC errors when leaving backup mode Romain Izard
2017-09-08 15:35 ` [PATCH v1 05/10] mtd: nand: atmel: Report PMECC failures as errors Romain Izard
2017-09-08 15:36 ` [PATCH v1 06/10] ehci-atmel: Power down during suspend is normal Romain Izard
2017-09-08 15:36 ` [PATCH v1 07/10] iio:adc:at91-sama5d2: Support backup mode Romain Izard
     [not found]   ` <20170908153604.28383-8-romain.izard.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-08 16:03     ` Nicolas Ferre [this message]
2017-09-08 16:21       ` Romain Izard
2017-09-08 15:36 ` [PATCH v1 09/10] atmel_flexcom: " Romain Izard
     [not found] ` <20170908153604.28383-1-romain.izard.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-08 15:36   ` [PATCH v1 08/10] pwm: atmel-tcb: " Romain Izard
2017-09-08 15:36   ` [PATCH v1 10/10] tty/serial: atmel: Prevent a warning on suspend Romain Izard
2017-09-11  9:52     ` Romain Izard

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=760d7c25-afa4-2242-a278-e0989bca5478@microchip.com \
    --to=nicolas.ferre-uwl1gki3jzl3ogb3hspcza@public.gmane.org \
    --cc=Eugen.Hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org \
    --cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=cyrille.pitchen-yU5RGvR974pGWvitb5QawA@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ludovic.desroches-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org \
    --cc=marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
    --cc=rainyfeeling-1ViLX0X+lBJBDgjK7y7TUQ@public.gmane.org \
    --cc=richard.genoud-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=romain.izard.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=wenyou.yang-AIFe0yeh4nAAvxtiuMwx3w@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).