From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] drivers: Add pinctrl handling for dynamic pin states
Date: Tue, 16 Jul 2013 02:05:39 -0700 [thread overview]
Message-ID: <20130716090539.5541.980.stgit@localhost> (raw)
In-Reply-To: <20130716090310.5541.36777.stgit@localhost>
We want to have static pin states handled separately from
dynamic pin states, so let's add optional state_active.
Then if state_active is defined, let's check and make sure
state_idle and state_sleep match state_active for the
pin groups to avoid checking them during runtime as the
active and idle pins may need to be toggled for many
devices every time we enter and exit idle.
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/base/pinctrl.c | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/base/pinctrl.c b/drivers/base/pinctrl.c
index 5fb74b4..49644ed 100644
--- a/drivers/base/pinctrl.c
+++ b/drivers/base/pinctrl.c
@@ -34,6 +34,7 @@ int pinctrl_bind_pins(struct device *dev)
goto cleanup_alloc;
}
+ /* Default static pins that don't need to change */
dev->pins->default_state = pinctrl_lookup_state(dev->pins->p,
PINCTRL_STATE_DEFAULT);
if (IS_ERR(dev->pins->default_state)) {
@@ -48,23 +49,57 @@ int pinctrl_bind_pins(struct device *dev)
goto cleanup_get;
}
+ /* Optional runtime dynamic pins in addition to the static pins */
+ dev->pins->active_state = pinctrl_lookup_state(dev->pins->p,
+ PINCTRL_STATE_ACTIVE);
+ if (IS_ERR(dev->pins->active_state)) {
+ /* Not supplying this state is perfectly legal */
+ dev_dbg(dev, "no active pinctrl state\n");
+ } else {
+ ret = pinctrl_select_dynamic(dev->pins->p,
+ dev->pins->active_state);
+ if (ret) {
+ dev_dbg(dev, "failed to select active pinctrl state\n");
+ goto cleanup_get;
+ }
+ }
+
#ifdef CONFIG_PM
/*
* If power management is enabled, we also look for the optional
* sleep and idle pin states, with semantics as defined in
* <linux/pinctrl/pinctrl-state.h>
+ *
+ * Note that if active state is defined, sleep and idle states must
+ * cover the same pin groups as active state.
*/
dev->pins->sleep_state = pinctrl_lookup_state(dev->pins->p,
PINCTRL_STATE_SLEEP);
- if (IS_ERR(dev->pins->sleep_state))
+ if (IS_ERR(dev->pins->sleep_state)) {
/* Not supplying this state is perfectly legal */
dev_dbg(dev, "no sleep pinctrl state\n");
+ } else if (!IS_ERR(dev->pins->active_state)) {
+ ret = pinctrl_check_dynamic(dev, dev->pins->active_state,
+ dev->pins->sleep_state);
+ if (ret) {
+ dev_err(dev, "sleep state groups do not match active state\n");
+ dev->pins->sleep_state = ERR_PTR(-EINVAL);
+ }
+ }
dev->pins->idle_state = pinctrl_lookup_state(dev->pins->p,
PINCTRL_STATE_IDLE);
- if (IS_ERR(dev->pins->idle_state))
+ if (IS_ERR(dev->pins->idle_state)) {
/* Not supplying this state is perfectly legal */
dev_dbg(dev, "no idle pinctrl state\n");
+ } else if (!IS_ERR(dev->pins->active_state)) {
+ ret = pinctrl_check_dynamic(dev, dev->pins->active_state,
+ dev->pins->idle_state);
+ if (ret) {
+ dev_err(dev, "idle state groups do not match active state\n");
+ dev->pins->idle_state = ERR_PTR(-EINVAL);
+ }
+ }
#endif
return 0;
next prev parent reply other threads:[~2013-07-16 9:05 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-16 9:05 [PATCH 0/4] improved support for runtime muxing for pinctrl Tony Lindgren
2013-07-16 9:05 ` [PATCH 1/4] pinctrl: Remove duplicate code in pinctrl_pm_select_state functions Tony Lindgren
2013-07-16 13:15 ` Grygorii Strashko
2013-07-16 13:41 ` Tony Lindgren
2013-07-16 14:25 ` Grygorii Strashko
2013-07-17 6:31 ` Tony Lindgren
2013-07-16 9:05 ` [PATCH 2/4] pinctrl: Allow pinctrl to have multiple active states Tony Lindgren
2013-07-17 20:55 ` Stephen Warren
2013-07-16 9:05 ` [PATCH 3/4] pinctrl: Add support for additional dynamic states Tony Lindgren
2013-07-16 9:35 ` Felipe Balbi
2013-07-16 12:06 ` Tony Lindgren
2013-07-17 21:14 ` Stephen Warren
2013-07-18 7:25 ` Tony Lindgren
2013-07-18 10:53 ` Tony Lindgren
2013-07-18 19:21 ` Stephen Warren
2013-07-19 7:29 ` Tony Lindgren
2013-07-19 18:52 ` Stephen Warren
2013-07-29 9:05 ` Tony Lindgren
2013-07-29 22:01 ` Stephen Warren
2013-08-14 16:41 ` Linus Walleij
2013-07-17 21:23 ` Stephen Warren
2013-07-18 7:36 ` Tony Lindgren
2013-07-18 19:26 ` Stephen Warren
2013-07-19 7:39 ` Tony Lindgren
2013-07-19 10:29 ` Grygorii Strashko
2013-07-19 19:03 ` Stephen Warren
2013-07-22 23:15 ` Linus Walleij
2013-07-29 9:08 ` Tony Lindgren
2013-07-19 18:58 ` Stephen Warren
2013-07-29 9:21 ` Tony Lindgren
2013-07-29 22:08 ` Stephen Warren
2013-07-22 23:07 ` Linus Walleij
2013-07-29 9:31 ` Tony Lindgren
2013-07-16 9:05 ` Tony Lindgren [this message]
2013-07-17 21:21 ` [PATCH 4/4] drivers: Add pinctrl handling for dynamic pin states Stephen Warren
2013-07-18 7:50 ` Tony Lindgren
2013-07-18 13:48 ` Tony Lindgren
2013-07-16 9:14 ` [PATCH 0/4] improved support for runtime muxing for pinctrl Tony Lindgren
2013-07-17 11:49 ` Grygorii Strashko
-- strict thread matches above, loose matches on Subject: below --
2013-07-18 15:15 [PATCHv2 " Tony Lindgren
2013-07-18 15:15 ` [PATCH 4/4] drivers: Add pinctrl handling for dynamic pin states Tony Lindgren
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=20130716090539.5541.980.stgit@localhost \
--to=tony@atomide.com \
--cc=linux-arm-kernel@lists.infradead.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).