mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Viresh Kumar <viresh.kumar@st.com>
Cc: baruch@tkos.co.il, grant.likely@secretlab.ca,
	linux-kernel@vger.kernel.org, armando.visconti@st.com,
	shiraz.hashim@st.com, vipin.kumar@st.com,
	rajeev-dlh.kumar@st.com, deepak.sikri@st.com,
	vipulkumar.samar@st.com, amit.virdi@st.com,
	pratyush.anand@st.com, bhupesh.sharma@st.com,
	viresh.linux@gmail.com, bhavna.yadav@st.com,
	vincenzo.frascino@st.com, mirko.gardi@st.com
Subject: Re: [PATCH V4] GPIO/pl061: Add suspend resume capability
Date: Fri, 18 Nov 2011 23:06:56 +0100	[thread overview]
Message-ID: <201111182306.56767.rjw@sisk.pl> (raw)
In-Reply-To: <ae47c7f2f31276ffb2b8db132bcabe80aa1139f6.1321609430.git.viresh.kumar@st.com>

On Friday, November 18, 2011, Viresh Kumar wrote:
> From: Deepak Sikri <deepak.sikri@st.com>
> 
> This patch adds the suspend and resume operations in the driver. The patch
> ensures the data save and restore for the device registers during the
> suspend and resume operations respectively.
> 
> Signed-off-by: Deepak Sikri <deepak.sikri@st.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
> Acked-by: Baruch Siach <baruch@tkos.co.il>

Acked-by: Rafael J. Wysocki <rjw@sisk.pl>

> ---
> 
> Changes since V3:
> - pl061_dev_pm_ops marked as static
> 
> changes Since V2:
> - gpio_context_save_regs renamed to pl061_context_save_regs
> - Hibernation callbacks added with help of SIMPLE_DEV_PM_OPS macro
> 
> 
>  drivers/gpio/gpio-pl061.c |   68 +++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 68 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 093c90b..42a5d56 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -23,6 +23,7 @@
>  #include <linux/amba/bus.h>
>  #include <linux/amba/pl061.h>
>  #include <linux/slab.h>
> +#include <linux/pm.h>
>  
>  #define GPIODIR 0x400
>  #define GPIOIS  0x404
> @@ -35,6 +36,17 @@
>  
>  #define PL061_GPIO_NR	8
>  
> +#ifdef CONFIG_PM
> +struct pl061_context_save_regs {
> +	u8 gpio_data;
> +	u8 gpio_dir;
> +	u8 gpio_is;
> +	u8 gpio_ibe;
> +	u8 gpio_iev;
> +	u8 gpio_ie;
> +};
> +#endif
> +
>  struct pl061_gpio {
>  	/* We use a list of pl061_gpio structs for each trigger IRQ in the main
>  	 * interrupts controller of the system. We need this to support systems
> @@ -54,6 +66,10 @@ struct pl061_gpio {
>  	void __iomem		*base;
>  	unsigned		irq_base;
>  	struct gpio_chip	gc;
> +
> +#ifdef CONFIG_PM
> +	struct pl061_context_save_regs csave_regs;
> +#endif
>  };
>  
>  static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> @@ -330,6 +346,8 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
>  		irq_set_chip_data(i + chip->irq_base, chip);
>  	}
>  
> +	amba_set_drvdata(dev, chip);
> +
>  	return 0;
>  
>  iounmap:
> @@ -342,6 +360,53 @@ free_mem:
>  	return ret;
>  }
>  
> +#ifdef CONFIG_PM
> +static int pl061_suspend(struct device *dev)
> +{
> +	struct pl061_gpio *chip = dev_get_drvdata(dev);
> +	int offset;
> +
> +	chip->csave_regs.gpio_data = 0;
> +	chip->csave_regs.gpio_dir = readb(chip->base + GPIODIR);
> +	chip->csave_regs.gpio_is = readb(chip->base + GPIOIS);
> +	chip->csave_regs.gpio_ibe = readb(chip->base + GPIOIBE);
> +	chip->csave_regs.gpio_iev = readb(chip->base + GPIOIEV);
> +	chip->csave_regs.gpio_ie = readb(chip->base + GPIOIE);
> +
> +	for (offset = 0; offset < PL061_GPIO_NR; offset++) {
> +		if (chip->csave_regs.gpio_dir & (1 << offset))
> +			chip->csave_regs.gpio_data |=
> +				pl061_get_value(&chip->gc, offset) << offset;
> +	}
> +
> +	return 0;
> +}
> +
> +static int pl061_resume(struct device *dev)
> +{
> +	struct pl061_gpio *chip = dev_get_drvdata(dev);
> +	int offset;
> +
> +	for (offset = 0; offset < PL061_GPIO_NR; offset++) {
> +		if (chip->csave_regs.gpio_dir & (1 << offset))
> +			pl061_direction_output(&chip->gc, offset,
> +					chip->csave_regs.gpio_data &
> +					(1 << offset));
> +		else
> +			pl061_direction_input(&chip->gc, offset);
> +	}
> +
> +	writeb(chip->csave_regs.gpio_is, chip->base + GPIOIS);
> +	writeb(chip->csave_regs.gpio_ibe, chip->base + GPIOIBE);
> +	writeb(chip->csave_regs.gpio_iev, chip->base + GPIOIEV);
> +	writeb(chip->csave_regs.gpio_ie, chip->base + GPIOIE);
> +
> +	return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(pl061_dev_pm_ops, pl061_suspend, pl061_resume);
> +#endif
> +
>  static struct amba_id pl061_ids[] = {
>  	{
>  		.id	= 0x00041061,
> @@ -353,6 +418,9 @@ static struct amba_id pl061_ids[] = {
>  static struct amba_driver pl061_gpio_driver = {
>  	.drv = {
>  		.name	= "pl061_gpio",
> +#ifdef CONFIG_PM
> +		.pm	= &pl061_dev_pm_ops,
> +#endif
>  	},
>  	.id_table	= pl061_ids,
>  	.probe		= pl061_probe,
> 


  reply	other threads:[~2011-11-18 22:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18  9:50 Viresh Kumar
2011-11-18 22:06 ` Rafael J. Wysocki [this message]
2011-11-19 22:06 ` Linus Walleij

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=201111182306.56767.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=amit.virdi@st.com \
    --cc=armando.visconti@st.com \
    --cc=baruch@tkos.co.il \
    --cc=bhavna.yadav@st.com \
    --cc=bhupesh.sharma@st.com \
    --cc=deepak.sikri@st.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mirko.gardi@st.com \
    --cc=pratyush.anand@st.com \
    --cc=rajeev-dlh.kumar@st.com \
    --cc=shiraz.hashim@st.com \
    --cc=vincenzo.frascino@st.com \
    --cc=vipin.kumar@st.com \
    --cc=vipulkumar.samar@st.com \
    --cc=viresh.kumar@st.com \
    --cc=viresh.linux@gmail.com \
    /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

all inboxes | Powered by JetHome®