[1/3] pinctrl: export pin_request to support parent pin

Message ID 1472213942-4815-1-git-send-email-jun.nie@linaro.org
State New
Headers show

Commit Message

Jun Nie Aug. 26, 2016, 12:19 p.m.
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(-)

-- 
1.9.1

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

Comments

Jun Nie Sept. 6, 2016, 6:07 a.m. | #1
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
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jun Nie Sept. 7, 2016, 1:38 a.m. | #2
2016-09-06 21:55 GMT+08:00 Linus Walleij <linus.walleij@linaro.org>:
> 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.


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 linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch hide | download patch | download mbox

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