linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: add sleep mode management for hogs
@ 2012-12-11 13:59 Linus Walleij
  2012-12-11 21:11 ` Stephen Warren
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2012-12-11 13:59 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Stephen Warren, Anmar Oueja, Julien Delacou, Linus Walleij

From: Julien Delacou <julien.delacou@stericsson.com>

This fix allows handling sleep mode for hogged
pins in pinctrl. It provides functions to set pins
to sleep/default configurations according to their
current state from the individual pinctrl drivers.

Signed-off-by: Julien Delacou <julien.delacou@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/pinctrl/core.c          | 35 ++++++++++++++++++++++++++++++++---
 drivers/pinctrl/core.h          |  4 ++++
 include/linux/pinctrl/pinctrl.h |  2 ++
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 5cdee86..f9c50bb 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1055,6 +1055,28 @@ void pinctrl_unregister_map(struct pinctrl_map const *map)
 	}
 }
 
+/**
+ * pinctrl_force_sleep() - turn a given controller device into sleep state
+ * @pctldev: pin controller device
+ */
+int pinctrl_force_sleep(struct pinctrl_dev *pctldev)
+{
+	if (!IS_ERR(pctldev->p) && !IS_ERR(pctldev->hog_sleep))
+		return pinctrl_select_state(pctldev->p, pctldev->hog_sleep);
+	return 0;
+}
+
+/**
+ * pinctrl_force_default() - turn a given controller device into default state
+ * @pctldev: pin controller device
+ */
+int pinctrl_force_default(struct pinctrl_dev *pctldev)
+{
+	if (!IS_ERR(pctldev->p) && !IS_ERR(pctldev->hog_default))
+		return pinctrl_select_state(pctldev->p, pctldev->hog_default);
+	return 0;
+}
+
 #ifdef CONFIG_DEBUG_FS
 
 static int pinctrl_pins_show(struct seq_file *s, void *what)
@@ -1500,16 +1522,23 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
 
 	pctldev->p = pinctrl_get_locked(pctldev->dev);
 	if (!IS_ERR(pctldev->p)) {
-		struct pinctrl_state *s =
+		pctldev->hog_default =
 			pinctrl_lookup_state_locked(pctldev->p,
 						    PINCTRL_STATE_DEFAULT);
-		if (IS_ERR(s)) {
+		if (IS_ERR(pctldev->hog_default)) {
 			dev_dbg(dev, "failed to lookup the default state\n");
 		} else {
-			if (pinctrl_select_state_locked(pctldev->p, s))
+			if (pinctrl_select_state_locked(pctldev->p,
+						pctldev->hog_default))
 				dev_err(dev,
 					"failed to select default state\n");
 		}
+
+		pctldev->hog_sleep =
+			pinctrl_lookup_state_locked(pctldev->p,
+						    PINCTRL_STATE_SLEEP);
+		if (IS_ERR(pctldev->hog_sleep))
+			dev_dbg(dev, "failed to lookup the sleep state\n");
 	}
 
 	mutex_unlock(&pinctrl_mutex);
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 12f5694..b5bbb09 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -30,6 +30,8 @@ struct pinctrl_gpio_range;
  * @driver_data: driver data for drivers registering to the pin controller
  *	subsystem
  * @p: result of pinctrl_get() for this device
+ * @hog_default: default state for pins hogged by this device
+ * @hog_sleep: sleep state for pins hogged by this device
  * @device_root: debugfs root for this device
  */
 struct pinctrl_dev {
@@ -41,6 +43,8 @@ struct pinctrl_dev {
 	struct module *owner;
 	void *driver_data;
 	struct pinctrl *p;
+	struct pinctrl_state *hog_default;
+	struct pinctrl_state *hog_sleep;
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *device_root;
 #endif
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h
index 04d6700..814cb56 100644
--- a/include/linux/pinctrl/pinctrl.h
+++ b/include/linux/pinctrl/pinctrl.h
@@ -155,6 +155,8 @@ struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
 
 extern const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev);
 extern void *pinctrl_dev_get_drvdata(struct pinctrl_dev *pctldev);
+extern int pinctrl_force_sleep(struct pinctrl_dev *pctldev);
+extern int pinctrl_force_default(struct pinctrl_dev *pctldev);
 #else
 
 struct pinctrl_dev;
-- 
1.7.11.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] pinctrl: add sleep mode management for hogs
  2012-12-11 13:59 [PATCH 1/2] pinctrl: add sleep mode management for hogs Linus Walleij
@ 2012-12-11 21:11 ` Stephen Warren
  2012-12-12 19:31   ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Warren @ 2012-12-11 21:11 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-kernel, linux-arm-kernel, Stephen Warren, Anmar Oueja,
	Julien Delacou, Linus Walleij

