diff mbox

[v2,09/10] gpio: pxa: bind to pinctrl by request

Message ID 1359886551-20950-10-git-send-email-haojian.zhuang@linaro.org
State Superseded
Headers show

Commit Message

Haojian Zhuang Feb. 3, 2013, 10:15 a.m. UTC
While gpio pins is requested, request the pin of pinctrl driver first.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 drivers/gpio/gpio-pxa.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Igor Grinberg Feb. 6, 2013, 2:11 p.m. UTC | #1
On 02/03/13 12:15, Haojian Zhuang wrote:
> While gpio pins is requested, request the pin of pinctrl driver first.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> ---
>  drivers/gpio/gpio-pxa.c |   19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
> index 5c39db3..c9cc636 100644
> --- a/drivers/gpio/gpio-pxa.c
> +++ b/drivers/gpio/gpio-pxa.c
> @@ -23,6 +23,7 @@
>  #include <linux/io.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> +#include <linux/pinctrl/consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/syscore_ops.h>
>  #include <linux/slab.h>
> @@ -159,6 +160,23 @@ int pxa_irq_to_gpio(struct irq_data *d)
>  	return gpio;
>  }
>  
> +static int pxa_gpio_request(struct gpio_chip *gc, unsigned offset)
> +{
> +	/*
> +	 * Map back to global GPIO space and request muxing, the direction
> +	 * parameter does not matter for this controller.
> +	 */
> +	int gpio = gc->base + offset;
> +
> +	/*
> +	 * Platforms in ARCH_PXA doesn't move to device tree yet,
> +	 * and PINCTRL_SINGLE is depend on device tree.
> +	 */ 

If this is interesting, git am says:
patch:32: trailing whitespace.
         */ 
warning: 1 line adds whitespace errors.

> +	if (IS_ENABLED(CONFIG_PINCTRL_SINGLE))
> +		return pinctrl_request_gpio(gpio);
> +	return 0;
> +}
> +
>  static int pxa_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct pxa_gpio_chip *chip = NULL;
> @@ -471,6 +489,7 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end,
>  		gc->base  = gpio;
>  		gc->label = chips[i].label;
>  
> +		gc->request = pxa_gpio_request;
>  		gc->direction_input  = pxa_gpio_direction_input;
>  		gc->direction_output = pxa_gpio_direction_output;
>  		gc->get = pxa_gpio_get;
>
Igor Grinberg Feb. 7, 2013, 3:17 p.m. UTC | #2
On 02/03/13 12:15, Haojian Zhuang wrote:
> While gpio pins is requested, request the pin of pinctrl driver first.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Tested-by: Igor Grinberg <grinberg@compulab.co.il>

> ---
>  drivers/gpio/gpio-pxa.c |   19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
> index 5c39db3..c9cc636 100644
> --- a/drivers/gpio/gpio-pxa.c
> +++ b/drivers/gpio/gpio-pxa.c
> @@ -23,6 +23,7 @@
>  #include <linux/io.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> +#include <linux/pinctrl/consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/syscore_ops.h>
>  #include <linux/slab.h>
> @@ -159,6 +160,23 @@ int pxa_irq_to_gpio(struct irq_data *d)
>  	return gpio;
>  }
>  
> +static int pxa_gpio_request(struct gpio_chip *gc, unsigned offset)
> +{
> +	/*
> +	 * Map back to global GPIO space and request muxing, the direction
> +	 * parameter does not matter for this controller.
> +	 */
> +	int gpio = gc->base + offset;
> +
> +	/*
> +	 * Platforms in ARCH_PXA doesn't move to device tree yet,
> +	 * and PINCTRL_SINGLE is depend on device tree.
> +	 */ 
> +	if (IS_ENABLED(CONFIG_PINCTRL_SINGLE))
> +		return pinctrl_request_gpio(gpio);
> +	return 0;
> +}
> +
>  static int pxa_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct pxa_gpio_chip *chip = NULL;
> @@ -471,6 +489,7 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end,
>  		gc->base  = gpio;
>  		gc->label = chips[i].label;
>  
> +		gc->request = pxa_gpio_request;
>  		gc->direction_input  = pxa_gpio_direction_input;
>  		gc->direction_output = pxa_gpio_direction_output;
>  		gc->get = pxa_gpio_get;
>
diff mbox

Patch

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 5c39db3..c9cc636 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -23,6 +23,7 @@ 
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/syscore_ops.h>
 #include <linux/slab.h>
@@ -159,6 +160,23 @@  int pxa_irq_to_gpio(struct irq_data *d)
 	return gpio;
 }
 
+static int pxa_gpio_request(struct gpio_chip *gc, unsigned offset)
+{
+	/*
+	 * Map back to global GPIO space and request muxing, the direction
+	 * parameter does not matter for this controller.
+	 */
+	int gpio = gc->base + offset;
+
+	/*
+	 * Platforms in ARCH_PXA doesn't move to device tree yet,
+	 * and PINCTRL_SINGLE is depend on device tree.
+	 */ 
+	if (IS_ENABLED(CONFIG_PINCTRL_SINGLE))
+		return pinctrl_request_gpio(gpio);
+	return 0;
+}
+
 static int pxa_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
 {
 	struct pxa_gpio_chip *chip = NULL;
@@ -471,6 +489,7 @@  static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end,
 		gc->base  = gpio;
 		gc->label = chips[i].label;
 
+		gc->request = pxa_gpio_request;
 		gc->direction_input  = pxa_gpio_direction_input;
 		gc->direction_output = pxa_gpio_direction_output;
 		gc->get = pxa_gpio_get;