All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] pinctrl: export pin_request to support parent pin
@ 2016-08-26 12:19 Jun Nie
  2016-09-06  6:07 ` Jun Nie
  2016-09-06 13:55 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Jun Nie @ 2016-08-26 12:19 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA
  Cc: shawn.guo-QSEj5FYQhm4dnm+yROfE0A,
	jason.liu-QSEj5FYQhm4dnm+yROfE0A, Jun Nie

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

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

* Re: [PATCH 1/3] pinctrl: export pin_request to support parent pin
  2016-08-26 12:19 [PATCH 1/3] pinctrl: export pin_request to support parent pin Jun Nie
@ 2016-09-06  6:07 ` Jun Nie
  2016-09-06 13:55 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Jun Nie @ 2016-09-06  6:07 UTC (permalink / raw)
  To: devicetree, Linus Walleij, linux-gpio; +Cc: Shawn Guo, Jason Liu, Jun Nie

2016-08-26 20:19 GMT+08:00 Jun Nie <jun.nie@linaro.org>:
> 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@linaro.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
>

Linus,

Do you have any comments on these change and following ZX pinctrl driver?

Thank you!
Jun

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

* Re: [PATCH 1/3] pinctrl: export pin_request to support parent pin
  2016-08-26 12:19 [PATCH 1/3] pinctrl: export pin_request to support parent pin Jun Nie
  2016-09-06  6:07 ` Jun Nie
@ 2016-09-06 13:55 ` Linus Walleij
       [not found]   ` <CACRpkdYPfBKshf1jGF85vj+bzwb1kX+2j-kUA+8+w+vSFPuGDQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2016-09-06 13:55 UTC (permalink / raw)
  To: Jun Nie; +Cc: devicetree, linux-gpio, Shawn Guo, Jason Liu

On Fri, Aug 26, 2016 at 2:19 PM, Jun Nie <jun.nie@linaro.org> wrote:

> 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@linaro.org>

This looks weird as 1/3, please put the DT bindings first in the
series.

We first need to agree on how to represent this before we start
hacking around in the core to support different shortcuts.

This patch just makes me nervous, but maybe I can be convinced
otherwise if we get some details on how the hardware works and why
this is necessary.

Yours,
Linus Walleij

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

* Re: [PATCH 1/3] pinctrl: export pin_request to support parent pin
       [not found]   ` <CACRpkdYPfBKshf1jGF85vj+bzwb1kX+2j-kUA+8+w+vSFPuGDQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-09-07  1:38     ` Jun Nie
  0 siblings, 0 replies; 4+ messages in thread
From: Jun Nie @ 2016-09-07  1:38 UTC (permalink / raw)
  To: Linus Walleij
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA, Shawn Guo, Jason Liu

2016-09-06 21:55 GMT+08:00 Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>:
> On Fri, Aug 26, 2016 at 2:19 PM, Jun Nie <jun.nie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
>
>> 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>
>
> This looks weird as 1/3, please put the DT bindings first in the
> series.

I thought 1/3 patch does not relate to ZTE driver directly, so I put as the
2nd patch. Will move it to the very first one as you point out.

>
> We first need to agree on how to represent this before we start
> hacking around in the core to support different shortcuts.
>
> This patch just makes me nervous, but maybe I can be convinced
> otherwise if we get some details on how the hardware works and why
> this is necessary.

Hardware has two register regions to control pinmux, one is for normal
function configuration and the other one is for always on subsystem(AON).
Some pins are controlled by both normal register and AON register. AON
register is the first level control for pinmux. If we need any
function in normal
register configuration, we need configure related AON pinmux register as
non-AON function first. Then we configure normal pinmux register to get the
pin function we want.

>
> Yours,
> Linus Walleij
--
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

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

end of thread, other threads:[~2016-09-07  1:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-26 12:19 [PATCH 1/3] pinctrl: export pin_request to support parent pin Jun Nie
2016-09-06  6:07 ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.