On 12/11/2012 06:59 AM, Linus Walleij wrote:
> From: Julien Delacou <julien.delacou@stericsson.com>
> 
> This fix allows handling sleep mode for hogged
> pins in pinctrl. It provides functions to set pins
> to sleep/default configurations according to their
> current state from the individual pinctrl drivers.

> diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h

> +extern int pinctrl_force_sleep(struct pinctrl_dev *pctldev);
> +extern int pinctrl_force_default(struct pinctrl_dev *pctldev);

Since I assume those function are only supposed to be used by pinctrl
drivers themselves, should the prototypes go into drivers/pinctrl/core.h
or similar, rather than something in include/linux/pinctrl?

Oh, and don't you need EXPORT_SYMBOL in case the pinctrl driver is a module?

Aside from that,

Reviewed-by: Stephen Warren <swarren@nvidia.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] pinctrl: add sleep mode management for hogs
  2012-12-11 21:11 ` Stephen Warren
@ 2012-12-12 19:31   ` Linus Walleij
  2012-12-13  8:18     ` Julien DELACOU
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2012-12-12 19:31 UTC (permalink / raw)
  To: Stephen Warren, Julien Delacou
  Cc: Linus Walleij, linux-kernel, linux-arm-kernel, Stephen Warren,
	Anmar Oueja

On Tue, Dec 11, 2012 at 10:11 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:

> Since I assume those function are only supposed to be used by pinctrl
> drivers themselves, should the prototypes go into drivers/pinctrl/core.h
> or similar, rather than something in include/linux/pinctrl?

Good point, Julien can you fix this?

Hm, maybe pinctrl_force_sleep()/default() isn't such a good name,
maybe it should be pinctrl_hogs_sleep()/pinctrl_hogs_default() intead?

> Oh, and don't you need EXPORT_SYMBOL in case the pinctrl driver is a module?

True.

> Aside from that,
>
> Reviewed-by: Stephen Warren <swarren@nvidia.com>

Thanks.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] pinctrl: add sleep mode management for hogs
  2012-12-12 19:31   ` Linus Walleij
@ 2012-12-13  8:18     ` Julien DELACOU
  0 siblings, 0 replies; 4+ messages in thread
From: Julien DELACOU @ 2012-12-13  8:18 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Stephen Warren, Linus WALLEIJ, linux-kernel, linux-arm-kernel,
	Stephen Warren, Anmar Oueja

On 12/12/2012 08:31 PM, Linus Walleij wrote:
> On Tue, Dec 11, 2012 at 10:11 PM, Stephen Warren<swarren@wwwdotorg.org>  wrote:
>
>> Since I assume those function are only supposed to be used by pinctrl
>> drivers themselves, should the prototypes go into drivers/pinctrl/core.h
>> or similar, rather than something in include/linux/pinctrl?
> Good point, Julien can you fix this?
Sure, I will.
>
> Hm, maybe pinctrl_force_sleep()/default() isn't such a good name,
> maybe it should be pinctrl_hogs_sleep()/pinctrl_hogs_default() intead?
>
>> Oh, and don't you need EXPORT_SYMBOL in case the pinctrl driver is a module?
> True.
I will do it too.
>
>> Aside from that,
>>
>> Reviewed-by: Stephen Warren<swarren@nvidia.com>
> Thanks.
>
> Yours,
> Linus Walleij
Thanks a lot.

Regards,
Julien


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-13  8:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-11 13:59 [PATCH 1/2] pinctrl: add sleep mode management for hogs Linus Walleij
2012-12-11 21:11 ` Stephen Warren
2012-12-12 19:31   ` Linus Walleij
2012-12-13  8:18     ` Julien DELACOU

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).