* [PATCH/RFT v4] gpio: gpio-rcar: Support S2RAM
@ 2018-02-04 19:15 Yoshihiro Kaneko
2018-02-14 5:27 ` Yoshihiro Shimoda
2018-02-22 14:51 ` Linus Walleij
0 siblings, 2 replies; 5+ messages in thread
From: Yoshihiro Kaneko @ 2018-02-04 19:15 UTC (permalink / raw)
To: linux-gpio
Cc: Linus Walleij, Simon Horman, Magnus Damm, Geert Uytterhoeven,
linux-renesas-soc
From: Hien Dang <hien.dang.eb@renesas.com>
This patch adds an implementation that saves and restores the state of
GPIO configuration on suspend and resume.
Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
[Modify structure of the bank info to simplify a saving registers]
[Remove DEV_PM_OPS macro]
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
This patch is based on the for-next branch of linux-gpio tree.
v2 [Yoshihiro Kaneko]
* Modify structure of the bank info as suggested by Geert Uytterhoeven
v3 [Yoshihiro Kaneko]
* Remove DEV_PM_OPS macro as suggested by Vladimir Zapolskiy
v4 [Yoshihiro Kaneko]
* As suggested by Geert Uytterhoeven
- make the name of all members of gpio_rcar_bank_info accord with the
name of the registers
- fix type of the 'offset' variable in unsigned int
- fix the inverted logic in gpio_rcar_resume()
drivers/gpio/gpio-rcar.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index e76de57..e5b0dbe 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -31,6 +31,16 @@
#include <linux/spinlock.h>
#include <linux/slab.h>
+struct gpio_rcar_bank_info {
+ u32 iointsel;
+ u32 inoutsel;
+ u32 outdt;
+ u32 posneg;
+ u32 edglevel;
+ u32 bothedge;
+ u32 intmsk;
+};
+
struct gpio_rcar_priv {
void __iomem *base;
spinlock_t lock;
@@ -41,6 +51,7 @@ struct gpio_rcar_priv {
unsigned int irq_parent;
bool has_both_edge_trigger;
bool needs_clk;
+ struct gpio_rcar_bank_info bank_info;
};
#define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */
@@ -531,11 +542,66 @@ static int gpio_rcar_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int gpio_rcar_suspend(struct device *dev)
+{
+ struct gpio_rcar_priv *p = dev_get_drvdata(dev);
+
+ p->bank_info.iointsel = gpio_rcar_read(p, IOINTSEL);
+ p->bank_info.inoutsel = gpio_rcar_read(p, INOUTSEL);
+ p->bank_info.outdt = gpio_rcar_read(p, OUTDT);
+ p->bank_info.intmsk = gpio_rcar_read(p, INTMSK);
+ p->bank_info.posneg = gpio_rcar_read(p, POSNEG);
+ p->bank_info.edglevel = gpio_rcar_read(p, EDGLEVEL);
+ if (p->has_both_edge_trigger)
+ p->bank_info.bothedge = gpio_rcar_read(p, BOTHEDGE);
+
+ return 0;
+}
+
+static int gpio_rcar_resume(struct device *dev)
+{
+ struct gpio_rcar_priv *p = dev_get_drvdata(dev);
+ unsigned int offset;
+ u32 mask;
+
+ for (offset = 0; offset < p->gpio_chip.ngpio; offset++) {
+ mask = BIT(offset);
+ /* I/O pin */
+ if (!(p->bank_info.iointsel & mask)) {
+ if (p->bank_info.inoutsel & mask)
+ gpio_rcar_direction_output(
+ &p->gpio_chip, offset,
+ !!(p->bank_info.outdt & mask));
+ else
+ gpio_rcar_direction_input(&p->gpio_chip,
+ offset);
+ } else {
+ /* Interrupt pin */
+ gpio_rcar_config_interrupt_input_mode(
+ p,
+ offset,
+ !(p->bank_info.posneg & mask),
+ !(p->bank_info.edglevel & mask),
+ !!(p->bank_info.bothedge & mask));
+
+ if (p->bank_info.intmsk & mask)
+ gpio_rcar_write(p, MSKCLR, mask);
+ }
+ }
+
+ return 0;
+}
+#endif /* CONFIG_PM_SLEEP*/
+
+static SIMPLE_DEV_PM_OPS(gpio_rcar_pm_ops, gpio_rcar_suspend, gpio_rcar_resume);
+
static struct platform_driver gpio_rcar_device_driver = {
.probe = gpio_rcar_probe,
.remove = gpio_rcar_remove,
.driver = {
.name = "gpio_rcar",
+ .pm = &gpio_rcar_pm_ops,
.of_match_table = of_match_ptr(gpio_rcar_of_table),
}
};
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH/RFT v4] gpio: gpio-rcar: Support S2RAM
2018-02-04 19:15 [PATCH/RFT v4] gpio: gpio-rcar: Support S2RAM Yoshihiro Kaneko
@ 2018-02-14 5:27 ` Yoshihiro Shimoda
2018-02-15 16:26 ` Simon Horman
2018-02-22 14:51 ` Linus Walleij
1 sibling, 1 reply; 5+ messages in thread
From: Yoshihiro Shimoda @ 2018-02-14 5:27 UTC (permalink / raw)
To: Yoshihiro Kaneko, linux-gpio
Cc: Linus Walleij, Simon Horman, Magnus Damm, Geert Uytterhoeven,
linux-renesas-soc, DUNG NGUYEN
Hi,
> From: Yoshihiro Kaneko, Sent: Monday, February 5, 2018 4:15 AM
>
> From: Hien Dang <hien.dang.eb@renesas.com>
>
> This patch adds an implementation that saves and restores the state of
> GPIO configuration on suspend and resume.
>
> Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
> Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
> [Modify structure of the bank info to simplify a saving registers]
> [Remove DEV_PM_OPS macro]
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> ---
Thank you for the patch. Our team tested this patch and
an issue that an SD card detection pin doesn't work after resumed is resolved.
So,
Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Best regards,
Yoshihiro Shimoda
> This patch is based on the for-next branch of linux-gpio tree.
>
> v2 [Yoshihiro Kaneko]
> * Modify structure of the bank info as suggested by Geert Uytterhoeven
>
> v3 [Yoshihiro Kaneko]
> * Remove DEV_PM_OPS macro as suggested by Vladimir Zapolskiy
>
> v4 [Yoshihiro Kaneko]
> * As suggested by Geert Uytterhoeven
> - make the name of all members of gpio_rcar_bank_info accord with the
> name of the registers
> - fix type of the 'offset' variable in unsigned int
> - fix the inverted logic in gpio_rcar_resume()
>
> drivers/gpio/gpio-rcar.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index e76de57..e5b0dbe 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -31,6 +31,16 @@
> #include <linux/spinlock.h>
> #include <linux/slab.h>
>
> +struct gpio_rcar_bank_info {
> + u32 iointsel;
> + u32 inoutsel;
> + u32 outdt;
> + u32 posneg;
> + u32 edglevel;
> + u32 bothedge;
> + u32 intmsk;
> +};
> +
> struct gpio_rcar_priv {
> void __iomem *base;
> spinlock_t lock;
> @@ -41,6 +51,7 @@ struct gpio_rcar_priv {
> unsigned int irq_parent;
> bool has_both_edge_trigger;
> bool needs_clk;
> + struct gpio_rcar_bank_info bank_info;
> };
>
> #define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */
> @@ -531,11 +542,66 @@ static int gpio_rcar_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM_SLEEP
> +static int gpio_rcar_suspend(struct device *dev)
> +{
> + struct gpio_rcar_priv *p = dev_get_drvdata(dev);
> +
> + p->bank_info.iointsel = gpio_rcar_read(p, IOINTSEL);
> + p->bank_info.inoutsel = gpio_rcar_read(p, INOUTSEL);
> + p->bank_info.outdt = gpio_rcar_read(p, OUTDT);
> + p->bank_info.intmsk = gpio_rcar_read(p, INTMSK);
> + p->bank_info.posneg = gpio_rcar_read(p, POSNEG);
> + p->bank_info.edglevel = gpio_rcar_read(p, EDGLEVEL);
> + if (p->has_both_edge_trigger)
> + p->bank_info.bothedge = gpio_rcar_read(p, BOTHEDGE);
> +
> + return 0;
> +}
> +
> +static int gpio_rcar_resume(struct device *dev)
> +{
> + struct gpio_rcar_priv *p = dev_get_drvdata(dev);
> + unsigned int offset;
> + u32 mask;
> +
> + for (offset = 0; offset < p->gpio_chip.ngpio; offset++) {
> + mask = BIT(offset);
> + /* I/O pin */
> + if (!(p->bank_info.iointsel & mask)) {
> + if (p->bank_info.inoutsel & mask)
> + gpio_rcar_direction_output(
> + &p->gpio_chip, offset,
> + !!(p->bank_info.outdt & mask));
> + else
> + gpio_rcar_direction_input(&p->gpio_chip,
> + offset);
> + } else {
> + /* Interrupt pin */
> + gpio_rcar_config_interrupt_input_mode(
> + p,
> + offset,
> + !(p->bank_info.posneg & mask),
> + !(p->bank_info.edglevel & mask),
> + !!(p->bank_info.bothedge & mask));
> +
> + if (p->bank_info.intmsk & mask)
> + gpio_rcar_write(p, MSKCLR, mask);
> + }
> + }
> +
> + return 0;
> +}
> +#endif /* CONFIG_PM_SLEEP*/
> +
> +static SIMPLE_DEV_PM_OPS(gpio_rcar_pm_ops, gpio_rcar_suspend, gpio_rcar_resume);
> +
> static struct platform_driver gpio_rcar_device_driver = {
> .probe = gpio_rcar_probe,
> .remove = gpio_rcar_remove,
> .driver = {
> .name = "gpio_rcar",
> + .pm = &gpio_rcar_pm_ops,
> .of_match_table = of_match_ptr(gpio_rcar_of_table),
> }
> };
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH/RFT v4] gpio: gpio-rcar: Support S2RAM
2018-02-14 5:27 ` Yoshihiro Shimoda
@ 2018-02-15 16:26 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2018-02-15 16:26 UTC (permalink / raw)
To: Yoshihiro Shimoda
Cc: Yoshihiro Kaneko, linux-gpio, Linus Walleij, Magnus Damm,
Geert Uytterhoeven, linux-renesas-soc, DUNG NGUYEN
On Wed, Feb 14, 2018 at 05:27:39AM +0000, Yoshihiro Shimoda wrote:
> Hi,
>
> > From: Yoshihiro Kaneko, Sent: Monday, February 5, 2018 4:15 AM
> >
> > From: Hien Dang <hien.dang.eb@renesas.com>
> >
> > This patch adds an implementation that saves and restores the state of
> > GPIO configuration on suspend and resume.
> >
> > Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
> > Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
> > [Modify structure of the bank info to simplify a saving registers]
> > [Remove DEV_PM_OPS macro]
> > Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> > ---
>
> Thank you for the patch. Our team tested this patch and
> an issue that an SD card detection pin doesn't work after resumed is resolved.
> So,
>
> Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Thanks for testing!
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH/RFT v4] gpio: gpio-rcar: Support S2RAM
2018-02-04 19:15 [PATCH/RFT v4] gpio: gpio-rcar: Support S2RAM Yoshihiro Kaneko
2018-02-14 5:27 ` Yoshihiro Shimoda
@ 2018-02-22 14:51 ` Linus Walleij
2018-02-22 15:24 ` Simon Horman
1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2018-02-22 14:51 UTC (permalink / raw)
To: Yoshihiro Kaneko
Cc: open list:GPIO SUBSYSTEM, Simon Horman, Magnus Damm,
Geert Uytterhoeven, Linux-Renesas
On Sun, Feb 4, 2018 at 8:15 PM, Yoshihiro Kaneko <ykaneko0929@gmail.com> wrote:
> From: Hien Dang <hien.dang.eb@renesas.com>
>
> This patch adds an implementation that saves and restores the state of
> GPIO configuration on suspend and resume.
>
> Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
> Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
> [Modify structure of the bank info to simplify a saving registers]
> [Remove DEV_PM_OPS macro]
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
This v4 version applied with Tested- and reviewed tags.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH/RFT v4] gpio: gpio-rcar: Support S2RAM
2018-02-22 14:51 ` Linus Walleij
@ 2018-02-22 15:24 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2018-02-22 15:24 UTC (permalink / raw)
To: Linus Walleij
Cc: Yoshihiro Kaneko, open list:GPIO SUBSYSTEM, Magnus Damm,
Geert Uytterhoeven, Linux-Renesas
On Thu, Feb 22, 2018 at 03:51:27PM +0100, Linus Walleij wrote:
> On Sun, Feb 4, 2018 at 8:15 PM, Yoshihiro Kaneko <ykaneko0929@gmail.com> wrote:
>
> > From: Hien Dang <hien.dang.eb@renesas.com>
> >
> > This patch adds an implementation that saves and restores the state of
> > GPIO configuration on suspend and resume.
> >
> > Signed-off-by: Hien Dang <hien.dang.eb@renesas.com>
> > Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
> > [Modify structure of the bank info to simplify a saving registers]
> > [Remove DEV_PM_OPS macro]
> > Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
>
> This v4 version applied with Tested- and reviewed tags.
Excellent, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-22 15:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-04 19:15 [PATCH/RFT v4] gpio: gpio-rcar: Support S2RAM Yoshihiro Kaneko
2018-02-14 5:27 ` Yoshihiro Shimoda
2018-02-15 16:26 ` Simon Horman
2018-02-22 14:51 ` Linus Walleij
2018-02-22 15:24 ` Simon Horman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.