From: Marcin Wojtas <mw@semihalf.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org
Cc: linus.walleij@linaro.org, sebastian.hesselbarth@gmail.com,
andrew@lunn.ch, jason@lakedaemon.net,
thomas.petazzoni@free-electrons.com,
gregory.clement@free-electrons.com, nadavh@marvell.com,
alior@marvell.com, tawfik@marvell.com, mw@semihalf.com,
jaz@semihalf.com
Subject: [PATCH] pinctrl: mvebu: armada-38x: add suspend/resume support
Date: Sat, 17 Oct 2015 23:28:48 +0200 [thread overview]
Message-ID: <1445117328-31678-1-git-send-email-mw@semihalf.com> (raw)
This commit adds suspend/resume support by saving and restoring registers'
state in a dedicated array.
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
drivers/pinctrl/mvebu/pinctrl-armada-38x.c | 37 ++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-38x.c b/drivers/pinctrl/mvebu/pinctrl-armada-38x.c
index 6ec82c6..094cb48 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-38x.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-38x.c
@@ -23,6 +23,7 @@
#include "pinctrl-mvebu.h"
static void __iomem *mpp_base;
+static u32 *mpp_saved_regs;
static int armada_38x_mpp_ctrl_get(unsigned pid, unsigned long *config)
{
@@ -424,6 +425,7 @@ static int armada_38x_pinctrl_probe(struct platform_device *pdev)
const struct of_device_id *match =
of_match_device(armada_38x_pinctrl_of_match, &pdev->dev);
struct resource *res;
+ int nregs;
if (!match)
return -ENODEV;
@@ -441,11 +443,44 @@ static int armada_38x_pinctrl_probe(struct platform_device *pdev)
soc->modes = armada_38x_mpp_modes;
soc->nmodes = armada_38x_mpp_controls[0].npins;
+ nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
+
+ mpp_saved_regs = devm_kcalloc(&pdev->dev, nregs, sizeof(u32),
+ GFP_KERNEL);
+ if (!mpp_saved_regs)
+ return -ENOMEM;
+
pdev->dev.platform_data = soc;
return mvebu_pinctrl_probe(pdev);
}
+int armada_38x_pinctrl_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ struct mvebu_pinctrl_soc_info *soc = platform_get_drvdata(pdev);
+ int i, nregs;
+
+ nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
+
+ for (i = 0; i < nregs; i++)
+ mpp_saved_regs[i] = readl(mpp_base + i * 4);
+
+ return 0;
+}
+
+int armada_38x_pinctrl_resume(struct platform_device *pdev)
+{
+ struct mvebu_pinctrl_soc_info *soc = platform_get_drvdata(pdev);
+ int i, nregs;
+
+ nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
+
+ for (i = 0; i < nregs; i++)
+ writel(mpp_saved_regs[i], mpp_base + i * 4);
+
+ return 0;
+}
+
static int armada_38x_pinctrl_remove(struct platform_device *pdev)
{
return mvebu_pinctrl_remove(pdev);
@@ -458,6 +493,8 @@ static struct platform_driver armada_38x_pinctrl_driver = {
},
.probe = armada_38x_pinctrl_probe,
.remove = armada_38x_pinctrl_remove,
+ .suspend = armada_38x_pinctrl_suspend,
+ .resume = armada_38x_pinctrl_resume,
};
module_platform_driver(armada_38x_pinctrl_driver);
--
1.8.3.1
next reply other threads:[~2015-10-17 21:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-17 21:28 Marcin Wojtas [this message]
2015-10-17 22:29 ` [PATCH] pinctrl: mvebu: armada-38x: add suspend/resume support Russell King - ARM Linux
2015-10-18 8:43 ` Marcin Wojtas
2015-10-18 14:01 ` Thomas Petazzoni
2015-10-19 6:04 ` Marcin Wojtas
2015-10-19 7:23 ` Thomas Petazzoni
2015-10-19 9:25 ` Marcin Wojtas
2015-10-19 10:10 ` Marcin Wojtas
2015-10-19 10:40 ` Russell King - ARM Linux
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=1445117328-31678-1-git-send-email-mw@semihalf.com \
--to=mw@semihalf.com \
--cc=alior@marvell.com \
--cc=andrew@lunn.ch \
--cc=gregory.clement@free-electrons.com \
--cc=jason@lakedaemon.net \
--cc=jaz@semihalf.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nadavh@marvell.com \
--cc=sebastian.hesselbarth@gmail.com \
--cc=tawfik@marvell.com \
--cc=thomas.petazzoni@free-electrons.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;
as well as URLs for NNTP newsgroup(s).