devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jun Nie <jun.nie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	jason.liu-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	Jun Nie <jun.nie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: [PATCH 1/3] pinctrl: export pin_request to support parent pin
Date: Fri, 26 Aug 2016 20:19:02 +0800	[thread overview]
Message-ID: <1472213942-4815-1-git-send-email-jun.nie@linaro.org> (raw)

Some pin functions may be controlled in 2nd level multiplex.
We need configure 1st level multiplex when request such
functions. Export pin_request functionality so that parent
can be configured automatically with calling it in
pinmux_ops->request().

Signed-off-by: Jun Nie <jun.nie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/pinctrl/core.c          | 20 ++++++++++++++++++++
 drivers/pinctrl/pinmux.c        |  3 ++-
 drivers/pinctrl/pinmux.h        |  9 +++++++++
 include/linux/pinctrl/pinctrl.h |  2 ++
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index fb38e20..0782a93 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -688,6 +688,26 @@ int pinctrl_gpio_direction_output(unsigned gpio)
 }
 EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output);
 
+/**
+ * pinctrl_request_pin() - request a single pin to be used
+ * @offset: the pin number from pinctrl dev pin number space
+ */
+int pinctrl_request_pin(struct pinctrl_dev *pctldev,
+			int offset, const char *owner)
+{
+	int ret;
+
+	mutex_lock(&pctldev->mutex);
+
+	ret = pin_request(pctldev, offset, owner, NULL);
+
+	mutex_unlock(&pctldev->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(pinctrl_request_pin);
+
+
 static struct pinctrl_state *find_state(struct pinctrl *p,
 					const char *name)
 {
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index ece7028..b18c1f0 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -80,7 +80,7 @@ int pinmux_validate_map(struct pinctrl_map const *map, int i)
  * @gpio_range: the range matching the GPIO pin if this is a request for a
  *	single GPIO pin
  */
-static int pin_request(struct pinctrl_dev *pctldev,
+int pin_request(struct pinctrl_dev *pctldev,
 		       int pin, const char *owner,
 		       struct pinctrl_gpio_range *gpio_range)
 {
@@ -180,6 +180,7 @@ out:
 
 	return status;
 }
+EXPORT_SYMBOL(pin_request);
 
 /**
  * pin_free() - release a single muxed in pin so something else can be muxed
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index d1a98b1c..6ff9baf 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -30,6 +30,9 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
 void pinmux_free_setting(struct pinctrl_setting const *setting);
 int pinmux_enable_setting(struct pinctrl_setting const *setting);
 void pinmux_disable_setting(struct pinctrl_setting const *setting);
+int pin_request(struct pinctrl_dev *pctldev,
+		int pin, const char *owner,
+		struct pinctrl_gpio_range *gpio_range);
 
 #else
 
@@ -83,6 +86,12 @@ static inline void pinmux_disable_setting(
 {
 }
 
+int pin_request(struct pinctrl_dev *pctldev,
+		int pin, const char *owner,
+		struct pinctrl_gpio_range *gpio_range)
+{
+}
+
 #endif
 
 #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h
index a42e57d..13bb7a1 100644
--- a/include/linux/pinctrl/pinctrl.h
+++ b/include/linux/pinctrl/pinctrl.h
@@ -167,6 +167,8 @@ pinctrl_find_gpio_range_from_pin(struct pinctrl_dev *pctldev,
 extern int pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
 				const char *pin_group, const unsigned **pins,
 				unsigned *num_pins);
+extern int pinctrl_request_pin(struct pinctrl_dev *pctldev,
+				int offset, const char *owner);
 
 #ifdef CONFIG_OF
 extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2016-08-26 12:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26 12:19 Jun Nie [this message]
2016-09-06  6:07 ` [PATCH 1/3] pinctrl: export pin_request to support parent pin Jun Nie
2016-09-06 13:55 ` Linus Walleij
     [not found]   ` <CACRpkdYPfBKshf1jGF85vj+bzwb1kX+2j-kUA+8+w+vSFPuGDQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-07  1:38     ` Jun Nie

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=1472213942-4815-1-git-send-email-jun.nie@linaro.org \
    --to=jun.nie-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jason.liu-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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).