On 24/10/2014 13:59, Thomas Petazzoni wrote: > This commit adds the implementation of ->suspend() and ->resume() > platform_driver hooks in order to save and restore the state of the > GPIO configuration. In order to achieve that, additional fields are > added to the mvebu_gpio_chip structure. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@xxxxxxxxxxxxxxxxxx> > Cc: Linus Walleij <linus.walleij@xxxxxxxxxx> > Cc: Alexandre Courbot <gnurou@xxxxxxxxx> > Cc: linux-gpio@xxxxxxxxxxxxxxx > --- > drivers/gpio/gpio-mvebu.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 99 insertions(+) > > diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c > index 418e386..dd5545c 100644 > --- a/drivers/gpio/gpio-mvebu.c > +++ b/drivers/gpio/gpio-mvebu.c > @@ -83,6 +83,14 @@ struct mvebu_gpio_chip { > int irqbase; > struct irq_domain *domain; > int soc_variant; > + > + /* Used to preserve GPIO registers accross suspend/resume */ across > + u32 out_reg; > + u32 io_conf_reg; > + u32 blink_en_reg; > + u32 in_pol_reg; > + u32 edge_mask_regs[4]; > + u32 level_mask_regs[4]; > }; > > /* > @@ -554,6 +562,93 @@ static const struct of_device_id mvebu_gpio_of_match[] = { > }; > MODULE_DEVICE_TABLE(of, mvebu_gpio_of_match); > > +static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state) > +{ > + struct mvebu_gpio_chip *mvchip = platform_get_drvdata(pdev); > + int i; > + > + mvchip->out_reg = readl(mvebu_gpioreg_out(mvchip)); > + mvchip->io_conf_reg = readl(mvebu_gpioreg_io_conf(mvchip)); > + mvchip->blink_en_reg = readl(mvebu_gpioreg_blink(mvchip)); > + mvchip->in_pol_reg = readl(mvebu_gpioreg_in_pol(mvchip)); > + > + switch (mvchip->soc_variant) { > + case MVEBU_GPIO_SOC_VARIANT_ORION: > + mvchip->edge_mask_regs[0] = > + readl(mvchip->membase + GPIO_EDGE_MASK_OFF); > + mvchip->level_mask_regs[0] = > + readl(mvchip->membase + GPIO_LEVEL_MASK_OFF); > + break; > + case MVEBU_GPIO_SOC_VARIANT_MV78200: > + for (i = 0; i < 2; i++) { > + mvchip->edge_mask_regs[i] = > + readl(mvchip->membase + > + GPIO_EDGE_MASK_MV78200_OFF(i)); > + mvchip->level_mask_regs[i] = > + readl(mvchip->membase + > + GPIO_LEVEL_MASK_MV78200_OFF(i)); > + } > + break; I don't know if the suspend is supported on this platform but as we were on the road to remove this platform I don't know it it worth testing it unless some interested users show up. I didn't tested it on a mv782xx platform but the patch looks correct: Reviewed-by: Gregory CLEMENT <gregory.clement@xxxxxxxxxxxxxxxxxx> Thanks, Gregory -- Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html